mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-04-26 01:35:08 +02:00
LibWeb/CSS: Add flag to disable create-internal-rep type checking
CSSTransformComponents hold other CSSStyleValues as their parameters. We want to be able to create internal representations from those parameters without them caring if they would be valid when directly assigned to the property. This is a temporary solution to make transform functions work. To be completely correct, we need to know what is allowed in that context, along with value ranges - a combination of the contexts we create when parsing, and when computing calculations. For transform functions, this doesn't matter, as there's no limit to the range of allowed values.
This commit is contained in:
Notes:
github-actions[bot]
2025-10-14 12:42:59 +00:00
Author: https://github.com/AtkinsSJ Commit: https://github.com/LadybirdBrowser/ladybird/commit/5178d1ebe3d Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/6466
@@ -326,7 +326,7 @@ static Optional<CalculationNode::NumericValue> create_numeric_value(double value
|
||||
}
|
||||
|
||||
// https://drafts.css-houdini.org/css-typed-om-1/#create-an-internal-representation
|
||||
WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSUnitValue::create_an_internal_representation(PropertyNameAndID const& property) const
|
||||
WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSUnitValue::create_an_internal_representation(PropertyNameAndID const& property, PerformTypeCheck perform_type_check) const
|
||||
{
|
||||
// If value is a CSSStyleValue subclass,
|
||||
// If value does not match the grammar of a list-valued property iteration of property, throw a TypeError.
|
||||
@@ -338,7 +338,7 @@ WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSUnitValue::create_an_int
|
||||
// Return the value.
|
||||
|
||||
// NB: We store all custom properties as UnresolvedStyleValue, so we always need to create one here.
|
||||
if (property.is_custom_property()) {
|
||||
if (perform_type_check == PerformTypeCheck::Yes && property.is_custom_property()) {
|
||||
auto token = [this]() {
|
||||
if (m_unit == "number"_fly_string)
|
||||
return Parser::Token::create_number(Number { Number::Type::Number, m_value });
|
||||
@@ -361,6 +361,35 @@ WebIDL::ExceptionOr<NonnullRefPtr<StyleValue const>> CSSUnitValue::create_an_int
|
||||
return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unrecognized unit '{}'.", m_unit)) };
|
||||
}
|
||||
|
||||
if (perform_type_check == PerformTypeCheck::No) {
|
||||
return value->visit(
|
||||
[&](Number const& number) -> RefPtr<StyleValue const> {
|
||||
return NumberStyleValue::create(number.value());
|
||||
},
|
||||
[&](Percentage const& percentage) -> RefPtr<StyleValue const> {
|
||||
return PercentageStyleValue::create(percentage);
|
||||
},
|
||||
[&](Angle const& angle) -> RefPtr<StyleValue const> {
|
||||
return AngleStyleValue::create(angle);
|
||||
},
|
||||
[&](Flex const& flex) -> RefPtr<StyleValue const> {
|
||||
return FlexStyleValue::create(flex);
|
||||
},
|
||||
[&](Frequency const& frequency) -> RefPtr<StyleValue const> {
|
||||
return FrequencyStyleValue::create(frequency);
|
||||
},
|
||||
[&](Length const& length) -> RefPtr<StyleValue const> {
|
||||
return LengthStyleValue::create(length);
|
||||
},
|
||||
[&](Resolution const& resolution) -> RefPtr<StyleValue const> {
|
||||
return ResolutionStyleValue::create(resolution);
|
||||
},
|
||||
[&](Time const& time) -> RefPtr<StyleValue const> {
|
||||
return TimeStyleValue::create(time);
|
||||
})
|
||||
.release_nonnull();
|
||||
}
|
||||
|
||||
// FIXME: Check types allowed by registered custom properties.
|
||||
auto style_value = value->visit(
|
||||
[&](Number const& number) -> RefPtr<StyleValue const> {
|
||||
|
||||
Reference in New Issue
Block a user