Index: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp |
diff --git a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp |
index 0e36470b531e96a7606c2db91c1a1ddbee5d4923..4240dca884613c7c685ee869b3b4306a855e02a4 100644 |
--- a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp |
+++ b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp |
@@ -20,6 +20,7 @@ |
#include "config.h" |
#include "core/layout/svg/SVGTextLayoutEngine.h" |
+#include "core/layout/line/GlyphOverflow.h" |
#include "core/layout/svg/LayoutSVGInlineText.h" |
#include "core/layout/svg/LayoutSVGTextPath.h" |
#include "core/layout/svg/SVGTextChunkBuilder.h" |
@@ -110,6 +111,28 @@ void SVGTextLayoutEngine::updateRelativePositionAdjustmentsIfNeeded(float dx, fl |
m_dy = dy; |
} |
+// Computes the glyph overflow without integer clamping (see: GlyphOverflow.h). |
+void computeGlyphOverflow(SVGInlineTextBox* textBox, SVGTextFragment& textFragment) |
fs
2015/12/14 09:59:31
Nit: static?
pdr.
2015/12/16 04:27:45
Done
|
+{ |
+ LineLayoutSVGInlineText textLineLayout = LineLayoutSVGInlineText(textBox->lineLayoutItem()); |
+ TextRun run = SVGTextMetrics::constructTextRun(textLineLayout, textFragment.characterOffset, textFragment.length, textLineLayout.styleRef().direction()); |
+ |
+ float scalingFactor = textLineLayout.scalingFactor(); |
+ ASSERT(scalingFactor); |
+ const Font& scaledFont = textLineLayout.scaledFont(); |
+ FloatRect glyphOverflowBounds; |
+ |
+ // TODO(pdr): The glyph overflow bounds can be wrong for runs with spaces. |
pdr.
2015/12/16 04:27:45
I have a fix for this in https://codereview.chromi
fs
2015/12/16 10:12:21
Roger Rogers.
|
+ float width = scaledFont.width(run, nullptr, &glyphOverflowBounds); |
+ float ascent = scaledFont.fontMetrics().floatAscent(); |
+ float descent = scaledFont.fontMetrics().floatDescent(); |
+ |
+ textFragment.glyphOverflowTop = GlyphOverflow::topOverflow(glyphOverflowBounds, ascent) / scalingFactor; |
+ textFragment.glyphOverflowBottom = GlyphOverflow::bottomOverflow(glyphOverflowBounds, descent) / scalingFactor; |
+ textFragment.glyphOverflowLeft = GlyphOverflow::leftOverflow(glyphOverflowBounds) / scalingFactor; |
+ textFragment.glyphOverflowRight = GlyphOverflow::rightOverflow(glyphOverflowBounds, width) / scalingFactor; |
+} |
+ |
void SVGTextLayoutEngine::recordTextFragment(SVGInlineTextBox* textBox) |
{ |
ASSERT(!m_currentTextFragment.length); |
@@ -138,6 +161,7 @@ void SVGTextLayoutEngine::recordTextFragment(SVGInlineTextBox* textBox) |
} |
} |
+ computeGlyphOverflow(textBox, m_currentTextFragment); |
textBox->textFragments().append(m_currentTextFragment); |
m_currentTextFragment = SVGTextFragment(); |
} |