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 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
72 { | 72 { |
73 return child->isSVGInline() || (child->isText() && SVGLayoutSupport::isLayou
tableTextNode(child)); | 73 return child->isSVGInline() || (child->isText() && SVGLayoutSupport::isLayou
tableTextNode(child)); |
74 } | 74 } |
75 | 75 |
76 LayoutSVGText* LayoutSVGText::locateLayoutSVGTextAncestor(LayoutObject* start) | 76 LayoutSVGText* LayoutSVGText::locateLayoutSVGTextAncestor(LayoutObject* start) |
77 { | 77 { |
78 ASSERT(start); | 78 ASSERT(start); |
79 while (start && !start->isSVGText()) | 79 while (start && !start->isSVGText()) |
80 start = start->parent(); | 80 start = start->parent(); |
81 if (!start || !start->isSVGText()) | 81 if (!start || !start->isSVGText()) |
82 return 0; | 82 return nullptr; |
83 return toLayoutSVGText(start); | 83 return toLayoutSVGText(start); |
84 } | 84 } |
85 | 85 |
86 const LayoutSVGText* LayoutSVGText::locateLayoutSVGTextAncestor(const LayoutObje
ct* start) | 86 const LayoutSVGText* LayoutSVGText::locateLayoutSVGTextAncestor(const LayoutObje
ct* start) |
87 { | 87 { |
88 ASSERT(start); | 88 ASSERT(start); |
89 while (start && !start->isSVGText()) | 89 while (start && !start->isSVGText()) |
90 start = start->parent(); | 90 start = start->parent(); |
91 if (!start || !start->isSVGText()) | 91 if (!start || !start->isSVGText()) |
92 return 0; | 92 return nullptr; |
93 return toLayoutSVGText(start); | 93 return toLayoutSVGText(start); |
94 } | 94 } |
95 | 95 |
96 static inline void collectLayoutAttributes(LayoutObject* text, Vector<SVGTextLay
outAttributes*>& attributes) | 96 static inline void collectLayoutAttributes(LayoutObject* text, Vector<SVGTextLay
outAttributes*>& attributes) |
97 { | 97 { |
98 for (LayoutObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { | 98 for (LayoutObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { |
99 if (descendant->isSVGInlineText()) | 99 if (descendant->isSVGInlineText()) |
100 attributes.append(toLayoutSVGInlineText(descendant)->layoutAttribute
s()); | 100 attributes.append(toLayoutSVGInlineText(descendant)->layoutAttribute
s()); |
101 } | 101 } |
102 } | 102 } |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
162 // Detect changes in layout attributes and only measure those text parts tha
t have changed! | 162 // Detect changes in layout attributes and only measure those text parts tha
t have changed! |
163 Vector<SVGTextLayoutAttributes*> newLayoutAttributes; | 163 Vector<SVGTextLayoutAttributes*> newLayoutAttributes; |
164 collectLayoutAttributes(this, newLayoutAttributes); | 164 collectLayoutAttributes(this, newLayoutAttributes); |
165 if (newLayoutAttributes.isEmpty()) { | 165 if (newLayoutAttributes.isEmpty()) { |
166 ASSERT(m_layoutAttributes.isEmpty()); | 166 ASSERT(m_layoutAttributes.isEmpty()); |
167 return; | 167 return; |
168 } | 168 } |
169 | 169 |
170 // Compare m_layoutAttributes with newLayoutAttributes to figure out which a
ttribute got added. | 170 // Compare m_layoutAttributes with newLayoutAttributes to figure out which a
ttribute got added. |
171 size_t size = newLayoutAttributes.size(); | 171 size_t size = newLayoutAttributes.size(); |
172 SVGTextLayoutAttributes* attributes = 0; | 172 SVGTextLayoutAttributes* attributes = nullptr; |
173 for (size_t i = 0; i < size; ++i) { | 173 for (size_t i = 0; i < size; ++i) { |
174 attributes = newLayoutAttributes[i]; | 174 attributes = newLayoutAttributes[i]; |
175 if (m_layoutAttributes.find(attributes) == kNotFound) { | 175 if (m_layoutAttributes.find(attributes) == kNotFound) { |
176 // Every time this is invoked, there's only a single new entry in th
e newLayoutAttributes list, compared to the old in m_layoutAttributes. | 176 // Every time this is invoked, there's only a single new entry in th
e newLayoutAttributes list, compared to the old in m_layoutAttributes. |
177 SVGTextLayoutAttributes* previous = 0; | 177 SVGTextLayoutAttributes* previous = nullptr; |
178 SVGTextLayoutAttributes* next = 0; | 178 SVGTextLayoutAttributes* next = nullptr; |
179 ASSERT_UNUSED(child, attributes->context() == child); | 179 ASSERT_UNUSED(child, attributes->context() == child); |
180 findPreviousAndNextAttributes(this, attributes->context(), previous,
next); | 180 findPreviousAndNextAttributes(this, attributes->context(), previous,
next); |
181 | 181 |
182 if (previous) | 182 if (previous) |
183 m_layoutAttributesBuilder.buildLayoutAttributesForText(previous-
>context()); | 183 m_layoutAttributesBuilder.buildLayoutAttributesForText(previous-
>context()); |
184 m_layoutAttributesBuilder.buildLayoutAttributesForText(attributes->c
ontext()); | 184 m_layoutAttributesBuilder.buildLayoutAttributesForText(attributes->c
ontext()); |
185 if (next) | 185 if (next) |
186 m_layoutAttributesBuilder.buildLayoutAttributesForText(next->con
text()); | 186 m_layoutAttributesBuilder.buildLayoutAttributesForText(next->con
text()); |
187 break; | 187 break; |
188 } | 188 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
223 checkLayoutAttributesConsistency(this, m_layoutAttributes); | 223 checkLayoutAttributesConsistency(this, m_layoutAttributes); |
224 | 224 |
225 // The positioning elements cache depends on the size of each text layoutObj
ect in the | 225 // The positioning elements cache depends on the size of each text layoutObj
ect in the |
226 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. | 226 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. |
227 m_layoutAttributesBuilder.clearTextPositioningElements(); | 227 m_layoutAttributesBuilder.clearTextPositioningElements(); |
228 if (m_layoutAttributes.isEmpty() || !child->isSVGInlineText()) | 228 if (m_layoutAttributes.isEmpty() || !child->isSVGInlineText()) |
229 return; | 229 return; |
230 | 230 |
231 // This logic requires that the 'text' child is still inserted in the tree. | 231 // This logic requires that the 'text' child is still inserted in the tree. |
232 LayoutSVGInlineText* text = toLayoutSVGInlineText(child); | 232 LayoutSVGInlineText* text = toLayoutSVGInlineText(child); |
233 SVGTextLayoutAttributes* previous = 0; | 233 SVGTextLayoutAttributes* previous = nullptr; |
234 SVGTextLayoutAttributes* next = 0; | 234 SVGTextLayoutAttributes* next = nullptr; |
235 if (!documentBeingDestroyed()) | 235 if (!documentBeingDestroyed()) |
236 findPreviousAndNextAttributes(this, text, previous, next); | 236 findPreviousAndNextAttributes(this, text, previous, next); |
237 | 237 |
238 if (previous) | 238 if (previous) |
239 affectedAttributes.append(previous); | 239 affectedAttributes.append(previous); |
240 if (next) | 240 if (next) |
241 affectedAttributes.append(next); | 241 affectedAttributes.append(next); |
242 | 242 |
243 size_t position = m_layoutAttributes.find(text->layoutAttributes()); | 243 size_t position = m_layoutAttributes.find(text->layoutAttributes()); |
244 ASSERT(position != kNotFound); | 244 ASSERT(position != kNotFound); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 // The positioning elements cache depends on the size of each text layoutObj
ect in the | 291 // The positioning elements cache depends on the size of each text layoutObj
ect in the |
292 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. | 292 // subtree. If this changes, clear the cache. It's going to be rebuilt below
. |
293 m_layoutAttributesBuilder.clearTextPositioningElements(); | 293 m_layoutAttributesBuilder.clearTextPositioningElements(); |
294 | 294 |
295 for (LayoutObject* 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.buildLayoutAttributesForText(toLayoutSVGIn
lineText(descendant)); | 297 m_layoutAttributesBuilder.buildLayoutAttributesForText(toLayoutSVGIn
lineText(descendant)); |
298 } | 298 } |
299 } | 299 } |
300 | 300 |
301 static inline void updateFontInAllDescendants(LayoutObject* start, SVGTextLayout
AttributesBuilder* builder = 0) | 301 static inline void updateFontInAllDescendants(LayoutObject* start, SVGTextLayout
AttributesBuilder* builder = nullptr) |
302 { | 302 { |
303 for (LayoutObject* 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 LayoutSVGInlineText* text = toLayoutSVGInlineText(descendant); | 306 LayoutSVGInlineText* text = toLayoutSVGInlineText(descendant); |
307 text->updateScaledFont(); | 307 text->updateScaledFont(); |
308 if (builder) | 308 if (builder) |
309 builder->rebuildMetricsForTextLayoutObject(text); | 309 builder->rebuildMetricsForTextLayoutObject(text); |
310 } | 310 } |
311 } | 311 } |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 SVGResourcesCache::clientWillBeRemovedFromTree(child); | 506 SVGResourcesCache::clientWillBeRemovedFromTree(child); |
507 | 507 |
508 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes; | 508 Vector<SVGTextLayoutAttributes*, 2> affectedAttributes; |
509 FontCachePurgePreventer fontCachePurgePreventer; | 509 FontCachePurgePreventer fontCachePurgePreventer; |
510 subtreeChildWillBeRemoved(child, affectedAttributes); | 510 subtreeChildWillBeRemoved(child, affectedAttributes); |
511 LayoutSVGBlock::removeChild(child); | 511 LayoutSVGBlock::removeChild(child); |
512 subtreeChildWasRemoved(affectedAttributes); | 512 subtreeChildWasRemoved(affectedAttributes); |
513 } | 513 } |
514 | 514 |
515 } | 515 } |
OLD | NEW |