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

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

Issue 1665413003: [Line Layout API] Add LineLayoutSVGInline and LineLayoutSVGTextPath (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 10 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 unified diff | Download patch
« no previous file with comments | « third_party/WebKit/Source/core/layout/api/LineLayoutSVGTextPath.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. 2 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved.
3 * 3 *
4 * This library is free software; you can redistribute it and/or 4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public 5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either 6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version. 7 * version 2 of the License, or (at your option) any later version.
8 * 8 *
9 * This library is distributed in the hope that it will be useful, 9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Library General Public License for more details. 12 * Library General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU Library General Public License 14 * You should have received a copy of the GNU Library General Public License
15 * along with this library; see the file COPYING.LIB. If not, write to 15 * along with this library; see the file COPYING.LIB. If not, write to
16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17 * Boston, MA 02110-1301, USA. 17 * Boston, MA 02110-1301, USA.
18 */ 18 */
19 19
20 #include "core/layout/svg/SVGTextLayoutEngine.h" 20 #include "core/layout/svg/SVGTextLayoutEngine.h"
21 21
22 #include "core/layout/api/LineLayoutAPIShim.h"
23 #include "core/layout/api/LineLayoutSVGTextPath.h"
22 #include "core/layout/svg/LayoutSVGInlineText.h" 24 #include "core/layout/svg/LayoutSVGInlineText.h"
23 #include "core/layout/svg/LayoutSVGTextPath.h"
24 #include "core/layout/svg/SVGTextChunkBuilder.h" 25 #include "core/layout/svg/SVGTextChunkBuilder.h"
25 #include "core/layout/svg/SVGTextLayoutEngineBaseline.h" 26 #include "core/layout/svg/SVGTextLayoutEngineBaseline.h"
26 #include "core/layout/svg/SVGTextLayoutEngineSpacing.h" 27 #include "core/layout/svg/SVGTextLayoutEngineSpacing.h"
27 #include "core/layout/svg/line/SVGInlineFlowBox.h" 28 #include "core/layout/svg/line/SVGInlineFlowBox.h"
28 #include "core/layout/svg/line/SVGInlineTextBox.h" 29 #include "core/layout/svg/line/SVGInlineTextBox.h"
29 #include "core/svg/SVGElement.h" 30 #include "core/svg/SVGElement.h"
30 #include "core/svg/SVGLengthContext.h" 31 #include "core/svg/SVGLengthContext.h"
31 #include "core/svg/SVGTextContentElement.h" 32 #include "core/svg/SVGTextContentElement.h"
32 33
33 namespace blink { 34 namespace blink {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 165
165 void SVGTextLayoutEngine::beginTextPathLayout(SVGInlineFlowBox* flowBox) 166 void SVGTextLayoutEngine::beginTextPathLayout(SVGInlineFlowBox* flowBox)
166 { 167 {
167 // Build text chunks for all <textPath> children, using the line layout algo rithm. 168 // Build text chunks for all <textPath> children, using the line layout algo rithm.
168 // This is needeed as text-anchor is just an additional startOffset for text paths. 169 // This is needeed as text-anchor is just an additional startOffset for text paths.
169 SVGTextLayoutEngine lineLayout(m_layoutAttributes); 170 SVGTextLayoutEngine lineLayout(m_layoutAttributes);
170 lineLayout.m_textLengthSpacingInEffect = m_textLengthSpacingInEffect; 171 lineLayout.m_textLengthSpacingInEffect = m_textLengthSpacingInEffect;
171 lineLayout.layoutCharactersInTextBoxes(flowBox); 172 lineLayout.layoutCharactersInTextBoxes(flowBox);
172 173
173 m_inPathLayout = true; 174 m_inPathLayout = true;
174 LayoutSVGTextPath* textPath = &toLayoutSVGTextPath(flowBox->layoutObject()); 175 LineLayoutSVGTextPath textPath = LineLayoutSVGTextPath(flowBox->lineLayoutIt em());
175 176
176 Path path = textPath->layoutPath(); 177 Path path = textPath.layoutPath();
177 if (path.isEmpty()) 178 if (path.isEmpty())
178 return; 179 return;
179 m_textPathCalculator = new Path::PositionCalculator(path); 180 m_textPathCalculator = new Path::PositionCalculator(path);
180 m_textPathLength = path.length(); 181 m_textPathLength = path.length();
181 m_textPathStartOffset = textPath->calculateStartOffset(m_textPathLength); 182 m_textPathStartOffset = textPath.calculateStartOffset(m_textPathLength);
182 183
183 SVGTextPathChunkBuilder textPathChunkLayoutBuilder; 184 SVGTextPathChunkBuilder textPathChunkLayoutBuilder;
184 textPathChunkLayoutBuilder.processTextChunks(lineLayout.m_lineLayoutBoxes); 185 textPathChunkLayoutBuilder.processTextChunks(lineLayout.m_lineLayoutBoxes);
185 186
186 m_textPathStartOffset += textPathChunkLayoutBuilder.totalTextAnchorShift(); 187 m_textPathStartOffset += textPathChunkLayoutBuilder.totalTextAnchorShift();
187 m_textPathCurrentOffset = m_textPathStartOffset; 188 m_textPathCurrentOffset = m_textPathStartOffset;
188 189
189 // Eventually handle textLength adjustments. 190 // Eventually handle textLength adjustments.
190 SVGLengthAdjustType lengthAdjust = SVGLengthAdjustUnknown; 191 SVGLengthAdjustType lengthAdjust = SVGLengthAdjustUnknown;
191 float desiredTextLength = 0; 192 float desiredTextLength = 0;
192 193
193 if (SVGTextContentElement* textContentElement = SVGTextContentElement::eleme ntFromLayoutObject(textPath)) { 194 if (SVGTextContentElement* textContentElement = SVGTextContentElement::eleme ntFromLayoutObject(LineLayoutAPIShim::layoutObjectFrom(textPath))) {
194 SVGLengthContext lengthContext(textContentElement); 195 SVGLengthContext lengthContext(textContentElement);
195 lengthAdjust = textContentElement->lengthAdjust()->currentValue()->enumV alue(); 196 lengthAdjust = textContentElement->lengthAdjust()->currentValue()->enumV alue();
196 if (textContentElement->textLengthIsSpecifiedByUser()) 197 if (textContentElement->textLengthIsSpecifiedByUser())
197 desiredTextLength = textContentElement->textLength()->currentValue() ->value(lengthContext); 198 desiredTextLength = textContentElement->textLength()->currentValue() ->value(lengthContext);
198 else 199 else
199 desiredTextLength = 0; 200 desiredTextLength = 0;
200 } 201 }
201 202
202 if (!desiredTextLength) 203 if (!desiredTextLength)
203 return; 204 return;
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
550 } 551 }
551 552
552 if (!didStartTextFragment) 553 if (!didStartTextFragment)
553 return; 554 return;
554 555
555 // Close last open fragment, if needed. 556 // Close last open fragment, if needed.
556 recordTextFragment(textBox); 557 recordTextFragment(textBox);
557 } 558 }
558 559
559 } // namespace blink 560 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/layout/api/LineLayoutSVGTextPath.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698