From 50cce72ab99f4ceea0e80f8091190928f05a346d Mon Sep 17 00:00:00 2001 From: Callum Law Date: Sat, 31 May 2025 20:40:39 +1200 Subject: [PATCH] LibWeb: Implement `text-wrap` CSS property This resolves an issue introduced in 94f5a51 with the tab-size-text-wrap test --- Libraries/LibWeb/CSS/Properties.json | 8 ++++ .../LibWeb/GenerateCSSPseudoElement.cpp | 2 +- .../Layout/expected/tab-size-text-wrap.txt | 32 +++++++------- ...upported-properties-and-default-values.txt | 2 + .../css-text/parsing/text-wrap-computed.txt | 22 ++++++++++ .../css-text/parsing/text-wrap-invalid.txt | 13 ++++++ .../css/css-text/parsing/text-wrap-pretty.txt | 19 ++++++++ .../css/css-text/parsing/text-wrap-valid.txt | 27 ++++++++++++ .../css-text/parsing/text-wrap-computed.html | 38 ++++++++++++++++ .../css-text/parsing/text-wrap-invalid.html | 25 +++++++++++ .../css-text/parsing/text-wrap-pretty.html | 34 +++++++++++++++ .../css/css-text/parsing/text-wrap-valid.html | 43 +++++++++++++++++++ 12 files changed, 248 insertions(+), 17 deletions(-) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-computed.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-invalid.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-pretty.txt create mode 100644 Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-valid.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-computed.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-invalid.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-pretty.html create mode 100644 Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-valid.html diff --git a/Libraries/LibWeb/CSS/Properties.json b/Libraries/LibWeb/CSS/Properties.json index cdece9846a4..3f5c6229d30 100644 --- a/Libraries/LibWeb/CSS/Properties.json +++ b/Libraries/LibWeb/CSS/Properties.json @@ -2943,6 +2943,14 @@ "text-transform" ] }, + "text-wrap": { + "inherited": true, + "initial": "wrap", + "longhands": [ + "text-wrap-mode", + "text-wrap-style" + ] + }, "text-wrap-mode": { "animation-type": "discrete", "inherited": true, diff --git a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPseudoElement.cpp b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPseudoElement.cpp index 84999d7543e..ac56a4b06dd 100644 --- a/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPseudoElement.cpp +++ b/Meta/Lagom/Tools/CodeGenerators/LibWeb/GenerateCSSPseudoElement.cpp @@ -432,7 +432,7 @@ bool pseudo_element_supports_property(PseudoElement pseudo_element, PropertyID p // FIXME: text-spacing // FIXME: text-spacing-trim append_property("text-transform"sv); - // FIXME: text-wrap + append_property("text-wrap"sv); append_property("text-wrap-mode"sv); append_property("text-wrap-style"sv); append_property("white-space"sv); diff --git a/Tests/LibWeb/Layout/expected/tab-size-text-wrap.txt b/Tests/LibWeb/Layout/expected/tab-size-text-wrap.txt index 4af804029e9..903fab5d5fa 100644 --- a/Tests/LibWeb/Layout/expected/tab-size-text-wrap.txt +++ b/Tests/LibWeb/Layout/expected/tab-size-text-wrap.txt @@ -1,33 +1,33 @@ Viewport <#document> at (0,0) content-size 800x600 children: not-inline - BlockContainer at (0,0) content-size 800x31 [BFC] children: not-inline - BlockContainer at (8,8) content-size 784x15 children: not-inline - BlockContainer
at (8,8) content-size 100x15 children: inline + BlockContainer at (0,0) content-size 800x61 [BFC] children: not-inline + BlockContainer at (8,8) content-size 784x45 children: not-inline + BlockContainer
at (8,8) content-size 100x45 children: inline frag 0 from BlockContainer start: 0, length: 0, rect: [8,8 111.59375x15] baseline: 11.390625 - frag 1 from BlockContainer start: 0, length: 0, rect: [119.59375,8 119.1875x15] baseline: 11.390625 - frag 2 from BlockContainer start: 0, length: 0, rect: [238.78125,8 127.5625x15] baseline: 11.390625 + frag 1 from BlockContainer start: 0, length: 0, rect: [8,23 119.1875x15] baseline: 11.390625 + frag 2 from BlockContainer start: 0, length: 0, rect: [8,38 127.5625x15] baseline: 11.390625 BlockContainer at (8,8) content-size 111.59375x15 inline-block [BFC] children: inline frag 0 from TextNode start: 0, length: 2, rect: [8,8 111.59375x15] baseline: 11.390625 " A" TextNode <#text> - BlockContainer at (119.59375,8) content-size 119.1875x15 inline-block [BFC] children: inline - frag 0 from TextNode start: 0, length: 3, rect: [119.59375,8 119.1875x15] baseline: 11.390625 + BlockContainer at (8,23) content-size 119.1875x15 inline-block [BFC] children: inline + frag 0 from TextNode start: 0, length: 3, rect: [8,23 119.1875x15] baseline: 11.390625 " AB" TextNode <#text> - BlockContainer at (238.78125,8) content-size 127.5625x15 inline-block [BFC] children: inline - frag 0 from TextNode start: 0, length: 4, rect: [238.78125,8 127.5625x15] baseline: 11.390625 + BlockContainer at (8,38) content-size 127.5625x15 inline-block [BFC] children: inline + frag 0 from TextNode start: 0, length: 4, rect: [8,38 127.5625x15] baseline: 11.390625 " ABC" TextNode <#text> - BlockContainer <(anonymous)> at (8,23) content-size 784x0 children: inline + BlockContainer <(anonymous)> at (8,53) content-size 784x0 children: inline TextNode <#text> ViewportPaintable (Viewport<#document>) [0,0 800x600] - PaintableWithLines (BlockContainer) [0,0 800x31] - PaintableWithLines (BlockContainer) [8,8 784x15] - PaintableWithLines (BlockContainer
) [8,8 100x15] overflow: [8,8 358.34375x15] + PaintableWithLines (BlockContainer) [0,0 800x61] + PaintableWithLines (BlockContainer) [8,8 784x45] + PaintableWithLines (BlockContainer
) [8,8 100x45] overflow: [8,8 127.5625x45] PaintableWithLines (BlockContainer) [8,8 111.59375x15] TextPaintable (TextNode<#text>) - PaintableWithLines (BlockContainer) [119.59375,8 119.1875x15] + PaintableWithLines (BlockContainer) [8,23 119.1875x15] TextPaintable (TextNode<#text>) - PaintableWithLines (BlockContainer) [238.78125,8 127.5625x15] + PaintableWithLines (BlockContainer) [8,38 127.5625x15] TextPaintable (TextNode<#text>) - PaintableWithLines (BlockContainer(anonymous)) [8,23 784x0] + PaintableWithLines (BlockContainer(anonymous)) [8,53 784x0] diff --git a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt index 4195682e826..6c18da36daf 100644 --- a/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt +++ b/Tests/LibWeb/Text/expected/css/CSSStyleProperties-all-supported-properties-and-default-values.txt @@ -617,6 +617,8 @@ All supported properties and their default values exposed from CSSStylePropertie 'text-shadow': 'none' 'textTransform': 'none' 'text-transform': 'none' +'textWrap': 'wrap' +'text-wrap': 'wrap' 'textWrapMode': 'wrap' 'text-wrap-mode': 'wrap' 'textWrapStyle': 'auto' diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-computed.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-computed.txt new file mode 100644 index 00000000000..1087b6d04d3 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-computed.txt @@ -0,0 +1,22 @@ +Harness status: OK + +Found 17 tests + +17 Pass +Pass Property text-wrap value 'wrap' +Pass Property text-wrap value 'nowrap' +Pass Property text-wrap value 'auto' +Pass Property text-wrap value 'balance' +Pass Property text-wrap value 'stable' +Pass Property text-wrap value 'wrap auto' +Pass Property text-wrap value 'wrap balance' +Pass Property text-wrap value 'wrap stable' +Pass Property text-wrap value 'auto wrap' +Pass Property text-wrap value 'balance wrap' +Pass Property text-wrap value 'stable wrap' +Pass Property text-wrap value 'nowrap auto' +Pass Property text-wrap value 'nowrap balance' +Pass Property text-wrap value 'nowrap stable' +Pass Property text-wrap value 'auto nowrap' +Pass Property text-wrap value 'balance nowrap' +Pass Property text-wrap value 'stable nowrap' \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-invalid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-invalid.txt new file mode 100644 index 00000000000..37e7367c580 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-invalid.txt @@ -0,0 +1,13 @@ +Harness status: OK + +Found 8 tests + +8 Pass +Pass e.style['text-wrap'] = "normal" should not set the property value +Pass e.style['text-wrap'] = "none" should not set the property value +Pass e.style['text-wrap'] = "wrap nowrap" should not set the property value +Pass e.style['text-wrap'] = "pretty balance" should not set the property value +Pass e.style['text-wrap'] = "balance stable" should not set the property value +Pass e.style['text-wrap'] = "stable pretty" should not set the property value +Pass e.style['text-wrap'] = "delicious wrap" should not set the property value +Pass e.style['text-wrap'] = "5px" should not set the property value \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-pretty.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-pretty.txt new file mode 100644 index 00000000000..9f26c45ee46 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-pretty.txt @@ -0,0 +1,19 @@ +Harness status: OK + +Found 14 tests + +14 Pass +Pass e.style['text-wrap'] = "pretty" should set the property value +Pass e.style['text-wrap'] = "wrap pretty" should set the property value +Pass e.style['text-wrap'] = "pretty wrap" should set the property value +Pass e.style['text-wrap'] = "stable wrap" should set the property value +Pass e.style['text-wrap'] = "nowrap pretty" should set the property value +Pass e.style['text-wrap'] = "pretty nowrap" should set the property value +Pass e.style['text-wrap-style'] = "pretty" should set the property value +Pass Property text-wrap value 'pretty' +Pass Property text-wrap value 'wrap pretty' +Pass Property text-wrap value 'pretty wrap' +Pass Property text-wrap value 'stable wrap' +Pass Property text-wrap value 'nowrap pretty' +Pass Property text-wrap value 'pretty nowrap' +Pass Property text-wrap-style value 'pretty' \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-valid.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-valid.txt new file mode 100644 index 00000000000..1ab10f7fb04 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-text/parsing/text-wrap-valid.txt @@ -0,0 +1,27 @@ +Harness status: OK + +Found 22 tests + +22 Pass +Pass e.style['text-wrap'] = "wrap" should set the property value +Pass e.style['text-wrap'] = "nowrap" should set the property value +Pass e.style['text-wrap'] = "auto" should set the property value +Pass e.style['text-wrap'] = "balance" should set the property value +Pass e.style['text-wrap'] = "stable" should set the property value +Pass e.style['text-wrap'] = "wrap auto" should set the property value +Pass e.style['text-wrap'] = "wrap balance" should set the property value +Pass e.style['text-wrap'] = "wrap stable" should set the property value +Pass e.style['text-wrap'] = "auto wrap" should set the property value +Pass e.style['text-wrap'] = "balance wrap" should set the property value +Pass e.style['text-wrap'] = "stable wrap" should set the property value +Pass e.style['text-wrap'] = "nowrap auto" should set the property value +Pass e.style['text-wrap'] = "nowrap balance" should set the property value +Pass e.style['text-wrap'] = "nowrap stable" should set the property value +Pass e.style['text-wrap'] = "auto nowrap" should set the property value +Pass e.style['text-wrap'] = "balance nowrap" should set the property value +Pass e.style['text-wrap'] = "stable nowrap" should set the property value +Pass e.style['text-wrap'] = "initial" should set the property value +Pass e.style['text-wrap'] = "inherit" should set the property value +Pass e.style['text-wrap'] = "unset" should set the property value +Pass e.style['text-wrap'] = "revert" should set the property value +Pass e.style['text-wrap'] = "revert-layer" should set the property value \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-computed.html b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-computed.html new file mode 100644 index 00000000000..6618e72bf38 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-computed.html @@ -0,0 +1,38 @@ + + + + +CSS Text: getComputedStyle().textWrap + + + + + + + + +
+ + + diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-invalid.html b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-invalid.html new file mode 100644 index 00000000000..10fec346aef --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-invalid.html @@ -0,0 +1,25 @@ + + + + +CSS Text Module Test: parsing text-wrap with invalid values + + + + + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-pretty.html b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-pretty.html new file mode 100644 index 00000000000..10697bcdd92 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-pretty.html @@ -0,0 +1,34 @@ + + + + +CSS Text Module Test: text-wrap: pretty parsing + + + + + + + + + +
+ + + diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-valid.html b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-valid.html new file mode 100644 index 00000000000..b2bae6f0d33 --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-text/parsing/text-wrap-valid.html @@ -0,0 +1,43 @@ + + + + +CSS Text Module Test: parsing text-wrap with valid values + + + + + + + + + + +