LibWeb: Map hr width attribute to the width dimension property

This commit is contained in:
Tim Ledbetter 2024-10-01 17:19:10 +01:00 committed by Andreas Kling
parent 45a3360a62
commit 4c3101e021
Notes: github-actions[bot] 2024-10-02 09:28:38 +00:00
4 changed files with 41 additions and 0 deletions

View file

@ -6,7 +6,10 @@
#include <LibWeb/Bindings/HTMLHRElementPrototype.h>
#include <LibWeb/Bindings/Intrinsics.h>
#include <LibWeb/CSS/StyleProperties.h>
#include <LibWeb/CSS/StyleValues/LengthStyleValue.h>
#include <LibWeb/HTML/HTMLHRElement.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
namespace Web::HTML {
@ -25,4 +28,16 @@ void HTMLHRElement::initialize(JS::Realm& realm)
WEB_SET_PROTOTYPE_FOR_INTERFACE(HTMLHRElement);
}
void HTMLHRElement::apply_presentational_hints(CSS::StyleProperties& style) const
{
for_each_attribute([&](auto& name, auto& value) {
// https://html.spec.whatwg.org/multipage/rendering.html#the-hr-element-2:maps-to-the-dimension-property
if (name == HTML::AttributeNames::width) {
if (auto parsed_value = parse_dimension_value(value)) {
style.set_property(CSS::PropertyID::Width, *parsed_value);
}
}
});
}
}