diff options
author | Andreas Kling <kling@serenityos.org> | 2021-10-28 01:50:19 +0200 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2021-10-28 12:53:31 +0200 |
commit | 5c132724ea93117a367f280a558980df828b4440 (patch) | |
tree | d19096435b1d00d8c348cbd6b38d0b4ca06d1303 /Userland/Libraries/LibWeb | |
parent | c1511ebbead1e09da09ead41e86e1bc41240529b (diff) | |
download | serenity-5c132724ea93117a367f280a558980df828b4440.zip |
LibWeb: Properly handle the <td align> attribute
When valid, this attribute needs to result in an IdentifierStyleValue.
Before this change we were turning it into a StringStyleValue, which
then defaulted to left alignment for all values.
For "center" and "middle", we turn it into -libweb-center. All other
values are passed verbatim to the CSS parser.
Diffstat (limited to 'Userland/Libraries/LibWeb')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp index 81c7446c78..68186fcc8b 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCellElement.cpp @@ -28,10 +28,13 @@ void HTMLTableCellElement::apply_presentational_hints(CSS::StyleProperties& styl return; } if (name == HTML::AttributeNames::align) { - if (value.equals_ignoring_case("center") || value.equals_ignoring_case("middle")) - style.set_property(CSS::PropertyID::TextAlign, StringView("-libweb-center")); - else - style.set_property(CSS::PropertyID::TextAlign, value.view()); + if (value.equals_ignoring_case("center"sv) || value.equals_ignoring_case("middle"sv)) { + style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::LibwebCenter)); + } else { + CSS::Parser parser(CSS::ParsingContext(document()), value.view()); + if (auto parsed_value = parser.parse_as_css_value(CSS::PropertyID::TextAlign)) + style.set_property(CSS::PropertyID::TextAlign, parsed_value.release_nonnull()); + } return; } if (name == HTML::AttributeNames::width) { |