Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[CTTE] RenderSVGText always has a SVGTextElement.
<https://webkit.org/b/121299>

Reviewed by Antti Koivisto.

This renderer is never anonymous, and always has a corresponding <svg> element.
Tighten this up and remove some pointless assertions.


Canonical link: https://commits.webkit.org/139255@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@155698 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Andreas Kling committed Sep 13, 2013
1 parent 0ad947e commit cb71311
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 9 deletions.
10 changes: 10 additions & 0 deletions Source/WebCore/ChangeLog
@@ -1,3 +1,13 @@
2013-09-13 Andreas Kling <akling@apple.com>

[CTTE] RenderSVGText always has a SVGTextElement.
<https://webkit.org/b/121299>

Reviewed by Antti Koivisto.

This renderer is never anonymous, and always has a corresponding <svg> element.
Tighten this up and remove some pointless assertions.

2013-09-13 Allan Sandfeld Jensen <allan.jensen@digia.com>

Remove support for QXmlStream as the XML parser.
Expand Down
16 changes: 9 additions & 7 deletions Source/WebCore/rendering/svg/RenderSVGText.cpp
Expand Up @@ -56,8 +56,8 @@

namespace WebCore {

RenderSVGText::RenderSVGText(SVGTextElement* node)
: RenderSVGBlock(node)
RenderSVGText::RenderSVGText(SVGTextElement& element)
: RenderSVGBlock(&element)
, m_needsReordering(false)
, m_needsPositioningValuesUpdate(false)
, m_needsTransformUpdate(true)
Expand All @@ -70,6 +70,11 @@ RenderSVGText::~RenderSVGText()
ASSERT(m_layoutAttributes.isEmpty());
}

SVGTextElement& RenderSVGText::textElement() const
{
return toSVGTextElement(*RenderSVGBlock::element());
}

bool RenderSVGText::isChildAllowed(RenderObject* child, RenderStyle*) const
{
return child->isInline();
Expand Down Expand Up @@ -354,8 +359,7 @@ void RenderSVGText::layout()

bool updateCachedBoundariesInParents = false;
if (m_needsTransformUpdate) {
SVGTextElement* text = toSVGTextElement(element());
m_localTransform = text->animatedLocalTransform();
m_localTransform = textElement().animatedLocalTransform();
m_needsTransformUpdate = false;
updateCachedBoundariesInParents = true;
}
Expand Down Expand Up @@ -515,9 +519,7 @@ FloatRect RenderSVGText::strokeBoundingBox() const
if (!svgStyle->hasStroke())
return strokeBoundaries;

ASSERT(element());
ASSERT(element()->isSVGElement());
SVGLengthContext lengthContext(toSVGElement(element()));
SVGLengthContext lengthContext(&textElement());
strokeBoundaries.inflate(svgStyle->strokeWidth().value(lengthContext));
return strokeBoundaries;
}
Expand Down
6 changes: 5 additions & 1 deletion Source/WebCore/rendering/svg/RenderSVGText.h
Expand Up @@ -35,9 +35,11 @@ class RenderSVGInlineText;

class RenderSVGText FINAL : public RenderSVGBlock {
public:
RenderSVGText(SVGTextElement*);
explicit RenderSVGText(SVGTextElement&);
virtual ~RenderSVGText();

SVGTextElement& textElement() const;

virtual bool isChildAllowed(RenderObject*, RenderStyle*) const;

void setNeedsPositioningValuesUpdate() { m_needsPositioningValuesUpdate = true; }
Expand All @@ -58,6 +60,8 @@ class RenderSVGText FINAL : public RenderSVGBlock {
void subtreeTextDidChange(RenderSVGInlineText*);

private:
void element() const WTF_DELETED_FUNCTION;

virtual const char* renderName() const { return "RenderSVGText"; }
virtual bool isSVGText() const { return true; }

Expand Down
2 changes: 1 addition & 1 deletion Source/WebCore/svg/SVGTextElement.cpp
Expand Up @@ -70,7 +70,7 @@ AffineTransform SVGTextElement::animatedLocalTransform() const

RenderObject* SVGTextElement::createRenderer(RenderArena* arena, RenderStyle*)
{
return new (arena) RenderSVGText(this);
return new (arena) RenderSVGText(*this);
}

bool SVGTextElement::childShouldCreateRenderer(const Node* child) const
Expand Down

0 comments on commit cb71311

Please sign in to comment.