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 14 matching lines...) Expand all Loading... |
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
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 TextAutosizer_h | 31 #ifndef TextAutosizer_h |
32 #define TextAutosizer_h | 32 #define TextAutosizer_h |
33 | 33 |
34 #include "core/CoreExport.h" | 34 #include "core/CoreExport.h" |
35 #include "core/layout/LayoutObject.h" | |
36 #include "core/layout/LayoutTable.h" | |
37 #include "platform/heap/Handle.h" | 35 #include "platform/heap/Handle.h" |
38 #include "wtf/HashMap.h" | 36 #include "wtf/HashMap.h" |
39 #include "wtf/HashSet.h" | 37 #include "wtf/HashSet.h" |
40 #include "wtf/Noncopyable.h" | 38 #include "wtf/Noncopyable.h" |
41 #include "wtf/OwnPtr.h" | 39 #include "wtf/OwnPtr.h" |
42 #include "wtf/PassOwnPtr.h" | 40 |
| 41 #include <unicode/uchar.h> |
43 | 42 |
44 namespace blink { | 43 namespace blink { |
45 | 44 |
| 45 class ComputedStyle; |
46 class Document; | 46 class Document; |
| 47 class IntSize; |
| 48 class LayoutBlock; |
47 class LayoutListItem; | 49 class LayoutListItem; |
48 class LayoutListMarker; | 50 class LayoutListMarker; |
49 class LayoutBlock; | 51 class LayoutObject; |
| 52 class LayoutTable; |
| 53 class LocalFrame; |
| 54 class Page; |
50 class SubtreeLayoutScope; | 55 class SubtreeLayoutScope; |
51 | 56 |
52 // Single-pass text autosizer. Documentation at: | 57 // Single-pass text autosizer. Documentation at: |
53 // http://tinyurl.com/TextAutosizer | 58 // http://tinyurl.com/TextAutosizer |
54 | 59 |
55 class CORE_EXPORT TextAutosizer final : public GarbageCollectedFinalized<TextAut
osizer> { | 60 class CORE_EXPORT TextAutosizer final : public GarbageCollectedFinalized<TextAut
osizer> { |
56 WTF_MAKE_NONCOPYABLE(TextAutosizer); | 61 WTF_MAKE_NONCOPYABLE(TextAutosizer); |
57 public: | 62 public: |
58 static TextAutosizer* create(const Document* document) | 63 ~TextAutosizer(); |
59 { | 64 static TextAutosizer* create(const Document* document) { return new TextAuto
sizer(document); } |
60 return new TextAutosizer(document); | |
61 } | |
62 static float computeAutosizedFontSize(float specifiedSize, float multiplier)
; | 65 static float computeAutosizedFontSize(float specifiedSize, float multiplier)
; |
63 | 66 |
64 void updatePageInfoInAllFrames(); | 67 void updatePageInfoInAllFrames(); |
65 void updatePageInfo(); | 68 void updatePageInfo(); |
66 void record(const LayoutBlock*); | 69 void record(const LayoutBlock*); |
67 void destroy(const LayoutBlock*); | 70 void destroy(const LayoutBlock*); |
68 | 71 |
69 bool pageNeedsAutosizing() const; | 72 bool pageNeedsAutosizing() const; |
70 | 73 |
71 DECLARE_TRACE(); | 74 DECLARE_TRACE(); |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
150 } | 153 } |
151 | 154 |
152 const BlockSet* const m_roots; | 155 const BlockSet* const m_roots; |
153 HasEnoughTextToAutosize m_hasEnoughTextToAutosize; | 156 HasEnoughTextToAutosize m_hasEnoughTextToAutosize; |
154 float m_multiplier; | 157 float m_multiplier; |
155 }; | 158 }; |
156 | 159 |
157 struct Cluster { | 160 struct Cluster { |
158 USING_FAST_MALLOC(Cluster); | 161 USING_FAST_MALLOC(Cluster); |
159 public: | 162 public: |
160 explicit Cluster(const LayoutBlock* root, BlockFlags flags, Cluster* par
ent, Supercluster* supercluster = nullptr) | 163 explicit Cluster(const LayoutBlock* root, BlockFlags, Cluster* parent, S
upercluster* = nullptr); |
161 : m_root(root) | |
162 , m_flags(flags) | |
163 , m_deepestBlockContainingAllText(nullptr) | |
164 , m_parent(parent) | |
165 , m_multiplier(0) | |
166 , m_hasEnoughTextToAutosize(UnknownAmountOfText) | |
167 , m_supercluster(supercluster) | |
168 , m_hasTableAncestor(root->isTableCell() || (m_parent && m_parent->m
_hasTableAncestor)) | |
169 { | |
170 } | |
171 | 164 |
172 const LayoutBlock* const m_root; | 165 const LayoutBlock* const m_root; |
173 BlockFlags m_flags; | 166 BlockFlags m_flags; |
174 // The deepest block containing all text is computed lazily (see: | 167 // The deepest block containing all text is computed lazily (see: |
175 // deepestBlockContainingAllText). A value of 0 indicates the value has
not been computed yet. | 168 // deepestBlockContainingAllText). A value of 0 indicates the value has
not been computed yet. |
176 const LayoutBlock* m_deepestBlockContainingAllText; | 169 const LayoutBlock* m_deepestBlockContainingAllText; |
177 Cluster* m_parent; | 170 Cluster* m_parent; |
178 // The multiplier is computed lazily (see: clusterMultiplier) because it
must be calculated | 171 // The multiplier is computed lazily (see: clusterMultiplier) because it
must be calculated |
179 // after the lowest block containing all text has entered layout (the | 172 // after the lowest block containing all text has entered layout (the |
180 // m_blocksThatHaveBegunLayout assertions cover this). Note: the multipl
ier is still | 173 // m_blocksThatHaveBegunLayout assertions cover this). Note: the multipl
ier is still |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
318 FingerprintMapper m_fingerprintMapper; | 311 FingerprintMapper m_fingerprintMapper; |
319 Vector<RefPtr<ComputedStyle>> m_stylesRetainedDuringLayout; | 312 Vector<RefPtr<ComputedStyle>> m_stylesRetainedDuringLayout; |
320 // FIXME: All frames should share the same m_pageInfo instance. | 313 // FIXME: All frames should share the same m_pageInfo instance. |
321 PageInfo m_pageInfo; | 314 PageInfo m_pageInfo; |
322 bool m_updatePageInfoDeferred; | 315 bool m_updatePageInfoDeferred; |
323 }; | 316 }; |
324 | 317 |
325 } // namespace blink | 318 } // namespace blink |
326 | 319 |
327 #endif // TextAutosizer_h | 320 #endif // TextAutosizer_h |
OLD | NEW |