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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
60 , m_needsTransformUpdate(true) | 60 , m_needsTransformUpdate(true) |
61 , m_needsTextMetricsUpdate(false) | 61 , m_needsTextMetricsUpdate(false) |
62 { | 62 { |
63 } | 63 } |
64 | 64 |
65 RenderSVGText::~RenderSVGText() | 65 RenderSVGText::~RenderSVGText() |
66 { | 66 { |
67 ASSERT(m_layoutAttributes.isEmpty()); | 67 ASSERT(m_layoutAttributes.isEmpty()); |
68 } | 68 } |
69 | 69 |
70 bool RenderSVGText::isChildAllowed(RenderObject* child, const RenderStyle&) cons
t | 70 bool RenderSVGText::isChildAllowed(LayoutObject* child, const RenderStyle&) cons
t |
71 { | 71 { |
72 return child->isSVGInline() || (child->isText() && SVGRenderSupport::isRende
rableTextNode(child)); | 72 return child->isSVGInline() || (child->isText() && SVGRenderSupport::isRende
rableTextNode(child)); |
73 } | 73 } |
74 | 74 |
75 RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(RenderObject* start) | 75 RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(LayoutObject* start) |
76 { | 76 { |
77 ASSERT(start); | 77 ASSERT(start); |
78 while (start && !start->isSVGText()) | 78 while (start && !start->isSVGText()) |
79 start = start->parent(); | 79 start = start->parent(); |
80 if (!start || !start->isSVGText()) | 80 if (!start || !start->isSVGText()) |
81 return 0; | 81 return 0; |
82 return toRenderSVGText(start); | 82 return toRenderSVGText(start); |
83 } | 83 } |
84 | 84 |
85 const RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(const RenderObje
ct* start) | 85 const RenderSVGText* RenderSVGText::locateRenderSVGTextAncestor(const LayoutObje
ct* start) |
86 { | 86 { |
87 ASSERT(start); | 87 ASSERT(start); |
88 while (start && !start->isSVGText()) | 88 while (start && !start->isSVGText()) |
89 start = start->parent(); | 89 start = start->parent(); |
90 if (!start || !start->isSVGText()) | 90 if (!start || !start->isSVGText()) |
91 return 0; | 91 return 0; |
92 return toRenderSVGText(start); | 92 return toRenderSVGText(start); |
93 } | 93 } |
94 | 94 |
95 static inline void collectLayoutAttributes(RenderObject* text, Vector<SVGTextLay
outAttributes*>& attributes) | 95 static inline void collectLayoutAttributes(LayoutObject* text, Vector<SVGTextLay
outAttributes*>& attributes) |
96 { | 96 { |
97 for (RenderObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { | 97 for (LayoutObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { |
98 if (descendant->isSVGInlineText()) | 98 if (descendant->isSVGInlineText()) |
99 attributes.append(toRenderSVGInlineText(descendant)->layoutAttribute
s()); | 99 attributes.append(toRenderSVGInlineText(descendant)->layoutAttribute
s()); |
100 } | 100 } |
101 } | 101 } |
102 | 102 |
103 static inline bool findPreviousAndNextAttributes(RenderSVGText* root, RenderSVGI
nlineText* locateElement, SVGTextLayoutAttributes*& previous, SVGTextLayoutAttri
butes*& next) | 103 static inline bool findPreviousAndNextAttributes(RenderSVGText* root, RenderSVGI
nlineText* locateElement, SVGTextLayoutAttributes*& previous, SVGTextLayoutAttri
butes*& next) |
104 { | 104 { |
105 ASSERT(root); | 105 ASSERT(root); |
106 ASSERT(locateElement); | 106 ASSERT(locateElement); |
107 bool stopAfterNext = false; | 107 bool stopAfterNext = false; |
108 RenderObject* current = root->firstChild(); | 108 LayoutObject* current = root->firstChild(); |
109 while (current) { | 109 while (current) { |
110 if (current->isSVGInlineText()) { | 110 if (current->isSVGInlineText()) { |
111 RenderSVGInlineText* text = toRenderSVGInlineText(current); | 111 RenderSVGInlineText* text = toRenderSVGInlineText(current); |
112 if (locateElement != text) { | 112 if (locateElement != text) { |
113 if (stopAfterNext) { | 113 if (stopAfterNext) { |
114 next = text->layoutAttributes(); | 114 next = text->layoutAttributes(); |
115 return true; | 115 return true; |
116 } | 116 } |
117 | 117 |
118 previous = text->layoutAttributes(); | 118 previous = text->layoutAttributes(); |
119 } else { | 119 } else { |
120 stopAfterNext = true; | 120 stopAfterNext = true; |
121 } | 121 } |
122 } else if (current->isSVGInline()) { | 122 } else if (current->isSVGInline()) { |
123 // Descend into text content (if possible). | 123 // Descend into text content (if possible). |
124 if (RenderObject* child = toRenderSVGInline(current)->firstChild())
{ | 124 if (LayoutObject* child = toRenderSVGInline(current)->firstChild())
{ |
125 current = child; | 125 current = child; |
126 continue; | 126 continue; |
127 } | 127 } |
128 } | 128 } |
129 | 129 |
130 current = current->nextInPreOrderAfterChildren(root); | 130 current = current->nextInPreOrderAfterChildren(root); |
131 } | 131 } |
132 return false; | 132 return false; |
133 } | 133 } |
134 | 134 |
135 inline bool RenderSVGText::shouldHandleSubtreeMutations() const | 135 inline bool RenderSVGText::shouldHandleSubtreeMutations() const |
136 { | 136 { |
137 if (beingDestroyed() || !everHadLayout()) { | 137 if (beingDestroyed() || !everHadLayout()) { |
138 ASSERT(m_layoutAttributes.isEmpty()); | 138 ASSERT(m_layoutAttributes.isEmpty()); |
139 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); | 139 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); |
140 return false; | 140 return false; |
141 } | 141 } |
142 return true; | 142 return true; |
143 } | 143 } |
144 | 144 |
145 void RenderSVGText::subtreeChildWasAdded(RenderObject* child) | 145 void RenderSVGText::subtreeChildWasAdded(LayoutObject* child) |
146 { | 146 { |
147 ASSERT(child); | 147 ASSERT(child); |
148 if (!shouldHandleSubtreeMutations() || documentBeingDestroyed()) | 148 if (!shouldHandleSubtreeMutations() || documentBeingDestroyed()) |
149 return; | 149 return; |
150 | 150 |
151 // Always protect the cache before clearing text positioning elements when t
he cache will subsequently be rebuilt. | 151 // Always protect the cache before clearing text positioning elements when t
he cache will subsequently be rebuilt. |
152 FontCachePurgePreventer fontCachePurgePreventer; | 152 FontCachePurgePreventer fontCachePurgePreventer; |
153 | 153 |
154 // The positioning elements cache doesn't include the new 'child' yet. Clear
the | 154 // The positioning elements cache doesn't include the new 'child' yet. Clear
the |
155 // cache, as the next buildLayoutAttributesForTextRenderer() call rebuilds i
t. | 155 // cache, as the next buildLayoutAttributesForTextRenderer() call rebuilds i
t. |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
206 } | 206 } |
207 | 207 |
208 void RenderSVGText::willBeDestroyed() | 208 void RenderSVGText::willBeDestroyed() |
209 { | 209 { |
210 m_layoutAttributes.clear(); | 210 m_layoutAttributes.clear(); |
211 m_layoutAttributesBuilder.clearTextPositioningElements(); | 211 m_layoutAttributesBuilder.clearTextPositioningElements(); |
212 | 212 |
213 RenderSVGBlock::willBeDestroyed(); | 213 RenderSVGBlock::willBeDestroyed(); |
214 } | 214 } |
215 | 215 |
216 void RenderSVGText::subtreeChildWillBeRemoved(RenderObject* child, Vector<SVGTex
tLayoutAttributes*, 2>& affectedAttributes) | 216 void RenderSVGText::subtreeChildWillBeRemoved(LayoutObject* child, Vector<SVGTex
tLayoutAttributes*, 2>& affectedAttributes) |
217 { | 217 { |
218 ASSERT(child); | 218 ASSERT(child); |
219 if (!shouldHandleSubtreeMutations()) | 219 if (!shouldHandleSubtreeMutations()) |
220 return; | 220 return; |
221 | 221 |
222 checkLayoutAttributesConsistency(this, m_layoutAttributes); | 222 checkLayoutAttributesConsistency(this, m_layoutAttributes); |
223 | 223 |
224 // The positioning elements cache depends on the size of each text renderer
in the | 224 // The positioning elements cache depends on the size of each text renderer
in the |
225 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. | 225 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. |
226 m_layoutAttributesBuilder.clearTextPositioningElements(); | 226 m_layoutAttributesBuilder.clearTextPositioningElements(); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
261 void RenderSVGText::subtreeStyleDidChange() | 261 void RenderSVGText::subtreeStyleDidChange() |
262 { | 262 { |
263 if (!shouldHandleSubtreeMutations() || documentBeingDestroyed()) | 263 if (!shouldHandleSubtreeMutations() || documentBeingDestroyed()) |
264 return; | 264 return; |
265 | 265 |
266 checkLayoutAttributesConsistency(this, m_layoutAttributes); | 266 checkLayoutAttributesConsistency(this, m_layoutAttributes); |
267 | 267 |
268 // Only update the metrics cache, but not the text positioning element cache | 268 // Only update the metrics cache, but not the text positioning element cache |
269 // nor the layout attributes cached in the leaf #text renderers. | 269 // nor the layout attributes cached in the leaf #text renderers. |
270 FontCachePurgePreventer fontCachePurgePreventer; | 270 FontCachePurgePreventer fontCachePurgePreventer; |
271 for (RenderObject* descendant = firstChild(); descendant; descendant = desce
ndant->nextInPreOrder(this)) { | 271 for (LayoutObject* descendant = firstChild(); descendant; descendant = desce
ndant->nextInPreOrder(this)) { |
272 if (descendant->isSVGInlineText()) | 272 if (descendant->isSVGInlineText()) |
273 m_layoutAttributesBuilder.rebuildMetricsForTextRenderer(toRenderSVGI
nlineText(descendant)); | 273 m_layoutAttributesBuilder.rebuildMetricsForTextRenderer(toRenderSVGI
nlineText(descendant)); |
274 } | 274 } |
275 } | 275 } |
276 | 276 |
277 void RenderSVGText::subtreeTextDidChange(RenderSVGInlineText* text) | 277 void RenderSVGText::subtreeTextDidChange(RenderSVGInlineText* text) |
278 { | 278 { |
279 ASSERT(text); | 279 ASSERT(text); |
280 ASSERT(!beingDestroyed()); | 280 ASSERT(!beingDestroyed()); |
281 if (!everHadLayout()) { | 281 if (!everHadLayout()) { |
282 ASSERT(m_layoutAttributes.isEmpty()); | 282 ASSERT(m_layoutAttributes.isEmpty()); |
283 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); | 283 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); |
284 return; | 284 return; |
285 } | 285 } |
286 | 286 |
287 // Always protect the cache before clearing text positioning elements when t
he cache will subsequently be rebuilt. | 287 // Always protect the cache before clearing text positioning elements when t
he cache will subsequently be rebuilt. |
288 FontCachePurgePreventer fontCachePurgePreventer; | 288 FontCachePurgePreventer fontCachePurgePreventer; |
289 | 289 |
290 // The positioning elements cache depends on the size of each text renderer
in the | 290 // The positioning elements cache depends on the size of each text renderer
in the |
291 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. | 291 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. |
292 m_layoutAttributesBuilder.clearTextPositioningElements(); | 292 m_layoutAttributesBuilder.clearTextPositioningElements(); |
293 | 293 |
294 checkLayoutAttributesConsistency(this, m_layoutAttributes); | 294 checkLayoutAttributesConsistency(this, m_layoutAttributes); |
295 for (RenderObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { | 295 for (LayoutObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { |
296 if (descendant->isSVGInlineText()) | 296 if (descendant->isSVGInlineText()) |
297 m_layoutAttributesBuilder.buildLayoutAttributesForTextRenderer(toRen
derSVGInlineText(descendant)); | 297 m_layoutAttributesBuilder.buildLayoutAttributesForTextRenderer(toRen
derSVGInlineText(descendant)); |
298 } | 298 } |
299 } | 299 } |
300 | 300 |
301 static inline void updateFontInAllDescendants(RenderObject* start, SVGTextLayout
AttributesBuilder* builder = 0) | 301 static inline void updateFontInAllDescendants(LayoutObject* start, SVGTextLayout
AttributesBuilder* builder = 0) |
302 { | 302 { |
303 for (RenderObject* descendant = start; descendant; descendant = descendant->
nextInPreOrder(start)) { | 303 for (LayoutObject* descendant = start; descendant; descendant = descendant->
nextInPreOrder(start)) { |
304 if (!descendant->isSVGInlineText()) | 304 if (!descendant->isSVGInlineText()) |
305 continue; | 305 continue; |
306 RenderSVGInlineText* text = toRenderSVGInlineText(descendant); | 306 RenderSVGInlineText* text = toRenderSVGInlineText(descendant); |
307 text->updateScaledFont(); | 307 text->updateScaledFont(); |
308 if (builder) | 308 if (builder) |
309 builder->rebuildMetricsForTextRenderer(text); | 309 builder->rebuildMetricsForTextRenderer(text); |
310 } | 310 } |
311 } | 311 } |
312 | 312 |
313 void RenderSVGText::layout() | 313 void RenderSVGText::layout() |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
479 { | 479 { |
480 FloatRect paintInvalidationRect = strokeBoundingBox(); | 480 FloatRect paintInvalidationRect = strokeBoundingBox(); |
481 SVGRenderSupport::intersectPaintInvalidationRectWithResources(this, paintInv
alidationRect); | 481 SVGRenderSupport::intersectPaintInvalidationRectWithResources(this, paintInv
alidationRect); |
482 | 482 |
483 if (const ShadowList* textShadow = style()->textShadow()) | 483 if (const ShadowList* textShadow = style()->textShadow()) |
484 textShadow->adjustRectForShadow(paintInvalidationRect); | 484 textShadow->adjustRectForShadow(paintInvalidationRect); |
485 | 485 |
486 return paintInvalidationRect; | 486 return paintInvalidationRect; |
487 } | 487 } |
488 | 488 |
489 void RenderSVGText::addChild(RenderObject* child, RenderObject* beforeChild) | 489 void RenderSVGText::addChild(LayoutObject* child, LayoutObject* beforeChild) |
490 { | 490 { |
491 RenderSVGBlock::addChild(child, beforeChild); | 491 RenderSVGBlock::addChild(child, beforeChild); |
492 | 492 |
493 SVGResourcesCache::clientWasAddedToTree(child, child->style()); | 493 SVGResourcesCache::clientWasAddedToTree(child, child->style()); |
494 subtreeChildWasAdded(child); | 494 subtreeChildWasAdded(child); |
495 } | 495 } |
496 | 496 |
497 void RenderSVGText::removeChild(RenderObject* child) | 497 void RenderSVGText::removeChild(LayoutObject* child) |
498 { | 498 { |
499 SVGResourcesCache::clientWillBeRemovedFromTree(child); | 499 SVGResourcesCache::clientWillBeRemovedFromTree(child); |
500 | 500 |
501 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes; | 501 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes; |
502 FontCachePurgePreventer fontCachePurgePreventer; | 502 FontCachePurgePreventer fontCachePurgePreventer; |
503 subtreeChildWillBeRemoved(child, affectedAttributes); | 503 subtreeChildWillBeRemoved(child, affectedAttributes); |
504 RenderSVGBlock::removeChild(child); | 504 RenderSVGBlock::removeChild(child); |
505 subtreeChildWasRemoved(affectedAttributes); | 505 subtreeChildWasRemoved(affectedAttributes); |
506 } | 506 } |
507 | 507 |
508 } | 508 } |
OLD | NEW |