mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-01 05:39:11 +00:00
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:
parent
9d06c86fe4
commit
94f5a51820
Notes:
github-actions[bot]
2025-05-29 10:05:43 +00:00
Author: https://github.com/Calme1709
Commit: 94f5a51820
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/4832
Reviewed-by: https://github.com/AtkinsSJ
Reviewed-by: https://github.com/gmta ✅
28 changed files with 568 additions and 308 deletions
|
@ -1355,8 +1355,8 @@ bool command_insert_linebreak_action(DOM::Document& document, String const&)
|
|||
if (is<DOM::Text>(*start_node) && active_range.start_offset() == start_node->length())
|
||||
MUST(selection.collapse(start_node->parent(), start_node->index() + 1));
|
||||
|
||||
// AD-HOC: If the active range's start node is a Text node and its resolved value for "white-space" is one of "pre",
|
||||
// "pre-line" or "pre-wrap":
|
||||
// AD-HOC: If the active range's start node is a Text node and its resolved value for "white-space-collapse" is one of
|
||||
// "preserve" or "preserve-breaks":
|
||||
// * Insert a newline (\n) character at the active range's start offset;
|
||||
// * Collapse the selection with active range's start node as the first argument and one plus active range's
|
||||
// start offset as the second argument
|
||||
|
@ -1364,9 +1364,8 @@ bool command_insert_linebreak_action(DOM::Document& document, String const&)
|
|||
// active range's start node.
|
||||
// * Return true.
|
||||
if (auto* text_node = as_if<DOM::Text>(*start_node); text_node) {
|
||||
auto resolved_white_space = resolved_keyword(*start_node, CSS::PropertyID::WhiteSpace);
|
||||
if (resolved_white_space.has_value()
|
||||
&& first_is_one_of(resolved_white_space.value(), CSS::Keyword::Pre, CSS::Keyword::PreLine, CSS::Keyword::PreWrap)) {
|
||||
auto resolved_white_space_collapse = resolved_keyword(*start_node, CSS::PropertyID::WhiteSpaceCollapse);
|
||||
if (resolved_white_space_collapse.has_value() && first_is_one_of(resolved_white_space_collapse.value(), CSS::Keyword::Preserve, CSS::Keyword::PreserveBreaks)) {
|
||||
MUST(text_node->insert_data(active_range.start_offset(), "\n"_string));
|
||||
MUST(selection.collapse(start_node, active_range.start_offset() + 1));
|
||||
if (selection.range()->start_offset() == start_node->length())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue