Commit 7051e6d4 authored by Koji Ishii's avatar Koji Ishii Committed by Commit Bot

[LayoutNG] Avoid calling HandleOverflow multiple times

This patch eliminates the call to |HandleOverflow| when the
|NGLineBreaker| state is 'overflow'.

r701601 (crrev.com/c/1826063) added the 'overflow' state to
|NGLineBreaker|. This state makes the `trailing' state more
efficient, but when multiple text runs appear without any
break opportunities in the 'overflow' state, the change
added a call to |HandleOverflow| on each text run.

Bug: 1010487
Change-Id: I608b704a9b65f905e6b57c245ea8f5dac7194c64
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1838791Reviewed-by: default avatarYoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#702942}
parent b3b852f1
...@@ -362,13 +362,6 @@ void NGLineBreaker::BreakLine( ...@@ -362,13 +362,6 @@ void NGLineBreaker::BreakLine(
continue; continue;
} }
// If |state_| is overflow, break at the earliest break opportunity.
const NGInlineItemResults& item_results = line_info->Results();
if (state_ == LineBreakState::kOverflow &&
CanBreakAfterLast(item_results)) {
state_ = LineBreakState::kTrailing;
}
// If we reach at the end of the block, this is the last line. // If we reach at the end of the block, this is the last line.
DCHECK_LE(item_index_, items.size()); DCHECK_LE(item_index_, items.size());
if (item_index_ == items.size()) { if (item_index_ == items.size()) {
...@@ -376,6 +369,13 @@ void NGLineBreaker::BreakLine( ...@@ -376,6 +369,13 @@ void NGLineBreaker::BreakLine(
return; return;
} }
// If |state_| is overflow, break at the earliest break opportunity.
const NGInlineItemResults& item_results = line_info->Results();
if (UNLIKELY(state_ == LineBreakState::kOverflow &&
CanBreakAfterLast(item_results))) {
state_ = LineBreakState::kTrailing;
}
// Handle trailable items first. These items may not be break before. // Handle trailable items first. These items may not be break before.
// They (or part of them) may also overhang the available width. // They (or part of them) may also overhang the available width.
const NGInlineItem& item = items[item_index_]; const NGInlineItem& item = items[item_index_];
...@@ -576,6 +576,12 @@ void NGLineBreaker::HandleText(const NGInlineItem& item, ...@@ -576,6 +576,12 @@ void NGLineBreaker::HandleText(const NGInlineItem& item,
} }
DCHECK_EQ(break_result, kOverflow); DCHECK_EQ(break_result, kOverflow);
if (UNLIKELY(state_ == LineBreakState::kOverflow &&
item_result->shape_result)) {
if (item_result->can_break_after)
state_ = LineBreakState::kTrailing;
return;
}
return HandleOverflow(line_info); return HandleOverflow(line_info);
} }
......
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