Diff
Modified: trunk/Source/WebCore/ChangeLog (174541 => 174542)
--- trunk/Source/WebCore/ChangeLog 2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/ChangeLog 2014-10-09 23:55:40 UTC (rev 174542)
@@ -1,3 +1,44 @@
+2014-10-09 Chris Dumez <[email protected]>
+
+ Use RenderObject::firstChildSlow() / lastChildSlow() less
+ https://bugs.webkit.org/show_bug.cgi?id=137573
+
+ Reviewed by Andreas Kling.
+
+ Use RenderObject::firstChildSlow() / lastChildSlow() less by using
+ tighter typing at call sites whenever possible to be able to call the
+ faster RenderElement::firstChild() / lastChild() instead.
+
+ This patch also uses more references instead of pointers when possible.
+
+ No new tests, no behavior change.
+
+ * accessibility/AccessibilityRenderObject.cpp:
+ (WebCore::firstChildIsInlineContinuation):
+ (WebCore::AccessibilityRenderObject::previousSibling):
+ (WebCore::lastChildHasContinuation):
+ (WebCore::AccessibilityRenderObject::nextSibling):
+ * page/FrameView.cpp:
+ (WebCore::countRenderedCharactersInRenderObjectWithThreshold):
+ (WebCore::FrameView::renderedCharactersExceed):
+ * rendering/RenderElement.h:
+ * rendering/RenderRuby.cpp:
+ (WebCore::isAnonymousRubyInlineBlock):
+ (WebCore::isRubyBeforeBlock):
+ (WebCore::isRubyAfterBlock):
+ * rendering/svg/RenderSVGInline.h:
+ * rendering/svg/RenderSVGText.cpp:
+ (WebCore::RenderSVGText::layout):
+ * rendering/svg/SVGTextLayoutAttributesBuilder.cpp:
+ (WebCore::SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer):
+ (WebCore::SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree):
+ (WebCore::SVGTextLayoutAttributesBuilder::collectTextPositioningElements):
+ (WebCore::SVGTextLayoutAttributesBuilder::buildCharacterDataMap):
+ * rendering/svg/SVGTextLayoutAttributesBuilder.h:
+ * svg/SVGTextPositioningElement.cpp:
+ (WebCore::SVGTextPositioningElement::elementFromRenderer):
+ * svg/SVGTextPositioningElement.h:
+
2014-10-09 Roger Fong <[email protected]>
Build fix for Win EWS bots.
Modified: trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp (174541 => 174542)
--- trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/accessibility/AccessibilityRenderObject.cpp 2014-10-09 23:55:40 UTC (rev 174542)
@@ -308,9 +308,9 @@
return nullptr;
}
-static inline bool firstChildIsInlineContinuation(RenderObject* renderer)
+static inline bool firstChildIsInlineContinuation(RenderElement& renderer)
{
- RenderObject* child = renderer->firstChildSlow();
+ RenderObject* child = renderer.firstChild();
return child && child->isInlineElementContinuation();
}
@@ -329,9 +329,11 @@
// Case 2: Anonymous block parent of the end of a continuation - skip all the way to before
// the parent of the start, since everything in between will be linked up via the continuation.
- else if (m_renderer->isAnonymousBlock() && firstChildIsInlineContinuation(m_renderer)) {
- auto* firstParent = startOfContinuations(*m_renderer->firstChildSlow())->parent();
- while (firstChildIsInlineContinuation(firstParent))
+ else if (m_renderer->isAnonymousBlock() && firstChildIsInlineContinuation(downcast<RenderBlock>(*m_renderer))) {
+ RenderBlock& renderBlock = downcast<RenderBlock>(*m_renderer);
+ auto* firstParent = startOfContinuations(*renderBlock.firstChild())->parent();
+ ASSERT(firstParent);
+ while (firstChildIsInlineContinuation(*firstParent))
firstParent = startOfContinuations(*firstParent->firstChild())->parent();
previousSibling = firstParent->previousSibling();
}
@@ -351,9 +353,9 @@
return axObjectCache()->getOrCreate(previousSibling);
}
-static inline bool lastChildHasContinuation(RenderObject* renderer)
+static inline bool lastChildHasContinuation(RenderElement& renderer)
{
- RenderObject* child = renderer->lastChildSlow();
+ RenderObject* child = renderer.lastChild();
return child && isInlineWithContinuation(child);
}
@@ -372,9 +374,10 @@
// Case 2: Anonymous block parent of the start of a continuation - skip all the way to
// after the parent of the end, since everything in between will be linked up via the continuation.
- else if (m_renderer->isAnonymousBlock() && lastChildHasContinuation(m_renderer)) {
+ else if (m_renderer->isAnonymousBlock() && lastChildHasContinuation(downcast<RenderBlock>(*m_renderer))) {
RenderElement* lastParent = endOfContinuations(*downcast<RenderBlock>(*m_renderer).lastChild())->parent();
- while (lastChildHasContinuation(lastParent))
+ ASSERT(lastParent);
+ while (lastChildHasContinuation(*lastParent))
lastParent = endOfContinuations(*lastParent->lastChild())->parent();
nextSibling = lastParent->nextSibling();
}
Modified: trunk/Source/WebCore/page/FrameView.cpp (174541 => 174542)
--- trunk/Source/WebCore/page/FrameView.cpp 2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/page/FrameView.cpp 2014-10-09 23:55:40 UTC (rev 174542)
@@ -2234,25 +2234,24 @@
ScrollView::repaintContentRectangle(r);
}
-static unsigned countRenderedCharactersInRenderObjectWithThreshold(const RenderObject& renderer, unsigned countSoFar, unsigned threshold)
+static unsigned countRenderedCharactersInRenderObjectWithThreshold(const RenderElement& renderer, unsigned threshold)
{
- // FIXME: Consider writing this using RenderObject::nextInPreOrder() instead of using recursion.
- if (is<RenderText>(renderer))
- countSoFar += downcast<RenderText>(renderer).text()->length();
-
- for (RenderObject* child = renderer.firstChildSlow(); child; child = child->nextSibling()) {
- if (countSoFar >= threshold)
- break;
- countSoFar = countRenderedCharactersInRenderObjectWithThreshold(*child, countSoFar, threshold);
+ unsigned count = 0;
+ for (const RenderObject* descendant = &renderer; descendant; descendant = descendant->nextInPreOrder()) {
+ if (is<RenderText>(*descendant)) {
+ count += downcast<RenderText>(*descendant).text()->length();
+ if (count >= threshold)
+ break;
+ }
}
- return countSoFar;
+ return count;
}
bool FrameView::renderedCharactersExceed(unsigned threshold)
{
if (!m_frame->contentRenderer())
return false;
- return countRenderedCharactersInRenderObjectWithThreshold(*m_frame->contentRenderer(), 0, threshold) >= threshold;
+ return countRenderedCharactersInRenderObjectWithThreshold(*m_frame->contentRenderer(), threshold) >= threshold;
}
void FrameView::contentsResized()
Modified: trunk/Source/WebCore/rendering/RenderElement.h (174541 => 174542)
--- trunk/Source/WebCore/rendering/RenderElement.h 2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/RenderElement.h 2014-10-09 23:55:40 UTC (rev 174542)
@@ -55,6 +55,8 @@
RenderObject* firstChild() const { return m_firstChild; }
RenderObject* lastChild() const { return m_lastChild; }
+ virtual bool isEmpty() const override { return !firstChild(); }
+
// FIXME: Make these standalone and move to relevant files.
bool isRenderLayerModelObject() const;
bool isBoxModelObject() const;
Modified: trunk/Source/WebCore/rendering/RenderRuby.cpp (174541 => 174542)
--- trunk/Source/WebCore/rendering/RenderRuby.cpp 2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/RenderRuby.cpp 2014-10-09 23:55:40 UTC (rev 174542)
@@ -46,30 +46,30 @@
{
ASSERT(!object
|| !object->parent()->isRuby()
- || object->isRubyRun()
+ || is<RenderRubyRun>(*object)
|| (object->isInline() && (object->isBeforeContent() || object->isAfterContent()))
- || (object->isAnonymous() && object->isRenderBlock() && object->style().display() == INLINE_BLOCK));
+ || (object->isAnonymous() && is<RenderBlock>(*object) && object->style().display() == INLINE_BLOCK));
return object
&& object->parent()->isRuby()
- && object->isRenderBlock()
- && !object->isRubyRun();
+ && is<RenderBlock>(*object)
+ && !is<RenderRubyRun>(*object);
}
static inline bool isRubyBeforeBlock(const RenderObject* object)
{
return isAnonymousRubyInlineBlock(object)
&& !object->previousSibling()
- && object->firstChildSlow()
- && object->firstChildSlow()->style().styleType() == BEFORE;
+ && downcast<RenderBlock>(*object).firstChild()
+ && downcast<RenderBlock>(*object).firstChild()->style().styleType() == BEFORE;
}
static inline bool isRubyAfterBlock(const RenderObject* object)
{
return isAnonymousRubyInlineBlock(object)
&& !object->nextSibling()
- && object->firstChildSlow()
- && object->firstChildSlow()->style().styleType() == AFTER;
+ && downcast<RenderBlock>(*object).firstChild()
+ && downcast<RenderBlock>(*object).firstChild()->style().styleType() == AFTER;
}
static inline RenderBlock* rubyBeforeBlock(const RenderElement* ruby)
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInline.h (174541 => 174542)
--- trunk/Source/WebCore/rendering/svg/RenderSVGInline.h 2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInline.h 2014-10-09 23:55:40 UTC (rev 174542)
@@ -65,6 +65,8 @@
virtual RenderObject* removeChild(RenderObject&) override final;
};
-}
+} // namespace WebCore
+SPECIALIZE_TYPE_TRAITS_RENDER_OBJECT(RenderSVGInline, isSVGInline())
+
#endif // !RenderSVGTSpan_H
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp (174541 => 174542)
--- trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp 2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp 2014-10-09 23:55:40 UTC (rev 174542)
@@ -361,7 +361,7 @@
ASSERT(m_layoutAttributes.isEmpty());
collectLayoutAttributes(this, m_layoutAttributes);
updateFontInAllDescendants(this);
- m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(this);
+ m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this);
m_needsReordering = true;
m_needsTextMetricsUpdate = false;
@@ -375,7 +375,7 @@
m_needsTextMetricsUpdate = false;
}
- m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(this);
+ m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this);
m_needsReordering = true;
m_needsPositioningValuesUpdate = false;
updateCachedBoundariesInParents = true;
Modified: trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp (174541 => 174542)
--- trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp 2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp 2014-10-09 23:55:40 UTC (rev 174542)
@@ -20,6 +20,7 @@
#include "config.h"
#include "SVGTextLayoutAttributesBuilder.h"
+#include "RenderSVGInline.h"
#include "RenderSVGInlineText.h"
#include "RenderSVGText.h"
#include "SVGTextPositioningElement.h"
@@ -42,21 +43,19 @@
m_textLength = 0;
bool lastCharacterWasSpace = true;
- collectTextPositioningElements(textRoot, lastCharacterWasSpace);
+ collectTextPositioningElements(*textRoot, lastCharacterWasSpace);
if (!m_textLength)
return;
- buildCharacterDataMap(textRoot);
+ buildCharacterDataMap(*textRoot);
}
m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, &text, m_characterDataMap);
}
-bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSVGText* textRoot)
+bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSVGText& textRoot)
{
- ASSERT(textRoot);
-
m_characterDataMap.clear();
if (m_textPositions.isEmpty()) {
@@ -69,7 +68,7 @@
return false;
buildCharacterDataMap(textRoot);
- m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, 0, m_characterDataMap);
+ m_metricsBuilder.buildMetricsAndLayoutAttributes(&textRoot, nullptr, m_characterDataMap);
return true;
}
@@ -96,25 +95,27 @@
}
}
-void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject* start, bool& lastCharacterWasSpace)
+void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderBoxModelObject& start, bool& lastCharacterWasSpace)
{
- ASSERT(!start->isSVGText() || m_textPositions.isEmpty());
+ ASSERT(!is<RenderSVGText>(start) || m_textPositions.isEmpty());
- for (RenderObject* child = start->firstChildSlow(); child; child = child->nextSibling()) {
- if (child->isSVGInlineText()) {
- processRenderSVGInlineText(*toRenderSVGInlineText(child), m_textLength, lastCharacterWasSpace);
+ for (RenderObject* child = start.firstChild(); child; child = child->nextSibling()) {
+ if (is<RenderSVGInlineText>(*child)) {
+ processRenderSVGInlineText(downcast<RenderSVGInlineText>(*child), m_textLength, lastCharacterWasSpace);
continue;
}
- if (!child->isSVGInline())
+ if (!is<RenderSVGInline>(*child))
continue;
- SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(child);
+ RenderSVGInline& inlineChild = downcast<RenderSVGInline>(*child);
+ SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(inlineChild);
+
unsigned atPosition = m_textPositions.size();
if (element)
m_textPositions.append(TextPosition(element, m_textLength));
- collectTextPositioningElements(child, lastCharacterWasSpace);
+ collectTextPositioningElements(inlineChild, lastCharacterWasSpace);
if (!element)
continue;
@@ -126,7 +127,7 @@
}
}
-void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(RenderSVGText* textRoot)
+void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(RenderSVGText& textRoot)
{
SVGTextPositioningElement* outermostTextElement = SVGTextPositioningElement::elementFromRenderer(textRoot);
ASSERT(outermostTextElement);
Modified: trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h (174541 => 174542)
--- trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h 2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.h 2014-10-09 23:55:40 UTC (rev 174542)
@@ -24,6 +24,7 @@
namespace WebCore {
+class RenderBoxModelObject;
class RenderObject;
class RenderSVGInlineText;
class RenderSVGText;
@@ -41,7 +42,7 @@
WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributesBuilder);
public:
SVGTextLayoutAttributesBuilder();
- bool buildLayoutAttributesForForSubtree(RenderSVGText*);
+ bool buildLayoutAttributesForForSubtree(RenderSVGText&);
void buildLayoutAttributesForTextRenderer(RenderSVGInlineText&);
void rebuildMetricsForTextRenderer(RenderSVGInlineText*);
@@ -64,8 +65,8 @@
unsigned length;
};
- void buildCharacterDataMap(RenderSVGText*);
- void collectTextPositioningElements(RenderObject*, bool& lastCharacterWasSpace);
+ void buildCharacterDataMap(RenderSVGText&);
+ void collectTextPositioningElements(RenderBoxModelObject&, bool& lastCharacterWasSpace);
void fillCharacterDataMap(const TextPosition&);
private:
Modified: trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp (174541 => 174542)
--- trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp 2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp 2014-10-09 23:55:40 UTC (rev 174542)
@@ -23,8 +23,10 @@
#include "SVGTextPositioningElement.h"
#include "Attribute.h"
+#include "RenderSVGInline.h"
#include "RenderSVGResource.h"
#include "RenderSVGText.h"
+#include "SVGAltGlyphElement.h"
#include "SVGElementInstance.h"
#include "SVGLengthList.h"
#include "SVGNames.h"
@@ -163,27 +165,24 @@
ASSERT_NOT_REACHED();
}
-SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderObject* renderer)
+SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderBoxModelObject& renderer)
{
- if (!renderer)
- return 0;
+ if (!is<RenderSVGText>(renderer) && !is<RenderSVGInline>(renderer))
+ return nullptr;
- if (!renderer->isSVGText() && !renderer->isSVGInline())
- return 0;
+ ASSERT(renderer.element());
+ SVGElement& element = downcast<SVGElement>(*renderer.element());
- Node* node = renderer->node();
- ASSERT(node);
- ASSERT(node->isSVGElement());
-
- if (!node->hasTagName(SVGNames::textTag)
- && !node->hasTagName(SVGNames::tspanTag)
+ if (!is<SVGTextElement>(element)
+ && !is<SVGTSpanElement>(element)
#if ENABLE(SVG_FONTS)
- && !node->hasTagName(SVGNames::altGlyphTag)
+ && !is<SVGAltGlyphElement>(element)
#endif
- && !node->hasTagName(SVGNames::trefTag))
- return 0;
+ && !is<SVGTRefElement>(element))
+ return nullptr;
- return static_cast<SVGTextPositioningElement*>(node);
+ // FIXME: This should use downcast<>().
+ return &static_cast<SVGTextPositioningElement&>(element);
}
}
Modified: trunk/Source/WebCore/svg/SVGTextPositioningElement.h (174541 => 174542)
--- trunk/Source/WebCore/svg/SVGTextPositioningElement.h 2014-10-09 23:50:21 UTC (rev 174541)
+++ trunk/Source/WebCore/svg/SVGTextPositioningElement.h 2014-10-09 23:55:40 UTC (rev 174542)
@@ -29,7 +29,7 @@
class SVGTextPositioningElement : public SVGTextContentElement {
public:
- static SVGTextPositioningElement* elementFromRenderer(RenderObject*);
+ static SVGTextPositioningElement* elementFromRenderer(RenderBoxModelObject&);
protected:
SVGTextPositioningElement(const QualifiedName&, Document&);