Diff
Modified: trunk/Source/WebCore/ChangeLog (156376 => 156377)
--- trunk/Source/WebCore/ChangeLog 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/ChangeLog 2013-09-25 01:01:17 UTC (rev 156377)
@@ -1,3 +1,42 @@
+2013-09-24 Antti Koivisto <[email protected]>
+
+ Clean up some uses of first/lastChildSlow
+ https://bugs.webkit.org/show_bug.cgi?id=121882
+
+ Reviewed by Andreas Kling.
+
+ Tighten typing and use first/lastChild instead.
+
+ * dom/Position.cpp:
+ (WebCore::Position::hasRenderedNonAnonymousDescendantsWithHeight):
+ (WebCore::Position::isCandidate):
+ (WebCore::Position::getInlineBoxAndOffset):
+ * dom/Position.h:
+ * dom/PositionIterator.cpp:
+ (WebCore::PositionIterator::isCandidate):
+ * editing/CompositeEditCommand.cpp:
+ (WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):
+ * rendering/RenderBlock.cpp:
+ (WebCore::canMergeAnonymousBlock):
+ (WebCore::canMergeContiguousAnonymousBlocks):
+ (WebCore::RenderBlock::firstLineBlock):
+ (WebCore::RenderBlock::updateFirstLetter):
+ * rendering/RenderRegion.cpp:
+ (WebCore::RenderRegion::setRegionObjectsRegionStyle):
+ (WebCore::RenderRegion::computeChildrenStyleInRegion):
+ * rendering/RenderRegion.h:
+ * rendering/RenderRuby.cpp:
+ (WebCore::rubyBeforeBlock):
+ (WebCore::rubyAfterBlock):
+ (WebCore::lastRubyRun):
+ * rendering/RenderTreeAsText.cpp:
+ (WebCore::write):
+ (WebCore::writeCounterValuesFromChildren):
+ * rendering/svg/RenderSVGText.cpp:
+ (WebCore::findPreviousAndNextAttributes):
+ * style/StyleResolveTree.cpp:
+ (WebCore::Style::textRendererIsNeeded):
+
2013-09-24 Mark Lam <[email protected]>
Change JSC debug hooks to pass a CallFrame* instead of a DebuggerCallFrame.
Modified: trunk/Source/WebCore/dom/Position.cpp (156376 => 156377)
--- trunk/Source/WebCore/dom/Position.cpp 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/dom/Position.cpp 2013-09-25 01:01:17 UTC (rev 156377)
@@ -851,10 +851,10 @@
return o->style()->isHorizontalWritingMode() ? rect.height() : rect.width();
}
-bool Position::hasRenderedNonAnonymousDescendantsWithHeight(RenderObject* renderer)
+bool Position::hasRenderedNonAnonymousDescendantsWithHeight(const RenderElement& renderer)
{
- RenderObject* stop = renderer->nextInPreOrderAfterChildren();
- for (RenderObject *o = renderer->firstChildSlow(); o && o != stop; o = o->nextInPreOrder())
+ RenderObject* stop = renderer.nextInPreOrderAfterChildren();
+ for (RenderObject* o = renderer.firstChild(); o && o != stop; o = o->nextInPreOrder())
if (o->nonPseudoNode()) {
if ((o->isText() && boundingBoxLogicalHeight(o, toRenderText(o)->linesBoundingBox()))
|| (o->isLineBreak() && boundingBoxLogicalHeight(o, toRenderLineBreak(o)->linesBoundingBox()))
@@ -937,8 +937,9 @@
return false;
if (renderer->isRenderBlockFlow()) {
- if (toRenderBlock(renderer)->logicalHeight() || m_anchorNode->hasTagName(bodyTag)) {
- if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer))
+ RenderBlock& block = toRenderBlock(*renderer);
+ if (block.logicalHeight() || m_anchorNode->hasTagName(bodyTag)) {
+ if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(block))
return atFirstEditingPositionForNode() && !Position::nodeIsUserSelectNone(deprecatedNode());
return m_anchorNode->rendererIsEditable() && !Position::nodeIsUserSelectNone(deprecatedNode()) && atEditingBoundary();
}
@@ -1229,7 +1230,7 @@
inlineBox = box ? box : candidate;
} else {
inlineBox = 0;
- if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isRenderBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight(renderer)) {
+ if (canHaveChildrenForEditing(deprecatedNode()) && renderer->isRenderBlockFlow() && hasRenderedNonAnonymousDescendantsWithHeight(toRenderBlock(*renderer))) {
// Try a visually equivalent position with possibly opposite editability. This helps in case |this| is in
// an editable block but surrounded by non-editable positions. It acts to negate the logic at the beginning
// of RenderObject::createVisiblePosition().
Modified: trunk/Source/WebCore/dom/Position.h (156376 => 156377)
--- trunk/Source/WebCore/dom/Position.h 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/dom/Position.h 2013-09-25 01:01:17 UTC (rev 156377)
@@ -41,6 +41,7 @@
class InlineBox;
class Node;
class Range;
+class RenderElement;
class RenderObject;
class Text;
@@ -186,7 +187,7 @@
TextDirection primaryDirection() const;
- static bool hasRenderedNonAnonymousDescendantsWithHeight(RenderObject*);
+ static bool hasRenderedNonAnonymousDescendantsWithHeight(const RenderElement&);
static bool nodeIsUserSelectNone(Node*);
#if ENABLE(USERSELECT_ALL)
static bool nodeIsUserSelectAll(const Node*);
Modified: trunk/Source/WebCore/dom/PositionIterator.cpp (156376 => 156377)
--- trunk/Source/WebCore/dom/PositionIterator.cpp 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/dom/PositionIterator.cpp 2013-09-25 01:01:17 UTC (rev 156377)
@@ -160,8 +160,9 @@
return (atStartOfNode() || atEndOfNode()) && !Position::nodeIsUserSelectNone(m_anchorNode->parentNode());
if (!m_anchorNode->hasTagName(htmlTag) && renderer->isRenderBlockFlow()) {
- if (toRenderBlock(renderer)->logicalHeight() || m_anchorNode->hasTagName(bodyTag)) {
- if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(renderer))
+ RenderBlock& block = toRenderBlock(*renderer);
+ if (block.logicalHeight() || m_anchorNode->hasTagName(bodyTag)) {
+ if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(block))
return atStartOfNode() && !Position::nodeIsUserSelectNone(m_anchorNode);
return m_anchorNode->rendererIsEditable() && !Position::nodeIsUserSelectNone(m_anchorNode) && Position(*this).atEditingBoundary();
}
Modified: trunk/Source/WebCore/editing/CompositeEditCommand.cpp (156376 => 156377)
--- trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/editing/CompositeEditCommand.cpp 2013-09-25 01:01:17 UTC (rev 156377)
@@ -940,7 +940,7 @@
if (upstreamStart.deprecatedNode() == editableRootForPosition(upstreamStart)) {
// If the block is the root editable element and it contains no visible content, create a new
// block but don't try and move content into it, since there's nothing for moveParagraphs to move.
- if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(upstreamStart.deprecatedNode()->renderer()))
+ if (!Position::hasRenderedNonAnonymousDescendantsWithHeight(toRenderElement(*upstreamStart.deprecatedNode()->renderer())))
return insertNewDefaultParagraphElementAt(upstreamStart);
} else if (isBlock(upstreamEnd.deprecatedNode())) {
if (!upstreamEnd.deprecatedNode()->isDescendantOf(upstreamStart.deprecatedNode())) {
Modified: trunk/Source/WebCore/rendering/RenderBlock.cpp (156376 => 156377)
--- trunk/Source/WebCore/rendering/RenderBlock.cpp 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/rendering/RenderBlock.cpp 2013-09-25 01:01:17 UTC (rev 156377)
@@ -1068,30 +1068,44 @@
child->destroy();
}
-static bool canMergeContiguousAnonymousBlocks(RenderObject* oldChild, RenderObject* prev, RenderObject* next)
+static bool canMergeAnonymousBlock(RenderBlock* anonymousBlock)
{
- if (oldChild->documentBeingDestroyed() || oldChild->isInline() || oldChild->virtualContinuation())
+ if (anonymousBlock->beingDestroyed() || anonymousBlock->continuation())
return false;
-
- if ((prev && (!prev->isAnonymousBlock() || toRenderBlock(prev)->continuation() || toRenderBlock(prev)->beingDestroyed()))
- || (next && (!next->isAnonymousBlock() || toRenderBlock(next)->continuation() || toRenderBlock(next)->beingDestroyed())))
+ if (anonymousBlock->isRubyRun() || anonymousBlock->isRubyBase())
return false;
+ return true;
+}
- // FIXME: This check isn't required when inline run-ins can't be split into continuations.
- RenderObject* child = prev ? prev->firstChildSlow() : nullptr;
- if (child && child->isInline() && child->isRunIn())
+static bool canMergeContiguousAnonymousBlocks(RenderObject* oldChild, RenderObject* previous, RenderObject* next)
+{
+ if (oldChild->documentBeingDestroyed() || oldChild->isInline() || oldChild->virtualContinuation())
return false;
- if ((prev && (prev->isRubyRun() || prev->isRubyBase()))
- || (next && (next->isRubyRun() || next->isRubyBase())))
- return false;
-
- if (!prev || !next)
+ if (previous) {
+ if (!previous->isAnonymousBlock())
+ return false;
+ RenderBlock* previousAnonymousBlock = toRenderBlock(previous);
+ if (!canMergeAnonymousBlock(previousAnonymousBlock))
+ return false;
+ // FIXME: This check isn't required when inline run-ins can't be split into continuations.
+ RenderObject* child = previousAnonymousBlock->firstChild();
+ if (child && child->isInline() && child->isRunIn())
+ return false;
+ }
+ if (next) {
+ if (!next->isAnonymousBlock())
+ return false;
+ RenderBlock* nextAnonymousBlock = toRenderBlock(next);
+ if (!canMergeAnonymousBlock(nextAnonymousBlock))
+ return false;
+ }
+ if (!previous || !next)
return true;
// Make sure the types of the anonymous blocks match up.
- return prev->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock()
- && prev->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanBlock();
+ return previous->isAnonymousColumnsBlock() == next->isAnonymousColumnsBlock()
+ && previous->isAnonymousColumnSpanBlock() == next->isAnonymousColumnSpanBlock();
}
void RenderBlock::collapseAnonymousBoxChild(RenderBlock* parent, RenderBlock* child)
@@ -5746,7 +5760,7 @@
hasPseudo = firstLineBlock->style()->hasPseudoStyle(FIRST_LINE);
if (hasPseudo)
break;
- RenderObject* parentBlock = firstLineBlock->parent();
+ RenderElement* parentBlock = firstLineBlock->parent();
// We include isRenderButton in this check because buttons are
// implemented using flex box but should still support first-line. The
// flex box spec requires that flex box does not support first-line,
@@ -5754,9 +5768,8 @@
// FIXME: Remove when buttons are implemented with align-items instead
// of flexbox.
if (firstLineBlock->isReplaced() || firstLineBlock->isFloating()
- || !parentBlock || parentBlock->firstChildSlow() != firstLineBlock || (!parentBlock->isRenderBlockFlow() && !parentBlock->isRenderButton()))
+ || !parentBlock || parentBlock->firstChild() != firstLineBlock || (!parentBlock->isRenderBlockFlow() && !parentBlock->isRenderButton()))
break;
- ASSERT_WITH_SECURITY_IMPLICATION(parentBlock->isRenderBlock());
firstLineBlock = toRenderBlock(parentBlock);
}
@@ -5794,9 +5807,9 @@
return isSpaceOrNewline(c) || c == noBreakSpace || isPunctuationForFirstLetter(c);
}
-static inline RenderElement* findFirstLetterBlock(RenderBlock* start)
+static inline RenderBlock* findFirstLetterBlock(RenderBlock* start)
{
- RenderElement* firstLetterBlock = start;
+ RenderBlock* firstLetterBlock = start;
while (true) {
// We include isRenderButton in these two checks because buttons are
// implemented using flex box but should still support first-letter.
@@ -5814,7 +5827,7 @@
if (firstLetterBlock->isReplaced() || !parentBlock || parentBlock->firstChild() != firstLetterBlock
|| (!parentBlock->isRenderBlockFlow() && !parentBlock->isRenderButton()))
return 0;
- firstLetterBlock = parentBlock;
+ firstLetterBlock = toRenderBlock(parentBlock);
}
return 0;
@@ -5948,51 +5961,52 @@
// FIXME: We need to destroy the first-letter object if it is no longer the first child. Need to find
// an efficient way to check for that situation though before implementing anything.
- RenderObject* firstLetterBlock = findFirstLetterBlock(this);
+ RenderElement* firstLetterBlock = findFirstLetterBlock(this);
if (!firstLetterBlock)
return;
- // Drill into inlines looking for our first text child.
- RenderObject* currChild = firstLetterBlock->firstChildSlow();
- while (currChild) {
- if (currChild->isText())
+ // Drill into inlines looking for our first text descendant.
+ RenderObject* descendant = firstLetterBlock->firstChild();
+ while (descendant) {
+ if (descendant->isText())
break;
- if (currChild->isListMarker())
- currChild = currChild->nextSibling();
- else if (currChild->isFloatingOrOutOfFlowPositioned()) {
- if (currChild->style()->styleType() == FIRST_LETTER) {
- currChild = currChild->firstChildSlow();
+ RenderElement& current = toRenderElement(*descendant);
+ if (current.isListMarker())
+ descendant = current.nextSibling();
+ else if (current.isFloatingOrOutOfFlowPositioned()) {
+ if (current.style()->styleType() == FIRST_LETTER) {
+ descendant = current.firstChild();
break;
}
- currChild = currChild->nextSibling();
- } else if (currChild->isReplaced() || currChild->isRenderButton() || currChild->isMenuList())
+ descendant = current.nextSibling();
+ } else if (current.isReplaced() || current.isRenderButton() || current.isMenuList())
break;
- else if (currChild->style()->hasPseudoStyle(FIRST_LETTER) && currChild->canHaveGeneratedChildren()) {
+ else if (current.style()->hasPseudoStyle(FIRST_LETTER) && current.canHaveGeneratedChildren()) {
// We found a lower-level node with first-letter, which supersedes the higher-level style
- firstLetterBlock = currChild;
- currChild = currChild->firstChildSlow();
+ firstLetterBlock = ¤t;
+ descendant = current.firstChild();
} else
- currChild = currChild->firstChildSlow();
+ descendant = current.firstChild();
}
- if (!currChild)
+ if (!descendant)
return;
// If the child already has style, then it has already been created, so we just want
// to update it.
- if (currChild->parent()->style()->styleType() == FIRST_LETTER) {
- updateFirstLetterStyle(firstLetterBlock, currChild);
+ if (descendant->parent()->style()->styleType() == FIRST_LETTER) {
+ updateFirstLetterStyle(firstLetterBlock, descendant);
return;
}
- if (!currChild->isText())
+ if (!descendant->isText())
return;
// Our layout state is not valid for the repaints we are going to trigger by
// adding and removing children of firstLetterContainer.
LayoutStateDisabler layoutStateDisabler(&view());
- createFirstLetterRenderer(firstLetterBlock, toRenderText(currChild));
+ createFirstLetterRenderer(firstLetterBlock, toRenderText(descendant));
}
// Helper methods for obtaining the last line, computing line counts and heights for line counts
Modified: trunk/Source/WebCore/rendering/RenderRegion.cpp (156376 => 156377)
--- trunk/Source/WebCore/rendering/RenderRegion.cpp 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/rendering/RenderRegion.cpp 2013-09-25 01:01:17 UTC (rev 156377)
@@ -497,7 +497,7 @@
if (!element->renderer())
continue;
- RenderObject* object = element->renderer();
+ RenderElement* object = element->renderer();
// If the content node does not flow any of its children in this region,
// we do not compute any style for them in this region.
if (!flowThread()->objectInFlowRegion(object, this))
@@ -578,9 +578,9 @@
return renderObjectRegionStyle.release();
}
-void RenderRegion::computeChildrenStyleInRegion(const RenderObject* object)
+void RenderRegion::computeChildrenStyleInRegion(const RenderElement* object)
{
- for (RenderObject* child = object->firstChildSlow(); child; child = child->nextSibling()) {
+ for (RenderObject* child = object->firstChild(); child; child = child->nextSibling()) {
RenderObjectRegionStyleMap::iterator it = m_renderObjectRegionStyle.find(child);
@@ -600,7 +600,8 @@
setObjectStyleInRegion(child, childStyleInRegion, objectRegionStyleCached);
- computeChildrenStyleInRegion(child);
+ if (child->isRenderElement())
+ computeChildrenStyleInRegion(toRenderElement(child));
}
}
Modified: trunk/Source/WebCore/rendering/RenderRegion.h (156376 => 156377)
--- trunk/Source/WebCore/rendering/RenderRegion.h 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/rendering/RenderRegion.h 2013-09-25 01:01:17 UTC (rev 156377)
@@ -190,7 +190,7 @@
virtual void installFlowThread();
PassRefPtr<RenderStyle> computeStyleInRegion(const RenderObject*);
- void computeChildrenStyleInRegion(const RenderObject*);
+ void computeChildrenStyleInRegion(const RenderElement*);
void setObjectStyleInRegion(RenderObject*, PassRefPtr<RenderStyle>, bool objectRegionStyleCached);
void checkRegionStyle();
Modified: trunk/Source/WebCore/rendering/RenderRuby.cpp (156376 => 156377)
--- trunk/Source/WebCore/rendering/RenderRuby.cpp 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/rendering/RenderRuby.cpp 2013-09-25 01:01:17 UTC (rev 156377)
@@ -71,15 +71,15 @@
&& object->firstChildSlow()->style()->styleType() == AFTER;
}
-static inline RenderBlock* rubyBeforeBlock(const RenderObject* ruby)
+static inline RenderBlock* rubyBeforeBlock(const RenderElement* ruby)
{
- RenderObject* child = ruby->firstChildSlow();
+ RenderObject* child = ruby->firstChild();
return isRubyBeforeBlock(child) ? toRenderBlock(child) : 0;
}
-static inline RenderBlock* rubyAfterBlock(const RenderObject* ruby)
+static inline RenderBlock* rubyAfterBlock(const RenderElement* ruby)
{
- RenderObject* child = ruby->lastChildSlow();
+ RenderObject* child = ruby->lastChild();
return isRubyAfterBlock(child) ? toRenderBlock(child) : 0;
}
@@ -91,9 +91,9 @@
return newBlock;
}
-static RenderRubyRun* lastRubyRun(const RenderObject* ruby)
+static RenderRubyRun* lastRubyRun(const RenderElement* ruby)
{
- RenderObject* child = ruby->lastChildSlow();
+ RenderObject* child = ruby->lastChild();
if (child && !child->isRubyRun())
child = child->previousSibling();
ASSERT(!child || child->isRubyRun() || child->isBeforeContent() || child == rubyBeforeBlock(ruby));
Modified: trunk/Source/WebCore/rendering/RenderTreeAsText.cpp (156376 => 156377)
--- trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/rendering/RenderTreeAsText.cpp 2013-09-25 01:01:17 UTC (rev 156377)
@@ -595,14 +595,14 @@
writeIndent(ts, indent + 1);
writeTextRun(ts, text, *box);
}
+ } else {
+ for (RenderObject* child = toRenderElement(o).firstChild(); child; child = child->nextSibling()) {
+ if (child->hasLayer())
+ continue;
+ write(ts, *child, indent + 1, behavior);
+ }
}
- for (RenderObject* child = o.firstChildSlow(); child; child = child->nextSibling()) {
- if (child->hasLayer())
- continue;
- write(ts, *child, indent + 1, behavior);
- }
-
if (o.isWidget()) {
Widget* widget = toRenderWidget(&o)->widget();
if (widget && widget->isFrameView()) {
@@ -914,11 +914,11 @@
return externalRepresentation(toRenderBox(renderer), behavior | RenderAsTextShowAllLayers);
}
-static void writeCounterValuesFromChildren(TextStream& stream, RenderObject* parent, bool& isFirstCounter)
+static void writeCounterValuesFromChildren(TextStream& stream, RenderElement* parent, bool& isFirstCounter)
{
if (!parent)
return;
- for (RenderObject* child = parent->firstChildSlow(); child; child = child->nextSibling()) {
+ for (RenderObject* child = parent->firstChild(); child; child = child->nextSibling()) {
if (child->isCounter()) {
if (!isFirstCounter)
stream << " ";
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp (156376 => 156377)
--- trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp 2013-09-25 01:01:17 UTC (rev 156377)
@@ -135,12 +135,12 @@
}
}
-static inline bool findPreviousAndNextAttributes(RenderObject* start, RenderSVGInlineText* locateElement, bool& stopAfterNext, SVGTextLayoutAttributes*& previous, SVGTextLayoutAttributes*& next)
+static inline bool findPreviousAndNextAttributes(RenderElement* start, RenderSVGInlineText* locateElement, bool& stopAfterNext, SVGTextLayoutAttributes*& previous, SVGTextLayoutAttributes*& next)
{
ASSERT(start);
ASSERT(locateElement);
// FIXME: Make this iterative.
- for (RenderObject* child = start->firstChildSlow(); child; child = child->nextSibling()) {
+ for (RenderObject* child = start->firstChild(); child; child = child->nextSibling()) {
if (child->isSVGInlineText()) {
RenderSVGInlineText* text = toRenderSVGInlineText(child);
if (locateElement != text) {
@@ -160,7 +160,7 @@
if (!child->isSVGInline())
continue;
- if (findPreviousAndNextAttributes(child, locateElement, stopAfterNext, previous, next))
+ if (findPreviousAndNextAttributes(toRenderElement(child), locateElement, stopAfterNext, previous, next))
return true;
}
Modified: trunk/Source/WebCore/style/StyleResolveTree.cpp (156376 => 156377)
--- trunk/Source/WebCore/style/StyleResolveTree.cpp 2013-09-25 00:37:57 UTC (rev 156376)
+++ trunk/Source/WebCore/style/StyleResolveTree.cpp 2013-09-25 01:01:17 UTC (rev 156377)
@@ -340,7 +340,7 @@
if (parentRenderer.isRenderBlock() && !parentRenderer.childrenInline() && (!previousRenderer || !previousRenderer->isInline()))
return false;
- RenderObject* first = parentRenderer.firstChildSlow();
+ RenderObject* first = toRenderElement(parentRenderer).firstChild();
while (first && first->isFloatingOrOutOfFlowPositioned())
first = first->nextSibling();
RenderObject* nextRenderer = nextSiblingRenderer(textNode);