Diff
Modified: trunk/Source/WebCore/ChangeLog (163284 => 163285)
--- trunk/Source/WebCore/ChangeLog 2014-02-03 04:54:26 UTC (rev 163284)
+++ trunk/Source/WebCore/ChangeLog 2014-02-03 05:04:57 UTC (rev 163285)
@@ -1,5 +1,42 @@
2014-02-02 Andreas Kling <[email protected]>
+ Modernize RenderSVGText::locateRenderSVGTextAncestor().
+ <https://webkit.org/b/128093>
+
+ Make locateRenderSVGTextAncestor() take a reference, and simplify it
+ internally with lineageOfType.
+
+ Switched callers to use 'auto' for the return type so we get some
+ devirtualization freebies.
+
+ Reviewed by Anders Carlsson.
+
+ * rendering/svg/RenderSVGInline.cpp:
+ (WebCore::RenderSVGInline::objectBoundingBox):
+ (WebCore::RenderSVGInline::strokeBoundingBox):
+ (WebCore::RenderSVGInline::repaintRectInLocalCoordinates):
+ (WebCore::RenderSVGInline::absoluteQuads):
+ (WebCore::RenderSVGInline::addChild):
+ (WebCore::RenderSVGInline::removeChild):
+ * rendering/svg/RenderSVGInlineText.cpp:
+ (WebCore::RenderSVGInlineText::setTextInternal):
+ (WebCore::RenderSVGInlineText::styleDidChange):
+ * rendering/svg/RenderSVGResourceGradient.cpp:
+ (WebCore::createMaskAndSwapContextForTextGradient):
+ (WebCore::clipToTextMask):
+ * rendering/svg/RenderSVGText.cpp:
+ (WebCore::RenderSVGText::locateRenderSVGTextAncestor):
+ * rendering/svg/RenderSVGText.h:
+ (WebCore::RenderSVGText>):
+ * rendering/svg/SVGTextLayoutAttributesBuilder.cpp:
+ (WebCore::SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer):
+ * rendering/svg/SVGTextMetricsBuilder.cpp:
+ (WebCore::SVGTextMetricsBuilder::measureTextRenderer):
+ * svg/SVGTextPositioningElement.cpp:
+ (WebCore::SVGTextPositioningElement::svgAttributeChanged):
+
+2014-02-02 Andreas Kling <[email protected]>
+
Modernize the toRenderSVGResourceContainer() helper.
<https://webkit.org/b/128091>
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp (163284 => 163285)
--- trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp 2014-02-03 04:54:26 UTC (rev 163284)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInline.cpp 2014-02-03 05:04:57 UTC (rev 163285)
@@ -47,24 +47,24 @@
FloatRect RenderSVGInline::objectBoundingBox() const
{
- if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))
- return object->objectBoundingBox();
+ if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this))
+ return textAncestor->objectBoundingBox();
return FloatRect();
}
FloatRect RenderSVGInline::strokeBoundingBox() const
{
- if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))
- return object->strokeBoundingBox();
+ if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this))
+ return textAncestor->strokeBoundingBox();
return FloatRect();
}
FloatRect RenderSVGInline::repaintRectInLocalCoordinates() const
{
- if (const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this))
- return object->repaintRectInLocalCoordinates();
+ if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this))
+ return textAncestor->repaintRectInLocalCoordinates();
return FloatRect();
}
@@ -91,11 +91,11 @@
void RenderSVGInline::absoluteQuads(Vector<FloatQuad>& quads, bool* wasFixed) const
{
- const RenderObject* object = RenderSVGText::locateRenderSVGTextAncestor(this);
- if (!object)
+ auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this);
+ if (!textAncestor)
return;
- FloatRect textBoundingBox = object->strokeBoundingBox();
+ FloatRect textBoundingBox = textAncestor->strokeBoundingBox();
for (InlineFlowBox* box = firstLineBox(); box; box = box->nextLineBox())
quads.append(localToAbsoluteQuad(FloatRect(textBoundingBox.x() + box->x(), textBoundingBox.y() + box->y(), box->logicalWidth(), box->logicalHeight()), false, wasFixed));
}
@@ -119,23 +119,23 @@
RenderInline::addChild(child, beforeChild);
SVGResourcesCache::clientWasAddedToTree(*child);
- if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this))
- textRenderer->subtreeChildWasAdded(child);
+ if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this))
+ textAncestor->subtreeChildWasAdded(child);
}
void RenderSVGInline::removeChild(RenderObject& child)
{
SVGResourcesCache::clientWillBeRemovedFromTree(child);
- RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this);
- if (!textRenderer) {
+ auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this);
+ if (!textAncestor) {
RenderInline::removeChild(child);
return;
}
Vector<SVGTextLayoutAttributes*, 2> affectedAttributes;
- textRenderer->subtreeChildWillBeRemoved(&child, affectedAttributes);
+ textAncestor->subtreeChildWillBeRemoved(&child, affectedAttributes);
RenderInline::removeChild(child);
- textRenderer->subtreeChildWasRemoved(affectedAttributes);
+ textAncestor->subtreeChildWasRemoved(affectedAttributes);
}
}
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp (163284 => 163285)
--- trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp 2014-02-03 04:54:26 UTC (rev 163284)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGInlineText.cpp 2014-02-03 05:04:57 UTC (rev 163285)
@@ -82,8 +82,8 @@
void RenderSVGInlineText::setTextInternal(const String& text)
{
RenderText::setTextInternal(text);
- if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this))
- textRenderer->subtreeTextDidChange(this);
+ if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this))
+ textAncestor->subtreeTextDidChange(this);
}
void RenderSVGInlineText::styleDidChange(StyleDifference diff, const RenderStyle* oldStyle)
@@ -107,8 +107,8 @@
return;
// The text metrics may be influenced by style changes.
- if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(this))
- textRenderer->subtreeStyleDidChange(this);
+ if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*this))
+ textAncestor->subtreeStyleDidChange(this);
}
std::unique_ptr<InlineTextBox> RenderSVGInlineText::createTextBox()
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp (163284 => 163285)
--- trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp 2014-02-03 04:54:26 UTC (rev 163284)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGResourceGradient.cpp 2014-02-03 05:04:57 UTC (rev 163285)
@@ -57,7 +57,7 @@
#if USE(CG)
static inline bool createMaskAndSwapContextForTextGradient(GraphicsContext*& context, GraphicsContext*& savedContext, std::unique_ptr<ImageBuffer>& imageBuffer, RenderObject* object)
{
- RenderObject* textRootBlock = RenderSVGText::locateRenderSVGTextAncestor(object);
+ auto* textRootBlock = RenderSVGText::locateRenderSVGTextAncestor(*object);
ASSERT(textRootBlock);
AffineTransform absoluteTransform;
@@ -79,7 +79,7 @@
static inline AffineTransform clipToTextMask(GraphicsContext* context, std::unique_ptr<ImageBuffer>& imageBuffer, FloatRect& targetRect, RenderObject* object, bool boundingBoxMode, const AffineTransform& gradientTransform)
{
- RenderObject* textRootBlock = RenderSVGText::locateRenderSVGTextAncestor(object);
+ auto* textRootBlock = RenderSVGText::locateRenderSVGTextAncestor(*object);
ASSERT(textRootBlock);
AffineTransform absoluteTransform;
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp (163284 => 163285)
--- trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp 2014-02-03 04:54:26 UTC (rev 163284)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.cpp 2014-02-03 05:04:57 UTC (rev 163285)
@@ -36,6 +36,7 @@
#include "HitTestResult.h"
#include "LayoutRepainter.h"
#include "PointerEventsHitRules.h"
+#include "RenderIterator.h"
#include "RenderSVGInlineText.h"
#include "RenderSVGResource.h"
#include "RenderSVGRoot.h"
@@ -77,24 +78,14 @@
return child.isInline();
}
-RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(RenderObject* start)
+RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(RenderObject& start)
{
- ASSERT(start);
- while (start && !start->isSVGText())
- start = start->parent();
- if (!start || !start->isSVGText())
- return 0;
- return toRenderSVGText(start);
+ return lineageOfType<RenderSVGText>(start).first();
}
-const RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(const RenderObject* start)
+const RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(const RenderObject& start)
{
- ASSERT(start);
- while (start && !start->isSVGText())
- start = start->parent();
- if (!start || !start->isSVGText())
- return 0;
- return toRenderSVGText(start);
+ return lineageOfType<RenderSVGText>(start).first();
}
LayoutRect RenderSVGText::clippedOverflowRectForRepaint(const RenderLayerModelObject* repaintContainer) const
Modified: trunk/Source/WebCore/rendering/svg/RenderSVGText.h (163284 => 163285)
--- trunk/Source/WebCore/rendering/svg/RenderSVGText.h 2014-02-03 04:54:26 UTC (rev 163284)
+++ trunk/Source/WebCore/rendering/svg/RenderSVGText.h 2014-02-03 05:04:57 UTC (rev 163285)
@@ -47,8 +47,8 @@
void setNeedsTextMetricsUpdate() { m_needsTextMetricsUpdate = true; }
virtual FloatRect repaintRectInLocalCoordinates() const;
- static RenderSVGText* locateRenderSVGTextAncestor(RenderObject*);
- static const RenderSVGText* locateRenderSVGTextAncestor(const RenderObject*);
+ static RenderSVGText* locateRenderSVGTextAncestor(RenderObject&);
+ static const RenderSVGText* locateRenderSVGTextAncestor(const RenderObject&);
bool needsReordering() const { return m_needsReordering; }
Vector<SVGTextLayoutAttributes*>& layoutAttributes() { return m_layoutAttributes; }
@@ -59,6 +59,9 @@
void subtreeStyleDidChange(RenderSVGInlineText*);
void subtreeTextDidChange(RenderSVGInlineText*);
+ virtual FloatRect objectBoundingBox() const override { return frameRect(); }
+ virtual FloatRect strokeBoundingBox() const override;
+
private:
void graphicsElement() const = delete;
@@ -85,9 +88,6 @@
virtual void removeChild(RenderObject&) override;
virtual void willBeDestroyed() override;
- virtual FloatRect objectBoundingBox() const { return frameRect(); }
- virtual FloatRect strokeBoundingBox() const;
-
virtual const AffineTransform& localToParentTransform() const { return m_localTransform; }
virtual AffineTransform localTransform() const { return m_localTransform; }
virtual std::unique_ptr<RootInlineBox> createRootInlineBox() override;
@@ -106,6 +106,7 @@
Vector<SVGTextLayoutAttributes*> m_layoutAttributes;
};
+template<> inline bool isRendererOfType<const RenderSVGText>(const RenderObject& renderer) { return renderer.isSVGText(); }
RENDER_OBJECT_TYPE_CASTS(RenderSVGText, isSVGText())
}
Modified: trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp (163284 => 163285)
--- trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp 2014-02-03 04:54:26 UTC (rev 163284)
+++ trunk/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp 2014-02-03 05:04:57 UTC (rev 163285)
@@ -35,7 +35,7 @@
void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer(RenderSVGInlineText& text)
{
- RenderSVGText* textRoot = RenderSVGText::locateRenderSVGTextAncestor(&text);
+ auto* textRoot = RenderSVGText::locateRenderSVGTextAncestor(text);
if (!textRoot)
return;
Modified: trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp (163284 => 163285)
--- trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp 2014-02-03 04:54:26 UTC (rev 163284)
+++ trunk/Source/WebCore/rendering/svg/SVGTextMetricsBuilder.cpp 2014-02-03 05:04:57 UTC (rev 163285)
@@ -207,7 +207,7 @@
{
ASSERT(text);
- RenderSVGText* textRoot = RenderSVGText::locateRenderSVGTextAncestor(text);
+ auto* textRoot = RenderSVGText::locateRenderSVGTextAncestor(*text);
if (!textRoot)
return;
Modified: trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp (163284 => 163285)
--- trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp 2014-02-03 04:54:26 UTC (rev 163284)
+++ trunk/Source/WebCore/svg/SVGTextPositioningElement.cpp 2014-02-03 05:04:57 UTC (rev 163285)
@@ -140,8 +140,8 @@
return;
if (updateRelativeLengths || attrName == SVGNames::rotateAttr) {
- if (RenderSVGText* textRenderer = RenderSVGText::locateRenderSVGTextAncestor(renderer))
- textRenderer->setNeedsPositioningValuesUpdate();
+ if (auto* textAncestor = RenderSVGText::locateRenderSVGTextAncestor(*renderer))
+ textAncestor->setNeedsPositioningValuesUpdate();
RenderSVGResource::markForLayoutAndParentResourceInvalidation(*renderer);
return;
}