[LayoutNG] Add comments about "certain zero-height line boxes"
Found the spec section that defines "certain zero-height line boxes" do
not prevent two margins being "adjoining" and thus collapsing.
TBR=eae@chromium.org, ikilpatrick@chromium.org
BUG=636993
NOTRY=true
Review-Url: https://codereview.chromium.org/2953403002
Cr-Commit-Position: refs/heads/master@{#482167}
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc
index 739502db..6a04416 100644
--- a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc
+++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.cc
@@ -457,6 +457,10 @@
borders.inline_start + paddings.inline_start;
position_ += item_result->inline_size;
+ // While the spec defines "non-zero margins, padding, or borders" prevents
+ // line boxes to be zero-height, tests indicate that only inline direction
+ // of them do so. See should_create_line_box_.
+ // Force to create a box, because such inline boxes affect line heights.
item_result->needs_box_when_empty =
item_result->inline_size || item_result->margins.inline_start;
if (item_result->needs_box_when_empty && !should_create_line_box_)
diff --git a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.h b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.h
index ac43b1c..780f7a0 100644
--- a/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.h
+++ b/third_party/WebKit/Source/core/layout/ng/inline/ng_line_breaker.h
@@ -105,7 +105,14 @@
ShapeResultSpacing<String> spacing_;
bool auto_wrap_;
+
+ // We don't create "certain zero-height line boxes".
+ // https://drafts.csswg.org/css2/visuren.html#phantom-line-box
+ // Such line boxes do not prevent two margins being "adjoining", and thus
+ // collapsing.
+ // https://drafts.csswg.org/css2/box.html#collapsing-margins
bool should_create_line_box_;
+
bool is_after_forced_break_;
};