diff --git a/Libraries/LibWeb/HTML/HTMLHRElement.cpp b/Libraries/LibWeb/HTML/HTMLHRElement.cpp index ef433a613fc..44a61bbf85c 100644 --- a/Libraries/LibWeb/HTML/HTMLHRElement.cpp +++ b/Libraries/LibWeb/HTML/HTMLHRElement.cpp @@ -36,7 +36,7 @@ bool HTMLHRElement::is_presentational_hint(FlyString const& name) const if (Base::is_presentational_hint(name)) return true; - return first_is_one_of(name, HTML::AttributeNames::color, HTML::AttributeNames::noshade, HTML::AttributeNames::width); + return first_is_one_of(name, HTML::AttributeNames::align, HTML::AttributeNames::color, HTML::AttributeNames::noshade, HTML::AttributeNames::width); } void HTMLHRElement::apply_presentational_hints(GC::Ref cascaded_properties) const @@ -50,6 +50,19 @@ void HTMLHRElement::apply_presentational_hints(GC::Ref cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::BorderLeftStyle, CSS::CSSKeywordValue::create(CSS::Keyword::Solid)); } + if (name == HTML::AttributeNames::align) { + if (value.equals_ignoring_ascii_case("left"sv)) { + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::MarginLeft, CSS::LengthStyleValue::create(CSS::Length::make_px(0))); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::MarginRight, CSS::CSSKeywordValue::create(CSS::Keyword::Auto)); + } else if (value.equals_ignoring_ascii_case("right"sv)) { + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::MarginLeft, CSS::CSSKeywordValue::create(CSS::Keyword::Auto)); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::MarginRight, CSS::LengthStyleValue::create(CSS::Length::make_px(0))); + } else if (value.equals_ignoring_ascii_case("center"sv)) { + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::MarginLeft, CSS::CSSKeywordValue::create(CSS::Keyword::Auto)); + cascaded_properties->set_property_from_presentational_hint(CSS::PropertyID::MarginRight, CSS::CSSKeywordValue::create(CSS::Keyword::Auto)); + } + } + // https://html.spec.whatwg.org/multipage/rendering.html#the-hr-element-2:attr-hr-color-3 // When an hr element has a color attribute, its value is expected to be parsed using the rules for parsing a legacy color value, and if that does not return failure, // the user agent is expected to treat the attribute as a presentational hint setting the element's 'color' property to the resulting color. diff --git a/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-hr-element-0/align-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-hr-element-0/align-ref.html new file mode 100644 index 00000000000..9e4283e208e --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/html/rendering/non-replaced-elements/the-hr-element-0/align-ref.html @@ -0,0 +1,31 @@ + + + + +
+
+
+
+
+ +
+
+
+
+
diff --git a/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-hr-element-0/align.html b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-hr-element-0/align.html new file mode 100644 index 00000000000..6ea8bae5179 --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/html/rendering/non-replaced-elements/the-hr-element-0/align.html @@ -0,0 +1,24 @@ + + + + + +
+
+
+
+
+ +