| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 STACK_ALLOCATED(); | 168 STACK_ALLOCATED(); |
| 169 public: | 169 public: |
| 170 AttributeListsIterator(SVGTextPositioningElement*); | 170 AttributeListsIterator(SVGTextPositioningElement*); |
| 171 | 171 |
| 172 bool hasAttributes() const | 172 bool hasAttributes() const |
| 173 { | 173 { |
| 174 return m_xListRemaining || m_yListRemaining | 174 return m_xListRemaining || m_yListRemaining |
| 175 || m_dxListRemaining || m_dyListRemaining | 175 || m_dxListRemaining || m_dyListRemaining |
| 176 || m_rotateListRemaining; | 176 || m_rotateListRemaining; |
| 177 } | 177 } |
| 178 void updateCharacterData(unsigned index, SVGCharacterData&); | 178 void updateCharacterData(size_t index, SVGCharacterData&); |
| 179 | |
| 180 bool hasRotation() const { return !SVGTextLayoutAttributes::isEmptyValue(m_l
astRotation); } | |
| 181 float lastRotation() const { return m_lastRotation; } | |
| 182 unsigned rotateEnd() const { return m_rotateList->length(); } | |
| 183 | 179 |
| 184 private: | 180 private: |
| 185 SVGLengthContext m_lengthContext; | 181 SVGLengthContext m_lengthContext; |
| 186 Member<SVGLengthList> m_xList; | 182 Member<SVGLengthList> m_xList; |
| 187 unsigned m_xListRemaining; | 183 unsigned m_xListRemaining; |
| 188 Member<SVGLengthList> m_yList; | 184 Member<SVGLengthList> m_yList; |
| 189 unsigned m_yListRemaining; | 185 unsigned m_yListRemaining; |
| 190 Member<SVGLengthList> m_dxList; | 186 Member<SVGLengthList> m_dxList; |
| 191 unsigned m_dxListRemaining; | 187 unsigned m_dxListRemaining; |
| 192 Member<SVGLengthList> m_dyList; | 188 Member<SVGLengthList> m_dyList; |
| 193 unsigned m_dyListRemaining; | 189 unsigned m_dyListRemaining; |
| 194 Member<SVGNumberList> m_rotateList; | 190 Member<SVGNumberList> m_rotateList; |
| 195 unsigned m_rotateListRemaining; | 191 unsigned m_rotateListRemaining; |
| 196 float m_lastRotation; | |
| 197 }; | 192 }; |
| 198 | 193 |
| 199 AttributeListsIterator::AttributeListsIterator(SVGTextPositioningElement* elemen
t) | 194 AttributeListsIterator::AttributeListsIterator(SVGTextPositioningElement* elemen
t) |
| 200 : m_lengthContext(element) | 195 : m_lengthContext(element) |
| 201 , m_xList(element->x()->currentValue()) | 196 , m_xList(element->x()->currentValue()) |
| 202 , m_xListRemaining(m_xList->length()) | 197 , m_xListRemaining(m_xList->length()) |
| 203 , m_yList(element->y()->currentValue()) | 198 , m_yList(element->y()->currentValue()) |
| 204 , m_yListRemaining(m_yList->length()) | 199 , m_yListRemaining(m_yList->length()) |
| 205 , m_dxList(element->dx()->currentValue()) | 200 , m_dxList(element->dx()->currentValue()) |
| 206 , m_dxListRemaining(m_dxList->length()) | 201 , m_dxListRemaining(m_dxList->length()) |
| 207 , m_dyList(element->dy()->currentValue()) | 202 , m_dyList(element->dy()->currentValue()) |
| 208 , m_dyListRemaining(m_dyList->length()) | 203 , m_dyListRemaining(m_dyList->length()) |
| 209 , m_rotateList(element->rotate()->currentValue()) | 204 , m_rotateList(element->rotate()->currentValue()) |
| 210 , m_rotateListRemaining(m_rotateList->length()) | 205 , m_rotateListRemaining(m_rotateList->length()) |
| 211 , m_lastRotation(SVGTextLayoutAttributes::emptyValue()) | |
| 212 { | 206 { |
| 213 } | 207 } |
| 214 | 208 |
| 215 inline void AttributeListsIterator::updateCharacterData(unsigned index, SVGChara
cterData& data) | 209 inline void AttributeListsIterator::updateCharacterData(size_t index, SVGCharact
erData& data) |
| 216 { | 210 { |
| 217 if (m_xListRemaining) { | 211 if (m_xListRemaining) { |
| 218 data.x = m_xList->at(index)->value(m_lengthContext); | 212 data.x = m_xList->at(index)->value(m_lengthContext); |
| 219 --m_xListRemaining; | 213 --m_xListRemaining; |
| 220 } | 214 } |
| 221 if (m_yListRemaining) { | 215 if (m_yListRemaining) { |
| 222 data.y = m_yList->at(index)->value(m_lengthContext); | 216 data.y = m_yList->at(index)->value(m_lengthContext); |
| 223 --m_yListRemaining; | 217 --m_yListRemaining; |
| 224 } | 218 } |
| 225 if (m_dxListRemaining) { | 219 if (m_dxListRemaining) { |
| 226 data.dx = m_dxList->at(index)->value(m_lengthContext); | 220 data.dx = m_dxList->at(index)->value(m_lengthContext); |
| 227 --m_dxListRemaining; | 221 --m_dxListRemaining; |
| 228 } | 222 } |
| 229 if (m_dyListRemaining) { | 223 if (m_dyListRemaining) { |
| 230 data.dy = m_dyList->at(index)->value(m_lengthContext); | 224 data.dy = m_dyList->at(index)->value(m_lengthContext); |
| 231 --m_dyListRemaining; | 225 --m_dyListRemaining; |
| 232 } | 226 } |
| 233 if (m_rotateListRemaining) { | 227 if (m_rotateListRemaining) { |
| 234 data.rotate = m_rotateList->at(index)->value(); | 228 data.rotate = m_rotateList->at(std::min(index, m_rotateList->length() -
1))->value(); |
| 235 m_lastRotation = data.rotate; | 229 // The last rotation value spans the whole scope. |
| 236 --m_rotateListRemaining; | 230 if (m_rotateListRemaining > 1) |
| 231 --m_rotateListRemaining; |
| 237 } | 232 } |
| 238 } | 233 } |
| 239 | 234 |
| 240 } // namespace | 235 } // namespace |
| 241 | 236 |
| 242 void SVGTextLayoutAttributesBuilder::fillCharacterDataMap(const TextPosition& po
sition) | 237 void SVGTextLayoutAttributesBuilder::fillCharacterDataMap(const TextPosition& po
sition) |
| 243 { | 238 { |
| 244 AttributeListsIterator attrLists(position.element); | 239 AttributeListsIterator attrLists(position.element); |
| 245 for (unsigned i = 0; attrLists.hasAttributes() && i < position.length; ++i)
{ | 240 for (unsigned i = 0; attrLists.hasAttributes() && i < position.length; ++i)
{ |
| 246 SVGCharacterData& data = m_characterDataMap.add(position.start + i + 1,
SVGCharacterData()).storedValue->value; | 241 SVGCharacterData& data = m_characterDataMap.add(position.start + i + 1,
SVGCharacterData()).storedValue->value; |
| 247 attrLists.updateCharacterData(i, data); | 242 attrLists.updateCharacterData(i, data); |
| 248 } | 243 } |
| 249 | |
| 250 if (!attrLists.hasRotation()) | |
| 251 return; | |
| 252 | |
| 253 // The last rotation value always spans the whole scope. | |
| 254 for (unsigned i = attrLists.rotateEnd(); i < position.length; ++i) { | |
| 255 SVGCharacterData& data = m_characterDataMap.add(position.start + i + 1,
SVGCharacterData()).storedValue->value; | |
| 256 data.rotate = attrLists.lastRotation(); | |
| 257 } | |
| 258 } | 244 } |
| 259 | 245 |
| 260 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) | 246 DEFINE_TRACE(SVGTextLayoutAttributesBuilder::TextPosition) |
| 261 { | 247 { |
| 262 visitor->trace(element); | 248 visitor->trace(element); |
| 263 } | 249 } |
| 264 | 250 |
| 265 } // namespace blink | 251 } // namespace blink |
| OLD | NEW |