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

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

Issue 145003009: Autosize list markers. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@tot
Patch Set: Address review comments. Created 6 years, 11 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') | Source/core/rendering/RenderListItem.cpp » ('j') | 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 58c860cfccbaada09658da31a96483203f7d201e..04694e00f2dc9dc4c146a5c78b1ff301504ec3bc 100644
--- a/Source/core/rendering/FastTextAutosizer.cpp
+++ b/Source/core/rendering/FastTextAutosizer.cpp
@@ -97,6 +97,23 @@ void FastTextAutosizer::beginLayout(RenderBlock* block)
inflate(block);
}
+void FastTextAutosizer::inflateListItem(RenderBlock* listItem, RenderObject* listItemMarker)
+{
+ ASSERT(listItem->isListItem());
+ ASSERT(listItemMarker->isListMarker());
+
+ if (!enabled())
+ return;
+
pdr. 2014/01/28 04:50:47 currentCluster() can be null here. Probably want t
skobes 2014/01/29 00:13:29 Done, with FIXME to investigate further.
+ // Force the LI to be inside the DBCAT when computing the multiplier.
+ // This guarantees that the DBCAT has entered layout, so we can ask for its width.
+ // It also makes sense because the list marker is autosized like a text node.
+ float multiplier = clusterMultiplier(currentCluster(), listItem);
pdr. 2014/01/28 04:50:47 I like the idea here except for passing listItem i
skobes 2014/01/29 00:13:29 Fixed.
+
+ applyMultiplier(listItem, multiplier);
+ applyMultiplier(listItemMarker, multiplier);
+}
+
void FastTextAutosizer::endLayout(RenderBlock* block)
{
if (!enabled())
@@ -277,15 +294,16 @@ const RenderBlock* FastTextAutosizer::deepestCommonAncestor(BlockSet& blocks)
return 0;
}
-float FastTextAutosizer::clusterMultiplier(Cluster* cluster)
+float FastTextAutosizer::clusterMultiplier(Cluster* cluster, const RenderBlock* forceInclude)
{
#ifndef NDEBUG
ASSERT(m_renderViewInfoPrepared);
#endif
if (!cluster->m_multiplier) {
if (TextAutosizer::isIndependentDescendant(cluster->m_root)) {
- if (clusterHasEnoughTextToAutosize(cluster)) {
- const RenderBlock* deepestBlockContainingAllText = findDeepestBlockContainingAllText(cluster->m_root);
+ bool enoughText = clusterHasEnoughTextToAutosize(cluster);
+ if (enoughText) {
+ const RenderBlock* deepestBlockContainingAllText = findDeepestBlockContainingAllText(cluster->m_root, forceInclude);
#ifndef NDEBUG
// This ensures the deepest block containing all text has a valid contentLogicalWidth.
ASSERT(m_blocksThatHaveBegunLayout.contains(deepestBlockContainingAllText));
@@ -301,12 +319,13 @@ float FastTextAutosizer::clusterMultiplier(Cluster* cluster)
cluster->m_multiplier = cluster->m_parent ? clusterMultiplier(cluster->m_parent) : 1.0f;
}
}
+ ASSERT(cluster->m_multiplier);
return cluster->m_multiplier;
}
// FIXME: Refactor this to look more like FastTextAutosizer::deepestCommonAncestor. This is copied
// from TextAutosizer::findDeepestBlockContainingAllText.
-const RenderBlock* FastTextAutosizer::findDeepestBlockContainingAllText(const RenderBlock* root)
+const RenderBlock* FastTextAutosizer::findDeepestBlockContainingAllText(const RenderBlock* root, const RenderBlock* forceInclude)
{
size_t firstDepth = 0;
const RenderObject* firstTextLeaf = findTextLeaf(root, firstDepth, First);
@@ -345,6 +364,15 @@ const RenderBlock* FastTextAutosizer::findDeepestBlockContainingAllText(const Re
const RenderBlock* containingBlock = firstNode->containingBlock();
ASSERT(containingBlock->isDescendantOf(root));
+ if (forceInclude && !forceInclude->isDescendantOf(containingBlock)) {
+ ASSERT(forceInclude->isDescendantOf(root));
+
+ BlockSet blockSet;
+ blockSet.add(containingBlock);
+ blockSet.add(forceInclude);
+ return deepestCommonAncestor(blockSet);
+ }
+
return containingBlock;
}
« no previous file with comments | « Source/core/rendering/FastTextAutosizer.h ('k') | Source/core/rendering/RenderListItem.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698