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 21 matching lines...) Expand all Loading... |
32 #include "core/layout/LayoutAnalyzer.h" | 32 #include "core/layout/LayoutAnalyzer.h" |
33 #include "core/layout/LayoutState.h" | 33 #include "core/layout/LayoutState.h" |
34 #include "core/layout/LayoutView.h" | 34 #include "core/layout/LayoutView.h" |
35 #include "core/layout/PointerEventsHitRules.h" | 35 #include "core/layout/PointerEventsHitRules.h" |
36 #include "core/layout/api/LineLayoutItem.h" | 36 #include "core/layout/api/LineLayoutItem.h" |
37 #include "core/layout/svg/LayoutSVGInline.h" | 37 #include "core/layout/svg/LayoutSVGInline.h" |
38 #include "core/layout/svg/LayoutSVGInlineText.h" | 38 #include "core/layout/svg/LayoutSVGInlineText.h" |
39 #include "core/layout/svg/LayoutSVGRoot.h" | 39 #include "core/layout/svg/LayoutSVGRoot.h" |
40 #include "core/layout/svg/SVGLayoutSupport.h" | 40 #include "core/layout/svg/SVGLayoutSupport.h" |
41 #include "core/layout/svg/SVGResourcesCache.h" | 41 #include "core/layout/svg/SVGResourcesCache.h" |
| 42 #include "core/layout/svg/SVGTextLayoutAttributesBuilder.h" |
42 #include "core/layout/svg/line/SVGRootInlineBox.h" | 43 #include "core/layout/svg/line/SVGRootInlineBox.h" |
43 #include "core/paint/SVGTextPainter.h" | 44 #include "core/paint/SVGTextPainter.h" |
44 #include "core/style/ShadowList.h" | 45 #include "core/style/ShadowList.h" |
45 #include "core/svg/SVGLengthList.h" | 46 #include "core/svg/SVGLengthList.h" |
46 #include "core/svg/SVGTextElement.h" | 47 #include "core/svg/SVGTextElement.h" |
47 #include "core/svg/SVGTransformList.h" | 48 #include "core/svg/SVGTransformList.h" |
48 #include "core/svg/SVGURIReference.h" | 49 #include "core/svg/SVGURIReference.h" |
49 #include "platform/FloatConversion.h" | 50 #include "platform/FloatConversion.h" |
50 #include "platform/geometry/FloatQuad.h" | 51 #include "platform/geometry/FloatQuad.h" |
51 | 52 |
(...skipping 23 matching lines...) Expand all Loading... |
75 } | 76 } |
76 | 77 |
77 LayoutSVGText::~LayoutSVGText() | 78 LayoutSVGText::~LayoutSVGText() |
78 { | 79 { |
79 ASSERT(m_layoutAttributes.isEmpty()); | 80 ASSERT(m_layoutAttributes.isEmpty()); |
80 } | 81 } |
81 | 82 |
82 void LayoutSVGText::willBeDestroyed() | 83 void LayoutSVGText::willBeDestroyed() |
83 { | 84 { |
84 m_layoutAttributes.clear(); | 85 m_layoutAttributes.clear(); |
85 m_layoutAttributesBuilder.clearTextPositioningElements(); | |
86 | 86 |
87 LayoutSVGBlock::willBeDestroyed(); | 87 LayoutSVGBlock::willBeDestroyed(); |
88 } | 88 } |
89 | 89 |
90 bool LayoutSVGText::isChildAllowed(LayoutObject* child, const ComputedStyle&) co
nst | 90 bool LayoutSVGText::isChildAllowed(LayoutObject* child, const ComputedStyle&) co
nst |
91 { | 91 { |
92 return child->isSVGInline() || (child->isText() && SVGLayoutSupport::isLayou
tableTextNode(child)); | 92 return child->isSVGInline() || (child->isText() && SVGLayoutSupport::isLayou
tableTextNode(child)); |
93 } | 93 } |
94 | 94 |
95 LayoutSVGText* LayoutSVGText::locateLayoutSVGTextAncestor(LayoutObject* start) | 95 LayoutSVGText* LayoutSVGText::locateLayoutSVGTextAncestor(LayoutObject* start) |
(...skipping 10 matching lines...) Expand all Loading... |
106 { | 106 { |
107 for (LayoutObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { | 107 for (LayoutObject* descendant = text; descendant; descendant = descendant->n
extInPreOrder(text)) { |
108 if (descendant->isSVGInlineText()) | 108 if (descendant->isSVGInlineText()) |
109 attributes.append(toLayoutSVGInlineText(descendant)->layoutAttribute
s()); | 109 attributes.append(toLayoutSVGInlineText(descendant)->layoutAttribute
s()); |
110 } | 110 } |
111 } | 111 } |
112 | 112 |
113 void LayoutSVGText::invalidatePositioningValues(LayoutInvalidationReasonForTraci
ng reason) | 113 void LayoutSVGText::invalidatePositioningValues(LayoutInvalidationReasonForTraci
ng reason) |
114 { | 114 { |
115 m_layoutAttributes.clear(); | 115 m_layoutAttributes.clear(); |
116 m_layoutAttributesBuilder.clearTextPositioningElements(); | |
117 setNeedsPositioningValuesUpdate(); | 116 setNeedsPositioningValuesUpdate(); |
118 setNeedsLayoutAndFullPaintInvalidation(reason); | 117 setNeedsLayoutAndFullPaintInvalidation(reason); |
119 } | 118 } |
120 | 119 |
121 void LayoutSVGText::subtreeChildWasAdded() | 120 void LayoutSVGText::subtreeChildWasAdded() |
122 { | 121 { |
123 if (beingDestroyed() || !everHadLayout()) { | 122 if (beingDestroyed() || !everHadLayout()) { |
124 ASSERT(m_layoutAttributes.isEmpty()); | 123 ASSERT(m_layoutAttributes.isEmpty()); |
125 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); | |
126 return; | 124 return; |
127 } | 125 } |
128 if (documentBeingDestroyed()) | 126 if (documentBeingDestroyed()) |
129 return; | 127 return; |
130 | 128 |
131 // The positioning elements cache depends on the size of each text layoutObj
ect in the | 129 // The positioning elements cache depends on the size of each text layoutObj
ect in the |
132 // subtree. If this changes, clear the cache. It will be rebuilt on the next
layout. | 130 // subtree. If this changes, clear the cache. It will be rebuilt on the next
layout. |
133 invalidatePositioningValues(LayoutInvalidationReason::ChildChanged); | 131 invalidatePositioningValues(LayoutInvalidationReason::ChildChanged); |
134 setNeedsTextMetricsUpdate(); | 132 setNeedsTextMetricsUpdate(); |
135 } | 133 } |
136 | 134 |
137 void LayoutSVGText::subtreeChildWillBeRemoved() | 135 void LayoutSVGText::subtreeChildWillBeRemoved() |
138 { | 136 { |
139 if (beingDestroyed() || !everHadLayout()) { | 137 if (beingDestroyed() || !everHadLayout()) { |
140 ASSERT(m_layoutAttributes.isEmpty()); | 138 ASSERT(m_layoutAttributes.isEmpty()); |
141 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); | |
142 return; | 139 return; |
143 } | 140 } |
144 | 141 |
145 // The positioning elements cache depends on the size of each text layoutObj
ect in the | 142 // The positioning elements cache depends on the size of each text layoutObj
ect in the |
146 // subtree. If this changes, clear the cache. It will be rebuilt on the next
layout. | 143 // subtree. If this changes, clear the cache. It will be rebuilt on the next
layout. |
147 invalidatePositioningValues(LayoutInvalidationReason::ChildChanged); | 144 invalidatePositioningValues(LayoutInvalidationReason::ChildChanged); |
148 setNeedsTextMetricsUpdate(); | 145 setNeedsTextMetricsUpdate(); |
149 } | 146 } |
150 | 147 |
151 void LayoutSVGText::subtreeTextDidChange() | 148 void LayoutSVGText::subtreeTextDidChange() |
152 { | 149 { |
153 ASSERT(!beingDestroyed()); | 150 ASSERT(!beingDestroyed()); |
154 if (!everHadLayout()) { | 151 if (!everHadLayout()) { |
155 ASSERT(m_layoutAttributes.isEmpty()); | 152 ASSERT(m_layoutAttributes.isEmpty()); |
156 ASSERT(!m_layoutAttributesBuilder.numberOfTextPositioningElements()); | |
157 return; | 153 return; |
158 } | 154 } |
159 | 155 |
160 // The positioning elements cache depends on the size of each text object in | 156 // The positioning elements cache depends on the size of each text object in |
161 // the subtree. If this changes, clear the cache and mark it for rebuilding | 157 // the subtree. If this changes, clear the cache and mark it for rebuilding |
162 // in the next layout. | 158 // in the next layout. |
163 invalidatePositioningValues(LayoutInvalidationReason::TextChanged); | 159 invalidatePositioningValues(LayoutInvalidationReason::TextChanged); |
164 setNeedsTextMetricsUpdate(); | 160 setNeedsTextMetricsUpdate(); |
165 } | 161 } |
166 | 162 |
(...skipping 29 matching lines...) Expand all Loading... |
196 m_needsTransformUpdate = false; | 192 m_needsTransformUpdate = false; |
197 updateCachedBoundariesInParents = true; | 193 updateCachedBoundariesInParents = true; |
198 } | 194 } |
199 | 195 |
200 if (!everHadLayout()) { | 196 if (!everHadLayout()) { |
201 // When laying out initially, collect all layout attributes, build the c
haracter data map, | 197 // When laying out initially, collect all layout attributes, build the c
haracter data map, |
202 // and propogate resulting SVGLayoutAttributes to all LayoutSVGInlineTex
t children in the subtree. | 198 // and propogate resulting SVGLayoutAttributes to all LayoutSVGInlineTex
t children in the subtree. |
203 ASSERT(m_layoutAttributes.isEmpty()); | 199 ASSERT(m_layoutAttributes.isEmpty()); |
204 collectLayoutAttributes(this, m_layoutAttributes); | 200 collectLayoutAttributes(this, m_layoutAttributes); |
205 updateFontAndMetrics(*this); | 201 updateFontAndMetrics(*this); |
206 m_layoutAttributesBuilder.buildLayoutAttributesForTextRoot(*this); | 202 |
| 203 SVGTextLayoutAttributesBuilder(*this).buildLayoutAttributes(); |
207 | 204 |
208 m_needsReordering = true; | 205 m_needsReordering = true; |
209 m_needsTextMetricsUpdate = false; | 206 m_needsTextMetricsUpdate = false; |
210 m_needsPositioningValuesUpdate = false; | 207 m_needsPositioningValuesUpdate = false; |
211 updateCachedBoundariesInParents = true; | 208 updateCachedBoundariesInParents = true; |
212 } else if (m_needsPositioningValuesUpdate) { | 209 } else if (m_needsPositioningValuesUpdate) { |
213 // When the x/y/dx/dy/rotate lists change, recompute the layout attribut
es, and eventually | 210 // When the x/y/dx/dy/rotate lists change, recompute the layout attribut
es, and eventually |
214 // update the on-screen font objects as well in all descendants. | 211 // update the on-screen font objects as well in all descendants. |
215 if (m_needsTextMetricsUpdate) { | 212 if (m_needsTextMetricsUpdate) { |
216 updateFontAndMetrics(*this); | 213 updateFontAndMetrics(*this); |
217 m_needsTextMetricsUpdate = false; | 214 m_needsTextMetricsUpdate = false; |
218 } | 215 } |
219 | 216 |
220 m_layoutAttributes.clear(); | 217 m_layoutAttributes.clear(); |
221 collectLayoutAttributes(this, m_layoutAttributes); | 218 collectLayoutAttributes(this, m_layoutAttributes); |
222 m_layoutAttributesBuilder.buildLayoutAttributesForTextRoot(*this); | 219 |
| 220 SVGTextLayoutAttributesBuilder(*this).buildLayoutAttributes(); |
| 221 |
223 m_needsReordering = true; | 222 m_needsReordering = true; |
224 m_needsPositioningValuesUpdate = false; | 223 m_needsPositioningValuesUpdate = false; |
225 updateCachedBoundariesInParents = true; | 224 updateCachedBoundariesInParents = true; |
226 } else if (m_needsTextMetricsUpdate || SVGLayoutSupport::findTreeRootObject(
this)->isLayoutSizeChanged()) { | 225 } else if (m_needsTextMetricsUpdate || SVGLayoutSupport::findTreeRootObject(
this)->isLayoutSizeChanged()) { |
227 // If the root layout size changed (eg. window size changes) or the tran
sform to the root | 226 // If the root layout size changed (eg. window size changes) or the tran
sform to the root |
228 // context has changed then recompute the on-screen font size. | 227 // context has changed then recompute the on-screen font size. |
229 updateFontAndMetrics(*this); | 228 updateFontAndMetrics(*this); |
230 | 229 |
231 ASSERT(!m_needsReordering); | 230 ASSERT(!m_needsReordering); |
232 ASSERT(!m_needsPositioningValuesUpdate); | 231 ASSERT(!m_needsPositioningValuesUpdate); |
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
418 paintInvalidationState.pushDelayedPaintInvalidationTarget(*this); | 417 paintInvalidationState.pushDelayedPaintInvalidationTarget(*this); |
419 | 418 |
420 if (reason == PaintInvalidationSVGResourceChange) | 419 if (reason == PaintInvalidationSVGResourceChange) |
421 newPaintInvalidationState.setForceSubtreeInvalidationWithinContainer(); | 420 newPaintInvalidationState.setForceSubtreeInvalidationWithinContainer(); |
422 | 421 |
423 newPaintInvalidationState.updateForChildren(); | 422 newPaintInvalidationState.updateForChildren(); |
424 invalidatePaintOfSubtreesIfNeeded(newPaintInvalidationState); | 423 invalidatePaintOfSubtreesIfNeeded(newPaintInvalidationState); |
425 } | 424 } |
426 | 425 |
427 } // namespace blink | 426 } // namespace blink |
OLD | NEW |