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

Unified Diff: Source/core/rendering/FastTextAutosizer.cpp

Issue 235993003: Revert "Modify supercluster multiplier logic" (http://crrev.com/231663006). (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/rendering/FastTextAutosizer.cpp
diff --git a/Source/core/rendering/FastTextAutosizer.cpp b/Source/core/rendering/FastTextAutosizer.cpp
index 55c73198ebd536bfbcf42976482ca08c61e3b9e1..8513523af46981ad79398a0cd49e07da583febae 100644
--- a/Source/core/rendering/FastTextAutosizer.cpp
+++ b/Source/core/rendering/FastTextAutosizer.cpp
@@ -701,6 +701,23 @@ FastTextAutosizer::Supercluster* FastTextAutosizer::getSupercluster(const Render
return supercluster;
}
+const RenderBlock* FastTextAutosizer::deepestCommonAncestor(BlockSet& blocks)
+{
+ // Find the lowest common ancestor of blocks.
+ // Note: this could be improved to not be O(b*h) for b blocks and tree height h.
+ HashCountedSet<const RenderBlock*> ancestors;
+ for (BlockSet::iterator it = blocks.begin(); it != blocks.end(); ++it) {
+ for (const RenderBlock* block = (*it); block; block = block->containingBlock()) {
+ ancestors.add(block);
+ // The first ancestor that has all of the blocks as children wins.
+ if (ancestors.count(block) == blocks.size())
+ return block;
+ }
+ }
+ ASSERT_NOT_REACHED();
+ return 0;
+}
+
float FastTextAutosizer::clusterMultiplier(Cluster* cluster)
{
if (cluster->m_multiplier)
@@ -768,7 +785,14 @@ float FastTextAutosizer::superclusterMultiplier(Cluster* cluster)
const BlockSet* roots = supercluster->m_roots;
const RenderBlock* widthProvider;
- widthProvider = maxClusterWidthProvider(cluster->m_supercluster, cluster->m_root);
+ if (cluster->m_root->isTableCell()) {
+ widthProvider = clusterWidthProvider(cluster->m_root);
+ } else {
+ BlockSet widthProviders;
+ for (BlockSet::iterator it = roots->begin(); it != roots->end(); ++it)
+ widthProviders.add(clusterWidthProvider(*it));
+ widthProvider = deepestCommonAncestor(widthProviders);
+ }
supercluster->m_multiplier = anyClusterHasEnoughTextToAutosize(roots, widthProvider)
? multiplierFromBlock(widthProvider) : 1.0f;
@@ -785,25 +809,6 @@ const RenderBlock* FastTextAutosizer::clusterWidthProvider(const RenderBlock* ro
return deepestBlockContainingAllText(root);
}
-
-const RenderBlock* FastTextAutosizer::maxClusterWidthProvider(const Supercluster* supercluster, const RenderBlock* currentRoot)
-{
- float maxWidth = 0;
- const RenderBlock* result = 0;
- const BlockSet* roots = supercluster->m_roots;
- for (BlockSet::iterator it = roots->begin(); it != roots->end(); ++it) {
- const RenderBlock* widthProvider = clusterWidthProvider(*it);
- if (widthProvider != currentRoot && widthProvider->needsLayout())
- continue;
- float width = widthFromBlock(widthProvider);
- if (width > maxWidth) {
- maxWidth = width;
- result = widthProvider;
- }
- }
- return result;
-}
-
float FastTextAutosizer::widthFromBlock(const RenderBlock* block)
{
if (block->isTable()) {
« 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