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

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

Issue 180743004: Disable FTA when max multiplier is 1. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Rebaseline. 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
« no previous file with comments | « no previous file | Source/core/rendering/FastTextAutosizer.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 { 60 {
61 return adoptPtr(new FastTextAutosizer(document)); 61 return adoptPtr(new FastTextAutosizer(document));
62 } 62 }
63 63
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 class LayoutScope { 68 class LayoutScope {
69 public: 69 public:
70 explicit LayoutScope(Document& document, RenderBlock* block) 70 explicit LayoutScope(RenderBlock*);
71 : m_block(0) 71 ~LayoutScope();
72 {
73 m_textAutosizer = document.fastTextAutosizer();
74 if (m_textAutosizer) {
75 if (!m_textAutosizer->enabled()) {
76 m_textAutosizer = 0;
77 return;
78 }
79 m_block = block;
80 m_textAutosizer->beginLayout(m_block);
81 }
82 }
83
84 ~LayoutScope()
85 {
86 if (m_textAutosizer)
87 m_textAutosizer->endLayout(m_block);
88 }
89 private: 72 private:
90 FastTextAutosizer* m_textAutosizer; 73 FastTextAutosizer* m_textAutosizer;
91 RenderBlock* m_block; 74 RenderBlock* m_block;
92 }; 75 };
93 76
94 private: 77 private:
95 typedef HashSet<const RenderBlock*> BlockSet; 78 typedef HashSet<const RenderBlock*> BlockSet;
96 79
97 enum HasEnoughTextToAutosize { 80 enum HasEnoughTextToAutosize {
98 Unknown, 81 UnknownAmountOfText,
99 Yes, 82 HasEnoughText,
100 No 83 NotEnoughText
84 };
85
86 enum PageAutosizingStatus {
87 PageAutosizingStatusUnknown,
88 PageNeedsAutosizing,
89 PageDoesNotNeedAutosizing
101 }; 90 };
102 91
103 // A supercluster represents autosizing information about a set of two or 92 // A supercluster represents autosizing information about a set of two or
104 // more blocks that all have the same fingerprint. Clusters whose roots 93 // more blocks that all have the same fingerprint. Clusters whose roots
105 // belong to a supercluster will share a common multiplier and 94 // belong to a supercluster will share a common multiplier and
106 // text-length-based autosizing status. 95 // text-length-based autosizing status.
107 struct Supercluster { 96 struct Supercluster {
108 explicit Supercluster(const BlockSet* roots) 97 explicit Supercluster(const BlockSet* roots)
109 : m_roots(roots) 98 : m_roots(roots)
110 , m_multiplier(0) 99 , m_multiplier(0)
111 { 100 {
112 } 101 }
113 102
114 const BlockSet* const m_roots; 103 const BlockSet* const m_roots;
115 float m_multiplier; 104 float m_multiplier;
116 }; 105 };
117 106
118 struct Cluster { 107 struct Cluster {
119 explicit Cluster(const RenderBlock* root, bool autosize, Cluster* parent , Supercluster* supercluster = 0) 108 explicit Cluster(const RenderBlock* root, bool autosize, Cluster* parent , Supercluster* supercluster = 0)
120 : m_root(root) 109 : m_root(root)
121 , m_deepestBlockContainingAllText(0) 110 , m_deepestBlockContainingAllText(0)
122 , m_parent(parent) 111 , m_parent(parent)
123 , m_autosize(autosize) 112 , m_autosize(autosize)
124 , m_multiplier(0) 113 , m_multiplier(0)
125 , m_hasEnoughTextToAutosize(Unknown) 114 , m_hasEnoughTextToAutosize(UnknownAmountOfText)
126 , m_supercluster(supercluster) 115 , m_supercluster(supercluster)
127 , m_hasTableAncestor(root->isTableCell() || (m_parent && m_parent->m _hasTableAncestor)) 116 , m_hasTableAncestor(root->isTableCell() || (m_parent && m_parent->m _hasTableAncestor))
128 { 117 {
129 } 118 }
130 119
131 const RenderBlock* const m_root; 120 const RenderBlock* const m_root;
132 // The deepest block containing all text is computed lazily (see: 121 // The deepest block containing all text is computed lazily (see:
133 // deepestBlockContainingAllText). A value of 0 indicates the value has not been computed yet. 122 // deepestBlockContainingAllText). A value of 0 indicates the value has not been computed yet.
134 const RenderBlock* m_deepestBlockContainingAllText; 123 const RenderBlock* m_deepestBlockContainingAllText;
135 Cluster* m_parent; 124 Cluster* m_parent;
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 ReverseFingerprintMap m_blocksForFingerprint; 179 ReverseFingerprintMap m_blocksForFingerprint;
191 }; 180 };
192 181
193 explicit FastTextAutosizer(const Document*); 182 explicit FastTextAutosizer(const Document*);
194 183
195 void beginLayout(RenderBlock*); 184 void beginLayout(RenderBlock*);
196 void endLayout(RenderBlock*); 185 void endLayout(RenderBlock*);
197 void inflateTable(RenderTable*); 186 void inflateTable(RenderTable*);
198 void inflate(RenderBlock*); 187 void inflate(RenderBlock*);
199 bool enabled(); 188 bool enabled();
200 void prepareRenderViewInfo(); 189 void updateRenderViewInfo();
201 void prepareClusterStack(const RenderObject*); 190 void prepareClusterStack(const RenderObject*);
202 bool isFingerprintingCandidate(const RenderBlock*); 191 bool isFingerprintingCandidate(const RenderBlock*);
203 bool clusterHasEnoughTextToAutosize(Cluster*, const RenderBlock* widthProvid er = 0); 192 bool clusterHasEnoughTextToAutosize(Cluster*, const RenderBlock* widthProvid er = 0);
204 bool clusterWouldHaveEnoughTextToAutosize(const RenderBlock* root, const Ren derBlock* widthProvider = 0); 193 bool clusterWouldHaveEnoughTextToAutosize(const RenderBlock* root, const Ren derBlock* widthProvider = 0);
205 Fingerprint getFingerprint(const RenderObject*); 194 Fingerprint getFingerprint(const RenderObject*);
206 Fingerprint computeFingerprint(const RenderObject*); 195 Fingerprint computeFingerprint(const RenderObject*);
207 Cluster* maybeCreateCluster(const RenderBlock*); 196 Cluster* maybeCreateCluster(const RenderBlock*);
208 Supercluster* getSupercluster(const RenderBlock*); 197 Supercluster* getSupercluster(const RenderBlock*);
209 const RenderBlock* deepestCommonAncestor(BlockSet&); 198 const RenderBlock* deepestCommonAncestor(BlockSet&);
210 float clusterMultiplier(Cluster*); 199 float clusterMultiplier(Cluster*);
(...skipping 19 matching lines...) Expand all
230 const RenderBlock* deepestBlockContainingAllText(const RenderBlock*); 219 const RenderBlock* deepestBlockContainingAllText(const RenderBlock*);
231 // Returns the first text leaf that is in the current cluster. We attempt to not include text 220 // Returns the first text leaf that is in the current cluster. We attempt to not include text
232 // from descendant clusters but because descendant clusters may not exist, t his is only an approximation. 221 // from descendant clusters but because descendant clusters may not exist, t his is only an approximation.
233 // The TraversalDirection controls whether we return the first or the last t ext leaf. 222 // The TraversalDirection controls whether we return the first or the last t ext leaf.
234 const RenderObject* findTextLeaf(const RenderObject*, size_t&, TextLeafSearc h); 223 const RenderObject* findTextLeaf(const RenderObject*, size_t&, TextLeafSearc h);
235 224
236 const Document* m_document; 225 const Document* m_document;
237 int m_frameWidth; // LocalFrame width in density-independent pixels (DIPs). 226 int m_frameWidth; // LocalFrame width in density-independent pixels (DIPs).
238 int m_layoutWidth; // Layout width in CSS pixels. 227 int m_layoutWidth; // Layout width in CSS pixels.
239 float m_baseMultiplier; // Includes accessibility font scale factor and devi ce scale adjustment. 228 float m_baseMultiplier; // Includes accessibility font scale factor and devi ce scale adjustment.
229 PageAutosizingStatus m_pageAutosizingStatus;
240 const RenderBlock* m_firstBlock; // First block to receive beginLayout. 230 const RenderBlock* m_firstBlock; // First block to receive beginLayout.
241 #ifndef NDEBUG 231 #ifndef NDEBUG
242 bool m_renderViewInfoPrepared; 232 bool m_renderViewInfoPrepared;
243 BlockSet m_blocksThatHaveBegunLayout; // Used to ensure we don't compute pro perties of a block before beginLayout() is called on it. 233 BlockSet m_blocksThatHaveBegunLayout; // Used to ensure we don't compute pro perties of a block before beginLayout() is called on it.
244 #endif 234 #endif
245 235
246 // Clusters are created and destroyed during layout. The map key is the 236 // Clusters are created and destroyed during layout. The map key is the
247 // cluster root. Clusters whose roots share the same fingerprint use the 237 // cluster root. Clusters whose roots share the same fingerprint use the
248 // same multiplier. 238 // same multiplier.
249 SuperclusterMap m_superclusters; 239 SuperclusterMap m_superclusters;
250 ClusterStack m_clusterStack; 240 ClusterStack m_clusterStack;
251 FingerprintMapper m_fingerprintMapper; 241 FingerprintMapper m_fingerprintMapper;
252 }; 242 };
253 243
254 } // namespace WebCore 244 } // namespace WebCore
255 245
256 #endif // FastTextAutosizer_h 246 #endif // FastTextAutosizer_h
OLDNEW
« no previous file with comments | « no previous file | Source/core/rendering/FastTextAutosizer.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698