diff --git a/Libraries/LibWeb/CSS/CSSMathClamp.cpp b/Libraries/LibWeb/CSS/CSSMathClamp.cpp index e06cc6ff070..6c419e06e2a 100644 --- a/Libraries/LibWeb/CSS/CSSMathClamp.cpp +++ b/Libraries/LibWeb/CSS/CSSMathClamp.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -146,4 +147,12 @@ Optional CSSMathClamp::create_a_sum_value() const }; } +WebIDL::ExceptionOr> CSSMathClamp::create_calculation_node(CalculationContext const& context) const +{ + auto lower = TRY(m_lower->create_calculation_node(context)); + auto value = TRY(m_value->create_calculation_node(context)); + auto upper = TRY(m_upper->create_calculation_node(context)); + return ClampCalculationNode::create(move(lower), move(value), move(upper)); +} + } diff --git a/Libraries/LibWeb/CSS/CSSMathClamp.h b/Libraries/LibWeb/CSS/CSSMathClamp.h index 26ab60274fc..66cfbb8598c 100644 --- a/Libraries/LibWeb/CSS/CSSMathClamp.h +++ b/Libraries/LibWeb/CSS/CSSMathClamp.h @@ -32,6 +32,8 @@ public: virtual bool is_equal_numeric_value(GC::Ref other) const override; virtual Optional create_a_sum_value() const override; + virtual WebIDL::ExceptionOr> create_calculation_node(CalculationContext const&) const override; + private: CSSMathClamp(JS::Realm&, NumericType, GC::Ref lower, GC::Ref value, GC::Ref upper); GC::Ref m_lower; diff --git a/Libraries/LibWeb/CSS/CSSMathInvert.cpp b/Libraries/LibWeb/CSS/CSSMathInvert.cpp index 6f8a2887dcc..a1e97ad1fc0 100644 --- a/Libraries/LibWeb/CSS/CSSMathInvert.cpp +++ b/Libraries/LibWeb/CSS/CSSMathInvert.cpp @@ -7,6 +7,7 @@ #include "CSSMathInvert.h" #include #include +#include #include namespace Web::CSS { @@ -131,4 +132,9 @@ Optional CSSMathInvert::create_a_sum_value() const return values; } +WebIDL::ExceptionOr> CSSMathInvert::create_calculation_node(CalculationContext const& context) const +{ + return InvertCalculationNode::create(TRY(m_value->create_calculation_node(context))); +} + } diff --git a/Libraries/LibWeb/CSS/CSSMathInvert.h b/Libraries/LibWeb/CSS/CSSMathInvert.h index 996a1738b13..2b66092d5ea 100644 --- a/Libraries/LibWeb/CSS/CSSMathInvert.h +++ b/Libraries/LibWeb/CSS/CSSMathInvert.h @@ -30,6 +30,8 @@ public: virtual bool is_equal_numeric_value(GC::Ref other) const override; virtual Optional create_a_sum_value() const override; + virtual WebIDL::ExceptionOr> create_calculation_node(CalculationContext const&) const override; + private: CSSMathInvert(JS::Realm&, NumericType, GC::Ref); GC::Ref m_value; diff --git a/Libraries/LibWeb/CSS/CSSMathMax.cpp b/Libraries/LibWeb/CSS/CSSMathMax.cpp index 7db0edd7d77..4edd3718f98 100644 --- a/Libraries/LibWeb/CSS/CSSMathMax.cpp +++ b/Libraries/LibWeb/CSS/CSSMathMax.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -157,4 +158,14 @@ Optional CSSMathMax::create_a_sum_value() const return item_with_largest_value; } +WebIDL::ExceptionOr> CSSMathMax::create_calculation_node(CalculationContext const& context) const +{ + Vector> child_nodes; + for (auto const& child_value : m_values->values()) { + child_nodes.append(TRY(child_value->create_calculation_node(context))); + } + + return MaxCalculationNode::create(move(child_nodes)); +} + } diff --git a/Libraries/LibWeb/CSS/CSSMathMax.h b/Libraries/LibWeb/CSS/CSSMathMax.h index 9fe7d98dae5..351e10e9b5c 100644 --- a/Libraries/LibWeb/CSS/CSSMathMax.h +++ b/Libraries/LibWeb/CSS/CSSMathMax.h @@ -30,6 +30,8 @@ public: virtual bool is_equal_numeric_value(GC::Ref other) const override; virtual Optional create_a_sum_value() const override; + virtual WebIDL::ExceptionOr> create_calculation_node(CalculationContext const&) const override; + private: CSSMathMax(JS::Realm&, NumericType, GC::Ref); GC::Ref m_values; diff --git a/Libraries/LibWeb/CSS/CSSMathMin.cpp b/Libraries/LibWeb/CSS/CSSMathMin.cpp index 733ac0eb862..c7a24d65cdc 100644 --- a/Libraries/LibWeb/CSS/CSSMathMin.cpp +++ b/Libraries/LibWeb/CSS/CSSMathMin.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include @@ -158,4 +159,14 @@ Optional CSSMathMin::create_a_sum_value() const return item_with_smallest_value; } +WebIDL::ExceptionOr> CSSMathMin::create_calculation_node(CalculationContext const& context) const +{ + Vector> child_nodes; + for (auto const& child_value : m_values->values()) { + child_nodes.append(TRY(child_value->create_calculation_node(context))); + } + + return MinCalculationNode::create(move(child_nodes)); +} + } diff --git a/Libraries/LibWeb/CSS/CSSMathMin.h b/Libraries/LibWeb/CSS/CSSMathMin.h index 2e271c1dc4f..a3e4d1695b4 100644 --- a/Libraries/LibWeb/CSS/CSSMathMin.h +++ b/Libraries/LibWeb/CSS/CSSMathMin.h @@ -30,6 +30,8 @@ public: virtual bool is_equal_numeric_value(GC::Ref other) const override; virtual Optional create_a_sum_value() const override; + virtual WebIDL::ExceptionOr> create_calculation_node(CalculationContext const&) const override; + private: CSSMathMin(JS::Realm&, NumericType, GC::Ref); GC::Ref m_values; diff --git a/Libraries/LibWeb/CSS/CSSMathNegate.cpp b/Libraries/LibWeb/CSS/CSSMathNegate.cpp index 706375887b3..a810d7cdef6 100644 --- a/Libraries/LibWeb/CSS/CSSMathNegate.cpp +++ b/Libraries/LibWeb/CSS/CSSMathNegate.cpp @@ -7,6 +7,7 @@ #include "CSSMathNegate.h" #include #include +#include #include namespace Web::CSS { @@ -121,4 +122,9 @@ Optional CSSMathNegate::create_a_sum_value() const return values; } +WebIDL::ExceptionOr> CSSMathNegate::create_calculation_node(CalculationContext const& context) const +{ + return NegateCalculationNode::create(TRY(m_value->create_calculation_node(context))); +} + } diff --git a/Libraries/LibWeb/CSS/CSSMathNegate.h b/Libraries/LibWeb/CSS/CSSMathNegate.h index 3b63b52834c..97ba5d12e3e 100644 --- a/Libraries/LibWeb/CSS/CSSMathNegate.h +++ b/Libraries/LibWeb/CSS/CSSMathNegate.h @@ -30,6 +30,8 @@ public: virtual bool is_equal_numeric_value(GC::Ref other) const override; virtual Optional create_a_sum_value() const override; + virtual WebIDL::ExceptionOr> create_calculation_node(CalculationContext const&) const override; + private: CSSMathNegate(JS::Realm&, NumericType, GC::Ref); GC::Ref m_value; diff --git a/Libraries/LibWeb/CSS/CSSMathProduct.cpp b/Libraries/LibWeb/CSS/CSSMathProduct.cpp index 219cf120e53..775994cc4ba 100644 --- a/Libraries/LibWeb/CSS/CSSMathProduct.cpp +++ b/Libraries/LibWeb/CSS/CSSMathProduct.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -194,4 +195,14 @@ Optional CSSMathProduct::create_a_sum_value() const return values; } +WebIDL::ExceptionOr> CSSMathProduct::create_calculation_node(CalculationContext const& context) const +{ + Vector> child_nodes; + for (auto const& child_value : m_values->values()) { + child_nodes.append(TRY(child_value->create_calculation_node(context))); + } + + return ProductCalculationNode::create(move(child_nodes)); +} + } diff --git a/Libraries/LibWeb/CSS/CSSMathProduct.h b/Libraries/LibWeb/CSS/CSSMathProduct.h index c3326b7ef44..35dacdcffcd 100644 --- a/Libraries/LibWeb/CSS/CSSMathProduct.h +++ b/Libraries/LibWeb/CSS/CSSMathProduct.h @@ -30,6 +30,8 @@ public: virtual bool is_equal_numeric_value(GC::Ref other) const override; virtual Optional create_a_sum_value() const override; + virtual WebIDL::ExceptionOr> create_calculation_node(CalculationContext const&) const override; + private: CSSMathProduct(JS::Realm&, NumericType, GC::Ref); GC::Ref m_values; diff --git a/Libraries/LibWeb/CSS/CSSMathSum.cpp b/Libraries/LibWeb/CSS/CSSMathSum.cpp index 9ae6a713eac..bc9dcee6aa6 100644 --- a/Libraries/LibWeb/CSS/CSSMathSum.cpp +++ b/Libraries/LibWeb/CSS/CSSMathSum.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include @@ -206,4 +207,14 @@ Optional CSSMathSum::create_a_sum_value() const return values; } +WebIDL::ExceptionOr> CSSMathSum::create_calculation_node(CalculationContext const& context) const +{ + Vector> child_nodes; + for (auto const& child_value : m_values->values()) { + child_nodes.append(TRY(child_value->create_calculation_node(context))); + } + + return SumCalculationNode::create(move(child_nodes)); +} + } diff --git a/Libraries/LibWeb/CSS/CSSMathSum.h b/Libraries/LibWeb/CSS/CSSMathSum.h index 02751646990..9ab718bc3c7 100644 --- a/Libraries/LibWeb/CSS/CSSMathSum.h +++ b/Libraries/LibWeb/CSS/CSSMathSum.h @@ -30,6 +30,8 @@ public: virtual bool is_equal_numeric_value(GC::Ref other) const override; virtual Optional create_a_sum_value() const override; + virtual WebIDL::ExceptionOr> create_calculation_node(CalculationContext const&) const override; + private: CSSMathSum(JS::Realm&, NumericType, GC::Ref); GC::Ref m_values; diff --git a/Libraries/LibWeb/CSS/CSSMathValue.cpp b/Libraries/LibWeb/CSS/CSSMathValue.cpp index edf39f39ec5..4cc6e7965b7 100644 --- a/Libraries/LibWeb/CSS/CSSMathValue.cpp +++ b/Libraries/LibWeb/CSS/CSSMathValue.cpp @@ -6,6 +6,8 @@ #include "CSSMathValue.h" #include +#include +#include namespace Web::CSS { @@ -23,4 +25,44 @@ void CSSMathValue::initialize(JS::Realm& realm) Base::initialize(realm); } +// https://drafts.css-houdini.org/css-typed-om-1/#create-an-internal-representation +WebIDL::ExceptionOr> CSSMathValue::create_an_internal_representation(PropertyNameAndID const& property) 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. + // + // If any component of property’s CSS grammar has a limited numeric range, and the corresponding part of value + // is a CSSUnitValue that is outside of that range, replace that value with the result of wrapping it in a + // fresh CSSMathSum whose values internal slot contains only that part of value. + // + // Return the value. + + // FIXME: Check types allowed by registered custom properties. + auto context = CalculationContext::for_property(property); + auto matches = [&] { + if (type().matches_angle(context.percentages_resolve_as)) + return property_accepts_type(property.id(), ValueType::Angle); + if (type().matches_flex(context.percentages_resolve_as)) + return property_accepts_type(property.id(), ValueType::Flex); + if (type().matches_frequency(context.percentages_resolve_as)) + return property_accepts_type(property.id(), ValueType::Frequency); + if (type().matches_length(context.percentages_resolve_as)) + return property_accepts_type(property.id(), ValueType::Length); + if (type().matches_number(context.percentages_resolve_as)) + return property_accepts_type(property.id(), ValueType::Number); + if (type().matches_percentage()) + return property_accepts_type(property.id(), ValueType::Percentage); + if (type().matches_resolution(context.percentages_resolve_as)) + return property_accepts_type(property.id(), ValueType::Resolution); + if (type().matches_time(context.percentages_resolve_as)) + return property_accepts_type(property.id(), ValueType::Time); + return false; + }(); + + if (!matches) + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Property does not accept values of this type."sv }; + + return CalculatedStyleValue::create(TRY(create_calculation_node(context)), type(), move(context)); +} + } diff --git a/Libraries/LibWeb/CSS/CSSMathValue.h b/Libraries/LibWeb/CSS/CSSMathValue.h index 0ea9e1da3d4..54d33c4b000 100644 --- a/Libraries/LibWeb/CSS/CSSMathValue.h +++ b/Libraries/LibWeb/CSS/CSSMathValue.h @@ -8,6 +8,7 @@ #include #include +#include namespace Web::CSS { @@ -31,6 +32,8 @@ public: }; virtual String serialize_math_value(Nested, Parens) const = 0; + virtual WebIDL::ExceptionOr> create_an_internal_representation(PropertyNameAndID const&) const final override; + protected: explicit CSSMathValue(JS::Realm&, Bindings::CSSMathOperator, NumericType); diff --git a/Libraries/LibWeb/CSS/CSSNumericValue.h b/Libraries/LibWeb/CSS/CSSNumericValue.h index 527e612107b..536fda465be 100644 --- a/Libraries/LibWeb/CSS/CSSNumericValue.h +++ b/Libraries/LibWeb/CSS/CSSNumericValue.h @@ -65,6 +65,8 @@ public: static WebIDL::ExceptionOr> parse(JS::VM&, String const& css_text); + virtual WebIDL::ExceptionOr> create_calculation_node(CalculationContext const&) const = 0; + protected: explicit CSSNumericValue(JS::Realm&, NumericType); diff --git a/Libraries/LibWeb/CSS/CSSUnitValue.cpp b/Libraries/LibWeb/CSS/CSSUnitValue.cpp index 1f233b0a5fa..7e165ed2f8e 100644 --- a/Libraries/LibWeb/CSS/CSSUnitValue.cpp +++ b/Libraries/LibWeb/CSS/CSSUnitValue.cpp @@ -297,6 +297,34 @@ Optional CSSUnitValue::create_a_sum_value() const return SumValue { SumValueItem { value, { { unit, 1 } } } }; } +static Optional create_numeric_value(double value, FlyString const& unit) +{ + if (unit == "number"_fly_string) + return Number { Number::Type::Number, value }; + + if (unit == "percent"_fly_string) + return Percentage { value }; + + if (auto dimension_type = dimension_for_unit(unit); dimension_type.has_value()) { + switch (*dimension_type) { + case DimensionType::Angle: + return Angle { value, string_to_angle_unit(unit).release_value() }; + case DimensionType::Flex: + return Flex { value, string_to_flex_unit(unit).release_value() }; + case DimensionType::Frequency: + return Frequency { value, string_to_frequency_unit(unit).release_value() }; + case DimensionType::Length: + return Length { value, string_to_length_unit(unit).release_value() }; + case DimensionType::Resolution: + return Resolution { value, string_to_resolution_unit(unit).release_value() }; + case DimensionType::Time: + return Time { value, string_to_time_unit(unit).release_value() }; + } + } + + return {}; +} + // https://drafts.css-houdini.org/css-typed-om-1/#create-an-internal-representation WebIDL::ExceptionOr> CSSUnitValue::create_an_internal_representation(PropertyNameAndID const& property) const { @@ -322,102 +350,107 @@ WebIDL::ExceptionOr> CSSUnitValue::create_an_int } auto wrap_in_math_sum = [this, &property](auto&& value) -> NonnullRefPtr { - CalculationContext context { - .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()), - }; + auto context = CalculationContext::for_property(property); auto numeric_node = NumericCalculationNode::create(value, context); auto math_sum_node = SumCalculationNode::create({ move(numeric_node) }); return CalculatedStyleValue::create(move(math_sum_node), NumericType::create_from_unit(m_unit).release_value(), context); }; - if (m_unit == "number"_fly_string) { - // NB: Number before Integer, because a custom property accepts either and we want to avoid rounding in that case. - if (property_accepts_type(property.id(), ValueType::Number)) { - if (property_accepts_number(property.id(), m_value)) - return NumberStyleValue::create(m_value); - return wrap_in_math_sum(Number { Number::Type::Number, m_value }); - } - - if (property_accepts_type(property.id(), ValueType::Integer)) { - // NB: Same rounding as CalculatedStyleValue::resolve_integer(). Maybe this should go somewhere central? - auto integer = llround(m_value); - if (property_accepts_integer(property.id(), integer)) - return IntegerStyleValue::create(integer); - return wrap_in_math_sum(Number { Number::Type::Number, m_value }); - } - - return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Property does not accept values of this type."sv }; - } - - if (m_unit == "percent"_fly_string) { - if (property_accepts_type(property.id(), ValueType::Percentage)) { - Percentage percentage { m_value }; - if (property_accepts_percentage(property.id(), percentage)) - return PercentageStyleValue::create(percentage); - return wrap_in_math_sum(percentage); - } - - return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Property does not accept values of this type."sv }; - } - - auto dimension_type = dimension_for_unit(m_unit); - if (!dimension_type.has_value()) + auto value = create_numeric_value(m_value, m_unit); + if (!value.has_value()) { return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unrecognized unit '{}'.", m_unit)) }; - - switch (*dimension_type) { - case DimensionType::Angle: - if (property_accepts_type(property.id(), ValueType::Angle)) { - Angle value { m_value, string_to_angle_unit(m_unit).release_value() }; - if (property_accepts_angle(property.id(), value)) - return AngleStyleValue::create(value); - return wrap_in_math_sum(value); - } - break; - case DimensionType::Flex: - if (property_accepts_type(property.id(), ValueType::Flex)) { - Flex value { m_value, string_to_flex_unit(m_unit).release_value() }; - if (property_accepts_flex(property.id(), value)) - return FlexStyleValue::create(value); - return wrap_in_math_sum(value); - } - break; - case DimensionType::Frequency: - if (property_accepts_type(property.id(), ValueType::Frequency)) { - Frequency value { m_value, string_to_frequency_unit(m_unit).release_value() }; - if (property_accepts_frequency(property.id(), value)) - return FrequencyStyleValue::create(value); - return wrap_in_math_sum(value); - } - break; - case DimensionType::Length: - if (property_accepts_type(property.id(), ValueType::Length)) { - Length value { m_value, string_to_length_unit(m_unit).release_value() }; - if (property_accepts_length(property.id(), value)) - return LengthStyleValue::create(value); - return wrap_in_math_sum(value); - } - break; - case DimensionType::Resolution: - if (property_accepts_type(property.id(), ValueType::Resolution)) { - Resolution value { m_value, string_to_resolution_unit(m_unit).release_value() }; - if (property_accepts_resolution(property.id(), value)) - return ResolutionStyleValue::create(value); - return wrap_in_math_sum(value); - } - break; - case DimensionType::Time: - if (property_accepts_type(property.id(), ValueType::Time)) { - Time value { m_value, string_to_time_unit(m_unit).release_value() }; - if (property_accepts_time(property.id(), value)) - return TimeStyleValue::create(value); - return wrap_in_math_sum(value); - } - break; } - return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Property does not accept values of this type."sv }; + // FIXME: Check types allowed by registered custom properties. + auto style_value = value->visit( + [&](Number const& number) -> RefPtr { + // NB: Number before Integer, because a custom property accepts either and we want to avoid rounding in that case. + if (property_accepts_type(property.id(), ValueType::Number)) { + if (property_accepts_number(property.id(), number.value())) + return NumberStyleValue::create(number.value()); + return wrap_in_math_sum(number); + } + + if (property_accepts_type(property.id(), ValueType::Integer)) { + // NB: Same rounding as CalculatedStyleValue::resolve_integer(). Maybe this should go somewhere central? + auto integer = llround(number.value()); + if (property_accepts_integer(property.id(), integer)) + return IntegerStyleValue::create(integer); + return wrap_in_math_sum(number); + } + + return {}; + }, + [&](Percentage const& percentage) -> RefPtr { + if (property_accepts_type(property.id(), ValueType::Percentage)) { + if (property_accepts_percentage(property.id(), percentage)) + return PercentageStyleValue::create(percentage); + return wrap_in_math_sum(percentage); + } + + return {}; + }, + [&](Angle const& angle) -> RefPtr { + if (property_accepts_type(property.id(), ValueType::Angle)) { + if (property_accepts_angle(property.id(), angle)) + return AngleStyleValue::create(angle); + return wrap_in_math_sum(angle); + } + return {}; + }, + [&](Flex const& flex) -> RefPtr { + if (property_accepts_type(property.id(), ValueType::Flex)) { + if (property_accepts_flex(property.id(), flex)) + return FlexStyleValue::create(flex); + return wrap_in_math_sum(flex); + } + return {}; + }, + [&](Frequency const& frequency) -> RefPtr { + if (property_accepts_type(property.id(), ValueType::Frequency)) { + if (property_accepts_frequency(property.id(), frequency)) + return FrequencyStyleValue::create(frequency); + return wrap_in_math_sum(frequency); + } + return {}; + }, + [&](Length const& length) -> RefPtr { + if (property_accepts_type(property.id(), ValueType::Length)) { + if (property_accepts_length(property.id(), length)) + return LengthStyleValue::create(length); + return wrap_in_math_sum(length); + } + return {}; + }, + [&](Resolution const& resolution) -> RefPtr { + if (property_accepts_type(property.id(), ValueType::Resolution)) { + if (property_accepts_resolution(property.id(), resolution)) + return ResolutionStyleValue::create(resolution); + return wrap_in_math_sum(resolution); + } + return {}; + }, + [&](Time const& time) -> RefPtr { + if (property_accepts_type(property.id(), ValueType::Time)) { + if (property_accepts_time(property.id(), time)) + return TimeStyleValue::create(time); + return wrap_in_math_sum(time); + } + return {}; + }); + + if (!style_value) + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, "Property does not accept values of this type."sv }; + return style_value.release_nonnull(); +} + +WebIDL::ExceptionOr> CSSUnitValue::create_calculation_node(CalculationContext const& context) const +{ + auto value = create_numeric_value(m_value, m_unit); + if (!value.has_value()) + return WebIDL::SimpleException { WebIDL::SimpleExceptionType::TypeError, MUST(String::formatted("Unable to create calculation node from `{}{}`.", m_value, m_unit)) }; + + return NumericCalculationNode::create(value.release_value(), context); } } diff --git a/Libraries/LibWeb/CSS/CSSUnitValue.h b/Libraries/LibWeb/CSS/CSSUnitValue.h index f7527955e03..2cf8cf90454 100644 --- a/Libraries/LibWeb/CSS/CSSUnitValue.h +++ b/Libraries/LibWeb/CSS/CSSUnitValue.h @@ -36,6 +36,7 @@ public: virtual Optional create_a_sum_value() const override; virtual WebIDL::ExceptionOr> create_an_internal_representation(PropertyNameAndID const&) const override; + virtual WebIDL::ExceptionOr> create_calculation_node(CalculationContext const&) const override; private: explicit CSSUnitValue(JS::Realm&, double value, FlyString unit, NumericType type); diff --git a/Libraries/LibWeb/CSS/Interpolation.cpp b/Libraries/LibWeb/CSS/Interpolation.cpp index dd2fb9dafa3..37b1d0493c6 100644 --- a/Libraries/LibWeb/CSS/Interpolation.cpp +++ b/Libraries/LibWeb/CSS/Interpolation.cpp @@ -1,7 +1,7 @@ /* * Copyright (c) 2018-2023, Andreas Kling * Copyright (c) 2021, the SerenityOS developers. - * Copyright (c) 2021-2024, Sam Atkins + * Copyright (c) 2021-2025, Sam Atkins * Copyright (c) 2024, Matthew Olsson * Copyright (c) 2025, Tim Ledbetter * @@ -11,6 +11,7 @@ #include "Interpolation.h" #include #include +#include #include #include #include @@ -600,10 +601,7 @@ ValueComparingRefPtr interpolate_property(DOM::Element& elemen auto from = with_keyword_values_resolved(element, property_id, a_from); auto to = with_keyword_values_resolved(element, property_id, a_to); - CalculationContext calculation_context { - .percentages_resolve_as = property_resolves_percentages_relative_to(property_id), - .accepted_type_ranges = property_accepted_type_ranges(property_id), - }; + auto calculation_context = CalculationContext::for_property(PropertyNameAndID::from_id(property_id)); auto animation_type = animation_type_from_longhand_property(property_id); switch (animation_type) { diff --git a/Libraries/LibWeb/CSS/Parser/Parser.h b/Libraries/LibWeb/CSS/Parser/Parser.h index db00b59f3f4..80172421bcc 100644 --- a/Libraries/LibWeb/CSS/Parser/Parser.h +++ b/Libraries/LibWeb/CSS/Parser/Parser.h @@ -566,6 +566,7 @@ private: ShadowBlurRadius, TranslateZArgument }; + // FIXME: Use PropertyNameAndID instead of PropertyID as the context, for registered custom properties. using ValueParsingContext = Variant; Vector m_value_context; auto push_temporary_value_parsing_context(ValueParsingContext&& context) diff --git a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp index 3cc80b6c484..d690e851347 100644 --- a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp @@ -4106,11 +4106,7 @@ RefPtr Parser::parse_calculated_value(ComponentValue for (auto const& value_context : m_value_context.in_reverse()) { auto maybe_context = value_context.visit( [](PropertyID property_id) -> Optional { - return CalculationContext { - .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), - }; + return CalculationContext::for_property(PropertyNameAndID::from_id(property_id)); }, [](FunctionContext const& function) -> Optional { // Gradients resolve percentages as lengths relative to the gradient-box. diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index b709ee224e5..5b72c75183d 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -3601,7 +3601,7 @@ NonnullRefPtr StyleComputer::compute_line_height(NonnullRefPtr // NOTE: We also support calc()'d numbers if (specified_value->is_calculated() && specified_value->as_calculated().resolves_to_number()) - return NumberStyleValue::create(specified_value->as_calculated().resolve_number(CalculationResolutionContext::from_computation_context(computation_context)).value()); + return NumberStyleValue::create(specified_value->as_calculated().resolve_number(CalculationResolutionContext::from_computation_context(computation_context, Length(1, LengthUnit::Em))).value()); // if (specified_value->is_percentage()) diff --git a/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp index 051f62bad74..fda72fe13ef 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp @@ -22,6 +22,7 @@ #include #include #include +#include #include #include #include @@ -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 add_the_types(Vector> const& nodes) { Optional left_type; diff --git a/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h index 7970eaea764..0ee2d6bb839 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.h @@ -32,6 +32,8 @@ struct CalculationContext { Optional percentages_resolve_as {}; bool resolve_numbers_as_integers = false; AcceptedTypeRangeMap accepted_type_ranges {}; + + static CalculationContext for_property(PropertyNameAndID const&); }; class CalculatedStyleValue : public StyleValue { diff --git a/Libraries/LibWeb/DOM/Range.cpp b/Libraries/LibWeb/DOM/Range.cpp index 276783da5f2..4a2a0331717 100644 --- a/Libraries/LibWeb/DOM/Range.cpp +++ b/Libraries/LibWeb/DOM/Range.cpp @@ -27,6 +27,8 @@ #include #include #include +#include +#include namespace Web::DOM { @@ -1240,9 +1242,16 @@ GC::Ref Range::get_bounding_client_rect() } // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment -WebIDL::ExceptionOr> Range::create_contextual_fragment(String const& string) +WebIDL::ExceptionOr> Range::create_contextual_fragment(TrustedTypes::TrustedHTMLOrString const& string) { - // FIXME: 1. Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with TrustedHTML, this's relevant global object, string, "Range createContextualFragment", and "script". + // 1. Let compliantString be the result of invoking the Get Trusted Type compliant string algorithm with + // TrustedHTML, this's relevant global object, string, "Range createContextualFragment", and "script". + auto const compliant_string = TRY(TrustedTypes::get_trusted_type_compliant_string( + TrustedTypes::TrustedTypeName::TrustedHTML, + HTML::relevant_global_object(*this), + string, + TrustedTypes::InjectionSink::RangecreateContextualFragment, + TrustedTypes::Script.to_string())); // 2. Let node be this's start node. GC::Ref node = *start_container(); @@ -1268,8 +1277,8 @@ WebIDL::ExceptionOr> Range::create_contextual_fragment element = TRY(DOM::create_element(node->document(), HTML::TagNames::body, Namespace::HTML)); } - // 7. Let fragment node be the result of invoking the fragment parsing algorithm steps with element and compliantString. FIXME: Use compliantString. - auto fragment_node = TRY(element->parse_fragment(string)); + // 7. Let fragment node be the result of invoking the fragment parsing algorithm steps with element and compliantString. + auto fragment_node = TRY(element->parse_fragment(compliant_string.to_utf8_but_should_be_ported_to_utf16())); // 8. For each script of fragment node's script element descendants: fragment_node->for_each_in_subtree_of_type([&](HTML::HTMLScriptElement& script_element) { diff --git a/Libraries/LibWeb/DOM/Range.h b/Libraries/LibWeb/DOM/Range.h index 8114346e6ec..791e6d8cd1f 100644 --- a/Libraries/LibWeb/DOM/Range.h +++ b/Libraries/LibWeb/DOM/Range.h @@ -13,6 +13,7 @@ #include #include #include +#include #include namespace Web::DOM { @@ -91,7 +92,7 @@ public: void set_associated_selection(Badge, GC::Ptr); - WebIDL::ExceptionOr> create_contextual_fragment(String const& fragment); + WebIDL::ExceptionOr> create_contextual_fragment(TrustedTypes::TrustedHTMLOrString const& fragment); template void for_each_contained(Callback callback) const diff --git a/Libraries/LibWeb/DOM/Range.idl b/Libraries/LibWeb/DOM/Range.idl index 6a003332dd5..d8d69ff3259 100644 --- a/Libraries/LibWeb/DOM/Range.idl +++ b/Libraries/LibWeb/DOM/Range.idl @@ -1,6 +1,7 @@ #import #import #import +#import // https://dom.spec.whatwg.org/#interface-range [Exposed=Window] @@ -46,6 +47,5 @@ interface Range : AbstractRange { stringifier; // https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#dom-range-createcontextualfragment - // FIXME: [CEReactions, NewObject] DocumentFragment createContextualFragment((TrustedHTML or DOMString) string); - [CEReactions, NewObject] DocumentFragment createContextualFragment(DOMString string); + [CEReactions, NewObject] DocumentFragment createContextualFragment((TrustedHTML or Utf16DOMString) string); }; diff --git a/Libraries/LibWeb/Editing/Commands.cpp b/Libraries/LibWeb/Editing/Commands.cpp index 9222eafc719..acda937ad79 100644 --- a/Libraries/LibWeb/Editing/Commands.cpp +++ b/Libraries/LibWeb/Editing/Commands.cpp @@ -24,6 +24,8 @@ #include #include #include +#include +#include namespace Web::Editing { @@ -1218,9 +1220,14 @@ bool command_insert_horizontal_rule_action(DOM::Document& document, Utf16String // https://w3c.github.io/editing/docs/execCommand/#the-inserthtml-command bool command_insert_html_action(DOM::Document& document, Utf16String const& value) { - // FIXME: 1. Set value to the result of invoking get trusted types compliant string with TrustedHTML, this's relevant + // 1. Set value to the result of invoking get trusted types compliant string with TrustedHTML, this's relevant // global object, value, "Document execCommand", and "script". - auto resulting_value = value; + auto const resulting_value = MUST(TrustedTypes::get_trusted_type_compliant_string( + TrustedTypes::TrustedTypeName::TrustedHTML, + HTML::relevant_global_object(document), + value, + TrustedTypes::InjectionSink::DocumentexecCommand, + TrustedTypes::Script.to_string())); // 2. Delete the selection. auto& selection = *document.get_selection(); @@ -1232,7 +1239,7 @@ bool command_insert_html_action(DOM::Document& document, Utf16String const& valu return true; // 4. Let frag be the result of calling createContextualFragment(value) on the active range. - auto frag = MUST(range->create_contextual_fragment(resulting_value.to_utf8_but_should_be_ported_to_utf16())); + auto frag = MUST(range->create_contextual_fragment(resulting_value)); // 5. Let last child be the lastChild of frag. GC::Ptr last_child = frag->last_child(); diff --git a/Libraries/LibWeb/Forward.h b/Libraries/LibWeb/Forward.h index 80b6c7614c7..00a48d5a527 100644 --- a/Libraries/LibWeb/Forward.h +++ b/Libraries/LibWeb/Forward.h @@ -217,6 +217,7 @@ class BasicShapeStyleValue; class BorderImageSliceStyleValue; class BorderRadiusStyleValue; class CalculatedStyleValue; +class CalculationNode; class CascadedProperties; class Clip; class ColorMixStyleValue; @@ -395,6 +396,7 @@ enum class MediaFeatureID : u8; enum class PropertyID : u16; struct BackgroundLayerData; +struct CalculationContext; struct CalculationResolutionContext; struct CSSStyleSheetInit; struct GridRepeatParams; diff --git a/Libraries/LibWeb/HTML/SharedWorker.cpp b/Libraries/LibWeb/HTML/SharedWorker.cpp index 84c0890514d..d11d812333e 100644 --- a/Libraries/LibWeb/HTML/SharedWorker.cpp +++ b/Libraries/LibWeb/HTML/SharedWorker.cpp @@ -17,17 +17,24 @@ #include #include #include +#include +#include namespace Web::HTML { GC_DEFINE_ALLOCATOR(SharedWorker); // https://html.spec.whatwg.org/multipage/workers.html#dom-sharedworker -WebIDL::ExceptionOr> SharedWorker::construct_impl(JS::Realm& realm, String const& script_url, Variant& options_value) +WebIDL::ExceptionOr> SharedWorker::construct_impl(JS::Realm& realm, TrustedTypes::TrustedScriptURLOrString const& script_url, Variant& options_value) { - // FIXME: 1. Let compliantScriptURL be the result of invoking the Get Trusted Type compliant string algorithm with - // TrustedScriptURL, this's relevant global object, scriptURL, "SharedWorker constructor", and "script". - auto const& compliant_script_url = script_url; + // 1. Let compliantScriptURL be the result of invoking the Get Trusted Type compliant string algorithm with + // TrustedScriptURL, this's relevant global object, scriptURL, "SharedWorker constructor", and "script". + auto const compliant_script_url = TRY(get_trusted_type_compliant_string( + TrustedTypes::TrustedTypeName::TrustedScriptURL, + realm.global_object(), + script_url, + TrustedTypes::InjectionSink::SharedWorkerconstructor, + TrustedTypes::Script.to_string())); // 2. If options is a DOMString, set options to a new WorkerOptions dictionary whose name member is set to the value // of options and whose other members are set to their default values. @@ -43,7 +50,7 @@ WebIDL::ExceptionOr> SharedWorker::construct_impl(JS::Real auto& outside_settings = current_principal_settings_object(); // 4. Let urlRecord be the result of encoding-parsing a URL given compliantScriptURL, relative to outside settings. - auto url = outside_settings.encoding_parse_url(compliant_script_url); + auto url = outside_settings.encoding_parse_url(compliant_script_url.to_utf8_but_should_be_ported_to_utf16()); // 5. If urlRecord is failure, then throw a "SyntaxError" DOMException. if (!url.has_value()) diff --git a/Libraries/LibWeb/HTML/SharedWorker.h b/Libraries/LibWeb/HTML/SharedWorker.h index 1cb7affb7e9..c6e99f30d0d 100644 --- a/Libraries/LibWeb/HTML/SharedWorker.h +++ b/Libraries/LibWeb/HTML/SharedWorker.h @@ -10,6 +10,7 @@ #include #include #include +#include #include namespace Web::HTML { @@ -22,7 +23,7 @@ class SharedWorker final GC_DECLARE_ALLOCATOR(SharedWorker); public: - static WebIDL::ExceptionOr> construct_impl(JS::Realm&, String const& script_url, Variant& options); + static WebIDL::ExceptionOr> construct_impl(JS::Realm&, TrustedTypes::TrustedScriptURLOrString const& script_url, Variant& options); virtual ~SharedWorker(); diff --git a/Libraries/LibWeb/HTML/SharedWorker.idl b/Libraries/LibWeb/HTML/SharedWorker.idl index 5f4f8fc1c43..389ad1b14ef 100644 --- a/Libraries/LibWeb/HTML/SharedWorker.idl +++ b/Libraries/LibWeb/HTML/SharedWorker.idl @@ -2,12 +2,12 @@ #import #import #import +#import // https://html.spec.whatwg.org/multipage/workers.html#sharedworker [Exposed=Window] interface SharedWorker : EventTarget { - // FIXME: "DOMString scriptURL" should be "(TrustedScriptURL or USVString) scriptURL". - constructor(DOMString scriptURL, optional (DOMString or WorkerOptions) options = {}); + constructor((TrustedScriptURL or Utf16USVString) scriptURL, optional (DOMString or WorkerOptions) options = {}); readonly attribute MessagePort port; }; diff --git a/Libraries/LibWeb/HTML/Worker.cpp b/Libraries/LibWeb/HTML/Worker.cpp index d2a7fec7857..279f55585b5 100644 --- a/Libraries/LibWeb/HTML/Worker.cpp +++ b/Libraries/LibWeb/HTML/Worker.cpp @@ -12,6 +12,8 @@ #include #include #include +#include +#include namespace Web::HTML { @@ -42,7 +44,7 @@ void Worker::visit_edges(Cell::Visitor& visitor) // https://html.spec.whatwg.org/multipage/workers.html#dom-worker // https://whatpr.org/html/9893/workers.html#dom-worker -WebIDL::ExceptionOr> Worker::create(String const& script_url, WorkerOptions const& options, DOM::Document& document) +WebIDL::ExceptionOr> Worker::create(TrustedTypes::TrustedScriptURLOrString const& script_url, WorkerOptions const& options, DOM::Document& document) { dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Creating worker with script_url = {}", script_url); @@ -53,26 +55,31 @@ WebIDL::ExceptionOr> Worker::create(String const& script_url, Wo // JavaScript modules (specify type: "module"), and if that is specified, can also be used // to specify how scriptURL is fetched through the credentials option. - // FIXME: 1. The user agent may throw a "SecurityError" DOMException if the request violates - // a policy decision (e.g. if the user agent is configured to not allow the page to start dedicated workers). - // Technically not a fixme if our policy is not to throw errors :^) + // 1. Let compliantScriptURL be the result of invoking the Get Trusted Type compliant string algorithm with + // TrustedScriptURL, this's relevant global object, scriptURL, "Worker constructor", and "script". + auto const compliant_script_url = TRY(TrustedTypes::get_trusted_type_compliant_string( + TrustedTypes::TrustedTypeName::TrustedScriptURL, + HTML::relevant_global_object(document), + script_url, + TrustedTypes::InjectionSink::Workerconstructor, + TrustedTypes::Script.to_string())); // 2. Let outside settings be the current principal settings object. auto& outside_settings = current_principal_settings_object(); // 3. Parse the scriptURL argument relative to outside settings. - auto url = outside_settings.parse_url(script_url); + auto url = outside_settings.parse_url(compliant_script_url.to_utf8_but_should_be_ported_to_utf16()); // 4. If this fails, throw a "SyntaxError" DOMException. if (!url.has_value()) { - dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Invalid URL loaded '{}'.", script_url); + dbgln_if(WEB_WORKER_DEBUG, "WebWorker: Invalid URL loaded '{}'.", compliant_script_url); return WebIDL::SyntaxError::create(document.realm(), "url is not valid"_utf16); } // 5. Let worker URL be the resulting URL record. // 6. Let worker be a new Worker object. - auto worker = document.realm().create(script_url, options, document); + auto worker = document.realm().create(compliant_script_url.to_utf8_but_should_be_ported_to_utf16(), options, document); // 7. Let outside port be a new MessagePort in outside settings's Realm. auto outside_port = MessagePort::create(outside_settings.realm()); diff --git a/Libraries/LibWeb/HTML/Worker.h b/Libraries/LibWeb/HTML/Worker.h index 1570b1d0d99..b9ddad05f73 100644 --- a/Libraries/LibWeb/HTML/Worker.h +++ b/Libraries/LibWeb/HTML/Worker.h @@ -26,8 +26,8 @@ class Worker GC_DECLARE_ALLOCATOR(Worker); public: - static WebIDL::ExceptionOr> create(String const& script_url, WorkerOptions const& options, DOM::Document& document); - static WebIDL::ExceptionOr> construct_impl(JS::Realm& realm, String const& script_url, WorkerOptions const& options) + static WebIDL::ExceptionOr> create(TrustedTypes::TrustedScriptURLOrString const& script_url, WorkerOptions const& options, DOM::Document& document); + static WebIDL::ExceptionOr> construct_impl(JS::Realm& realm, TrustedTypes::TrustedScriptURLOrString const& script_url, WorkerOptions const& options) { auto& window = as(realm.global_object()); return Worker::create(script_url, options, window.associated_document()); diff --git a/Libraries/LibWeb/HTML/Worker.idl b/Libraries/LibWeb/HTML/Worker.idl index 83d4207c17c..962de387541 100644 --- a/Libraries/LibWeb/HTML/Worker.idl +++ b/Libraries/LibWeb/HTML/Worker.idl @@ -3,12 +3,12 @@ #import #import #import +#import // https://html.spec.whatwg.org/multipage/workers.html#worker [Exposed=(Window,DedicatedWorker,SharedWorker)] interface Worker : EventTarget { - // FIXME: "DOMString scriptURL" should be "(TrustedScriptURL or USVString) scriptURL". - constructor(DOMString scriptURL, optional WorkerOptions options = {}); + constructor((TrustedScriptURL or Utf16USVString) scriptURL, optional WorkerOptions options = {}); undefined terminate(); undefined postMessage(any message, sequence transfer); diff --git a/Libraries/LibWeb/Layout/FormattingContext.cpp b/Libraries/LibWeb/Layout/FormattingContext.cpp index 09349a61c4e..0f2ad4eb694 100644 --- a/Libraries/LibWeb/Layout/FormattingContext.cpp +++ b/Libraries/LibWeb/Layout/FormattingContext.cpp @@ -1827,7 +1827,10 @@ CSSPixels FormattingContext::box_baseline(Box const& box) const } } - if (!box_state.line_boxes.is_empty()) + auto const& overflow_x = box.computed_values().overflow_x(); + auto const& overflow_y = box.computed_values().overflow_y(); + + if (!box_state.line_boxes.is_empty() && overflow_x == CSS::Overflow::Visible && overflow_y == CSS::Overflow::Visible) return box_state.margin_box_top() + box_state.offset.y() + box_state.line_boxes.last().baseline(); if (auto const* child_box = box_child_to_derive_baseline_from(box)) { return box_state.margin_box_top() + box_state.offset.y() + box_baseline(*child_box); diff --git a/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.cpp b/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.cpp index bf92d8aed5d..29c16af8bed 100644 --- a/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.cpp +++ b/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.cpp @@ -18,6 +18,9 @@ #include #include #include +#include +#include +#include namespace Web::ServiceWorker { @@ -49,7 +52,7 @@ GC::Ref ServiceWorkerContainer::create(JS::Realm& realm) } // https://w3c.github.io/ServiceWorker/#navigator-service-worker-register -GC::Ref ServiceWorkerContainer::register_(String script_url, RegistrationOptions const& options) +GC::Ref ServiceWorkerContainer::register_(TrustedTypes::TrustedScriptURLOrString script_url, RegistrationOptions const& options) { auto& realm = this->realm(); // Note: The register(scriptURL, options) method creates or updates a service worker registration for the given scope url. @@ -59,15 +62,21 @@ GC::Ref ServiceWorkerContainer::register_(String script_url, Re // 1. Let p be a promise. auto p = WebIDL::create_promise(realm); - // FIXME: 2. Set scriptURL to the result of invoking Get Trusted Type compliant string with TrustedScriptURL, + // 2. Set scriptURL to the result of invoking Get Trusted Type compliant string with TrustedScriptURL, // this's relevant global object, scriptURL, "ServiceWorkerContainer register", and "script". + auto const compliant_script_url = MUST(TrustedTypes::get_trusted_type_compliant_string( + TrustedTypes::TrustedTypeName::TrustedScriptURL, + HTML::relevant_global_object(*this), + script_url, + TrustedTypes::InjectionSink::ServiceWorkerContainerregister, + TrustedTypes::Script.to_string())); // 3 Let client be this's service worker client. auto client = m_service_worker_client; // 4. Let scriptURL be the result of parsing scriptURL with this's relevant settings object’s API base URL. auto base_url = HTML::relevant_settings_object(*this).api_base_url(); - auto parsed_script_url = DOMURL::parse(script_url, base_url); + auto parsed_script_url = DOMURL::parse(compliant_script_url.to_utf8_but_should_be_ported_to_utf16(), base_url); // 5. Let scopeURL be null. Optional scope_url; diff --git a/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.h b/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.h index ff204b2bee9..18212a7fab2 100644 --- a/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.h +++ b/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.h @@ -10,6 +10,8 @@ #include #include #include +#include +#include #include #include @@ -34,7 +36,7 @@ public: [[nodiscard]] static GC::Ref create(JS::Realm& realm); virtual ~ServiceWorkerContainer() override; - GC::Ref register_(String script_url, RegistrationOptions const& options); + GC::Ref register_(TrustedTypes::TrustedScriptURLOrString script_url, RegistrationOptions const& options); GC::Ref get_registration(String const& client_url); diff --git a/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.idl b/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.idl index cb14114aa01..5835df2db63 100644 --- a/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.idl +++ b/Libraries/LibWeb/ServiceWorker/ServiceWorkerContainer.idl @@ -2,6 +2,7 @@ #import #import #import +#import // https://w3c.github.io/ServiceWorker/#serviceworkercontainer-interface [SecureContext, Exposed=(Window,Worker)] @@ -9,8 +10,7 @@ interface ServiceWorkerContainer : EventTarget { [FIXME] readonly attribute ServiceWorker? controller; [FIXME] readonly attribute Promise ready; - // FIXME: [NewObject] Promise register((TrustedScriptURL or USVString) scriptURL, optional RegistrationOptions options = {}); - [NewObject, ImplementedAs=register_] Promise register(USVString scriptURL, optional RegistrationOptions options = {}); + [NewObject, ImplementedAs=register_] Promise register((TrustedScriptURL or Utf16USVString) scriptURL, optional RegistrationOptions options = {}); [NewObject] Promise<(ServiceWorkerRegistration or undefined)> getRegistration(optional USVString clientURL = ""); [FIXME, NewObject] Promise> getRegistrations(); diff --git a/Libraries/LibWeb/TrustedTypes/InjectionSink.h b/Libraries/LibWeb/TrustedTypes/InjectionSink.h index 0b918a66a37..75441b115cb 100644 --- a/Libraries/LibWeb/TrustedTypes/InjectionSink.h +++ b/Libraries/LibWeb/TrustedTypes/InjectionSink.h @@ -16,18 +16,23 @@ namespace Web::TrustedTypes { __ENUMERATE_INJECTION_SINKS(Element##attribute_name, "Element " #attribute_name) // https://w3c.github.io/trusted-types/dist/spec/#injection-sink -#define ENUMERATE_INJECTION_SINKS \ - __ENUMERATE_INJECTION_SINKS(Documentwrite, "Document write") \ - __ENUMERATE_INJECTION_SINKS(Documentwriteln, "Document writeln") \ - __ENUMERATE_INJECTION_SINKS(Function, "Function") \ - __ENUMERATE_INJECTION_SINKS(HTMLIFrameElementsrcdoc, "HTMLIFrameElement srcdoc") \ - __ENUMERATE_INJECTION_SINKS(HTMLScriptElementinnerText, "HTMLScriptElement innerText") \ - __ENUMERATE_INJECTION_SINKS(HTMLScriptElementsrc, "HTMLScriptElement src") \ - __ENUMERATE_INJECTION_SINKS(HTMLScriptElementtext, "HTMLScriptElement text") \ - __ENUMERATE_INJECTION_SINKS(HTMLScriptElementtextContent, "HTMLScriptElement textContent") \ - __ENUMERATE_INJECTION_SINKS(Locationhref, "Location href") \ - __ENUMERATE_INJECTION_SINKS(SVGScriptElementhref, "SVGScriptElement href") \ - ENUMERATE_GLOBAL_EVENT_HANDLERS(EVENT_HANDLERS_INJECTION_SINKS) \ +#define ENUMERATE_INJECTION_SINKS \ + __ENUMERATE_INJECTION_SINKS(Documentwrite, "Document write") \ + __ENUMERATE_INJECTION_SINKS(Documentwriteln, "Document writeln") \ + __ENUMERATE_INJECTION_SINKS(DocumentexecCommand, "Document execCommand") \ + __ENUMERATE_INJECTION_SINKS(Function, "Function") \ + __ENUMERATE_INJECTION_SINKS(HTMLIFrameElementsrcdoc, "HTMLIFrameElement srcdoc") \ + __ENUMERATE_INJECTION_SINKS(HTMLScriptElementinnerText, "HTMLScriptElement innerText") \ + __ENUMERATE_INJECTION_SINKS(HTMLScriptElementsrc, "HTMLScriptElement src") \ + __ENUMERATE_INJECTION_SINKS(HTMLScriptElementtext, "HTMLScriptElement text") \ + __ENUMERATE_INJECTION_SINKS(HTMLScriptElementtextContent, "HTMLScriptElement textContent") \ + __ENUMERATE_INJECTION_SINKS(Locationhref, "Location href") \ + __ENUMERATE_INJECTION_SINKS(RangecreateContextualFragment, "Range createContextualFragment") \ + __ENUMERATE_INJECTION_SINKS(ServiceWorkerContainerregister, "ServiceWorkerContainer register") \ + __ENUMERATE_INJECTION_SINKS(SharedWorkerconstructor, "SharedWorker constructor") \ + __ENUMERATE_INJECTION_SINKS(SVGScriptElementhref, "SVGScriptElement href") \ + __ENUMERATE_INJECTION_SINKS(Workerconstructor, "Worker constructor") \ + ENUMERATE_GLOBAL_EVENT_HANDLERS(EVENT_HANDLERS_INJECTION_SINKS) \ ENUMERATE_WINDOW_EVENT_HANDLERS(EVENT_HANDLERS_INJECTION_SINKS) enum class InjectionSink { diff --git a/Libraries/LibWeb/TrustedTypes/TrustedHTML.h b/Libraries/LibWeb/TrustedTypes/TrustedHTML.h index 11d2f762b56..4994b60b3d3 100644 --- a/Libraries/LibWeb/TrustedTypes/TrustedHTML.h +++ b/Libraries/LibWeb/TrustedTypes/TrustedHTML.h @@ -12,6 +12,8 @@ namespace Web::TrustedTypes { +using TrustedHTMLOrString = Variant, Utf16String>; + class TrustedHTML final : public Bindings::PlatformObject { WEB_PLATFORM_OBJECT(TrustedHTML, Bindings::PlatformObject); GC_DECLARE_ALLOCATOR(TrustedHTML); diff --git a/Tests/LibWeb/Ref/expected/wpt-import/css/css-align/reference/baseline-of-scrollable-1-ref.html b/Tests/LibWeb/Ref/expected/wpt-import/css/css-align/reference/baseline-of-scrollable-1-ref.html new file mode 100644 index 00000000000..422660aff6b --- /dev/null +++ b/Tests/LibWeb/Ref/expected/wpt-import/css/css-align/reference/baseline-of-scrollable-1-ref.html @@ -0,0 +1,58 @@ + + + + + + CSS Reference Case + + + + + + + + Test passes if the a/b text aligns with the bottom margin-edge of the "block" + rect and baseline-aligns with the "flex" and "grid" text. +

+ + + a +
+
block
+
+ b +
+ + a +
flex
+ b +
+ + a +
grid
+ b + + + diff --git a/Tests/LibWeb/Ref/input/wpt-import/css/css-align/baseline-of-scrollable-1a.html b/Tests/LibWeb/Ref/input/wpt-import/css/css-align/baseline-of-scrollable-1a.html new file mode 100644 index 00000000000..5e261991bcc --- /dev/null +++ b/Tests/LibWeb/Ref/input/wpt-import/css/css-align/baseline-of-scrollable-1a.html @@ -0,0 +1,58 @@ + + + + + + CSS Test: baseline of scrollable element should be taken from its + contents. (Except if the scrollable element is an inline-block, which gets + baseline from its margin-box.) + + + + + + + + + Test passes if the a/b text aligns with the bottom margin-edge of the "block" + rect and baseline-aligns with the "flex" and "grid" text. +

+ + + a +
block
+ b +
+ + a +
flex
+ b +
+ + a +
grid
+ b + + + diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.txt index c470ebf7783..a5bac913db2 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/cursor.txt @@ -2,8 +2,8 @@ Harness status: OK Found 69 tests -65 Pass -4 Fail +64 Pass +5 Fail Pass Can set 'cursor' to CSS-wide keywords: initial Pass Can set 'cursor' to CSS-wide keywords: inherit Pass Can set 'cursor' to CSS-wide keywords: unset @@ -67,7 +67,7 @@ Pass Setting 'cursor' to a flexible length: -3.14fr throws TypeError Fail Setting 'cursor' to a number: 0 throws TypeError Fail Setting 'cursor' to a number: -3.14 throws TypeError Fail Setting 'cursor' to a number: 3.14 throws TypeError -Pass Setting 'cursor' to a number: calc(2 + 3) throws TypeError +Fail Setting 'cursor' to a number: calc(2 + 3) throws TypeError Pass Setting 'cursor' to a transform: translate(50%, 50%) throws TypeError Pass Setting 'cursor' to a transform: perspective(10em) throws TypeError Pass Setting 'cursor' to a transform: translate3d(0px, 1px, 2px) translate(0px, 1px) rotate3d(1, 2, 3, 45deg) rotate(45deg) scale3d(1, 2, 3) scale(1, 2) skew(1deg, 1deg) skewX(1deg) skewY(45deg) perspective(1px) matrix3d(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16) matrix(1, 2, 3, 4, 5, 6) throws TypeError diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-height.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-height.txt index b174684e211..9bb899504a7 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-height.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/line-height.txt @@ -2,8 +2,8 @@ Harness status: OK Found 32 tests -26 Pass -6 Fail +29 Pass +3 Fail Pass Can set 'line-height' to CSS-wide keywords: initial Pass Can set 'line-height' to CSS-wide keywords: inherit Pass Can set 'line-height' to CSS-wide keywords: unset @@ -13,15 +13,15 @@ Pass Can set 'line-height' to the 'normal' keyword: normal Pass Can set 'line-height' to a length: 0px Pass Can set 'line-height' to a length: -3.14em Pass Can set 'line-height' to a length: 3.14cm -Fail Can set 'line-height' to a length: calc(0px + 0em) +Pass Can set 'line-height' to a length: calc(0px + 0em) Fail Can set 'line-height' to a number: 0 Fail Can set 'line-height' to a number: -3.14 Pass Can set 'line-height' to a number: 3.14 -Fail Can set 'line-height' to a number: calc(2 + 3) +Pass Can set 'line-height' to a number: calc(2 + 3) Pass Can set 'line-height' to a percent: 0% Pass Can set 'line-height' to a percent: -3.14% Pass Can set 'line-height' to a percent: 3.14% -Fail Can set 'line-height' to a percent: calc(0% + 0%) +Pass Can set 'line-height' to a percent: calc(0% + 0%) Pass Setting 'line-height' to a time: 0s throws TypeError Pass Setting 'line-height' to a time: -3.14ms throws TypeError Pass Setting 'line-height' to a time: 3.14s throws TypeError diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/margin.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/margin.txt index 970023a0b94..43b1c54d91f 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/margin.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/margin.txt @@ -2,8 +2,8 @@ Harness status: OK Found 161 tests -144 Pass -17 Fail +152 Pass +9 Fail Pass Can set 'margin-top' to CSS-wide keywords: initial Pass Can set 'margin-top' to CSS-wide keywords: inherit Pass Can set 'margin-top' to CSS-wide keywords: unset @@ -13,11 +13,11 @@ Pass Can set 'margin-top' to the 'auto' keyword: auto Pass Can set 'margin-top' to a percent: 0% Pass Can set 'margin-top' to a percent: -3.14% Pass Can set 'margin-top' to a percent: 3.14% -Fail Can set 'margin-top' to a percent: calc(0% + 0%) +Pass Can set 'margin-top' to a percent: calc(0% + 0%) Pass Can set 'margin-top' to a length: 0px Pass Can set 'margin-top' to a length: -3.14em Pass Can set 'margin-top' to a length: 3.14cm -Fail Can set 'margin-top' to a length: calc(0px + 0em) +Pass Can set 'margin-top' to a length: calc(0px + 0em) Pass Setting 'margin-top' to a time: 0s throws TypeError Pass Setting 'margin-top' to a time: -3.14ms throws TypeError Pass Setting 'margin-top' to a time: 3.14s throws TypeError @@ -45,11 +45,11 @@ Pass Can set 'margin-left' to the 'auto' keyword: auto Pass Can set 'margin-left' to a percent: 0% Pass Can set 'margin-left' to a percent: -3.14% Pass Can set 'margin-left' to a percent: 3.14% -Fail Can set 'margin-left' to a percent: calc(0% + 0%) +Pass Can set 'margin-left' to a percent: calc(0% + 0%) Pass Can set 'margin-left' to a length: 0px Pass Can set 'margin-left' to a length: -3.14em Pass Can set 'margin-left' to a length: 3.14cm -Fail Can set 'margin-left' to a length: calc(0px + 0em) +Pass Can set 'margin-left' to a length: calc(0px + 0em) Pass Setting 'margin-left' to a time: 0s throws TypeError Pass Setting 'margin-left' to a time: -3.14ms throws TypeError Pass Setting 'margin-left' to a time: 3.14s throws TypeError @@ -77,11 +77,11 @@ Pass Can set 'margin-right' to the 'auto' keyword: auto Pass Can set 'margin-right' to a percent: 0% Pass Can set 'margin-right' to a percent: -3.14% Pass Can set 'margin-right' to a percent: 3.14% -Fail Can set 'margin-right' to a percent: calc(0% + 0%) +Pass Can set 'margin-right' to a percent: calc(0% + 0%) Pass Can set 'margin-right' to a length: 0px Pass Can set 'margin-right' to a length: -3.14em Pass Can set 'margin-right' to a length: 3.14cm -Fail Can set 'margin-right' to a length: calc(0px + 0em) +Pass Can set 'margin-right' to a length: calc(0px + 0em) Pass Setting 'margin-right' to a time: 0s throws TypeError Pass Setting 'margin-right' to a time: -3.14ms throws TypeError Pass Setting 'margin-right' to a time: 3.14s throws TypeError @@ -109,11 +109,11 @@ Pass Can set 'margin-bottom' to the 'auto' keyword: auto Pass Can set 'margin-bottom' to a percent: 0% Pass Can set 'margin-bottom' to a percent: -3.14% Pass Can set 'margin-bottom' to a percent: 3.14% -Fail Can set 'margin-bottom' to a percent: calc(0% + 0%) +Pass Can set 'margin-bottom' to a percent: calc(0% + 0%) Pass Can set 'margin-bottom' to a length: 0px Pass Can set 'margin-bottom' to a length: -3.14em Pass Can set 'margin-bottom' to a length: 3.14cm -Fail Can set 'margin-bottom' to a length: calc(0px + 0em) +Pass Can set 'margin-bottom' to a length: calc(0px + 0em) Pass Setting 'margin-bottom' to a time: 0s throws TypeError Pass Setting 'margin-bottom' to a time: -3.14ms throws TypeError Pass Setting 'margin-bottom' to a time: 3.14s throws TypeError diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.txt index d6f23caf47a..9f1753fef63 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/padding.txt @@ -2,8 +2,8 @@ Harness status: OK Found 124 tests -108 Pass -16 Fail +116 Pass +8 Fail Pass Can set 'padding-top' to CSS-wide keywords: initial Pass Can set 'padding-top' to CSS-wide keywords: inherit Pass Can set 'padding-top' to CSS-wide keywords: unset @@ -12,11 +12,11 @@ Fail Can set 'padding-top' to var() references: var(--A) Pass Can set 'padding-top' to a percent: 0% Fail Can set 'padding-top' to a percent: -3.14% Pass Can set 'padding-top' to a percent: 3.14% -Fail Can set 'padding-top' to a percent: calc(0% + 0%) +Pass Can set 'padding-top' to a percent: calc(0% + 0%) Pass Can set 'padding-top' to a length: 0px Pass Can set 'padding-top' to a length: -3.14em Pass Can set 'padding-top' to a length: 3.14cm -Fail Can set 'padding-top' to a length: calc(0px + 0em) +Pass Can set 'padding-top' to a length: calc(0px + 0em) Pass Setting 'padding-top' to a time: 0s throws TypeError Pass Setting 'padding-top' to a time: -3.14ms throws TypeError Pass Setting 'padding-top' to a time: 3.14s throws TypeError @@ -43,11 +43,11 @@ Fail Can set 'padding-left' to var() references: var(--A) Pass Can set 'padding-left' to a percent: 0% Fail Can set 'padding-left' to a percent: -3.14% Pass Can set 'padding-left' to a percent: 3.14% -Fail Can set 'padding-left' to a percent: calc(0% + 0%) +Pass Can set 'padding-left' to a percent: calc(0% + 0%) Pass Can set 'padding-left' to a length: 0px Pass Can set 'padding-left' to a length: -3.14em Pass Can set 'padding-left' to a length: 3.14cm -Fail Can set 'padding-left' to a length: calc(0px + 0em) +Pass Can set 'padding-left' to a length: calc(0px + 0em) Pass Setting 'padding-left' to a time: 0s throws TypeError Pass Setting 'padding-left' to a time: -3.14ms throws TypeError Pass Setting 'padding-left' to a time: 3.14s throws TypeError @@ -74,11 +74,11 @@ Fail Can set 'padding-right' to var() references: var(--A) Pass Can set 'padding-right' to a percent: 0% Fail Can set 'padding-right' to a percent: -3.14% Pass Can set 'padding-right' to a percent: 3.14% -Fail Can set 'padding-right' to a percent: calc(0% + 0%) +Pass Can set 'padding-right' to a percent: calc(0% + 0%) Pass Can set 'padding-right' to a length: 0px Pass Can set 'padding-right' to a length: -3.14em Pass Can set 'padding-right' to a length: 3.14cm -Fail Can set 'padding-right' to a length: calc(0px + 0em) +Pass Can set 'padding-right' to a length: calc(0px + 0em) Pass Setting 'padding-right' to a time: 0s throws TypeError Pass Setting 'padding-right' to a time: -3.14ms throws TypeError Pass Setting 'padding-right' to a time: 3.14s throws TypeError @@ -105,11 +105,11 @@ Fail Can set 'padding-bottom' to var() references: var(--A) Pass Can set 'padding-bottom' to a percent: 0% Fail Can set 'padding-bottom' to a percent: -3.14% Pass Can set 'padding-bottom' to a percent: 3.14% -Fail Can set 'padding-bottom' to a percent: calc(0% + 0%) +Pass Can set 'padding-bottom' to a percent: calc(0% + 0%) Pass Can set 'padding-bottom' to a length: 0px Pass Can set 'padding-bottom' to a length: -3.14em Pass Can set 'padding-bottom' to a length: 3.14cm -Fail Can set 'padding-bottom' to a length: calc(0px + 0em) +Pass Can set 'padding-bottom' to a length: calc(0px + 0em) Pass Setting 'padding-bottom' to a time: 0s throws TypeError Pass Setting 'padding-bottom' to a time: -3.14ms throws TypeError Pass Setting 'padding-bottom' to a time: 3.14s throws TypeError diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/width.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/width.txt index 04cbc101f48..8b744fd78e9 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/width.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-typed-om/the-stylepropertymap/properties/width.txt @@ -2,8 +2,8 @@ Harness status: OK Found 95 tests -83 Pass -12 Fail +89 Pass +6 Fail Pass Can set 'width' to CSS-wide keywords: initial Pass Can set 'width' to CSS-wide keywords: inherit Pass Can set 'width' to CSS-wide keywords: unset @@ -13,11 +13,11 @@ Pass Can set 'width' to the 'auto' keyword: auto Pass Can set 'width' to a percent: 0% Fail Can set 'width' to a percent: -3.14% Pass Can set 'width' to a percent: 3.14% -Fail Can set 'width' to a percent: calc(0% + 0%) +Pass Can set 'width' to a percent: calc(0% + 0%) Pass Can set 'width' to a length: 0px Pass Can set 'width' to a length: -3.14em Pass Can set 'width' to a length: 3.14cm -Fail Can set 'width' to a length: calc(0px + 0em) +Pass Can set 'width' to a length: calc(0px + 0em) Pass Setting 'width' to a time: 0s throws TypeError Pass Setting 'width' to a time: -3.14ms throws TypeError Pass Setting 'width' to a time: 3.14s throws TypeError @@ -44,11 +44,11 @@ Fail Can set 'min-width' to var() references: var(--A) Pass Can set 'min-width' to a percent: 0% Fail Can set 'min-width' to a percent: -3.14% Pass Can set 'min-width' to a percent: 3.14% -Fail Can set 'min-width' to a percent: calc(0% + 0%) +Pass Can set 'min-width' to a percent: calc(0% + 0%) Pass Can set 'min-width' to a length: 0px Pass Can set 'min-width' to a length: -3.14em Pass Can set 'min-width' to a length: 3.14cm -Fail Can set 'min-width' to a length: calc(0px + 0em) +Pass Can set 'min-width' to a length: calc(0px + 0em) Pass Setting 'min-width' to a time: 0s throws TypeError Pass Setting 'min-width' to a time: -3.14ms throws TypeError Pass Setting 'min-width' to a time: 3.14s throws TypeError @@ -76,11 +76,11 @@ Pass Can set 'max-width' to the 'none' keyword: none Pass Can set 'max-width' to a percent: 0% Fail Can set 'max-width' to a percent: -3.14% Pass Can set 'max-width' to a percent: 3.14% -Fail Can set 'max-width' to a percent: calc(0% + 0%) +Pass Can set 'max-width' to a percent: calc(0% + 0%) Pass Can set 'max-width' to a length: 0px Pass Can set 'max-width' to a length: -3.14em Pass Can set 'max-width' to a length: 3.14cm -Fail Can set 'max-width' to a length: calc(0px + 0em) +Pass Can set 'max-width' to a length: calc(0px + 0em) Pass Setting 'max-width' to a time: 0s throws TypeError Pass Setting 'max-width' to a time: -3.14ms throws TypeError Pass Setting 'max-width' to a time: 3.14s throws TypeError diff --git a/Tests/LibWeb/Text/expected/wpt-import/css/css-values/typed_arithmetic.txt b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/typed_arithmetic.txt index a1ff3508bcf..2395f220209 100644 --- a/Tests/LibWeb/Text/expected/wpt-import/css/css-values/typed_arithmetic.txt +++ b/Tests/LibWeb/Text/expected/wpt-import/css/css-values/typed_arithmetic.txt @@ -1,8 +1,8 @@ Harness status: OK -Found 25 tests +Found 35 tests -19 Pass +29 Pass 6 Fail Pass min(1em, 110px / 10px * 1px) should be used-value-equivalent to 10px Pass max(10px, 110px / 10px * 1px) should be used-value-equivalent to 11px @@ -14,6 +14,16 @@ Pass calc(10em / 1em) should be used-value-equivalent to 10 Pass calc(10em / 1rem) should be used-value-equivalent to 10 Pass calc(10em / 1px) should be used-value-equivalent to 100 Pass calc(1px / 10em * NaN) should be used-value-equivalent to 0 +Pass calc(10% / 1px) should be used-value-equivalent to 1 +Pass calc(1% * 100% / 10%) should be used-value-equivalent to 10% +Pass calc(10% / 10%) should be used-value-equivalent to 1 +Pass calc((10% * 1%) / 1px) should be used-value-equivalent to 10px +Pass calc(10% * 10% / 1px * 10deg / 1deg / 10px) should be used-value-equivalent to 1 +Pass calc(10% * 10% / 1px * 1deg / 1deg) should be used-value-equivalent to 1px +Pass calc(1px * 2deg / 1deg) should be used-value-equivalent to 2px +Pass calc(1px * 3deg / 1deg / 1px) should be used-value-equivalent to 3 +Pass e.style['width'] = "calc((1% * 1deg) / 1px)" should not set the property value +Pass e.style['width'] = "calc((1% * 1% * 1%) / 1px)" should not set the property value Pass Property width value 'calc(1px * 10em / 0em)' Pass Property width value 'calc(1px / 1px * 10em * infinity)' Fail Property margin-left value 'calc(1px * 10em / -0em)' diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/DedicatedWorker-constructor.https.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/DedicatedWorker-constructor.https.txt new file mode 100644 index 00000000000..f85ce6e47fa --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/DedicatedWorker-constructor.https.txt @@ -0,0 +1,8 @@ +Harness status: OK + +Found 3 tests + +3 Pass +Pass Create Worker via ScriptTestUrl +Pass Block Worker creation via string +Pass Create Worker via string with default policy. \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/Range-createContextualFragment.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/Range-createContextualFragment.txt new file mode 100644 index 00000000000..351b40b00cd --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/Range-createContextualFragment.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass range.createContextualFragment assigned via policy (successful HTML transformation). \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/SharedWorker-constructor.https.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/SharedWorker-constructor.https.txt new file mode 100644 index 00000000000..2b2178b94bf --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/SharedWorker-constructor.https.txt @@ -0,0 +1,8 @@ +Harness status: OK + +Found 3 tests + +3 Pass +Pass Create SharedWorker via ScriptTestUrl +Pass Block SharedWorker creation via string +Pass Create SharedWorker via string with default policy. \ No newline at end of file diff --git a/Tests/LibWeb/Text/expected/wpt-import/trusted-types/block-string-assignment-to-Range-createContextualFragment.txt b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/block-string-assignment-to-Range-createContextualFragment.txt new file mode 100644 index 00000000000..00f535fbe75 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/trusted-types/block-string-assignment-to-Range-createContextualFragment.txt @@ -0,0 +1,10 @@ +Harness status: OK + +Found 5 tests + +5 Pass +Pass range.createContextualFragment assigned via policy (successful HTML transformation). +Pass `range.createContextualFragment(string)` throws. +Pass `range.createContextualFragment(null)` throws. +Pass `range.createContextualFragment(string)` assigned via default policy (successful HTML transformation). +Pass `range.createContextualFragment(null)` assigned via default policy does not throw. \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/css/css-values/typed_arithmetic.html b/Tests/LibWeb/Text/input/wpt-import/css/css-values/typed_arithmetic.html index b849cccdb84..7d5c88588c5 100644 --- a/Tests/LibWeb/Text/input/wpt-import/css/css-values/typed_arithmetic.html +++ b/Tests/LibWeb/Text/input/wpt-import/css/css-values/typed_arithmetic.html @@ -5,6 +5,7 @@ +