File indexing completed on 2024-05-05 16:10:18
0001 /* 0002 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 0003 * 0004 * Redistribution and use in source and binary forms, with or without 0005 * modification, are permitted provided that the following conditions 0006 * are met: 0007 * 1. Redistributions of source code must retain the above copyright 0008 * notice, this list of conditions and the following disclaimer. 0009 * 2. Redistributions in binary form must reproduce the above copyright 0010 * notice, this list of conditions and the following disclaimer in the 0011 * documentation and/or other materials provided with the distribution. 0012 * 0013 * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY 0014 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0015 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 0016 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR 0017 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 0018 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, 0019 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR 0020 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY 0021 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 0022 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 0023 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 0024 */ 0025 0026 #include "HTMLVideoElement.h" 0027 0028 #include "HTMLDocument.h" 0029 #include <rendering/render_media.h> 0030 0031 namespace khtml 0032 { 0033 0034 HTMLVideoElement::HTMLVideoElement(Document *doc) 0035 : HTMLMediaElement(doc) 0036 { 0037 } 0038 0039 DOM::NodeImpl::Id HTMLVideoElement::id() const 0040 { 0041 return ID_VIDEO; 0042 } 0043 0044 int HTMLVideoElement::videoWidth() const 0045 { 0046 if (!m_player) { 0047 return 0; 0048 } 0049 if (m_player->mediaObject()->hasVideo()) { 0050 return m_player->videoWidget()->sizeHint().width(); 0051 } else { 0052 return 0; 0053 } 0054 } 0055 0056 int HTMLVideoElement::videoHeight() const 0057 { 0058 if (!m_player) { 0059 return 0; 0060 } 0061 if (m_player->mediaObject()->hasVideo()) { 0062 return m_player->videoWidget()->sizeHint().height(); 0063 } else { 0064 return 0; 0065 } 0066 } 0067 0068 int HTMLVideoElement::width() const 0069 { 0070 bool ok; 0071 int w = getAttribute(ATTR_WIDTH).toInt(&ok); 0072 return ok ? w : 0; 0073 } 0074 0075 void HTMLVideoElement::setWidth(int value) 0076 { 0077 setAttribute(ATTR_WIDTH, QString::number(value)); 0078 } 0079 0080 int HTMLVideoElement::height() const 0081 { 0082 bool ok; 0083 int h = getAttribute(ATTR_HEIGHT).toInt(&ok); 0084 return ok ? h : 0; 0085 } 0086 0087 void HTMLVideoElement::setHeight(int value) 0088 { 0089 setAttribute(ATTR_HEIGHT, QString::number(value)); 0090 } 0091 0092 DOMString HTMLVideoElement::poster() const 0093 { 0094 return document()->completeURL(getAttribute(ATTR_POSTER).string()); 0095 } 0096 0097 void HTMLVideoElement::setPoster(const DOMString &value) 0098 { 0099 setAttribute(ATTR_POSTER, value); 0100 } 0101 0102 }