OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 | 122 |
123 enum BeginLayoutBehavior { StopLayout, ContinueLayout }; | 123 enum BeginLayoutBehavior { StopLayout, ContinueLayout }; |
124 | 124 |
125 enum InflateBehavior { ThisBlockOnly, DescendToInnerBlocks }; | 125 enum InflateBehavior { ThisBlockOnly, DescendToInnerBlocks }; |
126 | 126 |
127 enum BlockFlag { | 127 enum BlockFlag { |
128 // A block that is evaluated for becoming a cluster root. | 128 // A block that is evaluated for becoming a cluster root. |
129 POTENTIAL_ROOT = 1 << 0, | 129 POTENTIAL_ROOT = 1 << 0, |
130 // A cluster root that establishes an independent multiplier. | 130 // A cluster root that establishes an independent multiplier. |
131 INDEPENDENT = 1 << 1, | 131 INDEPENDENT = 1 << 1, |
132 // A cluster root with an explicit width. These are likely to be independent
. | 132 // A cluster root with an explicit width. These are likely to be |
| 133 // independent. |
133 EXPLICIT_WIDTH = 1 << 2, | 134 EXPLICIT_WIDTH = 1 << 2, |
134 // A cluster that is wider or narrower than its parent. These also create an | 135 // A cluster that is wider or narrower than its parent. These also create an |
135 // independent multiplier, but this state cannot be determined until layout. | 136 // independent multiplier, but this state cannot be determined until layout. |
136 WIDER_OR_NARROWER = 1 << 3, | 137 WIDER_OR_NARROWER = 1 << 3, |
137 // A cluster that suppresses autosizing. | 138 // A cluster that suppresses autosizing. |
138 SUPPRESSING = 1 << 4 | 139 SUPPRESSING = 1 << 4 |
139 }; | 140 }; |
140 | 141 |
141 typedef unsigned BlockFlags; | 142 typedef unsigned BlockFlags; |
142 | 143 |
(...skipping 20 matching lines...) Expand all Loading... |
163 | 164 |
164 public: | 165 public: |
165 explicit Cluster(const LayoutBlock* root, | 166 explicit Cluster(const LayoutBlock* root, |
166 BlockFlags, | 167 BlockFlags, |
167 Cluster* parent, | 168 Cluster* parent, |
168 Supercluster* = nullptr); | 169 Supercluster* = nullptr); |
169 | 170 |
170 const LayoutBlock* const m_root; | 171 const LayoutBlock* const m_root; |
171 BlockFlags m_flags; | 172 BlockFlags m_flags; |
172 // The deepest block containing all text is computed lazily (see: | 173 // The deepest block containing all text is computed lazily (see: |
173 // deepestBlockContainingAllText). A value of 0 indicates the value has not
been computed yet. | 174 // deepestBlockContainingAllText). A value of 0 indicates the value has not |
| 175 // been computed yet. |
174 const LayoutBlock* m_deepestBlockContainingAllText; | 176 const LayoutBlock* m_deepestBlockContainingAllText; |
175 Cluster* m_parent; | 177 Cluster* m_parent; |
176 // The multiplier is computed lazily (see: clusterMultiplier) because it mus
t be calculated | 178 // The multiplier is computed lazily (see: clusterMultiplier) because it |
177 // after the lowest block containing all text has entered layout (the | 179 // must be calculated after the lowest block containing all text has entered |
178 // m_blocksThatHaveBegunLayout assertions cover this). Note: the multiplier
is still | 180 // layout (the m_blocksThatHaveBegunLayout assertions cover this). Note: the |
179 // calculated when m_autosize is false because child clusters may depend on
this multiplier. | 181 // multiplier is still calculated when m_autosize is false because child |
| 182 // clusters may depend on this multiplier. |
180 float m_multiplier; | 183 float m_multiplier; |
181 HasEnoughTextToAutosize m_hasEnoughTextToAutosize; | 184 HasEnoughTextToAutosize m_hasEnoughTextToAutosize; |
182 // A set of blocks that are similar to this block. | 185 // A set of blocks that are similar to this block. |
183 Supercluster* m_supercluster; | 186 Supercluster* m_supercluster; |
184 bool m_hasTableAncestor; | 187 bool m_hasTableAncestor; |
185 }; | 188 }; |
186 | 189 |
187 enum TextLeafSearch { First, Last }; | 190 enum TextLeafSearch { First, Last }; |
188 | 191 |
189 struct FingerprintSourceData { | 192 struct FingerprintSourceData { |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
279 const LayoutBlock* widthProvider = nullptr); | 282 const LayoutBlock* widthProvider = nullptr); |
280 bool clusterWouldHaveEnoughTextToAutosize( | 283 bool clusterWouldHaveEnoughTextToAutosize( |
281 const LayoutBlock* root, | 284 const LayoutBlock* root, |
282 const LayoutBlock* widthProvider = nullptr); | 285 const LayoutBlock* widthProvider = nullptr); |
283 Fingerprint getFingerprint(const LayoutObject*); | 286 Fingerprint getFingerprint(const LayoutObject*); |
284 Fingerprint computeFingerprint(const LayoutObject*); | 287 Fingerprint computeFingerprint(const LayoutObject*); |
285 Cluster* maybeCreateCluster(const LayoutBlock*); | 288 Cluster* maybeCreateCluster(const LayoutBlock*); |
286 Supercluster* getSupercluster(const LayoutBlock*); | 289 Supercluster* getSupercluster(const LayoutBlock*); |
287 float clusterMultiplier(Cluster*); | 290 float clusterMultiplier(Cluster*); |
288 float superclusterMultiplier(Cluster*); | 291 float superclusterMultiplier(Cluster*); |
289 // A cluster's width provider is typically the deepest block containing all te
xt. | 292 // A cluster's width provider is typically the deepest block containing all |
290 // There are exceptions, such as tables and table cells which use the table it
self for width. | 293 // text. There are exceptions, such as tables and table cells which use the |
| 294 // table itself for width. |
291 const LayoutBlock* clusterWidthProvider(const LayoutBlock*) const; | 295 const LayoutBlock* clusterWidthProvider(const LayoutBlock*) const; |
292 const LayoutBlock* maxClusterWidthProvider( | 296 const LayoutBlock* maxClusterWidthProvider( |
293 const Supercluster*, | 297 const Supercluster*, |
294 const LayoutBlock* currentRoot) const; | 298 const LayoutBlock* currentRoot) const; |
295 // Typically this returns a block's computed width. In the case of tables layo
ut, this | 299 // Typically this returns a block's computed width. In the case of tables |
296 // width is not yet known so the fixed width is used if it's available, or the
containing | 300 // layout, this width is not yet known so the fixed width is used if it's |
297 // block's width otherwise. | 301 // available, or the containing block's width otherwise. |
298 float widthFromBlock(const LayoutBlock*) const; | 302 float widthFromBlock(const LayoutBlock*) const; |
299 float multiplierFromBlock(const LayoutBlock*); | 303 float multiplierFromBlock(const LayoutBlock*); |
300 void applyMultiplier(LayoutObject*, | 304 void applyMultiplier(LayoutObject*, |
301 float, | 305 float, |
302 SubtreeLayoutScope*, | 306 SubtreeLayoutScope*, |
303 RelayoutBehavior = AlreadyInLayout); | 307 RelayoutBehavior = AlreadyInLayout); |
304 bool isWiderOrNarrowerDescendant(Cluster*); | 308 bool isWiderOrNarrowerDescendant(Cluster*); |
305 Cluster* currentCluster() const; | 309 Cluster* currentCluster() const; |
306 const LayoutBlock* deepestBlockContainingAllText(Cluster*); | 310 const LayoutBlock* deepestBlockContainingAllText(Cluster*); |
307 const LayoutBlock* deepestBlockContainingAllText(const LayoutBlock*) const; | 311 const LayoutBlock* deepestBlockContainingAllText(const LayoutBlock*) const; |
308 // Returns the first text leaf that is in the current cluster. We attempt to n
ot include text | 312 // Returns the first text leaf that is in the current cluster. We attempt to |
309 // from descendant clusters but because descendant clusters may not exist, thi
s is only an approximation. | 313 // not include text from descendant clusters but because descendant clusters |
310 // The TraversalDirection controls whether we return the first or the last tex
t leaf. | 314 // may not exist, this is only an approximation. The TraversalDirection |
| 315 // controls whether we return the first or the last text leaf. |
311 const LayoutObject* findTextLeaf(const LayoutObject*, | 316 const LayoutObject* findTextLeaf(const LayoutObject*, |
312 size_t&, | 317 size_t&, |
313 TextLeafSearch) const; | 318 TextLeafSearch) const; |
314 BlockFlags classifyBlock(const LayoutObject*, | 319 BlockFlags classifyBlock(const LayoutObject*, |
315 BlockFlags mask = UINT_MAX) const; | 320 BlockFlags mask = UINT_MAX) const; |
316 #ifdef AUTOSIZING_DOM_DEBUG_INFO | 321 #ifdef AUTOSIZING_DOM_DEBUG_INFO |
317 void writeClusterDebugInfo(Cluster*); | 322 void writeClusterDebugInfo(Cluster*); |
318 #endif | 323 #endif |
319 | 324 |
320 Member<const Document> m_document; | 325 Member<const Document> m_document; |
321 const LayoutBlock* m_firstBlockToBeginLayout; | 326 const LayoutBlock* m_firstBlockToBeginLayout; |
322 #if ENABLE(ASSERT) | 327 #if ENABLE(ASSERT) |
323 BlockSet | 328 // Used to ensure we don't compute properties of a block before beginLayout() |
324 m_blocksThatHaveBegunLayout; // Used to ensure we don't compute propertie
s of a block before beginLayout() is called on it. | 329 // is called on it. |
| 330 BlockSet m_blocksThatHaveBegunLayout; |
325 #endif | 331 #endif |
326 | 332 |
327 // Clusters are created and destroyed during layout. The map key is the | 333 // Clusters are created and destroyed during layout. The map key is the |
328 // cluster root. Clusters whose roots share the same fingerprint use the | 334 // cluster root. Clusters whose roots share the same fingerprint use the |
329 // same multiplier. | 335 // same multiplier. |
330 SuperclusterMap m_superclusters; | 336 SuperclusterMap m_superclusters; |
331 ClusterStack m_clusterStack; | 337 ClusterStack m_clusterStack; |
332 FingerprintMapper m_fingerprintMapper; | 338 FingerprintMapper m_fingerprintMapper; |
333 Vector<RefPtr<ComputedStyle>> m_stylesRetainedDuringLayout; | 339 Vector<RefPtr<ComputedStyle>> m_stylesRetainedDuringLayout; |
334 // FIXME: All frames should share the same m_pageInfo instance. | 340 // FIXME: All frames should share the same m_pageInfo instance. |
335 PageInfo m_pageInfo; | 341 PageInfo m_pageInfo; |
336 bool m_updatePageInfoDeferred; | 342 bool m_updatePageInfoDeferred; |
337 }; | 343 }; |
338 | 344 |
339 } // namespace blink | 345 } // namespace blink |
340 | 346 |
341 #endif // TextAutosizer_h | 347 #endif // TextAutosizer_h |
OLD | NEW |