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 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
95 } | 95 } |
96 | 96 |
97 static inline void collectLayoutAttributes(LayoutObject* text, Vector<SVGTextLay
outAttributes*>& attributes) | 97 static inline void collectLayoutAttributes(LayoutObject* text, Vector<SVGTextLay
outAttributes*>& attributes) |
98 { | 98 { |
99 for (LayoutObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { | 99 for (LayoutObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { |
100 if (descendant->isSVGInlineText()) | 100 if (descendant->isSVGInlineText()) |
101 attributes.append(toLayoutSVGInlineText(descendant)->layoutAttribute
s()); | 101 attributes.append(toLayoutSVGInlineText(descendant)->layoutAttribute
s()); |
102 } | 102 } |
103 } | 103 } |
104 | 104 |
105 inline bool LayoutSVGText::shouldHandleSubtreeMutations() const | 105 void LayoutSVGText::invalidatePositioningValues(LayoutInvalidationReasonForTraci
ng reason) |
| 106 { |
| 107 m_layoutAttributes.clear(); |
| 108 m_layoutAttributesBuilder.clearTextPositioningElements(); |
| 109 setNeedsPositioningValuesUpdate(); |
| 110 setNeedsLayoutAndFullPaintInvalidation(reason); |
| 111 } |
| 112 |
| 113 void LayoutSVGText::subtreeChildWasAdded() |
106 { | 114 { |
107 if (beingDestroyed() || !everHadLayout()) { | 115 if (beingDestroyed() || !everHadLayout()) { |
108 ASSERT(m_layoutAttributes.isEmpty()); | 116 ASSERT(m_layoutAttributes.isEmpty()); |
109 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); | 117 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); |
110 return false; | 118 return; |
111 } | 119 } |
112 return true; | 120 if (documentBeingDestroyed()) |
113 } | |
114 | |
115 void LayoutSVGText::subtreeChildWasAdded(LayoutObject*) | |
116 { | |
117 if (!shouldHandleSubtreeMutations() || documentBeingDestroyed()) | |
118 return; | 121 return; |
119 | 122 |
120 // The positioning elements cache doesn't include the new 'child' yet. Clear
the | 123 // The positioning elements cache depends on the size of each text layoutObj
ect in the |
121 // cache, as the next buildLayoutAttributesForText() call rebuilds it. | 124 // subtree. If this changes, clear the cache. It will be rebuilt on the next
layout. |
122 m_layoutAttributesBuilder.clearTextPositioningElements(); | 125 invalidatePositioningValues(LayoutInvalidationReason::ChildChanged); |
123 setNeedsPositioningValuesUpdate(); | |
124 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::ChildChange
d); | |
125 } | 126 } |
126 | 127 |
127 void LayoutSVGText::willBeDestroyed() | 128 void LayoutSVGText::willBeDestroyed() |
128 { | 129 { |
129 m_layoutAttributes.clear(); | 130 m_layoutAttributes.clear(); |
130 m_layoutAttributesBuilder.clearTextPositioningElements(); | 131 m_layoutAttributesBuilder.clearTextPositioningElements(); |
131 | 132 |
132 LayoutSVGBlock::willBeDestroyed(); | 133 LayoutSVGBlock::willBeDestroyed(); |
133 } | 134 } |
134 | 135 |
135 void LayoutSVGText::subtreeChildWillBeRemoved(LayoutObject* child) | 136 void LayoutSVGText::subtreeChildWillBeRemoved() |
136 { | 137 { |
137 ASSERT(child); | 138 if (beingDestroyed() || !everHadLayout()) { |
138 if (!shouldHandleSubtreeMutations()) | 139 ASSERT(m_layoutAttributes.isEmpty()); |
| 140 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); |
139 return; | 141 return; |
| 142 } |
140 | 143 |
141 // The positioning elements cache depends on the size of each text layoutObj
ect in the | 144 // The positioning elements cache depends on the size of each text layoutObj
ect in the |
142 // subtree. If this changes, clear the cache. It will be rebuilt below on th
e next layout. | 145 // subtree. If this changes, clear the cache. It will be rebuilt on the next
layout. |
143 m_layoutAttributesBuilder.clearTextPositioningElements(); | 146 invalidatePositioningValues(LayoutInvalidationReason::ChildChanged); |
144 setNeedsPositioningValuesUpdate(); | |
145 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::ChildChange
d); | |
146 | |
147 if (m_layoutAttributes.isEmpty() || !child->isSVGInlineText()) | |
148 return; | |
149 | |
150 // Make sure that a text node (layout attribute) reference is not left | |
151 // dangling in |m_layoutAttributes|. | |
152 size_t position = m_layoutAttributes.find(toLayoutSVGInlineText(child)->layo
utAttributes()); | |
153 ASSERT(position != kNotFound); | |
154 m_layoutAttributes.remove(position); | |
155 } | 147 } |
156 | 148 |
157 void LayoutSVGText::subtreeTextDidChange(LayoutSVGInlineText* text) | 149 void LayoutSVGText::subtreeTextDidChange() |
158 { | 150 { |
159 ASSERT(text); | |
160 ASSERT(!beingDestroyed()); | 151 ASSERT(!beingDestroyed()); |
161 if (!everHadLayout()) { | 152 if (!everHadLayout()) { |
162 ASSERT(m_layoutAttributes.isEmpty()); | 153 ASSERT(m_layoutAttributes.isEmpty()); |
163 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); | 154 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); |
164 return; | 155 return; |
165 } | 156 } |
166 | 157 |
167 // The positioning elements cache depends on the size of each text object in | 158 // The positioning elements cache depends on the size of each text object in |
168 // the subtree. If this changes, clear the cache and mark it for rebuilding | 159 // the subtree. If this changes, clear the cache and mark it for rebuilding |
169 // in the next layout. | 160 // in the next layout. |
170 m_layoutAttributesBuilder.clearTextPositioningElements(); | 161 invalidatePositioningValues(LayoutInvalidationReason::TextChanged); |
171 setNeedsPositioningValuesUpdate(); | |
172 setNeedsLayoutAndFullPaintInvalidation(LayoutInvalidationReason::TextChanged
); | |
173 } | 162 } |
174 | 163 |
175 static inline void updateFontInAllDescendants(LayoutSVGText& textRoot, SVGTextLa
youtAttributesBuilder* builder = nullptr) | 164 static inline void updateFontInAllDescendants(LayoutSVGText& textRoot, SVGTextLa
youtAttributesBuilder* builder = nullptr) |
176 { | 165 { |
177 for (LayoutObject* descendant = &textRoot; descendant; descendant = descenda
nt->nextInPreOrder(&textRoot)) { | 166 for (LayoutObject* descendant = &textRoot; descendant; descendant = descenda
nt->nextInPreOrder(&textRoot)) { |
178 if (!descendant->isSVGInlineText()) | 167 if (!descendant->isSVGInlineText()) |
179 continue; | 168 continue; |
180 LayoutSVGInlineText* text = toLayoutSVGInlineText(descendant); | 169 LayoutSVGInlineText* text = toLayoutSVGInlineText(descendant); |
181 text->updateScaledFont(); | 170 text->updateScaledFont(); |
182 if (builder) | 171 if (builder) |
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 { | 372 { |
384 // If we don't have any line boxes, then consider the bbox invalid. | 373 // If we don't have any line boxes, then consider the bbox invalid. |
385 return firstLineBox(); | 374 return firstLineBox(); |
386 } | 375 } |
387 | 376 |
388 void LayoutSVGText::addChild(LayoutObject* child, LayoutObject* beforeChild) | 377 void LayoutSVGText::addChild(LayoutObject* child, LayoutObject* beforeChild) |
389 { | 378 { |
390 LayoutSVGBlock::addChild(child, beforeChild); | 379 LayoutSVGBlock::addChild(child, beforeChild); |
391 | 380 |
392 SVGResourcesCache::clientWasAddedToTree(child, child->styleRef()); | 381 SVGResourcesCache::clientWasAddedToTree(child, child->styleRef()); |
393 subtreeChildWasAdded(child); | 382 subtreeChildWasAdded(); |
394 } | 383 } |
395 | 384 |
396 void LayoutSVGText::removeChild(LayoutObject* child) | 385 void LayoutSVGText::removeChild(LayoutObject* child) |
397 { | 386 { |
398 SVGResourcesCache::clientWillBeRemovedFromTree(child); | 387 SVGResourcesCache::clientWillBeRemovedFromTree(child); |
399 subtreeChildWillBeRemoved(child); | 388 subtreeChildWillBeRemoved(); |
400 | 389 |
401 LayoutSVGBlock::removeChild(child); | 390 LayoutSVGBlock::removeChild(child); |
402 } | 391 } |
403 | 392 |
404 void LayoutSVGText::invalidateTreeIfNeeded(const PaintInvalidationState& paintIn
validationState) | 393 void LayoutSVGText::invalidateTreeIfNeeded(const PaintInvalidationState& paintIn
validationState) |
405 { | 394 { |
406 ASSERT(!needsLayout()); | 395 ASSERT(!needsLayout()); |
407 | 396 |
408 if (!shouldCheckForPaintInvalidation(paintInvalidationState)) | 397 if (!shouldCheckForPaintInvalidation(paintInvalidationState)) |
409 return; | 398 return; |
410 | 399 |
411 PaintInvalidationState newPaintInvalidationState(paintInvalidationState, *th
is); | 400 PaintInvalidationState newPaintInvalidationState(paintInvalidationState, *th
is); |
412 PaintInvalidationReason reason = invalidatePaintIfNeeded(newPaintInvalidatio
nState); | 401 PaintInvalidationReason reason = invalidatePaintIfNeeded(newPaintInvalidatio
nState); |
413 clearPaintInvalidationFlags(newPaintInvalidationState); | 402 clearPaintInvalidationFlags(newPaintInvalidationState); |
414 | 403 |
415 if (reason == PaintInvalidationDelayedFull) | 404 if (reason == PaintInvalidationDelayedFull) |
416 paintInvalidationState.pushDelayedPaintInvalidationTarget(*this); | 405 paintInvalidationState.pushDelayedPaintInvalidationTarget(*this); |
417 | 406 |
418 if (reason == PaintInvalidationSVGResourceChange) | 407 if (reason == PaintInvalidationSVGResourceChange) |
419 newPaintInvalidationState.setForceSubtreeInvalidationWithinContainer(); | 408 newPaintInvalidationState.setForceSubtreeInvalidationWithinContainer(); |
420 | 409 |
421 newPaintInvalidationState.updateForChildren(); | 410 newPaintInvalidationState.updateForChildren(); |
422 invalidatePaintOfSubtreesIfNeeded(newPaintInvalidationState); | 411 invalidatePaintOfSubtreesIfNeeded(newPaintInvalidationState); |
423 } | 412 } |
424 | 413 |
425 } // namespace blink | 414 } // namespace blink |
OLD | NEW |