Changeset 161553 in webkit


Ignore:
Timestamp:
Jan 9, 2014 4:06:21 AM (10 years ago)
Author:
abucur@adobe.com
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):

Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r161551 r161553  
     12014-01-09  Andrei Bucur  <abucur@adobe.com>
     2
     3        [CSSRegions] Move regions auto-size code into RenderNamedFlowFragment
     4        https://bugs.webkit.org/show_bug.cgi?id=122959
     5
     6        Reviewed by Mihnea Ovidenie.
     7
     8        Move the auto-height logic from RenderRegion to RenderNamedFlowFragment because it's
     9        used only by the CSS Regions implementation.
     10
     11        Bug 126642 covers the auto-height logic move from RenderFlowThread to RenderNamedFlowThread.
     12
     13        Tests: No new tests, just refactorings.
     14
     15        * rendering/RenderFlowThread.cpp:
     16        (WebCore::RenderFlowThread::styleDidChange):
     17        (WebCore::RenderFlowThread::validateRegions):
     18        (WebCore::RenderFlowThread::isAutoLogicalHeightRegionsCountConsistent):
     19        (WebCore::RenderFlowThread::initializeRegionsComputedAutoHeight):
     20        (WebCore::RenderFlowThread::markAutoLogicalHeightRegionsForLayout):
     21        (WebCore::RenderFlowThread::updateRegionsFlowThreadPortionRect):
     22        (WebCore::RenderFlowThread::addForcedRegionBreak):
     23        * rendering/RenderMultiColumnSet.h:
     24        * rendering/RenderNamedFlowFragment.cpp:
     25        (WebCore::RenderNamedFlowFragment::RenderNamedFlowFragment):
     26        (WebCore::RenderNamedFlowFragment::styleDidChange):
     27        (WebCore::RenderNamedFlowFragment::incrementAutoLogicalHeightCount):
     28        (WebCore::RenderNamedFlowFragment::decrementAutoLogicalHeightCount):
     29        (WebCore::RenderNamedFlowFragment::updateRegionHasAutoLogicalHeightFlag):
     30        (WebCore::RenderNamedFlowFragment::updateLogicalHeight):
     31        (WebCore::RenderNamedFlowFragment::pageLogicalHeight):
     32        (WebCore::RenderNamedFlowFragment::layoutBlock):
     33        (WebCore::RenderNamedFlowFragment::attachRegion):
     34        (WebCore::RenderNamedFlowFragment::detachRegion):
     35        * rendering/RenderNamedFlowFragment.h:
     36        * rendering/RenderRegion.cpp:
     37        (WebCore::RenderRegion::RenderRegion):
     38        (WebCore::RenderRegion::pageLogicalHeight):
     39        (WebCore::RenderRegion::logicalHeightOfAllFlowThreadContent):
     40        (WebCore::RenderRegion::isLastRegion):
     41        (WebCore::RenderRegion::styleDidChange):
     42        (WebCore::RenderRegion::attachRegion):
     43        (WebCore::RenderRegion::detachRegion):
     44        * rendering/RenderRegion.h:
     45        * rendering/RenderRegionSet.h:
     46        * rendering/RenderTreeAsText.cpp:
     47        (WebCore::writeRenderRegionList):
     48
    1492014-01-09  Antti Koivisto  <antti@apple.com>
    250
  • trunk/Source/WebCore/rendering/RenderFlowThread.cpp

    r161443 r161553  
    174174                // because the auto-height regions don't have their height computed yet.
    175175                if (inMeasureContentLayoutPhase() && region->hasAutoLogicalHeight()) {
    176                     region->setComputedAutoHeight(region->maxPageLogicalHeight());
     176                    RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(region);
     177                    namedFlowFragment->setComputedAutoHeight(namedFlowFragment->maxPageLogicalHeight());
    177178                    m_regionsHaveUniformLogicalHeight = false;
    178179                }
     
    917918        end = m_regionList.end(); regionIter != end; ++regionIter) {
    918919        RenderRegion* region = *regionIter;
    919         if (region->hasAutoLogicalHeight())
    920             region->setComputedAutoHeight(region->maxPageLogicalHeight());
     920        if (region->hasAutoLogicalHeight()) {
     921            RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(region);
     922            namedFlowFragment->setComputedAutoHeight(namedFlowFragment->maxPageLogicalHeight());
     923        }
    921924    }
    922925}
     
    961964        // If we find an empty auto-height region, clear the computedAutoHeight value.
    962965        if (emptyRegionsSegment && region->hasAutoLogicalHeight())
    963             region->clearComputedAutoHeight();
     966            toRenderNamedFlowFragment(region)->clearComputedAutoHeight();
    964967
    965968        LayoutUnit regionLogicalWidth = region->pageLogicalWidth();
     
    10231026
    10241027    if (region->hasAutoLogicalHeight()) {
     1028        RenderNamedFlowFragment* namedFlowFragment = toRenderNamedFlowFragment(region);
     1029
    10251030        // A forced break can appear only in an auto-height region that didn't have a forced break before.
    10261031        // This ASSERT is a good-enough heuristic to verify the above condition.
    1027         ASSERT(region->maxPageLogicalHeight() == region->computedAutoHeight());
    1028 
    1029         mapToUse.set(breakChild, region);
     1032        ASSERT(namedFlowFragment->maxPageLogicalHeight() == namedFlowFragment->computedAutoHeight());
     1033
     1034        mapToUse.set(breakChild, namedFlowFragment);
    10301035
    10311036        hasComputedAutoHeight = true;
    10321037
    10331038        // Compute the region height pretending that the offsetBreakInCurrentRegion is the logicalHeight for the auto-height region.
    1034         LayoutUnit regionComputedAutoHeight = region->constrainContentBoxLogicalHeightByMinMax(offsetBreakInCurrentRegion);
     1039        LayoutUnit regionComputedAutoHeight = namedFlowFragment->constrainContentBoxLogicalHeightByMinMax(offsetBreakInCurrentRegion);
    10351040
    10361041        // 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
    10371042        // height of an auto-height region besides content ending.
    1038         ASSERT(regionComputedAutoHeight <= region->maxPageLogicalHeight());
    1039 
    1040         region->setComputedAutoHeight(regionComputedAutoHeight);
     1043        ASSERT(regionComputedAutoHeight <= namedFlowFragment->maxPageLogicalHeight());
     1044
     1045        namedFlowFragment->setComputedAutoHeight(regionComputedAutoHeight);
    10411046
    10421047        currentRegionOffsetInFlowThread += regionComputedAutoHeight;
  • trunk/Source/WebCore/rendering/RenderMultiColumnSet.h

    r159609 r161553  
    110110    // FIXME: This will change once we have column sets constrained by enclosing pages, etc.
    111111    virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const OVERRIDE { return m_computedColumnHeight; }
    112 
    113     // FIXME: For now we return false, but it's likely we will leverage the auto height region code to do column
    114     // balancing. That's why we have an override of this function that is distinct from RenderRegionSet's override.
    115     virtual bool shouldHaveAutoLogicalHeight() const OVERRIDE { return false; }
    116112   
    117113    virtual void repaintFlowThreadContent(const LayoutRect& repaintRect, bool immediate) OVERRIDE;
  • trunk/Source/WebCore/rendering/RenderNamedFlowFragment.cpp

    r160905 r161553  
    3939#include "StyleResolver.h"
    4040
     41#include <wtf/StackStats.h>
     42
    4143namespace WebCore {
    4244
     
    4446    : RenderRegion(document, std::move(style), nullptr)
    4547    , m_hasCustomRegionStyle(false)
     48    , m_hasAutoLogicalHeight(false)
     49    , m_hasComputedAutoHeight(false)
     50    , m_computedAutoHeight(0)
    4651{
    4752}
     
    7984    }
    8085
     86    updateRegionHasAutoLogicalHeightFlag();
     87
    8188    checkRegionStyle();
    8289
     
    95102}
    96103
     104void RenderNamedFlowFragment::incrementAutoLogicalHeightCount()
     105{
     106    ASSERT(isValid());
     107    ASSERT(m_hasAutoLogicalHeight);
     108
     109    m_flowThread->incrementAutoLogicalHeightRegions();
     110}
     111
     112void RenderNamedFlowFragment::decrementAutoLogicalHeightCount()
     113{
     114    ASSERT(isValid());
     115
     116    m_flowThread->decrementAutoLogicalHeightRegions();
     117}
     118
     119void RenderNamedFlowFragment::updateRegionHasAutoLogicalHeightFlag()
     120{
     121    ASSERT(m_flowThread);
     122
     123    if (!isValid())
     124        return;
     125
     126    bool didHaveAutoLogicalHeight = m_hasAutoLogicalHeight;
     127    m_hasAutoLogicalHeight = shouldHaveAutoLogicalHeight();
     128    if (m_hasAutoLogicalHeight != didHaveAutoLogicalHeight) {
     129        if (m_hasAutoLogicalHeight)
     130            incrementAutoLogicalHeightCount();
     131        else {
     132            clearComputedAutoHeight();
     133            decrementAutoLogicalHeightCount();
     134        }
     135    }
     136}
     137
     138void RenderNamedFlowFragment::updateLogicalHeight()
     139{
     140    RenderRegion::updateLogicalHeight();
     141
     142    if (!hasAutoLogicalHeight())
     143        return;
     144
     145    // We want to update the logical height based on the computed auto-height
     146    // only after the measure cotnent layout phase when all the
     147    // auto logical height regions have a computed auto-height.
     148    if (m_flowThread->inMeasureContentLayoutPhase())
     149        return;
     150
     151    // There may be regions with auto logical height that during the prerequisite layout phase
     152    // did not have the chance to layout flow thread content. Because of that, these regions do not
     153    // have a computedAutoHeight and they will not be able to fragment any flow
     154    // thread content.
     155    if (!hasComputedAutoHeight())
     156        return;
     157
     158    LayoutUnit newLogicalHeight = computedAutoHeight() + borderAndPaddingLogicalHeight();
     159    ASSERT(newLogicalHeight < RenderFlowThread::maxLogicalHeight());
     160    if (newLogicalHeight > logicalHeight()) {
     161        setLogicalHeight(newLogicalHeight);
     162        // Recalculate position of the render block after new logical height is set.
     163        // (needed in absolute positioning case with bottom alignment for example)
     164        RenderRegion::updateLogicalHeight();
     165    }
     166}
     167
     168LayoutUnit RenderNamedFlowFragment::pageLogicalHeight() const
     169{
     170    ASSERT(m_flowThread);
     171    if (hasComputedAutoHeight() && m_flowThread->inMeasureContentLayoutPhase()) {
     172        ASSERT(hasAutoLogicalHeight());
     173        return computedAutoHeight();
     174    }
     175    return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
     176}
     177
     178// This method returns the maximum page size of a region with auto-height. This is the initial
     179// height value for auto-height regions in the first layout phase of the parent named flow.
    97180LayoutUnit RenderNamedFlowFragment::maxPageLogicalHeight() const
    98181{
     
    104187    const RenderStyle& styleToUse = parent()->style();
    105188    return styleToUse.logicalMaxHeight().isUndefined() ? RenderFlowThread::maxLogicalHeight() : toRenderBlock(parent())->computeReplacedLogicalHeightUsing(styleToUse.logicalMaxHeight());
     189}
     190
     191void RenderNamedFlowFragment::layoutBlock(bool relayoutChildren, LayoutUnit)
     192{
     193    StackStats::LayoutCheckPoint layoutCheckPoint;
     194    RenderRegion::layoutBlock(relayoutChildren);
     195
     196    if (isValid()) {
     197        LayoutRect oldRegionRect(flowThreadPortionRect());
     198        if (!isHorizontalWritingMode())
     199            oldRegionRect = oldRegionRect.transposedRect();
     200
     201        if (m_flowThread->inOverflowLayoutPhase() || m_flowThread->inFinalLayoutPhase())
     202            computeOverflowFromFlowThread();
     203
     204        if (hasAutoLogicalHeight() && m_flowThread->inMeasureContentLayoutPhase()) {
     205            m_flowThread->invalidateRegions();
     206            clearComputedAutoHeight();
     207            return;
     208        }
     209
     210        if ((oldRegionRect.width() != pageLogicalWidth() || oldRegionRect.height() != pageLogicalHeight()) && !m_flowThread->inFinalLayoutPhase())
     211            // This can happen even if we are in the inConstrainedLayoutPhase and it will trigger a pathological layout of the flow thread.
     212            m_flowThread->invalidateRegions();
     213    }
    106214}
    107215
     
    278386}
    279387
     388void RenderNamedFlowFragment::attachRegion()
     389{
     390    RenderRegion::attachRegion();
     391
     392    if (documentBeingDestroyed() || !m_flowThread)
     393        return;
     394
     395    // The region just got attached to the flow thread, lets check whether
     396    // it has region styling rules associated.
     397    checkRegionStyle();
     398
     399    if (!isValid())
     400        return;
     401
     402    m_hasAutoLogicalHeight = shouldHaveAutoLogicalHeight();
     403    if (hasAutoLogicalHeight())
     404        incrementAutoLogicalHeightCount();
     405}
     406
     407void RenderNamedFlowFragment::detachRegion()
     408{
     409    if (m_flowThread && hasAutoLogicalHeight())
     410        decrementAutoLogicalHeightCount();
     411   
     412    RenderRegion::detachRegion();
     413}
     414
    280415} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderNamedFlowFragment.h

    r160905 r161553  
    5858    virtual void styleDidChange(StyleDifference, const RenderStyle* oldStyle) OVERRIDE;
    5959
    60     virtual LayoutUnit maxPageLogicalHeight() const;
     60    virtual LayoutUnit pageLogicalHeight() const;
     61    LayoutUnit maxPageLogicalHeight() const;
    6162
    6263    bool isPseudoElementRegion() const { return parent() && parent()->isPseudoElement(); }
     
    8081    RenderNamedFlowThread* namedFlowThread() const;
    8182
     83    virtual bool hasAutoLogicalHeight() const OVERRIDE { return m_hasAutoLogicalHeight; }
     84
     85    LayoutUnit computedAutoHeight() const { return m_computedAutoHeight; }
     86
     87    void setComputedAutoHeight(LayoutUnit computedAutoHeight)
     88    {
     89        m_hasComputedAutoHeight = true;
     90        m_computedAutoHeight = computedAutoHeight;
     91    }
     92
     93    void clearComputedAutoHeight()
     94    {
     95        m_hasComputedAutoHeight = false;
     96        m_computedAutoHeight = 0;
     97    }
     98
     99    bool hasComputedAutoHeight() const { return m_hasComputedAutoHeight; }
     100
     101    virtual void attachRegion() OVERRIDE;
     102    virtual void detachRegion() OVERRIDE;
     103
     104    virtual void updateLogicalHeight() OVERRIDE;
     105
    82106// FIXME: Temporarily public until we move all the CSSRegions functionality from RenderRegion to here.
    83107public:
     
    85109
    86110private:
    87     virtual bool shouldHaveAutoLogicalHeight() const OVERRIDE;
    88111    virtual const char* renderName() const OVERRIDE { return "RenderNamedFlowFragment"; }
    89112
     
    91114    void computeChildrenStyleInRegion(const RenderElement*);
    92115    void setObjectStyleInRegion(RenderObject*, PassRefPtr<RenderStyle>, bool objectRegionStyleCached);
     116
     117    void updateRegionHasAutoLogicalHeightFlag();
     118
     119    void incrementAutoLogicalHeightCount();
     120    void decrementAutoLogicalHeightCount();
     121
     122    bool shouldHaveAutoLogicalHeight() const;
     123
     124    virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE;
    93125
    94126    struct ObjectRegionStyleInfo {
     
    107139
    108140    bool m_hasCustomRegionStyle : 1;
     141    bool m_hasAutoLogicalHeight : 1;
     142    bool m_hasComputedAutoHeight : 1;
     143
     144    LayoutUnit m_computedAutoHeight;
    109145};
    110146
  • trunk/Source/WebCore/rendering/RenderRegion.cpp

    r160979 r161553  
    4545#include "RenderView.h"
    4646#include "StyleResolver.h"
    47 #include <wtf/StackStats.h>
    4847
    4948namespace WebCore {
     
    5453    , m_parentNamedFlowThread(0)
    5554    , m_isValid(false)
    56     , m_hasAutoLogicalHeight(false)
    57     , m_hasComputedAutoHeight(false)
    58     , m_computedAutoHeight(0)
    5955{
    6056}
     
    6561    , m_parentNamedFlowThread(0)
    6662    , m_isValid(false)
    67     , m_hasAutoLogicalHeight(false)
    68     , m_hasComputedAutoHeight(false)
    69     , m_computedAutoHeight(0)
    7063{
    7164}
     
    129122{
    130123    ASSERT(m_flowThread);
    131     if (hasComputedAutoHeight() && m_flowThread->inMeasureContentLayoutPhase()) {
    132         ASSERT(hasAutoLogicalHeight());
    133         return computedAutoHeight();
    134     }
    135124    return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
    136125}
    137126
    138 // This method returns the maximum page size of a region with auto-height. This is the initial
    139 // height value for auto-height regions in the first layout phase of the parent named flow.
    140 LayoutUnit RenderRegion::maxPageLogicalHeight() const
    141 {
    142     ASSERT(m_flowThread);
    143     ASSERT(hasAutoLogicalHeight() && m_flowThread->inMeasureContentLayoutPhase());
    144     return style().logicalMaxHeight().isUndefined() ? RenderFlowThread::maxLogicalHeight() : computeReplacedLogicalHeightUsing(style().logicalMaxHeight());
    145 }
    146 
    147127LayoutUnit RenderRegion::logicalHeightOfAllFlowThreadContent() const
    148128{
    149     ASSERT(m_flowThread);
    150     if (hasComputedAutoHeight() && m_flowThread->inMeasureContentLayoutPhase()) {
    151         ASSERT(hasAutoLogicalHeight());
    152         return computedAutoHeight();
    153     }
    154     return m_flowThread->isHorizontalWritingMode() ? contentHeight() : contentWidth();
     129    return pageLogicalHeight();
    155130}
    156131
     
    248223    return m_flowThread->lastRegion() == this;
    249224}
    250 
    251 void RenderRegion::incrementAutoLogicalHeightCount()
    252 {
    253     ASSERT(isValid());
    254     ASSERT(m_hasAutoLogicalHeight);
    255 
    256     m_flowThread->incrementAutoLogicalHeightRegions();
    257 }
    258 
    259 void RenderRegion::decrementAutoLogicalHeightCount()
    260 {
    261     ASSERT(isValid());
    262 
    263     m_flowThread->decrementAutoLogicalHeightRegions();
    264 }
    265 
    266 void RenderRegion::updateRegionHasAutoLogicalHeightFlag()
    267 {
    268     ASSERT(m_flowThread);
    269 
    270     if (!isValid())
    271         return;
    272 
    273     bool didHaveAutoLogicalHeight = m_hasAutoLogicalHeight;
    274     m_hasAutoLogicalHeight = shouldHaveAutoLogicalHeight();
    275     if (m_hasAutoLogicalHeight != didHaveAutoLogicalHeight) {
    276         if (m_hasAutoLogicalHeight)
    277             incrementAutoLogicalHeightCount();
    278         else {
    279             clearComputedAutoHeight();
    280             decrementAutoLogicalHeightCount();
    281         }
    282     }
    283 }
    284 
    285 bool RenderRegion::shouldHaveAutoLogicalHeight() const
    286 {
    287     bool hasSpecifiedEndpointsForHeight = style().logicalTop().isSpecified() && style().logicalBottom().isSpecified();
    288     bool hasAnchoredEndpointsForHeight = isOutOfFlowPositioned() && hasSpecifiedEndpointsForHeight;
    289     return style().logicalHeight().isAuto() && !hasAnchoredEndpointsForHeight;
    290 }
    291225   
    292226void RenderRegion::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
     
    296230    if (!m_flowThread)
    297231        return;
    298 
    299     updateRegionHasAutoLogicalHeightFlag();
    300232
    301233    if (oldStyle && oldStyle->writingMode() != style().writingMode())
    302234        m_flowThread->regionChangedWritingMode(this);
    303 }
    304 
    305 void RenderRegion::layoutBlock(bool relayoutChildren, LayoutUnit)
    306 {
    307     StackStats::LayoutCheckPoint layoutCheckPoint;
    308     RenderBlockFlow::layoutBlock(relayoutChildren);
    309 
    310     if (isValid()) {
    311         LayoutRect oldRegionRect(flowThreadPortionRect());
    312         if (!isHorizontalWritingMode())
    313             oldRegionRect = oldRegionRect.transposedRect();
    314 
    315         if (m_flowThread->inOverflowLayoutPhase() || m_flowThread->inFinalLayoutPhase())
    316             computeOverflowFromFlowThread();
    317 
    318         if (hasAutoLogicalHeight() && m_flowThread->inMeasureContentLayoutPhase()) {
    319             m_flowThread->invalidateRegions();
    320             clearComputedAutoHeight();
    321             return;
    322         }
    323 
    324         if (!isRenderRegionSet() && (oldRegionRect.width() != pageLogicalWidth() || oldRegionRect.height() != pageLogicalHeight()) && !m_flowThread->inFinalLayoutPhase())
    325             // This can happen even if we are in the inConstrainedLayoutPhase and it will trigger a pathological layout of the flow thread.
    326             m_flowThread->invalidateRegions();
    327     }
    328235}
    329236
     
    426333    // Only after adding the region to the thread, the region is marked to be valid.
    427334    m_flowThread->addRegionToThread(this);
    428 
    429     // The region just got attached to the flow thread, lets check whether
    430     // it has region styling rules associated.
    431     // FIXME: Remove cast once attachRegion is moved to RenderNamedFlowFragment.
    432     if (isRenderNamedFlowFragment())
    433         toRenderNamedFlowFragment(this)->checkRegionStyle();
    434 
    435     if (!isValid())
    436         return;
    437 
    438     m_hasAutoLogicalHeight = shouldHaveAutoLogicalHeight();
    439     if (hasAutoLogicalHeight())
    440         incrementAutoLogicalHeightCount();
    441335}
    442336
    443337void RenderRegion::detachRegion()
    444338{
    445     if (m_flowThread) {
     339    if (m_flowThread)
    446340        m_flowThread->removeRegionFromThread(this);
    447         if (hasAutoLogicalHeight())
    448             decrementAutoLogicalHeightCount();
    449     }
    450341    m_flowThread = 0;
    451342}
     
    557448    const RenderNamedFlowThread& namedFlow = view().flowThreadController().ensureRenderFlowThreadWithName(style().regionThread());
    558449    namedFlow.getRanges(rangeObjects, this);
    559 }
    560 
    561 void RenderRegion::updateLogicalHeight()
    562 {
    563     RenderBlockFlow::updateLogicalHeight();
    564 
    565     if (!hasAutoLogicalHeight())
    566         return;
    567 
    568     // We want to update the logical height based on the computed auto-height
    569     // only after the measure cotnent layout phase when all the
    570     // auto logical height regions have a computed auto-height.
    571     if (m_flowThread->inMeasureContentLayoutPhase())
    572         return;
    573 
    574     // There may be regions with auto logical height that during the prerequisite layout phase
    575     // did not have the chance to layout flow thread content. Because of that, these regions do not
    576     // have a computedAutoHeight and they will not be able to fragment any flow
    577     // thread content.
    578     if (!hasComputedAutoHeight())
    579         return;
    580 
    581     LayoutUnit newLogicalHeight = computedAutoHeight() + borderAndPaddingLogicalHeight();
    582     ASSERT(newLogicalHeight < LayoutUnit::max() / 2);
    583     if (newLogicalHeight > logicalHeight()) {
    584         setLogicalHeight(newLogicalHeight);
    585         // Recalculate position of the render block after new logical height is set.
    586         // (needed in absolute positioning case with bottom alignment for example)
    587         RenderBlockFlow::updateLogicalHeight();
    588     }
    589450}
    590451
  • trunk/Source/WebCore/rendering/RenderRegion.h

    r159609 r161553  
    6060    RenderLayer* regionContainerLayer() const;
    6161
    62     void attachRegion();
    63     void detachRegion();
     62    virtual void attachRegion();
     63    virtual void detachRegion();
    6464
    6565    RenderNamedFlowThread* parentNamedFlowThread() const { return m_parentNamedFlowThread; }
     
    8989    virtual LayoutUnit pageLogicalWidth() const;
    9090    virtual LayoutUnit pageLogicalHeight() const;
    91     virtual LayoutUnit maxPageLogicalHeight() const;
    9291
    9392    LayoutUnit logicalTopOfFlowThreadContentRect(const LayoutRect&) const;
     
    102101    // or columns added together.
    103102    virtual LayoutUnit logicalHeightOfAllFlowThreadContent() const;
    104 
    105     bool hasAutoLogicalHeight() const { return m_hasAutoLogicalHeight; }
    106 
    107     LayoutUnit computedAutoHeight() const { return m_computedAutoHeight; }
    108 
    109     void setComputedAutoHeight(LayoutUnit computedAutoHeight)
    110     {
    111         m_hasComputedAutoHeight = true;
    112         m_computedAutoHeight = computedAutoHeight;
    113     }
    114 
    115     void clearComputedAutoHeight()
    116     {
    117         m_hasComputedAutoHeight = false;
    118         m_computedAutoHeight = 0;
    119     }
    120 
    121     bool hasComputedAutoHeight() const { return m_hasComputedAutoHeight; }
    122 
    123     virtual void updateLogicalHeight() OVERRIDE;
    124103
    125104    // The top of the nearest page inside the region. For RenderRegions, this is just the logical top of the
     
    155134    virtual VisiblePosition positionForPoint(const LayoutPoint&) OVERRIDE;
    156135
     136    virtual bool hasAutoLogicalHeight() const { return false; }
     137
    157138protected:
    158139    RenderRegion(Element&, PassRef<RenderStyle>, RenderFlowThread*);
     
    171152    LayoutRect overflowRectForFlowThreadPortion(const LayoutRect& flowThreadPortionRect, bool isFirstPortion, bool isLastPortion, OverflowType);
    172153    void repaintFlowThreadContentRectangle(const LayoutRect& repaintRect, bool immediate, const LayoutRect& flowThreadPortionRect, const LayoutPoint& regionLocation, const LayoutRect* flowThreadPortionClipRect = 0);
    173     virtual bool shouldHaveAutoLogicalHeight() const;
    174154
    175155    void computeOverflowFromFlowThread();
     
    181161    virtual void willBeRemovedFromTree() OVERRIDE;
    182162
    183     virtual void layoutBlock(bool relayoutChildren, LayoutUnit pageLogicalHeight = 0) OVERRIDE;
    184 
    185163    virtual void installFlowThread();
    186 
    187     void updateRegionHasAutoLogicalHeightFlag();
    188 
    189     void incrementAutoLogicalHeightCount();
    190     void decrementAutoLogicalHeightCount();
    191164
    192165    LayoutPoint mapRegionPointIntoFlowThreadCoordinates(const LayoutPoint&);
     
    210183
    211184    bool m_isValid : 1;
    212     bool m_hasAutoLogicalHeight : 1;
    213     bool m_hasComputedAutoHeight : 1;
    214 
    215     LayoutUnit m_computedAutoHeight;
    216185};
    217186
  • trunk/Source/WebCore/rendering/RenderRegionSet.h

    r158097 r161553  
    4949protected:
    5050    RenderRegionSet(Document&, PassRef<RenderStyle>, RenderFlowThread&);
    51     virtual bool shouldHaveAutoLogicalHeight() const OVERRIDE { return false; }
    5251
    5352private:
Note: See TracChangeset for help on using the changeset viewer.