summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMacDue <macdue@dueutil.tech>2022-09-15 08:31:19 +0100
committerSam Atkins <atkinssj@gmail.com>2022-09-16 10:50:48 +0100
commitec4de1e07d28cb6c41fda8c6e27dae98cf04e1b6 (patch)
treed97dd77e95fc41fe952bae31a42bd8e3b7a6a232
parentd1b99282d8851b086b2a5131347a2ec003625c46 (diff)
downloadserenity-ec4de1e07d28cb6c41fda8c6e27dae98cf04e1b6.zip
LibWeb: Plumb style/computed values for `backdrop-filter`
-rw-r--r--Userland/Libraries/LibWeb/CSS/BackdropFilter.h38
-rw-r--r--Userland/Libraries/LibWeb/CSS/ComputedValues.h5
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleProperties.cpp8
-rw-r--r--Userland/Libraries/LibWeb/CSS/StyleProperties.h1
-rw-r--r--Userland/Libraries/LibWeb/Layout/Node.cpp1
5 files changed, 53 insertions, 0 deletions
diff --git a/Userland/Libraries/LibWeb/CSS/BackdropFilter.h b/Userland/Libraries/LibWeb/CSS/BackdropFilter.h
new file mode 100644
index 0000000000..7c32f16c8e
--- /dev/null
+++ b/Userland/Libraries/LibWeb/CSS/BackdropFilter.h
@@ -0,0 +1,38 @@
+/*
+ * Copyright (c) 2022, MacDue <macdue@dueutil.tech>
+ *
+ * SPDX-License-Identifier: BSD-2-Clause
+ */
+
+#pragma once
+
+#include <AK/Variant.h>
+#include <LibWeb/CSS/StyleValue.h>
+
+namespace Web::CSS {
+
+class BackdropFilter {
+public:
+ BackdropFilter() = default;
+ BackdropFilter(FilterValueListStyleValue const& filter_value_list)
+ : m_filter_value_list { filter_value_list } {};
+
+ static inline BackdropFilter make_none()
+ {
+ return BackdropFilter {};
+ }
+
+ bool has_filters() const { return m_filter_value_list; }
+ bool is_none() const { return !has_filters(); }
+
+ Span<FilterFunction const> filters() const
+ {
+ VERIFY(has_filters());
+ return m_filter_value_list->filter_value_list().span();
+ }
+
+private:
+ RefPtr<FilterValueListStyleValue const> m_filter_value_list { nullptr };
+};
+
+}
diff --git a/Userland/Libraries/LibWeb/CSS/ComputedValues.h b/Userland/Libraries/LibWeb/CSS/ComputedValues.h
index ecb9c23134..b212e109d3 100644
--- a/Userland/Libraries/LibWeb/CSS/ComputedValues.h
+++ b/Userland/Libraries/LibWeb/CSS/ComputedValues.h
@@ -7,6 +7,7 @@
#pragma once
#include <AK/Optional.h>
+#include <LibWeb/CSS/BackdropFilter.h>
#include <LibWeb/CSS/Clip.h>
#include <LibWeb/CSS/LengthBox.h>
#include <LibWeb/CSS/StyleValue.h>
@@ -32,6 +33,7 @@ public:
static CSS::TextTransform text_transform() { return CSS::TextTransform::None; }
static CSS::Display display() { return CSS::Display { CSS::Display::Outside::Inline, CSS::Display::Inside::Flow }; }
static Color color() { return Color::Black; }
+ static CSS::BackdropFilter backdrop_filter() { return BackdropFilter::make_none(); }
static Color background_color() { return Color::Transparent; }
static CSS::ListStyleType list_style_type() { return CSS::ListStyleType::Disc; }
static CSS::Visibility visibility() { return CSS::Visibility::Visible; }
@@ -167,6 +169,7 @@ public:
CSS::Visibility visibility() const { return m_inherited.visibility; }
CSS::ImageRendering image_rendering() const { return m_inherited.image_rendering; }
CSS::JustifyContent justify_content() const { return m_noninherited.justify_content; }
+ CSS::BackdropFilter const& backdrop_filter() const { return m_noninherited.backdrop_filter; }
Vector<ShadowData> const& box_shadow() const { return m_noninherited.box_shadow; }
CSS::BoxSizing box_sizing() const { return m_noninherited.box_sizing; }
CSS::LengthPercentage const& width() const { return m_noninherited.width; }
@@ -267,6 +270,7 @@ protected:
CSS::LengthBox inset { InitialValues::inset() };
CSS::LengthBox margin { InitialValues::margin() };
CSS::LengthBox padding { InitialValues::padding() };
+ CSS::BackdropFilter backdrop_filter { InitialValues::backdrop_filter() };
BorderData border_left;
BorderData border_top;
BorderData border_right;
@@ -347,6 +351,7 @@ public:
void set_overflow_y(CSS::Overflow value) { m_noninherited.overflow_y = value; }
void set_list_style_type(CSS::ListStyleType value) { m_inherited.list_style_type = value; }
void set_display(CSS::Display value) { m_noninherited.display = value; }
+ void set_backdrop_filter(CSS::BackdropFilter backdrop_filter) { m_noninherited.backdrop_filter = move(backdrop_filter); }
void set_border_bottom_left_radius(CSS::BorderRadiusData value) { m_noninherited.border_bottom_left_radius = value; }
void set_border_bottom_right_radius(CSS::BorderRadiusData value) { m_noninherited.border_bottom_right_radius = value; }
void set_border_top_left_radius(CSS::BorderRadiusData value) { m_noninherited.border_top_left_radius = value; }
diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
index 3b8046c4aa..fc64695d40 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
+++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.cpp
@@ -355,6 +355,14 @@ Optional<CSS::Appearance> StyleProperties::appearance() const
return appearance;
}
+CSS::BackdropFilter StyleProperties::backdrop_filter() const
+{
+ auto value = property(CSS::PropertyID::BackdropFilter);
+ if (value->is_filter_value_list())
+ return BackdropFilter(value->as_filter_value_list());
+ return BackdropFilter::make_none();
+}
+
Optional<CSS::Position> StyleProperties::position() const
{
auto value = property(CSS::PropertyID::Position);
diff --git a/Userland/Libraries/LibWeb/CSS/StyleProperties.h b/Userland/Libraries/LibWeb/CSS/StyleProperties.h
index 72c0db8e37..d03478477e 100644
--- a/Userland/Libraries/LibWeb/CSS/StyleProperties.h
+++ b/Userland/Libraries/LibWeb/CSS/StyleProperties.h
@@ -70,6 +70,7 @@ public:
Optional<CSS::AlignItems> align_items() const;
Optional<CSS::AlignSelf> align_self() const;
Optional<CSS::Appearance> appearance() const;
+ CSS::BackdropFilter backdrop_filter() const;
float opacity() const;
Optional<CSS::Visibility> visibility() const;
Optional<CSS::ImageRendering> image_rendering() const;
diff --git a/Userland/Libraries/LibWeb/Layout/Node.cpp b/Userland/Libraries/LibWeb/Layout/Node.cpp
index 565348eb4d..69058d61ce 100644
--- a/Userland/Libraries/LibWeb/Layout/Node.cpp
+++ b/Userland/Libraries/LibWeb/Layout/Node.cpp
@@ -393,6 +393,7 @@ void NodeWithStyle::apply_style(const CSS::StyleProperties& computed_style)
computed_values.set_flex_shrink(computed_style.flex_shrink());
computed_values.set_order(computed_style.order());
computed_values.set_clip(computed_style.clip());
+ computed_values.set_backdrop_filter(computed_style.backdrop_filter());
auto justify_content = computed_style.justify_content();
if (justify_content.has_value())