Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(486)

Unified Diff: third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp

Issue 1824193002: Remove extra per-character walk in SVGTextLayoutEngine (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Greatest Expectations Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 895438085f75f7273e11705b6d8045c4055a4bea..6ea9250307c4ba2e4420039fdb1d8cecc3b9969d 100644
--- a/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp
+++ b/third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.cpp
@@ -111,10 +111,10 @@ void SVGTextLayoutEngine::updateRelativePositionAdjustmentsIfNeeded(float dx, fl
m_dy = dy;
}
-static void computeGlyphOverflow(SVGInlineTextBox* textBox, SVGTextFragment& textFragment)
+void SVGTextLayoutEngine::computeCurrentFragmentMetrics(SVGInlineTextBox* textBox)
{
LineLayoutSVGInlineText textLineLayout = LineLayoutSVGInlineText(textBox->getLineLayoutItem());
- TextRun run = textBox->constructTextRun(textLineLayout.styleRef(), textFragment);
+ TextRun run = textBox->constructTextRun(textLineLayout.styleRef(), m_currentTextFragment);
float scalingFactor = textLineLayout.scalingFactor();
ASSERT(scalingFactor);
@@ -124,11 +124,15 @@ static void computeGlyphOverflow(SVGInlineTextBox* textBox, SVGTextFragment& tex
float width = scaledFont.width(run, nullptr, &glyphOverflowBounds);
float ascent = scaledFont.getFontMetrics().floatAscent();
float descent = scaledFont.getFontMetrics().floatDescent();
- textFragment.glyphOverflow.setFromBounds(glyphOverflowBounds, ascent, descent, width);
- textFragment.glyphOverflow.top /= scalingFactor;
- textFragment.glyphOverflow.left /= scalingFactor;
- textFragment.glyphOverflow.right /= scalingFactor;
- textFragment.glyphOverflow.bottom /= scalingFactor;
+ m_currentTextFragment.glyphOverflow.setFromBounds(glyphOverflowBounds, ascent, descent, width);
+ m_currentTextFragment.glyphOverflow.top /= scalingFactor;
+ m_currentTextFragment.glyphOverflow.left /= scalingFactor;
+ m_currentTextFragment.glyphOverflow.right /= scalingFactor;
+ m_currentTextFragment.glyphOverflow.bottom /= scalingFactor;
+
+ float height = scaledFont.getFontMetrics().floatHeight();
+ m_currentTextFragment.height = height / scalingFactor;
+ m_currentTextFragment.width = width / scalingFactor;
}
void SVGTextLayoutEngine::recordTextFragment(SVGInlineTextBox* textBox)
@@ -139,27 +143,8 @@ void SVGTextLayoutEngine::recordTextFragment(SVGInlineTextBox* textBox)
m_currentTextFragment.length = m_visualMetricsIterator.characterOffset() - m_currentTextFragment.characterOffset;
// Figure out fragment metrics.
- const unsigned visualMetricsListOffset = m_visualMetricsIterator.metricsListOffset();
- const Vector<SVGTextMetrics>& textMetricsValues = m_visualMetricsIterator.metricsList();
- const SVGTextMetrics& lastCharacterMetrics = textMetricsValues.at(visualMetricsListOffset - 1);
- m_currentTextFragment.width = lastCharacterMetrics.width();
- m_currentTextFragment.height = lastCharacterMetrics.height();
-
- if (m_currentTextFragment.length > 1) {
- // SVGTextLayoutAttributesBuilder assures that the length of the range is equal to the sum of the individual lengths of the glyphs.
- float length = 0;
- if (m_isVerticalText) {
- for (unsigned i = m_currentTextFragment.metricsListOffset; i < visualMetricsListOffset; ++i)
- length += textMetricsValues.at(i).height();
- m_currentTextFragment.height = length;
- } else {
- for (unsigned i = m_currentTextFragment.metricsListOffset; i < visualMetricsListOffset; ++i)
- length += textMetricsValues.at(i).width();
- m_currentTextFragment.width = length;
- }
- }
+ computeCurrentFragmentMetrics(textBox);
- computeGlyphOverflow(textBox, m_currentTextFragment);
textBox->textFragments().append(m_currentTextFragment);
m_currentTextFragment = SVGTextFragment();
}
« no previous file with comments | « third_party/WebKit/Source/core/layout/svg/SVGTextLayoutEngine.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698