diff options
author | Luke Wilde <lukew@serenityos.org> | 2022-10-10 17:22:30 +0100 |
---|---|---|
committer | Andreas Kling <kling@serenityos.org> | 2022-10-10 19:33:34 +0200 |
commit | 6a7c5608496bfd6efad1a70fb6b7e3b135657cc4 (patch) | |
tree | 3c959aff369de0c83fd4a6c33d5faa554638e28c /Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp | |
parent | 8589f1115e480b9af0c0e458d40a4538f48bec13 (diff) | |
download | serenity-6a7c5608496bfd6efad1a70fb6b7e3b135657cc4.zip |
LibWeb: Respect width and height attributes of <iframe>
We have to respect the width and height attributes of <iframe> elements
the same way as <img> elements.
Diffstat (limited to 'Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp')
-rw-r--r-- | Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp index 399e1f9676..006640eabc 100644 --- a/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp +++ b/Userland/Libraries/LibWeb/HTML/HTMLIFrameElement.cpp @@ -9,6 +9,7 @@ #include <LibWeb/HTML/BrowsingContext.h> #include <LibWeb/HTML/HTMLIFrameElement.h> #include <LibWeb/HTML/Origin.h> +#include <LibWeb/HTML/Parser/HTMLParser.h> #include <LibWeb/Layout/FrameBox.h> namespace Web::HTML { @@ -126,6 +127,20 @@ void HTMLIFrameElement::load_src(String const& value) m_nested_browsing_context->loader().load(url, FrameLoader::Type::IFrame); } +// https://html.spec.whatwg.org/multipage/rendering.html#attributes-for-embedded-content-and-images +void HTMLIFrameElement::apply_presentational_hints(CSS::StyleProperties& style) const +{ + for_each_attribute([&](auto& name, auto& value) { + if (name == HTML::AttributeNames::width) { + if (auto parsed_value = parse_dimension_value(value)) + style.set_property(CSS::PropertyID::Width, parsed_value.release_nonnull()); + } else if (name == HTML::AttributeNames::height) { + if (auto parsed_value = parse_dimension_value(value)) + style.set_property(CSS::PropertyID::Height, parsed_value.release_nonnull()); + } + }); +} + // https://html.spec.whatwg.org/multipage/iframe-embed-object.html#iframe-load-event-steps void run_iframe_load_event_steps(HTML::HTMLIFrameElement& element) { |