LibWeb/HTML: Support align attributes on table sections and rows

thead, tbody, tfoot, tr, td, and th all have an `align` presentational
attribute with identical definitions. We previously only supported it
for td and th, and also allowed arbitrary text-align values instead of
the 4 dictated by the spec.
This commit is contained in:
Sam Atkins
2026-04-30 11:15:16 +01:00
committed by Jelle Raaijmakers
parent 0b4cea5b29
commit 73c4b77f68
Notes: github-actions[bot] 2026-04-30 13:21:30 +00:00
7 changed files with 373 additions and 12 deletions

View File

@@ -46,6 +46,7 @@ bool HTMLTableRowElement::is_presentational_hint(FlyString const& name) const
return true;
return first_is_one_of(name,
HTML::AttributeNames::align,
HTML::AttributeNames::bgcolor,
HTML::AttributeNames::background,
HTML::AttributeNames::height,
@@ -56,7 +57,10 @@ void HTMLTableRowElement::apply_presentational_hints(GC::Ref<CSS::CascadedProper
{
Base::apply_presentational_hints(cascaded_properties);
for_each_attribute([&](auto& name, auto& value) {
if (name == HTML::AttributeNames::bgcolor) {
if (name == HTML::AttributeNames::align) {
if (auto parsed_value = parse_table_child_element_align_value(value))
cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::TextAlign, parsed_value.release_nonnull());
} else if (name == HTML::AttributeNames::bgcolor) {
// https://html.spec.whatwg.org/multipage/rendering.html#tables-2:rules-for-parsing-a-legacy-colour-value
auto color = parse_legacy_color_value(value);
if (color.has_value())