diff options
author | Patrick Scott <> | 2009-04-08 11:18:09 -0700 |
---|---|---|
committer | The Android Open Source Project <initial-contribution@android.com> | 2009-04-08 11:18:09 -0700 |
commit | 1c8ef8b292e4eb8c03ce782b1ae6f6154d1d3db8 (patch) | |
tree | 8a107468d8411ebbbd6e46a9e9edab8b95871889 | |
parent | 05f9657eb2c4baad54f87aa1f9dd9b51c5a6d149 (diff) | |
download | external_webkit-1c8ef8b292e4eb8c03ce782b1ae6f6154d1d3db8.zip external_webkit-1c8ef8b292e4eb8c03ce782b1ae6f6154d1d3db8.tar.gz external_webkit-1c8ef8b292e4eb8c03ce782b1ae6f6154d1d3db8.tar.bz2 |
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
-rw-r--r-- | WebCore/rendering/RenderPartObject.cpp | 68 | ||||
-rw-r--r-- | 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<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(); + + // 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<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(); + 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); |