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

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

Issue 145123010: Fix supercluster logic. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Address review comment. Created 6 years, 10 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 | « Source/core/rendering/FastTextAutosizer.h ('k') | no next file » | 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 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 ASSERT(m_clusterStack.isEmpty() == block->isRenderView()); 90 ASSERT(m_clusterStack.isEmpty() == block->isRenderView());
91 91
92 if (block->isRenderView()) { 92 if (block->isRenderView()) {
93 prepareRenderViewInfo(toRenderView(block)); 93 prepareRenderViewInfo(toRenderView(block));
94 } else if (block == currentCluster()->m_root) { 94 } else if (block == currentCluster()->m_root) {
95 // Ignore beginLayout on the same block twice. 95 // Ignore beginLayout on the same block twice.
96 // This can happen with paginated overflow. 96 // This can happen with paginated overflow.
97 return; 97 return;
98 } 98 }
99 99
100 if (Cluster* cluster = maybeGetOrCreateCluster(block)) 100 if (Cluster* cluster = maybeCreateCluster(block))
101 m_clusterStack.append(cluster); 101 m_clusterStack.append(adoptPtr(cluster));
102 102
103 if (block->childrenInline()) 103 if (block->childrenInline())
104 inflate(block); 104 inflate(block);
105 } 105 }
106 106
107 void FastTextAutosizer::inflateListItem(RenderListItem* listItem, RenderListMark er* listItemMarker) 107 void FastTextAutosizer::inflateListItem(RenderListItem* listItem, RenderListMark er* listItemMarker)
108 { 108 {
109 if (!enabled()) 109 if (!enabled())
110 return; 110 return;
111 ASSERT(listItem && listItemMarker); 111 ASSERT(listItem && listItemMarker);
112 #ifndef NDEBUG 112 #ifndef NDEBUG
113 m_blocksThatHaveBegunLayout.add(listItem); 113 m_blocksThatHaveBegunLayout.add(listItem);
114 #endif 114 #endif
115 // Force the LI to be inside the DBCAT when computing the multiplier. 115 // Force the LI to be inside the DBCAT when computing the multiplier.
116 // This guarantees that the DBCAT has entered layout, so we can ask for its width. 116 // This guarantees that the DBCAT has entered layout, so we can ask for its width.
117 // It also makes sense because the list marker is autosized like a text node . 117 // It also makes sense because the list marker is autosized like a text node .
118 float multiplier = clusterMultiplier(currentCluster()); 118 float multiplier = clusterMultiplier(currentCluster());
119 119
120 applyMultiplier(listItem, multiplier); 120 applyMultiplier(listItem, multiplier);
121 applyMultiplier(listItemMarker, multiplier); 121 applyMultiplier(listItemMarker, multiplier);
122 } 122 }
123 123
124 void FastTextAutosizer::endLayout(RenderBlock* block) 124 void FastTextAutosizer::endLayout(RenderBlock* block)
125 { 125 {
126 ASSERT(enabled()); 126 ASSERT(enabled());
127 if (block->isRenderView()) {
128 m_superclusters.clear();
127 #ifndef NDEBUG 129 #ifndef NDEBUG
128 if (block->isRenderView())
129 m_blocksThatHaveBegunLayout.clear(); 130 m_blocksThatHaveBegunLayout.clear();
130 #endif 131 #endif
132 }
131 133
132 if (currentCluster()->m_root == block) 134 if (currentCluster()->m_root == block)
133 m_clusterStack.removeLast(); 135 m_clusterStack.removeLast();
134 136
135 ASSERT(m_clusterStack.isEmpty() == block->isRenderView()); 137 ASSERT(m_clusterStack.isEmpty() == block->isRenderView());
136 } 138 }
137 139
138 void FastTextAutosizer::inflate(RenderBlock* block) 140 void FastTextAutosizer::inflate(RenderBlock* block)
139 { 141 {
140 Cluster* cluster = currentCluster(); 142 Cluster* cluster = currentCluster();
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 } 188 }
187 189
188 bool FastTextAutosizer::isFingerprintingCandidate(const RenderBlock* block) 190 bool FastTextAutosizer::isFingerprintingCandidate(const RenderBlock* block)
189 { 191 {
190 // FIXME: move the logic out of TextAutosizer.cpp into this class. 192 // FIXME: move the logic out of TextAutosizer.cpp into this class.
191 return block->isRenderView() 193 return block->isRenderView()
192 || (TextAutosizer::isAutosizingContainer(block) 194 || (TextAutosizer::isAutosizingContainer(block)
193 && TextAutosizer::isIndependentDescendant(block)); 195 && TextAutosizer::isIndependentDescendant(block));
194 } 196 }
195 197
198 bool FastTextAutosizer::clusterWouldHaveEnoughTextToAutosize(const RenderBlock* root)
199 {
200 Cluster hypotheticalCluster(root, true, 0);
201 return clusterHasEnoughTextToAutosize(&hypotheticalCluster);
202 }
203
196 bool FastTextAutosizer::clusterHasEnoughTextToAutosize(Cluster* cluster) 204 bool FastTextAutosizer::clusterHasEnoughTextToAutosize(Cluster* cluster)
197 { 205 {
198 const RenderBlock* root = cluster->m_root; 206 const RenderBlock* root = cluster->m_root;
199 207
200 // TextAreas and user-modifiable areas get a free pass to autosize regardles s of text content. 208 // TextAreas and user-modifiable areas get a free pass to autosize regardles s of text content.
201 if (root->isTextArea() || (root->style() && root->style()->userModify() != R EAD_ONLY)) 209 if (root->isTextArea() || (root->style() && root->style()->userModify() != R EAD_ONLY))
202 return true; 210 return true;
203 211
204 static const float minLinesOfText = 4; 212 static const float minLinesOfText = 4;
205 if (textLength(cluster) >= root->contentLogicalWidth() * minLinesOfText) 213 if (textLength(cluster) >= root->contentLogicalWidth() * minLinesOfText)
206 return true; 214 return true;
207 215
208 return false; 216 return false;
209 } 217 }
210 218
211 float FastTextAutosizer::textLength(Cluster* cluster) 219 float FastTextAutosizer::textLength(Cluster* cluster)
212 { 220 {
213 if (cluster->m_textLength >= 0) 221 if (cluster->m_textLength >= 0)
214 return cluster->m_textLength; 222 return cluster->m_textLength;
215 223
216 float length = 0; 224 float length = 0;
217 const RenderBlock* root = cluster->m_root; 225 const RenderBlock* root = cluster->m_root;
218 bool measureLocalText = TextAutosizer::containerShouldBeAutosized(root); 226 bool measureLocalText = TextAutosizer::containerShouldBeAutosized(root);
219 RenderObject* descendant = root->nextInPreOrder(root); 227 RenderObject* descendant = root->nextInPreOrder(root);
220 while (descendant) { 228 while (descendant) {
221 // FIXME: We should skip over text from descendant clusters (see: 229 // FIXME: We should skip over text from descendant clusters (see:
222 // clusters-sufficient-text-except-in-root.html). This currently includes text 230 // clusters-sufficient-text-except-in-root.html). This currently includes text
223 // from descendant clusters. 231 // from descendant clusters.
224 232
225 if (descendant->isRenderBlock() && m_clusters.contains(toRenderBlock(des cendant))) {
226 length += textLength(m_clusters.get(toRenderBlock(descendant)));
227 descendant = descendant->nextInPreOrderAfterChildren(root);
228 continue;
229 }
230
231 if (measureLocalText && descendant->isText()) { 233 if (measureLocalText && descendant->isText()) {
232 // Note: Using text().stripWhiteSpace().length() instead of rendered TextLength() because 234 // Note: Using text().stripWhiteSpace().length() instead of rendered TextLength() because
233 // the lineboxes will not be built until layout. These values can be different. 235 // the lineboxes will not be built until layout. These values can be different.
234 length += toRenderText(descendant)->text().stripWhiteSpace().length( ) * descendant->style()->specifiedFontSize(); 236 length += toRenderText(descendant)->text().stripWhiteSpace().length( ) * descendant->style()->specifiedFontSize();
235 } 237 }
236 descendant = descendant->nextInPreOrder(root); 238 descendant = descendant->nextInPreOrder(root);
237 } 239 }
238 240
239 return cluster->m_textLength = length; 241 return cluster->m_textLength = length;
240 } 242 }
241 243
242 AtomicString FastTextAutosizer::computeFingerprint(const RenderBlock* block) 244 AtomicString FastTextAutosizer::computeFingerprint(const RenderBlock* block)
243 { 245 {
244 // FIXME(crbug.com/322340): Implement a fingerprinting algorithm. 246 // FIXME(crbug.com/322340): Implement a fingerprinting algorithm.
245 return nullAtom; 247 return nullAtom;
246 } 248 }
247 249
248 FastTextAutosizer::Cluster* FastTextAutosizer::maybeGetOrCreateCluster(const Ren derBlock* block) 250 FastTextAutosizer::Cluster* FastTextAutosizer::maybeCreateCluster(const RenderBl ock* block)
249 { 251 {
250 if (!TextAutosizer::isAutosizingContainer(block)) 252 if (!TextAutosizer::isAutosizingContainer(block))
251 return 0; 253 return 0;
252 254
253 Cluster* parentCluster = m_clusterStack.isEmpty() ? 0 : currentCluster(); 255 Cluster* parentCluster = m_clusterStack.isEmpty() ? 0 : currentCluster();
254 ASSERT(parentCluster || block->isRenderView()); 256 ASSERT(parentCluster || block->isRenderView());
255 257
256 // Create clusters to suppress / unsuppress autosizing based on containerSho uldBeAutosized. 258 // Create clusters to suppress / unsuppress autosizing based on containerSho uldBeAutosized.
257 bool containerCanAutosize = TextAutosizer::containerShouldBeAutosized(block) ; 259 bool containerCanAutosize = TextAutosizer::containerShouldBeAutosized(block) ;
258 bool parentClusterCanAutosize = parentCluster && parentCluster->m_autosize; 260 bool parentClusterCanAutosize = parentCluster && parentCluster->m_autosize;
259 bool createClusterThatMightAutosize = mightBeWiderOrNarrowerDescendant(block ) || TextAutosizer::isIndependentDescendant(block); 261 bool createClusterThatMightAutosize = mightBeWiderOrNarrowerDescendant(block ) || TextAutosizer::isIndependentDescendant(block);
260 262
261 // If the container would not alter the m_autosize bit, it doesn't need to b e a cluster. 263 // If the container would not alter the m_autosize bit, it doesn't need to b e a cluster.
262 if (!createClusterThatMightAutosize && containerCanAutosize == parentCluster CanAutosize) 264 if (!createClusterThatMightAutosize && containerCanAutosize == parentCluster CanAutosize)
263 return 0; 265 return 0;
264 266
265 ClusterMap::AddResult addResult = m_clusters.add(block, PassOwnPtr<Cluster>( )); 267 return new Cluster(block, containerCanAutosize, parentCluster, getSuperclust er(block));
268 }
269
270 FastTextAutosizer::Supercluster* FastTextAutosizer::getSupercluster(const Render Block* block)
271 {
272 AtomicString fingerprint = m_fingerprintMapper.get(block);
273 if (fingerprint.isNull())
274 return 0;
275
276 BlockSet* roots = &m_fingerprintMapper.getBlocks(fingerprint);
277 if (roots->size() < 2)
278 return 0;
279
280 SuperclusterMap::AddResult addResult = m_superclusters.add(fingerprint, Pass OwnPtr<Supercluster>());
266 if (!addResult.isNewEntry) 281 if (!addResult.isNewEntry)
267 return addResult.iterator->value.get(); 282 return addResult.iterator->value.get();
268 283
269 AtomicString fingerprint = m_fingerprintMapper.get(block); 284 Supercluster* supercluster = new Supercluster(roots);
270 if (fingerprint.isNull()) { 285 addResult.iterator->value = adoptPtr(supercluster);
271 addResult.iterator->value = adoptPtr(new Cluster(block, containerCanAuto size, parentCluster)); 286 return supercluster;
272 return addResult.iterator->value.get();
273 }
274 return addSupercluster(fingerprint, block);
275 }
276
277 // FIXME: The supercluster logic does not work yet.
278 FastTextAutosizer::Cluster* FastTextAutosizer::addSupercluster(AtomicString fing erprint, const RenderBlock* returnFor)
279 {
280 BlockSet& roots = m_fingerprintMapper.getBlocks(fingerprint);
281
282 Cluster* result = 0;
283 for (BlockSet::iterator it = roots.begin(); it != roots.end(); ++it) {
284 Cluster* cluster = new Cluster(*it, TextAutosizer::containerShouldBeAuto sized(*it), currentCluster());
285 m_clusters.set(*it, adoptPtr(cluster));
286
287 if (*it == returnFor)
288 result = cluster;
289 }
290 return result;
291 } 287 }
292 288
293 const RenderBlock* FastTextAutosizer::deepestCommonAncestor(BlockSet& blocks) 289 const RenderBlock* FastTextAutosizer::deepestCommonAncestor(BlockSet& blocks)
294 { 290 {
295 // Find the lowest common ancestor of blocks. 291 // Find the lowest common ancestor of blocks.
296 // Note: this could be improved to not be O(b*h) for b blocks and tree heigh t h. 292 // Note: this could be improved to not be O(b*h) for b blocks and tree heigh t h.
297 HashCountedSet<const RenderBlock*> ancestors; 293 HashCountedSet<const RenderBlock*> ancestors;
298 for (BlockSet::iterator it = blocks.begin(); it != blocks.end(); ++it) { 294 for (BlockSet::iterator it = blocks.begin(); it != blocks.end(); ++it) {
299 for (const RenderBlock* block = (*it); block; block = block->containingB lock()) { 295 for (const RenderBlock* block = (*it); block; block = block->containingB lock()) {
300 ancestors.add(block); 296 ancestors.add(block);
301 // The first ancestor that has all of the blocks as children wins. 297 // The first ancestor that has all of the blocks as children wins.
302 if (ancestors.count(block) == blocks.size()) 298 if (ancestors.count(block) == blocks.size())
303 return block; 299 return block;
304 } 300 }
305 } 301 }
306 ASSERT_NOT_REACHED(); 302 ASSERT_NOT_REACHED();
307 return 0; 303 return 0;
308 } 304 }
309 305
310 float FastTextAutosizer::clusterMultiplier(Cluster* cluster) 306 float FastTextAutosizer::clusterMultiplier(Cluster* cluster)
311 { 307 {
312 ASSERT(m_renderViewInfoPrepared); 308 ASSERT(m_renderViewInfoPrepared);
313 if (!cluster->m_multiplier) { 309 if (!cluster->m_multiplier) {
314 if (TextAutosizer::isIndependentDescendant(cluster->m_root) || isWiderDe scendant(cluster) || isNarrowerDescendant(cluster)) { 310 if (TextAutosizer::isIndependentDescendant(cluster->m_root) || isWiderDe scendant(cluster) || isNarrowerDescendant(cluster)) {
315 if (clusterHasEnoughTextToAutosize(cluster)) { 311 if (cluster->m_supercluster) {
316 const RenderBlock* deepestBlockWithAllText = deepestBlockContain ingAllText(cluster); 312 cluster->m_multiplier = superclusterMultiplier(cluster->m_superc luster);
317 313 } else if (clusterHasEnoughTextToAutosize(cluster)) {
318 // Ensure the deepest block containing all text has a valid cont entLogicalWidth. 314 cluster->m_multiplier = multiplierFromBlock(deepestBlockContaini ngAllText(cluster));
319 ASSERT(m_blocksThatHaveBegunLayout.contains(deepestBlockWithAllT ext));
320
321 // Block width, in CSS pixels.
322 float textBlockWidth = deepestBlockWithAllText->contentLogicalWi dth();
323 float multiplier = min(textBlockWidth, static_cast<float>(m_layo utWidth)) / m_frameWidth;
324 cluster->m_multiplier = max(m_baseMultiplier * multiplier, 1.0f) ;
325 } else { 315 } else {
326 cluster->m_multiplier = 1.0f; 316 cluster->m_multiplier = 1.0f;
327 } 317 }
328 } else { 318 } else {
329 cluster->m_multiplier = cluster->m_parent ? clusterMultiplier(cluste r->m_parent) : 1.0f; 319 cluster->m_multiplier = cluster->m_parent ? clusterMultiplier(cluste r->m_parent) : 1.0f;
330 } 320 }
331 } 321 }
332 ASSERT(cluster->m_multiplier); 322 ASSERT(cluster->m_multiplier);
333 return cluster->m_multiplier; 323 return cluster->m_multiplier;
334 } 324 }
335 325
326 float FastTextAutosizer::superclusterMultiplier(Supercluster* supercluster)
327 {
328 if (!supercluster->m_multiplier) {
329 const BlockSet* roots = supercluster->m_roots;
330 // Set of the deepest block containing all text (DBCAT) of every cluster .
331 BlockSet dbcats;
332 for (BlockSet::iterator it = roots->begin(); it != roots->end(); ++it) {
333 dbcats.add(deepestBlockContainingAllText(*it));
334 supercluster->m_anyClusterHasEnoughText |= clusterWouldHaveEnoughTex tToAutosize(*it);
335 }
336 supercluster->m_multiplier = supercluster->m_anyClusterHasEnoughText
337 ? multiplierFromBlock(deepestCommonAncestor(dbcats)) : 1.0f;
338 }
339 ASSERT(supercluster->m_multiplier);
340 return supercluster->m_multiplier;
341 }
342
343 float FastTextAutosizer::multiplierFromBlock(const RenderBlock* block)
344 {
345 // If block->needsLayout() is false, it does not need to be in m_blocksThatH aveBegunLayout.
346 // This can happen during layout of a positioned object if the cluster's DBC AT is deeper
347 // than the positioned object's containing block, and wasn't marked as needi ng layout.
348 ASSERT(m_blocksThatHaveBegunLayout.contains(block) || !block->needsLayout()) ;
349
350 // Block width, in CSS pixels.
351 float textBlockWidth = block->contentLogicalWidth();
352 float multiplier = min(textBlockWidth, static_cast<float>(m_layoutWidth)) / m_frameWidth;
353
354 return max(m_baseMultiplier * multiplier, 1.0f);
355 }
356
357 const RenderBlock* FastTextAutosizer::deepestBlockContainingAllText(Cluster* clu ster)
358 {
359 if (!cluster->m_deepestBlockContainingAllText)
360 cluster->m_deepestBlockContainingAllText = deepestBlockContainingAllText (cluster->m_root);
361
362 return cluster->m_deepestBlockContainingAllText;
363 }
364
336 // FIXME: Refactor this to look more like FastTextAutosizer::deepestCommonAncest or. This is copied 365 // FIXME: Refactor this to look more like FastTextAutosizer::deepestCommonAncest or. This is copied
337 // from TextAutosizer::findDeepestBlockContainingAllText. 366 // from TextAutosizer::findDeepestBlockContainingAllText.
338 const RenderBlock* FastTextAutosizer::deepestBlockContainingAllText(Cluster* clu ster) 367 const RenderBlock* FastTextAutosizer::deepestBlockContainingAllText(const Render Block* root)
339 { 368 {
340 if (cluster->m_deepestBlockContainingAllText)
341 return cluster->m_deepestBlockContainingAllText;
342
343 size_t firstDepth = 0; 369 size_t firstDepth = 0;
344 const RenderObject* firstTextLeaf = findTextLeaf(cluster->m_root, firstDepth , First); 370 const RenderObject* firstTextLeaf = findTextLeaf(root, firstDepth, First);
345 if (!firstTextLeaf) 371 if (!firstTextLeaf)
346 return cluster->m_deepestBlockContainingAllText = cluster->m_root; 372 return root;
347 373
348 size_t lastDepth = 0; 374 size_t lastDepth = 0;
349 const RenderObject* lastTextLeaf = findTextLeaf(cluster->m_root, lastDepth, Last); 375 const RenderObject* lastTextLeaf = findTextLeaf(root, lastDepth, Last);
350 ASSERT(lastTextLeaf); 376 ASSERT(lastTextLeaf);
351 377
352 // Equalize the depths if necessary. Only one of the while loops below will get executed. 378 // Equalize the depths if necessary. Only one of the while loops below will get executed.
353 const RenderObject* firstNode = firstTextLeaf; 379 const RenderObject* firstNode = firstTextLeaf;
354 const RenderObject* lastNode = lastTextLeaf; 380 const RenderObject* lastNode = lastTextLeaf;
355 while (firstDepth > lastDepth) { 381 while (firstDepth > lastDepth) {
356 firstNode = firstNode->parent(); 382 firstNode = firstNode->parent();
357 --firstDepth; 383 --firstDepth;
358 } 384 }
359 while (lastDepth > firstDepth) { 385 while (lastDepth > firstDepth) {
360 lastNode = lastNode->parent(); 386 lastNode = lastNode->parent();
361 --lastDepth; 387 --lastDepth;
362 } 388 }
363 389
364 // Go up from both nodes until the parent is the same. Both pointers will po int to the LCA then. 390 // Go up from both nodes until the parent is the same. Both pointers will po int to the LCA then.
365 while (firstNode != lastNode) { 391 while (firstNode != lastNode) {
366 firstNode = firstNode->parent(); 392 firstNode = firstNode->parent();
367 lastNode = lastNode->parent(); 393 lastNode = lastNode->parent();
368 } 394 }
369 395
370 if (firstNode->isRenderBlock()) 396 if (firstNode->isRenderBlock())
371 return cluster->m_deepestBlockContainingAllText = toRenderBlock(firstNod e); 397 return toRenderBlock(firstNode);
372 398
373 // containingBlock() should never leave the cluster, since it only skips anc estors when finding 399 // containingBlock() should never leave the cluster, since it only skips anc estors when finding
374 // the container of position:absolute/fixed blocks, and those cannot exist b etween a cluster and 400 // the container of position:absolute/fixed blocks, and those cannot exist b etween a cluster and
375 // its text node's lowest common ancestor as isAutosizingCluster would have made them into their 401 // its text node's lowest common ancestor as isAutosizingCluster would have made them into their
376 // own independent cluster. 402 // own independent cluster.
377 const RenderBlock* containingBlock = firstNode->containingBlock(); 403 const RenderBlock* containingBlock = firstNode->containingBlock();
378 ASSERT(containingBlock->isDescendantOf(cluster->m_root)); 404 ASSERT(containingBlock->isDescendantOf(root));
379 405
380 return cluster->m_deepestBlockContainingAllText = containingBlock; 406 return containingBlock;
381 } 407 }
382 408
383 const RenderObject* FastTextAutosizer::findTextLeaf(const RenderObject* parent, size_t& depth, TextLeafSearch firstOrLast) 409 const RenderObject* FastTextAutosizer::findTextLeaf(const RenderObject* parent, size_t& depth, TextLeafSearch firstOrLast)
384 { 410 {
385 // List items are treated as text due to the marker. 411 // List items are treated as text due to the marker.
386 // The actual renderer for the marker (RenderListMarker) may not be in the t ree yet since it is added during layout. 412 // The actual renderer for the marker (RenderListMarker) may not be in the t ree yet since it is added during layout.
387 if (parent->isListItem()) 413 if (parent->isListItem())
388 return parent; 414 return parent;
389 415
390 if (parent->isEmpty()) 416 if (parent->isEmpty())
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 float contentWidth = cluster->m_root->contentLogicalWidth(); 486 float contentWidth = cluster->m_root->contentLogicalWidth();
461 float clusterTextWidth = parentDeepestBlockContainingAllText->contentLogical Width(); 487 float clusterTextWidth = parentDeepestBlockContainingAllText->contentLogical Width();
462 float widthDifference = clusterTextWidth - contentWidth; 488 float widthDifference = clusterTextWidth - contentWidth;
463 489
464 return widthDifference > narrowWidthDifference; 490 return widthDifference > narrowWidthDifference;
465 } 491 }
466 492
467 FastTextAutosizer::Cluster* FastTextAutosizer::currentCluster() const 493 FastTextAutosizer::Cluster* FastTextAutosizer::currentCluster() const
468 { 494 {
469 ASSERT(!m_clusterStack.isEmpty()); 495 ASSERT(!m_clusterStack.isEmpty());
470 return m_clusterStack.last(); 496 return m_clusterStack.last().get();
471 } 497 }
472 498
473 void FastTextAutosizer::FingerprintMapper::add(const RenderBlock* block, AtomicS tring fingerprint) 499 void FastTextAutosizer::FingerprintMapper::add(const RenderBlock* block, AtomicS tring fingerprint)
474 { 500 {
475 m_fingerprints.set(block, fingerprint); 501 m_fingerprints.set(block, fingerprint);
476 502
477 ReverseFingerprintMap::AddResult addResult = m_blocksForFingerprint.add(fing erprint, PassOwnPtr<BlockSet>()); 503 ReverseFingerprintMap::AddResult addResult = m_blocksForFingerprint.add(fing erprint, PassOwnPtr<BlockSet>());
478 if (addResult.isNewEntry) 504 if (addResult.isNewEntry)
479 addResult.iterator->value = adoptPtr(new BlockSet); 505 addResult.iterator->value = adoptPtr(new BlockSet);
480 addResult.iterator->value->add(block); 506 addResult.iterator->value->add(block);
(...skipping 23 matching lines...) Expand all
504 } 530 }
505 531
506 RenderObject* FastTextAutosizer::nextChildSkippingChildrenOfBlocks(const RenderO bject* current, const RenderObject* stayWithin) 532 RenderObject* FastTextAutosizer::nextChildSkippingChildrenOfBlocks(const RenderO bject* current, const RenderObject* stayWithin)
507 { 533 {
508 if (current == stayWithin || !current->isRenderBlock()) 534 if (current == stayWithin || !current->isRenderBlock())
509 return current->nextInPreOrder(stayWithin); 535 return current->nextInPreOrder(stayWithin);
510 return current->nextInPreOrderAfterChildren(stayWithin); 536 return current->nextInPreOrderAfterChildren(stayWithin);
511 } 537 }
512 538
513 } // namespace WebCore 539 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698