summaryrefslogtreecommitdiff
path: root/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp
diff options
context:
space:
mode:
authorLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
committerLorry Tar Creator <lorry-tar-importer@lorry>2016-04-10 09:28:39 +0000
commit32761a6cee1d0dee366b885b7b9c777e67885688 (patch)
treed6bec92bebfb216f4126356e55518842c2f476a1 /Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp
parenta4e969f4965059196ca948db781e52f7cfebf19e (diff)
downloadWebKitGtk-tarball-32761a6cee1d0dee366b885b7b9c777e67885688.tar.gz
webkitgtk-2.4.11webkitgtk-2.4.11
Diffstat (limited to 'Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp')
-rw-r--r--Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp64
1 files changed, 35 insertions, 29 deletions
diff --git a/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp b/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp
index 16e27cc1f..1dbb01fd9 100644
--- a/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp
+++ b/Source/WebCore/rendering/svg/SVGTextLayoutAttributesBuilder.cpp
@@ -18,9 +18,10 @@
*/
#include "config.h"
+
+#if ENABLE(SVG)
#include "SVGTextLayoutAttributesBuilder.h"
-#include "RenderSVGInline.h"
#include "RenderSVGInlineText.h"
#include "RenderSVGText.h"
#include "SVGTextPositioningElement.h"
@@ -34,7 +35,7 @@ SVGTextLayoutAttributesBuilder::SVGTextLayoutAttributesBuilder()
void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer(RenderSVGInlineText& text)
{
- auto* textRoot = RenderSVGText::locateRenderSVGTextAncestor(text);
+ RenderSVGText* textRoot = RenderSVGText::locateRenderSVGTextAncestor(&text);
if (!textRoot)
return;
@@ -42,79 +43,82 @@ void SVGTextLayoutAttributesBuilder::buildLayoutAttributesForTextRenderer(Render
m_characterDataMap.clear();
m_textLength = 0;
- bool lastCharacterWasSpace = true;
- collectTextPositioningElements(*textRoot, lastCharacterWasSpace);
+ const UChar* lastCharacter = 0;
+ collectTextPositioningElements(textRoot, lastCharacter);
if (!m_textLength)
return;
- buildCharacterDataMap(*textRoot);
+ buildCharacterDataMap(textRoot);
}
- m_metricsBuilder.buildMetricsAndLayoutAttributes(*textRoot, &text, m_characterDataMap);
+ 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()) {
m_textLength = 0;
- bool lastCharacterWasSpace = true;
- collectTextPositioningElements(textRoot, lastCharacterWasSpace);
+ const UChar* lastCharacter = 0;
+ collectTextPositioningElements(textRoot, lastCharacter);
}
if (!m_textLength)
return false;
buildCharacterDataMap(textRoot);
- m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, nullptr, m_characterDataMap);
+ m_metricsBuilder.buildMetricsAndLayoutAttributes(textRoot, 0, m_characterDataMap);
return true;
}
-void SVGTextLayoutAttributesBuilder::rebuildMetricsForTextRenderer(RenderSVGInlineText& text)
+void SVGTextLayoutAttributesBuilder::rebuildMetricsForTextRenderer(RenderSVGInlineText* text)
{
+ ASSERT(text);
m_metricsBuilder.measureTextRenderer(text);
}
-static inline void processRenderSVGInlineText(const RenderSVGInlineText& text, unsigned& atCharacter, bool& lastCharacterWasSpace)
+static inline void processRenderSVGInlineText(RenderSVGInlineText* text, unsigned& atCharacter, const UChar*& lastCharacter)
{
- if (text.style().whiteSpace() == PRE) {
- atCharacter += text.textLength();
+ if (text->style().whiteSpace() == PRE) {
+ atCharacter += text->textLength();
return;
}
- for (unsigned textPosition = 0, textLength = text.textLength(); textPosition < textLength; ++textPosition) {
- const UChar currentCharacter = text[textPosition];
- if (currentCharacter == ' ' && lastCharacterWasSpace)
+ const UChar* characters = text->deprecatedCharacters();
+ unsigned textLength = text->textLength();
+ for (unsigned textPosition = 0; textPosition < textLength; ++textPosition) {
+ const UChar* currentCharacter = characters + textPosition;
+ if (*currentCharacter == ' ' && (!lastCharacter || *lastCharacter == ' '))
continue;
- lastCharacterWasSpace = currentCharacter == ' ';
+ lastCharacter = currentCharacter;
++atCharacter;
}
}
-void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderBoxModelObject& start, bool& lastCharacterWasSpace)
+void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderObject* start, const UChar*& lastCharacter)
{
- ASSERT(!is<RenderSVGText>(start) || m_textPositions.isEmpty());
+ ASSERT(!start->isSVGText() || m_textPositions.isEmpty());
- for (RenderObject* child = start.firstChild(); child; child = child->nextSibling()) {
- if (is<RenderSVGInlineText>(*child)) {
- processRenderSVGInlineText(downcast<RenderSVGInlineText>(*child), m_textLength, lastCharacterWasSpace);
+ for (RenderObject* child = start->firstChildSlow(); child; child = child->nextSibling()) {
+ if (child->isSVGInlineText()) {
+ processRenderSVGInlineText(toRenderSVGInlineText(child), m_textLength, lastCharacter);
continue;
}
- if (!is<RenderSVGInline>(*child))
+ if (!child->isSVGInline())
continue;
- RenderSVGInline& inlineChild = downcast<RenderSVGInline>(*child);
- SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(inlineChild);
-
+ SVGTextPositioningElement* element = SVGTextPositioningElement::elementFromRenderer(child);
unsigned atPosition = m_textPositions.size();
if (element)
m_textPositions.append(TextPosition(element, m_textLength));
- collectTextPositioningElements(inlineChild, lastCharacterWasSpace);
+ collectTextPositioningElements(child, lastCharacter);
if (!element)
continue;
@@ -126,7 +130,7 @@ void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(RenderBoxMod
}
}
-void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(RenderSVGText& textRoot)
+void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(RenderSVGText* textRoot)
{
SVGTextPositioningElement* outermostTextElement = SVGTextPositioningElement::elementFromRenderer(textRoot);
ASSERT(outermostTextElement);
@@ -228,3 +232,5 @@ void SVGTextLayoutAttributesBuilder::fillCharacterDataMap(const TextPosition& po
}
}
+
+#endif // ENABLE(SVG)