Changeset 80380 in webkit


Ignore:
Timestamp:
Mar 4, 2011 3:07:15 PM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-03-04 Yuqiang Xian <yuqiang.xian@intel.com>

Reviewed by Darin Adler.

improve layout performance by reducing the traversal time of the floating objects
https://bugs.webkit.org/show_bug.cgi?id=55440

We observered large overhead on traversing the floating objects list
in logicalLeftOffsetForLine() and logicalRightOffsetForLine() especially
when the list becomes enormous, for example in the default 30x30 maze test
from http://ie.microsoft.com/testdrive/Performance/MazeSolver/Default.html
there're >3700 floating objects. When placing a new floating object the
entire list (from begin to end) is traversed for multiple times.
There's a low hanging fruit to reduce the chances to do the traversal
which is especially applicable in logicalLeftOffsetForLine and logicalRightOffsetForLine.
As the two routines either cares about FloatLeft objects or FloatRight objects only,
if we know there's no corresponding type floating objects in the list
we can avoid the traversal actually. One thing we could do is to record
the number of FloatLeft objects and the number of FloatRight objects and
add a check before doing the traversal. This can reduce the time by 45%
to resolve the 30x30 Maze measured on N470 Netbook MeeGo using latest
Chromium browser 11 (from 503s to 269s).

No new tests, relying on existing layout tests.

  • rendering/RenderBlock.cpp: (WebCore::RenderBlock::~RenderBlock): (WebCore::RenderBlock::addOverflowFromFloats): (WebCore::RenderBlock::repaintOverhangingFloats): (WebCore::RenderBlock::paintFloats): (WebCore::RenderBlock::selectionGaps): (WebCore::RenderBlock::insertFloatingObject): (WebCore::RenderBlock::removeFloatingObject): (WebCore::RenderBlock::removeFloatingObjectsBelow): (WebCore::RenderBlock::positionNewFloats): (WebCore::RenderBlock::positionNewFloatOnLine): (WebCore::RenderBlock::logicalLeftOffsetForLine): (WebCore::RenderBlock::logicalRightOffsetForLine): (WebCore::RenderBlock::nextFloatLogicalBottomBelow): (WebCore::RenderBlock::lowestFloatLogicalBottom): (WebCore::RenderBlock::clearFloats): (WebCore::RenderBlock::addOverhangingFloats): (WebCore::RenderBlock::addIntrudingFloats): (WebCore::RenderBlock::containsFloat): (WebCore::RenderBlock::hitTestFloats): (WebCore::RenderBlock::adjustForBorderFit): (WebCore::RenderBlock::FloatingObjects::clear): (WebCore::RenderBlock::FloatingObjects::increaseObjectsCount): (WebCore::RenderBlock::FloatingObjects::decreaseObjectsCount):
  • rendering/RenderBlock.h: (WebCore::RenderBlock::containsFloats): (WebCore::RenderBlock::FloatingObjects::FloatingObjects): (WebCore::RenderBlock::FloatingObjects::hasLeftObjects): (WebCore::RenderBlock::FloatingObjects::hasRightObjects): (WebCore::RenderBlock::FloatingObjects::set):
  • rendering/RenderBlockLineLayout.cpp: (WebCore::RenderBlock::layoutInlineChildren): (WebCore::RenderBlock::matchedEndLine):
Location:
trunk/Source/WebCore
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r80379 r80380  
     12011-03-04  Yuqiang Xian  <yuqiang.xian@intel.com>
     2
     3        Reviewed by Darin Adler.
     4
     5        improve layout performance by reducing the traversal time of the floating objects
     6        https://bugs.webkit.org/show_bug.cgi?id=55440
     7
     8        We observered large overhead on traversing the floating objects list
     9        in logicalLeftOffsetForLine() and logicalRightOffsetForLine() especially
     10        when the list becomes enormous, for example in the default 30x30 maze test
     11        from http://ie.microsoft.com/testdrive/Performance/MazeSolver/Default.html
     12        there're >3700 floating objects. When placing a new floating object the
     13        entire list (from begin to end) is traversed for multiple times.
     14        There's a low hanging fruit to reduce the chances to do the traversal
     15        which is especially applicable in logicalLeftOffsetForLine and logicalRightOffsetForLine.
     16        As the two routines either cares about FloatLeft objects or FloatRight objects only,
     17        if we know there's no corresponding type floating objects in the list
     18        we can avoid the traversal actually. One thing we could do is to record
     19        the number of FloatLeft objects and the number of FloatRight objects and
     20        add a check before doing the traversal. This can reduce the time by 45%
     21        to resolve the 30x30 Maze measured on N470 Netbook MeeGo using latest
     22        Chromium browser 11 (from 503s to 269s).
     23
     24        No new tests, relying on existing layout tests.
     25
     26        * rendering/RenderBlock.cpp:
     27        (WebCore::RenderBlock::~RenderBlock):
     28        (WebCore::RenderBlock::addOverflowFromFloats):
     29        (WebCore::RenderBlock::repaintOverhangingFloats):
     30        (WebCore::RenderBlock::paintFloats):
     31        (WebCore::RenderBlock::selectionGaps):
     32        (WebCore::RenderBlock::insertFloatingObject):
     33        (WebCore::RenderBlock::removeFloatingObject):
     34        (WebCore::RenderBlock::removeFloatingObjectsBelow):
     35        (WebCore::RenderBlock::positionNewFloats):
     36        (WebCore::RenderBlock::positionNewFloatOnLine):
     37        (WebCore::RenderBlock::logicalLeftOffsetForLine):
     38        (WebCore::RenderBlock::logicalRightOffsetForLine):
     39        (WebCore::RenderBlock::nextFloatLogicalBottomBelow):
     40        (WebCore::RenderBlock::lowestFloatLogicalBottom):
     41        (WebCore::RenderBlock::clearFloats):
     42        (WebCore::RenderBlock::addOverhangingFloats):
     43        (WebCore::RenderBlock::addIntrudingFloats):
     44        (WebCore::RenderBlock::containsFloat):
     45        (WebCore::RenderBlock::hitTestFloats):
     46        (WebCore::RenderBlock::adjustForBorderFit):
     47        (WebCore::RenderBlock::FloatingObjects::clear):
     48        (WebCore::RenderBlock::FloatingObjects::increaseObjectsCount):
     49        (WebCore::RenderBlock::FloatingObjects::decreaseObjectsCount):
     50        * rendering/RenderBlock.h:
     51        (WebCore::RenderBlock::containsFloats):
     52        (WebCore::RenderBlock::FloatingObjects::FloatingObjects):
     53        (WebCore::RenderBlock::FloatingObjects::hasLeftObjects):
     54        (WebCore::RenderBlock::FloatingObjects::hasRightObjects):
     55        (WebCore::RenderBlock::FloatingObjects::set):
     56        * rendering/RenderBlockLineLayout.cpp:
     57        (WebCore::RenderBlock::layoutInlineChildren):
     58        (WebCore::RenderBlock::matchedEndLine):
     59
    1602011-03-04  Rik Cabanier  <cabanier@gmail.com>
    261
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r80221 r80380  
    124124{
    125125    if (m_floatingObjects)
    126         deleteAllValues(*m_floatingObjects);
     126        deleteAllValues(m_floatingObjects->set());
    127127   
    128128    if (hasColumns())
     
    13811381        return;
    13821382
    1383     FloatingObjectSetIterator end = m_floatingObjects->end();
    1384     for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     1383    FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     1384    FloatingObjectSetIterator end = floatingObjectSet.end();
     1385    for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    13851386        FloatingObject* r = *it;
    13861387        if (r->m_isDescendant)
     
    21782179        // in this block. Better yet would be to push extra state for the containers of other floats.
    21792180        view()->disableLayoutState();
    2180         FloatingObjectSetIterator end = m_floatingObjects->end();
    2181         for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     2181        FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     2182        FloatingObjectSetIterator end = floatingObjectSet.end();
     2183        for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    21822184            FloatingObject* r = *it;
    21832185            // Only repaint the object if it is overhanging, is not in its own layer, and
     
    25042506        return;
    25052507
    2506     FloatingObjectSetIterator end = m_floatingObjects->end();
    2507     for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     2508    FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     2509    FloatingObjectSetIterator end = floatingObjectSet.end();
     2510    for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    25082511        FloatingObject* r = *it;
    25092512        // Only paint the object if our m_shouldPaint flag is set.
     
    27562759                clipOutPositionedObjects(paintInfo, IntPoint(cb->x(), cb->y()), cb->m_positionedObjects.get()); // FIXME: Not right for flipped writing modes.
    27572760        if (m_floatingObjects) {
    2758             FloatingObjectSetIterator end = m_floatingObjects->end();
    2759             for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     2761            FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     2762            FloatingObjectSetIterator end = floatingObjectSet.end();
     2763            for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    27602764                FloatingObject* r = *it;
    27612765                IntRect floatBox = IntRect(offsetFromRootBlock.width() + xPositionForFloatIncludingMargin(r),
     
    30663070    // Create the list of special objects if we don't aleady have one
    30673071    if (!m_floatingObjects)
    3068         m_floatingObjects = adoptPtr(new FloatingObjectSet);
     3072        m_floatingObjects = adoptPtr(new FloatingObjects);
    30693073    else {
    30703074        // Don't insert the object again if it's already in the list
    3071         FloatingObjectSetIterator it = m_floatingObjects->find<RenderBox*, FloatingObjectHashTranslator>(o);
    3072         if (it != m_floatingObjects->end())
     3075        FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     3076        FloatingObjectSetIterator it = floatingObjectSet.find<RenderBox*, FloatingObjectHashTranslator>(o);
     3077        if (it != floatingObjectSet.end())
    30733078            return *it;
    30743079    }
     
    30973102    newObj->m_renderer = o;
    30983103
    3099     m_floatingObjects->add(newObj);
     3104    m_floatingObjects->increaseObjectsCount(newObj->type());
     3105    m_floatingObjects->set().add(newObj);
    31003106   
    31013107    return newObj;
     
    31053111{
    31063112    if (m_floatingObjects) {
    3107         FloatingObjectSet::iterator it = m_floatingObjects->find<RenderBox*, FloatingObjectHashTranslator>(o);
    3108         if (it != m_floatingObjects->end()) {
     3113        FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     3114        FloatingObjectSet::iterator it = floatingObjectSet.find<RenderBox*, FloatingObjectHashTranslator>(o);
     3115        if (it != floatingObjectSet.end()) {
    31093116            FloatingObject* r = *it;
    31103117            if (childrenInline()) {
     
    31233130                markLinesDirtyInBlockRange(0, logicalBottom);
    31243131            }
    3125             m_floatingObjects->remove(it);
     3132            m_floatingObjects->decreaseObjectsCount(r->type());
     3133            floatingObjectSet.remove(it);
    31263134            delete r;
    31273135        }
     
    31343142        return;
    31353143   
    3136     FloatingObject* curr = m_floatingObjects->last();
     3144    FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     3145    FloatingObject* curr = floatingObjectSet.last();
    31373146    while (curr != lastFloat && (!curr->isPlaced() || logicalTopForFloat(curr) >= logicalOffset)) {
    3138         m_floatingObjects->removeLast();
     3147        m_floatingObjects->decreaseObjectsCount(curr->type());
     3148        floatingObjectSet.removeLast();
    31393149        delete curr;
    3140         curr = m_floatingObjects->last();
     3150        curr = floatingObjectSet.last();
    31413151    }
    31423152}
     
    31473157        return false;
    31483158
    3149     if (m_floatingObjects->isEmpty())
     3159    FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     3160    if (floatingObjectSet.isEmpty())
    31503161        return false;
    31513162
    31523163    // If all floats have already been positioned, then we have no work to do.
    3153     if (m_floatingObjects->last()->isPlaced())
     3164    if (floatingObjectSet.last()->isPlaced())
    31543165        return false;
    31553166
     
    31573168    // already been positioned.  Then we'll be able to move forward, positioning all of
    31583169    // the new floats that need it.
    3159     FloatingObjectSetIterator it = m_floatingObjects->end();
     3170    FloatingObjectSetIterator it = floatingObjectSet.end();
    31603171    --it; // Go to last item.
    3161     FloatingObjectSetIterator begin = m_floatingObjects->begin();
     3172    FloatingObjectSetIterator begin = floatingObjectSet.begin();
    31623173    FloatingObject* lastPlacedFloatingObject = 0;
    31633174    while (it != begin) {
     
    31763187        logicalTop = max(logicalTopForFloat(lastPlacedFloatingObject), logicalTop);
    31773188
    3178     FloatingObjectSetIterator end = m_floatingObjects->end();
     3189    FloatingObjectSetIterator end = floatingObjectSet.end();
    31793190    // Now walk through the set of unpositioned floats and place them.
    31803191    for (; it != end; ++it) {
     
    32753286        return didPosition;
    32763287   
    3277     ASSERT(m_floatingObjects->last() == newFloat);
     3288    FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     3289    ASSERT(floatingObjectSet.last() == newFloat);
    32783290
    32793291    int floatLogicalTop = logicalTopForFloat(newFloat);
     
    32833295        return didPosition;
    32843296
    3285     FloatingObjectSetIterator it = m_floatingObjects->end();
     3297    FloatingObjectSetIterator it = floatingObjectSet.end();
    32863298    --it; // Last float is newFloat, skip that one.
    3287     FloatingObjectSetIterator begin = m_floatingObjects->begin();
     3299    FloatingObjectSetIterator begin = floatingObjectSet.begin();
    32883300    while (it != begin) {
    32893301        --it;
     
    33933405{
    33943406    int left = fixedOffset;
    3395     if (m_floatingObjects) {
     3407    if (m_floatingObjects && m_floatingObjects->hasLeftObjects()) {
    33963408        if (heightRemaining)
    33973409            *heightRemaining = 1;
    33983410
    3399         FloatingObjectSetIterator end = m_floatingObjects->end();
    3400         for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     3411        FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     3412        FloatingObjectSetIterator end = floatingObjectSet.end();
     3413        for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    34013414            FloatingObject* r = *it;
    34023415            if (r->isPlaced() && logicalTopForFloat(r) <= logicalTop && logicalBottomForFloat(r) > logicalTop
     
    34243437    int right = fixedOffset;
    34253438
    3426     if (m_floatingObjects) {
     3439    if (m_floatingObjects && m_floatingObjects->hasRightObjects()) {
    34273440        if (heightRemaining)
    34283441            *heightRemaining = 1;
    3429         FloatingObjectSetIterator end = m_floatingObjects->end();
    3430         for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     3442        FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     3443        FloatingObjectSetIterator end = floatingObjectSet.end();
     3444        for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    34313445            FloatingObject* r = *it;
    34323446            if (r->isPlaced() && logicalTopForFloat(r) <= logicalTop && logicalBottomForFloat(r) > logicalTop
     
    34623476
    34633477    int bottom = INT_MAX;
    3464     FloatingObjectSetIterator end = m_floatingObjects->end();
    3465     for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     3478    FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     3479    FloatingObjectSetIterator end = floatingObjectSet.end();
     3480    for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    34663481        FloatingObject* r = *it;
    34673482        int floatBottom = logicalBottomForFloat(r);
     
    34783493        return 0;
    34793494    int lowestFloatBottom = 0;
    3480     FloatingObjectSetIterator end = m_floatingObjects->end();
    3481     for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     3495    FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     3496    FloatingObjectSetIterator end = floatingObjectSet.end();
     3497    for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    34823498        FloatingObject* r = *it;
    34833499        if (r->isPlaced() && r->type() & floatType)
     
    35103526    if (avoidsFloats() || isRoot() || isRenderView() || isFloatingOrPositioned() || isTableCell()) {
    35113527        if (m_floatingObjects) {
    3512             deleteAllValues(*m_floatingObjects);
     3528            deleteAllValues(m_floatingObjects->set());
    35133529            m_floatingObjects->clear();
    35143530        }
     
    35203536
    35213537    if (m_floatingObjects) {
     3538        FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
    35223539        if (childrenInline()) {
    3523             FloatingObjectSet::iterator end = m_floatingObjects->end();
    3524             for (FloatingObjectSet::iterator it = m_floatingObjects->begin(); it != end; ++it) {
     3540            FloatingObjectSet::iterator end = floatingObjectSet.end();
     3541            for (FloatingObjectSet::iterator it = floatingObjectSet.begin(); it != end; ++it) {
    35253542                FloatingObject* f = *it;
    35263543                floatMap.add(f->m_renderer, f);
    35273544            }
    35283545        } else
    3529             deleteAllValues(*m_floatingObjects);
     3546            deleteAllValues(floatingObjectSet);
    35303547        m_floatingObjects->clear();
    35313548    }
     
    35743591        int changeLogicalBottom = numeric_limits<int>::min();
    35753592        if (m_floatingObjects) {
    3576             FloatingObjectSetIterator end = m_floatingObjects->end();
    3577             for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     3593            FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     3594            FloatingObjectSetIterator end = floatingObjectSet.end();
     3595            for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    35783596                FloatingObject* f = *it;
    35793597                FloatingObject* oldFloatingObject = floatMap.get(f->m_renderer);
     
    36223640    // Floats that will remain the child's responsibility to paint should factor into its
    36233641    // overflow.
    3624     FloatingObjectSetIterator childEnd = child->m_floatingObjects->end();
    3625     for (FloatingObjectSetIterator childIt = child->m_floatingObjects->begin(); childIt != childEnd; ++childIt) {
     3642    FloatingObjectSetIterator childEnd = child->m_floatingObjects->set().end();
     3643    for (FloatingObjectSetIterator childIt = child->m_floatingObjects->set().begin(); childIt != childEnd; ++childIt) {
    36263644        FloatingObject* r = *childIt;
    36273645        int logicalBottom = child->logicalTop() + logicalBottomForFloat(r);
     
    36493667                // We create the floating object list lazily.
    36503668                if (!m_floatingObjects)
    3651                     m_floatingObjects = adoptPtr(new FloatingObjectSet);
    3652 
    3653                 m_floatingObjects->add(floatingObj);
     3669                    m_floatingObjects = adoptPtr(new FloatingObjects);
     3670
     3671                m_floatingObjects->increaseObjectsCount(floatingObj->type());
     3672                m_floatingObjects->set().add(floatingObj);
    36543673            }
    36553674        } else {
     
    36813700    logicalLeftOffset += (style()->isHorizontalWritingMode() ? marginLeft() : marginTop());
    36823701
    3683     FloatingObjectSetIterator prevEnd = prev->m_floatingObjects->end();
    3684     for (FloatingObjectSetIterator prevIt = prev->m_floatingObjects->begin(); prevIt != prevEnd; ++prevIt) {
     3702    FloatingObjectSet& prevSet = prev->m_floatingObjects->set();
     3703    FloatingObjectSetIterator prevEnd = prevSet.end();
     3704    for (FloatingObjectSetIterator prevIt = prevSet.begin(); prevIt != prevEnd; ++prevIt) {
    36853705        FloatingObject* r = *prevIt;
    36863706        if (logicalBottomForFloat(r) > logicalTopOffset) {
    3687             if (!m_floatingObjects || !m_floatingObjects->contains(r)) {
     3707            if (!m_floatingObjects || !m_floatingObjects->set().contains(r)) {
    36883708                int leftOffset = style()->isHorizontalWritingMode() ? logicalLeftOffset : logicalTopOffset;
    36893709                int topOffset = style()->isHorizontalWritingMode() ? logicalTopOffset : logicalLeftOffset;
     
    37083728                // We create the floating object list lazily.
    37093729                if (!m_floatingObjects)
    3710                     m_floatingObjects = adoptPtr(new FloatingObjectSet);
    3711                 m_floatingObjects->add(floatingObj);
     3730                    m_floatingObjects = adoptPtr(new FloatingObjects);
     3731                m_floatingObjects->increaseObjectsCount(floatingObj->type());
     3732                m_floatingObjects->set().add(floatingObj);
    37123733            }
    37133734        }
     
    37233744bool RenderBlock::containsFloat(RenderBox* renderer)
    37243745{
    3725     return m_floatingObjects && m_floatingObjects->contains<RenderBox*, FloatingObjectHashTranslator>(renderer);
     3746    return m_floatingObjects && m_floatingObjects->set().contains<RenderBox*, FloatingObjectHashTranslator>(renderer);
    37263747}
    37273748
     
    38813902    }
    38823903
    3883     FloatingObjectSetIterator begin = m_floatingObjects->begin();
    3884     for (FloatingObjectSetIterator it = m_floatingObjects->end(); it != begin;) {
     3904    FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     3905    FloatingObjectSetIterator begin = floatingObjectSet.begin();
     3906    for (FloatingObjectSetIterator it = floatingObjectSet.end(); it != begin;) {
    38853907        --it;
    38863908        FloatingObject* floatingObject = *it;
     
    55095531       
    55105532        if (m_floatingObjects) {
    5511             FloatingObjectSetIterator end = m_floatingObjects->end();
    5512             for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     5533            FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     5534            FloatingObjectSetIterator end = floatingObjectSet.end();
     5535            for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    55135536                FloatingObject* r = *it;
    55145537                // Only examine the object if our m_shouldPaint flag is set.
     
    62186241}
    62196242
     6243inline void RenderBlock::FloatingObjects::clear()
     6244{
     6245    m_set.clear();
     6246    m_leftObjectsCount = 0;
     6247    m_rightObjectsCount = 0;
     6248}
     6249
     6250inline void RenderBlock::FloatingObjects::increaseObjectsCount(FloatingObject::Type type)
     6251{   
     6252    if (type == FloatingObject::FloatLeft)
     6253        m_leftObjectsCount++;
     6254    else
     6255        m_rightObjectsCount++;
     6256}
     6257
     6258inline void RenderBlock::FloatingObjects::decreaseObjectsCount(FloatingObject::Type type)
     6259{
     6260    if (type == FloatingObject::FloatLeft)
     6261        m_leftObjectsCount--;
     6262    else
     6263        m_rightObjectsCount--;
     6264}
     6265
    62206266} // namespace WebCore
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r80015 r80380  
    9696    virtual void markForPaginationRelayoutIfNeeded();
    9797   
    98     bool containsFloats() { return m_floatingObjects && !m_floatingObjects->isEmpty(); }
     98    bool containsFloats() { return m_floatingObjects && !m_floatingObjects->set().isEmpty(); }
    9999    bool containsFloat(RenderBox*);
    100100
     
    713713    typedef ListHashSet<FloatingObject*, 4, FloatingObjectHashFunctions> FloatingObjectSet;
    714714    typedef FloatingObjectSet::const_iterator FloatingObjectSetIterator;
    715     OwnPtr<FloatingObjectSet> m_floatingObjects;
     715    class FloatingObjects {
     716    public:
     717        FloatingObjects()
     718            : m_leftObjectsCount(0)
     719            , m_rightObjectsCount(0)
     720        {
     721        }
     722
     723        void clear();
     724        void increaseObjectsCount(FloatingObject::Type);
     725        void decreaseObjectsCount(FloatingObject::Type);
     726        bool hasLeftObjects() const { return m_leftObjectsCount > 0; }
     727        bool hasRightObjects() const { return m_rightObjectsCount > 0; }
     728        FloatingObjectSet& set() { return m_set; }
     729
     730    private:
     731        FloatingObjectSet m_set;
     732        unsigned m_leftObjectsCount;
     733        unsigned m_rightObjectsCount;
     734    };
     735    OwnPtr<FloatingObjects> m_floatingObjects;
    716736   
    717737    typedef PositionedObjectsListHashSet::const_iterator Iterator;
  • trunk/Source/WebCore/rendering/RenderBlockLineLayout.cpp

    r80288 r80380  
    619619        }
    620620
    621         FloatingObject* lastFloat = (m_floatingObjects && !m_floatingObjects->isEmpty()) ? m_floatingObjects->last() : 0;
     621        FloatingObject* lastFloat = (m_floatingObjects && !m_floatingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0;
    622622
    623623        LineMidpointState& lineMidpointState = resolver.midpointState();
     
    689689           
    690690            InlineIterator oldEnd = end;
    691             FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_floatingObjects->isEmpty()) ? m_floatingObjects->last() : 0;
     691            FloatingObject* lastFloatFromPreviousLine = (m_floatingObjects && !m_floatingObjects->set().isEmpty()) ? m_floatingObjects->set().last() : 0;
    692692            end = findNextLineBreak(resolver, firstLine, isLineEmpty, lineBreakIteratorInfo, previousLineBrokeCleanly, hyphenated, &clear, lastFloatFromPreviousLine);
    693693            if (resolver.position().atEnd()) {
     
    840840
    841841            if (m_floatingObjects && lastRootBox()) {
    842                 FloatingObjectSetIterator it = m_floatingObjects->begin();
    843                 FloatingObjectSetIterator end = m_floatingObjects->end();
     842                FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     843                FloatingObjectSetIterator it = floatingObjectSet.begin();
     844                FloatingObjectSetIterator end = floatingObjectSet.end();
    844845                if (lastFloat) {
    845                     FloatingObjectSetIterator lastFloatIterator = m_floatingObjects->find(lastFloat);
     846                    FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find(lastFloat);
    846847                    ASSERT(lastFloatIterator != end);
    847848                    ++lastFloatIterator;
     
    857858                    floatIndex++;
    858859                }
    859                 lastFloat = !m_floatingObjects->isEmpty() ? m_floatingObjects->last() : 0;
     860                lastFloat = !floatingObjectSet.isEmpty() ? floatingObjectSet.last() : 0;
    860861            }
    861862
     
    921922            }
    922923
    923             FloatingObjectSetIterator it = m_floatingObjects->begin();
    924             FloatingObjectSetIterator end = m_floatingObjects->end();
     924            FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     925            FloatingObjectSetIterator it = floatingObjectSet.begin();
     926            FloatingObjectSetIterator end = floatingObjectSet.end();
    925927            if (lastFloat) {
    926                 FloatingObjectSetIterator lastFloatIterator = m_floatingObjects->find(lastFloat);
     928                FloatingObjectSetIterator lastFloatIterator = floatingObjectSet.find(lastFloat);
    927929                ASSERT(lastFloatIterator != end);
    928930                ++lastFloatIterator;
     
    931933            for (; it != end; ++it)
    932934                lastRootBox()->floats().append((*it)->m_renderer);
    933             lastFloat = !m_floatingObjects->isEmpty() ? m_floatingObjects->last() : 0;
     935            lastFloat = !floatingObjectSet.isEmpty() ? floatingObjectSet.last() : 0;
    934936        }
    935937        size_t floatCount = floats.size();
     
    11681170        int logicalBottom = lastLine->blockLogicalHeight() + abs(delta);
    11691171
    1170         FloatingObjectSetIterator end = m_floatingObjects->end();
    1171         for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     1172        FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     1173        FloatingObjectSetIterator end = floatingObjectSet.end();
     1174        for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    11721175            FloatingObject* f = *it;
    11731176            if (logicalBottomForFloat(f) >= logicalTop && logicalBottomForFloat(f) < logicalBottom)
     
    12041207                int logicalBottom = lastLine->blockLogicalHeight() + abs(delta);
    12051208
    1206                 FloatingObjectSetIterator end = m_floatingObjects->end();
    1207                 for (FloatingObjectSetIterator it = m_floatingObjects->begin(); it != end; ++it) {
     1209                FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
     1210                FloatingObjectSetIterator end = floatingObjectSet.end();
     1211                for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    12081212                    FloatingObject* f = *it;
    12091213                    if (logicalBottomForFloat(f) >= logicalTop && logicalBottomForFloat(f) < logicalBottom)
Note: See TracChangeset for help on using the changeset viewer.