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()
ASSERT(m_layoutAttributes.isEmpty());
collectLayoutAttributes(this, m_layoutAttributes);
updateFontInAllDescendants(this);
m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(this);
m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this);
m_needsReordering = true;
m_needsTextMetricsUpdate = false;
......@@ -351,7 +351,7 @@ void RenderSVGText::layout()
m_needsTextMetricsUpdate = false;
}
m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(this);
m_layoutAttributesBuilder.buildLayoutAttributesForForSubtree(*this);
m_needsReordering = true;
m_needsPositioningValuesUpdate = false;
updateCachedBoundariesInParents = true;
......
......@@ -21,6 +21,7 @@
#include "core/rendering/svg/SVGTextLayoutAttributesBuilder.h"
#include "core/rendering/svg/RenderSVGInline.h"
#include "core/rendering/svg/RenderSVGInlineText.h"
#include "core/rendering/svg/RenderSVGText.h"
#include "core/rendering/svg/SVGTextMetricsBuilder.h"
......@@ -46,21 +47,19 @@ void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer(Render
m_textLength = 0;
UChar lastCharacter = ' ';
collectTextPositioningElements(textRoot, lastCharacter);
collectTextPositioningElements(*textRoot, lastCharacter);
if (!m_textLength)
return;
buildCharacterDataMap(textRoot);
buildCharacterDataMap(*textRoot);
}
SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(textRoot, text, m_characterDataMap);
}
bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSVGText* textRoot)
bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSVGText& textRoot)
{
ASSERT(textRoot);
m_characterDataMap.clear();
if (m_textPositions.isEmpty()) {
......@@ -73,7 +72,7 @@ bool SVGTextLayoutAttributesBuilder::buildLayoutAttributesForForSubtree(RenderSV
return false;
buildCharacterDataMap(textRoot);
SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(textRoot, 0, m_characterDataMap);
SVGTextMetricsBuilder::buildMetricsAndLayoutAttributes(&textRoot, nullptr, m_characterDataMap);
return true;
}
......@@ -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()) {
processRenderSVGInlineText(toRenderSVGInlineText(child), m_textLength, lastCharacter);
continue;
......@@ -114,12 +113,13 @@ void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject
if (!child->isSVGInline())
continue;
SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(child);
RenderSVGInline& inlineChild = toRenderSVGInline(*child);
SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(inlineChild);
unsigned atPosition = m_textPositions.size();
if (element)
m_textPositions.append(TextPosition(element, m_textLength));
collectTextPositioningElements(child, lastCharacter);
collectTextPositioningElements(inlineChild, lastCharacter);
if (!element)
continue;
......@@ -131,7 +131,7 @@ void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject
}
}
void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(RenderSVGText* textRoot)
void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(RenderSVGText& textRoot)
{
SVGTextPositioningElement* outermostTextElement = SVGTextPositioningElement::elementFromRenderer(textRoot);
ASSERT(outermostTextElement);
......
......@@ -25,7 +25,7 @@
namespace blink {
class RenderObject;
class RenderBoxModelObject;
class RenderSVGInlineText;
class RenderSVGText;
class SVGTextPositioningElement;
......@@ -42,7 +42,7 @@ class SVGTextLayoutAttributesBuilder {
WTF_MAKE_NONCOPYABLE(SVGTextLayoutAttributesBuilder);
public:
SVGTextLayoutAttributesBuilder();
bool buildLayoutAttributesForForSubtree(RenderSVGText*);
bool buildLayoutAttributesForForSubtree(RenderSVGText&);
void buildLayoutAttributesForTextRenderer(RenderSVGInlineText*);
void rebuildMetricsForTextRenderer(RenderSVGInlineText*);
......@@ -65,8 +65,8 @@ private:
unsigned length;
};
void buildCharacterDataMap(RenderSVGText*);
void collectTextPositioningElements(RenderObject*, UChar& lastCharacter);
void buildCharacterDataMap(RenderSVGText&);
void collectTextPositioningElements(RenderBoxModelObject&, UChar& lastCharacter);
void fillCharacterDataMap(const TextPosition&);
private:
......
......@@ -90,15 +90,12 @@ void SVGTextPositioningElement::svgAttributeChanged(const QualifiedName& attrNam
markForLayoutAndParentResourceInvalidation(renderer);
}
SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderObject* renderer)
SVGTextPositioningElement* SVGTextPositioningElement::elementFromRenderer(RenderObject& renderer)
{
if (!renderer)
return 0;
if (!renderer->isSVGText() && !renderer->isSVGInline())
if (!renderer.isSVGText() && !renderer.isSVGInline())
return 0;
Node* node = renderer->node();
Node* node = renderer.node();
ASSERT(node);
ASSERT(node->isSVGElement());
......
......@@ -31,7 +31,7 @@ namespace blink {
class SVGTextPositioningElement : public SVGTextContentElement {
DEFINE_WRAPPERTYPEINFO();
public:
static SVGTextPositioningElement* elementFromRenderer(RenderObject*);
static SVGTextPositioningElement* elementFromRenderer(RenderObject&);
SVGAnimatedLengthList* x() { return m_x.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