OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> | 2 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> |
3 * Copyright (C) 2006 Apple Computer Inc. | 3 * Copyright (C) 2006 Apple Computer Inc. |
4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 4 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. | 5 * Copyright (C) Research In Motion Limited 2010. All rights reserved. |
6 * Copyright (C) 2011 Torch Mobile (Beijing) CO. Ltd. All rights reserved. | 6 * Copyright (C) 2011 Torch Mobile (Beijing) CO. Ltd. All rights reserved. |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 | 51 |
52 Vector<SVGTextLayoutAttributes*>& layoutAttributes = textRoot.layoutAttribut
es(); | 52 Vector<SVGTextLayoutAttributes*>& layoutAttributes = textRoot.layoutAttribut
es(); |
53 if (layoutAttributes.isEmpty()) | 53 if (layoutAttributes.isEmpty()) |
54 return; | 54 return; |
55 | 55 |
56 if (textRoot.needsReordering()) | 56 if (textRoot.needsReordering()) |
57 reorderValueLists(layoutAttributes); | 57 reorderValueLists(layoutAttributes); |
58 | 58 |
59 // Perform SVG text layout phase two (see SVGTextLayoutEngine for details). | 59 // Perform SVG text layout phase two (see SVGTextLayoutEngine for details). |
60 SVGTextLayoutEngine characterLayout(layoutAttributes); | 60 SVGTextLayoutEngine characterLayout(layoutAttributes); |
61 layoutCharactersInTextBoxes(this, characterLayout); | 61 characterLayout.layoutCharactersInTextBoxes(this); |
62 | 62 |
63 // Perform SVG text layout phase three (see SVGTextChunkBuilder for details)
. | 63 // Perform SVG text layout phase three (see SVGTextChunkBuilder for details)
. |
64 characterLayout.finishLayout(); | 64 characterLayout.finishLayout(); |
65 | 65 |
66 // Perform SVG text layout phase four | 66 // Perform SVG text layout phase four |
67 // Position & resize all SVGInlineText/FlowBoxes in the inline box tree, res
ize the root box as well as the LayoutSVGText parent block. | 67 // Position & resize all SVGInlineText/FlowBoxes in the inline box tree, res
ize the root box as well as the LayoutSVGText parent block. |
68 FloatRectWillBeLayoutRect childRect; | 68 FloatRectWillBeLayoutRect childRect; |
69 layoutChildBoxes(this, &childRect); | 69 layoutChildBoxes(this, &childRect); |
70 layoutRootBox(childRect); | 70 layoutRootBox(childRect); |
71 } | 71 } |
72 | 72 |
73 void SVGRootInlineBox::layoutCharactersInTextBoxes(InlineFlowBox* start, SVGText
LayoutEngine& characterLayout) | |
74 { | |
75 for (InlineBox* child = start->firstChild(); child; child = child->nextOnLin
e()) { | |
76 if (child->isSVGInlineTextBox()) { | |
77 ASSERT(child->layoutObject().isSVGInlineText()); | |
78 characterLayout.layoutInlineTextBox(toSVGInlineTextBox(child)); | |
79 } else { | |
80 // Skip generated content. | |
81 Node* node = child->layoutObject().node(); | |
82 if (!node) | |
83 continue; | |
84 | |
85 SVGInlineFlowBox* flowBox = toSVGInlineFlowBox(child); | |
86 bool isTextPath = isSVGTextPathElement(*node); | |
87 if (isTextPath) { | |
88 // Build text chunks for all <textPath> children, using the line
layout algorithm. | |
89 // This is needeed as text-anchor is just an additional startOff
set for text paths. | |
90 SVGTextLayoutEngine lineLayout(characterLayout.layoutAttributes(
)); | |
91 layoutCharactersInTextBoxes(flowBox, lineLayout); | |
92 | |
93 characterLayout.beginTextPathLayout(&child->layoutObject(), line
Layout); | |
94 } | |
95 | |
96 layoutCharactersInTextBoxes(flowBox, characterLayout); | |
97 | |
98 if (isTextPath) | |
99 characterLayout.endTextPathLayout(); | |
100 } | |
101 } | |
102 } | |
103 | |
104 void SVGRootInlineBox::layoutChildBoxes(InlineFlowBox* start, FloatRectWillBeLay
outRect* childRect) | 73 void SVGRootInlineBox::layoutChildBoxes(InlineFlowBox* start, FloatRectWillBeLay
outRect* childRect) |
105 { | 74 { |
106 for (InlineBox* child = start->firstChild(); child; child = child->nextOnLin
e()) { | 75 for (InlineBox* child = start->firstChild(); child; child = child->nextOnLin
e()) { |
107 FloatRectWillBeLayoutRect boxRect; | 76 FloatRectWillBeLayoutRect boxRect; |
108 if (child->isSVGInlineTextBox()) { | 77 if (child->isSVGInlineTextBox()) { |
109 ASSERT(child->layoutObject().isSVGInlineText()); | 78 ASSERT(child->layoutObject().isSVGInlineText()); |
110 | 79 |
111 SVGInlineTextBox* textBox = toSVGInlineTextBox(child); | 80 SVGInlineTextBox* textBox = toSVGInlineTextBox(child); |
112 boxRect = textBox->calculateBoundaries(); | 81 boxRect = textBox->calculateBoundaries(); |
113 textBox->setX(boxRect.x()); | 82 textBox->setX(boxRect.x()); |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
258 } | 227 } |
259 } | 228 } |
260 | 229 |
261 void SVGRootInlineBox::reorderValueLists(Vector<SVGTextLayoutAttributes*>& attri
butes) | 230 void SVGRootInlineBox::reorderValueLists(Vector<SVGTextLayoutAttributes*>& attri
butes) |
262 { | 231 { |
263 Vector<InlineBox*> leafBoxesInLogicalOrder; | 232 Vector<InlineBox*> leafBoxesInLogicalOrder; |
264 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder, reverseInlineBoxRang
eAndValueListsIfNeeded, &attributes); | 233 collectLeafBoxesInLogicalOrder(leafBoxesInLogicalOrder, reverseInlineBoxRang
eAndValueListsIfNeeded, &attributes); |
265 } | 234 } |
266 | 235 |
267 } // namespace blink | 236 } // namespace blink |
OLD | NEW |