mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-12-07 21:59:54 +00:00
LibWeb/CSS: Implement "subdivide into iterations" for basic StyleValues
This algorithm is used by Typed-OM for producing a list of internal style values from a single one, for properties that take a list. We will probably need to implement this for more StyleValues later.
This commit is contained in:
parent
d739c8c22a
commit
07d77e89dd
Notes:
github-actions[bot]
2025-11-03 18:22:54 +00:00
Author: https://github.com/AtkinsSJ
Commit: 07d77e89dd
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6677
Reviewed-by: https://github.com/gmta ✅
4 changed files with 27 additions and 0 deletions
|
|
@ -154,4 +154,15 @@ GC::Ref<CSSStyleValue> StyleValue::reify(JS::Realm& realm, FlyString const& asso
|
|||
return CSSStyleValue::create(realm, associated_property, *this);
|
||||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#subdivide-into-iterations
|
||||
StyleValueVector StyleValue::subdivide_into_iterations(PropertyNameAndID const&) const
|
||||
{
|
||||
// To subdivide into iterations a CSS value whole value for a property property, execute the following steps:
|
||||
// 1. If property is a single-valued property, return a list containing whole value.
|
||||
// 2. Otherwise, divide whole value into individual iterations, as appropriate for property, and return a list
|
||||
// containing the iterations in order.
|
||||
// NB: We do this by type. By default, we assume step 1 applies. For step 2, override this method.
|
||||
return StyleValueVector { *this };
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -211,6 +211,7 @@ public:
|
|||
virtual String to_string(SerializationMode) const = 0;
|
||||
virtual Vector<Parser::ComponentValue> tokenize() const;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, FlyString const& associated_property) const;
|
||||
virtual StyleValueVector subdivide_into_iterations(PropertyNameAndID const&) const;
|
||||
|
||||
virtual void set_style_sheet(GC::Ptr<CSSStyleSheet>) { }
|
||||
virtual void visit_edges(JS::Cell::Visitor&) const { }
|
||||
|
|
|
|||
|
|
@ -13,6 +13,7 @@
|
|||
#include <LibWeb/CSS/CSSTransformComponent.h>
|
||||
#include <LibWeb/CSS/CSSTransformValue.h>
|
||||
#include <LibWeb/CSS/Parser/ComponentValue.h>
|
||||
#include <LibWeb/CSS/PropertyNameAndID.h>
|
||||
#include <LibWeb/CSS/StyleValues/TransformationStyleValue.h>
|
||||
|
||||
namespace Web::CSS {
|
||||
|
|
@ -119,4 +120,17 @@ GC::Ref<CSSStyleValue> StyleValueList::reify(JS::Realm& realm, FlyString const&
|
|||
return Base::reify(realm, associated_property);
|
||||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#subdivide-into-iterations
|
||||
StyleValueVector StyleValueList::subdivide_into_iterations(PropertyNameAndID const& property) const
|
||||
{
|
||||
// To subdivide into iterations a CSS value whole value for a property property, execute the following steps:
|
||||
// 1. If property is a single-valued property, return a list containing whole value.
|
||||
if (property.is_custom_property() || !property_is_list_valued(property.id()))
|
||||
return StyleValueVector { *this };
|
||||
|
||||
// 2. Otherwise, divide whole value into individual iterations, as appropriate for property, and return a list
|
||||
// containing the iterations in order.
|
||||
return values();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ public:
|
|||
virtual String to_string(SerializationMode) const override;
|
||||
virtual Vector<Parser::ComponentValue> tokenize() const override;
|
||||
virtual GC::Ref<CSSStyleValue> reify(JS::Realm&, FlyString const& associated_property) const override;
|
||||
virtual StyleValueVector subdivide_into_iterations(PropertyNameAndID const&) const override;
|
||||
|
||||
virtual ValueComparingNonnullRefPtr<StyleValue const> absolutized(ComputationContext const&) const override;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue