Index: Source/core/rendering/RenderView.cpp |
diff --git a/Source/core/rendering/RenderView.cpp b/Source/core/rendering/RenderView.cpp |
index 04eea08abaaf75c9f57665d7ec67d087b70ad1eb..ead2bdeca2936d5f00033132028ae2d42ad3c989 100644 |
--- a/Source/core/rendering/RenderView.cpp |
+++ b/Source/core/rendering/RenderView.cpp |
@@ -997,4 +997,83 @@ 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()); |
+ |
+ // 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; |
+ |
+ // If the height is decreasing and the view isn't vertically scrollable, fallback to |
+ // full layout to calculate the new layout overflow rect. |
+ LayoutRect layoutOverflow = layoutOverflowRect(); |
+ if (layoutOverflow.maxY() <= noOverflowRect().maxY() && viewHeight() < height()) |
+ return false; |
+ |
+ // Update style to ensure the following checks to access up-to-date styles. |
+ document().updateStyleIfNeeded(); |
Julien - ping for review
2014/03/11 01:23:37
Isn't this line contrary with the ASSERT above abo
Xianzhu
2014/03/11 19:05:13
Sorry. I added the code and later meant to move th
|
+ if (needsLayout()) |
+ 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)) |
+ return false; |
+ |
+ RenderStyle* childStyle = (*it)->style(); |
+ // Fixed position element may change compositing state when viewport height changes. |
+ if (childStyle->position() == FixedPosition) |
+ return false; |
Xianzhu
2014/03/11 19:05:13
Removed the above because fixed position layout ha
|
+ if (childStyle->top().isPercent() || childStyle->height().isPercent() || childStyle->minHeight().isPercent() || childStyle->maxHeight().isPercent() || !childStyle->bottom().isAuto()) |
+ return false; |
+ } |
+ } |
+ |
+ // Do a simplified layout on height change. |
+ setHeight(viewHeight()); |
+ |
+ // During a normal layout, change of height may cause creating or destroying the overflow. |
+ // The following code mimics the normal layout for overflow. |
+ m_overflow.clear(); |
+ addLayoutOverflow(layoutOverflow); |
Julien - ping for review
2014/03/11 01:23:37
It's weird that you don't also add visual overflow
Xianzhu
2014/03/11 19:05:13
Actually I didn't notice it, so for cases needing
|
+ |
+ // FIXME: There may be a more efficient way to adjust the size of the root layer. |
+ layer()->updateLayerPositionsAfterLayout(layer(), RenderLayer::defaultFlags); |
Julien - ping for review
2014/03/11 01:23:37
updateLayerPositions will recurse into all the lay
Xianzhu
2014/03/11 19:05:13
The repaints caused by layer resizing and exposing
|
+ |
+ return true; |
+} |
+ |
} // namespace WebCore |