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

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

Issue 196533012: Make LayoutState always be RAII (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Updated to ToT Created 6 years, 9 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/rendering/RenderVTTCue.cpp ('k') | Source/core/rendering/RenderView.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/RenderView.h
diff --git a/Source/core/rendering/RenderView.h b/Source/core/rendering/RenderView.h
index 348568d58938962ba287d08afce4adfeb97ec336..b4e790928c8667f3fc2ac7822c201d74ae42255b 100644
--- a/Source/core/rendering/RenderView.h
+++ b/Source/core/rendering/RenderView.h
@@ -226,9 +226,9 @@ private:
return false;
}
- void layoutContent(const LayoutState&);
+ void layoutContent();
#ifndef NDEBUG
- void checkLayoutState(const LayoutState&);
+ void checkLayoutState();
#endif
void positionDialog(RenderBox*);
@@ -239,6 +239,7 @@ private:
friend class LayoutStateMaintainer;
friend class LayoutStateDisabler;
+ friend class RootLayoutStateScope;
bool shouldUsePrintingLayout() const;
@@ -264,6 +265,27 @@ private:
DEFINE_RENDER_OBJECT_TYPE_CASTS(RenderView, isRenderView());
+class RootLayoutStateScope {
+public:
+ explicit RootLayoutStateScope(RenderView& view)
+ : m_view(view)
+ {
+ ASSERT(!m_view.m_layoutState);
+ initializeLayoutState();
+ m_view.m_layoutState = &m_rootLayoutState;
+ }
+
+ ~RootLayoutStateScope()
+ {
+ ASSERT(m_view.m_layoutState == &m_rootLayoutState);
+ m_view.m_layoutState = 0;
+ }
+private:
+ void initializeLayoutState();
+ RenderView& m_view;
+ LayoutState m_rootLayoutState;
+};
+
// Stack-based class to assist with LayoutState push/pop
class LayoutStateMaintainer {
WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer);
@@ -291,6 +313,8 @@ public:
~LayoutStateMaintainer()
{
+ if (m_didStart)
+ pop();
ASSERT(m_didStart == m_didEnd); // if this fires, it means that someone did a push(), but forgot to pop().
}
@@ -304,23 +328,21 @@ public:
m_didStart = true;
}
+ bool didPush() const { return m_didStart; }
+
+private:
void pop()
{
- if (m_didStart) {
- ASSERT(!m_didEnd);
- if (m_didCreateLayoutState) {
- m_view.popLayoutState();
- if (m_disabled)
- m_view.enableLayoutState();
- }
-
- m_didEnd = true;
+ ASSERT(m_didStart && !m_didEnd);
+ if (m_didCreateLayoutState) {
+ m_view.popLayoutState();
+ if (m_disabled)
+ m_view.enableLayoutState();
}
- }
- bool didPush() const { return m_didStart; }
+ m_didEnd = true;
+ }
-private:
RenderView& m_view;
bool m_disabled : 1; // true if the offset and clip part of layoutState is disabled
bool m_didStart : 1; // true if we did a push or disable
« no previous file with comments | « Source/core/rendering/RenderVTTCue.cpp ('k') | Source/core/rendering/RenderView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698