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 15 matching lines...) Expand all Loading... |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef FastTextAutosizer_h | 31 #ifndef FastTextAutosizer_h |
32 #define FastTextAutosizer_h | 32 #define FastTextAutosizer_h |
33 | 33 |
34 #include "core/rendering/RenderObject.h" | 34 #include "core/rendering/RenderObject.h" |
35 #include "core/rendering/RenderTable.h" | 35 #include "core/rendering/RenderTable.h" |
| 36 #include "platform/heap/Handle.h" |
36 #include "wtf/HashMap.h" | 37 #include "wtf/HashMap.h" |
37 #include "wtf/HashSet.h" | 38 #include "wtf/HashSet.h" |
38 #include "wtf/Noncopyable.h" | 39 #include "wtf/Noncopyable.h" |
39 #include "wtf/OwnPtr.h" | 40 #include "wtf/OwnPtr.h" |
40 #include "wtf/PassOwnPtr.h" | 41 #include "wtf/PassOwnPtr.h" |
41 | 42 |
42 namespace blink { | 43 namespace blink { |
43 | 44 |
44 class Document; | 45 class Document; |
45 class RenderBlock; | 46 class RenderBlock; |
46 class RenderListItem; | 47 class RenderListItem; |
47 class RenderListMarker; | 48 class RenderListMarker; |
48 | 49 |
49 // Single-pass text autosizer. Documentation at: | 50 // Single-pass text autosizer. Documentation at: |
50 // http://tinyurl.com/fasttextautosizer | 51 // http://tinyurl.com/fasttextautosizer |
51 | 52 |
52 class FastTextAutosizer FINAL { | 53 class FastTextAutosizer FINAL : public NoBaseWillBeGarbageCollectedFinalized<Fas
tTextAutosizer> { |
53 WTF_MAKE_NONCOPYABLE(FastTextAutosizer); | 54 WTF_MAKE_NONCOPYABLE(FastTextAutosizer); |
54 | |
55 public: | 55 public: |
56 static PassOwnPtr<FastTextAutosizer> create(const Document* document) | 56 static PassOwnPtrWillBeRawPtr<FastTextAutosizer> create(const Document* docu
ment) |
57 { | 57 { |
58 return adoptPtr(new FastTextAutosizer(document)); | 58 return adoptPtrWillBeNoop(new FastTextAutosizer(document)); |
59 } | 59 } |
60 static float computeAutosizedFontSize(float specifiedSize, float multiplier)
; | 60 static float computeAutosizedFontSize(float specifiedSize, float multiplier)
; |
61 | 61 |
62 void updatePageInfoInAllFrames(); | 62 void updatePageInfoInAllFrames(); |
63 void updatePageInfo(); | 63 void updatePageInfo(); |
64 void record(const RenderBlock*); | 64 void record(const RenderBlock*); |
65 void destroy(const RenderBlock*); | 65 void destroy(const RenderBlock*); |
66 void inflateListItem(RenderListItem*, RenderListMarker*); | 66 void inflateListItem(RenderListItem*, RenderListMarker*); |
67 | 67 |
| 68 void trace(Visitor*); |
| 69 |
68 class LayoutScope { | 70 class LayoutScope { |
69 public: | 71 public: |
70 explicit LayoutScope(RenderBlock*); | 72 explicit LayoutScope(RenderBlock*); |
71 ~LayoutScope(); | 73 ~LayoutScope(); |
72 protected: | 74 protected: |
73 FastTextAutosizer* m_textAutosizer; | 75 FastTextAutosizer* m_textAutosizer; |
74 RenderBlock* m_block; | 76 RenderBlock* m_block; |
75 }; | 77 }; |
76 | 78 |
77 class TableLayoutScope : LayoutScope { | 79 class TableLayoutScope : LayoutScope { |
(...skipping 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
280 const RenderBlock* deepestBlockContainingAllText(const RenderBlock*); | 282 const RenderBlock* deepestBlockContainingAllText(const RenderBlock*); |
281 // Returns the first text leaf that is in the current cluster. We attempt to
not include text | 283 // Returns the first text leaf that is in the current cluster. We attempt to
not include text |
282 // from descendant clusters but because descendant clusters may not exist, t
his is only an approximation. | 284 // from descendant clusters but because descendant clusters may not exist, t
his is only an approximation. |
283 // The TraversalDirection controls whether we return the first or the last t
ext leaf. | 285 // The TraversalDirection controls whether we return the first or the last t
ext leaf. |
284 const RenderObject* findTextLeaf(const RenderObject*, size_t&, TextLeafSearc
h); | 286 const RenderObject* findTextLeaf(const RenderObject*, size_t&, TextLeafSearc
h); |
285 BlockFlags classifyBlock(const RenderObject*, BlockFlags mask = UINT_MAX); | 287 BlockFlags classifyBlock(const RenderObject*, BlockFlags mask = UINT_MAX); |
286 #ifdef AUTOSIZING_DOM_DEBUG_INFO | 288 #ifdef AUTOSIZING_DOM_DEBUG_INFO |
287 void writeClusterDebugInfo(Cluster*); | 289 void writeClusterDebugInfo(Cluster*); |
288 #endif | 290 #endif |
289 | 291 |
290 const Document* m_document; | 292 RawPtrWillBeMember<const Document> m_document; |
291 const RenderBlock* m_firstBlockToBeginLayout; | 293 const RenderBlock* m_firstBlockToBeginLayout; |
292 #if ENABLE(ASSERT) | 294 #if ENABLE(ASSERT) |
293 BlockSet m_blocksThatHaveBegunLayout; // Used to ensure we don't compute pro
perties of a block before beginLayout() is called on it. | 295 BlockSet m_blocksThatHaveBegunLayout; // Used to ensure we don't compute pro
perties of a block before beginLayout() is called on it. |
294 #endif | 296 #endif |
295 | 297 |
296 // Clusters are created and destroyed during layout. The map key is the | 298 // Clusters are created and destroyed during layout. The map key is the |
297 // cluster root. Clusters whose roots share the same fingerprint use the | 299 // cluster root. Clusters whose roots share the same fingerprint use the |
298 // same multiplier. | 300 // same multiplier. |
299 SuperclusterMap m_superclusters; | 301 SuperclusterMap m_superclusters; |
300 ClusterStack m_clusterStack; | 302 ClusterStack m_clusterStack; |
301 FingerprintMapper m_fingerprintMapper; | 303 FingerprintMapper m_fingerprintMapper; |
302 Vector<RefPtr<RenderStyle> > m_stylesRetainedDuringLayout; | 304 Vector<RefPtr<RenderStyle> > m_stylesRetainedDuringLayout; |
303 // FIXME: All frames should share the same m_pageInfo instance. | 305 // FIXME: All frames should share the same m_pageInfo instance. |
304 PageInfo m_pageInfo; | 306 PageInfo m_pageInfo; |
305 bool m_updatePageInfoDeferred; | 307 bool m_updatePageInfoDeferred; |
306 }; | 308 }; |
307 | 309 |
308 } // namespace blink | 310 } // namespace blink |
309 | 311 |
310 #endif // FastTextAutosizer_h | 312 #endif // FastTextAutosizer_h |
OLD | NEW |