Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(446)

Side by Side Diff: Source/core/rendering/FastTextAutosizer.h

Issue 209353003: Clean up handling of autosizing state changes. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@crap_base
Patch Set: Address review comments. Created 6 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
53 53
54 class FastTextAutosizer FINAL { 54 class FastTextAutosizer FINAL {
55 WTF_MAKE_NONCOPYABLE(FastTextAutosizer); 55 WTF_MAKE_NONCOPYABLE(FastTextAutosizer);
56 56
57 public: 57 public:
58 static PassOwnPtr<FastTextAutosizer> create(const Document* document) 58 static PassOwnPtr<FastTextAutosizer> create(const Document* document)
59 { 59 {
60 return adoptPtr(new FastTextAutosizer(document)); 60 return adoptPtr(new FastTextAutosizer(document));
61 } 61 }
62 62
63 void updatePageInfoInAllFrames();
64 void updatePageInfo();
63 void record(const RenderBlock*); 65 void record(const RenderBlock*);
64 void destroy(const RenderBlock*); 66 void destroy(const RenderBlock*);
65 void inflateListItem(RenderListItem*, RenderListMarker*); 67 void inflateListItem(RenderListItem*, RenderListMarker*);
66 68
67 class LayoutScope { 69 class LayoutScope {
68 public: 70 public:
69 explicit LayoutScope(RenderBlock*); 71 explicit LayoutScope(RenderBlock*);
70 ~LayoutScope(); 72 ~LayoutScope();
71 private: 73 private:
72 FastTextAutosizer* m_textAutosizer; 74 FastTextAutosizer* m_textAutosizer;
73 RenderBlock* m_block; 75 RenderBlock* m_block;
74 }; 76 };
75 77
76 private: 78 private:
77 typedef HashSet<const RenderBlock*> BlockSet; 79 typedef HashSet<const RenderBlock*> BlockSet;
78 80
79 enum HasEnoughTextToAutosize { 81 enum HasEnoughTextToAutosize {
80 UnknownAmountOfText, 82 UnknownAmountOfText,
81 HasEnoughText, 83 HasEnoughText,
82 NotEnoughText 84 NotEnoughText
83 }; 85 };
84 86
85 enum PageAutosizingStatus {
86 PageAutosizingStatusUnknown,
87 PageNeedsAutosizing,
88 PageDoesNotNeedAutosizing
89 };
90
91 // A supercluster represents autosizing information about a set of two or 87 // A supercluster represents autosizing information about a set of two or
92 // more blocks that all have the same fingerprint. Clusters whose roots 88 // more blocks that all have the same fingerprint. Clusters whose roots
93 // belong to a supercluster will share a common multiplier and 89 // belong to a supercluster will share a common multiplier and
94 // text-length-based autosizing status. 90 // text-length-based autosizing status.
95 struct Supercluster { 91 struct Supercluster {
96 explicit Supercluster(const BlockSet* roots) 92 explicit Supercluster(const BlockSet* roots)
97 : m_roots(roots) 93 : m_roots(roots)
98 , m_multiplier(0) 94 , m_multiplier(0)
99 { 95 {
100 } 96 }
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 #endif 179 #endif
184 }; 180 };
185 181
186 explicit FastTextAutosizer(const Document*); 182 explicit FastTextAutosizer(const Document*);
187 183
188 void beginLayout(RenderBlock*); 184 void beginLayout(RenderBlock*);
189 void endLayout(RenderBlock*); 185 void endLayout(RenderBlock*);
190 void inflateTable(RenderTable*); 186 void inflateTable(RenderTable*);
191 void inflate(RenderBlock*); 187 void inflate(RenderBlock*);
192 bool enabled(); 188 bool enabled();
193 void updateRenderViewInfo(); 189 void setAllTextNeedsLayout();
190 void resetMultipliers();
194 void prepareClusterStack(const RenderObject*); 191 void prepareClusterStack(const RenderObject*);
195 bool isFingerprintingCandidate(const RenderBlock*); 192 bool isFingerprintingCandidate(const RenderBlock*);
196 bool clusterHasEnoughTextToAutosize(Cluster*, const RenderBlock* widthProvid er = 0); 193 bool clusterHasEnoughTextToAutosize(Cluster*, const RenderBlock* widthProvid er = 0);
197 bool anyClusterHasEnoughTextToAutosize(const BlockSet* roots, const RenderBl ock* widthProvider = 0); 194 bool anyClusterHasEnoughTextToAutosize(const BlockSet* roots, const RenderBl ock* widthProvider = 0);
198 bool clusterWouldHaveEnoughTextToAutosize(const RenderBlock* root, const Ren derBlock* widthProvider = 0); 195 bool clusterWouldHaveEnoughTextToAutosize(const RenderBlock* root, const Ren derBlock* widthProvider = 0);
199 Fingerprint getFingerprint(const RenderObject*); 196 Fingerprint getFingerprint(const RenderObject*);
200 Fingerprint computeFingerprint(const RenderObject*); 197 Fingerprint computeFingerprint(const RenderObject*);
201 Cluster* maybeCreateCluster(const RenderBlock*); 198 Cluster* maybeCreateCluster(const RenderBlock*);
202 Supercluster* getSupercluster(const RenderBlock*); 199 Supercluster* getSupercluster(const RenderBlock*);
203 const RenderBlock* deepestCommonAncestor(BlockSet&); 200 const RenderBlock* deepestCommonAncestor(BlockSet&);
204 float clusterMultiplier(Cluster*); 201 float clusterMultiplier(Cluster*);
205 float superclusterMultiplier(Cluster*); 202 float superclusterMultiplier(Cluster*);
206 // A cluster's width provider is typically the deepest block containing all text. 203 // A cluster's width provider is typically the deepest block containing all text.
207 // There are exceptions, such as tables and table cells which use the table itself for width. 204 // There are exceptions, such as tables and table cells which use the table itself for width.
208 const RenderBlock* clusterWidthProvider(const RenderBlock*); 205 const RenderBlock* clusterWidthProvider(const RenderBlock*);
209 // Typically this returns a block's computed width. In the case of tables la yout, this 206 // Typically this returns a block's computed width. In the case of tables la yout, this
210 // width is not yet known so the fixed width is used if it's available, or t he containing 207 // width is not yet known so the fixed width is used if it's available, or t he containing
211 // block's width otherwise. 208 // block's width otherwise.
212 float widthFromBlock(const RenderBlock*); 209 float widthFromBlock(const RenderBlock*);
213 float multiplierFromBlock(const RenderBlock*); 210 float multiplierFromBlock(const RenderBlock*);
214 void applyMultiplier(RenderObject*, float); 211 void applyMultiplier(RenderObject*, float, bool relayout = false);
pdr. 2014/03/25 04:23:41 Can you use an enum here instead of a bool?
skobes 2014/03/25 18:25:26 Done.
215 bool isWiderOrNarrowerDescendant(Cluster*); 212 bool isWiderOrNarrowerDescendant(Cluster*);
216 bool isLayoutRoot(const RenderBlock*) const; 213 bool isLayoutRoot(const RenderBlock*) const;
217 214
218 Cluster* currentCluster() const; 215 Cluster* currentCluster() const;
219 216
220 RenderObject* nextChildSkippingChildrenOfBlocks(const RenderObject*, const R enderObject*); 217 RenderObject* nextChildSkippingChildrenOfBlocks(const RenderObject*, const R enderObject*);
221 218
222 const RenderBlock* deepestBlockContainingAllText(Cluster*); 219 const RenderBlock* deepestBlockContainingAllText(Cluster*);
223 const RenderBlock* deepestBlockContainingAllText(const RenderBlock*); 220 const RenderBlock* deepestBlockContainingAllText(const RenderBlock*);
224 // Returns the first text leaf that is in the current cluster. We attempt to not include text 221 // Returns the first text leaf that is in the current cluster. We attempt to not include text
225 // from descendant clusters but because descendant clusters may not exist, t his is only an approximation. 222 // from descendant clusters but because descendant clusters may not exist, t his is only an approximation.
226 // The TraversalDirection controls whether we return the first or the last t ext leaf. 223 // The TraversalDirection controls whether we return the first or the last t ext leaf.
227 const RenderObject* findTextLeaf(const RenderObject*, size_t&, TextLeafSearc h); 224 const RenderObject* findTextLeaf(const RenderObject*, size_t&, TextLeafSearc h);
228 225
229 const Document* m_document; 226 const Document* m_document;
230 int m_frameWidth; // LocalFrame width in density-independent pixels (DIPs). 227 int m_frameWidth; // LocalFrame width in density-independent pixels (DIPs).
231 int m_layoutWidth; // Layout width in CSS pixels. 228 int m_layoutWidth; // Layout width in CSS pixels.
232 float m_baseMultiplier; // Includes accessibility font scale factor and devi ce scale adjustment. 229 float m_baseMultiplier; // Includes accessibility font scale factor and devi ce scale adjustment.
233 PageAutosizingStatus m_pageAutosizingStatus; 230 bool m_pageNeedsAutosizing;
231 bool m_previouslyAutosized;
232 bool m_updatePageInfoDeferred;
pdr. 2014/03/25 04:23:41 m_updatePageInfoDeferred isn't used in this patch.
skobes 2014/03/25 18:25:26 Done.
234 const RenderBlock* m_firstBlock; // First block to receive beginLayout. 233 const RenderBlock* m_firstBlock; // First block to receive beginLayout.
235 #ifndef NDEBUG 234 #ifndef NDEBUG
236 bool m_renderViewInfoPrepared;
237 BlockSet m_blocksThatHaveBegunLayout; // Used to ensure we don't compute pro perties of a block before beginLayout() is called on it. 235 BlockSet m_blocksThatHaveBegunLayout; // Used to ensure we don't compute pro perties of a block before beginLayout() is called on it.
238 #endif 236 #endif
239 237
240 // Clusters are created and destroyed during layout. The map key is the 238 // Clusters are created and destroyed during layout. The map key is the
241 // cluster root. Clusters whose roots share the same fingerprint use the 239 // cluster root. Clusters whose roots share the same fingerprint use the
242 // same multiplier. 240 // same multiplier.
243 SuperclusterMap m_superclusters; 241 SuperclusterMap m_superclusters;
244 ClusterStack m_clusterStack; 242 ClusterStack m_clusterStack;
245 FingerprintMapper m_fingerprintMapper; 243 FingerprintMapper m_fingerprintMapper;
246 }; 244 };
247 245
248 } // namespace WebCore 246 } // namespace WebCore
249 247
250 #endif // FastTextAutosizer_h 248 #endif // FastTextAutosizer_h
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698