Chromium Code Reviews| Index: Source/core/rendering/RenderView.cpp |
| diff --git a/Source/core/rendering/RenderView.cpp b/Source/core/rendering/RenderView.cpp |
| index 04eea08abaaf75c9f57665d7ec67d087b70ad1eb..059c39b7bb81a7bdea78b04b88203a870c8000ee 100644 |
| --- a/Source/core/rendering/RenderView.cpp |
| +++ b/Source/core/rendering/RenderView.cpp |
| @@ -997,4 +997,80 @@ double RenderView::layoutViewportHeight() const |
| return viewHeight(IncludeScrollbars) / scale; |
| } |
| +bool RenderView::trySimplifiedLayoutOnHeightChange() |
| +{ |
| + // FIXME: Move logics that are generic to RenderBox or RenderBlock into these classes |
| + // so that this function can be also used to optimize layout of them. |
| + |
| + // The style must be up-to-date. |
| + ASSERT(!document().needsStyleRecalc() && !document().childNeedsStyleRecalc()); |
|
esprehn
2014/03/15 02:19:42
This is not correct, you need to check !document()
|
| + |
| + // Don't need to check viewport media queries or viewport sizes here, because they are |
| + // handled before and during style recalc which should happen before this function is called. |
| + |
| + // Quicks mode has different layout rules on view size change, e.g. the height of <body> and |
| + // percent height descendants etc. To avoid simplified layout from being too complex, fallback |
| + // to full layout. |
| + if (document().inQuirksMode()) |
| + return false; |
| + |
| + if (document().paginated() || shouldUsePrintingLayout()) |
| + return false; |
| + |
| + // Optimize layout in horizontal writing mode only to simplify the logic. |
| + if (!style()->isHorizontalWritingMode()) |
| + return false; |
| + |
| + if (hasPercentHeightDescendants()) |
| + return false; |
| + |
| + // Needs full layout if there is no body element (e.g. there is frameset whose layout is almost always |
| + // affected by the view size. |
| + Element* body = document().body(); |
| + if (!body || !body->hasTagName(HTMLNames::bodyTag)) |
| + return false; |
| + |
| + // Root background image may be stretched related to the viewport size. |
| + Element* documentElement = document().documentElement(); |
| + if (!documentElement || !documentElement->renderer() |
| + || documentElement->renderer()->rendererForRootBackground()->style()->hasBackgroundImage()) |
| + return false; |
| + |
| + if (TrackedRendererListHashSet* positionedObjects = this->positionedObjects()) { |
| + TrackedRendererListHashSet::iterator end = positionedObjects->end(); |
| + for (TrackedRendererListHashSet::iterator it = positionedObjects->begin(); it != end; ++it) { |
| + if ((*it)->node() && (*it)->node()->hasTagName(HTMLNames::dialogTag)) |
|
esprehn
2014/03/15 02:19:42
Special casing dialog is wrong, why are you doing
|
| + return false; |
| + |
| + RenderStyle* childStyle = (*it)->style(); |
| + if (childStyle->top().isPercent() || childStyle->height().isPercent() || childStyle->minHeight().isPercent() || childStyle->maxHeight().isPercent() || !childStyle->bottom().isAuto()) |
|
esprehn
2014/03/15 02:19:42
This should be a method, the check is really hard
|
| + return false; |
| + } |
| + } |
| + |
| + // Do a simplified layout on height change. |
| + |
| + // If the height is decreasing and the view isn't vertically scrollable, we need to recompute the overflow. |
| + LayoutRect layoutOverflow = layoutOverflowRect(); |
| + bool needsRecomputeOverflow = layoutOverflow.maxY() <= noOverflowRect().maxY() && viewHeight() < height(); |
| + |
| + setHeight(viewHeight()); |
| + |
| + if (needsRecomputeOverflow) { |
| + LayoutUnit oldClientAfterEdge = hasRenderOverflow() ? m_overflow->layoutClientAfterEdge() : clientLogicalBottom(); |
| + computeOverflow(oldClientAfterEdge, false); |
| + } else { |
| + // Size of layout overflow is unchanged. However change of height may cause creating or destroying m_overflow. |
| + // following code mimics the normal layout for overflow. |
| + // Visual overflow will be automatically updated when m_overflow is recreated when needed in addLayoutOverflow(). |
| + m_overflow.clear(); |
| + addLayoutOverflow(layoutOverflow); |
| + } |
| + |
| + // FIXME: There may be a more efficient way to resize the root layer and repaint the exposed area. |
| + layer()->updateLayerPositionsAfterLayout(layer(), RenderLayer::defaultFlags); |
| + |
| + return true; |
| +} |
| + |
| } // namespace WebCore |