Changeset 156377 in webkit
- Timestamp:
- Sep 24, 2013, 6:01:17 PM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r156374 r156377 1 2013-09-24 Antti Koivisto <antti@apple.com> 2 3 Clean up some uses of first/lastChildSlow 4 https://bugs.webkit.org/show_bug.cgi?id=121882 5 6 Reviewed by Andreas Kling. 7 8 Tighten typing and use first/lastChild instead. 9 10 * dom/Position.cpp: 11 (WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight): 12 (WebCore::Position::isCandidate): 13 (WebCore::Position::getInlineBoxAndOffset): 14 * dom/Position.h: 15 * dom/PositionIterator.cpp: 16 (WebCore::PositionIterator::isCandidate): 17 * editing/CompositeEditCommand.cpp: 18 (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary): 19 * rendering/RenderBlock.cpp: 20 (WebCore::canMergeAnonymousBlock): 21 (WebCore::canMergeContiguousAnonymousBlocks): 22 (WebCore::RenderBlock::firstLineBlock): 23 (WebCore::RenderBlock::updateFirstLetter): 24 * rendering/RenderRegion.cpp: 25 (WebCore::RenderRegion::setRegionObjectsRegionStyle): 26 (WebCore::RenderRegion::computeChildrenStyleInRegion): 27 * rendering/RenderRegion.h: 28 * rendering/RenderRuby.cpp: 29 (WebCore::rubyBeforeBlock): 30 (WebCore::rubyAfterBlock): 31 (WebCore::lastRubyRun): 32 * rendering/RenderTreeAsText.cpp: 33 (WebCore::write): 34 (WebCore::writeCounterValuesFromChildren): 35 * rendering/svg/RenderSVGText.cpp: 36 (WebCore::findPreviousAndNextAttributes): 37 * style/StyleResolveTree.cpp: 38 (WebCore::Style::textRendererIsNeeded): 39 1 40 2013-09-24 Mark Lam <mark.lam@apple.com> 2 41 -
trunk/Source/WebCore/dom/Position.cpp
r156285 r156377 852 852 } 853 853 854 bool Position::hasRenderedNonAnonymousDescendantsWithHeight( RenderObject*renderer)855 { 856 RenderObject* stop = renderer ->nextInPreOrderAfterChildren();857 for (RenderObject *o = renderer->firstChildSlow(); o && o != stop; o = o->nextInPreOrder())854 bool Position::hasRenderedNonAnonymousDescendantsWithHeight(const RenderElement& renderer) 855 { 856 RenderObject* stop = renderer.nextInPreOrderAfterChildren(); 857 for (RenderObject* o = renderer.firstChild(); o && o != stop; o = o->nextInPreOrder()) 858 858 if (o->nonPseudoNode()) { 859 859 if ((o->isText() && boundingBoxLogicalHeight(o, toRenderText(o)->linesBoundingBox())) … … 938 938 939 939 if (renderer->isRenderBlockFlow()) { 940 if (toRenderBlock(renderer)->logicalHeight() || m_anchorNode->hasTagName(bodyTag)) { 941 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer)) 940 RenderBlock& block = toRenderBlock(*renderer); 941 if (block.logicalHeight() || m_anchorNode->hasTagName(bodyTag)) { 942 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(block)) 942 943 return atFirstEditingPositionForNode() && !Position::nodeIsUserSelectNone(deprecatedNode()); 943 944 return m_anchorNode->rendererIsEditable() && !Position::nodeIsUserSelectNone(deprecatedNode()) && atEditingBoundary(); … … 1230 1231 } else { 1231 1232 inlineBox = 0; 1232 if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isRenderBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight( renderer)) {1233 if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isRenderBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight(toRenderBlock(*renderer))) { 1233 1234 // Try a visually equivalent position with possibly opposite editability. This helps in case |this| is in 1234 1235 // an editable block but surrounded by non-editable positions. It acts to negate the logic at the beginning -
trunk/Source/WebCore/dom/Position.h
r154877 r156377 42 42 class Node; 43 43 class Range; 44 class RenderElement; 44 45 class RenderObject; 45 46 class Text; … … 187 188 TextDirection primaryDirection() const; 188 189 189 static bool hasRenderedNonAnonymousDescendantsWithHeight( RenderObject*);190 static bool hasRenderedNonAnonymousDescendantsWithHeight(const RenderElement&); 190 191 static bool nodeIsUserSelectNone(Node*); 191 192 #if ENABLE(USERSELECT_ALL) -
trunk/Source/WebCore/dom/PositionIterator.cpp
r155366 r156377 161 161 162 162 if (!m_anchorNode->hasTagName(htmlTag) && renderer->isRenderBlockFlow()) { 163 if (toRenderBlock(renderer)->logicalHeight() || m_anchorNode->hasTagName(bodyTag)) { 164 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer)) 163 RenderBlock& block = toRenderBlock(*renderer); 164 if (block.logicalHeight() || m_anchorNode->hasTagName(bodyTag)) { 165 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(block)) 165 166 return atStartOfNode() && !Position::nodeIsUserSelectNone(m_anchorNode); 166 167 return m_anchorNode->rendererIsEditable() && !Position::nodeIsUserSelectNone(m_anchorNode) && Position(*this).atEditingBoundary(); -
trunk/Source/WebCore/editing/CompositeEditCommand.cpp
r156289 r156377 941 941 // If the block is the root editable element and it contains no visible content, create a new 942 942 // block but don't try and move content into it, since there's nothing for moveParagraphs to move. 943 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight( upstreamStart.deprecatedNode()->renderer()))943 if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(toRenderElement(*upstreamStart.deprecatedNode()->renderer()))) 944 944 return insertNewDefaultParagraphElementAt(upstreamStart); 945 945 } else if (isBlock(upstreamEnd.deprecatedNode())) { -
trunk/Source/WebCore/rendering/RenderBlock.cpp
r156364 r156377 1069 1069 } 1070 1070 1071 static bool canMergeContiguousAnonymousBlocks(RenderObject* oldChild, RenderObject* prev, RenderObject* next) 1071 static bool canMergeAnonymousBlock(RenderBlock* anonymousBlock) 1072 { 1073 if (anonymousBlock->beingDestroyed() || anonymousBlock->continuation()) 1074 return false; 1075 if (anonymousBlock->isRubyRun() || anonymousBlock->isRubyBase()) 1076 return false; 1077 return true; 1078 } 1079 1080 static bool canMergeContiguousAnonymousBlocks(RenderObject* oldChild, RenderObject* previous, RenderObject* next) 1072 1081 { 1073 1082 if (oldChild->documentBeingDestroyed() || oldChild->isInline() || oldChild->virtualContinuation()) 1074 1083 return false; 1075 1084 1076 if ((prev && (!prev->isAnonymousBlock() || toRenderBlock(prev)->continuation() || toRenderBlock(prev)->beingDestroyed())) 1077 || (next && (!next->isAnonymousBlock() || toRenderBlock(next)->continuation() || toRenderBlock(next)->beingDestroyed()))) 1078 return false; 1079 1080 // FIXME: This check isn't required when inline run-ins can't be split into continuations. 1081 RenderObject* child = prev ? prev->firstChildSlow() : nullptr; 1082 if (child && child->isInline() && child->isRunIn()) 1083 return false; 1084 1085 if ((prev && (prev->isRubyRun() || prev->isRubyBase())) 1086 || (next && (next->isRubyRun() || next->isRubyBase()))) 1087 return false; 1088 1089 if (!prev || !next) 1085 if (previous) { 1086 if (!previous->isAnonymousBlock()) 1087 return false; 1088 RenderBlock* previousAnonymousBlock = toRenderBlock(previous); 1089 if (!canMergeAnonymousBlock(previousAnonymousBlock)) 1090 return false; 1091 // FIXME: This check isn't required when inline run-ins can't be split into continuations. 1092 RenderObject* child = previousAnonymousBlock->firstChild(); 1093 if (child && child->isInline() && child->isRunIn()) 1094 return false; 1095 } 1096 if (next) { 1097 if (!next->isAnonymousBlock()) 1098 return false; 1099 RenderBlock* nextAnonymousBlock = toRenderBlock(next); 1100 if (!canMergeAnonymousBlock(nextAnonymousBlock)) 1101 return false; 1102 } 1103 if (!previous || !next) 1090 1104 return true; 1091 1105 1092 1106 // Make sure the types of the anonymous blocks match up. 1093 return prev ->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock()1094 && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanBlock();1107 return previous->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock() 1108 && previous->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanBlock(); 1095 1109 } 1096 1110 … … 5747 5761 if (hasPseudo) 5748 5762 break; 5749 Render Object* parentBlock = firstLineBlock->parent();5763 RenderElement* parentBlock = firstLineBlock->parent(); 5750 5764 // We include isRenderButton in this check because buttons are 5751 5765 // implemented using flex box but should still support first-line. The … … 5755 5769 // of flexbox. 5756 5770 if (firstLineBlock->isReplaced() || firstLineBlock->isFloating() 5757 || !parentBlock || parentBlock->firstChild Slow() != firstLineBlock || (!parentBlock->isRenderBlockFlow() && !parentBlock->isRenderButton()))5771 || !parentBlock || parentBlock->firstChild() != firstLineBlock || (!parentBlock->isRenderBlockFlow() && !parentBlock->isRenderButton())) 5758 5772 break; 5759 ASSERT_WITH_SECURITY_IMPLICATION(parentBlock->isRenderBlock());5760 5773 firstLineBlock = toRenderBlock(parentBlock); 5761 5774 } … … 5795 5808 } 5796 5809 5797 static inline Render Element* findFirstLetterBlock(RenderBlock* start)5798 { 5799 Render Element* firstLetterBlock = start;5810 static inline RenderBlock* findFirstLetterBlock(RenderBlock* start) 5811 { 5812 RenderBlock* firstLetterBlock = start; 5800 5813 while (true) { 5801 5814 // We include isRenderButton in these two checks because buttons are … … 5815 5828 || (!parentBlock->isRenderBlockFlow() && !parentBlock->isRenderButton())) 5816 5829 return 0; 5817 firstLetterBlock = parentBlock;5830 firstLetterBlock = toRenderBlock(parentBlock); 5818 5831 } 5819 5832 … … 5949 5962 // FIXME: We need to destroy the first-letter object if it is no longer the first child. Need to find 5950 5963 // an efficient way to check for that situation though before implementing anything. 5951 Render Object* firstLetterBlock = findFirstLetterBlock(this);5964 RenderElement* firstLetterBlock = findFirstLetterBlock(this); 5952 5965 if (!firstLetterBlock) 5953 5966 return; 5954 5967 5955 // Drill into inlines looking for our first text child.5956 RenderObject* currChild = firstLetterBlock->firstChildSlow();5957 while ( currChild) {5958 if ( currChild->isText())5968 // Drill into inlines looking for our first text descendant. 5969 RenderObject* descendant = firstLetterBlock->firstChild(); 5970 while (descendant) { 5971 if (descendant->isText()) 5959 5972 break; 5960 if (currChild->isListMarker()) 5961 currChild = currChild->nextSibling(); 5962 else if (currChild->isFloatingOrOutOfFlowPositioned()) { 5963 if (currChild->style()->styleType() == FIRST_LETTER) { 5964 currChild = currChild->firstChildSlow(); 5973 RenderElement& current = toRenderElement(*descendant); 5974 if (current.isListMarker()) 5975 descendant = current.nextSibling(); 5976 else if (current.isFloatingOrOutOfFlowPositioned()) { 5977 if (current.style()->styleType() == FIRST_LETTER) { 5978 descendant = current.firstChild(); 5965 5979 break; 5966 5980 } 5967 currChild = currChild->nextSibling();5968 } else if (curr Child->isReplaced() || currChild->isRenderButton() || currChild->isMenuList())5981 descendant = current.nextSibling(); 5982 } else if (current.isReplaced() || current.isRenderButton() || current.isMenuList()) 5969 5983 break; 5970 else if (curr Child->style()->hasPseudoStyle(FIRST_LETTER) && currChild->canHaveGeneratedChildren()) {5984 else if (current.style()->hasPseudoStyle(FIRST_LETTER) && current.canHaveGeneratedChildren()) { 5971 5985 // We found a lower-level node with first-letter, which supersedes the higher-level style 5972 firstLetterBlock = currChild;5973 currChild = currChild->firstChildSlow();5986 firstLetterBlock = ¤t; 5987 descendant = current.firstChild(); 5974 5988 } else 5975 currChild = currChild->firstChildSlow();5976 } 5977 5978 if (! currChild)5989 descendant = current.firstChild(); 5990 } 5991 5992 if (!descendant) 5979 5993 return; 5980 5994 5981 5995 // If the child already has style, then it has already been created, so we just want 5982 5996 // to update it. 5983 if ( currChild->parent()->style()->styleType() == FIRST_LETTER) {5984 updateFirstLetterStyle(firstLetterBlock, currChild);5985 return; 5986 } 5987 5988 if (! currChild->isText())5997 if (descendant->parent()->style()->styleType() == FIRST_LETTER) { 5998 updateFirstLetterStyle(firstLetterBlock, descendant); 5999 return; 6000 } 6001 6002 if (!descendant->isText()) 5989 6003 return; 5990 6004 … … 5993 6007 LayoutStateDisabler layoutStateDisabler(&view()); 5994 6008 5995 createFirstLetterRenderer(firstLetterBlock, toRenderText( currChild));6009 createFirstLetterRenderer(firstLetterBlock, toRenderText(descendant)); 5996 6010 } 5997 6011 -
trunk/Source/WebCore/rendering/RenderRegion.cpp
r156285 r156377 498 498 continue; 499 499 500 Render Object* object = element->renderer();500 RenderElement* object = element->renderer(); 501 501 // If the content node does not flow any of its children in this region, 502 502 // we do not compute any style for them in this region. … … 579 579 } 580 580 581 void RenderRegion::computeChildrenStyleInRegion(const Render Object* object)582 { 583 for (RenderObject* child = object->firstChild Slow(); child; child = child->nextSibling()) {581 void RenderRegion::computeChildrenStyleInRegion(const RenderElement* object) 582 { 583 for (RenderObject* child = object->firstChild(); child; child = child->nextSibling()) { 584 584 585 585 RenderObjectRegionStyleMap::iterator it = m_renderObjectRegionStyle.find(child); … … 601 601 setObjectStyleInRegion(child, childStyleInRegion, objectRegionStyleCached); 602 602 603 computeChildrenStyleInRegion(child); 603 if (child->isRenderElement()) 604 computeChildrenStyleInRegion(toRenderElement(child)); 604 605 } 605 606 } -
trunk/Source/WebCore/rendering/RenderRegion.h
r156093 r156377 191 191 192 192 PassRefPtr<RenderStyle> computeStyleInRegion(const RenderObject*); 193 void computeChildrenStyleInRegion(const Render Object*);193 void computeChildrenStyleInRegion(const RenderElement*); 194 194 void setObjectStyleInRegion(RenderObject*, PassRefPtr<RenderStyle>, bool objectRegionStyleCached); 195 195 -
trunk/Source/WebCore/rendering/RenderRuby.cpp
r156312 r156377 72 72 } 73 73 74 static inline RenderBlock* rubyBeforeBlock(const Render Object* ruby)75 { 76 RenderObject* child = ruby->firstChild Slow();74 static inline RenderBlock* rubyBeforeBlock(const RenderElement* ruby) 75 { 76 RenderObject* child = ruby->firstChild(); 77 77 return isRubyBeforeBlock(child) ? toRenderBlock(child) : 0; 78 78 } 79 79 80 static inline RenderBlock* rubyAfterBlock(const Render Object* ruby)81 { 82 RenderObject* child = ruby->lastChild Slow();80 static inline RenderBlock* rubyAfterBlock(const RenderElement* ruby) 81 { 82 RenderObject* child = ruby->lastChild(); 83 83 return isRubyAfterBlock(child) ? toRenderBlock(child) : 0; 84 84 } … … 92 92 } 93 93 94 static RenderRubyRun* lastRubyRun(const Render Object* ruby)95 { 96 RenderObject* child = ruby->lastChild Slow();94 static RenderRubyRun* lastRubyRun(const RenderElement* ruby) 95 { 96 RenderObject* child = ruby->lastChild(); 97 97 if (child && !child->isRubyRun()) 98 98 child = child->previousSibling(); -
trunk/Source/WebCore/rendering/RenderTreeAsText.cpp
r156285 r156377 596 596 writeTextRun(ts, text, *box); 597 597 } 598 } 599 600 for (RenderObject* child = o.firstChildSlow(); child; child = child->nextSibling()) {601 if (child->hasLayer())602 continue;603 write(ts, *child, indent + 1, behavior);598 } else { 599 for (RenderObject* child = toRenderElement(o).firstChild(); child; child = child->nextSibling()) { 600 if (child->hasLayer()) 601 continue; 602 write(ts, *child, indent + 1, behavior); 603 } 604 604 } 605 605 … … 915 915 } 916 916 917 static void writeCounterValuesFromChildren(TextStream& stream, Render Object* parent, bool& isFirstCounter)917 static void writeCounterValuesFromChildren(TextStream& stream, RenderElement* parent, bool& isFirstCounter) 918 918 { 919 919 if (!parent) 920 920 return; 921 for (RenderObject* child = parent->firstChild Slow(); child; child = child->nextSibling()) {921 for (RenderObject* child = parent->firstChild(); child; child = child->nextSibling()) { 922 922 if (child->isCounter()) { 923 923 if (!isFirstCounter) -
trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp
r156285 r156377 136 136 } 137 137 138 static inline bool findPreviousAndNextAttributes(Render Object* start, RenderSVGInlineText* locateElement, bool& stopAfterNext, SVGTextLayoutAttributes*& previous, SVGTextLayoutAttributes*& next)138 static inline bool findPreviousAndNextAttributes(RenderElement* start, RenderSVGInlineText* locateElement, bool& stopAfterNext, SVGTextLayoutAttributes*& previous, SVGTextLayoutAttributes*& next) 139 139 { 140 140 ASSERT(start); 141 141 ASSERT(locateElement); 142 142 // FIXME: Make this iterative. 143 for (RenderObject* child = start->firstChild Slow(); child; child = child->nextSibling()) {143 for (RenderObject* child = start->firstChild(); child; child = child->nextSibling()) { 144 144 if (child->isSVGInlineText()) { 145 145 RenderSVGInlineText* text = toRenderSVGInlineText(child); … … 161 161 continue; 162 162 163 if (findPreviousAndNextAttributes( child, locateElement, stopAfterNext, previous, next))163 if (findPreviousAndNextAttributes(toRenderElement(child), locateElement, stopAfterNext, previous, next)) 164 164 return true; 165 165 } -
trunk/Source/WebCore/style/StyleResolveTree.cpp
r156285 r156377 341 341 return false; 342 342 343 RenderObject* first = parentRenderer.firstChildSlow();343 RenderObject* first = toRenderElement(parentRenderer).firstChild(); 344 344 while (first && first->isFloatingOrOutOfFlowPositioned()) 345 345 first = first->nextSibling();
Note:
See TracChangeset
for help on using the changeset viewer.