| 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 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 106 Node* node = layoutObject.node(); | 106 Node* node = layoutObject.node(); |
| 107 ASSERT(node); | 107 ASSERT(node); |
| 108 ASSERT(node->isSVGElement()); | 108 ASSERT(node->isSVGElement()); |
| 109 | 109 |
| 110 return isSVGTextPositioningElement(*node) ? toSVGTextPositioningElement(node
) : nullptr; | 110 return isSVGTextPositioningElement(*node) ? toSVGTextPositioningElement(node
) : nullptr; |
| 111 } | 111 } |
| 112 | 112 |
| 113 void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(LayoutBoxMod
elObject& start) | 113 void SVGTextLayoutAttributesBuilder::collectTextPositioningElements(LayoutBoxMod
elObject& start) |
| 114 { | 114 { |
| 115 ASSERT(!start.isSVGText() || m_textPositions.isEmpty()); | 115 ASSERT(!start.isSVGText() || m_textPositions.isEmpty()); |
| 116 SVGTextPositioningElement* element = positioningElementFromLayoutObject(star
t); |
| 117 unsigned atPosition = m_textPositions.size(); |
| 118 if (element) |
| 119 m_textPositions.append(TextPosition(element, m_characterCount)); |
| 116 | 120 |
| 117 for (LayoutObject* child = start.slowFirstChild(); child; child = child->nex
tSibling()) { | 121 for (LayoutObject* child = start.slowFirstChild(); child; child = child->nex
tSibling()) { |
| 118 if (child->isSVGInlineText()) { | 122 if (child->isSVGInlineText()) { |
| 119 m_characterCount += countCharactersInTextNode(toLayoutSVGInlineText(
*child)); | 123 m_characterCount += countCharactersInTextNode(toLayoutSVGInlineText(
*child)); |
| 120 continue; | 124 continue; |
| 121 } | 125 } |
| 122 | 126 |
| 123 if (!child->isSVGInline()) | 127 if (child->isSVGInline()) { |
| 128 collectTextPositioningElements(toLayoutSVGInline(*child)); |
| 124 continue; | 129 continue; |
| 130 } |
| 131 } |
| 125 | 132 |
| 126 LayoutSVGInline& inlineChild = toLayoutSVGInline(*child); | 133 if (!element) |
| 127 SVGTextPositioningElement* element = positioningElementFromLayoutObject(
inlineChild); | 134 return; |
| 128 unsigned atPosition = m_textPositions.size(); | |
| 129 if (element) | |
| 130 m_textPositions.append(TextPosition(element, m_characterCount)); | |
| 131 | 135 |
| 132 collectTextPositioningElements(inlineChild); | 136 // Compute the length of the subtree after all children have been visited. |
| 133 | 137 TextPosition& position = m_textPositions[atPosition]; |
| 134 if (!element) | 138 ASSERT(!position.length); |
| 135 continue; | 139 position.length = m_characterCount - position.start; |
| 136 | |
| 137 // Update text position, after we're back from recursion. | |
| 138 TextPosition& position = m_textPositions[atPosition]; | |
| 139 ASSERT(!position.length); | |
| 140 position.length = m_characterCount - position.start; | |
| 141 } | |
| 142 } | 140 } |
| 143 | 141 |
| 144 void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(LayoutSVGText& textRo
ot) | 142 void SVGTextLayoutAttributesBuilder::buildCharacterDataMap(LayoutSVGText& textRo
ot) |
| 145 { | 143 { |
| 146 SVGTextPositioningElement* outermostTextElement = positioningElementFromLayo
utObject(textRoot); | 144 // Fill character data map using text positioning elements in top-down order
. |
| 147 ASSERT(outermostTextElement); | 145 for (const TextPosition& position : m_textPositions) |
| 148 | 146 fillCharacterDataMap(position); |
| 149 // Grab outermost <text> element value lists and insert them in the characte
r data map. | |
| 150 TextPosition wholeTextPosition(outermostTextElement, 0, m_characterCount); | |
| 151 fillCharacterDataMap(wholeTextPosition); | |
| 152 | |
| 153 // Fill character data map using child text positioning elements in top-down
order. | |
| 154 unsigned size = m_textPositions.size(); | |
| 155 for (unsigned i = 0; i < size; ++i) | |
| 156 fillCharacterDataMap(m_textPositions[i]); | |
| 157 | 147 |
| 158 // Handle x/y default attributes. | 148 // Handle x/y default attributes. |
| 159 SVGCharacterData& data = m_characterDataMap.add(1, SVGCharacterData()).store
dValue->value; | 149 SVGCharacterData& data = m_characterDataMap.add(1, SVGCharacterData()).store
dValue->value; |
| 160 if (SVGTextLayoutAttributes::isEmptyValue(data.x)) | 150 if (SVGTextLayoutAttributes::isEmptyValue(data.x)) |
| 161 data.x = 0; | 151 data.x = 0; |
| 162 if (SVGTextLayoutAttributes::isEmptyValue(data.y)) | 152 if (SVGTextLayoutAttributes::isEmptyValue(data.y)) |
| 163 data.y = 0; | 153 data.y = 0; |
| 164 } | 154 } |
| 165 | 155 |
| 166 namespace { | 156 namespace { |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 attrLists.updateCharacterData(i, data); | 233 attrLists.updateCharacterData(i, data); |
| 244 } | 234 } |
| 245 } | 235 } |
| 246 | 236 |
| 247 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) | 237 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) |
| 248 { | 238 { |
| 249 visitor->trace(element); | 239 visitor->trace(element); |
| 250 } | 240 } |
| 251 | 241 |
| 252 } // namespace blink | 242 } // namespace blink |
| OLD | NEW |