OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) Research In Motion Limited 2010-2011. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2010-2011. 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 |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
93 for (const SVGTextMetrics& metrics : text.metricsList()) { | 93 for (const SVGTextMetrics& metrics : text.metricsList()) { |
94 if (metrics.isEmpty()) | 94 if (metrics.isEmpty()) |
95 continue; | 95 continue; |
96 numCharacters++; | 96 numCharacters++; |
97 } | 97 } |
98 return numCharacters; | 98 return numCharacters; |
99 } | 99 } |
100 | 100 |
101 static SVGTextPositioningElement* positioningElementFromLayoutObject( | 101 static SVGTextPositioningElement* positioningElementFromLayoutObject( |
102 LayoutObject& layoutObject) { | 102 LayoutObject& layoutObject) { |
103 ASSERT(layoutObject.isSVGText() || layoutObject.isSVGInline()); | 103 DCHECK(layoutObject.isSVGText() || layoutObject.isSVGInline()); |
104 | 104 |
105 Node* node = layoutObject.node(); | 105 Node* node = layoutObject.node(); |
106 ASSERT(node); | 106 DCHECK(node); |
107 ASSERT(node->isSVGElement()); | 107 DCHECK(node->isSVGElement()); |
108 | 108 |
109 return isSVGTextPositioningElement(*node) ? toSVGTextPositioningElement(node) | 109 return isSVGTextPositioningElement(*node) ? toSVGTextPositioningElement(node) |
110 : nullptr; | 110 : nullptr; |
111 } | 111 } |
112 | 112 |
113 void SVGTextLayoutAttributesBuilder::collectTextPositioningElements( | 113 void SVGTextLayoutAttributesBuilder::collectTextPositioningElements( |
114 LayoutBoxModelObject& start) { | 114 LayoutBoxModelObject& start) { |
115 ASSERT(!start.isSVGText() || m_textPositions.isEmpty()); | 115 DCHECK(!start.isSVGText() || m_textPositions.isEmpty()); |
116 SVGTextPositioningElement* element = | 116 SVGTextPositioningElement* element = |
117 positioningElementFromLayoutObject(start); | 117 positioningElementFromLayoutObject(start); |
118 unsigned atPosition = m_textPositions.size(); | 118 unsigned atPosition = m_textPositions.size(); |
119 if (element) | 119 if (element) |
120 m_textPositions.push_back(TextPosition(element, m_characterCount)); | 120 m_textPositions.push_back(TextPosition(element, m_characterCount)); |
121 | 121 |
122 for (LayoutObject* child = start.slowFirstChild(); child; | 122 for (LayoutObject* child = start.slowFirstChild(); child; |
123 child = child->nextSibling()) { | 123 child = child->nextSibling()) { |
124 if (child->isSVGInlineText()) { | 124 if (child->isSVGInlineText()) { |
125 m_characterCount += | 125 m_characterCount += |
126 countCharactersInTextNode(toLayoutSVGInlineText(*child)); | 126 countCharactersInTextNode(toLayoutSVGInlineText(*child)); |
127 continue; | 127 continue; |
128 } | 128 } |
129 | 129 |
130 if (child->isSVGInline()) { | 130 if (child->isSVGInline()) { |
131 collectTextPositioningElements(toLayoutSVGInline(*child)); | 131 collectTextPositioningElements(toLayoutSVGInline(*child)); |
132 continue; | 132 continue; |
133 } | 133 } |
134 } | 134 } |
135 | 135 |
136 if (!element) | 136 if (!element) |
137 return; | 137 return; |
138 | 138 |
139 // Compute the length of the subtree after all children have been visited. | 139 // Compute the length of the subtree after all children have been visited. |
140 TextPosition& position = m_textPositions[atPosition]; | 140 TextPosition& position = m_textPositions[atPosition]; |
141 ASSERT(!position.length); | 141 DCHECK(!position.length); |
142 position.length = m_characterCount - position.start; | 142 position.length = m_characterCount - position.start; |
143 } | 143 } |
144 | 144 |
145 void SVGTextLayoutAttributesBuilder::buildCharacterDataMap( | 145 void SVGTextLayoutAttributesBuilder::buildCharacterDataMap( |
146 LayoutSVGText& textRoot) { | 146 LayoutSVGText& textRoot) { |
147 // Fill character data map using text positioning elements in top-down order. | 147 // Fill character data map using text positioning elements in top-down order. |
148 for (const TextPosition& position : m_textPositions) | 148 for (const TextPosition& position : m_textPositions) |
149 fillCharacterDataMap(position); | 149 fillCharacterDataMap(position); |
150 | 150 |
151 // Handle x/y default attributes. | 151 // Handle x/y default attributes. |
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
238 .storedValue->value; | 238 .storedValue->value; |
239 attrLists.updateCharacterData(i, data); | 239 attrLists.updateCharacterData(i, data); |
240 } | 240 } |
241 } | 241 } |
242 | 242 |
243 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) { | 243 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) { |
244 visitor->trace(element); | 244 visitor->trace(element); |
245 } | 245 } |
246 | 246 |
247 } // namespace blink | 247 } // namespace blink |
OLD | NEW |