diff --git a/Libraries/LibWeb/DOM/HTMLImageElement.cpp b/Libraries/LibWeb/DOM/HTMLImageElement.cpp
index 124b00b734..7c1d7e7e57 100644
--- a/Libraries/LibWeb/DOM/HTMLImageElement.cpp
+++ b/Libraries/LibWeb/DOM/HTMLImageElement.cpp
@@ -33,6 +33,7 @@
#include
#include
#include
+#include
namespace Web {
@@ -60,6 +61,21 @@ HTMLImageElement::~HTMLImageElement()
{
}
+void HTMLImageElement::apply_presentational_hints(StyleProperties& style) const
+{
+ for_each_attribute([&](auto& name, auto& value) {
+ if (name == HTML::AttributeNames::width) {
+ if (auto parsed_value = parse_html_length(document(), value)) {
+ style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull());
+ }
+ } else if (name == HTML::AttributeNames::height) {
+ if (auto parsed_value = parse_html_length(document(), value)) {
+ style.set_property(CSS::PropertyID::Height, parsed_value.release_nonnull());
+ }
+ }
+ });
+}
+
void HTMLImageElement::parse_attribute(const FlyString& name, const String& value)
{
HTMLElement::parse_attribute(name, value);
diff --git a/Libraries/LibWeb/DOM/HTMLImageElement.h b/Libraries/LibWeb/DOM/HTMLImageElement.h
index b4a3c4b4d2..fff36b0359 100644
--- a/Libraries/LibWeb/DOM/HTMLImageElement.h
+++ b/Libraries/LibWeb/DOM/HTMLImageElement.h
@@ -51,6 +51,8 @@ public:
const Gfx::Bitmap* bitmap() const;
private:
+ virtual void apply_presentational_hints(StyleProperties&) const override;
+
void animate();
virtual RefPtr create_layout_node(const StyleProperties* parent_style) override;