LibWeb: Use dimension image source for images

Fixes tiny images on Wikipedia
This commit is contained in:
Chase Knowlden
2026-02-11 20:41:13 -05:00
committed by Sam Atkins
parent 31cbe2061a
commit b8f31179b2
Notes: github-actions[bot] 2026-02-13 10:44:04 +00:00
5 changed files with 83 additions and 14 deletions

View File

@@ -78,6 +78,7 @@
#include <LibWeb/DOM/ShadowRoot.h>
#include <LibWeb/HTML/HTMLBRElement.h>
#include <LibWeb/HTML/HTMLHtmlElement.h>
#include <LibWeb/HTML/HTMLImageElement.h>
#include <LibWeb/HTML/HTMLSlotElement.h>
#include <LibWeb/HTML/Parser/HTMLParser.h>
#include <LibWeb/Layout/Node.h>
@@ -1274,8 +1275,11 @@ GC::Ref<CascadedProperties> StyleComputer::compute_cascaded_values(DOM::Abstract
auto& element = abstract_element.element();
element.apply_presentational_hints(cascaded_properties);
if (element.supports_dimension_attributes()) {
apply_dimension_attribute(cascaded_properties, element, HTML::AttributeNames::width, CSS::PropertyID::Width);
apply_dimension_attribute(cascaded_properties, element, HTML::AttributeNames::height, CSS::PropertyID::Height);
auto const& dimension_source = is<HTML::HTMLImageElement>(element)
? static_cast<HTML::HTMLImageElement const&>(element).dimension_attribute_source()
: element;
apply_dimension_attribute(cascaded_properties, dimension_source, HTML::AttributeNames::width, CSS::PropertyID::Width);
apply_dimension_attribute(cascaded_properties, dimension_source, HTML::AttributeNames::height, CSS::PropertyID::Height);
}
// SVG presentation attributes are parsed as CSS values, so we need to handle potential custom properties here.