Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1532)

Unified Diff: Source/core/rendering/RenderView.cpp

Issue 99663004: Avoid layout/full-repaint on view height change if possible (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: We have Document::hasViewportUnits() now Created 6 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/rendering/RenderView.cpp
diff --git a/Source/core/rendering/RenderView.cpp b/Source/core/rendering/RenderView.cpp
index cc1be67964c43f88cdfddff09b90bfaf0426367c..af733218b66dbf958a2f251d4bda45449b86d550 100644
--- a/Source/core/rendering/RenderView.cpp
+++ b/Source/core/rendering/RenderView.cpp
@@ -1222,6 +1222,65 @@ double RenderView::layoutViewportHeight() const
return viewHeight(ScrollableArea::IncludeScrollbars) / scale;
}
+void RenderView::viewResized()
+{
+ if (logicalWidth() != viewLogicalWidth() || needsLayoutOnLogicalHeightChange()) {
+ setNeedsLayout();
+ } else if (!needsLayout()) {
+ setLogicalHeight(viewLogicalHeight());
+ if (m_overflow)
+ m_overflow->setVisualOverflow(borderBoxRect());
+ layer()->updateLayerPositionsAfterLayout(layer(), RenderLayer::defaultFlags);
+ }
+}
+
+bool RenderView::needsLayoutOnLogicalHeightChange() const
+{
+ // 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.
+
+ if (document().inQuirksMode() || document().paginated() || shouldUsePrintingLayout())
+ return true;
+
+ // Optimize layout in horizontal writing mode only to simplify the logic.
+ if (!style()->isHorizontalWritingMode())
+ return true;
+
+ if (hasPercentHeightDescendants())
+ return true;
+
+ if (document().ensureStyleResolver().mediaQueryAffectedByViewportChange() || document().hasViewportUnits())
+ return true;
+
+ // Needs layout if there is no body element (e.g. there is frameset).
+ Element* body = document().body();
+ if (!body || !body->hasTagName(HTMLNames::bodyTag))
+ return true;
+
+ // 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 true;
+
+ 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 true;
+
+ RenderStyle* childStyle = (*it)->style();
+ // Fixed position element may change compositing state when viewport height changes.
+ if (childStyle->position() == FixedPosition)
+ return true;
+ if (childStyle->top().isPercent() || childStyle->height().isPercent() || childStyle->minHeight().isPercent() || childStyle->maxHeight().isPercent() || !childStyle->bottom().isAuto())
+ return true;
+ }
+ }
+
+ return false;
+}
+
FragmentationDisabler::FragmentationDisabler(RenderObject* root)
{
RenderView* renderView = root->view();

Powered by Google App Engine
This is Rietveld 408576698