mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 18:07:34 +00:00
LibWeb: Resolve backdrop filter length in apply_style()
Instead of resolving lengths used in the backdrop-filter during painting, we can do that earlier in apply_style(). This change moves us a bit closer to the point when the stacking context tree will be completely separated from the layout tree :)
This commit is contained in:
parent
6528f6db26
commit
7803dcfcf9
7 changed files with 74 additions and 37 deletions
|
@ -537,7 +537,35 @@ 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());
|
||||
|
||||
if (computed_style.backdrop_filter().has_filters()) {
|
||||
CSS::ResolvedBackdropFilter resolved_backdrop_filter;
|
||||
for (auto& filter : computed_style.backdrop_filter().filters()) {
|
||||
filter.visit(
|
||||
[&](CSS::Filter::Blur const& blur) {
|
||||
resolved_backdrop_filter.filters.append(CSS::ResolvedBackdropFilter::Blur {
|
||||
.radius = blur.resolved_radius(*this) });
|
||||
},
|
||||
[&](CSS::Filter::DropShadow const& drop_shadow) {
|
||||
// The default value for omitted values is missing length values set to 0
|
||||
// and the missing used color is taken from the color property.
|
||||
resolved_backdrop_filter.filters.append(CSS::ResolvedBackdropFilter::DropShadow {
|
||||
.offset_x = drop_shadow.offset_x.to_px(*this).to_double(),
|
||||
.offset_y = drop_shadow.offset_y.to_px(*this).to_double(),
|
||||
.radius = drop_shadow.radius.has_value() ? drop_shadow.radius->to_px(*this).to_double() : 0.0,
|
||||
.color = drop_shadow.color.has_value() ? *drop_shadow.color : this->computed_values().color() });
|
||||
},
|
||||
[&](CSS::Filter::Color const& color_operation) {
|
||||
resolved_backdrop_filter.filters.append(CSS::ResolvedBackdropFilter::ColorOperation {
|
||||
.operation = color_operation.operation,
|
||||
.amount = color_operation.resolved_amount() });
|
||||
},
|
||||
[&](CSS::Filter::HueRotate const& hue_rotate) {
|
||||
resolved_backdrop_filter.filters.append(CSS::ResolvedBackdropFilter::HueRotate { .angle_degrees = hue_rotate.angle_degrees() });
|
||||
});
|
||||
}
|
||||
computed_values.set_backdrop_filter(resolved_backdrop_filter);
|
||||
}
|
||||
|
||||
auto justify_content = computed_style.justify_content();
|
||||
if (justify_content.has_value())
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue