| Index: third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
|
| diff --git a/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc b/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
|
| index a9d8dd6e73af28685ad42483b4674a8e47816cb6..96402b5f64b35d33df7bb8377a1409ecae153d5f 100644
|
| --- a/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
|
| +++ b/third_party/WebKit/Source/core/layout/ng/ng_block_node.cc
|
| @@ -203,6 +203,11 @@ NGLayoutInputNode* NGBlockNode::NextSibling() {
|
| LayoutObject* next_sibling = layout_box_->NextSibling();
|
| if (next_sibling) {
|
| if (next_sibling->IsInline()) {
|
| + // As long as we traverse LayoutObject tree, this should not happen.
|
| + // See ShouldHandleByInlineContext() for more context.
|
| + // Also this leads to incorrect layout because we create two
|
| + // NGLayoutInputNode for one LayoutBlockFlow.
|
| + NOTREACHED();
|
| next_sibling_ = new NGInlineNode(
|
| next_sibling, ToLayoutBlockFlow(layout_box_->Parent()));
|
| } else {
|
| @@ -217,11 +222,32 @@ LayoutObject* NGBlockNode::GetLayoutObject() {
|
| return layout_box_;
|
| }
|
|
|
| +static bool ShouldHandleByInlineContext(LayoutObject* child) {
|
| + DCHECK(child);
|
| + // The spec isn't clear about whether floats/OOF should be in inline
|
| + // formatting context or in block formatting context.
|
| + // Prefer inline formatting context because 1) floats/OOF at the beginning
|
| + // and in the middle of inline should be handled in the same code, and 2)
|
| + // it matches to the LayoutObject tree.
|
| + for (; child; child = child->NextSibling()) {
|
| + if (child->IsInline())
|
| + return true;
|
| + if (child->IsFloating() || child->IsOutOfFlowPositioned())
|
| + continue;
|
| + return false;
|
| + }
|
| + // All children are either float or OOF.
|
| + // TODO(kojii): Should this be handled in block context or inline context?
|
| + // If we handle in inline, we can remove all code for floats/OOF from block
|
| + // layout, but it may change semantics and causes incorrectness?
|
| + return false;
|
| +}
|
| +
|
| NGLayoutInputNode* NGBlockNode::FirstChild() {
|
| if (!first_child_) {
|
| LayoutObject* child = layout_box_->SlowFirstChild();
|
| if (child) {
|
| - if (child->IsInline()) {
|
| + if (ShouldHandleByInlineContext(child)) {
|
| first_child_ = new NGInlineNode(child, ToLayoutBlockFlow(layout_box_));
|
| } else {
|
| first_child_ = new NGBlockNode(child);
|
|
|