From 1c8ef8b292e4eb8c03ce782b1ae6f6154d1d3db8 Mon Sep 17 00:00:00 2001 From: Patrick Scott <> Date: Wed, 8 Apr 2009 11:18:09 -0700 Subject: AI 145074: Override calcWidth and calcHeight to compute the content dimensions. This fixes a few calls to calcWidth/calcHeight without doing a layout. BUG=1360169 Automated import of CL 145074 --- WebCore/rendering/RenderPartObject.cpp | 68 ++++++++++++++++++++++++++++++++-- WebCore/rendering/RenderPartObject.h | 4 ++ 2 files changed, 68 insertions(+), 4 deletions(-) diff --git a/WebCore/rendering/RenderPartObject.cpp b/WebCore/rendering/RenderPartObject.cpp index 86cb2ad..4df631f 100644 --- a/WebCore/rendering/RenderPartObject.cpp +++ b/WebCore/rendering/RenderPartObject.cpp @@ -300,10 +300,9 @@ 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(); @@ -340,10 +339,17 @@ void RenderPartObject::layout() // Do not shrink iframes with specified sizes if (contentHeight > h || style()->height().isAuto()) setHeight(contentHeight); - setWidth(std::min(contentWidth, 800)); + setWidth(contentWidth); + + // Update one last time + updateWidgetPosition(); } } +#else + calcWidth(); + calcHeight(); #endif + adjustOverflowForBoxShadow(); RenderPart::layout(); @@ -354,6 +360,60 @@ void RenderPartObject::layout() setNeedsLayout(false); } +#ifdef FLATTEN_IFRAME +void RenderPartObject::calcWidth() { + RenderPart::calcWidth(); + if (!m_widget || !m_widget->isFrameView()) + return; + FrameView* view = static_cast(m_widget); + RenderView* root = static_cast(view->frame()->contentRenderer()); + if (!root) + return; + // Update the dimensions to get the correct minimum preferred + // width + updateWidgetPosition(); + + // Set the width + setWidth(max(width(), root->minPrefWidth())); + + // Update based on the new width + updateWidgetPosition(); + + // Layout to get the content width + while (view->needsLayout()) + view->layout(); + + setWidth(view->contentsWidth()); + + // 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(m_widget); + RenderView* root = static_cast(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(); + if (h > height() || style()->height().isAuto()) + setHeight(h); + + // Update one last time to ensure the dimensions. + updateWidgetPosition(); +} +#endif + void RenderPartObject::viewCleared() { if (element() && m_widget && m_widget->isFrameView()) { diff --git a/WebCore/rendering/RenderPartObject.h b/WebCore/rendering/RenderPartObject.h index 98de5b9..2b21644 100644 --- a/WebCore/rendering/RenderPartObject.h +++ b/WebCore/rendering/RenderPartObject.h @@ -36,6 +36,10 @@ public: virtual const char* renderName() const { return "RenderPartObject"; } +#ifdef FLATTEN_IFRAME + virtual void calcWidth(); + virtual void calcHeight(); +#endif virtual void layout(); void updateWidget(bool onlyCreateNonNetscapePlugins); -- cgit v1.1