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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
179 collectLayoutAttributes(text, newLayoutAttributes); | 179 collectLayoutAttributes(text, newLayoutAttributes); |
180 ASSERT(newLayoutAttributes == expectedLayoutAttributes); | 180 ASSERT(newLayoutAttributes == expectedLayoutAttributes); |
181 #endif | 181 #endif |
182 } | 182 } |
183 | 183 |
184 void LayoutSVGText::layout() | 184 void LayoutSVGText::layout() |
185 { | 185 { |
186 ASSERT(needsLayout()); | 186 ASSERT(needsLayout()); |
187 LayoutAnalyzer::Scope analyzer(*this); | 187 LayoutAnalyzer::Scope analyzer(*this); |
188 | 188 |
189 bool updateCachedBoundariesInParents = false; | 189 bool updateParentBoundaries = false; |
190 if (m_needsTransformUpdate) { | 190 if (m_needsTransformUpdate) { |
191 m_localTransform = toSVGTextElement(node())->calculateAnimatedLocalTrans form(); | 191 m_localTransform = toSVGTextElement(node())->calculateAnimatedLocalTrans form(); |
192 m_needsTransformUpdate = false; | 192 m_needsTransformUpdate = false; |
193 updateCachedBoundariesInParents = true; | 193 updateParentBoundaries = true; |
194 } | 194 } |
195 | 195 |
196 // This flag is set and reset as needed only within this function. | |
197 ASSERT(!m_needsReordering); | |
f(malita)
2016/04/29 17:50:54
Nit: can we move the assert either at the beginnin
fs
2016/04/29 19:43:26
Moved to beginning.
| |
198 | |
199 // When laying out initially, build the character data map and propagate | |
200 // resulting layout attributes to all LayoutSVGInlineText children in the | |
201 // subtree. | |
196 if (!everHadLayout()) { | 202 if (!everHadLayout()) { |
197 // When laying out initially, collect all layout attributes, build the c haracter data map, | 203 m_needsPositioningValuesUpdate = true; |
198 // and propogate resulting SVGLayoutAttributes to all LayoutSVGInlineTex t children in the subtree. | 204 m_needsTextMetricsUpdate = true; |
199 ASSERT(m_layoutAttributes.isEmpty()); | 205 } |
200 collectLayoutAttributes(this, m_layoutAttributes); | 206 |
f(malita)
2016/04/29 17:50:54
I guess updateFontMetrics() doesn't depend on coll
fs
2016/04/29 19:43:26
Correct.
| |
207 // If the root layout size changed (eg. window size changes), or the screen | |
208 // scale factor has changed, then recompute the on-screen font size. Since | |
209 // the computation of layout attributes uses the text metrics, we need to | |
210 // update them before updating the layout attributes. | |
211 if (m_needsTextMetricsUpdate || SVGLayoutSupport::findTreeRootObject(this)-> isLayoutSizeChanged()) { | |
201 updateFontAndMetrics(*this); | 212 updateFontAndMetrics(*this); |
213 m_needsTextMetricsUpdate = false; | |
214 updateParentBoundaries = true; | |
215 } | |
202 | 216 |
203 SVGTextLayoutAttributesBuilder(*this).buildLayoutAttributes(); | 217 // When the x/y/dx/dy/rotate lists change, we need to recompute the layout |
204 | 218 // attributes. |
205 m_needsReordering = true; | 219 if (m_needsPositioningValuesUpdate) { |
206 m_needsTextMetricsUpdate = false; | |
207 m_needsPositioningValuesUpdate = false; | |
208 updateCachedBoundariesInParents = true; | |
209 } else if (m_needsPositioningValuesUpdate) { | |
210 // When the x/y/dx/dy/rotate lists change, recompute the layout attribut es, and eventually | |
211 // update the on-screen font objects as well in all descendants. | |
212 if (m_needsTextMetricsUpdate) { | |
213 updateFontAndMetrics(*this); | |
214 m_needsTextMetricsUpdate = false; | |
215 } | |
216 | |
217 m_layoutAttributes.clear(); | 220 m_layoutAttributes.clear(); |
218 collectLayoutAttributes(this, m_layoutAttributes); | 221 collectLayoutAttributes(this, m_layoutAttributes); |
219 | 222 |
220 SVGTextLayoutAttributesBuilder(*this).buildLayoutAttributes(); | 223 SVGTextLayoutAttributesBuilder(*this).buildLayoutAttributes(); |
221 | 224 |
225 m_needsPositioningValuesUpdate = false; | |
222 m_needsReordering = true; | 226 m_needsReordering = true; |
223 m_needsPositioningValuesUpdate = false; | 227 updateParentBoundaries = true; |
f(malita)
2016/04/29 17:50:54
Can we use a TemporaryChange<bool> in the outer sc
fs
2016/04/29 19:43:26
Didn't look too shabby, but m_needsReordering is a
| |
224 updateCachedBoundariesInParents = true; | |
225 } else if (m_needsTextMetricsUpdate || SVGLayoutSupport::findTreeRootObject( this)->isLayoutSizeChanged()) { | |
226 // If the root layout size changed (eg. window size changes), or the scr een scale factor has | |
227 // changed, then recompute the on-screen font size. | |
228 updateFontAndMetrics(*this); | |
229 | |
230 ASSERT(!m_needsReordering); | |
231 ASSERT(!m_needsPositioningValuesUpdate); | |
232 m_needsTextMetricsUpdate = false; | |
233 updateCachedBoundariesInParents = true; | |
234 } | 228 } |
235 | 229 |
236 checkLayoutAttributesConsistency(this, m_layoutAttributes); | 230 checkLayoutAttributesConsistency(this, m_layoutAttributes); |
237 | 231 |
238 // Reduced version of LayoutBlock::layoutBlock(), which only takes care of S VG text. | 232 // Reduced version of LayoutBlock::layoutBlock(), which only takes care of S VG text. |
239 // All if branches that could cause early exit in LayoutBlocks layoutBlock() method are turned into assertions. | 233 // All if branches that could cause early exit in LayoutBlocks layoutBlock() method are turned into assertions. |
240 ASSERT(!isInline()); | 234 ASSERT(!isInline()); |
241 ASSERT(!simplifiedLayout()); | 235 ASSERT(!simplifiedLayout()); |
242 ASSERT(!scrollsOverflow()); | 236 ASSERT(!scrollsOverflow()); |
243 ASSERT(!hasControlClip()); | 237 ASSERT(!hasControlClip()); |
(...skipping 12 matching lines...) Expand all Loading... | |
256 LayoutUnit beforeEdge = borderBefore() + paddingBefore(); | 250 LayoutUnit beforeEdge = borderBefore() + paddingBefore(); |
257 LayoutUnit afterEdge = borderAfter() + paddingAfter() + scrollbarLogicalHeig ht(); | 251 LayoutUnit afterEdge = borderAfter() + paddingAfter() + scrollbarLogicalHeig ht(); |
258 setLogicalHeight(beforeEdge); | 252 setLogicalHeight(beforeEdge); |
259 | 253 |
260 LayoutState state(*this, locationOffset()); | 254 LayoutState state(*this, locationOffset()); |
261 LayoutUnit paintInvalidationLogicalTop; | 255 LayoutUnit paintInvalidationLogicalTop; |
262 LayoutUnit paintInvalidationLogicalBottom; | 256 LayoutUnit paintInvalidationLogicalBottom; |
263 layoutInlineChildren(true, paintInvalidationLogicalTop, paintInvalidationLog icalBottom, afterEdge); | 257 layoutInlineChildren(true, paintInvalidationLogicalTop, paintInvalidationLog icalBottom, afterEdge); |
264 | 258 |
265 if (m_needsReordering) | 259 if (m_needsReordering) |
266 m_needsReordering = false; | 260 m_needsReordering = false; |
f(malita)
2016/04/29 17:50:54
Nit: make this unconditional?
fs
2016/04/29 19:43:26
Done.
| |
267 | 261 |
268 // If we don't have any line boxes, then make sure the frame rect is still c leared. | 262 // If we don't have any line boxes, then make sure the frame rect is still c leared. |
269 if (!firstLineBox()) | 263 if (!firstLineBox()) |
270 setFrameRect(LayoutRect()); | 264 setFrameRect(LayoutRect()); |
271 | 265 |
272 m_overflow.clear(); | 266 m_overflow.clear(); |
273 addVisualEffectOverflow(); | 267 addVisualEffectOverflow(); |
274 | 268 |
275 if (!updateCachedBoundariesInParents) | 269 if (!updateParentBoundaries) |
276 updateCachedBoundariesInParents = oldBoundaries != objectBoundingBox(); | 270 updateParentBoundaries = oldBoundaries != objectBoundingBox(); |
277 | 271 |
278 // Invalidate all resources of this client if our layout changed. | 272 // Invalidate all resources of this client if our layout changed. |
279 if (everHadLayout() && selfNeedsLayout()) | 273 if (everHadLayout() && selfNeedsLayout()) |
280 SVGResourcesCache::clientLayoutChanged(this); | 274 SVGResourcesCache::clientLayoutChanged(this); |
281 | 275 |
282 // If our bounds changed, notify the parents. | 276 // If our bounds changed, notify the parents. |
283 if (updateCachedBoundariesInParents) | 277 if (updateParentBoundaries) |
284 LayoutSVGBlock::setNeedsBoundariesUpdate(); | 278 LayoutSVGBlock::setNeedsBoundariesUpdate(); |
285 | 279 |
280 ASSERT(!m_needsReordering); | |
281 ASSERT(!m_needsTransformUpdate); | |
282 ASSERT(!m_needsTextMetricsUpdate); | |
283 ASSERT(!m_needsPositioningValuesUpdate); | |
286 clearNeedsLayout(); | 284 clearNeedsLayout(); |
287 } | 285 } |
288 | 286 |
289 RootInlineBox* LayoutSVGText::createRootInlineBox() | 287 RootInlineBox* LayoutSVGText::createRootInlineBox() |
290 { | 288 { |
291 RootInlineBox* box = new SVGRootInlineBox(LineLayoutItem(this)); | 289 RootInlineBox* box = new SVGRootInlineBox(LineLayoutItem(this)); |
292 box->setHasVirtualLogicalHeight(); | 290 box->setHasVirtualLogicalHeight(); |
293 return box; | 291 return box; |
294 } | 292 } |
295 | 293 |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
417 paintInvalidationState.pushDelayedPaintInvalidationTarget(*this); | 415 paintInvalidationState.pushDelayedPaintInvalidationTarget(*this); |
418 | 416 |
419 if (reason == PaintInvalidationSVGResourceChange) | 417 if (reason == PaintInvalidationSVGResourceChange) |
420 newPaintInvalidationState.setForceSubtreeInvalidationWithinContainer(); | 418 newPaintInvalidationState.setForceSubtreeInvalidationWithinContainer(); |
421 | 419 |
422 newPaintInvalidationState.updateForChildren(); | 420 newPaintInvalidationState.updateForChildren(); |
423 invalidatePaintOfSubtreesIfNeeded(newPaintInvalidationState); | 421 invalidatePaintOfSubtreesIfNeeded(newPaintInvalidationState); |
424 } | 422 } |
425 | 423 |
426 } // namespace blink | 424 } // namespace blink |
OLD | NEW |