Commit 7be22785 authored by Javier Fernández García-Boente's avatar Javier Fernández García-Boente Committed by Chromium LUCI CQ

[css-text] break-space support for ideographic spaces in legacy layout

In r837379 we landed support for this feature in LayoutNG. This CL
implements the feature for Legacy layout.

Bug: 1155633
Change-Id: I2b974daad7a98d26fdc4d4468572840e30be5cad
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2598843
Commit-Queue: Javier Fernandez <jfernandez@igalia.com>
Reviewed-by: default avatarKoji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#842846}
parent 0958e2ab
...@@ -207,6 +207,7 @@ class BreakingContext { ...@@ -207,6 +207,7 @@ class BreakingContext {
bool ignoring_spaces_; bool ignoring_spaces_;
bool current_character_is_space_; bool current_character_is_space_;
bool is_space_or_other_space_separator_; bool is_space_or_other_space_separator_;
bool previous_is_space_or_other_space_separator_;
bool previous_character_is_space_; bool previous_character_is_space_;
bool has_former_opportunity_; bool has_former_opportunity_;
unsigned current_start_offset_; // initial offset for the current text unsigned current_start_offset_; // initial offset for the current text
...@@ -1077,11 +1078,10 @@ inline bool BreakingContext::HandleText(WordMeasurements& word_measurements, ...@@ -1077,11 +1078,10 @@ inline bool BreakingContext::HandleText(WordMeasurements& word_measurements,
UChar last_character = layout_text_info_.line_break_iterator_.LastCharacter(); UChar last_character = layout_text_info_.line_break_iterator_.LastCharacter();
UChar second_to_last_character = UChar second_to_last_character =
layout_text_info_.line_break_iterator_.SecondToLastCharacter(); layout_text_info_.line_break_iterator_.SecondToLastCharacter();
bool previous_is_space_or_other_space_separator = false;
for (; current_.Offset() < layout_text.TextLength(); for (; current_.Offset() < layout_text.TextLength();
current_.FastIncrementInTextNode()) { current_.FastIncrementInTextNode()) {
previous_character_is_space_ = current_character_is_space_; previous_character_is_space_ = current_character_is_space_;
previous_is_space_or_other_space_separator = previous_is_space_or_other_space_separator_ =
is_space_or_other_space_separator_; is_space_or_other_space_separator_;
UChar c = current_.Current(); UChar c = current_.Current();
SetCurrentCharacterIsSpace(c); SetCurrentCharacterIsSpace(c);
...@@ -1145,7 +1145,7 @@ inline bool BreakingContext::HandleText(WordMeasurements& word_measurements, ...@@ -1145,7 +1145,7 @@ inline bool BreakingContext::HandleText(WordMeasurements& word_measurements,
} }
PrepareForNextCharacter(layout_text, prohibit_break_inside, PrepareForNextCharacter(layout_text, prohibit_break_inside,
previous_is_space_or_other_space_separator); previous_is_space_or_other_space_separator_);
at_start_ = false; at_start_ = false;
NextCharacter(c, last_character, second_to_last_character); NextCharacter(c, last_character, second_to_last_character);
continue; continue;
...@@ -1185,7 +1185,7 @@ inline bool BreakingContext::HandleText(WordMeasurements& word_measurements, ...@@ -1185,7 +1185,7 @@ inline bool BreakingContext::HandleText(WordMeasurements& word_measurements,
// We keep track of the total width contributed by trailing space as we // We keep track of the total width contributed by trailing space as we
// often want to exclude it when determining // often want to exclude it when determining
// if a run fits on a line. // if a run fits on a line.
if (collapse_white_space_ && previous_is_space_or_other_space_separator && if (collapse_white_space_ && previous_is_space_or_other_space_separator_ &&
is_space_or_other_space_separator_ && last_width_measurement) is_space_or_other_space_separator_ && last_width_measurement)
width_.SetTrailingWhitespaceWidth(last_width_measurement); width_.SetTrailingWhitespaceWidth(last_width_measurement);
...@@ -1250,9 +1250,9 @@ inline bool BreakingContext::HandleText(WordMeasurements& word_measurements, ...@@ -1250,9 +1250,9 @@ inline bool BreakingContext::HandleText(WordMeasurements& word_measurements,
if (CanBreakAtWhitespace( if (CanBreakAtWhitespace(
break_words, word_measurement, stopped_ignoring_spaces, char_width, break_words, word_measurement, stopped_ignoring_spaces, char_width,
hyphenated, disable_soft_hyphen, hyphen_width, between_words, hyphenated, disable_soft_hyphen, hyphen_width, between_words,
mid_word_break, can_break_mid_word, previous_character_is_space_, mid_word_break, can_break_mid_word,
last_width_measurement, layout_text, font, apply_word_spacing, previous_is_space_or_other_space_separator_, last_width_measurement,
word_spacing)) layout_text, font, apply_word_spacing, word_spacing))
return false; return false;
// If there is a hard-break available at this whitespace position then take // If there is a hard-break available at this whitespace position then take
...@@ -1304,7 +1304,7 @@ inline bool BreakingContext::HandleText(WordMeasurements& word_measurements, ...@@ -1304,7 +1304,7 @@ inline bool BreakingContext::HandleText(WordMeasurements& word_measurements,
} }
PrepareForNextCharacter(layout_text, prohibit_break_inside, PrepareForNextCharacter(layout_text, prohibit_break_inside,
previous_is_space_or_other_space_separator); previous_is_space_or_other_space_separator_);
at_start_ = false; at_start_ = false;
is_line_empty = line_info_.IsEmpty(); is_line_empty = line_info_.IsEmpty();
NextCharacter(c, last_character, second_to_last_character); NextCharacter(c, last_character, second_to_last_character);
...@@ -1461,7 +1461,7 @@ inline void BreakingContext::TrailingSpacesHang(bool can_break_mid_word) { ...@@ -1461,7 +1461,7 @@ inline void BreakingContext::TrailingSpacesHang(bool can_break_mid_word) {
DCHECK(curr_ws_ == EWhiteSpace::kBreakSpaces); DCHECK(curr_ws_ == EWhiteSpace::kBreakSpaces);
// Avoid breaking before the first white-space after a word if there is a // Avoid breaking before the first white-space after a word if there is a
// breaking opportunity before. // breaking opportunity before.
if (has_former_opportunity_ && !previous_character_is_space_) if (has_former_opportunity_ && !previous_is_space_or_other_space_separator_)
return; return;
line_break_.MoveTo(current_.GetLineLayoutItem(), current_.Offset(), line_break_.MoveTo(current_.GetLineLayoutItem(), current_.Offset(),
...@@ -1469,7 +1469,7 @@ inline void BreakingContext::TrailingSpacesHang(bool can_break_mid_word) { ...@@ -1469,7 +1469,7 @@ inline void BreakingContext::TrailingSpacesHang(bool can_break_mid_word) {
// Avoid breaking before the first white-space after a word, unless // Avoid breaking before the first white-space after a word, unless
// overflow-wrap or word-break allow to. // overflow-wrap or word-break allow to.
if (!previous_character_is_space_ && !can_break_mid_word) if (!previous_is_space_or_other_space_separator_ && !can_break_mid_word)
line_break_.Increment(); line_break_.Increment();
} }
......
...@@ -236,17 +236,8 @@ crbug.com/591099 external/wpt/css/css-text/white-space/control-chars-00C.html [ ...@@ -236,17 +236,8 @@ crbug.com/591099 external/wpt/css/css-text/white-space/control-chars-00C.html [
crbug.com/591099 external/wpt/css/css-text/white-space/line-edge-white-space-collapse-001.html [ Failure ] crbug.com/591099 external/wpt/css/css-text/white-space/line-edge-white-space-collapse-001.html [ Failure ]
crbug.com/591099 external/wpt/css/css-text/white-space/line-edge-white-space-collapse-002.html [ Failure ] crbug.com/591099 external/wpt/css/css-text/white-space/line-edge-white-space-collapse-002.html [ Failure ]
crbug.com/591099 external/wpt/css/css-text/white-space/pre-line-with-space-and-newline.html [ Failure ] crbug.com/591099 external/wpt/css/css-text/white-space/pre-line-with-space-and-newline.html [ Failure ]
crbug.com/1155633 external/wpt/css/css-text/white-space/break-spaces-with-ideographic-space-001.html [ Failure ]
crbug.com/1155633 external/wpt/css/css-text/white-space/break-spaces-with-ideographic-space-005.html [ Failure ]
crbug.com/1151784 external/wpt/css/css-text/white-space/seg-break-transformation-016.tentative.html [ Failure ] crbug.com/1151784 external/wpt/css/css-text/white-space/seg-break-transformation-016.tentative.html [ Failure ]
crbug.com/1151784 external/wpt/css/css-text/white-space/seg-break-transformation-017.tentative.html [ Failure ] crbug.com/1151784 external/wpt/css/css-text/white-space/seg-break-transformation-017.tentative.html [ Failure ]
crbug.com/1155633 external/wpt/css/css-text/white-space/trailing-ideographic-space-break-spaces-001.html [ Failure ]
crbug.com/1155633 external/wpt/css/css-text/white-space/trailing-ideographic-space-break-spaces-002.html [ Failure ]
crbug.com/1155633 external/wpt/css/css-text/white-space/trailing-ideographic-space-break-spaces-003.html [ Failure ]
crbug.com/1155633 external/wpt/css/css-text/white-space/trailing-ideographic-space-break-spaces-004.html [ Failure ]
crbug.com/1155633 external/wpt/css/css-text/white-space/trailing-ideographic-space-break-spaces-005.html [ Failure ]
crbug.com/1155633 external/wpt/css/css-text/white-space/trailing-ideographic-space-break-spaces-006.html [ Failure ]
crbug.com/1155633 external/wpt/css/css-text/white-space/trailing-ideographic-space-break-spaces-007.html [ Failure ]
crbug.com/1162836 external/wpt/css/css-text/white-space/trailing-ideographic-space-017.html [ Failure ] crbug.com/1162836 external/wpt/css/css-text/white-space/trailing-ideographic-space-017.html [ Failure ]
crbug.com/1162836 external/wpt/css/css-text/white-space/trailing-ideographic-space-020.html [ Failure ] crbug.com/1162836 external/wpt/css/css-text/white-space/trailing-ideographic-space-020.html [ Failure ]
crbug.com/1162836 external/wpt/css/css-text/white-space/trailing-ideographic-space-023.html [ Failure ] crbug.com/1162836 external/wpt/css/css-text/white-space/trailing-ideographic-space-023.html [ Failure ]
......
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