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

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

Issue 17071009: Consistently autosize markers in <ul> and <ol> lists. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@ls-TA-margins-14June
Patch Set: removed the setMarginStart related modification Created 7 years, 6 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/TextAutosizer.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/TextAutosizer.cpp
diff --git a/Source/core/rendering/TextAutosizer.cpp b/Source/core/rendering/TextAutosizer.cpp
index a794fbfaf8e3af44610a3c68ba1e3ea362cf9d73..0c902688dfdd237b6d56e60da6b5c19155db8403 100644
--- a/Source/core/rendering/TextAutosizer.cpp
+++ b/Source/core/rendering/TextAutosizer.cpp
@@ -90,6 +90,16 @@ static RenderListItem* getAncestorListItem(const RenderObject* renderer)
return (ancestor && ancestor->isListItem()) ? toRenderListItem(ancestor) : 0;
}
+static RenderObject* getAncestorList(const RenderObject* renderer)
+{
+ for (RenderObject* ancestor = renderer->parent(); ancestor; ancestor = ancestor->parent()) {
+ Node* parentNode = ancestor->generatingNode();
+ if (parentNode && (parentNode->hasTagName(olTag) || parentNode->hasTagName(ulTag)))
Julien - ping for review 2013/06/21 19:01:53 HTML5 allows <menu> in the toolbar state for the c
timvolodine 2013/06/21 19:21:37 Done.
+ return ancestor;
+ }
+ return 0;
+}
+
TextAutosizer::TextAutosizer(Document* document)
: m_document(document)
{
@@ -216,9 +226,12 @@ void TextAutosizer::processContainer(float multiplier, RenderBlock* container, T
if (localMultiplier != 1 && descendant->style()->textAutosizingMultiplier() == 1) {
setMultiplier(descendant, localMultiplier);
setMultiplier(descendant->parent(), localMultiplier); // Parent does line spacing.
+
if (RenderListItem* listItemAncestor = getAncestorListItem(descendant)) {
- if (listItemAncestor->style()->textAutosizingMultiplier() == 1)
- setMultiplier(listItemAncestor, localMultiplier);
+ if (RenderObject* list = getAncestorList(listItemAncestor)) {
+ if (list->style()->textAutosizingMultiplier() == 1)
+ setMultiplierForList(list, localMultiplier);
+ }
}
}
} else if (isAutosizingContainer(descendant)) {
@@ -244,6 +257,24 @@ void TextAutosizer::setMultiplier(RenderObject* renderer, float multiplier)
renderer->setStyle(newStyle.release());
}
+void TextAutosizer::setMultiplierForList(RenderObject* renderer, float multiplier)
+{
+#ifndef NDEBUG
+ Node* parentNode = renderer->generatingNode();
+ ASSERT(parentNode);
+ ASSERT(parentNode->hasTagName(olTag) || parentNode->hasTagName(ulTag));
+#endif
+ RefPtr<RenderStyle> newListStyle = RenderStyle::clone(renderer->style());
+ newListStyle->setTextAutosizingMultiplier(multiplier);
+ renderer->setStyle(newListStyle.release());
Julien - ping for review 2013/06/21 19:01:53 It seems that this is just setMultiplier() above.
timvolodine 2013/06/21 19:21:37 Done.
+
+ // Make sure all list items are autosized consistently.
+ for (RenderObject* child = renderer->firstChild(); child; child = child->nextSibling()) {
+ if (child->isListItem() && child->style()->textAutosizingMultiplier() == 1)
+ setMultiplier(child, multiplier);
+ }
+}
+
float TextAutosizer::computeAutosizedFontSize(float specifiedSize, float multiplier)
{
// Somewhat arbitrary "pleasant" font size.
« no previous file with comments | « Source/core/rendering/TextAutosizer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698