Changeset 158954 in webkit


Ignore:
Timestamp:
Nov 8, 2013 2:01:33 PM (10 years ago)
Author:
Bem Jones-Bey
Message:

RenderBlockFlow::nextFloatLogicalBottomBelow should not use ShapeOutsideFloatOffsetMode
https://bugs.webkit.org/show_bug.cgi?id=123931

Reviewed by Sam Weinig.

Rewrite nextFloatLogicalBottomBelow to use the placed floats tree for
the search and to not need ShapeOutsideFloatOffsetMode anymore. This
moves almost all of the logic into FloatingObjects, making a small
reduction in the amount that RenderBlockFlow needs to know about the
implementation of FloatingObjects.

In addition, change ComputeFloatOffsetAdapter to take in LayoutUnits
and roundToInt itself so that all of it's callers can be simplified.

No new tests, no new behavior.

  • rendering/FloatingObjects.cpp:

(WebCore::rangesIntersect):
(WebCore::ComputeFloatOffsetAdapter::ComputeFloatOffsetAdapter):
(WebCore::FindNextFloatLogicalBottomAdapter::FindNextFloatLogicalBottomAdapter):
(WebCore::FindNextFloatLogicalBottomAdapter::lowValue):
(WebCore::FindNextFloatLogicalBottomAdapter::highValue):
(WebCore::FindNextFloatLogicalBottomAdapter::nextLogicalBottom):
(WebCore::FindNextFloatLogicalBottomAdapter::nextShapeLogicalBottom):
(WebCore::FindNextFloatLogicalBottomAdapter::collectIfNeeded):
(WebCore::FloatingObjects::findNextFloatLogicalBottomBelow):
(WebCore::FloatingObjects::findNextFloatLogicalBottomBelowForBlock):
(WebCore::FloatingObjects::logicalLeftOffsetForPositioningFloat):
(WebCore::FloatingObjects::logicalRightOffsetForPositioningFloat):
(WebCore::FloatingObjects::logicalLeftOffset):
(WebCore::FloatingObjects::logicalRightOffset):

  • rendering/FloatingObjects.h:
  • rendering/LineWidth.cpp:

(WebCore::LineWidth::fitBelowFloats):

  • rendering/RenderBlockFlow.cpp:

(WebCore::RenderBlockFlow::nextFloatLogicalBottomBelow):
(WebCore::RenderBlockFlow::nextFloatLogicalBottomBelowForBlock):
(WebCore::RenderBlockFlow::getClearDelta):

  • rendering/RenderBlockFlow.h:
Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r158945 r158954  
     12013-11-08  Bem Jones-Bey  <bjonesbe@adobe.com>
     2
     3        RenderBlockFlow::nextFloatLogicalBottomBelow should not use ShapeOutsideFloatOffsetMode
     4        https://bugs.webkit.org/show_bug.cgi?id=123931
     5
     6        Reviewed by Sam Weinig.
     7
     8        Rewrite nextFloatLogicalBottomBelow to use the placed floats tree for
     9        the search and to not need ShapeOutsideFloatOffsetMode anymore. This
     10        moves almost all of the logic into FloatingObjects, making a small
     11        reduction in the amount that RenderBlockFlow needs to know about the
     12        implementation of FloatingObjects.
     13
     14        In addition, change ComputeFloatOffsetAdapter to take in LayoutUnits
     15        and roundToInt itself so that all of it's callers can be simplified.
     16
     17        No new tests, no new behavior.
     18
     19        * rendering/FloatingObjects.cpp:
     20        (WebCore::rangesIntersect):
     21        (WebCore::ComputeFloatOffsetAdapter::ComputeFloatOffsetAdapter):
     22        (WebCore::FindNextFloatLogicalBottomAdapter::FindNextFloatLogicalBottomAdapter):
     23        (WebCore::FindNextFloatLogicalBottomAdapter::lowValue):
     24        (WebCore::FindNextFloatLogicalBottomAdapter::highValue):
     25        (WebCore::FindNextFloatLogicalBottomAdapter::nextLogicalBottom):
     26        (WebCore::FindNextFloatLogicalBottomAdapter::nextShapeLogicalBottom):
     27        (WebCore::FindNextFloatLogicalBottomAdapter::collectIfNeeded):
     28        (WebCore::FloatingObjects::findNextFloatLogicalBottomBelow):
     29        (WebCore::FloatingObjects::findNextFloatLogicalBottomBelowForBlock):
     30        (WebCore::FloatingObjects::logicalLeftOffsetForPositioningFloat):
     31        (WebCore::FloatingObjects::logicalRightOffsetForPositioningFloat):
     32        (WebCore::FloatingObjects::logicalLeftOffset):
     33        (WebCore::FloatingObjects::logicalRightOffset):
     34        * rendering/FloatingObjects.h:
     35        * rendering/LineWidth.cpp:
     36        (WebCore::LineWidth::fitBelowFloats):
     37        * rendering/RenderBlockFlow.cpp:
     38        (WebCore::RenderBlockFlow::nextFloatLogicalBottomBelow):
     39        (WebCore::RenderBlockFlow::nextFloatLogicalBottomBelowForBlock):
     40        (WebCore::RenderBlockFlow::getClearDelta):
     41        * rendering/RenderBlockFlow.h:
     42
    1432013-11-08  Alexey Proskuryakov  <ap@apple.com>
    244
  • trunk/Source/WebCore/rendering/FloatingObjects.cpp

    r158856 r158954  
    101101}
    102102
     103inline static bool rangesIntersect(int floatTop, int floatBottom, int objectTop, int objectBottom)
     104{
     105    if (objectTop >= floatBottom || objectBottom < floatTop)
     106        return false;
     107
     108    // The top of the object overlaps the float
     109    if (objectTop >= floatTop)
     110        return true;
     111
     112    // The object encloses the float
     113    if (objectTop < floatTop && objectBottom > floatBottom)
     114        return true;
     115
     116    // The bottom of the object overlaps the float
     117    if (objectBottom > objectTop && objectBottom > floatTop && objectBottom <= floatBottom)
     118        return true;
     119
     120    return false;
     121}
     122
    103123template <FloatingObject::Type FloatTypeValue>
    104124class ComputeFloatOffsetAdapter {
     
    106126    typedef FloatingObjectInterval IntervalType;
    107127
    108     ComputeFloatOffsetAdapter(const RenderBlockFlow* renderer, int lineTop, int lineBottom, LayoutUnit offset)
     128    ComputeFloatOffsetAdapter(const RenderBlockFlow* renderer, LayoutUnit lineTop, LayoutUnit lineBottom, LayoutUnit offset)
    109129        : m_renderer(renderer)
    110         , m_lineTop(lineTop)
    111         , m_lineBottom(lineBottom)
     130        , m_lineTop(roundToInt(lineTop))
     131        , m_lineBottom(roundToInt(lineBottom))
    112132        , m_offset(offset)
    113133        , m_outermostFloat(0)
     
    132152    const FloatingObject* m_outermostFloat;
    133153};
     154
     155class FindNextFloatLogicalBottomAdapter {
     156public:
     157    typedef FloatingObjectInterval IntervalType;
     158
     159    FindNextFloatLogicalBottomAdapter(const RenderBlockFlow& renderer, LayoutUnit belowLogicalHeight)
     160        : m_renderer(renderer)
     161        , m_belowLogicalHeight(floorToInt(belowLogicalHeight))
     162        , m_aboveLogicalHeight(roundToInt(LayoutUnit::max()))
     163        , m_nextLogicalBottom(LayoutUnit::max())
     164        , m_nextShapeLogicalBottom(LayoutUnit::max())
     165    {
     166    }
     167
     168    int lowValue() const { return m_belowLogicalHeight; }
     169    int highValue() const { return m_aboveLogicalHeight; }
     170    void collectIfNeeded(const IntervalType&);
     171
     172    LayoutUnit nextLogicalBottom() { return m_nextLogicalBottom == LayoutUnit::max() ? LayoutUnit() : m_nextLogicalBottom; }
     173    LayoutUnit nextShapeLogicalBottom() { return m_nextShapeLogicalBottom == LayoutUnit::max() ? nextLogicalBottom() : m_nextShapeLogicalBottom; }
     174
     175private:
     176    const RenderBlockFlow& m_renderer;
     177    int m_belowLogicalHeight;
     178    int m_aboveLogicalHeight;
     179    LayoutUnit m_nextLogicalBottom;
     180    LayoutUnit m_nextShapeLogicalBottom;
     181};
     182
     183inline void FindNextFloatLogicalBottomAdapter::collectIfNeeded(const IntervalType& interval)
     184{
     185    const FloatingObject* floatingObject = interval.data();
     186    if (!rangesIntersect(interval.low(), interval.high(), m_belowLogicalHeight, m_aboveLogicalHeight))
     187        return;
     188
     189    // All the objects returned from the tree should be already placed.
     190    ASSERT(floatingObject->isPlaced());
     191    ASSERT(rangesIntersect(m_renderer.pixelSnappedLogicalTopForFloat(floatingObject), m_renderer.pixelSnappedLogicalBottomForFloat(floatingObject), m_belowLogicalHeight, m_aboveLogicalHeight));
     192
     193    LayoutUnit floatBottom = m_renderer.logicalBottomForFloat(floatingObject);
     194    if (m_nextLogicalBottom < floatBottom)
     195        return;
     196
     197#if ENABLE(CSS_SHAPES)
     198    if (ShapeOutsideInfo* shapeOutside = floatingObject->renderer().shapeOutsideInfo()) {
     199        LayoutUnit shapeBottom = m_renderer.logicalTopForFloat(floatingObject) + m_renderer.marginBeforeForChild(floatingObject->renderer()) + shapeOutside->shapeLogicalBottom();
     200        // Use the shapeBottom unless it extends outside of the margin box, in which case it is clipped.
     201        m_nextShapeLogicalBottom = min(shapeBottom, floatBottom);
     202    } else
     203        m_nextShapeLogicalBottom = floatBottom;
     204#endif
     205    m_nextLogicalBottom = floatBottom;
     206}
     207
     208LayoutUnit FloatingObjects::findNextFloatLogicalBottomBelow(LayoutUnit logicalHeight)
     209{
     210    FindNextFloatLogicalBottomAdapter adapter(*m_renderer, logicalHeight);
     211    placedFloatsTree().allOverlapsWithAdapter(adapter);
     212
     213    return adapter.nextShapeLogicalBottom();
     214}
     215
     216LayoutUnit FloatingObjects::findNextFloatLogicalBottomBelowForBlock(LayoutUnit logicalHeight)
     217{
     218    FindNextFloatLogicalBottomAdapter adapter(*m_renderer, logicalHeight);
     219    placedFloatsTree().allOverlapsWithAdapter(adapter);
     220
     221    return adapter.nextLogicalBottom();
     222}
    134223
    135224FloatingObjects::FloatingObjects(const RenderBlockFlow* renderer, bool horizontalWritingMode)
     
    306395LayoutUnit FloatingObjects::logicalLeftOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining)
    307396{
    308     int logicalTopAsInt = roundToInt(logicalTop);
    309     ComputeFloatOffsetAdapter<FloatingObject::FloatLeft> adapter(m_renderer, logicalTopAsInt, logicalTopAsInt, fixedOffset);
     397    ComputeFloatOffsetAdapter<FloatingObject::FloatLeft> adapter(m_renderer, logicalTop, logicalTop, fixedOffset);
    310398    placedFloatsTree().allOverlapsWithAdapter(adapter);
    311399
     
    318406LayoutUnit FloatingObjects::logicalRightOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit *heightRemaining)
    319407{
    320     int logicalTopAsInt = roundToInt(logicalTop);
    321     ComputeFloatOffsetAdapter<FloatingObject::FloatRight> adapter(m_renderer, logicalTopAsInt, logicalTopAsInt, fixedOffset);
     408    ComputeFloatOffsetAdapter<FloatingObject::FloatRight> adapter(m_renderer, logicalTop, logicalTop, fixedOffset);
    322409    placedFloatsTree().allOverlapsWithAdapter(adapter);
    323410
     
    330417LayoutUnit FloatingObjects::logicalLeftOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight)
    331418{
    332     ComputeFloatOffsetAdapter<FloatingObject::FloatLeft> adapter(m_renderer, roundToInt(logicalTop), roundToInt(logicalTop + logicalHeight), fixedOffset);
     419    ComputeFloatOffsetAdapter<FloatingObject::FloatLeft> adapter(m_renderer, logicalTop, logicalTop + logicalHeight, fixedOffset);
    333420    placedFloatsTree().allOverlapsWithAdapter(adapter);
    334421
     
    338425LayoutUnit FloatingObjects::logicalRightOffset(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit logicalHeight)
    339426{
    340     ComputeFloatOffsetAdapter<FloatingObject::FloatRight> adapter(m_renderer, roundToInt(logicalTop), roundToInt(logicalTop + logicalHeight), fixedOffset);
     427    ComputeFloatOffsetAdapter<FloatingObject::FloatRight> adapter(m_renderer, logicalTop, logicalTop + logicalHeight, fixedOffset);
    341428    placedFloatsTree().allOverlapsWithAdapter(adapter);
    342429
    343430    return min(fixedOffset, adapter.shapeOffset());
    344 }
    345 
    346 inline static bool rangesIntersect(int floatTop, int floatBottom, int objectTop, int objectBottom)
    347 {
    348     if (objectTop >= floatBottom || objectBottom < floatTop)
    349         return false;
    350 
    351     // The top of the object overlaps the float
    352     if (objectTop >= floatTop)
    353         return true;
    354 
    355     // The object encloses the float
    356     if (objectTop < floatTop && objectBottom > floatBottom)
    357         return true;
    358 
    359     // The bottom of the object overlaps the float
    360     if (objectBottom > objectTop && objectBottom > floatTop && objectBottom <= floatBottom)
    361         return true;
    362 
    363     return false;
    364431}
    365432
  • trunk/Source/WebCore/rendering/FloatingObjects.h

    r158855 r158954  
    3333class RenderBlockFlow;
    3434class RenderBox;
    35 
    36 // FIXME this should be removed once RenderBlockFlow::nextFloatLogicalBottomBelow doesn't need it anymore. (Bug 123931)
    37 enum ShapeOutsideFloatOffsetMode { ShapeOutsideFloatShapeOffset, ShapeOutsideFloatMarginBoxOffset };
    3835
    3936class FloatingObject {
     
    150147    LayoutUnit logicalRightOffsetForPositioningFloat(LayoutUnit fixedOffset, LayoutUnit logicalTop, LayoutUnit* heightRemaining);
    151148
     149    LayoutUnit findNextFloatLogicalBottomBelow(LayoutUnit logicalHeight);
     150    LayoutUnit findNextFloatLogicalBottomBelowForBlock(LayoutUnit logicalHeight);
     151
    152152private:
    153153    void computePlacedFloatsTree();
  • trunk/Source/WebCore/rendering/LineWidth.cpp

    r158163 r158954  
    182182    float newLineRight = m_right;
    183183    while (true) {
    184         floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lastFloatLogicalBottom, ShapeOutsideFloatShapeOffset);
     184        floatLogicalBottom = m_block.nextFloatLogicalBottomBelow(lastFloatLogicalBottom);
    185185        if (floatLogicalBottom <= lastFloatLogicalBottom)
    186186            break;
  • trunk/Source/WebCore/rendering/RenderBlockFlow.cpp

    r158855 r158954  
    22772277}
    22782278
    2279 LayoutUnit RenderBlockFlow::nextFloatLogicalBottomBelow(LayoutUnit logicalHeight, ShapeOutsideFloatOffsetMode offsetMode) const
     2279LayoutUnit RenderBlockFlow::nextFloatLogicalBottomBelow(LayoutUnit logicalHeight) const
    22802280{
    22812281    if (!m_floatingObjects)
    22822282        return logicalHeight;
    22832283
    2284     LayoutUnit bottom = LayoutUnit::max();
    2285     const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
    2286     auto end = floatingObjectSet.end();
    2287     for (auto it = floatingObjectSet.begin(); it != end; ++it) {
    2288         FloatingObject* floatingObject = it->get();
    2289         LayoutUnit floatBottom = logicalBottomForFloat(floatingObject);
    2290 #if ENABLE(CSS_SHAPES)
    2291         ShapeOutsideInfo* shapeOutside = floatingObject->renderer().shapeOutsideInfo();
    2292         if (offsetMode == ShapeOutsideFloatShapeOffset && shapeOutside) {
    2293             LayoutUnit shapeBottom = logicalTopForFloat(floatingObject) + marginBeforeForChild(floatingObject->renderer()) + shapeOutside->shapeLogicalBottom();
    2294             // Use the shapeBottom unless it extends outside of the margin box, in which case it is clipped.
    2295             if (shapeBottom < floatBottom)
    2296                 floatBottom = shapeBottom;
    2297         }
    2298 #endif
    2299         if (floatBottom > logicalHeight)
    2300             bottom = min(floatBottom, bottom);
    2301     }
    2302 
    2303     return bottom == LayoutUnit::max() ? LayoutUnit() : bottom;
     2284    return m_floatingObjects->findNextFloatLogicalBottomBelow(logicalHeight);
     2285}
     2286
     2287LayoutUnit RenderBlockFlow::nextFloatLogicalBottomBelowForBlock(LayoutUnit logicalHeight) const
     2288{
     2289    if (!m_floatingObjects)
     2290        return logicalHeight;
     2291
     2292    return m_floatingObjects->findNextFloatLogicalBottomBelowForBlock(logicalHeight);
    23042293}
    23052294
     
    25532542            }
    25542543
    2555             newLogicalTop = nextFloatLogicalBottomBelow(newLogicalTop);
     2544            newLogicalTop = nextFloatLogicalBottomBelowForBlock(newLogicalTop);
    25562545            ASSERT(newLogicalTop >= logicalTop);
    25572546            if (newLogicalTop < logicalTop)
  • trunk/Source/WebCore/rendering/RenderBlockFlow.h

    r158855 r158954  
    424424
    425425    LayoutUnit lowestFloatLogicalBottom(FloatingObject::Type = FloatingObject::FloatLeftRight) const;
    426     LayoutUnit nextFloatLogicalBottomBelow(LayoutUnit, ShapeOutsideFloatOffsetMode = ShapeOutsideFloatMarginBoxOffset) const;
     426    LayoutUnit nextFloatLogicalBottomBelow(LayoutUnit) const;
     427    LayoutUnit nextFloatLogicalBottomBelowForBlock(LayoutUnit) const;
    427428   
    428429    LayoutUnit addOverhangingFloats(RenderBlockFlow& child, bool makeChildPaintOtherFloats);
Note: See TracChangeset for help on using the changeset viewer.