Chromium Code Reviews| Index: third_party/WebKit/Source/core/layout/TextAutosizer.cpp |
| diff --git a/third_party/WebKit/Source/core/layout/TextAutosizer.cpp b/third_party/WebKit/Source/core/layout/TextAutosizer.cpp |
| index af61f4ee062355a2a97ee95ee8ea791af24cea91..bb34db81bb7e1375f3aead92b792fc1cb442b535 100644 |
| --- a/third_party/WebKit/Source/core/layout/TextAutosizer.cpp |
| +++ b/third_party/WebKit/Source/core/layout/TextAutosizer.cpp |
| @@ -30,6 +30,7 @@ |
| #include "core/layout/TextAutosizer.h" |
| +#include <memory> |
| #include "core/dom/Document.h" |
| #include "core/frame/FrameHost.h" |
| #include "core/frame/FrameView.h" |
| @@ -41,6 +42,7 @@ |
| #include "core/layout/LayoutInline.h" |
| #include "core/layout/LayoutListItem.h" |
| #include "core/layout/LayoutListMarker.h" |
| +#include "core/layout/LayoutRubyRun.h" |
| #include "core/layout/LayoutTable.h" |
| #include "core/layout/LayoutTableCell.h" |
| #include "core/layout/LayoutView.h" |
| @@ -48,7 +50,6 @@ |
| #include "core/layout/api/LayoutViewItem.h" |
| #include "core/page/Page.h" |
| #include "wtf/PtrUtil.h" |
| -#include <memory> |
| #ifdef AUTOSIZING_DOM_DEBUG_INFO |
| #include "core/dom/ExecutionContextTask.h" |
| @@ -400,6 +401,10 @@ void TextAutosizer::beginLayout(LayoutBlock* block, |
| if (prepareForLayout(block) == StopLayout) |
| return; |
| + // Skip ruby's inner blocks, because these blocks already be inflated. |
|
pdr.
2017/02/10 04:10:46
nit: "...these blocks already are inflated."
cathiechentx
2017/02/10 05:17:47
Got it. Thank you :)
|
| + if (block->isRubyRun() || block->isRubyBase() || block->isRubyText()) |
| + return; |
| + |
| ASSERT(!m_clusterStack.isEmpty() || block->isLayoutView()); |
| if (Cluster* cluster = maybeCreateCluster(block)) |
| @@ -470,11 +475,20 @@ float TextAutosizer::inflate(LayoutObject* parent, |
| bool hasTextChild = false; |
| LayoutObject* child = nullptr; |
| - if (parent->isLayoutBlock() && |
| - (parent->childrenInline() || behavior == DescendToInnerBlocks)) |
| + if (parent->isRuby()) { |
| + // Skip layoutRubyRun which is inline-block. |
| + // Inflate rubyRun's inner blocks. |
| + LayoutObject* run = parent->slowFirstChild(); |
| + if (run && run->isRubyRun()) { |
| + child = toLayoutRubyRun(run)->firstChild(); |
| + behavior = SkippedInlineBlockAndDescendToInnerBlocks; |
| + } |
| + } else if (parent->isLayoutBlock() && |
| + (parent->childrenInline() || behavior == DescendToInnerBlocks)) { |
| child = toLayoutBlock(parent)->firstChild(); |
| - else if (parent->isLayoutInline()) |
| + } else if (parent->isLayoutInline()) { |
| child = toLayoutInline(parent)->firstChild(); |
| + } |
| while (child) { |
| if (child->isText()) { |
| @@ -487,11 +501,15 @@ float TextAutosizer::inflate(LayoutObject* parent, |
| applyMultiplier(child, multiplier, layouter); |
| // FIXME: Investigate why MarkOnlyThis is sufficient. |
| - if (parent->isLayoutInline()) |
| + // If inlineBlocks have been skipped, we should use MarkContainerChain |
| + // here. |
| + if (behavior == SkippedInlineBlockAndDescendToInnerBlocks) |
|
pdr.
2017/02/10 04:10:46
Nit: setPreferredLogicalWidthsDirty has lost its c
cathiechentx
2017/02/10 05:17:47
yes, it's much simpler. But rubyText is a block;(
pdr.
2017/02/10 19:27:09
Yeah, something like that seems good (just don't f
|
| + child->setPreferredLogicalWidthsDirty(MarkContainerChain); |
| + else if (parent->isLayoutInline()) |
| child->setPreferredLogicalWidthsDirty(MarkOnlyThis); |
| } else if (child->isLayoutInline()) { |
| multiplier = inflate(child, layouter, behavior, multiplier); |
| - } else if (child->isLayoutBlock() && behavior == DescendToInnerBlocks && |
| + } else if (child->isLayoutBlock() && behavior >= DescendToInnerBlocks && |
| !classifyBlock(child, |
| INDEPENDENT | EXPLICIT_WIDTH | SUPPRESSING)) { |
| multiplier = inflate(child, layouter, behavior, multiplier); |