Commit fe430f53 authored by rob.buis@samsung.com's avatar rob.buis@samsung.com

Make SVGTextPositioningElement::elementFromRenderer take a reference

This avoids doing a null check in this method, adjust
all call sites.

Review URL: https://codereview.chromium.org/715023002

git-svn-id: svn://svn.chromium.org/blink/trunk@185160 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent fae0111e
...@@ -337,7 +337,7 @@ void RenderSVGText::layout() ...@@ -337,7 +337,7 @@ void RenderSVGText::layout()
ASSERT(m_layoutAttributes.isEmpty()); ASSERT(m_layoutAttributes.isEmpty());
collectLayoutAttributes(this, m_layoutAttributes); collectLayoutAttributes(this, m_layoutAttributes);
updateFontInAllDescendants(this); updateFontInAllDescendants(this);
m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(this); m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this);
m_needsReordering = true; m_needsReordering = true;
m_needsTextMetricsUpdate = false; m_needsTextMetricsUpdate = false;
...@@ -351,7 +351,7 @@ void RenderSVGText::layout() ...@@ -351,7 +351,7 @@ void RenderSVGText::layout()
m_needsTextMetricsUpdate = false; m_needsTextMetricsUpdate = false;
} }
m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(this); m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this);
m_needsReordering = true; m_needsReordering = true;
m_needsPositioningValuesUpdate = false; m_needsPositioningValuesUpdate = false;
updateCachedBoundariesInParents = true; updateCachedBoundariesInParents = true;
......
...@@ -21,6 +21,7 @@ ...@@ -21,6 +21,7 @@
#include "core/rendering/svg/SVGTextLayoutAttributesBuilder.h" #include "core/rendering/svg/SVGTextLayoutAttributesBuilder.h"
#include "core/rendering/svg/RenderSVGInline.h"
#include "core/rendering/svg/RenderSVGInlineText.h" #include "core/rendering/svg/RenderSVGInlineText.h"
#include "core/rendering/svg/RenderSVGText.h" #include "core/rendering/svg/RenderSVGText.h"
#include "core/rendering/svg/SVGTextMetricsBuilder.h" #include "core/rendering/svg/SVGTextMetricsBuilder.h"
...@@ -46,21 +47,19 @@ void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer(Render ...@@ -46,21 +47,19 @@ void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer(Render
m_textLength = 0; m_textLength = 0;
UChar lastCharacter = ' '; UChar lastCharacter = ' ';
collectTextPositioningElements(textRoot, lastCharacter); collectTextPositioningElements(*textRoot, lastCharacter);
if (!m_textLength) if (!m_textLength)
return; return;
buildCharacterDataMap(textRoot); buildCharacterDataMap(*textRoot);
} }
SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(textRoot, text, m_characterDataMap); SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(textRoot, text, m_characterDataMap);
} }
bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSVGText* textRoot) bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSVGText& textRoot)
{ {
ASSERT(textRoot);
m_characterDataMap.clear(); m_characterDataMap.clear();
if (m_textPositions.isEmpty()) { if (m_textPositions.isEmpty()) {
...@@ -73,7 +72,7 @@ bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSV ...@@ -73,7 +72,7 @@ bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSV
return false; return false;
buildCharacterDataMap(textRoot); buildCharacterDataMap(textRoot);
SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(textRoot, 0, m_characterDataMap); SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(&textRoot, nullptr, m_characterDataMap);
return true; return true;
} }
...@@ -101,11 +100,11 @@ static inline void processRenderSVGInlineText(RenderSVGInlineText* text, unsigne ...@@ -101,11 +100,11 @@ static inline void processRenderSVGInlineText(RenderSVGInlineText* text, unsigne
} }
} }
void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject* start, UChar& lastCharacter) void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderBoxModelObject& start, UChar& lastCharacter)
{ {
ASSERT(!start->isSVGText() || m_textPositions.isEmpty()); ASSERT(!start.isSVGText() || m_textPositions.isEmpty());
for (RenderObject* child = start->slowFirstChild(); child; child = child->nextSibling()) { for (RenderObject* child = start.slowFirstChild(); child; child = child->nextSibling()) {
if (child->isSVGInlineText()) { if (child->isSVGInlineText()) {
processRenderSVGInlineText(toRenderSVGInlineText(child), m_textLength, lastCharacter); processRenderSVGInlineText(toRenderSVGInlineText(child), m_textLength, lastCharacter);
continue; continue;
...@@ -114,12 +113,13 @@ void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject ...@@ -114,12 +113,13 @@ void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject
if (!child->isSVGInline()) if (!child->isSVGInline())
continue; continue;
SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(child); RenderSVGInline& inlineChild = toRenderSVGInline(*child);
SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(inlineChild);
unsigned atPosition = m_textPositions.size(); unsigned atPosition = m_textPositions.size();
if (element) if (element)
m_textPositions.append(TextPosition(element, m_textLength)); m_textPositions.append(TextPosition(element, m_textLength));
collectTextPositioningElements(child, lastCharacter); collectTextPositioningElements(inlineChild, lastCharacter);
if (!element) if (!element)
continue; continue;
...@@ -131,7 +131,7 @@ void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject ...@@ -131,7 +131,7 @@ void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject
} }
} }
void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(RenderSVGText* textRoot) void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(RenderSVGText& textRoot)
{ {
SVGTextPositioningElement* outermostTextElement = SVGTextPositioningElement::elementFromRenderer(textRoot); SVGTextPositioningElement* outermostTextElement = SVGTextPositioningElement::elementFromRenderer(textRoot);
ASSERT(outermostTextElement); ASSERT(outermostTextElement);
......
...@@ -25,7 +25,7 @@ ...@@ -25,7 +25,7 @@
namespace blink { namespace blink {
class RenderObject; class RenderBoxModelObject;
class RenderSVGInlineText; class RenderSVGInlineText;
class RenderSVGText; class RenderSVGText;
class SVGTextPositioningElement; class SVGTextPositioningElement;
...@@ -42,7 +42,7 @@ class SVGTextLayoutAttributesBuilder { ...@@ -42,7 +42,7 @@ class SVGTextLayoutAttributesBuilder {
WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributesBuilder); WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributesBuilder);
public: public:
SVGTextLayoutAttributesBuilder(); SVGTextLayoutAttributesBuilder();
bool buildLayoutAttributesForForSubtree(RenderSVGText*); bool buildLayoutAttributesForForSubtree(RenderSVGText&);
void buildLayoutAttributesForTextRenderer(RenderSVGInlineText*); void buildLayoutAttributesForTextRenderer(RenderSVGInlineText*);
void rebuildMetricsForTextRenderer(RenderSVGInlineText*); void rebuildMetricsForTextRenderer(RenderSVGInlineText*);
...@@ -65,8 +65,8 @@ private: ...@@ -65,8 +65,8 @@ private:
unsigned length; unsigned length;
}; };
void buildCharacterDataMap(RenderSVGText*); void buildCharacterDataMap(RenderSVGText&);
void collectTextPositioningElements(RenderObject*, UChar& lastCharacter); void collectTextPositioningElements(RenderBoxModelObject&, UChar& lastCharacter);
void fillCharacterDataMap(const TextPosition&); void fillCharacterDataMap(const TextPosition&);
private: private:
......
...@@ -90,15 +90,12 @@ void SVGTextPositioningElement::svgAttributeChanged(const QualifiedName& attrNam ...@@ -90,15 +90,12 @@ void SVGTextPositioningElement::svgAttributeChanged(const QualifiedName& attrNam
markForLayoutAndParentResourceInvalidation(renderer); markForLayoutAndParentResourceInvalidation(renderer);
} }
SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderObject* renderer) SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderObject& renderer)
{ {
if (!renderer) if (!renderer.isSVGText() && !renderer.isSVGInline())
return 0;
if (!renderer->isSVGText() && !renderer->isSVGInline())
return 0; return 0;
Node* node = renderer->node(); Node* node = renderer.node();
ASSERT(node); ASSERT(node);
ASSERT(node->isSVGElement()); ASSERT(node->isSVGElement());
......
...@@ -31,7 +31,7 @@ namespace blink { ...@@ -31,7 +31,7 @@ namespace blink {
class SVGTextPositioningElement : public SVGTextContentElement { class SVGTextPositioningElement : public SVGTextContentElement {
DEFINE_WRAPPERTYPEINFO(); DEFINE_WRAPPERTYPEINFO();
public: public:
static SVGTextPositioningElement* elementFromRenderer(RenderObject*); static SVGTextPositioningElement* elementFromRenderer(RenderObject&);
SVGAnimatedLengthList* x() { return m_x.get(); } SVGAnimatedLengthList* x() { return m_x.get(); }
SVGAnimatedLengthList* y() { return m_y.get(); } SVGAnimatedLengthList* y() { return m_y.get(); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment