mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-10-17 05:29:56 +00:00
LibWeb/CSS: Add a Property -> CalculationContext factory method
We have this code duplicated in multiple places, and we'll want to handle registered custom properties too at some point, so wrap it in a reusable `CalculationContext::for_property()` method. Noticed while doing this that ValueParsingContext will eventually need to take a PropertyNameAndID, not a PropertyID, so I've added a FIXME.
This commit is contained in:
parent
a3e973970a
commit
0afa93e639
Notes:
github-actions[bot]
2025-10-13 09:01:24 +00:00
Author: https://github.com/AtkinsSJ
Commit: 0afa93e639
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6440
6 changed files with 19 additions and 15 deletions
|
@ -22,6 +22,7 @@
|
|||
#include <LibWeb/CSS/CSSUnitValue.h>
|
||||
#include <LibWeb/CSS/Percentage.h>
|
||||
#include <LibWeb/CSS/PropertyID.h>
|
||||
#include <LibWeb/CSS/PropertyNameAndID.h>
|
||||
#include <LibWeb/CSS/StyleValues/AngleStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FlexStyleValue.h>
|
||||
#include <LibWeb/CSS/StyleValues/FrequencyStyleValue.h>
|
||||
|
@ -34,6 +35,16 @@
|
|||
|
||||
namespace Web::CSS {
|
||||
|
||||
CalculationContext CalculationContext::for_property(PropertyNameAndID const& property)
|
||||
{
|
||||
// FIXME: Handle registered custom properties, which may limit which types they accept.
|
||||
return {
|
||||
.percentages_resolve_as = property_resolves_percentages_relative_to(property.id()),
|
||||
.resolve_numbers_as_integers = property_accepts_type(property.id(), ValueType::Integer),
|
||||
.accepted_type_ranges = property_accepted_type_ranges(property.id()),
|
||||
};
|
||||
}
|
||||
|
||||
static Optional<NumericType> add_the_types(Vector<NonnullRefPtr<CalculationNode const>> const& nodes)
|
||||
{
|
||||
Optional<NumericType> left_type;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue