Diff
Modified: trunk/Source/WebCore/ChangeLog (224578 => 224579)
--- trunk/Source/WebCore/ChangeLog 2017-11-08 13:55:46 UTC (rev 224578)
+++ trunk/Source/WebCore/ChangeLog 2017-11-08 15:02:10 UTC (rev 224579)
@@ -1,3 +1,47 @@
+2017-11-08 Zalan Bujtas <[email protected]>
+
+ [LayoutState cleanup] Make public data members private.
+ https://bugs.webkit.org/show_bug.cgi?id=179409
+ <rdar://problem/35406184>
+
+ Reviewed by Sam Weinig.
+
+ No change in functionality.
+
+ * page/LayoutContext.cpp:
+ (WebCore::LayoutContext::layoutDelta const):
+ (WebCore::LayoutContext::addLayoutDelta):
+ (WebCore::LayoutContext::layoutDeltaMatches):
+ (WebCore::LayoutContext::pushLayoutStateForPaginationIfNeeded):
+ * rendering/LayoutState.cpp:
+ (WebCore::LayoutState::LayoutState):
+ (WebCore::LayoutState::addLayoutDelta):
+ (WebCore::LayoutState::layoutDeltaMatches):
+ * rendering/LayoutState.h:
+ (WebCore::LayoutState::setIsPaginated):
+ (WebCore::LayoutState::setPageLogicalHeight):
+ (WebCore::LayoutState::paintOffset const):
+ (WebCore::LayoutState::renderer const):
+ (WebCore::LayoutState::clipRect const):
+ (WebCore::LayoutState::isClipped const):
+ (WebCore::LayoutState::layoutDelta const):
+ * rendering/RenderBlock.cpp:
+ (WebCore::RenderBlock::offsetFromLogicalTopOfFirstPage const):
+ (WebCore::RenderBlock::childBoxIsUnsplittableForFragmentation const):
+ * rendering/RenderBlockFlow.cpp:
+ (WebCore::RenderBlockFlow::layoutBlock):
+ (WebCore::RenderBlockFlow::applyBeforeBreak):
+ (WebCore::RenderBlockFlow::applyAfterBreak):
+ (WebCore::RenderBlockFlow::pageLogicalTopForOffset const):
+ (WebCore::RenderBlockFlow::pageLogicalHeightForOffset const):
+ (WebCore::RenderBlockFlow::pageRemainingLogicalHeightForOffset const):
+ * rendering/RenderBox.cpp:
+ (WebCore::RenderBox::mapLocalToContainer const):
+ (WebCore::RenderBox::computeRectForRepaint const):
+ * rendering/RenderInline.cpp:
+ (WebCore::RenderInline::computeRectForRepaint const):
+ (WebCore::RenderInline::mapLocalToContainer const):
+
2017-11-08 Zan Dobersek <[email protected]>
[Cairo] Improve PlatformContextCairo lifetime management in GraphicsContextPlatformPrivate
Modified: trunk/Source/WebCore/page/LayoutContext.cpp (224578 => 224579)
--- trunk/Source/WebCore/page/LayoutContext.cpp 2017-11-08 13:55:46 UTC (rev 224578)
+++ trunk/Source/WebCore/page/LayoutContext.cpp 2017-11-08 15:02:10 UTC (rev 224579)
@@ -532,7 +532,7 @@
{
if (!m_layoutState)
return { };
- return m_layoutState->m_layoutDelta;
+ return m_layoutState->layoutDelta();
}
void LayoutContext::addLayoutDelta(const LayoutSize& delta)
@@ -539,12 +539,7 @@
{
if (!m_layoutState)
return;
-
- m_layoutState->m_layoutDelta += delta;
-#if !ASSERT_DISABLED
- m_layoutState->m_layoutDeltaXSaturated |= m_layoutState->m_layoutDelta.width() == LayoutUnit::max() || m_layoutState->m_layoutDelta.width() == LayoutUnit::min();
- m_layoutState->m_layoutDeltaYSaturated |= m_layoutState->m_layoutDelta.height() == LayoutUnit::max() || m_layoutState->m_layoutDelta.height() == LayoutUnit::min();
-#endif
+ m_layoutState->addLayoutDelta(delta);
}
#if !ASSERT_DISABLED
@@ -552,7 +547,7 @@
{
if (!m_layoutState)
return false;
- return (delta.width() == m_layoutState->m_layoutDelta.width() || m_layoutState->m_layoutDeltaXSaturated) && (delta.height() == m_layoutState->m_layoutDelta.height() || m_layoutState->m_layoutDeltaYSaturated);
+ return m_layoutState->layoutDeltaMatches(delta);
}
#endif
@@ -569,9 +564,9 @@
if (m_layoutState)
return false;
m_layoutState = std::make_unique<LayoutState>(layoutRoot);
- m_layoutState->m_isPaginated = true;
+ m_layoutState->setIsPaginated();
// This is just a flag for known page height (see RenderBlockFlow::checkForPaginationLogicalHeightChange).
- m_layoutState->m_pageLogicalHeight = 1;
+ m_layoutState->setPageLogicalHeight(1);
return true;
}
Modified: trunk/Source/WebCore/rendering/LayoutState.cpp (224578 => 224579)
--- trunk/Source/WebCore/rendering/LayoutState.cpp 2017-11-08 13:55:46 UTC (rev 224578)
+++ trunk/Source/WebCore/rendering/LayoutState.cpp 2017-11-08 15:02:10 UTC (rev 224579)
@@ -61,7 +61,8 @@
}
LayoutState::LayoutState(std::unique_ptr<LayoutState> ancestor, RenderBox& renderer, const LayoutSize& offset, LayoutUnit pageLogicalHeight, bool pageLogicalHeightChanged)
- : m_clipped(false)
+ : m_ancestor(WTFMove(ancestor))
+ , m_clipped(false)
, m_isPaginated(false)
, m_pageLogicalHeightChanged(false)
#if !ASSERT_DISABLED
@@ -68,7 +69,6 @@
, m_layoutDeltaXSaturated(false)
, m_layoutDeltaYSaturated(false)
#endif
- , m_ancestor(WTFMove(ancestor))
#ifndef NDEBUG
, m_renderer(&renderer)
#endif
@@ -218,6 +218,22 @@
m_lineGridOffset = m_layoutOffset;
}
+void LayoutState::addLayoutDelta(LayoutSize delta)
+{
+ m_layoutDelta += delta;
+#if !ASSERT_DISABLED
+ m_layoutDeltaXSaturated |= m_layoutDelta.width() == LayoutUnit::max() || m_layoutDelta.width() == LayoutUnit::min();
+ m_layoutDeltaYSaturated |= m_layoutDelta.height() == LayoutUnit::max() || m_layoutDelta.height() == LayoutUnit::min();
+#endif
+}
+
+#if !ASSERT_DISABLED
+bool LayoutState::layoutDeltaMatches(LayoutSize delta)
+{
+ return (delta.width() == m_layoutDelta.width() || m_layoutDeltaXSaturated) && (delta.height() == m_layoutDelta.height() || m_layoutDeltaYSaturated);
+}
+#endif
+
LayoutStateMaintainer::LayoutStateMaintainer(RenderBox& root, LayoutSize offset, bool disablePaintOffsetCache, LayoutUnit pageHeight, bool pageHeightChanged)
: m_layoutContext(root.view().frameView().layoutContext())
, m_paintOffsetCacheIsDisabled(disablePaintOffsetCache)
Modified: trunk/Source/WebCore/rendering/LayoutState.h (224578 => 224579)
--- trunk/Source/WebCore/rendering/LayoutState.h 2017-11-08 13:55:46 UTC (rev 224578)
+++ trunk/Source/WebCore/rendering/LayoutState.h 2017-11-08 15:02:10 UTC (rev 224579)
@@ -55,13 +55,15 @@
LayoutState(std::unique_ptr<LayoutState> ancestor, RenderBox&, const LayoutSize& offset, LayoutUnit pageHeight, bool pageHeightChanged);
explicit LayoutState(RenderElement&);
+ bool isPaginated() const { return m_isPaginated; }
+ void setIsPaginated() { m_isPaginated = true; }
void clearPaginationInformation();
- bool isPaginated() const { return m_isPaginated; }
-
+
// The page logical offset is the object's offset from the top of the page in the page progression
// direction (so an x-offset in vertical text and a y-offset for horizontal text).
LayoutUnit pageLogicalOffset(RenderBox*, LayoutUnit childLogicalOffset) const;
+ void setPageLogicalHeight(LayoutUnit logicalHeight) { m_pageLogicalHeight = logicalHeight; }
LayoutUnit pageLogicalHeight() const { return m_pageLogicalHeight; }
bool pageLogicalHeightChanged() const { return m_pageLogicalHeightChanged; }
@@ -69,6 +71,7 @@
LayoutSize lineGridOffset() const { return m_lineGridOffset; }
LayoutSize lineGridPaginationOrigin() const { return m_lineGridPaginationOrigin; }
+ LayoutSize paintOffset() const { return m_paintOffset; }
LayoutSize layoutOffset() const { return m_layoutOffset; }
LayoutSize pageOffset() const { return m_pageOffset; }
@@ -78,7 +81,21 @@
RenderFragmentedFlow* currentRenderFragmentedFlow() const { return m_currentRenderFragmentedFlow; }
void setCurrentRenderFragmentedFlow(RenderFragmentedFlow* fragmentedFlow) { m_currentRenderFragmentedFlow = fragmentedFlow; }
+#ifndef NDEBUG
+ RenderElement* renderer() const { return m_renderer; }
+#endif
+ LayoutRect clipRect() const { return m_clipRect; }
+ bool isClipped() const { return m_clipped; }
+ void addLayoutDelta(LayoutSize);
+ LayoutSize layoutDelta() const { return m_layoutDelta; }
+#if !ASSERT_DISABLED
+ bool layoutDeltaMatches(LayoutSize);
+#endif
+
+ // FIXME: webkit.org/b/179408 LayoutContext should own the stack of LayoutState objects
+ std::unique_ptr<LayoutState> m_ancestor;
+
private:
void computeOffsets(RenderBox&, LayoutSize offset);
void computeClipRect(RenderBox&);
@@ -86,7 +103,6 @@
void propagateLineGridInfo(RenderBox&);
void establishLineGrid(RenderBlockFlow&);
-public:
// Do not add anything apart from bitfields. See https://bugs.webkit.org/show_bug.cgi?id=100173
bool m_clipped : 1;
bool m_isPaginated : 1;
@@ -99,7 +115,6 @@
// The current line grid that we're snapping to and the offset of the start of the grid.
RenderBlockFlow* m_lineGrid { nullptr };
- std::unique_ptr<LayoutState> m_ancestor;
// FIXME: Distinguish between the layout clip rect and the paint clip rect which may be larger,
// e.g., because of composited scrolling.
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (224578 => 224579)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2017-11-08 13:55:46 UTC (rev 224578)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2017-11-08 15:02:10 UTC (rev 224579)
@@ -3325,9 +3325,9 @@
return fragmentedFlow->offsetFromLogicalTopOfFirstFragment(this);
if (layoutState) {
- ASSERT(layoutState->m_renderer == this);
+ ASSERT(layoutState->renderer() == this);
- LayoutSize offsetDelta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
+ LayoutSize offsetDelta = layoutState->layoutOffset() - layoutState->pageOffset();
return isHorizontalWritingMode() ? offsetDelta.height() : offsetDelta.width();
}
@@ -3362,7 +3362,7 @@
{
RenderFragmentedFlow* fragmentedFlow = enclosingFragmentedFlow();
bool checkColumnBreaks = fragmentedFlow && fragmentedFlow->shouldCheckColumnBreaks();
- bool checkPageBreaks = !checkColumnBreaks && view().frameView().layoutContext().layoutState()->m_pageLogicalHeight;
+ bool checkPageBreaks = !checkColumnBreaks && view().frameView().layoutContext().layoutState()->pageLogicalHeight();
return child.isUnsplittableForPagination() || child.style().breakInside() == AvoidBreakInside
|| (checkColumnBreaks && child.style().breakInside() == AvoidColumnBreakInside)
|| (checkPageBreaks && child.style().breakInside() == AvoidPageBreakInside);
Modified: trunk/Source/WebCore/rendering/RenderBlockFlow.cpp (224578 => 224579)
--- trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2017-11-08 13:55:46 UTC (rev 224578)
+++ trunk/Source/WebCore/rendering/RenderBlockFlow.cpp 2017-11-08 15:02:10 UTC (rev 224579)
@@ -501,7 +501,6 @@
setHasMarginAfterQuirk(styleToUse.hasMarginAfterQuirk());
setPaginationStrut(0);
}
-
LayoutUnit maxFloatLogicalBottom = 0;
if (!firstChild() && !isAnonymousBlock())
setChildrenInline(true);
@@ -554,9 +553,8 @@
fitBorderToLinesIfNeeded();
}
-
auto* state = view().frameView().layoutContext().layoutState();
- if (state && state->m_pageLogicalHeight)
+ if (state && state->pageLogicalHeight())
setPageLogicalOffset(state->pageLogicalOffset(this, logicalTop()));
updateLayerTransform();
@@ -1499,7 +1497,7 @@
RenderFragmentedFlow* fragmentedFlow = enclosingFragmentedFlow();
bool isInsideMulticolFlow = fragmentedFlow;
bool checkColumnBreaks = fragmentedFlow && fragmentedFlow->shouldCheckColumnBreaks();
- bool checkPageBreaks = !checkColumnBreaks && view().frameView().layoutContext().layoutState()->m_pageLogicalHeight; // FIXME: Once columns can print we have to check this.
+ bool checkPageBreaks = !checkColumnBreaks && view().frameView().layoutContext().layoutState()->pageLogicalHeight(); // FIXME: Once columns can print we have to check this.
bool checkFragmentBreaks = false;
bool checkBeforeAlways = (checkColumnBreaks && child.style().breakBefore() == ColumnBreakBetween)
|| (checkPageBreaks && alwaysPageBreak(child.style().breakBefore()));
@@ -1524,7 +1522,7 @@
RenderFragmentedFlow* fragmentedFlow = enclosingFragmentedFlow();
bool isInsideMulticolFlow = fragmentedFlow;
bool checkColumnBreaks = fragmentedFlow && fragmentedFlow->shouldCheckColumnBreaks();
- bool checkPageBreaks = !checkColumnBreaks && view().frameView().layoutContext().layoutState()->m_pageLogicalHeight; // FIXME: Once columns can print we have to check this.
+ bool checkPageBreaks = !checkColumnBreaks && view().frameView().layoutContext().layoutState()->pageLogicalHeight(); // FIXME: Once columns can print we have to check this.
bool checkFragmentBreaks = false;
bool checkAfterAlways = (checkColumnBreaks && child.style().breakAfter() == ColumnBreakBetween)
|| (checkPageBreaks && alwaysPageBreak(child.style().breakAfter()));
@@ -1911,12 +1909,12 @@
// Unsplittable objects clear out the pageLogicalHeight in the layout state as a way of signaling that no
// pagination should occur. Therefore we have to check this first and bail if the value has been set to 0.
auto* layoutState = view().frameView().layoutContext().layoutState();
- LayoutUnit pageLogicalHeight = layoutState->m_pageLogicalHeight;
+ LayoutUnit pageLogicalHeight = layoutState->pageLogicalHeight();
if (!pageLogicalHeight)
return 0;
- LayoutUnit firstPageLogicalTop = isHorizontalWritingMode() ? layoutState->m_pageOffset.height() : layoutState->m_pageOffset.width();
- LayoutUnit blockLogicalTop = isHorizontalWritingMode() ? layoutState->m_layoutOffset.height() : layoutState->m_layoutOffset.width();
+ LayoutUnit firstPageLogicalTop = isHorizontalWritingMode() ? layoutState->pageOffset().height() : layoutState->pageOffset().width();
+ LayoutUnit blockLogicalTop = isHorizontalWritingMode() ? layoutState->layoutOffset().height() : layoutState->layoutOffset().width();
LayoutUnit cumulativeOffset = offset + blockLogicalTop;
RenderFragmentedFlow* fragmentedFlow = enclosingFragmentedFlow();
@@ -1929,7 +1927,7 @@
{
// Unsplittable objects clear out the pageLogicalHeight in the layout state as a way of signaling that no
// pagination should occur. Therefore we have to check this first and bail if the value has been set to 0.
- LayoutUnit pageLogicalHeight = view().frameView().layoutContext().layoutState()->m_pageLogicalHeight;
+ LayoutUnit pageLogicalHeight = view().frameView().layoutContext().layoutState()->pageLogicalHeight();
if (!pageLogicalHeight)
return 0;
@@ -1946,7 +1944,7 @@
RenderFragmentedFlow* fragmentedFlow = enclosingFragmentedFlow();
if (!fragmentedFlow) {
- LayoutUnit pageLogicalHeight = view().frameView().layoutContext().layoutState()->m_pageLogicalHeight;
+ LayoutUnit pageLogicalHeight = view().frameView().layoutContext().layoutState()->pageLogicalHeight();
LayoutUnit remainingHeight = pageLogicalHeight - intMod(offset, pageLogicalHeight);
if (pageBoundaryRule == IncludePageBoundary) {
// If includeBoundaryPoint is true the line exactly on the top edge of a
Modified: trunk/Source/WebCore/rendering/RenderBox.cpp (224578 => 224579)
--- trunk/Source/WebCore/rendering/RenderBox.cpp 2017-11-08 13:55:46 UTC (rev 224578)
+++ trunk/Source/WebCore/rendering/RenderBox.cpp 2017-11-08 15:02:10 UTC (rev 224579)
@@ -1926,7 +1926,7 @@
if (view().frameView().layoutContext().isPaintOffsetCacheEnabled() && !repaintContainer) {
auto* layoutState = view().frameView().layoutContext().layoutState();
- LayoutSize offset = layoutState->m_paintOffset + locationOffset();
+ LayoutSize offset = layoutState->paintOffset() + locationOffset();
if (style().hasInFlowPosition() && layer())
offset += layer()->offsetForInFlowPosition();
transformState.move(offset);
@@ -2151,9 +2151,9 @@
adjustedRect.move(layer()->offsetForInFlowPosition());
adjustedRect.moveBy(location());
- adjustedRect.move(layoutState->m_paintOffset);
- if (layoutState->m_clipped)
- adjustedRect.intersect(layoutState->m_clipRect);
+ adjustedRect.move(layoutState->paintOffset());
+ if (layoutState->isClipped())
+ adjustedRect.intersect(layoutState->clipRect());
return adjustedRect;
}
Modified: trunk/Source/WebCore/rendering/RenderInline.cpp (224578 => 224579)
--- trunk/Source/WebCore/rendering/RenderInline.cpp 2017-11-08 13:55:46 UTC (rev 224578)
+++ trunk/Source/WebCore/rendering/RenderInline.cpp 2017-11-08 15:02:10 UTC (rev 224579)
@@ -1226,9 +1226,9 @@
auto* layoutState = view().frameView().layoutContext().layoutState();
if (style().hasInFlowPosition() && layer())
adjustedRect.move(layer()->offsetForInFlowPosition());
- adjustedRect.move(layoutState->m_paintOffset);
- if (layoutState->m_clipped)
- adjustedRect.intersect(layoutState->m_clipRect);
+ adjustedRect.move(layoutState->paintOffset());
+ if (layoutState->isClipped())
+ adjustedRect.intersect(layoutState->clipRect());
return adjustedRect;
}
@@ -1292,7 +1292,7 @@
if (view().frameView().layoutContext().isPaintOffsetCacheEnabled() && !repaintContainer) {
auto* layoutState = view().frameView().layoutContext().layoutState();
- LayoutSize offset = layoutState->m_paintOffset;
+ LayoutSize offset = layoutState->paintOffset();
if (style().hasInFlowPosition() && layer())
offset += layer()->offsetForInFlowPosition();
transformState.move(offset);