Commit a53a045f authored by Yoshifumi Inoue's avatar Yoshifumi Inoue Committed by Commit Bot

Revise condition of using fast path in LayoutText::SetTextWithOffset()

This patch makes |LayoutText::SetTextWithOffset()| to use fast path in
case of using generated break opportunities for spaces after newline
in same layout text.

There are three cases we use generated break opportunities:
 1. In white-space:pre-wrap: leading spaces after newline
 2. In white-space:pre-wrap: spaces after newline
 3. collapsible space after newline in white-space:pre-wrap
    <b><i><s>ab\n</s></i>\n</b>

The CL[1] makes |LayoutText::SetTextWithOffset()| to use slow path
because of it is hard to handle case 3 even if we can handle case 1 and
2. In this CL, we use fast path for case 1 and 2 but case 3.

[1] http://crrev.com/c/2395136: Make LayoutText::SetTextWithOffset() to
use slow path for generated break opportunities

Bug: 1125640, 1125641
Change-Id: I22ee9c1aa6b7ff5f57c08524ee7ac704ecb5db6a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2397036Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Commit-Queue: Yoshifumi Inoue <yosin@chromium.org>
Auto-Submit: Yoshifumi Inoue <yosin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#804840}
parent e7896817
...@@ -277,7 +277,6 @@ void NGInlineItemsBuilderTemplate<OffsetMappingBuilder>:: ...@@ -277,7 +277,6 @@ void NGInlineItemsBuilderTemplate<OffsetMappingBuilder>::
typename OffsetMappingBuilder::SourceNodeScope scope(&mapping_builder_, typename OffsetMappingBuilder::SourceNodeScope scope(&mapping_builder_,
nullptr); nullptr);
NGInlineItem& item = AppendBreakOpportunity(layout_object); NGInlineItem& item = AppendBreakOpportunity(layout_object);
has_generated_break_opportunity_ = true;
item.SetIsGeneratedForLineBreak(); item.SetIsGeneratedForLineBreak();
item.SetEndCollapseType(NGInlineItem::kOpaqueToCollapsing); item.SetEndCollapseType(NGInlineItem::kOpaqueToCollapsing);
} }
...@@ -568,6 +567,7 @@ void NGInlineItemsBuilderTemplate< ...@@ -568,6 +567,7 @@ void NGInlineItemsBuilderTemplate<
// after a forced break. // after a forced break.
if (item->Type() != NGInlineItem::kControl || if (item->Type() != NGInlineItem::kControl ||
text_[item->StartOffset()] != kNewlineCharacter) { text_[item->StartOffset()] != kNewlineCharacter) {
can_use_fast_editing_ = false;
AppendGeneratedBreakOpportunity(layout_object); AppendGeneratedBreakOpportunity(layout_object);
} }
} }
...@@ -1240,7 +1240,7 @@ void NGInlineItemsBuilderTemplate< ...@@ -1240,7 +1240,7 @@ void NGInlineItemsBuilderTemplate<
// |SegmentText()| will analyze the text and reset |is_bidi_enabled_| if it // |SegmentText()| will analyze the text and reset |is_bidi_enabled_| if it
// doesn't contain any RTL characters. // doesn't contain any RTL characters.
data->is_bidi_enabled_ = MayBeBidiEnabled(); data->is_bidi_enabled_ = MayBeBidiEnabled();
data->has_generated_break_opportunity_ = HasGeneratedBreakOpportunity(); data->can_use_fast_editing_ = CanUseFastEditing();
// Note: Even if |IsEmptyInline()| is true, |text_| isn't empty, e.g. it // Note: Even if |IsEmptyInline()| is true, |text_| isn't empty, e.g. it
// holds U+FFFC(ORC) for float or abspos. // holds U+FFFC(ORC) for float or abspos.
data->has_line_even_if_empty_ = data->has_line_even_if_empty_ =
......
...@@ -57,9 +57,7 @@ class NGInlineItemsBuilderTemplate { ...@@ -57,9 +57,7 @@ class NGInlineItemsBuilderTemplate {
bool HasBidiControls() const { return has_bidi_controls_; } bool HasBidiControls() const { return has_bidi_controls_; }
// Returns whether the items contain any generated break opportunity. // Returns whether the items contain any generated break opportunity.
bool HasGeneratedBreakOpportunity() const { bool CanUseFastEditing() const { return can_use_fast_editing_; }
return has_generated_break_opportunity_;
}
// Returns if the inline node has no content. For example: // Returns if the inline node has no content. For example:
// <span></span> or <span><float></float></span>. // <span></span> or <span><float></float></span>.
...@@ -187,7 +185,7 @@ class NGInlineItemsBuilderTemplate { ...@@ -187,7 +185,7 @@ class NGInlineItemsBuilderTemplate {
bool has_bidi_controls_ = false; bool has_bidi_controls_ = false;
bool has_ruby_ = false; bool has_ruby_ = false;
bool has_generated_break_opportunity_ = false; bool can_use_fast_editing_ = true;
bool is_empty_inline_ = true; bool is_empty_inline_ = true;
bool is_block_level_ = true; bool is_block_level_ = true;
bool changes_may_affect_earlier_lines_ = false; bool changes_may_affect_earlier_lines_ = false;
......
...@@ -523,7 +523,7 @@ class NGInlineNodeDataEditor final { ...@@ -523,7 +523,7 @@ class NGInlineNodeDataEditor final {
block_flow_->GetDocument().NeedsLayoutTreeUpdate() || block_flow_->GetDocument().NeedsLayoutTreeUpdate() ||
!block_flow_->GetNGInlineNodeData() || !block_flow_->GetNGInlineNodeData() ||
block_flow_->GetNGInlineNodeData()->text_content.IsNull() || block_flow_->GetNGInlineNodeData()->text_content.IsNull() ||
block_flow_->GetNGInlineNodeData()->HasGeneratedBreakOpportunity()) !block_flow_->GetNGInlineNodeData()->CanUseFastEditing())
return nullptr; return nullptr;
// Because of current text content has secured text, e.g. whole text is // Because of current text content has secured text, e.g. whole text is
......
...@@ -22,10 +22,7 @@ struct CORE_EXPORT NGInlineNodeData : NGInlineItemsData { ...@@ -22,10 +22,7 @@ struct CORE_EXPORT NGInlineNodeData : NGInlineItemsData {
return static_cast<TextDirection>(base_direction_); return static_cast<TextDirection>(base_direction_);
} }
bool HasGeneratedBreakOpportunity() const { bool CanUseFastEditing() const { return can_use_fast_editing_; }
return has_generated_break_opportunity_;
}
bool HasLineEvenIfEmpty() const { return has_line_even_if_empty_; } bool HasLineEvenIfEmpty() const { return has_line_even_if_empty_; }
bool HasRuby() const { return has_ruby_; } bool HasRuby() const { return has_ruby_; }
bool IsEmptyInline() const { return is_empty_inline_; } bool IsEmptyInline() const { return is_empty_inline_; }
...@@ -62,9 +59,8 @@ struct CORE_EXPORT NGInlineNodeData : NGInlineItemsData { ...@@ -62,9 +59,8 @@ struct CORE_EXPORT NGInlineNodeData : NGInlineItemsData {
unsigned is_bidi_enabled_ : 1; unsigned is_bidi_enabled_ : 1;
unsigned base_direction_ : 1; // TextDirection unsigned base_direction_ : 1; // TextDirection
// True if text content has U+200B, zero width space, representing generated // True if we can use fast editing path.
// break opportunity. unsigned can_use_fast_editing_ : 1;
unsigned has_generated_break_opportunity_ : 1;
// True if there are no inline item items and the associated block is root // True if there are no inline item items and the associated block is root
// editable element or having "-internal-empty-line-height:fabricated", // editable element or having "-internal-empty-line-height:fabricated",
......
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