LibWeb: Convert white-space CSS property to shorthand

This exposed a few bugs which caused the following tests to behave
incorrectly:
- `tab-size-text-wrap.html`: This previously relied on a bug where we
  incorrectly treated `white-space: pre` as allowing text wrapping. The
  fix here is to implement the text-wrap CSS shorthand property.

- `execCommand-preserveWhitespace.html`: We don't correctly serialize
  shorthand properties. This is covered by an existing FIXME in
  `CSSStyleProperties::serialized()`

- `white-space-shorthand.html`: The last 5 subtests here fail as we
  don't correctly handle shorthand properties in
  `CSSStyleProperties::remove_property()`. This is covered by an
  existing FIXME in said function.
This commit is contained in:
Callum Law 2025-05-22 00:31:24 +12:00 committed by Jelle Raaijmakers
commit 94f5a51820
Notes: github-actions[bot] 2025-05-29 10:05:43 +00:00
28 changed files with 568 additions and 308 deletions

View file

@ -326,18 +326,7 @@ void TextNode::compute_text_for_rendering()
return;
}
bool collapse = [](CSS::WhiteSpace white_space) {
switch (white_space) {
case CSS::WhiteSpace::Normal:
case CSS::WhiteSpace::Nowrap:
case CSS::WhiteSpace::PreLine:
return true;
case CSS::WhiteSpace::Pre:
case CSS::WhiteSpace::PreWrap:
return false;
}
VERIFY_NOT_REACHED();
}(computed_values().white_space());
bool collapse = first_is_one_of(computed_values().white_space_collapse(), CSS::WhiteSpaceCollapse::Collapse, CSS::WhiteSpaceCollapse::PreserveBreaks);
auto parent_element = dom_node().parent_element();
auto const maybe_lang = parent_element ? parent_element->lang() : Optional<String> {};