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

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

Issue 1155293005: Perform SVG text chunk processing on-the-fly (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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
Index: Source/core/layout/svg/SVGTextLayoutEngine.cpp
diff --git a/Source/core/layout/svg/SVGTextLayoutEngine.cpp b/Source/core/layout/svg/SVGTextLayoutEngine.cpp
index 7dfb40dab2b50a2d5488e0f898ff820b3e736d9d..7c98bbeb822a445cc1f2fbe1a2efedbb759e251a 100644
--- a/Source/core/layout/svg/SVGTextLayoutEngine.cpp
+++ b/Source/core/layout/svg/SVGTextLayoutEngine.cpp
@@ -177,28 +177,10 @@ void SVGTextLayoutEngine::beginTextPathLayout(LayoutObject* object, SVGTextLayou
if (m_textPathStartOffset > 0 && m_textPathStartOffset <= 1)
m_textPathStartOffset *= m_textPathLength;
- float totalLength = 0;
- unsigned totalCharacters = 0;
-
- SVGTextChunkBuilder textPathChunkLayoutBuilder;
- textPathChunkLayoutBuilder.buildTextChunks(lineLayout.m_lineLayoutBoxes);
- const Vector<SVGTextChunk>& textChunks = textPathChunkLayoutBuilder.textChunks();
-
- unsigned size = textChunks.size();
- for (unsigned i = 0; i < size; ++i) {
- const SVGTextChunk& chunk = textChunks.at(i);
-
- float length = 0;
- unsigned characters = 0;
- chunk.calculateLength(length, characters);
-
- // Handle text-anchor as additional start offset for text paths.
- m_textPathStartOffset += chunk.calculateTextAnchorShift(length);
-
- totalLength += length;
- totalCharacters += characters;
- }
+ SVGTextPathChunkBuilder textPathChunkLayoutBuilder;
+ textPathChunkLayoutBuilder.processTextChunks(lineLayout.m_lineLayoutBoxes);
+ m_textPathStartOffset += textPathChunkLayoutBuilder.totalTextAnchorShift();
m_textPathCurrentOffset = m_textPathStartOffset;
// Eventually handle textLength adjustments.
@@ -217,8 +199,9 @@ void SVGTextLayoutEngine::beginTextPathLayout(LayoutObject* object, SVGTextLayou
if (!desiredTextLength)
return;
+ float totalLength = textPathChunkLayoutBuilder.totalLength();
if (lengthAdjust == SVGLengthAdjustSpacing)
- m_textPathSpacing = (desiredTextLength - totalLength) / totalCharacters;
+ m_textPathSpacing = (desiredTextLength - totalLength) / textPathChunkLayoutBuilder.totalCharacters();
else
m_textPathScaling = desiredTextLength / totalLength;
}
@@ -263,7 +246,7 @@ void SVGTextLayoutEngine::finishLayout()
// After all text fragments are stored in their correpsonding SVGInlineTextBoxes, we can layout individual text chunks.
// Chunk layouting is only performed for line layout boxes, not for path layout, where it has already been done.
SVGTextChunkBuilder chunkLayoutBuilder;
- chunkLayoutBuilder.layoutTextChunks(m_lineLayoutBoxes);
+ chunkLayoutBuilder.processTextChunks(m_lineLayoutBoxes);
// Finalize transform matrices, after the chunk layout corrections have been applied, and all fragment x/y positions are finalized.
if (!m_lineLayoutBoxes.isEmpty()) {

Powered by Google App Engine
This is Rietveld 408576698