Changeset 155065 in webkit


Ignore:
Timestamp:
Sep 4, 2013 2:35:56 PM (11 years ago)
Author:
Bem Jones-Bey
Message:

FloatingObjects should manage cleaning it's line box tree pointers itself
https://bugs.webkit.org/show_bug.cgi?id=120692

Reviewed by David Hyatt.

This is another step in properly encapsulating FloatingObjects.
Instead of having RenderBlock walk and clear the line box tree
pointers, create a method for the behavior, and have RenderBlock call
that.

In addtion, add a proper destructor to FloatingObjects, so that
RenderBlock does not have to explicitly delete the set in
FloatingObjects.

And as a bonus, fix the ordering of an if to avoid the expensive
descendantChild check.

This is a port of a Blink patch by Eric Seidel.

No new tests, no behavior change.

  • rendering/RenderBlock.cpp:

(WebCore::RenderBlock::~RenderBlock):
(WebCore::RenderBlock::deleteLineBoxTree):
(WebCore::RenderBlock::repaintOverhangingFloats):
(WebCore::RenderBlock::FloatingObjects::~FloatingObjects):
(WebCore::RenderBlock::FloatingObjects::clearLineBoxTreePointers):
(WebCore::RenderBlock::FloatingObjects::clear):

  • rendering/RenderBlock.h:
Location:
trunk/Source/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r155060 r155065  
     12013-09-04  Bem Jones-Bey  <bjonesbe@adobe.com>
     2
     3        FloatingObjects should manage cleaning it's line box tree pointers itself
     4        https://bugs.webkit.org/show_bug.cgi?id=120692
     5
     6        Reviewed by David Hyatt.
     7
     8        This is another step in properly encapsulating FloatingObjects.
     9        Instead of having RenderBlock walk and clear the line box tree
     10        pointers, create a method for the behavior, and have RenderBlock call
     11        that.
     12
     13        In addtion, add a proper destructor to FloatingObjects, so that
     14        RenderBlock does not have to explicitly delete the set in
     15        FloatingObjects.
     16
     17        And as a bonus, fix the ordering of an if to avoid the expensive
     18        descendantChild check.
     19
     20        This is a port of a Blink patch by Eric Seidel.
     21
     22        No new tests, no behavior change.
     23
     24        * rendering/RenderBlock.cpp:
     25        (WebCore::RenderBlock::~RenderBlock):
     26        (WebCore::RenderBlock::deleteLineBoxTree):
     27        (WebCore::RenderBlock::repaintOverhangingFloats):
     28        (WebCore::RenderBlock::FloatingObjects::~FloatingObjects):
     29        (WebCore::RenderBlock::FloatingObjects::clearLineBoxTreePointers):
     30        (WebCore::RenderBlock::FloatingObjects::clear):
     31        * rendering/RenderBlock.h:
     32
    1332013-09-04  Tim Horton  <timothy_horton@apple.com>
    234
  • trunk/Source/WebCore/rendering/RenderBlock.cpp

    r155050 r155065  
    228228RenderBlock::~RenderBlock()
    229229{
    230     if (m_floatingObjects)
    231         deleteAllValues(m_floatingObjects->set());
    232    
    233230    if (hasColumns())
    234231        gColumnInfoMap->take(this);
    235 
    236232    if (gPercentHeightDescendantsMap)
    237233        removeBlockFromDescendantAndContainerMaps(this, gPercentHeightDescendantsMap, gPercentHeightContainerMap);
     
    989985void RenderBlock::deleteLineBoxTree()
    990986{
    991     if (containsFloats()) {
    992         // Clear references to originating lines, since the lines are being deleted
    993         const FloatingObjectSet& floatingObjectSet = m_floatingObjects->set();
    994         FloatingObjectSetIterator end = floatingObjectSet.end();
    995         for (FloatingObjectSetIterator it = floatingObjectSet.begin(); it != end; ++it) {
    996             ASSERT(!((*it)->originatingLine()) || &(*it)->originatingLine()->renderer() == this);
    997             (*it)->setOriginatingLine(0);
    998         }
    999     }
     987    if (containsFloats())
     988        m_floatingObjects->clearLineBoxTreePointers();
    1000989    m_lineBoxes.deleteLineBoxTree(renderArena());
    1001990
     
    30433032        // is our responsibility to paint (m_shouldPaint is set). When paintAllDescendants is true, the latter
    30443033        // condition is replaced with being a descendant of us.
    3045         if (r->logicalBottom(isHorizontalWritingMode()) > logicalHeight() && ((paintAllDescendants && r->renderer()->isDescendantOf(this)) || r->shouldPaint()) && !r->renderer()->hasSelfPaintingLayer()) {
     3034        if (r->logicalBottom(isHorizontalWritingMode()) > logicalHeight()
     3035            && !r->renderer()->hasSelfPaintingLayer()
     3036            && (r->shouldPaint() || (paintAllDescendants && r->renderer()->isDescendantOf(this)))) {
    30463037            r->renderer()->repaint();
    30473038            r->renderer()->repaintOverhangingFloats(false);
     
    82388229}
    82398230
     8231RenderBlock::FloatingObjects::~FloatingObjects()
     8232{
     8233    // FIXME: m_set should use OwnPtr instead.
     8234    deleteAllValues(m_set);
     8235}
     8236
     8237void RenderBlock::FloatingObjects::clearLineBoxTreePointers()
     8238{
     8239    // Clear references to originating lines, since the lines are being deleted
     8240    FloatingObjectSetIterator end = m_set.end();
     8241    for (FloatingObjectSetIterator it = m_set.begin(); it != end; ++it) {
     8242        ASSERT(!((*it)->originatingLine()) || &((*it)->originatingLine()->renderer()) == m_renderer);
     8243        (*it)->setOriginatingLine(0);
     8244    }
     8245}
     8246
    82408247void RenderBlock::createFloatingObjects()
    82418248{
     
    82458252inline void RenderBlock::FloatingObjects::clear()
    82468253{
     8254    // FIXME: This should call deleteAllValues, except RenderBlock::clearFloats
     8255    // like to play fast and loose with ownership of these pointers.
     8256    // If we move to OwnPtr that will fix this ownership oddness.
    82478257    m_set.clear();
    82488258    m_placedFloatsTree.clear();
  • trunk/Source/WebCore/rendering/RenderBlock.h

    r155050 r155065  
    12521252        WTF_MAKE_NONCOPYABLE(FloatingObjects); WTF_MAKE_FAST_ALLOCATED;
    12531253    public:
     1254        ~FloatingObjects();
     1255
    12541256        void clear();
    12551257        void add(FloatingObject*);
     
    12671269            return m_placedFloatsTree;
    12681270        }
     1271        void clearLineBoxTreePointers();
    12691272    private:
    12701273        FloatingObjects(const RenderBlock*, bool horizontalWritingMode);
Note: See TracChangeset for help on using the changeset viewer.