Remove some more code from RenderFlowThread
authorantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Sep 2017 21:11:03 +0000 (21:11 +0000)
committerantti@apple.com <antti@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 21 Sep 2017 21:11:03 +0000 (21:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=177320

Reviewed by David Hyatt.

More dead code related to named flows.

* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::RenderFlowThread):
(WebCore::RenderFlowThread::invalidateRegions):
(WebCore::RenderFlowThread::layout):
(WebCore::RenderFlowThread::logicalWidthChangedInRegionsForBlock):
(WebCore::RenderFlowThread::updateRegionsFlowThreadPortionRect):
(WebCore::RenderFlowThread::addForcedRegionBreak):
(WebCore::RenderFlowThread::offsetFromLogicalTopOfFirstRegion const):
(WebCore::RenderFlowThread::hasCachedOffsetFromLogicalTopOfFirstRegion const): Deleted.
(WebCore::RenderFlowThread::cachedOffsetFromLogicalTopOfFirstRegion const): Deleted.
(WebCore::RenderFlowThread::setOffsetFromLogicalTopOfFirstRegion): Deleted.
(WebCore::RenderFlowThread::clearOffsetFromLogicalTopOfFirstRegion): Deleted.
(WebCore::RenderFlowThread::currentActiveRenderBox const): Deleted.
(WebCore::RenderFlowThread::pushFlowThreadLayoutState): Deleted.
(WebCore::RenderFlowThread::popFlowThreadLayoutState): Deleted.
* rendering/RenderFlowThread.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@222350 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/rendering/RenderFlowThread.cpp
Source/WebCore/rendering/RenderFlowThread.h

index 9c58f5a..d4cb7df 100644 (file)
@@ -1,3 +1,29 @@
+2017-09-21  Antti Koivisto  <antti@apple.com>
+
+        Remove some more code from RenderFlowThread
+        https://bugs.webkit.org/show_bug.cgi?id=177320
+
+        Reviewed by David Hyatt.
+
+        More dead code related to named flows.
+
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::RenderFlowThread):
+        (WebCore::RenderFlowThread::invalidateRegions):
+        (WebCore::RenderFlowThread::layout):
+        (WebCore::RenderFlowThread::logicalWidthChangedInRegionsForBlock):
+        (WebCore::RenderFlowThread::updateRegionsFlowThreadPortionRect):
+        (WebCore::RenderFlowThread::addForcedRegionBreak):
+        (WebCore::RenderFlowThread::offsetFromLogicalTopOfFirstRegion const):
+        (WebCore::RenderFlowThread::hasCachedOffsetFromLogicalTopOfFirstRegion const): Deleted.
+        (WebCore::RenderFlowThread::cachedOffsetFromLogicalTopOfFirstRegion const): Deleted.
+        (WebCore::RenderFlowThread::setOffsetFromLogicalTopOfFirstRegion): Deleted.
+        (WebCore::RenderFlowThread::clearOffsetFromLogicalTopOfFirstRegion): Deleted.
+        (WebCore::RenderFlowThread::currentActiveRenderBox const): Deleted.
+        (WebCore::RenderFlowThread::pushFlowThreadLayoutState): Deleted.
+        (WebCore::RenderFlowThread::popFlowThreadLayoutState): Deleted.
+        * rendering/RenderFlowThread.h:
+
 2017-09-21  Chris Dumez  <cdumez@apple.com>
 
         eventInitDict parameter to GamepadEvent constructor should be optional
index 39f5ada..db81599 100644 (file)
@@ -51,14 +51,11 @@ namespace WebCore {
 
 RenderFlowThread::RenderFlowThread(Document& document, RenderStyle&& style)
     : RenderBlockFlow(document, WTFMove(style))
-    , m_previousRegionCount(0)
     , m_currentRegionMaintainer(nullptr)
     , m_regionsInvalidated(false)
     , m_regionsHaveUniformLogicalWidth(true)
     , m_regionsHaveUniformLogicalHeight(true)
     , m_pageLogicalSizeChanged(false)
-    , m_layoutPhase(LayoutPhaseMeasureContent)
-    , m_needsTwoPhasesLayout(false)
 {
     setIsRenderFlowThread(true);
 }
@@ -102,8 +99,6 @@ void RenderFlowThread::removeRegionFromThread(RenderRegion* renderRegion)
 
 void RenderFlowThread::invalidateRegions(MarkingBehavior markingParents)
 {
-    ASSERT(!inFinalLayoutPhase());
-
     if (m_regionsInvalidated) {
         ASSERT(selfNeedsLayout());
         return;
@@ -165,10 +160,6 @@ void RenderFlowThread::layout()
 
     m_pageLogicalSizeChanged = m_regionsInvalidated && everHadLayout();
 
-    // It's also possible to need a secondary layout if the overflow computation invalidated the region chain (e.g. overflow: auto scrollbars
-    // shrunk some regions) so repropagation is required.
-    m_needsTwoPhasesLayout = inOverflowLayoutPhase() && m_regionsInvalidated;
-
     validateRegions();
 
     RenderBlockFlow::layout();
@@ -454,13 +445,8 @@ void RenderFlowThread::removeLineRegionInfo(const RenderBlockFlow& blockFlow)
 
 void RenderFlowThread::logicalWidthChangedInRegionsForBlock(const RenderBlock* block, bool& relayoutChildren)
 {
-    if (!hasValidRegionInfo()) {
-        // FIXME: Remove once we stop laying out flow threads without regions.
-        // If we had regions but don't any more, relayout the children because the code below
-        // can't properly detect this scenario.
-        relayoutChildren |= previousRegionCountChanged();
+    if (!hasValidRegionInfo())
         return;
-    }
 
     auto it = m_regionRangeMap.find(block);
     if (it == m_regionRangeMap.end())
@@ -808,11 +794,9 @@ void RenderFlowThread::markRegionsForOverflowLayoutIfNeeded()
         region->setNeedsSimplifiedNormalFlowLayout();
 }
 
-void RenderFlowThread::updateRegionsFlowThreadPortionRect(const RenderRegion* lastRegionWithContent)
+void RenderFlowThread::updateRegionsFlowThreadPortionRect()
 {
-    ASSERT(!lastRegionWithContent);
     LayoutUnit logicalHeight = 0;
-    bool emptyRegionsSegment = false;
     // FIXME: Optimize not to clear the interval all the time. This implies manually managing the tree nodes lifecycle.
     m_regionIntervalTree.clear();
     for (auto& region : m_regionList) {
@@ -826,13 +810,7 @@ void RenderFlowThread::updateRegionsFlowThreadPortionRect(const RenderRegion* la
         m_regionIntervalTree.add(RegionIntervalTree::createInterval(logicalHeight, logicalHeight + regionLogicalHeight, region));
 
         logicalHeight += regionLogicalHeight;
-
-        // Once we find the last region with content the next regions are considered empty.
-        if (lastRegionWithContent == region)
-            emptyRegionsSegment = true;
     }
-
-    ASSERT(!lastRegionWithContent || emptyRegionsSegment);
 }
 
 // Even if we require the break to occur at offsetBreakInFlowThread, because regions may have min/max-height values,
@@ -840,13 +818,6 @@ void RenderFlowThread::updateRegionsFlowThreadPortionRect(const RenderRegion* la
 // offsetBreakAdjustment measures the different between the requested break offset and the current break offset.
 bool RenderFlowThread::addForcedRegionBreak(const RenderBlock* block, LayoutUnit offsetBreakInFlowThread, RenderBox*, bool, LayoutUnit* offsetBreakAdjustment)
 {
-    // We take breaks into account for height computation for auto logical height regions
-    // only in the layout phase in which we lay out the flows threads unconstrained
-    // and we use the content breaks to determine the computed auto height for
-    // auto logical height regions.
-    if (!inMeasureContentLayoutPhase())
-        return false;
-
     // We need to update the regions flow thread portion rect because we are going to process
     // a break on these regions.
     updateRegionsFlowThreadPortionRect();
@@ -894,68 +865,8 @@ LayoutRect RenderFlowThread::fragmentsBoundingBox(const LayoutRect& layerBoundin
     return result;
 }
 
-bool RenderFlowThread::hasCachedOffsetFromLogicalTopOfFirstRegion(const RenderBox* box) const
-{
-    return m_boxesToOffsetMap.contains(box);
-}
-
-LayoutUnit RenderFlowThread::cachedOffsetFromLogicalTopOfFirstRegion(const RenderBox* box) const
-{
-    return m_boxesToOffsetMap.get(box);
-}
-
-void RenderFlowThread::setOffsetFromLogicalTopOfFirstRegion(const RenderBox* box, LayoutUnit offset)
-{
-    m_boxesToOffsetMap.set(box, offset);
-}
-
-void RenderFlowThread::clearOffsetFromLogicalTopOfFirstRegion(const RenderBox* box)
-{
-    ASSERT(m_boxesToOffsetMap.contains(box));
-    m_boxesToOffsetMap.remove(box);
-}
-
-const RenderBox* RenderFlowThread::currentActiveRenderBox() const
-{
-    if (m_activeObjectsStack.isEmpty())
-        return nullptr;
-
-    const RenderObject* currentObject = m_activeObjectsStack.last();
-    return is<RenderBox>(*currentObject) ? downcast<RenderBox>(currentObject) : nullptr;
-}
-
-void RenderFlowThread::pushFlowThreadLayoutState(const RenderObject& object)
-{
-    m_activeObjectsStack.append(&object);
-
-    if (const RenderBox* currentBoxDescendant = currentActiveRenderBox()) {
-        LayoutState* layoutState = currentBoxDescendant->view().layoutState();
-        if (layoutState && layoutState->isPaginated()) {
-            ASSERT(layoutState->m_renderer == currentBoxDescendant);
-            LayoutSize offsetDelta = layoutState->m_layoutOffset - layoutState->m_pageOffset;
-            setOffsetFromLogicalTopOfFirstRegion(currentBoxDescendant, currentBoxDescendant->isHorizontalWritingMode() ? offsetDelta.height() : offsetDelta.width());
-        }
-    }
-}
-
-void RenderFlowThread::popFlowThreadLayoutState()
-{
-    if (const RenderBox* currentBoxDescendant = currentActiveRenderBox()) {
-        LayoutState* layoutState = currentBoxDescendant->view().layoutState();
-        if (layoutState && layoutState->isPaginated())
-            clearOffsetFromLogicalTopOfFirstRegion(currentBoxDescendant);
-    }
-
-    m_activeObjectsStack.removeLast();
-}
-
 LayoutUnit RenderFlowThread::offsetFromLogicalTopOfFirstRegion(const RenderBlock* currentBlock) const
 {
-    // First check if we cached the offset for the block if it's an ancestor containing block of the box
-    // being currently laid out.
-    if (hasCachedOffsetFromLogicalTopOfFirstRegion(currentBlock))
-        return cachedOffsetFromLogicalTopOfFirstRegion(currentBlock);
-
     // As a last resort, take the slow path.
     LayoutRect blockRect(0, 0, currentBlock->width(), currentBlock->height());
     while (currentBlock && !is<RenderView>(*currentBlock) && !currentBlock->isRenderFlowThread()) {
index 9af8746..4356a43 100644 (file)
@@ -125,9 +125,6 @@ public:
     RenderRegion* firstRegion() const;
     RenderRegion* lastRegion() const;
 
-    bool previousRegionCountChanged() const { return m_previousRegionCount != m_regionList.size(); };
-    void updatePreviousRegionCount() { m_previousRegionCount = m_regionList.size(); };
-
     virtual void setRegionRangeForBox(const RenderBox&, RenderRegion*, RenderRegion*);
     bool getRegionRangeForBox(const RenderBox*, RenderRegion*& startRegion, RenderRegion*& endRegion) const;
     bool computedRegionRangeForBox(const RenderBox*, RenderRegion*& startRegion, RenderRegion*& endRegion) const;
@@ -150,24 +147,6 @@ public:
     void collectLayerFragments(LayerFragments&, const LayoutRect& layerBoundingBox, const LayoutRect& dirtyRect);
     LayoutRect fragmentsBoundingBox(const LayoutRect& layerBoundingBox);
 
-    // A flow thread goes through different states during layout.
-    enum LayoutPhase {
-        LayoutPhaseMeasureContent = 0, // The initial phase, used to measure content for the auto-height regions.
-        LayoutPhaseConstrained, // In this phase the regions are laid out using the sizes computed in the normal phase.
-        LayoutPhaseOverflow, // In this phase the layout overflow is propagated from the content to the regions.
-        LayoutPhaseFinal // In case scrollbars have resized the regions, content is laid out one last time to respect the change.
-    };
-    bool inMeasureContentLayoutPhase() const { return m_layoutPhase == LayoutPhaseMeasureContent; }
-    bool inConstrainedLayoutPhase() const { return m_layoutPhase == LayoutPhaseConstrained; }
-    bool inOverflowLayoutPhase() const { return m_layoutPhase == LayoutPhaseOverflow; }
-    bool inFinalLayoutPhase() const { return m_layoutPhase == LayoutPhaseFinal; }
-    void setLayoutPhase(LayoutPhase phase) { m_layoutPhase = phase; }
-
-    bool needsTwoPhasesLayout() const { return m_needsTwoPhasesLayout; }
-    void clearNeedsTwoPhasesLayout() { m_needsTwoPhasesLayout = false; }
-
-    void pushFlowThreadLayoutState(const RenderObject&);
-    void popFlowThreadLayoutState();
     LayoutUnit offsetFromLogicalTopOfFirstRegion(const RenderBlock*) const;
     void clearRenderBoxRegionInfoAndCustomStyle(const RenderBox&, const RenderRegion*, const RenderRegion*, const RenderRegion*, const RenderRegion*);
 
@@ -223,23 +202,15 @@ protected:
 
     void mapLocalToContainer(const RenderLayerModelObject* repaintContainer, TransformState&, MapCoordinatesFlags, bool* wasFixed) const override;
 
-    void updateRegionsFlowThreadPortionRect(const RenderRegion* = nullptr);
+    void updateRegionsFlowThreadPortionRect();
     bool shouldRepaint(const LayoutRect&) const;
 
-    inline bool hasCachedOffsetFromLogicalTopOfFirstRegion(const RenderBox*) const;
-    inline LayoutUnit cachedOffsetFromLogicalTopOfFirstRegion(const RenderBox*) const;
-    inline void setOffsetFromLogicalTopOfFirstRegion(const RenderBox*, LayoutUnit);
-    inline void clearOffsetFromLogicalTopOfFirstRegion(const RenderBox*);
-
-    inline const RenderBox* currentActiveRenderBox() const;
-
     bool getRegionRangeForBoxFromCachedInfo(const RenderBox*, RenderRegion*& startRegion, RenderRegion*& endRegion) const;
 
     void removeRenderBoxRegionInfo(RenderBox&);
     void removeLineRegionInfo(const RenderBlockFlow&);
 
     RenderRegionList m_regionList;
-    unsigned short m_previousRegionCount;
 
     class RenderRegionRange {
     public:
@@ -305,12 +276,6 @@ protected:
     RenderBoxToRegionMap m_breakBeforeToRegionMap;
     RenderBoxToRegionMap m_breakAfterToRegionMap;
 
-    typedef Vector<const RenderObject*> RenderObjectStack;
-    RenderObjectStack m_activeObjectsStack;
-
-    typedef HashMap<const RenderBox*, LayoutUnit> RenderBoxToOffsetMap;
-    RenderBoxToOffsetMap m_boxesToOffsetMap;
-
     RegionIntervalTree m_regionIntervalTree;
 
     CurrentRenderRegionMaintainer* m_currentRegionMaintainer;
@@ -319,8 +284,6 @@ protected:
     bool m_regionsHaveUniformLogicalWidth : 1;
     bool m_regionsHaveUniformLogicalHeight : 1;
     bool m_pageLogicalSizeChanged : 1;
-    unsigned m_layoutPhase : 2;
-    bool m_needsTwoPhasesLayout : 1;
 };
 
 } // namespace WebCore