ladybird/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.h
Andreas Kling fac08ff8c6 LibWeb: Track compound inherited style dependencies
Use StyleValue's computational-independence predicate when deciding
which specified values to retain for inherited-style recomputation.
Compound values such as shadows, filters, lists, and calc trees now
reuse their existing dependency tracking instead of the old bare-length
check.

Treat missing tuple entries and keyword-only edge offsets as
computationally independent. These nullable slots are part of the
parsed value representation, and the inherited dependency tracking now
uses the shared computational-independence query for specified values.

Add viewport resize coverage for media query changes that update root
font metrics while a descendant uses font-relative lengths inside
box-shadow and filter values.
2026-05-25 19:18:10 +02:00

49 lines
1.8 KiB
C++

/*
* Copyright (c) 2023, MacDue <macdue@dueutil.tech>
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#pragma once
#include <LibWeb/CSS/StyleValues/PercentageStyleValue.h>
#include <LibWeb/CSS/StyleValues/StyleValue.h>
namespace Web::CSS {
class EdgeStyleValue final : public StyleValueWithDefaultOperators<EdgeStyleValue> {
public:
static ValueComparingNonnullRefPtr<EdgeStyleValue const> create(Optional<PositionEdge> edge, RefPtr<StyleValue const> const& offset)
{
return adopt_ref(*new (nothrow) EdgeStyleValue(edge, offset));
}
virtual ~EdgeStyleValue() override = default;
// This is nonnull as it is only called after resolving keywords
NonnullRefPtr<StyleValue const> offset() const { return *m_properties.offset; }
bool is_center(SerializationMode) const;
virtual void serialize(StringBuilder&, SerializationMode) const override;
ValueComparingNonnullRefPtr<EdgeStyleValue const> with_resolved_keywords() const;
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const& computation_context) const override;
bool properties_equal(EdgeStyleValue const& other) const { return m_properties == other.m_properties; }
virtual bool is_computationally_independent() const override { return !m_properties.offset || m_properties.offset->is_computationally_independent(); }
private:
EdgeStyleValue(Optional<PositionEdge> edge, RefPtr<StyleValue const> const& offset)
: StyleValueWithDefaultOperators(Type::Edge)
, m_properties { .edge = edge, .offset = offset }
{
}
struct Properties {
Optional<PositionEdge> edge;
ValueComparingRefPtr<StyleValue const> offset;
bool operator==(Properties const&) const = default;
} m_properties;
};
}