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 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 ASSERT(m_layoutAttributes.isEmpty()); | 161 ASSERT(m_layoutAttributes.isEmpty()); |
162 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); | 162 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); |
163 return false; | 163 return false; |
164 } | 164 } |
165 return true; | 165 return true; |
166 } | 166 } |
167 | 167 |
168 void RenderSVGText::subtreeChildWasAdded(RenderObject* child) | 168 void RenderSVGText::subtreeChildWasAdded(RenderObject* child) |
169 { | 169 { |
170 ASSERT(child); | 170 ASSERT(child); |
| 171 ASSERT(child->isSVGInlineText() || child->isSVGInline()); |
171 if (!shouldHandleSubtreeMutations() || documentBeingDestroyed()) | 172 if (!shouldHandleSubtreeMutations() || documentBeingDestroyed()) |
172 return; | 173 return; |
173 | 174 |
174 // The positioning elements cache doesn't include the new 'child' yet. Clear
the | 175 // The positioning elements cache doesn't include the new 'child' yet. Clear
the |
175 // cache, as the next buildLayoutAttributesForTextRenderer() call rebuilds i
t. | 176 // cache, as the next buildLayoutAttributesForTextRenderer() call rebuilds i
t. |
176 m_layoutAttributesBuilder.clearTextPositioningElements(); | 177 m_layoutAttributesBuilder.clearTextPositioningElements(); |
177 | 178 |
178 // Detect changes in layout attributes and only measure those text parts tha
t have changed! | 179 // Detect changes in layout attributes and only measure those text parts tha
t have changed! |
179 Vector<SVGTextLayoutAttributes*> newLayoutAttributes; | 180 Vector<SVGTextLayoutAttributes*> newLayoutAttributes; |
180 collectLayoutAttributes(this, newLayoutAttributes); | 181 collectLayoutAttributes(this, newLayoutAttributes); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 } | 228 } |
228 | 229 |
229 void RenderSVGText::willBeDestroyed() | 230 void RenderSVGText::willBeDestroyed() |
230 { | 231 { |
231 m_layoutAttributes.clear(); | 232 m_layoutAttributes.clear(); |
232 m_layoutAttributesBuilder.clearTextPositioningElements(); | 233 m_layoutAttributesBuilder.clearTextPositioningElements(); |
233 | 234 |
234 RenderSVGBlock::willBeDestroyed(); | 235 RenderSVGBlock::willBeDestroyed(); |
235 } | 236 } |
236 | 237 |
237 void RenderSVGText::subtreeChildWillBeRemoved(RenderSVGInlineText* text, Vector<
SVGTextLayoutAttributes*, 2>& affectedAttributes) | 238 void RenderSVGText::subtreeChildWillBeRemoved(RenderObject* child, Vector<SVGTex
tLayoutAttributes*, 2>& affectedAttributes) |
238 { | 239 { |
239 ASSERT(text); | 240 ASSERT(child); |
| 241 ASSERT(child->isSVGInlineText() || child->isSVGInline()); |
240 if (!shouldHandleSubtreeMutations()) | 242 if (!shouldHandleSubtreeMutations()) |
241 return; | 243 return; |
242 | 244 |
243 checkLayoutAttributesConsistency(this, m_layoutAttributes); | 245 checkLayoutAttributesConsistency(this, m_layoutAttributes); |
244 | 246 |
245 // The positioning elements cache depends on the size of each text renderer
in the | 247 // The positioning elements cache depends on the size of each text renderer
in the |
246 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. | 248 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. |
247 m_layoutAttributesBuilder.clearTextPositioningElements(); | 249 m_layoutAttributesBuilder.clearTextPositioningElements(); |
248 if (m_layoutAttributes.isEmpty()) | 250 if (m_layoutAttributes.isEmpty() || child->isSVGInline()) |
249 return; | 251 return; |
250 | 252 |
251 // This logic requires that the 'text' child is still inserted in the tree. | 253 // This logic requires that the 'text' child is still inserted in the tree. |
| 254 RenderSVGInlineText* text = toRenderSVGInlineText(child); |
252 bool stopAfterNext = false; | 255 bool stopAfterNext = false; |
253 SVGTextLayoutAttributes* previous = 0; | 256 SVGTextLayoutAttributes* previous = 0; |
254 SVGTextLayoutAttributes* next = 0; | 257 SVGTextLayoutAttributes* next = 0; |
255 if (!documentBeingDestroyed()) | 258 if (!documentBeingDestroyed()) |
256 findPreviousAndNextAttributes(this, text, stopAfterNext, previous, next)
; | 259 findPreviousAndNextAttributes(this, text, stopAfterNext, previous, next)
; |
257 | 260 |
258 if (previous) | 261 if (previous) |
259 affectedAttributes.append(previous); | 262 affectedAttributes.append(previous); |
260 if (next) | 263 if (next) |
261 affectedAttributes.append(next); | 264 affectedAttributes.append(next); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
512 } | 515 } |
513 | 516 |
514 void RenderSVGText::addChild(RenderObject* child, RenderObject* beforeChild) | 517 void RenderSVGText::addChild(RenderObject* child, RenderObject* beforeChild) |
515 { | 518 { |
516 RenderSVGBlock::addChild(child, beforeChild); | 519 RenderSVGBlock::addChild(child, beforeChild); |
517 subtreeChildWasAdded(child); | 520 subtreeChildWasAdded(child); |
518 } | 521 } |
519 | 522 |
520 void RenderSVGText::removeChild(RenderObject* child) | 523 void RenderSVGText::removeChild(RenderObject* child) |
521 { | 524 { |
522 if (!child->isSVGInlineText()) { | |
523 RenderSVGBlock::removeChild(child); | |
524 return; | |
525 } | |
526 | |
527 RenderSVGInlineText* text = toRenderSVGInlineText(child); | |
528 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes; | 525 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes; |
529 subtreeChildWillBeRemoved(text, affectedAttributes); | 526 subtreeChildWillBeRemoved(child, affectedAttributes); |
530 RenderSVGBlock::removeChild(child); | 527 RenderSVGBlock::removeChild(child); |
531 subtreeChildWasRemoved(affectedAttributes); | 528 subtreeChildWasRemoved(affectedAttributes); |
532 } | 529 } |
533 | 530 |
534 // Fix for <rdar://problem/8048875>. We should not render :first-line CSS Style | 531 // Fix for <rdar://problem/8048875>. We should not render :first-line CSS Style |
535 // in a SVG text element context. | 532 // in a SVG text element context. |
536 RenderBlock* RenderSVGText::firstLineBlock() const | 533 RenderBlock* RenderSVGText::firstLineBlock() const |
537 { | 534 { |
538 return 0; | 535 return 0; |
539 } | 536 } |
540 | 537 |
541 // Fix for <rdar://problem/8048875>. We should not render :first-letter CSS Styl
e | 538 // Fix for <rdar://problem/8048875>. We should not render :first-letter CSS Styl
e |
542 // in a SVG text element context. | 539 // in a SVG text element context. |
543 void RenderSVGText::updateFirstLetter() | 540 void RenderSVGText::updateFirstLetter() |
544 { | 541 { |
545 } | 542 } |
546 | 543 |
547 } | 544 } |
548 | 545 |
549 #endif // ENABLE(SVG) | 546 #endif // ENABLE(SVG) |
OLD | NEW |