From d8b4dab4e38c2928f034248e158e8bf9b5ad60d6 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Wed, 6 May 2020 00:51:59 -0400 Subject: [PATCH 1/3] Implement basic white-space: pre support for layout 2020. --- components/layout_2020/flow/construct.rs | 51 ++++++++--- components/layout_2020/flow/inline.rs | 22 +++-- .../longhands/inherited_text.mako.rs | 1 - ...tical-inline-alone-on-second-line.html.ini | 2 - .../CSS2/colors/color-applies-to-008.xht.ini | 2 - .../CSS2/colors/color-applies-to-015.xht.ini | 2 - .../css/CSS2/css1/c562-white-sp-000.xht.ini | 2 - .../css/CSS2/floats-clear/float-003.xht.ini | 2 - .../float-no-content-beside-001.html.ini | 2 + .../floats-placement-vertical-004.xht.ini | 2 + .../CSS2/floats/hit-test-floats-004.html.ini | 4 + .../generated-content/content-171.xht.ini | 2 - .../generated-content/content-173.xht.ini | 2 + .../content-newline-001.xht.ini | 2 - .../content-white-space-002.xht.ini | 2 + .../padding-percentage-inherit-001.xht.ini | 2 - .../block-replaced-width-006.xht.ini | 2 - .../inline-replaced-width-001.xht.ini | 2 - .../inline-replaced-width-006.xht.ini | 2 - .../css/CSS2/normal-flow/inlines-016.xht.ini | 2 - .../absolute-non-replaced-height-008.xht.ini | 2 - .../positioning/position-static-001.xht.ini | 2 - .../table-anonymous-objects-009.xht.ini | 2 + .../table-anonymous-objects-010.xht.ini | 2 + .../css/CSS2/text/white-space-004.xht.ini | 2 - .../text/white-space-applies-to-003.xht.ini | 2 - .../text/white-space-processing-013.xht.ini | 2 - .../text/white-space-processing-016.xht.ini | 2 - .../text/white-space-processing-017.xht.ini | 2 - .../text/white-space-processing-018.xht.ini | 2 - .../text/white-space-processing-046.xht.ini | 2 - .../text/white-space-processing-047.xht.ini | 2 - .../text/white-space-processing-052.xht.ini | 2 - .../CSS2/visuren/anonymous-boxes-001b.xht.ini | 2 - .../background-size-027.html.ini | 2 - .../background-size-028.html.ini | 2 - .../background-size-030.html.ini | 2 - .../background-size-031.html.ini | 2 - .../anonymous-flex-item-004.html.ini | 2 + .../anonymous-flex-item-005.html.ini | 2 + .../anonymous-flex-item-006.html.ini | 2 + .../text-decoration-subelements-001.html.ini | 2 - .../offsetTopLeft-border-box.html.ini | 85 +++++++++++++++++++ .../css/cssom/serialize-values.html.ini | 17 +--- .../mozilla/meta-layout-2020/css/br.html.ini | 2 - .../css/input_whitespace.html.ini | 2 - ...ne_breaking_whitespace_collapse_a.html.ini | 2 - .../meta-layout-2020/css/many_brs_a.html.ini | 2 - .../css/white-space-pre-line.htm.ini | 2 + .../white_space_intrinsic_sizes_a.html.ini | 2 - .../css/whitespace_pre.html.ini | 2 - .../css/word-break-keep-all-005.htm.ini | 2 - .../css/word-break-keep-all-006.htm.ini | 2 - .../css/word-break-keep-all-007.htm.ini | 2 - .../mozilla/hit_test_multiple_sc.html.ini | 4 + 55 files changed, 167 insertions(+), 113 deletions(-) delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/abspos/hypothetical-inline-alone-on-second-line.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/colors/color-applies-to-008.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/colors/color-applies-to-015.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/css1/c562-white-sp-000.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/floats-clear/float-003.xht.ini create mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/floats/float-no-content-beside-001.html.ini create mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-vertical-004.xht.ini create mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-004.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-171.xht.ini create mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-173.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-newline-001.xht.ini create mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-white-space-002.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/padding-percentage-inherit-001.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/block-replaced-width-006.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inline-replaced-width-001.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inline-replaced-width-006.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inlines-016.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/positioning/absolute-non-replaced-height-008.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/positioning/position-static-001.xht.ini create mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/tables/table-anonymous-objects-009.xht.ini create mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/tables/table-anonymous-objects-010.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-004.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-applies-to-003.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-013.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-016.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-017.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-018.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-046.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-047.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-052.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/visuren/anonymous-boxes-001b.xht.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-027.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-028.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-030.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-031.html.ini create mode 100644 tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-004.html.ini create mode 100644 tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-005.html.ini create mode 100644 tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-006.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/css-text-decor/text-decoration-subelements-001.html.ini create mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/offsetTopLeft-border-box.html.ini delete mode 100644 tests/wpt/mozilla/meta-layout-2020/css/br.html.ini delete mode 100644 tests/wpt/mozilla/meta-layout-2020/css/input_whitespace.html.ini delete mode 100644 tests/wpt/mozilla/meta-layout-2020/css/line_breaking_whitespace_collapse_a.html.ini delete mode 100644 tests/wpt/mozilla/meta-layout-2020/css/many_brs_a.html.ini create mode 100644 tests/wpt/mozilla/meta-layout-2020/css/white-space-pre-line.htm.ini delete mode 100644 tests/wpt/mozilla/meta-layout-2020/css/white_space_intrinsic_sizes_a.html.ini delete mode 100644 tests/wpt/mozilla/meta-layout-2020/css/whitespace_pre.html.ini delete mode 100644 tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-005.htm.ini delete mode 100644 tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-006.htm.ini delete mode 100644 tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-007.htm.ini create mode 100644 tests/wpt/mozilla/meta-layout-2020/mozilla/hit_test_multiple_sc.html.ini diff --git a/components/layout_2020/flow/construct.rs b/components/layout_2020/flow/construct.rs index 00bcfdd2586..73aa0c151b5 100644 --- a/components/layout_2020/flow/construct.rs +++ b/components/layout_2020/flow/construct.rs @@ -20,6 +20,7 @@ use rayon_croissant::ParallelIteratorExt; use servo_arc::Arc; use std::borrow::Cow; use std::convert::{TryFrom, TryInto}; +use style::computed_values::white_space::T as WhiteSpace; use style::properties::longhands::list_style_position::computed_value::T as ListStylePosition; use style::properties::ComputedValues; use style::selector_parser::PseudoElement; @@ -293,7 +294,8 @@ where } fn handle_text(&mut self, info: &NodeAndStyleInfo, input: Cow<'dom, str>) { - let (leading_whitespace, mut input) = self.handle_leading_whitespace(&input); + let white_space = info.style.get_inherited_text().white_space; + let (leading_whitespace, mut input) = self.handle_leading_whitespace(&input, white_space); if leading_whitespace || !input.is_empty() { // This text node should be pushed either to the next ongoing // inline level box with the parent style of that inline level box @@ -323,20 +325,37 @@ where if leading_whitespace { output.push(' ') } - loop { - if let Some(i) = input.bytes().position(|b| b.is_ascii_whitespace()) { - let (non_whitespace, rest) = input.split_at(i); - output.push_str(non_whitespace); - output.push(' '); - if let Some(i) = rest.bytes().position(|b| !b.is_ascii_whitespace()) { - input = &rest[i..]; + + match ( + white_space.preserve_spaces(), + white_space.preserve_newlines(), + ) { + (true, true) => { + output.push_str(input); + }, + + (true, false) => unreachable!(), + + (false, preserve_newlines) => loop { + if let Some(i) = input.bytes().position(|b| { + b.is_ascii_whitespace() && (!preserve_newlines || b != b'\n') + }) { + let (non_whitespace, rest) = input.split_at(i); + output.push_str(non_whitespace); + output.push(' '); + + if let Some(i) = rest.bytes().position(|b| { + !b.is_ascii_whitespace() || (preserve_newlines && b == b'\n') + }) { + input = &rest[i..]; + } else { + break; + } } else { + output.push_str(input); break; } - } else { - output.push_str(input); - break; - } + }, } } @@ -359,10 +378,14 @@ where /// /// * Whether this text run has preserved (non-collapsible) leading whitespace /// * The contents starting at the first non-whitespace character (or the empty string) - fn handle_leading_whitespace<'text>(&mut self, text: &'text str) -> (bool, &'text str) { + fn handle_leading_whitespace<'text>( + &mut self, + text: &'text str, + white_space: WhiteSpace, + ) -> (bool, &'text str) { // FIXME: this is only an approximation of // https://drafts.csswg.org/css2/text.html#white-space-model - if !text.starts_with(|c: char| c.is_ascii_whitespace()) { + if !text.starts_with(|c: char| c.is_ascii_whitespace()) || white_space.preserve_spaces() { return (false, text); } diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs index f0d0f51ba50..d0b91aef506 100644 --- a/components/layout_2020/flow/inline.rs +++ b/components/layout_2020/flow/inline.rs @@ -756,13 +756,15 @@ impl TextRun { let mut glyphs = vec![]; let mut advance_width = Length::zero(); let mut last_break_opportunity = None; + let mut force_line_break = false; loop { let next = runs.next(); - if next - .as_ref() - .map_or(true, |run| run.glyph_store.is_whitespace()) - { - if advance_width > ifc.containing_block.inline_size - ifc.inline_position { + if next.as_ref().map_or(true, |run| { + run.glyph_store.is_whitespace() || force_line_break + }) { + if advance_width > ifc.containing_block.inline_size - ifc.inline_position || + force_line_break + { if let Some((len, width, iter)) = last_break_opportunity.take() { glyphs.truncate(len); advance_width = width; @@ -774,6 +776,14 @@ impl TextRun { if let Some(run) = next { if run.glyph_store.is_whitespace() { last_break_opportunity = Some((glyphs.len(), advance_width, runs.clone())); + if self.text.as_bytes().get(run.range.end().to_usize() - 1) == Some(&b'\n') + { + force_line_break = self + .parent_style + .get_inherited_text() + .white_space + .preserve_newlines(); + } } glyphs.push(run.glyph_store.clone()); advance_width += Length::from(run.glyph_store.total_advance()); @@ -812,7 +822,7 @@ impl TextRun { glyphs, text_decoration_line: ifc.current_nesting_level.text_decoration_line, })); - if runs.as_slice().is_empty() { + if runs.as_slice().is_empty() && !force_line_break { break; } else { // New line diff --git a/components/style/properties/longhands/inherited_text.mako.rs b/components/style/properties/longhands/inherited_text.mako.rs index 41614a04d92..6587627a58f 100644 --- a/components/style/properties/longhands/inherited_text.mako.rs +++ b/components/style/properties/longhands/inherited_text.mako.rs @@ -186,7 +186,6 @@ ${helpers.predefined_type( name="white-space" values="normal pre nowrap pre-wrap pre-line" engines="gecko servo-2013 servo-2020", - servo_2020_pref="layout.2020.unimplemented", extra_gecko_values="break-spaces -moz-pre-space" gecko_enum_prefix="StyleWhiteSpace" needs_conversion="True" diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/abspos/hypothetical-inline-alone-on-second-line.html.ini b/tests/wpt/metadata-layout-2020/css/CSS2/abspos/hypothetical-inline-alone-on-second-line.html.ini deleted file mode 100644 index df17fc5f182..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/abspos/hypothetical-inline-alone-on-second-line.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[hypothetical-inline-alone-on-second-line.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/colors/color-applies-to-008.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/colors/color-applies-to-008.xht.ini deleted file mode 100644 index 09b26767921..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/colors/color-applies-to-008.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[color-applies-to-008.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/colors/color-applies-to-015.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/colors/color-applies-to-015.xht.ini deleted file mode 100644 index c5be6b4fcad..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/colors/color-applies-to-015.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[color-applies-to-015.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/css1/c562-white-sp-000.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/css1/c562-white-sp-000.xht.ini deleted file mode 100644 index f256b9fa665..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/css1/c562-white-sp-000.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[c562-white-sp-000.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats-clear/float-003.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats-clear/float-003.xht.ini deleted file mode 100644 index d7b0c2ca89d..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/floats-clear/float-003.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[float-003.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats/float-no-content-beside-001.html.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats/float-no-content-beside-001.html.ini new file mode 100644 index 00000000000..7b131324eca --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/CSS2/floats/float-no-content-beside-001.html.ini @@ -0,0 +1,2 @@ +[float-no-content-beside-001.html] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-vertical-004.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-vertical-004.xht.ini new file mode 100644 index 00000000000..6036454a24a --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/CSS2/floats/floats-placement-vertical-004.xht.ini @@ -0,0 +1,2 @@ +[floats-placement-vertical-004.xht] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-004.html.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-004.html.ini new file mode 100644 index 00000000000..4bfb0c2053a --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-004.html.ini @@ -0,0 +1,4 @@ +[hit-test-floats-004.html] + [Miss float below something else] + expected: FAIL + diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-171.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-171.xht.ini deleted file mode 100644 index 17841b6e37d..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-171.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[content-171.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-173.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-173.xht.ini new file mode 100644 index 00000000000..27d146b4f76 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-173.xht.ini @@ -0,0 +1,2 @@ +[content-173.xht] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-newline-001.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-newline-001.xht.ini deleted file mode 100644 index 898b224f106..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-newline-001.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[content-newline-001.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-white-space-002.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-white-space-002.xht.ini new file mode 100644 index 00000000000..d9895725434 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/CSS2/generated-content/content-white-space-002.xht.ini @@ -0,0 +1,2 @@ +[content-white-space-002.xht] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/padding-percentage-inherit-001.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/padding-percentage-inherit-001.xht.ini deleted file mode 100644 index f3c8ca13fcc..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/margin-padding-clear/padding-percentage-inherit-001.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[padding-percentage-inherit-001.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/block-replaced-width-006.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/block-replaced-width-006.xht.ini deleted file mode 100644 index 6b28c0a7732..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/block-replaced-width-006.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[block-replaced-width-006.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inline-replaced-width-001.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inline-replaced-width-001.xht.ini deleted file mode 100644 index f90e509741a..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inline-replaced-width-001.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[inline-replaced-width-001.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inline-replaced-width-006.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inline-replaced-width-006.xht.ini deleted file mode 100644 index 3b1738d27e4..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inline-replaced-width-006.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[inline-replaced-width-006.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inlines-016.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inlines-016.xht.ini deleted file mode 100644 index 08323ae34d3..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/normal-flow/inlines-016.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[inlines-016.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/positioning/absolute-non-replaced-height-008.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/positioning/absolute-non-replaced-height-008.xht.ini deleted file mode 100644 index a8181f873e1..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/positioning/absolute-non-replaced-height-008.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[absolute-non-replaced-height-008.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/positioning/position-static-001.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/positioning/position-static-001.xht.ini deleted file mode 100644 index b8665fc1939..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/positioning/position-static-001.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[position-static-001.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/tables/table-anonymous-objects-009.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/tables/table-anonymous-objects-009.xht.ini new file mode 100644 index 00000000000..91d95f9df47 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/CSS2/tables/table-anonymous-objects-009.xht.ini @@ -0,0 +1,2 @@ +[table-anonymous-objects-009.xht] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/tables/table-anonymous-objects-010.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/tables/table-anonymous-objects-010.xht.ini new file mode 100644 index 00000000000..12c3a9c74b3 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/CSS2/tables/table-anonymous-objects-010.xht.ini @@ -0,0 +1,2 @@ +[table-anonymous-objects-010.xht] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-004.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-004.xht.ini deleted file mode 100644 index d2813834d88..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-004.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[white-space-004.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-applies-to-003.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-applies-to-003.xht.ini deleted file mode 100644 index a577c292396..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-applies-to-003.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[white-space-applies-to-003.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-013.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-013.xht.ini deleted file mode 100644 index d4163fc0bd8..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-013.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[white-space-processing-013.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-016.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-016.xht.ini deleted file mode 100644 index 8ce343d746f..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-016.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[white-space-processing-016.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-017.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-017.xht.ini deleted file mode 100644 index df0a0b0c0a4..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-017.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[white-space-processing-017.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-018.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-018.xht.ini deleted file mode 100644 index f6ed836f1da..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-018.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[white-space-processing-018.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-046.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-046.xht.ini deleted file mode 100644 index a4fb2e4fe18..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-046.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[white-space-processing-046.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-047.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-047.xht.ini deleted file mode 100644 index 8046ab670c7..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-047.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[white-space-processing-047.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-052.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-052.xht.ini deleted file mode 100644 index f981ec7b5d5..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/text/white-space-processing-052.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[white-space-processing-052.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/visuren/anonymous-boxes-001b.xht.ini b/tests/wpt/metadata-layout-2020/css/CSS2/visuren/anonymous-boxes-001b.xht.ini deleted file mode 100644 index 67b06807a43..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/visuren/anonymous-boxes-001b.xht.ini +++ /dev/null @@ -1,2 +0,0 @@ -[anonymous-boxes-001b.xht] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-027.html.ini b/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-027.html.ini deleted file mode 100644 index 5c1f927e20e..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-027.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[background-size-027.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-028.html.ini b/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-028.html.ini deleted file mode 100644 index baa377e6a97..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-028.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[background-size-028.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-030.html.ini b/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-030.html.ini deleted file mode 100644 index 8f67471d49f..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-030.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[background-size-030.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-031.html.ini b/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-031.html.ini deleted file mode 100644 index 227740a1cbb..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-size-031.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[background-size-031.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-004.html.ini b/tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-004.html.ini new file mode 100644 index 00000000000..7df62ee8875 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-004.html.ini @@ -0,0 +1,2 @@ +[anonymous-flex-item-004.html] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-005.html.ini b/tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-005.html.ini new file mode 100644 index 00000000000..f5db1aa1610 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-005.html.ini @@ -0,0 +1,2 @@ +[anonymous-flex-item-005.html] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-006.html.ini b/tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-006.html.ini new file mode 100644 index 00000000000..5865ea15bc8 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/css-flexbox/anonymous-flex-item-006.html.ini @@ -0,0 +1,2 @@ +[anonymous-flex-item-006.html] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-text-decor/text-decoration-subelements-001.html.ini b/tests/wpt/metadata-layout-2020/css/css-text-decor/text-decoration-subelements-001.html.ini deleted file mode 100644 index e1bbdb7fc9d..00000000000 --- a/tests/wpt/metadata-layout-2020/css/css-text-decor/text-decoration-subelements-001.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[text-decoration-subelements-001.html] - expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/cssom-view/offsetTopLeft-border-box.html.ini b/tests/wpt/metadata-layout-2020/css/cssom-view/offsetTopLeft-border-box.html.ini new file mode 100644 index 00000000000..3bd0a5266dd --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/cssom-view/offsetTopLeft-border-box.html.ini @@ -0,0 +1,85 @@ +[offsetTopLeft-border-box.html] + [container: 11] + expected: FAIL + + [container: 10] + expected: FAIL + + [container: 13] + expected: FAIL + + [container: 12] + expected: FAIL + + [container: 15] + expected: FAIL + + [container: 14] + expected: FAIL + + [container: 17] + expected: FAIL + + [container: 16] + expected: FAIL + + [container: 19] + expected: FAIL + + [container: 18] + expected: FAIL + + [container: 9] + expected: FAIL + + [container: 8] + expected: FAIL + + [container: 1] + expected: FAIL + + [container: 0] + expected: FAIL + + [container: 3] + expected: FAIL + + [container: 2] + expected: FAIL + + [container: 5] + expected: FAIL + + [container: 4] + expected: FAIL + + [container: 7] + expected: FAIL + + [container: 6] + expected: FAIL + + [container: 20] + expected: FAIL + + [container: 21] + expected: FAIL + + [container: 22] + expected: FAIL + + [container: 23] + expected: FAIL + + [container: 24] + expected: FAIL + + [container: 25] + expected: FAIL + + [container: 26] + expected: FAIL + + [container: 27] + expected: FAIL + diff --git a/tests/wpt/metadata-layout-2020/css/cssom/serialize-values.html.ini b/tests/wpt/metadata-layout-2020/css/cssom/serialize-values.html.ini index 0f09476f884..21832fe8ef4 100644 --- a/tests/wpt/metadata-layout-2020/css/cssom/serialize-values.html.ini +++ b/tests/wpt/metadata-layout-2020/css/cssom/serialize-values.html.ini @@ -23,15 +23,9 @@ [page-break-before: always] expected: FAIL - [white-space: inherit] - expected: FAIL - [page-break-after: inherit] expected: FAIL - [white-space: nowrap] - expected: FAIL - [page-break-before: left] expected: FAIL @@ -218,9 +212,6 @@ [display: table-cell] expected: FAIL - [white-space: pre] - expected: FAIL - [text-indent: 5%] expected: FAIL @@ -263,7 +254,7 @@ [clear: both] expected: FAIL - [white-space: pre-wrap] + [list-style-image: url(http://localhost/)] expected: FAIL [outline-width: 0px] @@ -332,9 +323,6 @@ [vertical-align: 1px] expected: FAIL - [white-space: pre-line] - expected: FAIL - [display: table-column] expected: FAIL @@ -395,9 +383,6 @@ [float: none] expected: FAIL - [white-space: normal] - expected: FAIL - [list-style-type: lower-roman] expected: FAIL diff --git a/tests/wpt/mozilla/meta-layout-2020/css/br.html.ini b/tests/wpt/mozilla/meta-layout-2020/css/br.html.ini deleted file mode 100644 index d4cc92b6bf0..00000000000 --- a/tests/wpt/mozilla/meta-layout-2020/css/br.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[br.html] - expected: FAIL diff --git a/tests/wpt/mozilla/meta-layout-2020/css/input_whitespace.html.ini b/tests/wpt/mozilla/meta-layout-2020/css/input_whitespace.html.ini deleted file mode 100644 index d4d47c4946b..00000000000 --- a/tests/wpt/mozilla/meta-layout-2020/css/input_whitespace.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[input_whitespace.html] - expected: FAIL diff --git a/tests/wpt/mozilla/meta-layout-2020/css/line_breaking_whitespace_collapse_a.html.ini b/tests/wpt/mozilla/meta-layout-2020/css/line_breaking_whitespace_collapse_a.html.ini deleted file mode 100644 index b4de5d5d47d..00000000000 --- a/tests/wpt/mozilla/meta-layout-2020/css/line_breaking_whitespace_collapse_a.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[line_breaking_whitespace_collapse_a.html] - expected: FAIL diff --git a/tests/wpt/mozilla/meta-layout-2020/css/many_brs_a.html.ini b/tests/wpt/mozilla/meta-layout-2020/css/many_brs_a.html.ini deleted file mode 100644 index cc004c9dffe..00000000000 --- a/tests/wpt/mozilla/meta-layout-2020/css/many_brs_a.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[many_brs_a.html] - expected: FAIL diff --git a/tests/wpt/mozilla/meta-layout-2020/css/white-space-pre-line.htm.ini b/tests/wpt/mozilla/meta-layout-2020/css/white-space-pre-line.htm.ini new file mode 100644 index 00000000000..b549416814c --- /dev/null +++ b/tests/wpt/mozilla/meta-layout-2020/css/white-space-pre-line.htm.ini @@ -0,0 +1,2 @@ +[white-space-pre-line.htm] + expected: FAIL diff --git a/tests/wpt/mozilla/meta-layout-2020/css/white_space_intrinsic_sizes_a.html.ini b/tests/wpt/mozilla/meta-layout-2020/css/white_space_intrinsic_sizes_a.html.ini deleted file mode 100644 index 1330b71867f..00000000000 --- a/tests/wpt/mozilla/meta-layout-2020/css/white_space_intrinsic_sizes_a.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[white_space_intrinsic_sizes_a.html] - expected: FAIL diff --git a/tests/wpt/mozilla/meta-layout-2020/css/whitespace_pre.html.ini b/tests/wpt/mozilla/meta-layout-2020/css/whitespace_pre.html.ini deleted file mode 100644 index 891465ffedf..00000000000 --- a/tests/wpt/mozilla/meta-layout-2020/css/whitespace_pre.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[whitespace_pre.html] - expected: FAIL diff --git a/tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-005.htm.ini b/tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-005.htm.ini deleted file mode 100644 index 7f36a3f3fd4..00000000000 --- a/tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-005.htm.ini +++ /dev/null @@ -1,2 +0,0 @@ -[word-break-keep-all-005.htm] - expected: FAIL diff --git a/tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-006.htm.ini b/tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-006.htm.ini deleted file mode 100644 index 65ad4524b55..00000000000 --- a/tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-006.htm.ini +++ /dev/null @@ -1,2 +0,0 @@ -[word-break-keep-all-006.htm] - expected: FAIL diff --git a/tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-007.htm.ini b/tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-007.htm.ini deleted file mode 100644 index 48e6b6c94b5..00000000000 --- a/tests/wpt/mozilla/meta-layout-2020/css/word-break-keep-all-007.htm.ini +++ /dev/null @@ -1,2 +0,0 @@ -[word-break-keep-all-007.htm] - expected: FAIL diff --git a/tests/wpt/mozilla/meta-layout-2020/mozilla/hit_test_multiple_sc.html.ini b/tests/wpt/mozilla/meta-layout-2020/mozilla/hit_test_multiple_sc.html.ini new file mode 100644 index 00000000000..8ed8088a59f --- /dev/null +++ b/tests/wpt/mozilla/meta-layout-2020/mozilla/hit_test_multiple_sc.html.ini @@ -0,0 +1,4 @@ +[hit_test_multiple_sc.html] + [Hit testing works for following stacking contexts] + expected: FAIL + From 260347e5dc287b7d47e29c97d08fa4abba3e8a75 Mon Sep 17 00:00:00 2001 From: Josh Matthews Date: Fri, 24 Jul 2020 14:57:11 -0400 Subject: [PATCH 2/3] Simplify control flow of whitespace handling. --- components/layout_2020/flow/construct.rs | 134 ++++++++++-------- components/layout_2020/flow/inline.rs | 35 +++-- .../css/cssom/serialize-values.html.ini | 3 - 3 files changed, 100 insertions(+), 72 deletions(-) diff --git a/components/layout_2020/flow/construct.rs b/components/layout_2020/flow/construct.rs index 73aa0c151b5..5cb1fe51e73 100644 --- a/components/layout_2020/flow/construct.rs +++ b/components/layout_2020/flow/construct.rs @@ -294,78 +294,96 @@ where } fn handle_text(&mut self, info: &NodeAndStyleInfo, input: Cow<'dom, str>) { + // Skip any leading whitespace as dictated by the node's style. let white_space = info.style.get_inherited_text().white_space; - let (leading_whitespace, mut input) = self.handle_leading_whitespace(&input, white_space); - if leading_whitespace || !input.is_empty() { - // This text node should be pushed either to the next ongoing - // inline level box with the parent style of that inline level box - // that will be ended, or directly to the ongoing inline formatting - // context with the parent style of that builder. - let inlines = self.current_inline_level_boxes(); + let (preserved_leading_whitespace, mut input) = + self.handle_leading_whitespace(&input, white_space); - let mut new_text_run_contents; - let output; + if !preserved_leading_whitespace && input.is_empty() { + return; + } - { - let mut last_box = inlines.last_mut().map(|last| last.borrow_mut()); - let last_text = last_box.as_mut().and_then(|last| match &mut **last { - InlineLevelBox::TextRun(last) => Some(&mut last.text), - _ => None, - }); + // This text node should be pushed either to the next ongoing + // inline level box with the parent style of that inline level box + // that will be ended, or directly to the ongoing inline formatting + // context with the parent style of that builder. + let inlines = self.current_inline_level_boxes(); - if let Some(text) = last_text { - // Append to the existing text run - new_text_run_contents = None; - output = text; - } else { - new_text_run_contents = Some(String::new()); - output = new_text_run_contents.as_mut().unwrap(); - } + let mut new_text_run_contents; + let output; - if leading_whitespace { - output.push(' ') - } + { + let mut last_box = inlines.last_mut().map(|last| last.borrow_mut()); + let last_text = last_box.as_mut().and_then(|last| match &mut **last { + InlineLevelBox::TextRun(last) => Some(&mut last.text), + _ => None, + }); - match ( - white_space.preserve_spaces(), - white_space.preserve_newlines(), - ) { - (true, true) => { - output.push_str(input); - }, + if let Some(text) = last_text { + // Append to the existing text run + new_text_run_contents = None; + output = text; + } else { + new_text_run_contents = Some(String::new()); + output = new_text_run_contents.as_mut().unwrap(); + } - (true, false) => unreachable!(), + if preserved_leading_whitespace { + output.push(' ') + } - (false, preserve_newlines) => loop { - if let Some(i) = input.bytes().position(|b| { - b.is_ascii_whitespace() && (!preserve_newlines || b != b'\n') + match ( + white_space.preserve_spaces(), + white_space.preserve_newlines(), + ) { + // All whitespace is significant, so we don't need to transform + // the input at all. + (true, true) => { + output.push_str(input); + }, + + // There are no cases in CSS where where need to preserve spaces + // but not newlines. + (true, false) => unreachable!(), + + // Spaces are not significant, but newlines might be. We need + // to collapse non-significant whitespace as appropriate. + (false, preserve_newlines) => loop { + // If there are any spaces that need preserving, split the string + // that precedes them, collapse them into a single whitespace, + // then process the remainder of the string independently. + if let Some(i) = input + .bytes() + .position(|b| b.is_ascii_whitespace() && (!preserve_newlines || b != b'\n')) + { + let (non_whitespace, rest) = input.split_at(i); + output.push_str(non_whitespace); + output.push(' '); + + // Find the first byte that is either significant whitespace or + // non-whitespace to continue processing it. + if let Some(i) = rest.bytes().position(|b| { + !b.is_ascii_whitespace() || (preserve_newlines && b == b'\n') }) { - let (non_whitespace, rest) = input.split_at(i); - output.push_str(non_whitespace); - output.push(' '); - - if let Some(i) = rest.bytes().position(|b| { - !b.is_ascii_whitespace() || (preserve_newlines && b == b'\n') - }) { - input = &rest[i..]; - } else { - break; - } + input = &rest[i..]; } else { - output.push_str(input); break; } - }, - } + } else { + // No whitespace found, so no transformation is required. + output.push_str(input); + break; + } + }, } + } - if let Some(text) = new_text_run_contents { - inlines.push(ArcRefCell::new(InlineLevelBox::TextRun(TextRun { - tag: Tag::from_node_and_style_info(info), - parent_style: Arc::clone(&info.style), - text, - }))) - } + if let Some(text) = new_text_run_contents { + inlines.push(ArcRefCell::new(InlineLevelBox::TextRun(TextRun { + tag: Tag::from_node_and_style_info(info), + parent_style: Arc::clone(&info.style), + text, + }))) } } } diff --git a/components/layout_2020/flow/inline.rs b/components/layout_2020/flow/inline.rs index d0b91aef506..fa79264db5a 100644 --- a/components/layout_2020/flow/inline.rs +++ b/components/layout_2020/flow/inline.rs @@ -757,14 +757,20 @@ impl TextRun { let mut advance_width = Length::zero(); let mut last_break_opportunity = None; let mut force_line_break = false; + // Fit as many glyphs within a single line as possible. loop { let next = runs.next(); - if next.as_ref().map_or(true, |run| { - run.glyph_store.is_whitespace() || force_line_break - }) { - if advance_width > ifc.containing_block.inline_size - ifc.inline_position || - force_line_break - { + // If there are no more text runs we still need to check if the last + // run was a forced line break + if next + .as_ref() + .map_or(true, |run| run.glyph_store.is_whitespace()) + { + // If this run exceeds the bounds of the containing block, then + // we need to attempt to break the line. + if advance_width > ifc.containing_block.inline_size - ifc.inline_position { + // Reset the text run iterator to the last whitespace if possible, + // to attempt to re-layout the most recent glyphs on a new line. if let Some((len, width, iter)) = last_break_opportunity.take() { glyphs.truncate(len); advance_width = width; @@ -776,18 +782,24 @@ impl TextRun { if let Some(run) = next { if run.glyph_store.is_whitespace() { last_break_opportunity = Some((glyphs.len(), advance_width, runs.clone())); - if self.text.as_bytes().get(run.range.end().to_usize() - 1) == Some(&b'\n') - { - force_line_break = self - .parent_style + // If this whitespace ends with a newline, we need to check if + // it's meaningful within the current style. If so, we force + // a line break immediately. + let last_byte = self.text.as_bytes().get(run.range.end().to_usize() - 1); + if last_byte == Some(&b'\n') && + self.parent_style .get_inherited_text() .white_space - .preserve_newlines(); + .preserve_newlines() + { + force_line_break = true; + break; } } glyphs.push(run.glyph_store.clone()); advance_width += Length::from(run.glyph_store.total_advance()); } else { + // No more runs, so we can end the line. break; } } @@ -822,6 +834,7 @@ impl TextRun { glyphs, text_decoration_line: ifc.current_nesting_level.text_decoration_line, })); + // If this line is being broken because of a trailing newline, we can't ignore it. if runs.as_slice().is_empty() && !force_line_break { break; } else { diff --git a/tests/wpt/metadata-layout-2020/css/cssom/serialize-values.html.ini b/tests/wpt/metadata-layout-2020/css/cssom/serialize-values.html.ini index 21832fe8ef4..89f8f5b5a5e 100644 --- a/tests/wpt/metadata-layout-2020/css/cssom/serialize-values.html.ini +++ b/tests/wpt/metadata-layout-2020/css/cssom/serialize-values.html.ini @@ -254,9 +254,6 @@ [clear: both] expected: FAIL - [list-style-image: url(http://localhost/)] - expected: FAIL - [outline-width: 0px] expected: FAIL From 720d8a12b8159e88c9bb46c71d50778b10042d37 Mon Sep 17 00:00:00 2001 From: WPT Sync Bot Date: Wed, 29 Jul 2020 08:21:27 +0000 Subject: [PATCH 3/3] Update web-platform-tests to revision 43ef1ad9afcc9d9d922a5a96bc12b4eaf950960b --- .../FileAPI/url/url-charset.window.js.ini | 8 + ....html.ini => hit-test-floats-004.html.ini} | 2 +- .../CSS2/floats/hit-test-floats-005.html.ini | 4 - .../inline-negative-margin-001.html.ini | 27 -- .../background-attachment-353.html.ini | 2 + .../css-flexbox/grid-flex-item-005.html.ini | 2 + .../transform-scale-hittest.html.ini | 3 - .../css/cssom-view/CaretPosition-001.html.ini | 4 - .../css/cssom-view/client-props-root.html.ini | 4 + .../matchMedia-display-none-iframe.html.ini | 2 + .../reactions/HTMLMediaElement.html.ini | 2 - .../fetch/content-type/response.window.js.ini | 24 +- .../fetch/content-type/script.window.js.ini | 3 - .../nosniff/parsing-nosniff.window.js.ini | 3 + .../traverse_the_history_1.html.ini | 4 - .../traverse_the_history_2.html.ini | 4 - .../traverse_the_history_3.html.ini | 4 - ...ross-origin-objects-on-new-window.html.ini | 2 + .../embedded-opener-remove-frame.html.ini | 1 + .../iframe_sandbox_popups_escaping-1.html.ini | 3 +- .../iframe_sandbox_popups_escaping-2.html.ini | 1 + .../iframe_sandbox_popups_escaping-3.html.ini | 3 +- ...rame_sandbox_popups_nonescaping-1.html.ini | 2 +- ...rame_sandbox_popups_nonescaping-3.html.ini | 3 +- .../execution-timing/077.html.ini | 4 + .../module-static-import-delayed.html.ini | 4 - .../ignore-opens-during-unload.window.js.ini | 2 +- ...le-event-handler-settings-objects.html.ini | 3 + .../jsapi/constructor/toStringTag.any.js.ini} | 4 +- .../Worker/Worker-constructor.html.ini | 2 + .../FileAPI/url/url-charset.window.js.ini | 8 + tests/wpt/metadata/MANIFEST.json | 293 ++++++++++++++++-- ....html.ini => hit-test-floats-004.html.ini} | 2 +- .../CSS2/floats/hit-test-floats-005.html.ini | 4 - .../inline-negative-margin-001.html.ini | 5 +- .../background-attachment-353.html.ini | 2 + .../css-flexbox/grid-flex-item-005.html.ini | 2 + .../transform-scale-hittest.html.ini | 3 - .../css/cssom-view/CaretPosition-001.html.ini | 4 - .../css/cssom-view/client-props-root.html.ini | 4 + .../matchMedia-display-none-iframe.html.ini | 2 + .../reactions/HTMLMediaElement.html.ini | 2 - .../fetch/content-type/response.window.js.ini | 24 +- .../fetch/content-type/script.window.js.ini | 3 - .../nosniff/parsing-nosniff.window.js.ini | 3 + .../traverse_the_history_1.html.ini | 4 - .../traverse_the_history_2.html.ini | 4 - .../traverse_the_history_3.html.ini | 4 - ...ross-origin-objects-on-new-window.html.ini | 2 + .../embedded-opener-remove-frame.html.ini | 1 + .../iframe_sandbox_popups_escaping-1.html.ini | 3 +- .../iframe_sandbox_popups_escaping-2.html.ini | 1 + .../iframe_sandbox_popups_escaping-3.html.ini | 3 +- ...rame_sandbox_popups_nonescaping-1.html.ini | 2 +- ...rame_sandbox_popups_nonescaping-3.html.ini | 3 +- .../execution-timing/077.html.ini | 4 + .../module-static-import-delayed.html.ini | 4 - .../ignore-opens-during-unload.window.js.ini | 2 +- ...le-event-handler-settings-objects.html.ini | 3 + .../jsapi/constructor/toStringTag.any.js.ini | 21 ++ .../Worker/Worker-constructor.html.ini | 2 + .../web-platform-tests/.azure-pipelines.yml | 2 +- .../audio-output/setSinkId.https.html | 2 + .../cookie-store/resources/cookie_helper.py | 74 +++-- .../background-attachment-353.html | 131 ++++++++ .../css-backgrounds/support/100x100-gr-rr.png | Bin 0 -> 1216 bytes .../css/css-flexbox/grid-flex-item-005.html | 15 + .../alignment/grid-place-content-001.html | 139 +++++++++ .../active-selection-001-manual.html | 37 +++ .../active-selection-002-manual.html | 47 +++ .../active-selection-003-manual.html | 42 +++ .../active-selection-004-manual.html | 36 +++ .../css/css-pseudo/active-selection-011.html | 43 +++ .../css/css-pseudo/active-selection-012.html | 51 +++ .../css/css-pseudo/active-selection-014.html | 55 ++++ .../css/css-pseudo/active-selection-016.html | 46 +++ .../css/css-pseudo/active-selection-018.html | 60 ++++ .../reference/active-selection-011-ref.html | 19 ++ .../reference/active-selection-012-ref.html | 21 ++ .../reference/active-selection-014-ref.html | 47 +++ .../reference/active-selection-016-ref.html | 22 ++ .../selection-intercharacter-011-ref.html | 11 +- .../selection-intercharacter-012-ref.html | 11 +- .../selection-intercharacter-011.html | 2 +- .../selection-intercharacter-012.html | 2 +- .../css/css-pseudo/support/select-custom.cur | Bin 0 -> 326 bytes .../css/css-pseudo/support/select-custom.png | Bin 0 -> 337 bytes .../css/cssom-view/client-props-root.html | 29 ++ .../fetch/range/resources/long-wav.py | 7 +- ...restoration-in-different-site-iframes.html | 16 + ...ation-in-different-site-iframes-inner.html | 37 +++ ...ation-in-different-site-iframes-other.html | 7 + ...n-in-different-site-iframes-outer.sub.html | 39 +++ .../window-open-invalid-url.html | 10 + .../access-reporting/property.https.html | 2 - .../reporting/resources/dispatcher.py | 15 +- .../support/download_stash.py | 3 +- .../interfaces/geolocation-API.idl | 4 +- .../layout-instability/move-transformed.html | 28 ++ .../layout-instability/transform-change.html | 33 ++ tests/wpt/web-platform-tests/lint.ignore | 1 + .../MediaDevices-getUserMedia.https.html | 4 + .../idlharness.https.window.js | 2 + .../web-platform-tests/tools/ci/pr_preview.py | 79 ++++- .../tools/ci/tests/test_pr_preview.py | 38 +++ .../web-platform-tests/tools/wpt/browser.py | 10 +- .../tools/wpt/tests/test_install.py | 12 +- .../toStringTag.any.js} | 2 + 108 files changed, 1609 insertions(+), 244 deletions(-) create mode 100644 tests/wpt/metadata-layout-2020/FileAPI/url/url-charset.window.js.ini rename tests/wpt/metadata-layout-2020/css/CSS2/floats/{hit-test-floats-003.html.ini => hit-test-floats-004.html.ini} (67%) delete mode 100644 tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-005.html.ini create mode 100644 tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-353.html.ini create mode 100644 tests/wpt/metadata-layout-2020/css/css-flexbox/grid-flex-item-005.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/CaretPosition-001.html.ini create mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/client-props-root.html.ini create mode 100644 tests/wpt/metadata-layout-2020/css/cssom-view/matchMedia-display-none-iframe.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/custom-elements/reactions/HTMLMediaElement.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/html/browsers/history/the-history-interface/traverse_the_history_1.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/html/browsers/history/the-history-interface/traverse_the_history_2.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/html/browsers/history/the-history-interface/traverse_the_history_3.html.ini create mode 100644 tests/wpt/metadata-layout-2020/html/browsers/origin/cross-origin-objects/cross-origin-objects-on-new-window.html.ini create mode 100644 tests/wpt/metadata-layout-2020/html/semantics/scripting-1/the-script-element/execution-timing/077.html.ini delete mode 100644 tests/wpt/metadata-layout-2020/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.html.ini rename tests/wpt/{metadata/wasm/jsapi/namespace-object-class-string.any.js.ini => metadata-layout-2020/wasm/jsapi/constructor/toStringTag.any.js.ini} (87%) create mode 100644 tests/wpt/metadata-layout-2020/workers/constructors/Worker/Worker-constructor.html.ini create mode 100644 tests/wpt/metadata/FileAPI/url/url-charset.window.js.ini rename tests/wpt/metadata/css/CSS2/floats/{hit-test-floats-003.html.ini => hit-test-floats-004.html.ini} (67%) delete mode 100644 tests/wpt/metadata/css/CSS2/floats/hit-test-floats-005.html.ini create mode 100644 tests/wpt/metadata/css/css-backgrounds/background-attachment-353.html.ini create mode 100644 tests/wpt/metadata/css/css-flexbox/grid-flex-item-005.html.ini delete mode 100644 tests/wpt/metadata/css/cssom-view/CaretPosition-001.html.ini create mode 100644 tests/wpt/metadata/css/cssom-view/client-props-root.html.ini create mode 100644 tests/wpt/metadata/css/cssom-view/matchMedia-display-none-iframe.html.ini delete mode 100644 tests/wpt/metadata/custom-elements/reactions/HTMLMediaElement.html.ini delete mode 100644 tests/wpt/metadata/html/browsers/history/the-history-interface/traverse_the_history_1.html.ini delete mode 100644 tests/wpt/metadata/html/browsers/history/the-history-interface/traverse_the_history_2.html.ini delete mode 100644 tests/wpt/metadata/html/browsers/history/the-history-interface/traverse_the_history_3.html.ini create mode 100644 tests/wpt/metadata/html/browsers/origin/cross-origin-objects/cross-origin-objects-on-new-window.html.ini create mode 100644 tests/wpt/metadata/html/semantics/scripting-1/the-script-element/execution-timing/077.html.ini delete mode 100644 tests/wpt/metadata/html/webappapis/dynamic-markup-insertion/document-write/module-static-import-delayed.html.ini create mode 100644 tests/wpt/metadata/wasm/jsapi/constructor/toStringTag.any.js.ini create mode 100644 tests/wpt/metadata/workers/constructors/Worker/Worker-constructor.html.ini create mode 100644 tests/wpt/web-platform-tests/css/css-backgrounds/background-attachment-353.html create mode 100644 tests/wpt/web-platform-tests/css/css-backgrounds/support/100x100-gr-rr.png create mode 100644 tests/wpt/web-platform-tests/css/css-flexbox/grid-flex-item-005.html create mode 100644 tests/wpt/web-platform-tests/css/css-grid/alignment/grid-place-content-001.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/active-selection-001-manual.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/active-selection-002-manual.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/active-selection-003-manual.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/active-selection-004-manual.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/active-selection-011.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/active-selection-012.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/active-selection-014.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/active-selection-016.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/active-selection-018.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/reference/active-selection-011-ref.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/reference/active-selection-012-ref.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/reference/active-selection-014-ref.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/reference/active-selection-016-ref.html create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/support/select-custom.cur create mode 100644 tests/wpt/web-platform-tests/css/css-pseudo/support/select-custom.png create mode 100644 tests/wpt/web-platform-tests/css/cssom-view/client-props-root.html create mode 100644 tests/wpt/web-platform-tests/focus/focus-restoration-in-different-site-iframes.html create mode 100644 tests/wpt/web-platform-tests/focus/support/focus-restoration-in-different-site-iframes-inner.html create mode 100644 tests/wpt/web-platform-tests/focus/support/focus-restoration-in-different-site-iframes-other.html create mode 100644 tests/wpt/web-platform-tests/focus/support/focus-restoration-in-different-site-iframes-outer.sub.html create mode 100644 tests/wpt/web-platform-tests/html/browsers/the-window-object/window-open-invalid-url.html create mode 100644 tests/wpt/web-platform-tests/layout-instability/move-transformed.html create mode 100644 tests/wpt/web-platform-tests/layout-instability/transform-change.html rename tests/wpt/web-platform-tests/wasm/jsapi/{namespace-object-class-string.any.js => constructor/toStringTag.any.js} (97%) diff --git a/tests/wpt/metadata-layout-2020/FileAPI/url/url-charset.window.js.ini b/tests/wpt/metadata-layout-2020/FileAPI/url/url-charset.window.js.ini new file mode 100644 index 00000000000..a9005e45d6e --- /dev/null +++ b/tests/wpt/metadata-layout-2020/FileAPI/url/url-charset.window.js.ini @@ -0,0 +1,8 @@ +[url-charset.window.html] + expected: TIMEOUT + [Blob charset should override any auto-detected charset.] + expected: TIMEOUT + + [Blob charset should override .] + expected: TIMEOUT + diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-003.html.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-004.html.ini similarity index 67% rename from tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-003.html.ini rename to tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-004.html.ini index f29da48a2a0..4bfb0c2053a 100644 --- a/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-003.html.ini +++ b/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-004.html.ini @@ -1,4 +1,4 @@ -[hit-test-floats-003.html] +[hit-test-floats-004.html] [Miss float below something else] expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-005.html.ini b/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-005.html.ini deleted file mode 100644 index baa9f1a7541..00000000000 --- a/tests/wpt/metadata-layout-2020/css/CSS2/floats/hit-test-floats-005.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[hit-test-floats-005.html] - [Miss clipped float] - expected: FAIL - diff --git a/tests/wpt/metadata-layout-2020/css/CSS2/linebox/inline-negative-margin-001.html.ini b/tests/wpt/metadata-layout-2020/css/CSS2/linebox/inline-negative-margin-001.html.ini index 5643f1a8367..5e4d523cef9 100644 --- a/tests/wpt/metadata-layout-2020/css/CSS2/linebox/inline-negative-margin-001.html.ini +++ b/tests/wpt/metadata-layout-2020/css/CSS2/linebox/inline-negative-margin-001.html.ini @@ -11,36 +11,9 @@ [[data-expected-height\] 2] expected: FAIL - [[data-expected-height\] 4] - expected: FAIL - [[data-expected-height\] 1] expected: FAIL - [[data-expected-height\] 10] - expected: FAIL - [[data-expected-height\] 2] expected: FAIL - [[data-expected-height\] 5] - expected: FAIL - - [[data-expected-height\] 6] - expected: FAIL - - [[data-expected-height\] 9] - expected: FAIL - - [[data-expected-height\] 8] - expected: FAIL - - [[data-expected-height\] 13] - expected: FAIL - - [[data-expected-height\] 12] - expected: FAIL - - [[data-expected-height\] 11] - expected: FAIL - diff --git a/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-353.html.ini b/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-353.html.ini new file mode 100644 index 00000000000..d1af9d7d555 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/css-backgrounds/background-attachment-353.html.ini @@ -0,0 +1,2 @@ +[background-attachment-353.html] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-flexbox/grid-flex-item-005.html.ini b/tests/wpt/metadata-layout-2020/css/css-flexbox/grid-flex-item-005.html.ini new file mode 100644 index 00000000000..3fe332060a7 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/css-flexbox/grid-flex-item-005.html.ini @@ -0,0 +1,2 @@ +[grid-flex-item-005.html] + expected: FAIL diff --git a/tests/wpt/metadata-layout-2020/css/css-transforms/transform-scale-hittest.html.ini b/tests/wpt/metadata-layout-2020/css/css-transforms/transform-scale-hittest.html.ini index f8e7e539aae..4a1e8110f6f 100644 --- a/tests/wpt/metadata-layout-2020/css/css-transforms/transform-scale-hittest.html.ini +++ b/tests/wpt/metadata-layout-2020/css/css-transforms/transform-scale-hittest.html.ini @@ -2,6 +2,3 @@ [Hit test intersecting scaled box] expected: FAIL - [Hit test within unscaled box] - expected: FAIL - diff --git a/tests/wpt/metadata-layout-2020/css/cssom-view/CaretPosition-001.html.ini b/tests/wpt/metadata-layout-2020/css/cssom-view/CaretPosition-001.html.ini deleted file mode 100644 index 4c79907309b..00000000000 --- a/tests/wpt/metadata-layout-2020/css/cssom-view/CaretPosition-001.html.ini +++ /dev/null @@ -1,4 +0,0 @@ -[CaretPosition-001.html] - [Element at (400, 100)] - expected: FAIL - diff --git a/tests/wpt/metadata-layout-2020/css/cssom-view/client-props-root.html.ini b/tests/wpt/metadata-layout-2020/css/cssom-view/client-props-root.html.ini new file mode 100644 index 00000000000..cbdf6bf109c --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/cssom-view/client-props-root.html.ini @@ -0,0 +1,4 @@ +[client-props-root.html] + [client* properties on the root element] + expected: FAIL + diff --git a/tests/wpt/metadata-layout-2020/css/cssom-view/matchMedia-display-none-iframe.html.ini b/tests/wpt/metadata-layout-2020/css/cssom-view/matchMedia-display-none-iframe.html.ini new file mode 100644 index 00000000000..e6e1f29e274 --- /dev/null +++ b/tests/wpt/metadata-layout-2020/css/cssom-view/matchMedia-display-none-iframe.html.ini @@ -0,0 +1,2 @@ +[matchMedia-display-none-iframe.html] + expected: ERROR diff --git a/tests/wpt/metadata-layout-2020/custom-elements/reactions/HTMLMediaElement.html.ini b/tests/wpt/metadata-layout-2020/custom-elements/reactions/HTMLMediaElement.html.ini deleted file mode 100644 index 2ca05f57bb0..00000000000 --- a/tests/wpt/metadata-layout-2020/custom-elements/reactions/HTMLMediaElement.html.ini +++ /dev/null @@ -1,2 +0,0 @@ -[HTMLMediaElement.html] - expected: TIMEOUT diff --git a/tests/wpt/metadata-layout-2020/fetch/content-type/response.window.js.ini b/tests/wpt/metadata-layout-2020/fetch/content-type/response.window.js.ini index a3f0e3742dd..665e9b4f334 100644 --- a/tests/wpt/metadata-layout-2020/fetch/content-type/response.window.js.ini +++ b/tests/wpt/metadata-layout-2020/fetch/content-type/response.window.js.ini @@ -312,24 +312,24 @@ [Response: combined response Content-Type: text/html;" \\" text/plain ";charset=GBK] expected: NOTRUN - [