OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2006 Apple Computer, Inc. | 2 * Copyright (C) 2006 Apple Computer, Inc. |
3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> | 3 * Copyright (C) 2006 Alexander Kellett <lypanov@kde.org> |
4 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> | 4 * Copyright (C) 2006 Oliver Hunt <ojh16@student.canterbury.ac.nz> |
5 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> | 5 * Copyright (C) 2007 Nikolas Zimmermann <zimmermann@kde.org> |
6 * Copyright (C) 2008 Rob Buis <buis@kde.org> | 6 * Copyright (C) 2008 Rob Buis <buis@kde.org> |
7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> | 7 * Copyright (C) 2009 Dirk Schulze <krit@webkit.org> |
8 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. | 8 * Copyright (C) Research In Motion Limited 2010-2012. All rights reserved. |
9 * Copyright (C) 2012 Google Inc. | 9 * Copyright (C) 2012 Google Inc. |
10 * | 10 * |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 } | 101 } |
102 | 102 |
103 static inline void collectLayoutAttributes(RenderObject* text, Vector<SVGTextLay
outAttributes*>& attributes) | 103 static inline void collectLayoutAttributes(RenderObject* text, Vector<SVGTextLay
outAttributes*>& attributes) |
104 { | 104 { |
105 for (RenderObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { | 105 for (RenderObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { |
106 if (descendant->isSVGInlineText()) | 106 if (descendant->isSVGInlineText()) |
107 attributes.append(toRenderSVGInlineText(descendant)->layoutAttribute
s()); | 107 attributes.append(toRenderSVGInlineText(descendant)->layoutAttribute
s()); |
108 } | 108 } |
109 } | 109 } |
110 | 110 |
111 static inline bool findPreviousAndNextAttributes(RenderObject* start, RenderSVGI
nlineText* locateElement, bool& stopAfterNext, SVGTextLayoutAttributes*& previou
s, SVGTextLayoutAttributes*& next) | 111 static inline bool findPreviousAndNextAttributes(RenderObject* root, RenderSVGIn
lineText* locateElement, SVGTextLayoutAttributes*& previous, SVGTextLayoutAttrib
utes*& next) |
112 { | 112 { |
113 ASSERT(start); | 113 ASSERT(root); |
114 ASSERT(locateElement); | 114 ASSERT(locateElement); |
115 // FIXME: Make this iterative. | 115 bool stopAfterNext = false; |
116 for (RenderObject* child = start->firstChild(); child; child = child->nextSi
bling()) { | 116 RenderObject* current = root->firstChild(); |
117 if (child->isSVGInlineText()) { | 117 while (current) { |
118 RenderSVGInlineText* text = toRenderSVGInlineText(child); | 118 if (current->isSVGInlineText()) { |
| 119 RenderSVGInlineText* text = toRenderSVGInlineText(current); |
119 if (locateElement != text) { | 120 if (locateElement != text) { |
120 if (stopAfterNext) { | 121 if (stopAfterNext) { |
121 next = text->layoutAttributes(); | 122 next = text->layoutAttributes(); |
122 return true; | 123 return true; |
123 } | 124 } |
124 | 125 |
125 previous = text->layoutAttributes(); | 126 previous = text->layoutAttributes(); |
| 127 } else { |
| 128 stopAfterNext = true; |
| 129 } |
| 130 } else if (current->isSVGInline()) { |
| 131 // Descend into text content (if possible). |
| 132 if (RenderObject* child = current->firstChild()) { |
| 133 current = child; |
126 continue; | 134 continue; |
127 } | 135 } |
128 | |
129 stopAfterNext = true; | |
130 continue; | |
131 } | 136 } |
132 | 137 |
133 if (!child->isSVGInline()) | 138 current = current->nextInPreOrderAfterChildren(root); |
134 continue; | |
135 | |
136 if (findPreviousAndNextAttributes(child, locateElement, stopAfterNext, p
revious, next)) | |
137 return true; | |
138 } | 139 } |
139 | |
140 return false; | 140 return false; |
141 } | 141 } |
142 | 142 |
143 inline bool RenderSVGText::shouldHandleSubtreeMutations() const | 143 inline bool RenderSVGText::shouldHandleSubtreeMutations() const |
144 { | 144 { |
145 if (beingDestroyed() || !everHadLayout()) { | 145 if (beingDestroyed() || !everHadLayout()) { |
146 ASSERT(m_layoutAttributes.isEmpty()); | 146 ASSERT(m_layoutAttributes.isEmpty()); |
147 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); | 147 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); |
148 return false; | 148 return false; |
149 } | 149 } |
(...skipping 24 matching lines...) Expand all Loading... |
174 return; | 174 return; |
175 } | 175 } |
176 | 176 |
177 // Compare m_layoutAttributes with newLayoutAttributes to figure out which a
ttribute got added. | 177 // Compare m_layoutAttributes with newLayoutAttributes to figure out which a
ttribute got added. |
178 size_t size = newLayoutAttributes.size(); | 178 size_t size = newLayoutAttributes.size(); |
179 SVGTextLayoutAttributes* attributes = 0; | 179 SVGTextLayoutAttributes* attributes = 0; |
180 for (size_t i = 0; i < size; ++i) { | 180 for (size_t i = 0; i < size; ++i) { |
181 attributes = newLayoutAttributes[i]; | 181 attributes = newLayoutAttributes[i]; |
182 if (m_layoutAttributes.find(attributes) == kNotFound) { | 182 if (m_layoutAttributes.find(attributes) == kNotFound) { |
183 // Every time this is invoked, there's only a single new entry in th
e newLayoutAttributes list, compared to the old in m_layoutAttributes. | 183 // Every time this is invoked, there's only a single new entry in th
e newLayoutAttributes list, compared to the old in m_layoutAttributes. |
184 bool stopAfterNext = false; | |
185 SVGTextLayoutAttributes* previous = 0; | 184 SVGTextLayoutAttributes* previous = 0; |
186 SVGTextLayoutAttributes* next = 0; | 185 SVGTextLayoutAttributes* next = 0; |
187 ASSERT_UNUSED(child, attributes->context() == child); | 186 ASSERT_UNUSED(child, attributes->context() == child); |
188 findPreviousAndNextAttributes(this, attributes->context(), stopAfter
Next, previous, next); | 187 findPreviousAndNextAttributes(this, attributes->context(), previous,
next); |
189 | 188 |
190 if (previous) | 189 if (previous) |
191 m_layoutAttributesBuilder.buildLayoutAttributesForTextRenderer(p
revious->context()); | 190 m_layoutAttributesBuilder.buildLayoutAttributesForTextRenderer(p
revious->context()); |
192 m_layoutAttributesBuilder.buildLayoutAttributesForTextRenderer(attri
butes->context()); | 191 m_layoutAttributesBuilder.buildLayoutAttributesForTextRenderer(attri
butes->context()); |
193 if (next) | 192 if (next) |
194 m_layoutAttributesBuilder.buildLayoutAttributesForTextRenderer(n
ext->context()); | 193 m_layoutAttributesBuilder.buildLayoutAttributesForTextRenderer(n
ext->context()); |
195 break; | 194 break; |
196 } | 195 } |
197 } | 196 } |
198 | 197 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
231 checkLayoutAttributesConsistency(this, m_layoutAttributes); | 230 checkLayoutAttributesConsistency(this, m_layoutAttributes); |
232 | 231 |
233 // The positioning elements cache depends on the size of each text renderer
in the | 232 // The positioning elements cache depends on the size of each text renderer
in the |
234 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. | 233 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. |
235 m_layoutAttributesBuilder.clearTextPositioningElements(); | 234 m_layoutAttributesBuilder.clearTextPositioningElements(); |
236 if (m_layoutAttributes.isEmpty() || !child->isSVGInlineText()) | 235 if (m_layoutAttributes.isEmpty() || !child->isSVGInlineText()) |
237 return; | 236 return; |
238 | 237 |
239 // This logic requires that the 'text' child is still inserted in the tree. | 238 // This logic requires that the 'text' child is still inserted in the tree. |
240 RenderSVGInlineText* text = toRenderSVGInlineText(child); | 239 RenderSVGInlineText* text = toRenderSVGInlineText(child); |
241 bool stopAfterNext = false; | |
242 SVGTextLayoutAttributes* previous = 0; | 240 SVGTextLayoutAttributes* previous = 0; |
243 SVGTextLayoutAttributes* next = 0; | 241 SVGTextLayoutAttributes* next = 0; |
244 if (!documentBeingDestroyed()) | 242 if (!documentBeingDestroyed()) |
245 findPreviousAndNextAttributes(this, text, stopAfterNext, previous, next)
; | 243 findPreviousAndNextAttributes(this, text, previous, next); |
246 | 244 |
247 if (previous) | 245 if (previous) |
248 affectedAttributes.append(previous); | 246 affectedAttributes.append(previous); |
249 if (next) | 247 if (next) |
250 affectedAttributes.append(next); | 248 affectedAttributes.append(next); |
251 | 249 |
252 size_t position = m_layoutAttributes.find(text->layoutAttributes()); | 250 size_t position = m_layoutAttributes.find(text->layoutAttributes()); |
253 ASSERT(position != kNotFound); | 251 ASSERT(position != kNotFound); |
254 m_layoutAttributes.remove(position); | 252 m_layoutAttributes.remove(position); |
255 } | 253 } |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
535 return 0; | 533 return 0; |
536 } | 534 } |
537 | 535 |
538 // Fix for <rdar://problem/8048875>. We should not render :first-letter CSS Styl
e | 536 // Fix for <rdar://problem/8048875>. We should not render :first-letter CSS Styl
e |
539 // in a SVG text element context. | 537 // in a SVG text element context. |
540 void RenderSVGText::updateFirstLetter() | 538 void RenderSVGText::updateFirstLetter() |
541 { | 539 { |
542 } | 540 } |
543 | 541 |
544 } | 542 } |
OLD | NEW |