Chromium Code Reviews| 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. |