Changeset 148759 in webkit
- Timestamp:
- Apr 19, 2013 12:58:08 PM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r148758 r148759 1 2013-04-18 Ryosuke Niwa <rniwa@webkit.org> 2 3 Make loops in RenderObject::containingBlock homogeneous in their forms to simplify 4 https://bugs.webkit.org/show_bug.cgi?id=114853 5 6 Reviewed by David Hyatt. 7 8 This patch prepares us to avoid computing containing blocks during a depth-first traversal of the render tree. 9 10 Extracted inline functions out of RenderBlock::containingBlock to make the code simpler. Also moved the code 11 to obtain the nearest containing block out of the loop for a relatively positioned inline. 12 13 * rendering/RenderObject.cpp: 14 (WebCore::isNonReplacedInlineInFlowPosition): Extracted. 15 (WebCore::isContainingBlockCandidateForAbsolutelyPositionedObject): Extracted. 16 (WebCore::isNonRenderBlockInline): Extracted. 17 (WebCore::RenderObject::containingBlock): Refactored as stated above. 18 1 19 2013-04-19 Tim Horton <timothy_horton@apple.com> 2 20 -
trunk/Source/WebCore/rendering/RenderObject.cpp
r148545 r148759 769 769 } 770 770 771 static inline bool isContainingBlockCandidateForAbsolutelyPositionedObject(RenderObject* object) 772 { 773 return object->style()->position() != StaticPosition 774 || (object->hasTransform() && object->isRenderBlock()) 775 #if ENABLE(SVG) 776 || object->isSVGForeignObject() 777 #endif 778 || object->isRenderView(); 779 } 780 781 static inline bool isNonRenderBlockInline(RenderObject* object) 782 { 783 return (object->isInline() && !object->isReplaced()) || !object->isRenderBlock(); 784 } 785 771 786 RenderBlock* RenderObject::containingBlock() const 772 787 { … … 774 789 if (!o && isRenderScrollbarPart()) 775 790 o = toRenderScrollbarPart(this)->rendererOwningScrollbar(); 791 776 792 if (!isText() && m_style->position() == FixedPosition) { 777 while (o) { 778 if (o->canContainFixedPositionObjects()) 779 break; 793 while (o && !o->canContainFixedPositionObjects()) 780 794 o = o->parent(); 781 }782 795 ASSERT(!o || !o->isAnonymousBlock()); 783 796 } else if (!isText() && m_style->position() == AbsolutePosition) { 784 while (o) { 785 // For relpositioned inlines, we return the nearest non-anonymous enclosing block. We don't try 786 // to return the inline itself. This allows us to avoid having a positioned objects 787 // list in all RenderInlines and lets us return a strongly-typed RenderBlock* result 788 // from this method. The container() method can actually be used to obtain the 789 // inline directly. 790 if (o->style()->position() != StaticPosition && (!o->isInline() || o->isReplaced())) 791 break; 792 if (o->isRenderView()) 793 break; 794 if (o->hasTransform() && o->isRenderBlock()) 795 break; 796 797 if (o->style()->hasInFlowPosition() && o->isInline() && !o->isReplaced()) { 798 o = o->containingBlock(); 799 break; 800 } 801 #if ENABLE(SVG) 802 if (o->isSVGForeignObject()) //foreignObject is the containing block for contents inside it 803 break; 804 #endif 805 797 while (o && !isContainingBlockCandidateForAbsolutelyPositionedObject(o)) 806 798 o = o->parent(); 807 } 799 800 // For a relatively positioned inline, return its nearest non-anonymous containing block, 801 // not the inline itself, to avoid having a positioned objects list in all RenderInlines 802 // and use RenderBlock* as this function's return type. 803 // Use RenderBlock::container() to obtain the inline. 804 if (o->isRenderInline()) 805 o = o->containingBlock(); 808 806 809 807 while (o && o->isAnonymousBlock()) 810 808 o = o->containingBlock(); 811 809 } else { 812 while (o && ((o->isInline() && !o->isReplaced()) || !o->isRenderBlock()))810 while (o && isNonRenderBlockInline(o)) 813 811 o = o->parent(); 814 812 }
Note: See TracChangeset
for help on using the changeset viewer.