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

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: Protect the feature with a runtime flag Created 7 years 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 05955691af573fc99f2d0102d0b46c6a62b72e2f..8ffd652405448c4ee3b09a4286fdd5016152e979 100644
--- a/Source/core/rendering/RenderView.cpp
+++ b/Source/core/rendering/RenderView.cpp
@@ -1235,6 +1235,56 @@ LayoutUnit RenderView::viewportPercentageMax(float percentage) const
* percentage / 100.f;
}
+void RenderView::viewResized()
+{
+ if (!RuntimeEnabledFeatures::optimizedLayoutOnViewHeightChangeEnabled() || width() != viewWidth() || needsLayoutOnHeightChange()) {
ojan 2013/12/18 00:48:20 I don't think we need to add a RuntimeEnabledFeatu
Xianzhu 2013/12/18 20:22:45 Yes. I added the flag because I was afraid of the
+ setNeedsLayout();
+ } else {
+ setHeight(viewHeight());
+ if (m_overflow)
+ m_overflow->setVisualOverflow(borderBoxRect());
+ layer()->updateLayerPositionsAfterLayout(layer(), RenderLayer::defaultFlags);
+ }
+}
+
+bool RenderView::needsLayoutOnHeightChange() const
ojan 2013/12/18 00:48:20 This misses a number of cases. For example, if the
Xianzhu 2013/12/18 20:22:45 Thanks for the case. Will add them.
+{
+ if (!style()->isHorizontalWritingMode() || hasPercentHeightDescendants() || document().paginated())
+ return true;
+
+ if (!document().styleResolver() || document().styleResolver()->affectedByViewportChange())
ojan 2013/12/18 00:48:20 It's not uncommon that we destroy the styleResolve
+ return true;
+
+ // Needs layout if there is no body element (e.g. there is frameset).
+ Element* body = document().body();
+ if (!body || !body->renderer() || !body->renderer()->isBody())
ojan 2013/12/18 00:48:20 I don't think you need this case. We'll do a layou
Xianzhu 2013/12/18 20:22:45 My intention was to exclude the frameset case whic
+ return true;
+
+ Element* documentElement = document().documentElement();
+ if (RenderObject* rootRenderer = documentElement ? documentElement->renderer() : 0) {
+ // Background image may be stretched related to the viewport size.
+ if (rootRenderer->rendererForRootBackground()->style()->hasBackgroundImage())
+ return true;
+ } else {
+ return true;
+ }
+
+ TrackedRendererListHashSet* positionedDescendants = positionedObjects();
+ if (positionedDescendants) {
+ TrackedRendererListHashSet::iterator end = positionedDescendants->end();
+ for (TrackedRendererListHashSet::iterator it = positionedDescendants->begin(); it != end; ++it) {
+ RenderStyle* style = (*it)->style();
+ // Fixed position element may change compositing state when viewport height changes.
+ if (style->position() == FixedPosition)
+ return true;
+ if (style->top().isPercent() || style->height().isPercent() || style->maxHeight().isPercent() || !style->bottom().isAuto())
+ return true;
+ }
+ }
+
+ return false;
+}
+
FragmentationDisabler::FragmentationDisabler(RenderObject* root)
{
RenderView* renderView = root->view();

Powered by Google App Engine
This is Rietveld 408576698