1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:57:35 +00:00

LibWeb: Allow calc() values in image sizes attribute

Note that we currently can't resolve calc() values without a layout
node, so when normalizing an image's source set, we'll flush any pending
layout updates and hope that gives us an up-to-date layout node.

I've left a FIXME about implementing this in a more elegant and less
layout-thrashy way, as that will require more architectural work.
This commit is contained in:
Andreas Kling 2023-07-28 15:52:06 +02:00
parent 9997f46593
commit 95097e47a7
7 changed files with 77 additions and 28 deletions

View file

@ -8,7 +8,7 @@
#include <AK/URL.h>
#include <AK/Variant.h>
#include <LibWeb/CSS/Length.h>
#include <LibWeb/CSS/CalculatedOr.h>
namespace Web::HTML {
@ -33,7 +33,7 @@ struct ImageSourceAndPixelDensity {
// https://html.spec.whatwg.org/multipage/images.html#source-set
struct SourceSet {
static SourceSet create(DOM::Document const&, String default_source, String srcset, String sizes);
static SourceSet create(DOM::Element const&, String default_source, String srcset, String sizes);
[[nodiscard]] bool is_empty() const;
@ -41,15 +41,15 @@ struct SourceSet {
[[nodiscard]] ImageSourceAndPixelDensity select_an_image_source();
// https://html.spec.whatwg.org/multipage/images.html#normalise-the-source-densities
void normalize_source_densities();
void normalize_source_densities(DOM::Element const&);
SourceSet();
Vector<ImageSource> m_sources;
CSS::Length m_source_size;
CSS::LengthOrCalculated m_source_size;
};
SourceSet parse_a_srcset_attribute(StringView);
CSS::Length parse_a_sizes_attribute(DOM::Document const&, StringView);
[[nodiscard]] CSS::LengthOrCalculated parse_a_sizes_attribute(DOM::Document const&, StringView);
}