Commit 2e6c0434 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Generated break opportunities should not make the line non-empty

Generated break opportunities are not in DOM/box tree, and
that they alone should not make the line non-empty.

Bug: 966817, 969449
Change-Id: Ic718171b45f64f2b66b158e49d98ac0aaffb90a3
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1634591
Commit-Queue: Emil A Eklund <eae@chromium.org>
Reviewed-by: default avatarEmil A Eklund <eae@chromium.org>
Cr-Commit-Position: refs/heads/master@{#665426}
parent 83c5a883
...@@ -73,7 +73,7 @@ NGInlineItem::NGInlineItem(NGInlineItemType type, ...@@ -73,7 +73,7 @@ NGInlineItem::NGInlineItem(NGInlineItemType type,
end_collapse_type_(kNotCollapsible), end_collapse_type_(kNotCollapsible),
is_end_collapsible_newline_(false), is_end_collapsible_newline_(false),
is_symbol_marker_(false), is_symbol_marker_(false),
is_generated_(false) { is_generated_for_line_break_(false) {
DCHECK_GE(end, start); DCHECK_GE(end, start);
ComputeBoxProperties(); ComputeBoxProperties();
} }
...@@ -95,7 +95,7 @@ NGInlineItem::NGInlineItem(const NGInlineItem& other, ...@@ -95,7 +95,7 @@ NGInlineItem::NGInlineItem(const NGInlineItem& other,
end_collapse_type_(other.end_collapse_type_), end_collapse_type_(other.end_collapse_type_),
is_end_collapsible_newline_(other.is_end_collapsible_newline_), is_end_collapsible_newline_(other.is_end_collapsible_newline_),
is_symbol_marker_(other.is_symbol_marker_), is_symbol_marker_(other.is_symbol_marker_),
is_generated_(other.is_generated_) { is_generated_for_line_break_(other.is_generated_for_line_break_) {
DCHECK_GE(end, start); DCHECK_GE(end, start);
} }
......
...@@ -175,8 +175,8 @@ class CORE_EXPORT NGInlineItem { ...@@ -175,8 +175,8 @@ class CORE_EXPORT NGInlineItem {
// context that are lost during the whitespace collapsing. This item is used // context that are lost during the whitespace collapsing. This item is used
// during the line breaking and layout, but is not supposed to generate // during the line breaking and layout, but is not supposed to generate
// fragments. // fragments.
bool IsGenerated() const { return is_generated_; } bool IsGeneratedForLineBreak() const { return is_generated_for_line_break_; }
void SetIsGenerated() { is_generated_ = true; } void SetIsGeneratedForLineBreak() { is_generated_for_line_break_ = true; }
// Whether the end collapsible space run contains a newline. // Whether the end collapsible space run contains a newline.
// Valid only when kCollapsible or kCollapsed. // Valid only when kCollapsible or kCollapsed.
...@@ -243,7 +243,7 @@ class CORE_EXPORT NGInlineItem { ...@@ -243,7 +243,7 @@ class CORE_EXPORT NGInlineItem {
unsigned end_collapse_type_ : 2; // NGCollapseType unsigned end_collapse_type_ : 2; // NGCollapseType
unsigned is_end_collapsible_newline_ : 1; unsigned is_end_collapsible_newline_ : 1;
unsigned is_symbol_marker_ : 1; unsigned is_symbol_marker_ : 1;
unsigned is_generated_ : 1; unsigned is_generated_for_line_break_ : 1;
friend class NGInlineNode; friend class NGInlineNode;
}; };
......
...@@ -271,7 +271,7 @@ void NGInlineItemsBuilderTemplate<OffsetMappingBuilder>:: ...@@ -271,7 +271,7 @@ void NGInlineItemsBuilderTemplate<OffsetMappingBuilder>::
nullptr); nullptr);
AppendBreakOpportunity(layout_object); AppendBreakOpportunity(layout_object);
NGInlineItem* item = &items_->back(); NGInlineItem* item = &items_->back();
item->SetIsGenerated(); item->SetIsGeneratedForLineBreak();
item->SetEndCollapseType(NGInlineItem::kOpaqueToCollapsing); item->SetEndCollapseType(NGInlineItem::kOpaqueToCollapsing);
} }
......
...@@ -391,7 +391,7 @@ void NGInlineLayoutAlgorithm::PlaceControlItem(const NGInlineItem& item, ...@@ -391,7 +391,7 @@ void NGInlineLayoutAlgorithm::PlaceControlItem(const NGInlineItem& item,
case kZeroWidthSpaceCharacter: case kZeroWidthSpaceCharacter:
// Don't generate fragments if this is a generated (not in DOM) break // Don't generate fragments if this is a generated (not in DOM) break
// opportunity during the white space collapsing in NGInlineItemBuilder. // opportunity during the white space collapsing in NGInlineItemBuilder.
if (item.IsGenerated()) if (item.IsGeneratedForLineBreak())
return; return;
type = NGPhysicalTextFragment::kFlowControl; type = NGPhysicalTextFragment::kFlowControl;
break; break;
......
...@@ -1074,7 +1074,11 @@ void NGLineBreaker::HandleControlItem(const NGInlineItem& item, ...@@ -1074,7 +1074,11 @@ void NGLineBreaker::HandleControlItem(const NGInlineItem& item,
case kZeroWidthSpaceCharacter: { case kZeroWidthSpaceCharacter: {
// <wbr> tag creates break opportunities regardless of auto_wrap. // <wbr> tag creates break opportunities regardless of auto_wrap.
NGInlineItemResult* item_result = AddItem(item, line_info); NGInlineItemResult* item_result = AddItem(item, line_info);
item_result->should_create_line_box = true; // A generated break opportunity doesn't generate fragments, but we still
// need to add this for rewind to find this opportunity. This will be
// discarded in |NGInlineLayoutAlgorithm| when it generates fragments.
if (!item.IsGeneratedForLineBreak())
item_result->should_create_line_box = true;
item_result->can_break_after = true; item_result->can_break_after = true;
break; break;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment