diff options
Diffstat (limited to 'WebCore/rendering/RenderPartObject.cpp')
-rw-r--r-- | WebCore/rendering/RenderPartObject.cpp | 138 |
1 files changed, 116 insertions, 22 deletions
diff --git a/WebCore/rendering/RenderPartObject.cpp b/WebCore/rendering/RenderPartObject.cpp index 86cb2ad..47a5954 100644 --- a/WebCore/rendering/RenderPartObject.cpp +++ b/WebCore/rendering/RenderPartObject.cpp @@ -34,21 +34,21 @@ #include "HTMLNames.h" #include "HTMLObjectElement.h" #include "HTMLParamElement.h" +#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) +#include "HTMLMediaElement.h" +#include "HTMLVideoElement.h" +#endif #include "MIMETypeRegistry.h" #include "Page.h" #include "PluginData.h" #include "RenderView.h" #include "Text.h" -#ifdef FLATTEN_IFRAME -#include "RenderView.h" -#endif - namespace WebCore { using namespace HTMLNames; -RenderPartObject::RenderPartObject(HTMLFrameOwnerElement* element) +RenderPartObject::RenderPartObject(Element* element) : RenderPart(element) { // init RenderObject attributes @@ -132,10 +132,17 @@ static String serviceTypeForClassId(const String& classId, const PluginData* plu static inline bool shouldUseEmbedDescendant(HTMLObjectElement* objectElement, const PluginData* pluginData) { +#if PLATFORM(MAC) + UNUSED_PARAM(objectElement); + UNUSED_PARAM(pluginData); + // On Mac, we always want to use the embed descendant. + return true; +#else // If we have both an <object> and <embed>, we always want to use the <embed> except when we have // an ActiveX plug-in and plan to use it. return !(havePlugin(pluginData, activeXType()) && serviceTypeForClassId(objectElement->classId(), pluginData) == activeXType()); +#endif } void RenderPartObject::updateWidget(bool onlyCreateNonNetscapePlugins) @@ -146,8 +153,8 @@ void RenderPartObject::updateWidget(bool onlyCreateNonNetscapePlugins) Vector<String> paramValues; Frame* frame = m_view->frame(); - if (element()->hasTagName(objectTag)) { - HTMLObjectElement* o = static_cast<HTMLObjectElement*>(element()); + if (node()->hasTagName(objectTag)) { + HTMLObjectElement* o = static_cast<HTMLObjectElement*>(node()); o->setNeedWidgetUpdate(false); if (!o->isFinishedParsingChildren()) @@ -261,8 +268,8 @@ void RenderPartObject::updateWidget(bool onlyCreateNonNetscapePlugins) bool success = frame->loader()->requestObject(this, url, AtomicString(o->name()), serviceType, paramNames, paramValues); if (!success && m_hasFallbackContent) o->renderFallbackContent(); - } else if (element()->hasTagName(embedTag)) { - HTMLEmbedElement *o = static_cast<HTMLEmbedElement*>(element()); + } else if (node()->hasTagName(embedTag)) { + HTMLEmbedElement *o = static_cast<HTMLEmbedElement*>(node()); o->setNeedWidgetUpdate(false); url = o->url(); serviceType = o->serviceType(); @@ -294,16 +301,39 @@ void RenderPartObject::updateWidget(bool onlyCreateNonNetscapePlugins) frame->loader()->requestObject(this, url, o->getAttribute(nameAttr), serviceType, paramNames, paramValues); } +#if ENABLE(PLUGIN_PROXY_FOR_VIDEO) + else if (node()->hasTagName(videoTag) || node()->hasTagName(audioTag)) { + HTMLMediaElement* o = static_cast<HTMLMediaElement*>(node()); + + o->setNeedWidgetUpdate(false); + if (node()->hasTagName(videoTag)) { + HTMLVideoElement* vid = static_cast<HTMLVideoElement*>(node()); + String poster = vid->poster(); + if (!poster.isEmpty()) { + paramNames.append("_media_element_poster_"); + paramValues.append(poster); + } + } + + url = o->initialURL(); + if (!url.isEmpty()) { + paramNames.append("_media_element_src_"); + paramValues.append(url); + } + + serviceType = "application/x-media-element-proxy-plugin"; + frame->loader()->requestObject(this, url, nullAtom, serviceType, paramNames, paramValues); + } +#endif } void RenderPartObject::layout() { ASSERT(needsLayout()); - calcWidth(); - calcHeight(); - #ifdef FLATTEN_IFRAME + RenderPart::calcWidth(); + RenderPart::calcHeight(); // Some IFrames have a width and/or height of 1 when they are meant to be // hidden. If that is the case, don't try to expand. int w = width(); @@ -319,10 +349,11 @@ void RenderPartObject::layout() // Update the dimensions to get the correct minimum preferred width updateWidgetPosition(); - // Use the preferred width if it is larger. - setWidth(max(w, root->minPrefWidth())); int extraWidth = paddingLeft() + paddingRight() + borderLeft() + borderRight(); int extraHeight = paddingTop() + paddingBottom() + borderTop() + borderBottom(); + // Use the preferred width if it is larger. + setWidth(max(w, root->minPrefWidth()) + extraWidth); + // Resize the view to recalc the height. int height = h - extraHeight; int width = w - extraWidth; @@ -337,14 +368,21 @@ void RenderPartObject::layout() view->layout(); int contentHeight = view->contentsHeight(); int contentWidth = view->contentsWidth(); - // Do not shrink iframes with specified sizes - if (contentHeight > h || style()->height().isAuto()) - setHeight(contentHeight); - setWidth(std::min(contentWidth, 800)); + // Do not shrink iframes with a specified height. + if (contentHeight > (h - extraHeight) || style()->height().isAuto()) + setHeight(contentHeight + extraHeight); + setWidth(contentWidth + extraWidth); + + // Update one last time + updateWidgetPosition(); } } +#else + calcWidth(); + calcHeight(); #endif - adjustOverflowForBoxShadow(); + + adjustOverflowForBoxShadowAndReflect(); RenderPart::layout(); @@ -354,14 +392,70 @@ void RenderPartObject::layout() setNeedsLayout(false); } +#ifdef FLATTEN_IFRAME +void RenderPartObject::calcWidth() { + RenderPart::calcWidth(); + if (!m_widget || !m_widget->isFrameView()) + return; + FrameView* view = static_cast<FrameView*>(m_widget); + RenderView* root = static_cast<RenderView*>(view->frame()->contentRenderer()); + if (!root) + return; + // Update the dimensions to get the correct minimum preferred + // width + updateWidgetPosition(); + + int extraWidth = paddingLeft() + paddingRight() + borderLeft() + borderRight(); + // Set the width + setWidth(max(width(), root->minPrefWidth()) + extraWidth); + + // Update based on the new width + updateWidgetPosition(); + + // Layout to get the content width + while (view->needsLayout()) + view->layout(); + + setWidth(view->contentsWidth() + extraWidth); + + // Update one last time to ensure the dimensions. + updateWidgetPosition(); +} + +void RenderPartObject::calcHeight() { + RenderPart::calcHeight(); + if (!m_widget || !m_widget->isFrameView()) + return; + FrameView* view = static_cast<FrameView*>(m_widget); + RenderView* root = static_cast<RenderView*>(view->frame()->contentRenderer()); + if (!root) + return; + // Update the widget + updateWidgetPosition(); + + // Layout to get the content height + while (view->needsLayout()) + view->layout(); + + // Do not shrink the height if the size is specified + int h = view->contentsHeight(); + int extraHeight = paddingTop() + paddingBottom() + borderTop() + borderBottom(); + if (h > height() - extraHeight || style()->height().isAuto()) + setHeight(h + extraHeight); + + // Update one last time to ensure the dimensions. + updateWidgetPosition(); +} +#endif + void RenderPartObject::viewCleared() { - if (element() && m_widget && m_widget->isFrameView()) { + if (node() && m_widget && m_widget->isFrameView()) { FrameView* view = static_cast<FrameView*>(m_widget); int marginw = -1; int marginh = -1; - if (element()->hasTagName(iframeTag)) { - HTMLIFrameElement* frame = static_cast<HTMLIFrameElement*>(element()); + if (node()->hasTagName(iframeTag)) { + HTMLIFrameElement* frame = static_cast<HTMLIFrameElement*>(node()); marginw = frame->getMarginWidth(); marginh = frame->getMarginHeight(); } |