Changeset 95573 in webkit


Ignore:
Timestamp:
Sep 20, 2011 3:23:41 PM (13 years ago)
Author:
hyatt@apple.com
Message:

https://bugs.webkit.org/show_bug.cgi?id=68480

De-virtualize containingBlock() and make RenderView return 0 instead
of itself to make the construction of normal loops that terminate via
a null-check possible.

Fix the only two places in the tree that needed null checks.

Eliminating RenderTableCell::containingBlock() is fine since the base class
does the same thing anyway.

Reviewed by Simon Fraser.

  • editing/VisiblePosition.cpp:

(WebCore::VisiblePosition::lineDirectionPointForBlockDirectionNavigation):

  • rendering/RenderObject.cpp:

(WebCore::RenderObject::containingBlock):

  • rendering/RenderObject.h:
  • rendering/RenderTableCell.cpp:
  • rendering/RenderTableCell.h:
  • rendering/RenderTreeAsText.cpp:

(WebCore::RenderTreeAsText::writeRenderObject):

  • rendering/RenderView.cpp:
  • rendering/RenderView.h:
Location:
trunk/Source/WebCore
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r95570 r95573  
     12011-09-20  David Hyatt  <hyatt@apple.com>
     2
     3        https://bugs.webkit.org/show_bug.cgi?id=68480
     4       
     5        De-virtualize containingBlock() and make RenderView return 0 instead
     6        of itself to make the construction of normal loops that terminate via
     7        a null-check possible.
     8
     9        Fix the only two places in the tree that needed null checks.
     10
     11        Eliminating RenderTableCell::containingBlock() is fine since the base class
     12        does the same thing anyway.
     13
     14        Reviewed by Simon Fraser.
     15
     16        * editing/VisiblePosition.cpp:
     17        (WebCore::VisiblePosition::lineDirectionPointForBlockDirectionNavigation):
     18        * rendering/RenderObject.cpp:
     19        (WebCore::RenderObject::containingBlock):
     20        * rendering/RenderObject.h:
     21        * rendering/RenderTableCell.cpp:
     22        * rendering/RenderTableCell.h:
     23        * rendering/RenderTreeAsText.cpp:
     24        (WebCore::RenderTreeAsText::writeRenderObject):
     25        * rendering/RenderView.cpp:
     26        * rendering/RenderView.h:
     27
    1282011-09-20  Anders Carlsson  <andersca@apple.com>
    229
  • trunk/Source/WebCore/editing/VisiblePosition.cpp

    r93443 r95573  
    608608    // relative to the text, not absolute 'up'.
    609609    FloatPoint caretPoint = renderer->localToAbsolute(localRect.location());
    610     return renderer->containingBlock()->isHorizontalWritingMode() ? caretPoint.x() : caretPoint.y();
     610    RenderObject* containingBlock = renderer->containingBlock();
     611    if (!containingBlock)
     612        containingBlock = renderer; // Just use ourselves to determine the writing mode if we have no containing block.
     613    return containingBlock->isHorizontalWritingMode() ? caretPoint.x() : caretPoint.y();
    611614}
    612615
  • trunk/Source/WebCore/rendering/RenderObject.cpp

    r95461 r95573  
    637637RenderBlock* RenderObject::containingBlock() const
    638638{
    639     ASSERT(!isTableCell());
    640     ASSERT(!isRenderView());
    641 
    642639    RenderObject* o = parent();
    643640    if (!isText() && m_style->position() == FixedPosition) {
  • trunk/Source/WebCore/rendering/RenderObject.h

    r95461 r95573  
    601601
    602602    // returns the containing block level element for this element.
    603     virtual RenderBlock* containingBlock() const;
     603    RenderBlock* containingBlock() const;
    604604
    605605    // Convert the given local point to absolute coordinates
  • trunk/Source/WebCore/rendering/RenderTableCell.cpp

    r94706 r95573  
    320320}
    321321
    322 RenderBlock* RenderTableCell::containingBlock() const
    323 {
    324     if (parent() && section())
    325         return table();
    326     return 0;
    327 }
    328 
    329322// The following rules apply for resolving conflicts and figuring out which border
    330323// to use.
  • trunk/Source/WebCore/rendering/RenderTableCell.h

    r94706 r95573  
    138138    virtual bool isTableCell() const { return true; }
    139139
    140     virtual RenderBlock* containingBlock() const;
    141 
    142140    virtual void willBeDestroyed();
    143141
  • trunk/Source/WebCore/rendering/RenderTreeAsText.cpp

    r95239 r95573  
    247247    }
    248248   
    249     bool adjustForTableCells = o.containingBlock()->isTableCell();
     249    RenderBlock* cb = o.containingBlock();
     250    bool adjustForTableCells = cb ? cb->isTableCell() : false;
    250251
    251252    IntRect r;
  • trunk/Source/WebCore/rendering/RenderView.cpp

    r95264 r95573  
    266266}
    267267
    268 RenderBlock* RenderView::containingBlock() const
    269 {
    270     return const_cast<RenderView*>(this);
    271 }
    272 
    273268void RenderView::repaintViewRectangle(const IntRect& ur, bool immediate)
    274269{
  • trunk/Source/WebCore/rendering/RenderView.h

    r95264 r95573  
    194194private:
    195195    bool shouldRepaint(const IntRect& r) const;
    196    
    197     virtual RenderBlock* containingBlock() const;
    198196
    199197    // These functions may only be accessed by LayoutStateMaintainer.
Note: See TracChangeset for help on using the changeset viewer.