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

Unified Diff: Source/core/frame/FrameView.cpp

Issue 164553004: Convert LayoutState/LayoutStateMaintainer/LayoutStateDisabler to references (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebase Created 6 years, 10 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
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/rendering/LayoutState.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/frame/FrameView.cpp
diff --git a/Source/core/frame/FrameView.cpp b/Source/core/frame/FrameView.cpp
index d0648ac7b1866531a539650d47a35fac35983920..0914c7bea778b20027844f74b3ab34050c89f095 100644
--- a/Source/core/frame/FrameView.cpp
+++ b/Source/core/frame/FrameView.cpp
@@ -104,6 +104,31 @@ static RenderLayer::UpdateLayerPositionsFlags updateLayerPositionFlags(RenderLay
return flags;
}
+class FrameViewLayoutStateMaintainer {
+ WTF_MAKE_NONCOPYABLE(FrameViewLayoutStateMaintainer);
+public:
+ FrameViewLayoutStateMaintainer(RenderObject& root)
+ : m_view(*root.view())
+ , m_disabled(m_view.frameView()->isSubtreeLayout() && m_view.shouldDisableLayoutStateForSubtree(root))
+ {
+ if (m_view.frameView()->isSubtreeLayout())
+ m_view.pushLayoutState(root);
+ if (m_disabled)
+ m_view.disableLayoutState();
+ }
+
+ ~FrameViewLayoutStateMaintainer()
+ {
+ if (m_disabled)
+ m_view.enableLayoutState();
+ if (m_view.frameView()->isSubtreeLayout())
+ m_view.popLayoutState();
+ }
+private:
+ RenderView& m_view;
+ bool m_disabled;
+};
+
FrameView::FrameView(Frame* frame)
: m_frame(frame)
, m_canHaveScrollbars(true)
@@ -766,17 +791,10 @@ void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay
// FIXME: The 300 other lines in layout() probably belong in other helper functions
// so that a single human could understand what layout() is actually doing.
- {
- bool disableLayoutState = false;
- if (inSubtreeLayout) {
- RenderView* view = rootForThisLayout->view();
- disableLayoutState = view->shouldDisableLayoutStateForSubtree(rootForThisLayout);
- view->pushLayoutState(rootForThisLayout);
- }
- LayoutStateDisabler layoutStateDisabler(disableLayoutState ? rootForThisLayout->view() : 0);
-
- forceLayoutParentViewIfNeeded();
+ FrameViewLayoutStateMaintainer statePusher(*rootForThisLayout);
+ forceLayoutParentViewIfNeeded();
+ {
// Text Autosizing requires two-pass layout which is incompatible with partial layout.
// If enabled, only do partial layout for the second layout.
// FIXME (crbug.com/256657): Do not do two layouts for text autosizing.
@@ -796,9 +814,6 @@ void FrameView::performLayout(RenderObject* rootForThisLayout, bool inSubtreeLay
gatherDebugLayoutRects(rootForThisLayout);
}
- if (inSubtreeLayout)
- rootForThisLayout->view()->popLayoutState(rootForThisLayout);
-
lifecycle().advanceTo(DocumentLifecycle::AfterPerformLayout);
}
« no previous file with comments | « Source/core/frame/FrameView.h ('k') | Source/core/rendering/LayoutState.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698