diff options
Diffstat (limited to 'Source/WebCore/rendering/svg/SVGTextMetrics.cpp')
-rw-r--r-- | Source/WebCore/rendering/svg/SVGTextMetrics.cpp | 52 |
1 files changed, 16 insertions, 36 deletions
diff --git a/Source/WebCore/rendering/svg/SVGTextMetrics.cpp b/Source/WebCore/rendering/svg/SVGTextMetrics.cpp index 0e6446e31..7627fe553 100644 --- a/Source/WebCore/rendering/svg/SVGTextMetrics.cpp +++ b/Source/WebCore/rendering/svg/SVGTextMetrics.cpp @@ -18,12 +18,9 @@ */ #include "config.h" - -#if ENABLE(SVG) #include "SVGTextMetrics.h" #include "RenderSVGInlineText.h" -#include "SVGTextRunRenderingContext.h" #include "WidthIterator.h" namespace WebCore { @@ -42,18 +39,18 @@ SVGTextMetrics::SVGTextMetrics(SVGTextMetrics::MetricsType) { } -SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* textRenderer, const TextRun& run) +SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText& textRenderer, const TextRun& run) { - ASSERT(textRenderer); - - float scalingFactor = textRenderer->scalingFactor(); + float scalingFactor = textRenderer.scalingFactor(); ASSERT(scalingFactor); - const Font& scaledFont = textRenderer->scaledFont(); + const FontCascade& scaledFont = textRenderer.scaledFont(); int length = 0; // Calculate width/height using the scaled font, divide this result by the scalingFactor afterwards. - m_width = scaledFont.width(run, length, m_glyph.name) / scalingFactor; + m_width = scaledFont.width(run) / scalingFactor; + length = run.length(); + m_glyph.name = emptyString(); m_height = scaledFont.fontMetrics().floatHeight() / scalingFactor; m_glyph.unicodeString = run.is8Bit() ? String(run.characters8(), length) : String(run.characters16(), length); @@ -63,57 +60,40 @@ SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* textRenderer, const TextRun& m_length = static_cast<unsigned>(length); } -TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText* text, const UChar* characters, unsigned position, unsigned length) +TextRun SVGTextMetrics::constructTextRun(RenderSVGInlineText& text, unsigned position, unsigned length) { - const RenderStyle& style = text->style(); + const RenderStyle& style = text.style(); - TextRun run(characters + position - , length + TextRun run(StringView(text.text()).substring(position, length) , 0 /* xPos, only relevant with allowTabs=true */ , 0 /* padding, only relevant for justified text, not relevant for SVG */ - , TextRun::AllowTrailingExpansion + , AllowTrailingExpansion , style.direction() , isOverride(style.unicodeBidi()) /* directionalOverride */); - if (style.font().isSVGFont()) - run.setRenderingContext(SVGTextRunRenderingContext::create(*text)); - - run.disableRoundingHacks(); - // We handle letter & word spacing ourselves. run.disableSpacing(); // Propagate the maximum length of the characters buffer to the TextRun, even when we're only processing a substring. - run.setCharactersLength(text->textLength() - position); + run.setCharactersLength(text.textLength() - position); ASSERT(run.charactersLength() >= run.length()); return run; } -SVGTextMetrics SVGTextMetrics::measureCharacterRange(RenderSVGInlineText* text, unsigned position, unsigned length) +SVGTextMetrics SVGTextMetrics::measureCharacterRange(RenderSVGInlineText& text, unsigned position, unsigned length) { - ASSERT(text); - return SVGTextMetrics(text, constructTextRun(text, text->deprecatedCharacters(), position, length)); + return SVGTextMetrics(text, constructTextRun(text, position, length)); } -SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText* text, unsigned position, unsigned length, float width, const String& glyphName) +SVGTextMetrics::SVGTextMetrics(RenderSVGInlineText& text, unsigned length, float width) { - ASSERT(text); - - bool needsContext = text->style().font().isSVGFont(); - float scalingFactor = text->scalingFactor(); + float scalingFactor = text.scalingFactor(); ASSERT(scalingFactor); m_width = width / scalingFactor; - m_height = text->scaledFont().fontMetrics().floatHeight() / scalingFactor; - if (needsContext) { - m_glyph.isValid = true; - m_glyph.unicodeString = String(text->deprecatedCharacters() + position, length); - m_glyph.name = glyphName; - } + m_height = text.scaledFont().fontMetrics().floatHeight() / scalingFactor; m_length = length; } } - -#endif // ENABLE(SVG) |