From eec4365542b5d7bb90d2414f985cba0683f041ee Mon Sep 17 00:00:00 2001 From: Sam Atkins Date: Fri, 16 May 2025 19:20:24 +0100 Subject: [PATCH] LibWeb/CSS: Extract SerializationMode into its own header Prep for using this to serialize dimension types, and perhaps other things in the future. --- .../LibWeb/Animations/KeyframeEffect.cpp | 4 ++-- Libraries/LibWeb/CSS/CSSDescriptors.cpp | 4 ++-- Libraries/LibWeb/CSS/CSSFontFaceRule.cpp | 14 +++++------ Libraries/LibWeb/CSS/CSSPropertyRule.cpp | 2 +- Libraries/LibWeb/CSS/CSSStyleProperties.cpp | 12 +++++----- Libraries/LibWeb/CSS/CSSStyleValue.h | 7 ++---- Libraries/LibWeb/CSS/CalculatedOr.h | 2 +- Libraries/LibWeb/CSS/ComputedProperties.cpp | 24 +++++++++---------- Libraries/LibWeb/CSS/FontFace.cpp | 24 +++++++++---------- Libraries/LibWeb/CSS/Interpolation.cpp | 2 +- Libraries/LibWeb/CSS/MediaQuery.cpp | 2 +- Libraries/LibWeb/CSS/Parser/ValueParsing.cpp | 2 +- Libraries/LibWeb/CSS/PercentageOr.h | 2 +- Libraries/LibWeb/CSS/SerializationMode.h | 16 +++++++++++++ Libraries/LibWeb/CSS/StyleComputer.cpp | 10 ++++---- .../CSS/StyleValues/AbstractImageStyleValue.h | 2 +- .../CSS/StyleValues/BasicShapeStyleValue.cpp | 12 +++++----- .../CSS/StyleValues/BasicShapeStyleValue.h | 12 +++++----- .../CSS/StyleValues/CalculatedStyleValue.cpp | 8 +++---- .../CSS/StyleValues/CounterStyleValue.cpp | 2 +- .../LibWeb/CSS/StyleValues/EdgeStyleValue.cpp | 2 +- Libraries/LibWeb/Dump.cpp | 8 +++---- .../LibWeb/Editing/Internal/Algorithms.cpp | 12 +++++----- .../HTML/Canvas/CanvasTextDrawingStyles.h | 8 +++---- Services/WebContent/ConnectionFromClient.cpp | 16 ++++++------- Services/WebContent/WebDriverConnection.cpp | 2 +- 26 files changed, 112 insertions(+), 99 deletions(-) create mode 100644 Libraries/LibWeb/CSS/SerializationMode.h diff --git a/Libraries/LibWeb/Animations/KeyframeEffect.cpp b/Libraries/LibWeb/Animations/KeyframeEffect.cpp index 1dc16f06e32..47d0e88d0b6 100644 --- a/Libraries/LibWeb/Animations/KeyframeEffect.cpp +++ b/Libraries/LibWeb/Animations/KeyframeEffect.cpp @@ -813,7 +813,7 @@ WebIDL::ExceptionOr> KeyframeEffect::get_keyframes() TRY(object->set(vm.names.offset, keyframe.offset.has_value() ? JS::Value(keyframe.offset.value()) : JS::js_null(), ShouldThrowExceptions::Yes)); TRY(object->set(vm.names.computedOffset, JS::Value(keyframe.computed_offset.value()), ShouldThrowExceptions::Yes)); auto easing_value = keyframe.easing.get>(); - TRY(object->set(vm.names.easing, JS::PrimitiveString::create(vm, easing_value->to_string(CSS::CSSStyleValue::SerializationMode::Normal)), ShouldThrowExceptions::Yes)); + TRY(object->set(vm.names.easing, JS::PrimitiveString::create(vm, easing_value->to_string(CSS::SerializationMode::Normal)), ShouldThrowExceptions::Yes)); if (keyframe.composite == Bindings::CompositeOperationOrAuto::Replace) { TRY(object->set(vm.names.composite, JS::PrimitiveString::create(vm, "replace"sv), ShouldThrowExceptions::Yes)); @@ -826,7 +826,7 @@ WebIDL::ExceptionOr> KeyframeEffect::get_keyframes() } for (auto const& [id, value] : keyframe.parsed_properties()) { - auto value_string = JS::PrimitiveString::create(vm, value->to_string(CSS::CSSStyleValue::SerializationMode::Normal)); + auto value_string = JS::PrimitiveString::create(vm, value->to_string(CSS::SerializationMode::Normal)); TRY(object->set(JS::PropertyKey { CSS::camel_case_string_from_property_id(id), JS::PropertyKey::StringMayBeNumber::No }, value_string, ShouldThrowExceptions::Yes)); } diff --git a/Libraries/LibWeb/CSS/CSSDescriptors.cpp b/Libraries/LibWeb/CSS/CSSDescriptors.cpp index fcadfc28801..aead5b21f5b 100644 --- a/Libraries/LibWeb/CSS/CSSDescriptors.cpp +++ b/Libraries/LibWeb/CSS/CSSDescriptors.cpp @@ -178,7 +178,7 @@ String CSSDescriptors::get_property_value(StringView property) const if (descriptor_id.has_value()) { auto match = m_descriptors.first_matching([descriptor_id](auto& entry) { return entry.descriptor_id == *descriptor_id; }); if (match.has_value()) - return match->value->to_string(CSSStyleValue::SerializationMode::Normal); + return match->value->to_string(SerializationMode::Normal); } // 3. Return the empty string. @@ -215,7 +215,7 @@ String CSSDescriptors::serialized() const // NB: Descriptors can't be shorthands. // 5. Let value be the result of invoking serialize a CSS value of declaration. - auto value = descriptor.value->to_string(CSSStyleValue::SerializationMode::Normal); + auto value = descriptor.value->to_string(SerializationMode::Normal); // 6. Let serialized declaration be the result of invoking serialize a CSS declaration with property name property, value value, and the important flag set if declaration has its important flag set. auto serialized_declaration = serialize_a_css_declaration(property, value, Important::No); diff --git a/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp b/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp index f1e741996fc..a414f1852f6 100644 --- a/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp +++ b/Libraries/LibWeb/CSS/CSSFontFaceRule.cpp @@ -64,7 +64,7 @@ String CSSFontFaceRule::serialized() const builder.append("font-family: "sv); // 3. The result of performing serialize a string on the rule’s font family name. - builder.append(descriptors.descriptor(DescriptorID::FontFamily)->to_string(CSSStyleValue::SerializationMode::Normal)); + builder.append(descriptors.descriptor(DescriptorID::FontFamily)->to_string(SerializationMode::Normal)); // 4. The string ";", i.e., SEMICOLON (U+003B). builder.append(';'); @@ -75,7 +75,7 @@ String CSSFontFaceRule::serialized() const builder.append(" src: "sv); // 2. The result of invoking serialize a comma-separated list on performing serialize a URL or serialize a LOCAL for each source on the source list. - builder.append(sources->to_string(CSSStyleValue::SerializationMode::Normal)); + builder.append(sources->to_string(SerializationMode::Normal)); // 3. The string ";", i.e., SEMICOLON (U+003B). builder.append(';'); @@ -84,7 +84,7 @@ String CSSFontFaceRule::serialized() const // 6. If rule’s associated unicode-range descriptor is present, a single SPACE (U+0020), followed by the string "unicode-range:", followed by a single SPACE (U+0020), followed by the result of performing serialize a <'unicode-range'>, followed by the string ";", i.e., SEMICOLON (U+003B). if (auto unicode_range = descriptors.descriptor(DescriptorID::UnicodeRange)) { builder.append(" unicode-range: "sv); - builder.append(unicode_range->to_string(CSSStyleValue::SerializationMode::Normal)); + builder.append(unicode_range->to_string(SerializationMode::Normal)); builder.append(';'); } @@ -99,7 +99,7 @@ String CSSFontFaceRule::serialized() const // followed by the string ";", i.e., SEMICOLON (U+003B). if (auto font_feature_settings = descriptors.descriptor(DescriptorID::FontFeatureSettings)) { builder.append(" font-feature-settings: "sv); - builder.append(font_feature_settings->to_string(CSSStyleValue::SerializationMode::Normal)); + builder.append(font_feature_settings->to_string(SerializationMode::Normal)); builder.append(";"sv); } @@ -110,7 +110,7 @@ String CSSFontFaceRule::serialized() const // NOTE: font-stretch is now an alias for font-width, so we use that instead. if (auto font_width = descriptors.descriptor(DescriptorID::FontWidth)) { builder.append(" font-stretch: "sv); - builder.append(font_width->to_string(CSSStyleValue::SerializationMode::Normal)); + builder.append(font_width->to_string(SerializationMode::Normal)); builder.append(";"sv); } @@ -120,7 +120,7 @@ String CSSFontFaceRule::serialized() const // followed by the string ";", i.e., SEMICOLON (U+003B). if (auto font_weight = descriptors.descriptor(DescriptorID::FontWeight)) { builder.append(" font-weight: "sv); - builder.append(font_weight->to_string(CSSStyleValue::SerializationMode::Normal)); + builder.append(font_weight->to_string(SerializationMode::Normal)); builder.append(";"sv); } @@ -130,7 +130,7 @@ String CSSFontFaceRule::serialized() const // followed by the string ";", i.e., SEMICOLON (U+003B). if (auto font_style = descriptors.descriptor(DescriptorID::FontStyle)) { builder.append(" font-style: "sv); - builder.append(font_style->to_string(CSSStyleValue::SerializationMode::Normal)); + builder.append(font_style->to_string(SerializationMode::Normal)); builder.append(";"sv); } diff --git a/Libraries/LibWeb/CSS/CSSPropertyRule.cpp b/Libraries/LibWeb/CSS/CSSPropertyRule.cpp index 6cc2377a1dc..ba179345049 100644 --- a/Libraries/LibWeb/CSS/CSSPropertyRule.cpp +++ b/Libraries/LibWeb/CSS/CSSPropertyRule.cpp @@ -30,7 +30,7 @@ CSSPropertyRule::CSSPropertyRule(JS::Realm& realm, FlyString name, FlyString syn Optional CSSPropertyRule::initial_value() const { if (m_initial_value) - return m_initial_value->to_string(CSSStyleValue::SerializationMode::Normal); + return m_initial_value->to_string(SerializationMode::Normal); return {}; } diff --git a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp index 1a23f5da009..79f1e06557b 100644 --- a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp +++ b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp @@ -392,8 +392,8 @@ String CSSStyleProperties::get_property_value(StringView property_name) const auto maybe_custom_property = custom_property(FlyString::from_utf8_without_validation(property_name.bytes())); if (maybe_custom_property.has_value()) { return maybe_custom_property.value().value->to_string( - is_computed() ? CSSStyleValue::SerializationMode::ResolvedValue - : CSSStyleValue::SerializationMode::Normal); + is_computed() ? SerializationMode::ResolvedValue + : SerializationMode::Normal); } return {}; } @@ -402,8 +402,8 @@ String CSSStyleProperties::get_property_value(StringView property_name) const if (!maybe_property.has_value()) return {}; return maybe_property->value->to_string( - is_computed() ? CSSStyleValue::SerializationMode::ResolvedValue - : CSSStyleValue::SerializationMode::Normal); + is_computed() ? SerializationMode::ResolvedValue + : SerializationMode::Normal); } // https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-getpropertypriority @@ -1109,7 +1109,7 @@ String CSSStyleProperties::serialized() const // NB: There are no shorthands for custom properties. // 5. Let value be the result of invoking serialize a CSS value of declaration. - auto value = declaration.value.value->to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal); + auto value = declaration.value.value->to_string(Web::CSS::SerializationMode::Normal); // 6. Let serialized declaration be the result of invoking serialize a CSS declaration with property name property, value value, // and the important flag set if declaration has its important flag set. @@ -1137,7 +1137,7 @@ String CSSStyleProperties::serialized() const // FIXME: 4. Shorthand loop: For each shorthand in shorthands, follow these substeps: ... // 5. Let value be the result of invoking serialize a CSS value of declaration. - auto value = declaration.value->to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal); + auto value = declaration.value->to_string(Web::CSS::SerializationMode::Normal); // 6. Let serialized declaration be the result of invoking serialize a CSS declaration with property name property, value value, // and the important flag set if declaration has its important flag set. diff --git a/Libraries/LibWeb/CSS/CSSStyleValue.h b/Libraries/LibWeb/CSS/CSSStyleValue.h index ac22963ecf7..b402a0287cb 100644 --- a/Libraries/LibWeb/CSS/CSSStyleValue.h +++ b/Libraries/LibWeb/CSS/CSSStyleValue.h @@ -22,6 +22,7 @@ #include #include #include +#include #include namespace Web::CSS { @@ -385,10 +386,6 @@ public: virtual Color to_color(Optional) const { return {}; } Keyword to_keyword() const; - enum class SerializationMode { - Normal, - ResolvedValue, - }; virtual String to_string(SerializationMode) const = 0; [[nodiscard]] int to_font_weight() const; @@ -432,6 +429,6 @@ template<> struct AK::Formatter : Formatter { ErrorOr format(FormatBuilder& builder, Web::CSS::CSSStyleValue const& style_value) { - return Formatter::format(builder, style_value.to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal)); + return Formatter::format(builder, style_value.to_string(Web::CSS::SerializationMode::Normal)); } }; diff --git a/Libraries/LibWeb/CSS/CalculatedOr.h b/Libraries/LibWeb/CSS/CalculatedOr.h index c9872dda092..688537a4a39 100644 --- a/Libraries/LibWeb/CSS/CalculatedOr.h +++ b/Libraries/LibWeb/CSS/CalculatedOr.h @@ -74,7 +74,7 @@ public: } }, [](NonnullRefPtr const& calculated) { - return calculated->to_string(CSSStyleValue::SerializationMode::Normal); + return calculated->to_string(SerializationMode::Normal); }); } diff --git a/Libraries/LibWeb/CSS/ComputedProperties.cpp b/Libraries/LibWeb/CSS/ComputedProperties.cpp index c5f1acea4e0..1e1d53a736b 100644 --- a/Libraries/LibWeb/CSS/ComputedProperties.cpp +++ b/Libraries/LibWeb/CSS/ComputedProperties.cpp @@ -182,7 +182,7 @@ Size ComputedProperties::size_value(PropertyID id) const } // FIXME: Support `fit-content()` - dbgln("FIXME: Unsupported size value: `{}`, treating as `auto`", value.to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("FIXME: Unsupported size value: `{}`, treating as `auto`", value.to_string(SerializationMode::Normal)); return Size::make_auto(); } @@ -310,7 +310,7 @@ CSSPixels ComputedProperties::compute_line_height(CSSPixelRect const& viewport_r if (line_height.as_calculated().resolves_to_number()) { auto resolved = line_height.as_calculated().resolve_number(context); if (!resolved.has_value()) { - dbgln("FIXME: Failed to resolve calc() line-height (number): {}", line_height.as_calculated().to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("FIXME: Failed to resolve calc() line-height (number): {}", line_height.as_calculated().to_string(SerializationMode::Normal)); return CSSPixels::nearest_value_for(m_font_list->first().pixel_metrics().line_spacing()); } return Length(resolved.value(), Length::Type::Em).to_px(viewport_rect, font_metrics, root_font_metrics); @@ -318,7 +318,7 @@ CSSPixels ComputedProperties::compute_line_height(CSSPixelRect const& viewport_r auto resolved = line_height.as_calculated().resolve_length(context); if (!resolved.has_value()) { - dbgln("FIXME: Failed to resolve calc() line-height: {}", line_height.as_calculated().to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("FIXME: Failed to resolve calc() line-height: {}", line_height.as_calculated().to_string(SerializationMode::Normal)); return CSSPixels::nearest_value_for(m_font_list->first().pixel_metrics().line_spacing()); } return resolved->to_px(viewport_rect, font_metrics, root_font_metrics); @@ -358,13 +358,13 @@ float ComputedProperties::resolve_opacity_value(CSSStyleValue const& value) if (maybe_percentage.has_value()) unclamped_opacity = maybe_percentage->as_fraction(); else - dbgln("Unable to resolve calc() as opacity (percentage): {}", value.to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("Unable to resolve calc() as opacity (percentage): {}", value.to_string(SerializationMode::Normal)); } else if (calculated.resolves_to_number()) { auto maybe_number = value.as_calculated().resolve_number(context); if (maybe_number.has_value()) unclamped_opacity = maybe_number.value(); else - dbgln("Unable to resolve calc() as opacity (number): {}", value.to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("Unable to resolve calc() as opacity (number): {}", value.to_string(SerializationMode::Normal)); } } else if (value.is_percentage()) { unclamped_opacity = value.as_percentage().percentage().as_fraction(); @@ -938,14 +938,14 @@ ComputedProperties::ContentDataAndQuoteNestingLevel ComputedProperties::content( quote_nesting_level--; break; default: - dbgln("`{}` is not supported in `content` (yet?)", item->to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("`{}` is not supported in `content` (yet?)", item->to_string(SerializationMode::Normal)); break; } } else if (item->is_counter()) { builder.append(item->as_counter().resolve(element)); } else { // TODO: Implement images, and other things. - dbgln("`{}` is not supported in `content` (yet?)", item->to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("`{}` is not supported in `content` (yet?)", item->to_string(SerializationMode::Normal)); } } content_data.type = ContentData::Type::String; @@ -959,7 +959,7 @@ ComputedProperties::ContentDataAndQuoteNestingLevel ComputedProperties::content( } else if (item->is_counter()) { alt_text_builder.append(item->as_counter().resolve(element)); } else { - dbgln("`{}` is not supported in `content` alt-text (yet?)", item->to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("`{}` is not supported in `content` alt-text (yet?)", item->to_string(SerializationMode::Normal)); } } content_data.alt_text = MUST(alt_text_builder.to_string()); @@ -1048,7 +1048,7 @@ Vector ComputedProperties::text_decoration_line() const return { keyword_to_text_decoration_line(value.to_keyword()).release_value() }; } - dbgln("FIXME: Unsupported value for text-decoration-line: {}", value.to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("FIXME: Unsupported value for text-decoration-line: {}", value.to_string(SerializationMode::Normal)); return {}; } @@ -1686,7 +1686,7 @@ Containment ComputedProperties::contain() const containment.paint_containment = true; break; default: - dbgln("`{}` is not supported in `contain` (yet?)", item->to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("`{}` is not supported in `contain` (yet?)", item->to_string(SerializationMode::Normal)); break; } } @@ -1789,7 +1789,7 @@ Vector ComputedProperties::counter_data(PropertyID property_id) con if (maybe_int.has_value()) data.value = AK::clamp_to(*maybe_int); } else { - dbgln("Unimplemented type for {} integer value: '{}'", string_from_property_id(property_id), counter.value->to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("Unimplemented type for {} integer value: '{}'", string_from_property_id(property_id), counter.value->to_string(SerializationMode::Normal)); } } result.append(move(data)); @@ -1800,7 +1800,7 @@ Vector ComputedProperties::counter_data(PropertyID property_id) con if (value.to_keyword() == Keyword::None) return {}; - dbgln("Unhandled type for {} value: '{}'", string_from_property_id(property_id), value.to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("Unhandled type for {} value: '{}'", string_from_property_id(property_id), value.to_string(SerializationMode::Normal)); return {}; } diff --git a/Libraries/LibWeb/CSS/FontFace.cpp b/Libraries/LibWeb/CSS/FontFace.cpp index dcb67fe4dad..09ae802c17c 100644 --- a/Libraries/LibWeb/CSS/FontFace.cpp +++ b/Libraries/LibWeb/CSS/FontFace.cpp @@ -82,7 +82,7 @@ GC::Ref FontFace::construct_impl(JS::Realm& realm, String family, Font font_face->reject_status_promise(WebIDL::SyntaxError::create(realm, MUST(String::formatted("FontFace constructor: Invalid {}", to_string(descriptor_id))))); return {}; } - return result->to_string(CSSStyleValue::SerializationMode::Normal); + return result->to_string(SerializationMode::Normal); }; font_face->m_family = try_parse_descriptor(DescriptorID::FontFamily, family); font_face->m_style = try_parse_descriptor(DescriptorID::FontStyle, descriptors.style); @@ -224,7 +224,7 @@ WebIDL::ExceptionOr FontFace::set_family(String const& string) // FIXME: Propagate to the CSSFontFaceRule and update the font-family property } - m_family = property->to_string(CSSStyleValue::SerializationMode::Normal); + m_family = property->to_string(SerializationMode::Normal); return {}; } @@ -244,7 +244,7 @@ WebIDL::ExceptionOr FontFace::set_style(String const& string) // FIXME: Propagate to the CSSFontFaceRule and update the font-style property } - m_style = property->to_string(CSSStyleValue::SerializationMode::Normal); + m_style = property->to_string(SerializationMode::Normal); return {}; } @@ -264,7 +264,7 @@ WebIDL::ExceptionOr FontFace::set_weight(String const& string) // FIXME: Propagate to the CSSFontFaceRule and update the font-weight property } - m_weight = property->to_string(CSSStyleValue::SerializationMode::Normal); + m_weight = property->to_string(SerializationMode::Normal); return {}; } @@ -285,7 +285,7 @@ WebIDL::ExceptionOr FontFace::set_stretch(String const& string) // FIXME: Propagate to the CSSFontFaceRule and update the font-width property } - m_stretch = property->to_string(CSSStyleValue::SerializationMode::Normal); + m_stretch = property->to_string(SerializationMode::Normal); return {}; } @@ -305,7 +305,7 @@ WebIDL::ExceptionOr FontFace::set_unicode_range(String const& string) // FIXME: Propagate to the CSSFontFaceRule and update the font-width property } - m_unicode_range = property->to_string(CSSStyleValue::SerializationMode::Normal); + m_unicode_range = property->to_string(SerializationMode::Normal); return {}; } @@ -325,7 +325,7 @@ WebIDL::ExceptionOr FontFace::set_feature_settings(String const& string) // FIXME: Propagate to the CSSFontFaceRule and update the font-width property } - m_feature_settings = property->to_string(CSSStyleValue::SerializationMode::Normal); + m_feature_settings = property->to_string(SerializationMode::Normal); return {}; } @@ -345,7 +345,7 @@ WebIDL::ExceptionOr FontFace::set_variation_settings(String const& string) // FIXME: Propagate to the CSSFontFaceRule and update the font-width property } - m_variation_settings = property->to_string(CSSStyleValue::SerializationMode::Normal); + m_variation_settings = property->to_string(SerializationMode::Normal); return {}; } @@ -365,7 +365,7 @@ WebIDL::ExceptionOr FontFace::set_display(String const& string) // FIXME: Propagate to the CSSFontFaceRule and update the font-width property } - m_display = property->to_string(CSSStyleValue::SerializationMode::Normal); + m_display = property->to_string(SerializationMode::Normal); return {}; } @@ -385,7 +385,7 @@ WebIDL::ExceptionOr FontFace::set_ascent_override(String const& string) // FIXME: Propagate to the CSSFontFaceRule and update the font-width property } - m_ascent_override = property->to_string(CSSStyleValue::SerializationMode::Normal); + m_ascent_override = property->to_string(SerializationMode::Normal); return {}; } @@ -405,7 +405,7 @@ WebIDL::ExceptionOr FontFace::set_descent_override(String const& string) // FIXME: Propagate to the CSSFontFaceRule and update the font-width property } - m_descent_override = property->to_string(CSSStyleValue::SerializationMode::Normal); + m_descent_override = property->to_string(SerializationMode::Normal); return {}; } @@ -425,7 +425,7 @@ WebIDL::ExceptionOr FontFace::set_line_gap_override(String const& string) // FIXME: Propagate to the CSSFontFaceRule and update the font-width property } - m_line_gap_override = property->to_string(CSSStyleValue::SerializationMode::Normal); + m_line_gap_override = property->to_string(SerializationMode::Normal); return {}; } diff --git a/Libraries/LibWeb/CSS/Interpolation.cpp b/Libraries/LibWeb/CSS/Interpolation.cpp index e3bc9f27977..e9530b616af 100644 --- a/Libraries/LibWeb/CSS/Interpolation.cpp +++ b/Libraries/LibWeb/CSS/Interpolation.cpp @@ -270,7 +270,7 @@ RefPtr interpolate_transform(DOM::Element& element, CSSStyl } else if (calculated.resolves_to_number()) { values.append(NumberPercentage { calculated }); } else { - dbgln("Calculation `{}` inside {} transform-function is not a recognized type", calculated.to_string(CSSStyleValue::SerializationMode::Normal), to_string(transformation.transform_function())); + dbgln("Calculation `{}` inside {} transform-function is not a recognized type", calculated.to_string(SerializationMode::Normal), to_string(transformation.transform_function())); return {}; } break; diff --git a/Libraries/LibWeb/CSS/MediaQuery.cpp b/Libraries/LibWeb/CSS/MediaQuery.cpp index 5e3cbb31eb2..801bd865c4a 100644 --- a/Libraries/LibWeb/CSS/MediaQuery.cpp +++ b/Libraries/LibWeb/CSS/MediaQuery.cpp @@ -31,7 +31,7 @@ String MediaFeatureValue::to_string() const [](ResolutionOrCalculated const& resolution) { return resolution.to_string(); }, [](IntegerOrCalculated const& integer) { if (integer.is_calculated()) - return integer.calculated()->to_string(CSSStyleValue::SerializationMode::Normal); + return integer.calculated()->to_string(SerializationMode::Normal); return String::number(integer.value()); }); } diff --git a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp index e9772ad1cd4..0d4dcf673c0 100644 --- a/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp +++ b/Libraries/LibWeb/CSS/Parser/ValueParsing.cpp @@ -1086,7 +1086,7 @@ RefPtr Parser::parse_rect_value(TokenStream if (!maybe_length.has_value()) return nullptr; if (maybe_length.value().is_calculated()) { - dbgln("FIXME: Support calculated lengths in rect(): {}", maybe_length.value().calculated()->to_string(CSS::CSSStyleValue::SerializationMode::Normal)); + dbgln("FIXME: Support calculated lengths in rect(): {}", maybe_length.value().calculated()->to_string(CSS::SerializationMode::Normal)); return nullptr; } params.append(maybe_length.value().value()); diff --git a/Libraries/LibWeb/CSS/PercentageOr.h b/Libraries/LibWeb/CSS/PercentageOr.h index 52be7b8bef2..1c75c04d6ab 100644 --- a/Libraries/LibWeb/CSS/PercentageOr.h +++ b/Libraries/LibWeb/CSS/PercentageOr.h @@ -122,7 +122,7 @@ public: String to_string() const { if (is_calculated()) - return m_value.template get>()->to_string(CSSStyleValue::SerializationMode::Normal); + return m_value.template get>()->to_string(SerializationMode::Normal); if (is_percentage()) return m_value.template get().to_string(); return m_value.template get().to_string(); diff --git a/Libraries/LibWeb/CSS/SerializationMode.h b/Libraries/LibWeb/CSS/SerializationMode.h new file mode 100644 index 00000000000..ff31f3a5ffe --- /dev/null +++ b/Libraries/LibWeb/CSS/SerializationMode.h @@ -0,0 +1,16 @@ +/* + * Copyright (c) 2025, Sam Atkins + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#pragma once + +namespace Web::CSS { + +enum class SerializationMode : u8 { + Normal, + ResolvedValue, +}; + +} diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cpp index 32b0c39be4f..b3e8ad1c248 100644 --- a/Libraries/LibWeb/CSS/StyleComputer.cpp +++ b/Libraries/LibWeb/CSS/StyleComputer.cpp @@ -1248,7 +1248,7 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optionalto_string(CSSStyleValue::SerializationMode::Normal)); + dbgln_if(LIBWEB_CSS_ANIMATION_DEBUG, "No end property for property {}, using {}", string_from_property_id(it.key), resolved_start_property->to_string(SerializationMode::Normal)); } continue; } @@ -1267,11 +1267,11 @@ void StyleComputer::collect_animation_into(DOM::Element& element, Optionaltarget(), it.key, *start, *end, progress_in_keyframe)) { - dbgln_if(LIBWEB_CSS_ANIMATION_DEBUG, "Interpolated value for property {} at {}: {} -> {} = {}", string_from_property_id(it.key), progress_in_keyframe, start->to_string(CSSStyleValue::SerializationMode::Normal), end->to_string(CSSStyleValue::SerializationMode::Normal), next_value->to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln_if(LIBWEB_CSS_ANIMATION_DEBUG, "Interpolated value for property {} at {}: {} -> {} = {}", string_from_property_id(it.key), progress_in_keyframe, start->to_string(SerializationMode::Normal), end->to_string(SerializationMode::Normal), next_value->to_string(SerializationMode::Normal)); computed_properties.set_animated_property(it.key, *next_value); } else { // If interpolate_property() fails, the element should not be rendered - dbgln_if(LIBWEB_CSS_ANIMATION_DEBUG, "Interpolated value for property {} at {}: {} -> {} is invalid", string_from_property_id(it.key), progress_in_keyframe, start->to_string(CSSStyleValue::SerializationMode::Normal), end->to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln_if(LIBWEB_CSS_ANIMATION_DEBUG, "Interpolated value for property {} at {}: {} -> {} is invalid", string_from_property_id(it.key), progress_in_keyframe, start->to_string(SerializationMode::Normal), end->to_string(SerializationMode::Normal)); computed_properties.set_animated_property(PropertyID::Visibility, CSSKeywordValue::create(Keyword::Hidden)); } } @@ -1556,7 +1556,7 @@ void StyleComputer::start_needed_transitions(ComputedProperties const& previous_ // there is a matching transition-property value, // and the end value of the running transition is not equal to the value of the property in the after-change style, then: if (has_running_transition && matching_transition_properties.has_value() && !existing_transition->transition_end_value()->equals(after_change_value)) { - dbgln_if(CSS_TRANSITIONS_DEBUG, "Transition step 4. existing end value = {}, after change value = {}", existing_transition->transition_end_value()->to_string(CSSStyleValue::SerializationMode::Normal), after_change_value.to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln_if(CSS_TRANSITIONS_DEBUG, "Transition step 4. existing end value = {}, after change value = {}", existing_transition->transition_end_value()->to_string(SerializationMode::Normal), after_change_value.to_string(SerializationMode::Normal)); // 1. If the current value of the property in the running transition is equal to the value of the property in the after-change style, // or if these two values are not transitionable, // then implementations must cancel the running transition. @@ -2686,7 +2686,7 @@ GC::Ref StyleComputer::compute_properties(DOM::Element& elem return OptionalNone {}; if (animation_name->is_string()) return animation_name->as_string().string_value().to_string(); - return animation_name->to_string(CSSStyleValue::SerializationMode::Normal); + return animation_name->to_string(SerializationMode::Normal); }(); if (animation_name.has_value()) { diff --git a/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h index 6820ee6d337..43fa8346bad 100644 --- a/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/AbstractImageStyleValue.h @@ -177,7 +177,7 @@ struct ColorStopListElement { using LinearColorStopListElement = ColorStopListElement; using AngularColorStopListElement = ColorStopListElement; -static void serialize_color_stop_list(StringBuilder& builder, auto const& color_stop_list, CSSStyleValue::SerializationMode mode) +static void serialize_color_stop_list(StringBuilder& builder, auto const& color_stop_list, SerializationMode mode) { bool first = true; for (auto const& element : color_stop_list) { diff --git a/Libraries/LibWeb/CSS/StyleValues/BasicShapeStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/BasicShapeStyleValue.cpp index f64171bf940..cbfbab7176a 100644 --- a/Libraries/LibWeb/CSS/StyleValues/BasicShapeStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/BasicShapeStyleValue.cpp @@ -34,7 +34,7 @@ Gfx::Path Inset::to_path(CSSPixelRect reference_box, Layout::Node const& node) c return path_from_resolved_rect(top, right, bottom, left); } -String Inset::to_string(CSSStyleValue::SerializationMode) const +String Inset::to_string(SerializationMode) const { return MUST(String::formatted("inset({} {} {} {})", inset_box.top(), inset_box.right(), inset_box.bottom(), inset_box.left())); } @@ -49,7 +49,7 @@ Gfx::Path Xywh::to_path(CSSPixelRect reference_box, Layout::Node const& node) co return path_from_resolved_rect(top, right, bottom, left); } -String Xywh::to_string(CSSStyleValue::SerializationMode) const +String Xywh::to_string(SerializationMode) const { return MUST(String::formatted("xywh({} {} {} {})", x, y, width, height)); } @@ -68,7 +68,7 @@ Gfx::Path Rect::to_path(CSSPixelRect reference_box, Layout::Node const& node) co return path_from_resolved_rect(top, max(right, left), max(bottom, top), left); } -String Rect::to_string(CSSStyleValue::SerializationMode) const +String Rect::to_string(SerializationMode) const { return MUST(String::formatted("rect({} {} {} {})", box.top(), box.right(), box.bottom(), box.left())); } @@ -123,7 +123,7 @@ Gfx::Path Circle::to_path(CSSPixelRect reference_box, Layout::Node const& node) return path; } -String Circle::to_string(CSSStyleValue::SerializationMode mode) const +String Circle::to_string(SerializationMode mode) const { return MUST(String::formatted("circle({} at {})", radius_to_string(radius), position->to_string(mode))); } @@ -168,7 +168,7 @@ Gfx::Path Ellipse::to_path(CSSPixelRect reference_box, Layout::Node const& node) return path; } -String Ellipse::to_string(CSSStyleValue::SerializationMode mode) const +String Ellipse::to_string(SerializationMode mode) const { return MUST(String::formatted("ellipse({} {} at {})", radius_to_string(radius_x), radius_to_string(radius_y), position->to_string(mode))); } @@ -193,7 +193,7 @@ Gfx::Path Polygon::to_path(CSSPixelRect reference_box, Layout::Node const& node) return path; } -String Polygon::to_string(CSSStyleValue::SerializationMode) const +String Polygon::to_string(SerializationMode) const { StringBuilder builder; builder.append("polygon("sv); diff --git a/Libraries/LibWeb/CSS/StyleValues/BasicShapeStyleValue.h b/Libraries/LibWeb/CSS/StyleValues/BasicShapeStyleValue.h index 766d6f28375..fdf58309ee6 100644 --- a/Libraries/LibWeb/CSS/StyleValues/BasicShapeStyleValue.h +++ b/Libraries/LibWeb/CSS/StyleValues/BasicShapeStyleValue.h @@ -17,7 +17,7 @@ namespace Web::CSS { struct Inset { Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const; - String to_string(CSSStyleValue::SerializationMode) const; + String to_string(SerializationMode) const; bool operator==(Inset const&) const = default; @@ -26,7 +26,7 @@ struct Inset { struct Xywh { Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const; - String to_string(CSSStyleValue::SerializationMode) const; + String to_string(SerializationMode) const; bool operator==(Xywh const&) const = default; @@ -38,7 +38,7 @@ struct Xywh { struct Rect { Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const; - String to_string(CSSStyleValue::SerializationMode) const; + String to_string(SerializationMode) const; bool operator==(Rect const&) const = default; @@ -54,7 +54,7 @@ using ShapeRadius = Variant; struct Circle { Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const; - String to_string(CSSStyleValue::SerializationMode) const; + String to_string(SerializationMode) const; bool operator==(Circle const&) const = default; @@ -64,7 +64,7 @@ struct Circle { struct Ellipse { Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const; - String to_string(CSSStyleValue::SerializationMode) const; + String to_string(SerializationMode) const; bool operator==(Ellipse const&) const = default; @@ -81,7 +81,7 @@ struct Polygon { }; Gfx::Path to_path(CSSPixelRect reference_box, Layout::Node const&) const; - String to_string(CSSStyleValue::SerializationMode) const; + String to_string(SerializationMode) const; bool operator==(Polygon const&) const = default; diff --git a/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp index c819cce6f72..6157144faec 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CalculatedStyleValue.cpp @@ -130,17 +130,17 @@ static NonnullRefPtr simplify_2_children(T const& origina return original; } -static String serialize_a_calculation_tree(CalculationNode const&, CalculationContext const&, CSSStyleValue::SerializationMode); +static String serialize_a_calculation_tree(CalculationNode const&, CalculationContext const&, SerializationMode); // https://drafts.csswg.org/css-values-4/#serialize-a-math-function -static String serialize_a_math_function(CalculationNode const& fn, CalculationContext const& context, CSSStyleValue::SerializationMode serialization_mode) +static String serialize_a_math_function(CalculationNode const& fn, CalculationContext const& context, SerializationMode serialization_mode) { // To serialize a math function fn: // 1. If the root of the calculation tree fn represents is a numeric value (number, percentage, or dimension), and // the serialization being produced is of a computed value or later, then clamp the value to the range allowed // for its context (if necessary), then serialize the value as normal and return the result. - if (fn.type() == CalculationNode::Type::Numeric && serialization_mode == CSSStyleValue::SerializationMode::ResolvedValue) { + if (fn.type() == CalculationNode::Type::Numeric && serialization_mode == SerializationMode::ResolvedValue) { // FIXME: Clamp the value. Note that we might have an infinite/nan value here. return static_cast(fn).value_to_string(); } @@ -311,7 +311,7 @@ static Vector> sort_a_calculations_children } // https://drafts.csswg.org/css-values-4/#serialize-a-calculation-tree -static String serialize_a_calculation_tree(CalculationNode const& root, CalculationContext const& context, CSSStyleValue::SerializationMode serialization_mode) +static String serialize_a_calculation_tree(CalculationNode const& root, CalculationContext const& context, SerializationMode serialization_mode) { // 1. Let root be the root node of the calculation tree. // NOTE: Already the case. diff --git a/Libraries/LibWeb/CSS/StyleValues/CounterStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/CounterStyleValue.cpp index bc361ca828f..f5870fbb314 100644 --- a/Libraries/LibWeb/CSS/StyleValues/CounterStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/CounterStyleValue.cpp @@ -90,7 +90,7 @@ static String generate_a_counter_representation(CSSStyleValue const& counter_sty } // FIXME: Handle `symbols()` function for counter_style. - dbgln("FIXME: Unsupported counter style '{}'", counter_style.to_string(CSSStyleValue::SerializationMode::Normal)); + dbgln("FIXME: Unsupported counter style '{}'", counter_style.to_string(SerializationMode::Normal)); return MUST(String::formatted("{}", value)); } diff --git a/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.cpp b/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.cpp index fef30da7615..ccf74f64c97 100644 --- a/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.cpp +++ b/Libraries/LibWeb/CSS/StyleValues/EdgeStyleValue.cpp @@ -10,7 +10,7 @@ namespace Web::CSS { String EdgeStyleValue::to_string(SerializationMode mode) const { - if (mode == CSSStyleValue::SerializationMode::ResolvedValue) { + if (mode == SerializationMode::ResolvedValue) { // FIXME: Figure out how to get the proper calculation context here CalculationContext context {}; return resolved_value(context)->offset().to_string(); diff --git a/Libraries/LibWeb/Dump.cpp b/Libraries/LibWeb/Dump.cpp index f4241c784c2..ea54cc9b2bf 100644 --- a/Libraries/LibWeb/Dump.cpp +++ b/Libraries/LibWeb/Dump.cpp @@ -426,7 +426,7 @@ void dump_tree(StringBuilder& builder, Layout::Node const& layout_node, bool sho }; Vector properties; as(*layout_node.dom_node()).computed_properties()->for_each_property([&](auto property_id, auto& value) { - properties.append({ CSS::string_from_property_id(property_id), value.to_string(CSS::CSSStyleValue::SerializationMode::Normal) }); + properties.append({ CSS::string_from_property_id(property_id), value.to_string(CSS::SerializationMode::Normal) }); }); quick_sort(properties, [](auto& a, auto& b) { return a.name < b.name; }); @@ -827,14 +827,14 @@ void dump_style_properties(StringBuilder& builder, CSS::CSSStyleProperties const builder.appendff("Declarations ({}):\n", declaration.length()); for (auto& property : declaration.properties()) { indent(builder, indent_levels); - builder.appendff(" {}: '{}'", CSS::string_from_property_id(property.property_id), property.value->to_string(CSS::CSSStyleValue::SerializationMode::Normal)); + builder.appendff(" {}: '{}'", CSS::string_from_property_id(property.property_id), property.value->to_string(CSS::SerializationMode::Normal)); if (property.important == CSS::Important::Yes) builder.append(" \033[31;1m!important\033[0m"sv); builder.append('\n'); } for (auto& property : declaration.custom_properties()) { indent(builder, indent_levels); - builder.appendff(" {}: '{}'", property.key, property.value.value->to_string(CSS::CSSStyleValue::SerializationMode::Normal)); + builder.appendff(" {}: '{}'", property.key, property.value.value->to_string(CSS::SerializationMode::Normal)); if (property.value.important == CSS::Important::Yes) builder.append(" \033[31;1m!important\033[0m"sv); builder.append('\n'); @@ -847,7 +847,7 @@ void dump_descriptors(StringBuilder& builder, CSS::CSSDescriptors const& descrip builder.appendff("Declarations ({}):\n", descriptors.length()); for (auto const& descriptor : descriptors.descriptors()) { indent(builder, indent_levels); - builder.appendff(" {}: '{}'", CSS::to_string(descriptor.descriptor_id), descriptor.value->to_string(CSS::CSSStyleValue::SerializationMode::Normal)); + builder.appendff(" {}: '{}'", CSS::to_string(descriptor.descriptor_id), descriptor.value->to_string(CSS::SerializationMode::Normal)); builder.append('\n'); } } diff --git a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp b/Libraries/LibWeb/Editing/Internal/Algorithms.cpp index ce8f04e5453..db721a61a78 100644 --- a/Libraries/LibWeb/Editing/Internal/Algorithms.cpp +++ b/Libraries/LibWeb/Editing/Internal/Algorithms.cpp @@ -646,7 +646,7 @@ Vector> clear_the_value(FlyString const& command, GC::Refset_property( string_from_property_id(CSS::PropertyID::TextDecoration), - new_style_value->to_string(CSS::CSSStyleValue::SerializationMode::Normal), + new_style_value->to_string(CSS::SerializationMode::Normal), {})); }; if (command == CommandNames::strikethrough) @@ -1184,7 +1184,7 @@ Optional effective_command_value(GC::Ptr node, FlyString cons auto resolved_value = resolved_background_color(); if (!resolved_value.has_value()) return {}; - return resolved_value.value()->to_string(CSS::CSSStyleValue::SerializationMode::ResolvedValue); + return resolved_value.value()->to_string(CSS::SerializationMode::ResolvedValue); } // 5. If command is "subscript" or "superscript": @@ -1264,7 +1264,7 @@ Optional effective_command_value(GC::Ptr node, FlyString cons auto optional_value = resolved_value(*node, command_definition.relevant_css_property.value()); if (!optional_value.has_value()) return {}; - return optional_value.value()->to_string(CSS::CSSStyleValue::SerializationMode::ResolvedValue); + return optional_value.value()->to_string(CSS::SerializationMode::ResolvedValue); } // https://w3c.github.io/editing/docs/execCommand/#first-equivalent-point @@ -2741,7 +2741,7 @@ void justify_the_selection(DOM::Document& document, JustifyAlignment alignment) && element->inline_style()->length() == 1) { auto text_align = element->inline_style()->property(CSS::PropertyID::TextAlign); if (text_align.has_value()) { - auto align_value = text_align.value().value->to_string(CSS::CSSStyleValue::SerializationMode::Normal); + auto align_value = text_align.value().value->to_string(CSS::SerializationMode::Normal); if (align_value.equals_ignoring_ascii_case(alignment_keyword)) ++number_of_matching_attributes; } @@ -3927,7 +3927,7 @@ Optional specified_command_value(GC::Ref element, FlyStrin // that it sets property to. auto style_value = property_in_style_attribute(element, property.value()); if (style_value.has_value()) - return style_value.value()->to_string(CSS::CSSStyleValue::SerializationMode::Normal); + return style_value.value()->to_string(CSS::SerializationMode::Normal); // 11. If element is a font element that has an attribute whose effect is to create a presentational hint for // property, return the value that the hint sets property to. (For a size of 7, this will be the non-CSS value @@ -3938,7 +3938,7 @@ Optional specified_command_value(GC::Ref element, FlyStrin font_element.apply_presentational_hints(cascaded_properties); auto property_value = cascaded_properties->property(property.value()); if (property_value) - return property_value->to_string(CSS::CSSStyleValue::SerializationMode::Normal); + return property_value->to_string(CSS::SerializationMode::Normal); } // 12. If element is in the following list, and property is equal to the CSS property name listed for it, return the diff --git a/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h b/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h index 353d9cf86a0..56bdf439d93 100644 --- a/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h +++ b/Libraries/LibWeb/HTML/Canvas/CanvasTextDrawingStyles.h @@ -34,10 +34,10 @@ public: auto font_size = font_style_value.longhand(CSS::PropertyID::FontSize); auto font_family = font_style_value.longhand(CSS::PropertyID::FontFamily); return ByteString::formatted("{} {} {} {}", - font_style->to_string(CSS::CSSStyleValue::SerializationMode::Normal), - font_weight->to_string(CSS::CSSStyleValue::SerializationMode::Normal), - font_size->to_string(CSS::CSSStyleValue::SerializationMode::Normal), - font_family->to_string(CSS::CSSStyleValue::SerializationMode::Normal)); + font_style->to_string(CSS::SerializationMode::Normal), + font_weight->to_string(CSS::SerializationMode::Normal), + font_size->to_string(CSS::SerializationMode::Normal), + font_family->to_string(CSS::SerializationMode::Normal)); } void set_font(StringView font) diff --git a/Services/WebContent/ConnectionFromClient.cpp b/Services/WebContent/ConnectionFromClient.cpp index a9ca53dc6ee..d2ec071e89f 100644 --- a/Services/WebContent/ConnectionFromClient.cpp +++ b/Services/WebContent/ConnectionFromClient.cpp @@ -315,7 +315,7 @@ void ConnectionFromClient::debug_request(u64 page_id, ByteString request, ByteSt dbgln("+ Element {}", element->debug_description()); for (size_t i = 0; i < Web::CSS::ComputedProperties::number_of_properties; ++i) { auto property = styles->maybe_null_property(static_cast(i)); - dbgln("| {} = {}", Web::CSS::string_from_property_id(static_cast(i)), property ? property->to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal) : ""_string); + dbgln("| {} = {}", Web::CSS::string_from_property_id(static_cast(i)), property ? property->to_string(Web::CSS::SerializationMode::Normal) : ""_string); } dbgln("---"); } @@ -483,7 +483,7 @@ void ConnectionFromClient::inspect_dom_node(u64 page_id, WebView::DOMNodePropert properties->for_each_property([&](auto property_id, auto& value) { serialized.set( Web::CSS::string_from_property_id(property_id), - value.to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal)); + value.to_string(Web::CSS::SerializationMode::Normal)); }); return serialized; @@ -517,12 +517,12 @@ void ConnectionFromClient::inspect_dom_node(u64 page_id, WebView::DOMNodePropert serialized.set("border-bottom-width"sv, box_model.border.bottom.to_double()); serialized.set("border-left-width"sv, box_model.border.left.to_double()); - serialized.set("box-sizing"sv, properties->property(Web::CSS::PropertyID::BoxSizing).to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal)); - serialized.set("display"sv, properties->property(Web::CSS::PropertyID::Display).to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal)); - serialized.set("float"sv, properties->property(Web::CSS::PropertyID::Float).to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal)); - serialized.set("line-height"sv, properties->property(Web::CSS::PropertyID::LineHeight).to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal)); - serialized.set("position"sv, properties->property(Web::CSS::PropertyID::Position).to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal)); - serialized.set("z-index"sv, properties->property(Web::CSS::PropertyID::ZIndex).to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal)); + serialized.set("box-sizing"sv, properties->property(Web::CSS::PropertyID::BoxSizing).to_string(Web::CSS::SerializationMode::Normal)); + serialized.set("display"sv, properties->property(Web::CSS::PropertyID::Display).to_string(Web::CSS::SerializationMode::Normal)); + serialized.set("float"sv, properties->property(Web::CSS::PropertyID::Float).to_string(Web::CSS::SerializationMode::Normal)); + serialized.set("line-height"sv, properties->property(Web::CSS::PropertyID::LineHeight).to_string(Web::CSS::SerializationMode::Normal)); + serialized.set("position"sv, properties->property(Web::CSS::PropertyID::Position).to_string(Web::CSS::SerializationMode::Normal)); + serialized.set("z-index"sv, properties->property(Web::CSS::PropertyID::ZIndex).to_string(Web::CSS::SerializationMode::Normal)); return serialized; }; diff --git a/Services/WebContent/WebDriverConnection.cpp b/Services/WebContent/WebDriverConnection.cpp index d6a90062ed8..9abb786f470 100644 --- a/Services/WebContent/WebDriverConnection.cpp +++ b/Services/WebContent/WebDriverConnection.cpp @@ -1378,7 +1378,7 @@ Messages::WebDriverClient::GetElementCssValueResponse WebDriverConnection::get_e // computed value of parameter URL variables["property name"] from element's style declarations. if (auto property = Web::CSS::property_id_from_string(name); property.has_value()) { if (auto computed_properties = element->computed_properties()) - computed_value = computed_properties->property(property.value()).to_string(Web::CSS::CSSStyleValue::SerializationMode::Normal); + computed_value = computed_properties->property(property.value()).to_string(Web::CSS::SerializationMode::Normal); } } // -> Otherwise