Revert "LibWeb/CSS: Rename CalculatedStyleValue -> CSSMathValue"

This reverts commit 76daba3069.

We're going to need separate types for the JS-exposed style values, so
it doesn't make sense for us to match their names with our internal
types.
This commit is contained in:
Sam Atkins 2024-12-11 15:05:56 +00:00 committed by Andreas Kling
commit 69a0f28d04
Notes: github-actions[bot] 2024-12-21 17:15:55 +00:00
37 changed files with 391 additions and 391 deletions

View file

@ -1913,7 +1913,7 @@ RefPtr<CustomIdentStyleValue> Parser::parse_custom_ident_value(TokenStream<Compo
return CustomIdentStyleValue::create(custom_ident);
}
RefPtr<CSSMathValue> Parser::parse_calculated_value(ComponentValue const& component_value)
RefPtr<CalculatedStyleValue> Parser::parse_calculated_value(ComponentValue const& component_value)
{
if (!component_value.is_function())
return nullptr;
@ -1928,7 +1928,7 @@ RefPtr<CSSMathValue> Parser::parse_calculated_value(ComponentValue const& compon
if (!function_type.has_value())
return nullptr;
return CSSMathValue::create(function_node.release_nonnull(), function_type.release_value());
return CalculatedStyleValue::create(function_node.release_nonnull(), function_type.release_value());
}
OwnPtr<CalculationNode> Parser::parse_a_calc_function_node(Function const& function)
@ -2697,7 +2697,7 @@ RefPtr<CSSStyleValue> Parser::parse_angle_value(TokenStream<ComponentValue>& tok
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_angle()
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_angle())) {
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_angle())) {
transaction.commit();
return dimension_value;
}
@ -2710,7 +2710,7 @@ RefPtr<CSSStyleValue> Parser::parse_angle_percentage_value(TokenStream<Component
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_angle() || dimension_value->is_percentage()
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_angle_percentage())) {
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_angle_percentage())) {
transaction.commit();
return dimension_value;
}
@ -2723,7 +2723,7 @@ RefPtr<CSSStyleValue> Parser::parse_flex_value(TokenStream<ComponentValue>& toke
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_flex()
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_flex())) {
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_flex())) {
transaction.commit();
return dimension_value;
}
@ -2736,7 +2736,7 @@ RefPtr<CSSStyleValue> Parser::parse_frequency_value(TokenStream<ComponentValue>&
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_frequency()
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_frequency())) {
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_frequency())) {
transaction.commit();
return dimension_value;
}
@ -2749,7 +2749,7 @@ RefPtr<CSSStyleValue> Parser::parse_frequency_percentage_value(TokenStream<Compo
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_frequency() || dimension_value->is_percentage()
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_frequency_percentage())) {
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_frequency_percentage())) {
transaction.commit();
return dimension_value;
}
@ -2762,7 +2762,7 @@ RefPtr<CSSStyleValue> Parser::parse_length_value(TokenStream<ComponentValue>& to
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_length()
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_length())) {
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_length())) {
transaction.commit();
return dimension_value;
}
@ -2775,7 +2775,7 @@ RefPtr<CSSStyleValue> Parser::parse_length_percentage_value(TokenStream<Componen
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_length() || dimension_value->is_percentage()
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_length_percentage())) {
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_length_percentage())) {
transaction.commit();
return dimension_value;
}
@ -2788,7 +2788,7 @@ RefPtr<CSSStyleValue> Parser::parse_resolution_value(TokenStream<ComponentValue>
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_resolution()
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_resolution())) {
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_resolution())) {
transaction.commit();
return dimension_value;
}
@ -2801,7 +2801,7 @@ RefPtr<CSSStyleValue> Parser::parse_time_value(TokenStream<ComponentValue>& toke
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_time()
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_time())) {
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_time())) {
transaction.commit();
return dimension_value;
}
@ -2814,7 +2814,7 @@ RefPtr<CSSStyleValue> Parser::parse_time_percentage_value(TokenStream<ComponentV
auto transaction = tokens.begin_transaction();
if (auto dimension_value = parse_dimension_value(tokens)) {
if (dimension_value->is_time() || dimension_value->is_percentage()
|| (dimension_value->is_math() && dimension_value->as_math().resolves_to_time_percentage())) {
|| (dimension_value->is_calculated() && dimension_value->as_calculated().resolves_to_time_percentage())) {
transaction.commit();
return dimension_value;
}
@ -3052,7 +3052,7 @@ RefPtr<CSSStyleValue> Parser::parse_rgb_color_value(TokenStream<ComponentValue>&
// Verify we're all percentages or all numbers
auto is_percentage = [](CSSStyleValue const& style_value) {
return style_value.is_percentage()
|| (style_value.is_math() && style_value.as_math().resolves_to_percentage());
|| (style_value.is_calculated() && style_value.as_calculated().resolves_to_percentage());
};
bool red_is_percentage = is_percentage(*red);
bool green_is_percentage = is_percentage(*green);
@ -4513,8 +4513,8 @@ static Optional<LengthPercentage> style_value_to_length_percentage(auto value)
return LengthPercentage { value->as_percentage().percentage() };
if (value->is_length())
return LengthPercentage { value->as_length().length() };
if (value->is_math())
return LengthPercentage { value->as_math() };
if (value->is_calculated())
return LengthPercentage { value->as_calculated() };
return {};
}
@ -4644,8 +4644,8 @@ RefPtr<CSSStyleValue> Parser::parse_single_background_size_value(TokenStream<Com
return LengthPercentage { style_value.as_percentage().percentage() };
if (style_value.is_length())
return LengthPercentage { style_value.as_length().length() };
if (style_value.is_math())
return LengthPercentage { style_value.as_math() };
if (style_value.is_calculated())
return LengthPercentage { style_value.as_calculated() };
return {};
};
@ -7179,7 +7179,7 @@ RefPtr<CSSStyleValue> Parser::parse_transform_value(TokenStream<ComponentValue>&
argument_tokens.discard_whitespace();
auto const& value = argument_tokens.consume_a_token();
RefPtr<CSSMathValue> maybe_calc_value = parse_calculated_value(value);
RefPtr<CalculatedStyleValue> maybe_calc_value = parse_calculated_value(value);
switch (function_metadata.parameters[argument_index].type) {
case TransformFunctionParameterType::Angle: {
@ -7319,8 +7319,8 @@ RefPtr<CSSStyleValue> Parser::parse_transform_origin_value(TokenStream<Component
return OptionalNone {};
}
}
if (value->is_math()) {
return AxisOffset { Axis::None, value->as_math() };
if (value->is_calculated()) {
return AxisOffset { Axis::None, value->as_calculated() };
}
return OptionalNone {};
};
@ -9564,9 +9564,9 @@ bool Parser::expand_unresolved_values(DOM::Element& element, FlyString const& pr
}
if (property.has_value()) {
if (auto maybe_calc_value = parse_calculated_value(value); maybe_calc_value && maybe_calc_value->is_math()) {
if (auto maybe_calc_value = parse_calculated_value(value); maybe_calc_value && maybe_calc_value->is_calculated()) {
// FIXME: Run the actual simplification algorithm
auto& calc_value = maybe_calc_value->as_math();
auto& calc_value = maybe_calc_value->as_calculated();
if (property_accepts_type(*property, ValueType::Angle) && calc_value.resolves_to_angle()) {
auto resolved_value = calc_value.resolve_angle();
dest.empend(Token::create_dimension(resolved_value->to_degrees(), "deg"_fly_string));