Title: [161553] trunk/Source/WebCore
Revision
161553
Author
[email protected]
Date
2014-01-09 04:06:21 -0800 (Thu, 09 Jan 2014)

Log Message

[CSSRegions] Move regions auto-size code into RenderNamedFlowFragment
https://bugs.webkit.org/show_bug.cgi?id=122959

Reviewed by Mihnea Ovidenie.

Move the auto-height logic from RenderRegion to RenderNamedFlowFragment because it's
used only by the CSS Regions implementation.

Bug 126642 covers the auto-height logic move from RenderFlowThread to RenderNamedFlowThread.

Tests: No new tests, just refactorings.

* rendering/RenderFlowThread.cpp:
(WebCore::RenderFlowThread::styleDidChange):
(WebCore::RenderFlowThread::validateRegions):
(WebCore::RenderFlowThread::isAutoLogicalHeightRegionsCountConsistent):
(WebCore::RenderFlowThread::initializeRegionsComputedAutoHeight):
(WebCore::RenderFlowThread::markAutoLogicalHeightRegionsForLayout):
(WebCore::RenderFlowThread::updateRegionsFlowThreadPortionRect):
(WebCore::RenderFlowThread::addForcedRegionBreak):
* rendering/RenderMultiColumnSet.h:
* rendering/RenderNamedFlowFragment.cpp:
(WebCore::RenderNamedFlowFragment::RenderNamedFlowFragment):
(WebCore::RenderNamedFlowFragment::styleDidChange):
(WebCore::RenderNamedFlowFragment::incrementAutoLogicalHeightCount):
(WebCore::RenderNamedFlowFragment::decrementAutoLogicalHeightCount):
(WebCore::RenderNamedFlowFragment::updateRegionHasAutoLogicalHeightFlag):
(WebCore::RenderNamedFlowFragment::updateLogicalHeight):
(WebCore::RenderNamedFlowFragment::pageLogicalHeight):
(WebCore::RenderNamedFlowFragment::layoutBlock):
(WebCore::RenderNamedFlowFragment::attachRegion):
(WebCore::RenderNamedFlowFragment::detachRegion):
* rendering/RenderNamedFlowFragment.h:
* rendering/RenderRegion.cpp:
(WebCore::RenderRegion::RenderRegion):
(WebCore::RenderRegion::pageLogicalHeight):
(WebCore::RenderRegion::logicalHeightOfAllFlowThreadContent):
(WebCore::RenderRegion::isLastRegion):
(WebCore::RenderRegion::styleDidChange):
(WebCore::RenderRegion::attachRegion):
(WebCore::RenderRegion::detachRegion):
* rendering/RenderRegion.h:
* rendering/RenderRegionSet.h:
* rendering/RenderTreeAsText.cpp:
(WebCore::writeRenderRegionList):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (161552 => 161553)


--- trunk/Source/WebCore/ChangeLog	2014-01-09 10:32:54 UTC (rev 161552)
+++ trunk/Source/WebCore/ChangeLog	2014-01-09 12:06:21 UTC (rev 161553)
@@ -1,3 +1,51 @@
+2014-01-09  Andrei Bucur  <[email protected]>
+
+        [CSSRegions] Move regions auto-size code into RenderNamedFlowFragment
+        https://bugs.webkit.org/show_bug.cgi?id=122959
+
+        Reviewed by Mihnea Ovidenie.
+
+        Move the auto-height logic from RenderRegion to RenderNamedFlowFragment because it's
+        used only by the CSS Regions implementation.
+
+        Bug 126642 covers the auto-height logic move from RenderFlowThread to RenderNamedFlowThread.
+
+        Tests: No new tests, just refactorings.
+
+        * rendering/RenderFlowThread.cpp:
+        (WebCore::RenderFlowThread::styleDidChange):
+        (WebCore::RenderFlowThread::validateRegions):
+        (WebCore::RenderFlowThread::isAutoLogicalHeightRegionsCountConsistent):
+        (WebCore::RenderFlowThread::initializeRegionsComputedAutoHeight):
+        (WebCore::RenderFlowThread::markAutoLogicalHeightRegionsForLayout):
+        (WebCore::RenderFlowThread::updateRegionsFlowThreadPortionRect):
+        (WebCore::RenderFlowThread::addForcedRegionBreak):
+        * rendering/RenderMultiColumnSet.h:
+        * rendering/RenderNamedFlowFragment.cpp:
+        (WebCore::RenderNamedFlowFragment::RenderNamedFlowFragment):
+        (WebCore::RenderNamedFlowFragment::styleDidChange):
+        (WebCore::RenderNamedFlowFragment::incrementAutoLogicalHeightCount):
+        (WebCore::RenderNamedFlowFragment::decrementAutoLogicalHeightCount):
+        (WebCore::RenderNamedFlowFragment::updateRegionHasAutoLogicalHeightFlag):
+        (WebCore::RenderNamedFlowFragment::updateLogicalHeight):
+        (WebCore::RenderNamedFlowFragment::pageLogicalHeight):
+        (WebCore::RenderNamedFlowFragment::layoutBlock):
+        (WebCore::RenderNamedFlowFragment::attachRegion):
+        (WebCore::RenderNamedFlowFragment::detachRegion):
+        * rendering/RenderNamedFlowFragment.h:
+        * rendering/RenderRegion.cpp:
+        (WebCore::RenderRegion::RenderRegion):
+        (WebCore::RenderRegion::pageLogicalHeight):
+        (WebCore::RenderRegion::logicalHeightOfAllFlowThreadContent):
+        (WebCore::RenderRegion::isLastRegion):
+        (WebCore::RenderRegion::styleDidChange):
+        (WebCore::RenderRegion::attachRegion):
+        (WebCore::RenderRegion::detachRegion):
+        * rendering/RenderRegion.h:
+        * rendering/RenderRegionSet.h:
+        * rendering/RenderTreeAsText.cpp:
+        (WebCore::writeRenderRegionList):
+
 2014-01-09  Antti Koivisto  <[email protected]>
 
         Switch HTMLTableRowsCollection from Traversal<> to iterators

Modified: trunk/Source/WebCore/rendering/RenderFlowThread.cpp (161552 => 161553)


--- trunk/Source/WebCore/rendering/RenderFlowThread.cpp	2014-01-09 10:32:54 UTC (rev 161552)
+++ trunk/Source/WebCore/rendering/RenderFlowThread.cpp	2014-01-09 12:06:21 UTC (rev 161553)
@@ -173,7 +173,8 @@
                 // Also, if we have auto-height regions we can't assume m_regionsHaveUniformLogicalHeight to be true in the first phase
                 // because the auto-height regions don't have their height computed yet.
                 if (inMeasureContentLayoutPhase() && region->hasAutoLogicalHeight()) {
-                    region->setComputedAutoHeight(region->maxPageLogicalHeight());
+                    RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(region);
+                    namedFlowFragment->setComputedAutoHeight(namedFlowFragment->maxPageLogicalHeight());
                     m_regionsHaveUniformLogicalHeight = false;
                 }
 
@@ -916,8 +917,10 @@
     for (auto regionIter = startRegion ? m_regionList.find(startRegion) : m_regionList.begin(),
         end = m_regionList.end(); regionIter != end; ++regionIter) {
         RenderRegion* region = *regionIter;
-        if (region->hasAutoLogicalHeight())
-            region->setComputedAutoHeight(region->maxPageLogicalHeight());
+        if (region->hasAutoLogicalHeight()) {
+            RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(region);
+            namedFlowFragment->setComputedAutoHeight(namedFlowFragment->maxPageLogicalHeight());
+        }
     }
 }
 
@@ -960,7 +963,7 @@
 
         // If we find an empty auto-height region, clear the computedAutoHeight value.
         if (emptyRegionsSegment && region->hasAutoLogicalHeight())
-            region->clearComputedAutoHeight();
+            toRenderNamedFlowFragment(region)->clearComputedAutoHeight();
 
         LayoutUnit regionLogicalWidth = region->pageLogicalWidth();
         LayoutUnit regionLogicalHeight = std::min<LayoutUnit>(RenderFlowThread::maxLogicalHeight() - logicalHeight, region->logicalHeightOfAllFlowThreadContent());
@@ -1022,22 +1025,24 @@
     LayoutUnit offsetBreakInCurrentRegion = offsetBreakInFlowThread - currentRegionOffsetInFlowThread;
 
     if (region->hasAutoLogicalHeight()) {
+        RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(region);
+
         // A forced break can appear only in an auto-height region that didn't have a forced break before.
         // This ASSERT is a good-enough heuristic to verify the above condition.
-        ASSERT(region->maxPageLogicalHeight() == region->computedAutoHeight());
+        ASSERT(namedFlowFragment->maxPageLogicalHeight() == namedFlowFragment->computedAutoHeight());
 
-        mapToUse.set(breakChild, region);
+        mapToUse.set(breakChild, namedFlowFragment);
 
         hasComputedAutoHeight = true;
 
         // Compute the region height pretending that the offsetBreakInCurrentRegion is the logicalHeight for the auto-height region.
-        LayoutUnit regionComputedAutoHeight = region->constrainContentBoxLogicalHeightByMinMax(offsetBreakInCurrentRegion);
+        LayoutUnit regionComputedAutoHeight = namedFlowFragment->constrainContentBoxLogicalHeightByMinMax(offsetBreakInCurrentRegion);
 
         // The new height of this region needs to be smaller than the initial value, the max height. A forced break is the only way to change the initial
         // height of an auto-height region besides content ending.
-        ASSERT(regionComputedAutoHeight <= region->maxPageLogicalHeight());
+        ASSERT(regionComputedAutoHeight <= namedFlowFragment->maxPageLogicalHeight());
 
-        region->setComputedAutoHeight(regionComputedAutoHeight);
+        namedFlowFragment->setComputedAutoHeight(regionComputedAutoHeight);
 
         currentRegionOffsetInFlowThread += regionComputedAutoHeight;
     } else

Modified: trunk/Source/WebCore/rendering/RenderMultiColumnSet.h (161552 => 161553)


--- trunk/Source/WebCore/rendering/RenderMultiColumnSet.h	2014-01-09 10:32:54 UTC (rev 161552)
+++ trunk/Source/WebCore/rendering/RenderMultiColumnSet.h	2014-01-09 12:06:21 UTC (rev 161553)
@@ -109,10 +109,6 @@
     
     // FIXME: This will change once we have column sets constrained by enclosing pages, etc.
     virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const OVERRIDE { return m_computedColumnHeight; }
-
-    // FIXME: For now we return false, but it's likely we will leverage the auto height region code to do column
-    // balancing. That's why we have an override of this function that is distinct from RenderRegionSet's override.
-    virtual bool shouldHaveAutoLogicalHeight() const OVERRIDE { return false; }
     
     virtual void repaintFlowThreadContent(const LayoutRect& repaintRect, bool immediate) OVERRIDE;
 

Modified: trunk/Source/WebCore/rendering/RenderNamedFlowFragment.cpp (161552 => 161553)


--- trunk/Source/WebCore/rendering/RenderNamedFlowFragment.cpp	2014-01-09 10:32:54 UTC (rev 161552)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowFragment.cpp	2014-01-09 12:06:21 UTC (rev 161553)
@@ -38,11 +38,16 @@
 #include "RenderView.h"
 #include "StyleResolver.h"
 
+#include <wtf/StackStats.h>
+
 namespace WebCore {
 
 RenderNamedFlowFragment::RenderNamedFlowFragment(Document& document, PassRef<RenderStyle> style)
     : RenderRegion(document, std::move(style), nullptr)
     , m_hasCustomRegionStyle(false)
+    , m_hasAutoLogicalHeight(false)
+    , m_hasComputedAutoHeight(false)
+    , m_computedAutoHeight(0)
 {
 }
 
@@ -78,6 +83,8 @@
         return;
     }
 
+    updateRegionHasAutoLogicalHeightFlag();
+
     checkRegionStyle();
 
     if (parent() && parent()->needsLayout())
@@ -94,6 +101,82 @@
     return styleToUse.logicalHeight().isAuto() && !hasAnchoredEndpointsForHeight;
 }
 
+void RenderNamedFlowFragment::incrementAutoLogicalHeightCount()
+{
+    ASSERT(isValid());
+    ASSERT(m_hasAutoLogicalHeight);
+
+    m_flowThread->incrementAutoLogicalHeightRegions();
+}
+
+void RenderNamedFlowFragment::decrementAutoLogicalHeightCount()
+{
+    ASSERT(isValid());
+
+    m_flowThread->decrementAutoLogicalHeightRegions();
+}
+
+void RenderNamedFlowFragment::updateRegionHasAutoLogicalHeightFlag()
+{
+    ASSERT(m_flowThread);
+
+    if (!isValid())
+        return;
+
+    bool didHaveAutoLogicalHeight = m_hasAutoLogicalHeight;
+    m_hasAutoLogicalHeight = shouldHaveAutoLogicalHeight();
+    if (m_hasAutoLogicalHeight != didHaveAutoLogicalHeight) {
+        if (m_hasAutoLogicalHeight)
+            incrementAutoLogicalHeightCount();
+        else {
+            clearComputedAutoHeight();
+            decrementAutoLogicalHeightCount();
+        }
+    }
+}
+
+void RenderNamedFlowFragment::updateLogicalHeight()
+{
+    RenderRegion::updateLogicalHeight();
+
+    if (!hasAutoLogicalHeight())
+        return;
+
+    // We want to update the logical height based on the computed auto-height
+    // only after the measure cotnent layout phase when all the
+    // auto logical height regions have a computed auto-height.
+    if (m_flowThread->inMeasureContentLayoutPhase())
+        return;
+
+    // There may be regions with auto logical height that during the prerequisite layout phase
+    // did not have the chance to layout flow thread content. Because of that, these regions do not
+    // have a computedAutoHeight and they will not be able to fragment any flow
+    // thread content.
+    if (!hasComputedAutoHeight())
+        return;
+
+    LayoutUnit newLogicalHeight = computedAutoHeight() + borderAndPaddingLogicalHeight();
+    ASSERT(newLogicalHeight < RenderFlowThread::maxLogicalHeight());
+    if (newLogicalHeight > logicalHeight()) {
+        setLogicalHeight(newLogicalHeight);
+        // Recalculate position of the render block after new logical height is set.
+        // (needed in absolute positioning case with bottom alignment for example)
+        RenderRegion::updateLogicalHeight();
+    }
+}
+
+LayoutUnit RenderNamedFlowFragment::pageLogicalHeight() const
+{
+    ASSERT(m_flowThread);
+    if (hasComputedAutoHeight() && m_flowThread->inMeasureContentLayoutPhase()) {
+        ASSERT(hasAutoLogicalHeight());
+        return computedAutoHeight();
+    }
+    return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
+}
+
+// This method returns the maximum page size of a region with auto-height. This is the initial
+// height value for auto-height regions in the first layout phase of the parent named flow.
 LayoutUnit RenderNamedFlowFragment::maxPageLogicalHeight() const
 {
     ASSERT(m_flowThread);
@@ -105,6 +188,31 @@
     return styleToUse.logicalMaxHeight().isUndefined() ? RenderFlowThread::maxLogicalHeight() : toRenderBlock(parent())->computeReplacedLogicalHeightUsing(styleToUse.logicalMaxHeight());
 }
 
+void RenderNamedFlowFragment::layoutBlock(bool relayoutChildren, LayoutUnit)
+{
+    StackStats::LayoutCheckPoint layoutCheckPoint;
+    RenderRegion::layoutBlock(relayoutChildren);
+
+    if (isValid()) {
+        LayoutRect oldRegionRect(flowThreadPortionRect());
+        if (!isHorizontalWritingMode())
+            oldRegionRect = oldRegionRect.transposedRect();
+
+        if (m_flowThread->inOverflowLayoutPhase() || m_flowThread->inFinalLayoutPhase())
+            computeOverflowFromFlowThread();
+
+        if (hasAutoLogicalHeight() && m_flowThread->inMeasureContentLayoutPhase()) {
+            m_flowThread->invalidateRegions();
+            clearComputedAutoHeight();
+            return;
+        }
+
+        if ((oldRegionRect.width() != pageLogicalWidth() || oldRegionRect.height() != pageLogicalHeight()) && !m_flowThread->inFinalLayoutPhase())
+            // This can happen even if we are in the inConstrainedLayoutPhase and it will trigger a pathological layout of the flow thread.
+            m_flowThread->invalidateRegions();
+    }
+}
+
 void RenderNamedFlowFragment::checkRegionStyle()
 {
     ASSERT(m_flowThread);
@@ -277,4 +385,31 @@
     return RenderRegion::visualOverflowRect();
 }
 
+void RenderNamedFlowFragment::attachRegion()
+{
+    RenderRegion::attachRegion();
+
+    if (documentBeingDestroyed() || !m_flowThread)
+        return;
+
+    // The region just got attached to the flow thread, lets check whether
+    // it has region styling rules associated.
+    checkRegionStyle();
+
+    if (!isValid())
+        return;
+
+    m_hasAutoLogicalHeight = shouldHaveAutoLogicalHeight();
+    if (hasAutoLogicalHeight())
+        incrementAutoLogicalHeightCount();
+}
+
+void RenderNamedFlowFragment::detachRegion()
+{
+    if (m_flowThread && hasAutoLogicalHeight())
+        decrementAutoLogicalHeightCount();
+    
+    RenderRegion::detachRegion();
+}
+
 } // namespace WebCore

Modified: trunk/Source/WebCore/rendering/RenderNamedFlowFragment.h (161552 => 161553)


--- trunk/Source/WebCore/rendering/RenderNamedFlowFragment.h	2014-01-09 10:32:54 UTC (rev 161552)
+++ trunk/Source/WebCore/rendering/RenderNamedFlowFragment.h	2014-01-09 12:06:21 UTC (rev 161553)
@@ -57,7 +57,8 @@
     virtual bool isRenderNamedFlowFragment() const OVERRIDE FINAL { return true; }
     virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
 
-    virtual LayoutUnit maxPageLogicalHeight() const;
+    virtual LayoutUnit pageLogicalHeight() const;
+    LayoutUnit maxPageLogicalHeight() const;
 
     bool isPseudoElementRegion() const { return parent() && parent()->isPseudoElement(); }
 
@@ -79,18 +80,49 @@
 
     RenderNamedFlowThread* namedFlowThread() const;
 
+    virtual bool hasAutoLogicalHeight() const OVERRIDE { return m_hasAutoLogicalHeight; }
+
+    LayoutUnit computedAutoHeight() const { return m_computedAutoHeight; }
+
+    void setComputedAutoHeight(LayoutUnit computedAutoHeight)
+    {
+        m_hasComputedAutoHeight = true;
+        m_computedAutoHeight = computedAutoHeight;
+    }
+
+    void clearComputedAutoHeight()
+    {
+        m_hasComputedAutoHeight = false;
+        m_computedAutoHeight = 0;
+    }
+
+    bool hasComputedAutoHeight() const { return m_hasComputedAutoHeight; }
+
+    virtual void attachRegion() OVERRIDE;
+    virtual void detachRegion() OVERRIDE;
+
+    virtual void updateLogicalHeight() OVERRIDE;
+
 // FIXME: Temporarily public until we move all the CSSRegions functionality from RenderRegion to here.
 public:
     void checkRegionStyle();
 
 private:
-    virtual bool shouldHaveAutoLogicalHeight() const OVERRIDE;
     virtual const char* renderName() const OVERRIDE { return "RenderNamedFlowFragment"; }
 
     PassRefPtr<RenderStyle> computeStyleInRegion(const RenderObject*);
     void computeChildrenStyleInRegion(const RenderElement*);
     void setObjectStyleInRegion(RenderObject*, PassRefPtr<RenderStyle>, bool objectRegionStyleCached);
 
+    void updateRegionHasAutoLogicalHeightFlag();
+
+    void incrementAutoLogicalHeightCount();
+    void decrementAutoLogicalHeightCount();
+
+    bool shouldHaveAutoLogicalHeight() const;
+
+    virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE;
+
     struct ObjectRegionStyleInfo {
         // Used to store the original style of the object in region
         // so that the original style is properly restored after paint.
@@ -106,6 +138,10 @@
     RenderObjectRegionStyleMap m_renderObjectRegionStyle;
 
     bool m_hasCustomRegionStyle : 1;
+    bool m_hasAutoLogicalHeight : 1;
+    bool m_hasComputedAutoHeight : 1;
+
+    LayoutUnit m_computedAutoHeight;
 };
 
 RENDER_OBJECT_TYPE_CASTS(RenderNamedFlowFragment, isRenderNamedFlowFragment())

Modified: trunk/Source/WebCore/rendering/RenderRegion.cpp (161552 => 161553)


--- trunk/Source/WebCore/rendering/RenderRegion.cpp	2014-01-09 10:32:54 UTC (rev 161552)
+++ trunk/Source/WebCore/rendering/RenderRegion.cpp	2014-01-09 12:06:21 UTC (rev 161553)
@@ -44,7 +44,6 @@
 #include "RenderNamedFlowThread.h"
 #include "RenderView.h"
 #include "StyleResolver.h"
-#include <wtf/StackStats.h>
 
 namespace WebCore {
 
@@ -53,9 +52,6 @@
     , m_flowThread(flowThread)
     , m_parentNamedFlowThread(0)
     , m_isValid(false)
-    , m_hasAutoLogicalHeight(false)
-    , m_hasComputedAutoHeight(false)
-    , m_computedAutoHeight(0)
 {
 }
 
@@ -64,9 +60,6 @@
     , m_flowThread(flowThread)
     , m_parentNamedFlowThread(0)
     , m_isValid(false)
-    , m_hasAutoLogicalHeight(false)
-    , m_hasComputedAutoHeight(false)
-    , m_computedAutoHeight(0)
 {
 }
 
@@ -128,30 +121,12 @@
 LayoutUnit RenderRegion::pageLogicalHeight() const
 {
     ASSERT(m_flowThread);
-    if (hasComputedAutoHeight() && m_flowThread->inMeasureContentLayoutPhase()) {
-        ASSERT(hasAutoLogicalHeight());
-        return computedAutoHeight();
-    }
     return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
 }
 
-// This method returns the maximum page size of a region with auto-height. This is the initial
-// height value for auto-height regions in the first layout phase of the parent named flow.
-LayoutUnit RenderRegion::maxPageLogicalHeight() const
-{
-    ASSERT(m_flowThread);
-    ASSERT(hasAutoLogicalHeight() && m_flowThread->inMeasureContentLayoutPhase());
-    return style().logicalMaxHeight().isUndefined() ? RenderFlowThread::maxLogicalHeight() : computeReplacedLogicalHeightUsing(style().logicalMaxHeight());
-}
-
 LayoutUnit RenderRegion::logicalHeightOfAllFlowThreadContent() const
 {
-    ASSERT(m_flowThread);
-    if (hasComputedAutoHeight() && m_flowThread->inMeasureContentLayoutPhase()) {
-        ASSERT(hasAutoLogicalHeight());
-        return computedAutoHeight();
-    }
-    return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
+    return pageLogicalHeight();
 }
 
 LayoutRect RenderRegion::flowThreadPortionOverflowRect()
@@ -247,47 +222,6 @@
 
     return m_flowThread->lastRegion() == this;
 }
-
-void RenderRegion::incrementAutoLogicalHeightCount()
-{
-    ASSERT(isValid());
-    ASSERT(m_hasAutoLogicalHeight);
-
-    m_flowThread->incrementAutoLogicalHeightRegions();
-}
-
-void RenderRegion::decrementAutoLogicalHeightCount()
-{
-    ASSERT(isValid());
-
-    m_flowThread->decrementAutoLogicalHeightRegions();
-}
-
-void RenderRegion::updateRegionHasAutoLogicalHeightFlag()
-{
-    ASSERT(m_flowThread);
-
-    if (!isValid())
-        return;
-
-    bool didHaveAutoLogicalHeight = m_hasAutoLogicalHeight;
-    m_hasAutoLogicalHeight = shouldHaveAutoLogicalHeight();
-    if (m_hasAutoLogicalHeight != didHaveAutoLogicalHeight) {
-        if (m_hasAutoLogicalHeight)
-            incrementAutoLogicalHeightCount();
-        else {
-            clearComputedAutoHeight();
-            decrementAutoLogicalHeightCount();
-        }
-    }
-}
-
-bool RenderRegion::shouldHaveAutoLogicalHeight() const
-{
-    bool hasSpecifiedEndpointsForHeight = style().logicalTop().isSpecified() && style().logicalBottom().isSpecified();
-    bool hasAnchoredEndpointsForHeight = isOutOfFlowPositioned() && hasSpecifiedEndpointsForHeight;
-    return style().logicalHeight().isAuto() && !hasAnchoredEndpointsForHeight;
-}
     
 void RenderRegion::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
 {
@@ -296,37 +230,10 @@
     if (!m_flowThread)
         return;
 
-    updateRegionHasAutoLogicalHeightFlag();
-
     if (oldStyle && oldStyle->writingMode() != style().writingMode())
         m_flowThread->regionChangedWritingMode(this);
 }
 
-void RenderRegion::layoutBlock(bool relayoutChildren, LayoutUnit)
-{
-    StackStats::LayoutCheckPoint layoutCheckPoint;
-    RenderBlockFlow::layoutBlock(relayoutChildren);
-
-    if (isValid()) {
-        LayoutRect oldRegionRect(flowThreadPortionRect());
-        if (!isHorizontalWritingMode())
-            oldRegionRect = oldRegionRect.transposedRect();
-
-        if (m_flowThread->inOverflowLayoutPhase() || m_flowThread->inFinalLayoutPhase())
-            computeOverflowFromFlowThread();
-
-        if (hasAutoLogicalHeight() && m_flowThread->inMeasureContentLayoutPhase()) {
-            m_flowThread->invalidateRegions();
-            clearComputedAutoHeight();
-            return;
-        }
-
-        if (!isRenderRegionSet() && (oldRegionRect.width() != pageLogicalWidth() || oldRegionRect.height() != pageLogicalHeight()) && !m_flowThread->inFinalLayoutPhase())
-            // This can happen even if we are in the inConstrainedLayoutPhase and it will trigger a pathological layout of the flow thread.
-            m_flowThread->invalidateRegions();
-    }
-}
-
 void RenderRegion::computeOverflowFromFlowThread()
 {
     ASSERT(isValid());
@@ -425,28 +332,12 @@
 
     // Only after adding the region to the thread, the region is marked to be valid.
     m_flowThread->addRegionToThread(this);
-
-    // The region just got attached to the flow thread, lets check whether
-    // it has region styling rules associated.
-    // FIXME: Remove cast once attachRegion is moved to RenderNamedFlowFragment.
-    if (isRenderNamedFlowFragment())
-        toRenderNamedFlowFragment(this)->checkRegionStyle();
-
-    if (!isValid())
-        return;
-
-    m_hasAutoLogicalHeight = shouldHaveAutoLogicalHeight();
-    if (hasAutoLogicalHeight())
-        incrementAutoLogicalHeightCount();
 }
 
 void RenderRegion::detachRegion()
 {
-    if (m_flowThread) {
+    if (m_flowThread)
         m_flowThread->removeRegionFromThread(this);
-        if (hasAutoLogicalHeight())
-            decrementAutoLogicalHeightCount();
-    }
     m_flowThread = 0;
 }
 
@@ -558,36 +449,6 @@
     namedFlow.getRanges(rangeObjects, this);
 }
 
-void RenderRegion::updateLogicalHeight()
-{
-    RenderBlockFlow::updateLogicalHeight();
-
-    if (!hasAutoLogicalHeight())
-        return;
-
-    // We want to update the logical height based on the computed auto-height
-    // only after the measure cotnent layout phase when all the
-    // auto logical height regions have a computed auto-height.
-    if (m_flowThread->inMeasureContentLayoutPhase())
-        return;
-
-    // There may be regions with auto logical height that during the prerequisite layout phase
-    // did not have the chance to layout flow thread content. Because of that, these regions do not
-    // have a computedAutoHeight and they will not be able to fragment any flow
-    // thread content.
-    if (!hasComputedAutoHeight())
-        return;
-
-    LayoutUnit newLogicalHeight = computedAutoHeight() + borderAndPaddingLogicalHeight();
-    ASSERT(newLogicalHeight < LayoutUnit::max() / 2);
-    if (newLogicalHeight > logicalHeight()) {
-        setLogicalHeight(newLogicalHeight);
-        // Recalculate position of the render block after new logical height is set.
-        // (needed in absolute positioning case with bottom alignment for example)
-        RenderBlockFlow::updateLogicalHeight();
-    }
-}
-
 void RenderRegion::adjustRegionBoundsFromFlowThreadPortionRect(const IntPoint& layerOffset, IntRect& regionBounds)
 {
     LayoutRect flippedFlowThreadPortionRect = flowThreadPortionRect();

Modified: trunk/Source/WebCore/rendering/RenderRegion.h (161552 => 161553)


--- trunk/Source/WebCore/rendering/RenderRegion.h	2014-01-09 10:32:54 UTC (rev 161552)
+++ trunk/Source/WebCore/rendering/RenderRegion.h	2014-01-09 12:06:21 UTC (rev 161553)
@@ -59,8 +59,8 @@
     
     RenderLayer* regionContainerLayer() const;
 
-    void attachRegion();
-    void detachRegion();
+    virtual void attachRegion();
+    virtual void detachRegion();
 
     RenderNamedFlowThread* parentNamedFlowThread() const { return m_parentNamedFlowThread; }
     RenderFlowThread* flowThread() const { return m_flowThread; }
@@ -88,7 +88,6 @@
     // height of a single column or page in the set.
     virtual LayoutUnit pageLogicalWidth() const;
     virtual LayoutUnit pageLogicalHeight() const;
-    virtual LayoutUnit maxPageLogicalHeight() const;
 
     LayoutUnit logicalTopOfFlowThreadContentRect(const LayoutRect&) const;
     LayoutUnit logicalBottomOfFlowThreadContentRect(const LayoutRect&) const;
@@ -102,26 +101,6 @@
     // or columns added together.
     virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const;
 
-    bool hasAutoLogicalHeight() const { return m_hasAutoLogicalHeight; }
-
-    LayoutUnit computedAutoHeight() const { return m_computedAutoHeight; }
-
-    void setComputedAutoHeight(LayoutUnit computedAutoHeight)
-    {
-        m_hasComputedAutoHeight = true;
-        m_computedAutoHeight = computedAutoHeight;
-    }
-
-    void clearComputedAutoHeight()
-    {
-        m_hasComputedAutoHeight = false;
-        m_computedAutoHeight = 0;
-    }
-
-    bool hasComputedAutoHeight() const { return m_hasComputedAutoHeight; }
-
-    virtual void updateLogicalHeight() OVERRIDE;
-
     // The top of the nearest page inside the region. For RenderRegions, this is just the logical top of the
     // flow thread portion we contain. For sets, we have to figure out the top of the nearest column or
     // page.
@@ -154,6 +133,8 @@
     virtual bool canHaveGeneratedChildren() const OVERRIDE { return true; }
     virtual VisiblePosition positionForPoint(const LayoutPoint&) OVERRIDE;
 
+    virtual bool hasAutoLogicalHeight() const { return false; }
+
 protected:
     RenderRegion(Element&, PassRef<RenderStyle>, RenderFlowThread*);
     RenderRegion(Document&, PassRef<RenderStyle>, RenderFlowThread*);
@@ -170,7 +151,6 @@
 
     LayoutRect overflowRectForFlowThreadPortion(const LayoutRect& flowThreadPortionRect, bool isFirstPortion, bool isLastPortion, OverflowType);
     void repaintFlowThreadContentRectangle(const LayoutRect& repaintRect, bool immediate, const LayoutRect& flowThreadPortionRect, const LayoutPoint& regionLocation, const LayoutRect* flowThreadPortionClipRect = 0);
-    virtual bool shouldHaveAutoLogicalHeight() const;
 
     void computeOverflowFromFlowThread();
 
@@ -180,15 +160,8 @@
     virtual void insertedIntoTree() OVERRIDE;
     virtual void willBeRemovedFromTree() OVERRIDE;
 
-    virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE;
-
     virtual void installFlowThread();
 
-    void updateRegionHasAutoLogicalHeightFlag();
-
-    void incrementAutoLogicalHeightCount();
-    void decrementAutoLogicalHeightCount();
-
     LayoutPoint mapRegionPointIntoFlowThreadCoordinates(const LayoutPoint&);
 
 protected:
@@ -209,10 +182,6 @@
     RenderBoxRegionInfoMap m_renderBoxRegionInfo;
 
     bool m_isValid : 1;
-    bool m_hasAutoLogicalHeight : 1;
-    bool m_hasComputedAutoHeight : 1;
-
-    LayoutUnit m_computedAutoHeight;
 };
 
 RENDER_OBJECT_TYPE_CASTS(RenderRegion, isRenderRegion())

Modified: trunk/Source/WebCore/rendering/RenderRegionSet.h (161552 => 161553)


--- trunk/Source/WebCore/rendering/RenderRegionSet.h	2014-01-09 10:32:54 UTC (rev 161552)
+++ trunk/Source/WebCore/rendering/RenderRegionSet.h	2014-01-09 12:06:21 UTC (rev 161553)
@@ -48,7 +48,6 @@
 class RenderRegionSet : public RenderRegion {
 protected:
     RenderRegionSet(Document&, PassRef<RenderStyle>, RenderFlowThread&);
-    virtual bool shouldHaveAutoLogicalHeight() const OVERRIDE { return false; }
 
 private:
     virtual void installFlowThread() OVERRIDE FINAL;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to