From d3c51ea05e941f6312906215146315d17c24e6a1 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Fri, 21 Feb 2025 11:13:11 +0000 Subject: [PATCH] LibWeb: Apply `nowrap` attribute as presentational hint --- Libraries/LibWeb/HTML/HTMLTableCellElement.cpp | 4 ++++ .../table-cell-nowrap-with-fixed-width-ref.html | 2 ++ .../table-cell-nowrap-with-fixed-width.html | 15 +++++++++++++++ 3 files changed, 21 insertions(+) create mode 100644 Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/tables/table-cell-nowrap-with-fixed-width-ref.html create mode 100644 Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/tables/table-cell-nowrap-with-fixed-width.html diff --git a/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index 392b52d20bb..c35d06e8891 100644 --- a/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -47,6 +47,7 @@ bool HTMLTableCellElement::is_presentational_hint(FlyString const& name) const HTML::AttributeNames::background, HTML::AttributeNames::bgcolor, HTML::AttributeNames::height, + HTML::AttributeNames::nowrap, HTML::AttributeNames::valign, HTML::AttributeNames::width); } @@ -92,6 +93,9 @@ void HTMLTableCellElement::apply_presentational_hints(GC::Refset_property_from_presentational_hint(CSS::PropertyID::BackgroundImage, CSS::ImageStyleValue::create(*parsed_value)); return; + } else if (name == HTML::AttributeNames::nowrap) { + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::WhiteSpace, CSS::CSSKeywordValue::create(CSS::Keyword::Nowrap)); + return; } }); diff --git a/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/tables/table-cell-nowrap-with-fixed-width-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/tables/table-cell-nowrap-with-fixed-width-ref.html new file mode 100644 index 00000000000..5b2ea91fe5f --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/tables/table-cell-nowrap-with-fixed-width-ref.html @@ -0,0 +1,2 @@ + +
diff --git a/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/tables/table-cell-nowrap-with-fixed-width.html b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/tables/table-cell-nowrap-with-fixed-width.html new file mode 100644 index 00000000000..94de54b168b --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/tables/table-cell-nowrap-with-fixed-width.html @@ -0,0 +1,15 @@ + + + + +A td element with the nowrap attribute should unconditionally apply white-space:nowrap + + + +
+
+