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

Unified Diff: third_party/WebKit/Source/core/layout/ng/ng_block_node.cc

Issue 2815003006: [LayoutNG] Handle floats/OOF at the beginning of inline in inline context (Closed)
Patch Set: Resolve merge conflict Created 3 years, 8 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
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);

Powered by Google App Engine
This is Rietveld 408576698