diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp index 24cbb8d110..b1bc336ee9 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.cpp @@ -16,4 +16,23 @@ HTMLHeadingElement::HTMLHeadingElement(DOM::Document& document, DOM::QualifiedNa } HTMLHeadingElement::~HTMLHeadingElement() = default; + +// https://html.spec.whatwg.org/multipage/rendering.html#tables-2 +void HTMLHeadingElement::apply_presentational_hints(CSS::StyleProperties& style) const +{ + HTMLElement::apply_presentational_hints(style); + for_each_attribute([&](auto& name, auto& value) { + if (name.equals_ignoring_case("align"sv)) { + if (value == "left"sv) + style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left)); + else if (value == "right"sv) + style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right)); + else if (value == "center"sv) + style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center)); + else if (value == "justify"sv) + style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify)); + } + }); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h index 41fe152596..9dcd4aa61e 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLHeadingElement.h @@ -16,6 +16,8 @@ class HTMLHeadingElement final : public HTMLElement { public: virtual ~HTMLHeadingElement() override; + virtual void apply_presentational_hints(CSS::StyleProperties&) const override; + private: HTMLHeadingElement(DOM::Document&, DOM::QualifiedName); }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp index cfffd942a3..f6057fea88 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.cpp @@ -17,4 +17,22 @@ HTMLParagraphElement::HTMLParagraphElement(DOM::Document& document, DOM::Qualifi HTMLParagraphElement::~HTMLParagraphElement() = default; +// https://html.spec.whatwg.org/multipage/rendering.html#tables-2 +void HTMLParagraphElement::apply_presentational_hints(CSS::StyleProperties& style) const +{ + HTMLElement::apply_presentational_hints(style); + for_each_attribute([&](auto& name, auto& value) { + if (name.equals_ignoring_case("align"sv)) { + if (value == "left"sv) + style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Left)); + else if (value == "right"sv) + style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Right)); + else if (value == "center"sv) + style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Center)); + else if (value == "justify"sv) + style.set_property(CSS::PropertyID::TextAlign, CSS::IdentifierStyleValue::create(CSS::ValueID::Justify)); + } + }); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h index 03dd5a358e..b18f7d19fe 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLParagraphElement.h @@ -16,6 +16,8 @@ class HTMLParagraphElement final : public HTMLElement { public: virtual ~HTMLParagraphElement() override; + virtual void apply_presentational_hints(CSS::StyleProperties&) const override; + private: HTMLParagraphElement(DOM::Document&, DOM::QualifiedName); }; diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp index 96b5bba433..82074e21ec 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.cpp @@ -17,4 +17,16 @@ HTMLTableCaptionElement::HTMLTableCaptionElement(DOM::Document& document, DOM::Q HTMLTableCaptionElement::~HTMLTableCaptionElement() = default; +// https://html.spec.whatwg.org/multipage/rendering.html#tables-2 +void HTMLTableCaptionElement::apply_presentational_hints(CSS::StyleProperties& style) const +{ + HTMLElement::apply_presentational_hints(style); + for_each_attribute([&](auto& name, auto& value) { + if (name.equals_ignoring_case("align"sv)) { + if (value == "bottom"sv) + style.set_property(CSS::PropertyID::CaptionSide, CSS::IdentifierStyleValue::create(CSS::ValueID::Bottom)); + } + }); +} + } diff --git a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h index 6b05e4e66a..ec68ce04b7 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h +++ b/Userland/Libraries/LibWeb/HTML/HTMLTableCaptionElement.h @@ -16,6 +16,8 @@ class HTMLTableCaptionElement final : public HTMLElement { public: virtual ~HTMLTableCaptionElement() override; + virtual void apply_presentational_hints(CSS::StyleProperties&) const override; + private: HTMLTableCaptionElement(DOM::Document&, DOM::QualifiedName); };