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

LibWeb: Store background layers in ComputedValues

Instead of storing these as individual `background-foo` properties, we
combine them together into layers, since that is how they will be
painted. It also makes it more convenient to pass them around.
This commit is contained in:
Sam Atkins 2021-11-12 12:11:01 +00:00 committed by Andreas Kling
parent 64d805a027
commit cdeac132dc
6 changed files with 86 additions and 1 deletions

View file

@ -39,6 +39,12 @@ public:
static float opacity() { return 1.0f; }
};
struct BackgroundLayerData {
RefPtr<CSS::ImageStyleValue> image;
CSS::Repeat repeat_x;
CSS::Repeat repeat_y;
};
struct BorderData {
public:
Color color { Color::Transparent };
@ -119,6 +125,7 @@ public:
Color color() const { return m_inherited.color; }
Color background_color() const { return m_noninherited.background_color; }
Vector<BackgroundLayerData> const& background_layers() const { return m_noninherited.background_layers; }
BackgroundRepeatData background_repeat() const { return m_noninherited.background_repeat; }
CSS::ListStyleType list_style_type() const { return m_inherited.list_style_type; }
@ -176,6 +183,7 @@ protected:
Length border_top_left_radius;
Length border_top_right_radius;
Color background_color { InitialValues::background_color() };
Vector<BackgroundLayerData> background_layers;
BackgroundRepeatData background_repeat { InitialValues::background_repeat(), InitialValues::background_repeat() };
CSS::FlexDirection flex_direction { InitialValues::flex_direction() };
CSS::FlexWrap flex_wrap { InitialValues::flex_wrap() };
@ -203,6 +211,7 @@ public:
void set_pointer_events(CSS::PointerEvents value) { m_inherited.pointer_events = value; }
void set_background_color(const Color& color) { m_noninherited.background_color = color; }
void set_background_repeat(BackgroundRepeatData repeat) { m_noninherited.background_repeat = repeat; }
void set_background_layers(Vector<BackgroundLayerData>&& layers) { m_noninherited.background_layers = move(layers); }
void set_float(CSS::Float value) { m_noninherited.float_ = value; }
void set_clear(CSS::Clear value) { m_noninherited.clear = value; }
void set_z_index(Optional<int> value) { m_noninherited.z_index = value; }