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,
end_collapse_type_(kNotCollapsible),
is_end_collapsible_newline_(false),
is_symbol_marker_(false),
is_generated_(false) {
is_generated_for_line_break_(false) {
DCHECK_GE(end, start);
ComputeBoxProperties();
}
......@@ -95,7 +95,7 @@ NGInlineItem::NGInlineItem(const NGInlineItem& other,
end_collapse_type_(other.end_collapse_type_),
is_end_collapsible_newline_(other.is_end_collapsible_newline_),
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);
}
......
......@@ -175,8 +175,8 @@ class CORE_EXPORT NGInlineItem {
// context that are lost during the whitespace collapsing. This item is used
// during the line breaking and layout, but is not supposed to generate
// fragments.
bool IsGenerated() const { return is_generated_; }
void SetIsGenerated() { is_generated_ = true; }
bool IsGeneratedForLineBreak() const { return is_generated_for_line_break_; }
void SetIsGeneratedForLineBreak() { is_generated_for_line_break_ = true; }
// Whether the end collapsible space run contains a newline.
// Valid only when kCollapsible or kCollapsed.
......@@ -243,7 +243,7 @@ class CORE_EXPORT NGInlineItem {
unsigned end_collapse_type_ : 2; // NGCollapseType
unsigned is_end_collapsible_newline_ : 1;
unsigned is_symbol_marker_ : 1;
unsigned is_generated_ : 1;
unsigned is_generated_for_line_break_ : 1;
friend class NGInlineNode;
};
......
......@@ -271,7 +271,7 @@ void NGInlineItemsBuilderTemplate<OffsetMappingBuilder>::
nullptr);
AppendBreakOpportunity(layout_object);
NGInlineItem* item = &items_->back();
item->SetIsGenerated();
item->SetIsGeneratedForLineBreak();
item->SetEndCollapseType(NGInlineItem::kOpaqueToCollapsing);
}
......
......@@ -391,7 +391,7 @@ void NGInlineLayoutAlgorithm::PlaceControlItem(const NGInlineItem& item,
case kZeroWidthSpaceCharacter:
// Don't generate fragments if this is a generated (not in DOM) break
// opportunity during the white space collapsing in NGInlineItemBuilder.
if (item.IsGenerated())
if (item.IsGeneratedForLineBreak())
return;
type = NGPhysicalTextFragment::kFlowControl;
break;
......
......@@ -1074,7 +1074,11 @@ void NGLineBreaker::HandleControlItem(const NGInlineItem& item,
case kZeroWidthSpaceCharacter: {
// <wbr> tag creates break opportunities regardless of auto_wrap.
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;
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