- Revision
- 224461
- Author
- [email protected]
- Date
- 2017-11-04 15:02:39 -0700 (Sat, 04 Nov 2017)
Log Message
[LayoutState cleanup] Move all LayoutState* classes to LayoutState.h/cpp
https://bugs.webkit.org/show_bug.cgi?id=179280
<rdar://problem/35348452>
Reviewed by Antti Koivisto.
No change in functionality.
* page/LayoutContext.cpp:
(WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer): Deleted.
(WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer): Deleted.
(WebCore::SubtreeLayoutStateMaintainer::shouldDisableLayoutStateForSubtree): Deleted.
* rendering/LayoutState.cpp:
(WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
(WebCore::LayoutStateMaintainer::~LayoutStateMaintainer):
(WebCore::LayoutStateMaintainer::push):
(WebCore::LayoutStateMaintainer::pop):
(WebCore::LayoutStateDisabler::LayoutStateDisabler):
(WebCore::LayoutStateDisabler::~LayoutStateDisabler):
(WebCore::shouldDisableLayoutStateForSubtree):
(WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer):
(WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer):
(WebCore::PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer):
(WebCore::PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer):
* rendering/LayoutState.h:
(WebCore::LayoutStateMaintainer::didPush const):
* rendering/RenderBlockFlow.cpp:
(WebCore::PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer): Deleted.
(WebCore::PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer): Deleted.
(): Deleted.
* rendering/RenderView.h:
(WebCore::LayoutStateMaintainer::LayoutStateMaintainer): Deleted.
(WebCore::LayoutStateMaintainer::~LayoutStateMaintainer): Deleted.
(WebCore::LayoutStateMaintainer::push): Deleted.
(WebCore::LayoutStateMaintainer::pop): Deleted.
(WebCore::LayoutStateMaintainer::didPush const): Deleted.
(WebCore::LayoutStateDisabler::LayoutStateDisabler): Deleted.
(WebCore::LayoutStateDisabler::~LayoutStateDisabler): Deleted.
Modified Paths
Diff
Modified: trunk/Source/WebCore/ChangeLog (224460 => 224461)
--- trunk/Source/WebCore/ChangeLog 2017-11-04 21:41:10 UTC (rev 224460)
+++ trunk/Source/WebCore/ChangeLog 2017-11-04 22:02:39 UTC (rev 224461)
@@ -1,5 +1,46 @@
2017-11-04 Zalan Bujtas <[email protected]>
+ [LayoutState cleanup] Move all LayoutState* classes to LayoutState.h/cpp
+ https://bugs.webkit.org/show_bug.cgi?id=179280
+ <rdar://problem/35348452>
+
+ Reviewed by Antti Koivisto.
+
+ No change in functionality.
+
+ * page/LayoutContext.cpp:
+ (WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer): Deleted.
+ (WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer): Deleted.
+ (WebCore::SubtreeLayoutStateMaintainer::shouldDisableLayoutStateForSubtree): Deleted.
+ * rendering/LayoutState.cpp:
+ (WebCore::LayoutStateMaintainer::LayoutStateMaintainer):
+ (WebCore::LayoutStateMaintainer::~LayoutStateMaintainer):
+ (WebCore::LayoutStateMaintainer::push):
+ (WebCore::LayoutStateMaintainer::pop):
+ (WebCore::LayoutStateDisabler::LayoutStateDisabler):
+ (WebCore::LayoutStateDisabler::~LayoutStateDisabler):
+ (WebCore::shouldDisableLayoutStateForSubtree):
+ (WebCore::SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer):
+ (WebCore::SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer):
+ (WebCore::PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer):
+ (WebCore::PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer):
+ * rendering/LayoutState.h:
+ (WebCore::LayoutStateMaintainer::didPush const):
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer): Deleted.
+ (WebCore::PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer): Deleted.
+ (): Deleted.
+ * rendering/RenderView.h:
+ (WebCore::LayoutStateMaintainer::LayoutStateMaintainer): Deleted.
+ (WebCore::LayoutStateMaintainer::~LayoutStateMaintainer): Deleted.
+ (WebCore::LayoutStateMaintainer::push): Deleted.
+ (WebCore::LayoutStateMaintainer::pop): Deleted.
+ (WebCore::LayoutStateMaintainer::didPush const): Deleted.
+ (WebCore::LayoutStateDisabler::LayoutStateDisabler): Deleted.
+ (WebCore::LayoutStateDisabler::~LayoutStateDisabler): Deleted.
+
+2017-11-04 Zalan Bujtas <[email protected]>
+
[LayoutState cleanup] Move offset/cliprect/pagination code to dedicate methods
https://bugs.webkit.org/show_bug.cgi?id=179279
<rdar://problem/35348171>
Modified: trunk/Source/WebCore/page/LayoutContext.cpp (224460 => 224461)
--- trunk/Source/WebCore/page/LayoutContext.cpp 2017-11-04 21:41:10 UTC (rev 224460)
+++ trunk/Source/WebCore/page/LayoutContext.cpp 2017-11-04 22:02:39 UTC (rev 224461)
@@ -51,45 +51,6 @@
return false;
}
-class SubtreeLayoutStateMaintainer {
-public:
- SubtreeLayoutStateMaintainer(RenderElement* subtreeLayoutRoot)
- : m_subtreeLayoutRoot(subtreeLayoutRoot)
- {
- if (m_subtreeLayoutRoot) {
- RenderView& view = m_subtreeLayoutRoot->view();
- view.pushLayoutState(*m_subtreeLayoutRoot);
- if (shouldDisableLayoutStateForSubtree()) {
- view.disableLayoutState();
- m_didDisableLayoutState = true;
- }
- }
- }
-
- ~SubtreeLayoutStateMaintainer()
- {
- if (m_subtreeLayoutRoot) {
- RenderView& view = m_subtreeLayoutRoot->view();
- view.popLayoutState(*m_subtreeLayoutRoot);
- if (m_didDisableLayoutState)
- view.enableLayoutState();
- }
- }
-
- bool shouldDisableLayoutStateForSubtree()
- {
- for (auto* renderer = m_subtreeLayoutRoot; renderer; renderer = renderer->container()) {
- if (renderer->hasTransform() || renderer->hasReflection())
- return true;
- }
- return false;
- }
-
-private:
- RenderElement* m_subtreeLayoutRoot { nullptr };
- bool m_didDisableLayoutState { false };
-};
-
#ifndef NDEBUG
class RenderTreeNeedsLayoutChecker {
public :
Modified: trunk/Source/WebCore/rendering/LayoutState.cpp (224460 => 224461)
--- trunk/Source/WebCore/rendering/LayoutState.cpp 2017-11-04 21:41:10 UTC (rev 224460)
+++ trunk/Source/WebCore/rendering/LayoutState.cpp 2017-11-04 22:02:39 UTC (rev 224461)
@@ -208,5 +208,102 @@
m_lineGridOffset = m_layoutOffset;
}
+LayoutStateMaintainer::LayoutStateMaintainer(RenderBox& root, LayoutSize offset, bool disableState, LayoutUnit pageHeight, bool pageHeightChanged)
+ : m_view(root.view())
+ , m_disabled(disableState)
+{
+ push(root, offset, pageHeight, pageHeightChanged);
+}
+
+LayoutStateMaintainer::LayoutStateMaintainer(RenderView& view)
+ : m_view(view)
+{
+}
+
+LayoutStateMaintainer::~LayoutStateMaintainer()
+{
+ ASSERT(!m_didCallPush || m_didCallPush == m_didCallPop);
+}
+
+void LayoutStateMaintainer::push(RenderBox& root, LayoutSize offset, LayoutUnit pageHeight, bool pageHeightChanged)
+{
+ ASSERT(!m_didCallPush);
+ m_didCallPush = true;
+ // We push state even if disabled, because we still need to store layoutDelta
+ m_didPushLayoutState = m_view.pushLayoutState(root, offset, pageHeight, pageHeightChanged);
+ if (!m_didPushLayoutState)
+ return;
+ if (m_disabled)
+ m_view.disableLayoutState();
+}
+
+void LayoutStateMaintainer::pop()
+{
+ ASSERT(!m_didCallPop);
+ m_didCallPop = true;
+ if (!m_didCallPush)
+ return;
+ if (!m_didPushLayoutState)
+ return;
+ m_view.popLayoutState();
+ if (m_disabled)
+ m_view.enableLayoutState();
+}
+
+LayoutStateDisabler::LayoutStateDisabler(RenderView& view)
+ : m_view(view)
+{
+ m_view.disableLayoutState();
+}
+
+LayoutStateDisabler::~LayoutStateDisabler()
+{
+ m_view.enableLayoutState();
+}
+
+static bool shouldDisableLayoutStateForSubtree(RenderElement& subtreeLayoutRoot)
+{
+ for (auto* renderer = &subtreeLayoutRoot; renderer; renderer = renderer->container()) {
+ if (renderer->hasTransform() || renderer->hasReflection())
+ return true;
+ }
+ return false;
+}
+
+SubtreeLayoutStateMaintainer::SubtreeLayoutStateMaintainer(RenderElement* subtreeLayoutRoot)
+ : m_subtreeLayoutRoot(subtreeLayoutRoot)
+{
+ if (m_subtreeLayoutRoot) {
+ RenderView& view = m_subtreeLayoutRoot->view();
+ view.pushLayoutState(*m_subtreeLayoutRoot);
+ if (shouldDisableLayoutStateForSubtree(*m_subtreeLayoutRoot)) {
+ view.disableLayoutState();
+ m_didDisableLayoutState = true;
+ }
+ }
+}
+
+SubtreeLayoutStateMaintainer::~SubtreeLayoutStateMaintainer()
+{
+ if (m_subtreeLayoutRoot) {
+ RenderView& view = m_subtreeLayoutRoot->view();
+ view.popLayoutState(*m_subtreeLayoutRoot);
+ if (m_didDisableLayoutState)
+ view.enableLayoutState();
+ }
+}
+
+PaginatedLayoutStateMaintainer::PaginatedLayoutStateMaintainer(RenderBlockFlow& flow)
+ : m_flow(flow)
+ , m_pushed(flow.view().pushLayoutStateForPaginationIfNeeded(flow))
+{
+}
+
+PaginatedLayoutStateMaintainer::~PaginatedLayoutStateMaintainer()
+{
+ if (m_pushed)
+ m_flow.view().popLayoutState(m_flow);
+}
+
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/LayoutState.h (224460 => 224461)
--- trunk/Source/WebCore/rendering/LayoutState.h 2017-11-04 21:41:10 UTC (rev 224460)
+++ trunk/Source/WebCore/rendering/LayoutState.h 2017-11-04 22:02:39 UTC (rev 224461)
@@ -30,13 +30,12 @@
namespace WebCore {
-class RenderBlock;
class RenderBlockFlow;
class RenderBox;
class RenderElement;
class RenderFragmentedFlow;
class RenderObject;
-class ShapeInsideInfo;
+class RenderView;
class LayoutState {
WTF_MAKE_NONCOPYABLE(LayoutState); WTF_MAKE_FAST_ALLOCATED;
@@ -128,4 +127,56 @@
#endif
};
+// Stack-based class to assist with LayoutState push/pop
+class LayoutStateMaintainer {
+ WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer);
+public:
+ // Constructor to push now.
+ explicit LayoutStateMaintainer(RenderBox&, LayoutSize offset, bool disableState = false, LayoutUnit pageHeight = 0, bool pageHeightChanged = false);
+ // Constructor to maybe push later.
+ explicit LayoutStateMaintainer(RenderView&);
+ ~LayoutStateMaintainer();
+
+ void push(RenderBox& root, LayoutSize offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false);
+ void pop();
+ bool didPush() const { return m_didCallPush; }
+
+private:
+ RenderView& m_view;
+ bool m_disabled { false };
+ bool m_didCallPush { false };
+ bool m_didCallPop { false };
+ bool m_didPushLayoutState { false };
+};
+
+class SubtreeLayoutStateMaintainer {
+public:
+ SubtreeLayoutStateMaintainer(RenderElement* subtreeLayoutRoot);
+ ~SubtreeLayoutStateMaintainer();
+
+private:
+ RenderElement* m_subtreeLayoutRoot { nullptr };
+ bool m_didDisableLayoutState { false };
+};
+
+class LayoutStateDisabler {
+ WTF_MAKE_NONCOPYABLE(LayoutStateDisabler);
+public:
+ LayoutStateDisabler(RenderView&);
+ ~LayoutStateDisabler();
+
+private:
+ RenderView& m_view;
+};
+
+class PaginatedLayoutStateMaintainer {
+public:
+ PaginatedLayoutStateMaintainer(RenderBlockFlow&);
+ ~PaginatedLayoutStateMaintainer();
+
+private:
+ RenderBlockFlow& m_flow;
+ bool m_pushed { false };
+};
+
} // namespace WebCore
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (224460 => 224461)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2017-11-04 21:41:10 UTC (rev 224460)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2017-11-04 22:02:39 UTC (rev 224461)
@@ -67,25 +67,6 @@
COMPILE_ASSERT(sizeof(RenderBlockFlow::MarginValues) == sizeof(LayoutUnit[4]), MarginValues_should_stay_small);
COMPILE_ASSERT(sizeof(RenderBlockFlow::MarginInfo) == sizeof(SameSizeAsMarginInfo), MarginInfo_should_stay_small);
-class PaginatedLayoutStateMaintainer {
-public:
- PaginatedLayoutStateMaintainer(RenderBlockFlow& flow)
- : m_flow(flow)
- , m_pushed(flow.view().pushLayoutStateForPaginationIfNeeded(flow))
- {
- }
-
- ~PaginatedLayoutStateMaintainer()
- {
- if (m_pushed)
- m_flow.view().popLayoutState(m_flow);
- }
-
-private:
- RenderBlockFlow& m_flow;
- bool m_pushed { false };
-};
-
// Our MarginInfo state used when laying out block children.
RenderBlockFlow::MarginInfo::MarginInfo(const RenderBlockFlow& block, LayoutUnit beforeBorderPadding, LayoutUnit afterBorderPadding)
: m_atBeforeSideOfBlock(true)
Modified: trunk/Source/WebCore/rendering/RenderView.h (224460 => 224461)
--- trunk/Source/WebCore/rendering/RenderView.h 2017-11-04 21:41:10 UTC (rev 224460)
+++ trunk/Source/WebCore/rendering/RenderView.h 2017-11-04 22:02:39 UTC (rev 224461)
@@ -341,82 +341,6 @@
#endif
};
-// Stack-based class to assist with LayoutState push/pop
-class LayoutStateMaintainer {
- WTF_MAKE_NONCOPYABLE(LayoutStateMaintainer);
-public:
- // Constructor to push now.
- explicit LayoutStateMaintainer(RenderBox& root, LayoutSize offset, bool disableState = false, LayoutUnit pageHeight = 0, bool pageHeightChanged = false)
- : m_view(root.view())
- , m_disabled(disableState)
- {
- push(root, offset, pageHeight, pageHeightChanged);
- }
-
- // Constructor to maybe push later.
- explicit LayoutStateMaintainer(RenderView& view)
- : m_view(view)
- {
- }
-
- ~LayoutStateMaintainer()
- {
- ASSERT(!m_didCallPush || m_didCallPush == m_didCallPop);
- }
-
- void push(RenderBox& root, LayoutSize offset, LayoutUnit pageHeight = 0, bool pageHeightChanged = false)
- {
- ASSERT(!m_didCallPush);
- m_didCallPush = true;
- // We push state even if disabled, because we still need to store layoutDelta
- m_didPushLayoutState = m_view.pushLayoutState(root, offset, pageHeight, pageHeightChanged);
- if (!m_didPushLayoutState)
- return;
- if (m_disabled)
- m_view.disableLayoutState();
- }
-
- void pop()
- {
- ASSERT(!m_didCallPop);
- m_didCallPop = true;
- if (!m_didCallPush)
- return;
- if (!m_didPushLayoutState)
- return;
- m_view.popLayoutState();
- if (m_disabled)
- m_view.enableLayoutState();
- }
-
- bool didPush() const { return m_didCallPush; }
-
-private:
- RenderView& m_view;
- bool m_disabled { false };
- bool m_didCallPush { false };
- bool m_didCallPop { false };
- bool m_didPushLayoutState { false };
-};
-
-class LayoutStateDisabler {
- WTF_MAKE_NONCOPYABLE(LayoutStateDisabler);
-public:
- LayoutStateDisabler(RenderView& view)
- : m_view(view)
- {
- m_view.disableLayoutState();
- }
-
- ~LayoutStateDisabler()
- {
- m_view.enableLayoutState();
- }
-
-private:
- RenderView& m_view;
-};
-
} // namespace WebCore
SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderView, isRenderView())