Changeset 181654 in webkit
- Timestamp:
- Mar 17, 2015, 11:58:59 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
rendering/LogicalSelectionOffsetCaches.h (modified) (3 diffs)
-
rendering/RenderBlock.cpp (modified) (2 diffs)
-
rendering/RenderElement.cpp (modified) (2 diffs)
-
rendering/RenderElement.h (modified) (3 diffs)
-
rendering/RenderLayer.cpp (modified) (2 diffs)
-
rendering/RenderObject.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r181653 r181654 1 2015-03-17 Simon Fraser <simon.fraser@apple.com> 2 3 Move some code from LogicalSelectionOffsetCaches into RenderElement 4 https://bugs.webkit.org/show_bug.cgi?id=142758 5 6 Reviewed by Myles C. Maxfield. 7 8 LogicalSelectionOffsetCaches had some useful code regarding containing blocks etc 9 that should be used in more places, so move it into RenderElement. 10 11 No behavior change. 12 13 * rendering/LogicalSelectionOffsetCaches.h: 14 (WebCore::LogicalSelectionOffsetCaches::LogicalSelectionOffsetCaches): 15 (WebCore::isContainingBlockCandidateForAbsolutelyPositionedObject): Deleted. 16 (WebCore::isNonRenderBlockInline): Deleted. 17 (WebCore::containingBlockForFixedPosition): Deleted. 18 (WebCore::containingBlockForAbsolutePosition): Deleted. 19 (WebCore::containingBlockForObjectInFlow): Deleted. 20 * rendering/RenderBlock.cpp: No need to initialize static data. 21 (WebCore::RenderBlock::positionedObjects): nullptr 22 * rendering/RenderElement.cpp: 23 (WebCore::RenderElement::containingBlockForFixedPosition): 24 (WebCore::RenderElement::containingBlockForAbsolutePosition): 25 (WebCore::isNonRenderBlockInline): 26 (WebCore::RenderElement::containingBlockForObjectInFlow): 27 * rendering/RenderElement.h: 28 (WebCore::RenderElement::canContainAbsolutelyPositionedObjects): 29 * rendering/RenderLayer.cpp: 30 (WebCore::isContainerForPositioned): 31 * rendering/RenderObject.cpp: 32 (WebCore::RenderObject::containingBlock): 33 1 34 2015-03-17 Alex Christensen <achristensen@webkit.org> 2 35 -
trunk/Source/WebCore/rendering/LogicalSelectionOffsetCaches.h
r177200 r181654 25 25 26 26 namespace WebCore { 27 28 // FIXME: share code with RenderObject::container().29 static inline bool isContainingBlockCandidateForAbsolutelyPositionedObject(RenderElement& object)30 {31 // FIXME: hasTransformRelatedProperty() includes preserves3D() check, but this may need to change: https://www.w3.org/Bugs/Public/show_bug.cgi?id=2756632 return object.style().position() != StaticPosition33 || (object.isRenderBlock() && object.hasTransformRelatedProperty())34 || object.isSVGForeignObject()35 || object.isRenderView();36 }37 38 static inline bool isNonRenderBlockInline(RenderElement& object)39 {40 return (object.isInline() && !object.isReplaced()) || !object.isRenderBlock();41 }42 43 // FIXME: share code with RenderObject::container().44 static inline RenderBlock* containingBlockForFixedPosition(RenderElement* parent)45 {46 RenderElement* object = parent;47 while (object && !object->canContainFixedPositionObjects())48 object = object->parent();49 ASSERT(!object || !object->isAnonymousBlock());50 return downcast<RenderBlock>(object);51 }52 53 static inline RenderBlock* containingBlockForAbsolutePosition(RenderElement* parent)54 {55 RenderElement* object = parent;56 while (object && !isContainingBlockCandidateForAbsolutelyPositionedObject(*object))57 object = object->parent();58 59 // For a relatively positioned inline, return its nearest non-anonymous containing block,60 // not the inline itself, to avoid having a positioned objects list in all RenderInlines61 // and use RenderBlock* as RenderElement::containingBlock's return type.62 // Use RenderBlock::container() to obtain the inline.63 if (object && !is<RenderBlock>(*object))64 object = object->containingBlock();65 66 while (object && object->isAnonymousBlock())67 object = object->containingBlock();68 69 return downcast<RenderBlock>(object);70 }71 72 static inline RenderBlock* containingBlockForObjectInFlow(RenderElement* parent)73 {74 RenderElement* object = parent;75 while (object && isNonRenderBlockInline(*object))76 object = object->parent();77 return downcast<RenderBlock>(object);78 }79 27 80 28 class LogicalSelectionOffsetCaches { … … 145 93 146 94 // LogicalSelectionOffsetCaches should not be used on an orphaned tree. 147 m_containingBlockForFixedPosition.setBlock( containingBlockForFixedPosition(parent), 0);148 m_containingBlockForAbsolutePosition.setBlock( containingBlockForAbsolutePosition(parent), 0);149 m_containingBlockForInflowPosition.setBlock( containingBlockForObjectInFlow(parent), 0);95 m_containingBlockForFixedPosition.setBlock(parent->containingBlockForFixedPosition(), nullptr); 96 m_containingBlockForAbsolutePosition.setBlock(parent->containingBlockForAbsolutePosition(), nullptr); 97 m_containingBlockForInflowPosition.setBlock(parent->containingBlockForObjectInFlow(), nullptr); 150 98 } 151 99 … … 157 105 m_containingBlockForFixedPosition.setBlock(&block, &cache); 158 106 159 if ( isContainingBlockCandidateForAbsolutelyPositionedObject(block) && !block.isRenderInline() && !block.isAnonymousBlock())107 if (block.canContainAbsolutelyPositionedObjects() && !block.isRenderInline() && !block.isAnonymousBlock()) 160 108 m_containingBlockForFixedPosition.setBlock(&block, &cache); 161 109 -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r181505 r181654 91 91 COMPILE_ASSERT(sizeof(RenderBlock) == sizeof(SameSizeAsRenderBlock), RenderBlock_should_stay_small); 92 92 93 static TrackedDescendantsMap* gPositionedDescendantsMap = 0;94 static TrackedDescendantsMap* gPercentHeightDescendantsMap = 0;95 96 static TrackedContainerMap* gPositionedContainerMap = 0;97 static TrackedContainerMap* gPercentHeightContainerMap = 0;93 static TrackedDescendantsMap* gPositionedDescendantsMap; 94 static TrackedDescendantsMap* gPercentHeightDescendantsMap; 95 96 static TrackedContainerMap* gPositionedContainerMap; 97 static TrackedContainerMap* gPercentHeightContainerMap; 98 98 99 99 typedef HashMap<RenderBlock*, std::unique_ptr<ListHashSet<RenderInline*>>> ContinuationOutlineTableMap; … … 2145 2145 if (gPositionedDescendantsMap) 2146 2146 return gPositionedDescendantsMap->get(this); 2147 return 0;2147 return nullptr; 2148 2148 } 2149 2149 -
trunk/Source/WebCore/rendering/RenderElement.cpp
r181164 r181654 38 38 #include "HTMLNames.h" 39 39 #include "FlowThreadController.h" 40 #include "RenderBlock.h" 40 41 #include "RenderCounter.h" 41 42 #include "RenderDeprecatedFlexibleBox.h" … … 1497 1498 } 1498 1499 1500 RenderBlock* RenderElement::containingBlockForFixedPosition() const 1501 { 1502 const RenderElement* object = this; 1503 while (object && !object->canContainFixedPositionObjects()) 1504 object = object->parent(); 1505 1506 ASSERT(!object || !object->isAnonymousBlock()); 1507 return const_cast<RenderBlock*>(downcast<RenderBlock>(object)); 1508 } 1509 1510 RenderBlock* RenderElement::containingBlockForAbsolutePosition() const 1511 { 1512 const RenderElement* object = this; 1513 while (object && !object->canContainAbsolutelyPositionedObjects()) 1514 object = object->parent(); 1515 1516 // For a relatively positioned inline, return its nearest non-anonymous containing block, 1517 // not the inline itself, to avoid having a positioned objects list in all RenderInlines 1518 // and use RenderBlock* as RenderElement::containingBlock's return type. 1519 // Use RenderBlock::container() to obtain the inline. 1520 if (object && !is<RenderBlock>(*object)) 1521 object = object->containingBlock(); 1522 1523 while (object && object->isAnonymousBlock()) 1524 object = object->containingBlock(); 1525 1526 return const_cast<RenderBlock*>(downcast<RenderBlock>(object)); 1527 } 1528 1529 static inline bool isNonRenderBlockInline(const RenderElement& object) 1530 { 1531 return (object.isInline() && !object.isReplaced()) || !object.isRenderBlock(); 1532 } 1533 1534 RenderBlock* RenderElement::containingBlockForObjectInFlow() const 1535 { 1536 const RenderElement* object = this; 1537 while (object && isNonRenderBlockInline(*object)) 1538 object = object->parent(); 1539 return const_cast<RenderBlock*>(downcast<RenderBlock>(object)); 1540 } 1541 1499 1542 Color RenderElement::selectionColor(int colorProperty) const 1500 1543 { -
trunk/Source/WebCore/rendering/RenderElement.h
r180150 r181654 30 30 31 31 class ControlStates; 32 class RenderBlock; 32 33 33 34 class RenderElement : public RenderObject { … … 64 65 65 66 bool canContainFixedPositionObjects() const; 67 bool canContainAbsolutelyPositionedObjects() const; 68 69 RenderBlock* containingBlockForFixedPosition() const; 70 RenderBlock* containingBlockForAbsolutePosition() const; 71 RenderBlock* containingBlockForObjectInFlow() const; 66 72 67 73 Color selectionColor(int colorProperty) const; … … 394 400 } 395 401 402 inline bool RenderElement::canContainAbsolutelyPositionedObjects() const 403 { 404 return style().position() != StaticPosition 405 || (isRenderBlock() && hasTransformRelatedProperty()) 406 || isSVGForeignObject() 407 || isRenderView(); 408 } 409 396 410 inline bool RenderObject::isRenderLayerModelObject() const 397 411 { -
trunk/Source/WebCore/rendering/RenderLayer.cpp
r181515 r181654 78 78 #include "HitTestResult.h" 79 79 #include "InspectorInstrumentation.h" 80 #include "LogicalSelectionOffsetCaches.h"81 80 #include "OverflowEvent.h" 82 81 #include "OverlapTestRequestClient.h" … … 1435 1434 1436 1435 case AbsolutePosition: 1437 return isContainingBlockCandidateForAbsolutelyPositionedObject(layer.renderer());1436 return layer.renderer().canContainAbsolutelyPositionedObjects(); 1438 1437 1439 1438 default: -
trunk/Source/WebCore/rendering/RenderObject.cpp
r181505 r181654 694 694 const RenderStyle& style = this->style(); 695 695 if (!is<RenderText>(*this) && style.position() == FixedPosition) 696 parent = containingBlockForFixedPosition(parent);696 parent = parent->containingBlockForFixedPosition(); 697 697 else if (!is<RenderText>(*this) && style.position() == AbsolutePosition) 698 parent = containingBlockForAbsolutePosition(parent);698 parent = parent->containingBlockForAbsolutePosition(); 699 699 else 700 parent = containingBlockForObjectInFlow(parent);700 parent = parent->containingBlockForObjectInFlow(); 701 701 702 702 if (!is<RenderBlock>(parent))
Note:
See TracChangeset
for help on using the changeset viewer.