Truly independent web browser
LibWeb: Set and remove CSS declarations in Rust
Andreas Kling0c0e38985fb3
diff --git a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp b/Libraries/LibWeb/CSS/CSSStyleProperties.cppindex 638c479ccd1..f0bebbb3d80 100644--- a/Libraries/LibWeb/CSS/CSSStyleProperties.cpp+++ b/Libraries/LibWeb/CSS/CSSStyleProperties.cpp@@ -279,42 +279,22 @@ WebIDL::ExceptionOr<void> CSSStyleProperties::set_property_internal(PropertyNameprepare_to_update_style_attribute();- // 7. Let updated be false.+ // NB: Steps 7 to 9 are implemented in RustDeclarationBlock::set_expanding_shorthands().+ auto important = !priority.is_empty() ? Important::Yes : Important::No;bool updated = false;-- // 8. If property is a shorthand property,- if (property_is_shorthand(property.id())) {- // then for each longhand property longhand that property maps to, in canonical order, follow these substeps:- StyleComputer::for_each_property_expanding_shorthands(property.id(), *component_value_list, [this, &updated, priority](PropertyID longhand_property_id, StyleValue const& longhand_value) {- // 1. Let longhand result be the result of set the CSS declaration longhand with the appropriate value(s) from component value list,- // with the important flag set if priority is not the empty string, and unset otherwise, and with the list of declarations being the declarations.- // 2. If longhand result is true, let updated be true.- updated |= set_a_css_declaration(longhand_property_id, longhand_value, !priority.is_empty() ? Important::Yes : Important::No);- });- }- // 9. Otherwise,- else {- if (property.is_custom_property()) {- auto important = !priority.is_empty() ? Important::Yes : Important::No;- StyleProperty style_property {- .important = important,- .property_id = property.id(),- .value = component_value_list.release_nonnull(),- };- if (auto existing_property = custom_property(property.name()); existing_property.has_value()- && existing_property->important == important- && *existing_property->value == *style_property.value) {- updated = false;- } else {- m_declarations.set_custom(property.name(), style_property);- updated = true;- }- } else {- // let updated be the result of set the CSS declaration property with value component value list,- // with the important flag set if priority is not the empty string, and unset otherwise,- // and with the list of declarations being the declarations.- updated = set_a_css_declaration(property.id(), *component_value_list, !priority.is_empty() ? Important::Yes : Important::No);+ if (property.is_custom_property()) {+ StyleProperty style_property {+ .important = important,+ .property_id = property.id(),+ .value = component_value_list.release_nonnull(),+ };+ auto existing_property = custom_property(property.name());+ if (!existing_property.has_value() || existing_property->important != important || *existing_property->value != *style_property.value) {+ m_declarations.set_custom(property.name(), style_property);+ updated = true;}+ } else {+ updated = m_declarations.set_expanding_shorthands(property.id(), *component_value_list, important);}// 10. If updated is true, update style attribute for the CSS declaration block.@@ -428,9 +408,7 @@ WebIDL::ExceptionOr<void> CSSStyleProperties::set_property_style_value(PropertyNprepare_to_update_style_attribute();- StyleComputer::for_each_property_expanding_shorthands(property.id(), style_value, [this](PropertyID longhand_id, StyleValue const& longhand_value) {- m_declarations.append(longhand_id, longhand_value, Important::No);- });+ m_declarations.append_expanding_shorthands(property.id(), style_value, Important::No);update_style_attribute();invalidate_owners();@@ -1040,31 +1018,12 @@ WebIDL::ExceptionOr<Utf16String> CSSStyleProperties::remove_property_internal(Op// FIXME: Add an overload that takes PropertyNameAndID?value = get_property_value(property->name());- Function<bool(PropertyNameAndID const&)> remove_declaration = [&](PropertyNameAndID const& property_to_remove) {- // 4. Let removed be false.- bool removed = false;-- // 5. If property is a shorthand property, for each longhand property longhand that property maps to:- if (property_is_shorthand(property_to_remove.id())) {- for (auto longhand_property_id : longhands_for_shorthand(property_to_remove.id())) {- // 1. If longhand is not a property name of a CSS declaration in the declarations, continue.- // 2. Remove that CSS declaration and let removed be true.- removed |= remove_declaration(PropertyNameAndID::from_id(longhand_property_id));- }- } else {- // 6. Otherwise, if property is a case-sensitive match for a property name of a CSS declaration in the declarations, remove that CSS declaration and let removed be true.- if (property_to_remove.is_custom_property()) {- removed = m_declarations.remove_custom(property_to_remove.name());- } else {- removed = m_declarations.remove(property_to_remove.id());- }- }-- return removed;- };-prepare_to_update_style_attribute();- auto removed = remove_declaration(property.value());++ // NB: Steps 4 to 6 are implemented in RustDeclarationBlock::remove_expanding_shorthands().+ auto removed = property->is_custom_property()+ ? m_declarations.remove_custom(property->name())+ : m_declarations.remove_expanding_shorthands(property->id());// 7. If removed is true, Update style attribute for the CSS declaration block.if (removed) {@@ -1133,14 +1092,6 @@ void CSSStyleProperties::invalidate_owners()}}-// https://drafts.csswg.org/cssom/#set-a-css-declaration-bool CSSStyleProperties::set_a_css_declaration(PropertyID property_id, NonnullRefPtr<StyleValue const> value, Important important)-{- VERIFY(!is_computed());-- return m_declarations.set(property_id, *value, important);-}-void CSSStyleProperties::set_declarations_from_text(Utf16View css_text){m_declarations.replace(RustDeclarationBlock { {}, {} });diff --git a/Libraries/LibWeb/CSS/CSSStyleProperties.h b/Libraries/LibWeb/CSS/CSSStyleProperties.hindex af846e7a082..225e3f831bf 100644--- a/Libraries/LibWeb/CSS/CSSStyleProperties.h+++ b/Libraries/LibWeb/CSS/CSSStyleProperties.h@@ -84,7 +84,6 @@ private:Optional<StyleProperty> get_direct_property(PropertyNameAndID const&) const;WebIDL::ExceptionOr<void> set_property_internal(PropertyNameAndID const&, Utf16View css_text, Utf16View priority);WebIDL::ExceptionOr<Utf16String> remove_property_internal(Optional<PropertyNameAndID> const&);- bool set_a_css_declaration(PropertyID, NonnullRefPtr<StyleValue const>, Important);void invalidate_owners();diff --git a/Libraries/LibWeb/CSS/RustDeclarationBlock.cpp b/Libraries/LibWeb/CSS/RustDeclarationBlock.cppindex 7c7fcdcdae2..8b445d2c291 100644--- a/Libraries/LibWeb/CSS/RustDeclarationBlock.cpp+++ b/Libraries/LibWeb/CSS/RustDeclarationBlock.cpp@@ -202,16 +202,16 @@ size_t RustDeclarationBlock::external_memory_size() constreturn JS::saturating_add_external_memory_size(size, JS::hash_map_external_memory_size(m_views->custom_properties));}-bool RustDeclarationBlock::set(PropertyID property_id, StyleValue const& value, Important important)+bool RustDeclarationBlock::set_expanding_shorthands(PropertyID property_id, StyleValue const& value, Important important){auto property = property_view(property_id, value, important);- return rust_declaration_block_set(m_block, &property);+ return rust_declaration_block_set_expanding_shorthands(m_block, &property);}-void RustDeclarationBlock::append(PropertyID property_id, StyleValue const& value, Important important)+void RustDeclarationBlock::append_expanding_shorthands(PropertyID property_id, StyleValue const& value, Important important){auto property = property_view(property_id, value, important);- rust_declaration_block_append(m_block, &property);+ rust_declaration_block_append_expanding_shorthands(m_block, &property);}void RustDeclarationBlock::set_custom(Utf16FlyString const& name, StyleProperty const& property)@@ -220,9 +220,9 @@ void RustDeclarationBlock::set_custom(Utf16FlyString const& name, StylePropertyrust_declaration_block_set_custom(m_block, &view);}-bool RustDeclarationBlock::remove(PropertyID property_id)+bool RustDeclarationBlock::remove_expanding_shorthands(PropertyID property_id){- return rust_declaration_block_remove(m_block, to_underlying(property_id));+ return rust_declaration_block_remove_expanding_shorthands(m_block, to_underlying(property_id));}bool RustDeclarationBlock::remove_custom(Utf16FlyString const& name)diff --git a/Libraries/LibWeb/CSS/RustDeclarationBlock.h b/Libraries/LibWeb/CSS/RustDeclarationBlock.hindex 61cdb5dc915..1939ce12636 100644--- a/Libraries/LibWeb/CSS/RustDeclarationBlock.h+++ b/Libraries/LibWeb/CSS/RustDeclarationBlock.h@@ -58,10 +58,10 @@ public:OrderedHashMap<Utf16FlyString, StyleProperty> const& custom_properties() const;size_t external_memory_size() const;- bool set(PropertyID, StyleValue const&, Important);- void append(PropertyID, StyleValue const&, Important);+ bool set_expanding_shorthands(PropertyID, StyleValue const&, Important);+ void append_expanding_shorthands(PropertyID, StyleValue const&, Important);void set_custom(Utf16FlyString const&, StyleProperty const&);- bool remove(PropertyID);+ bool remove_expanding_shorthands(PropertyID);bool remove_custom(Utf16FlyString const&);Parser::ValueParserFFI::DeclarationBlock const* handle() const { return m_block; }diff --git a/Libraries/LibWeb/CSS/StyleComputer.cpp b/Libraries/LibWeb/CSS/StyleComputer.cppindex 91e33852d8a..3b3fe4734e6 100644--- a/Libraries/LibWeb/CSS/StyleComputer.cpp+++ b/Libraries/LibWeb/CSS/StyleComputer.cpp@@ -487,26 +487,6 @@ struct ResolvedScope {size_t proximity { NumericLimits<size_t>::max() };};-void StyleComputer::for_each_property_expanding_shorthands(PropertyID property_id, StyleValue const& value, Function<void(PropertyID, StyleValue const&)> const& set_longhand_property)-{- // The expansion recursion and pending-substitution values live in the Rust style value graph.- // This wrapper creates C++ facades only for the returned longhand roots.- auto expansion = ComputedValuesFFI::rust_expand_property_shorthands(- to_underlying(property_id), value.rust_style_value_data());- ScopeGuard destroy_expansion = [&] {- ComputedValuesFFI::rust_shorthand_expansion_destroy(expansion.storage);- };- HashMap<void const*, NonnullRefPtr<StyleValue const>> wrapper_cache;- for (size_t i = 0; i < expansion.count; ++i) {- auto const& property = expansion.properties[i];- auto& expanded_value = wrapper_cache.ensure(property.data, [&] {- return StyleValue::adopt_rust_style_value_data(StyleValueFFI::rust_style_value_retain(- static_cast<StyleValueFFI::StyleValueData const*>(property.data)));- });- set_longhand_property(static_cast<PropertyID>(property.property_id), *expanded_value);- }-}-static RefPtr<CustomPropertyData const> inheritable_custom_property_data(Layout::BegunRead const& read, DOM::AbstractElement abstract_element){auto data = abstract_element.custom_property_data();diff --git a/Libraries/LibWeb/CSS/StyleComputer.h b/Libraries/LibWeb/CSS/StyleComputer.hindex b564206fd74..54d8aa1cdce 100644--- a/Libraries/LibWeb/CSS/StyleComputer.h+++ b/Libraries/LibWeb/CSS/StyleComputer.h@@ -43,8 +43,6 @@ class WEB_API StyleComputer final : public GC::Cell {GC_DECLARE_ALLOCATOR(StyleComputer);public:- static void for_each_property_expanding_shorthands(PropertyID, StyleValue const&, Function<void(PropertyID, StyleValue const&)> const& set_longhand_property);-static Optional<Utf16String> user_agent_style_sheet_source(Utf16View name);static Vector<StyleProperty> collect_presentational_hint_properties(DOM::AbstractElement);diff --git a/Libraries/LibWeb/Rust/src/css/declaration_block.rs b/Libraries/LibWeb/Rust/src/css/declaration_block.rsindex 4aa67593c4f..9721d37a41f 100644--- a/Libraries/LibWeb/Rust/src/css/declaration_block.rs+++ b/Libraries/LibWeb/Rust/src/css/declaration_block.rs@@ -7,14 +7,14 @@use crate::css::css_string::CssString;use crate::css::ffi_support::{FfiUtf16View, OwnedBox};use crate::css::property_metadata::{- property_is_logical_alias_including_shorthands, property_is_shorthand, property_logical_group,- shorthand_has_leaf_longhand,+ longhands_for_shorthand, property_is_logical_alias_including_shorthands, property_is_shorthand,+ property_logical_group, shorthand_has_leaf_longhand,};use crate::css::style::cascade::CascadeOperator;use crate::css::style::pipeline::rule_store::BlockCascadeData;use crate::css::style_compute::expand_shorthands_with;use crate::css::style_value::ContentPayload;-use crate::css::style_value::StyleValueData;+use crate::css::style_value::{RetainedStyleValueData, StyleValueData};use crate::css::style_value_arc::StyleValueArc;use std::alloc::{Layout, alloc, dealloc, handle_alloc_error};use std::cell::RefCell;@@ -1133,34 +1133,94 @@ pub extern "C" fn rust_declaration_block_visit(rust_declaration_data_visit(&block.data(), context, visit);}+/// The declarations that the declaration stands for: itself for a longhand, and otherwise its longhands.+unsafe fn declarations_expanding_shorthands(property: &FfiDeclaredProperty) -> Vec<DeclaredProperty> {+ let important = property.important;+ let value = RetainedStyleValueData::from_arc(unsafe { retain_value(property.value) });+ let mut declarations = Vec::new();+ expand_shorthands_with(property.property_id, &value, false, &mut |property_id, value, _| {+ declarations.push(DeclaredProperty {+ property_id,+ important,+ value: value.clone().into_arc(),+ });+ });+ declarations+}++/// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-setproperty#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_declaration_block_set(+pub unsafe extern "C" fn rust_declaration_block_set_expanding_shorthands(block: &mut DeclarationBlock,property: &FfiDeclaredProperty,) -> bool {- let declaration = unsafe { declaration_from_view(property) };- let property_id = declaration.property_id;+ let declarations = unsafe { declarations_expanding_shorthands(property) };block.mutate(|data| {- let updated = data.set_declaration(declaration);- if updated {- data.drop_shorthands_no_longer_pending_in(property_id);+ // 7. Let updated be false.+ let mut updated = false;++ // 8. If property is a shorthand property, then for each longhand property longhand that property maps to, in+ // canonical order, follow these substeps:+ // 9. Otherwise, let updated be the result of set the CSS declaration property with value component value list,+ // with the important flag set if priority is not the empty string, and unset otherwise, and with the list+ // of declarations being the declarations.+ for declaration in declarations {+ let property_id = declaration.property_id;+ // 1. Let longhand result be the result of set the CSS declaration longhand with the appropriate value(s)+ // from component value list, with the important flag set if priority is not the empty string, and unset+ // otherwise, and with the list of declarations being the declarations.+ // 2. If longhand result is true, let updated be true.+ if data.set_declaration(declaration) {+ data.drop_shorthands_no_longer_pending_in(property_id);+ updated = true;+ }}updated})}#[unsafe(no_mangle)]-pub unsafe extern "C" fn rust_declaration_block_append(block: &mut DeclarationBlock, property: &FfiDeclaredProperty) {- let declaration = unsafe { declaration_from_view(property) };+pub unsafe extern "C" fn rust_declaration_block_append_expanding_shorthands(+ block: &mut DeclarationBlock,+ property: &FfiDeclaredProperty,+) {+ let declarations = unsafe { declarations_expanding_shorthands(property) };block.mutate(|data| {- let property_id = declaration.property_id;- data.properties.retain(|existing| existing.property_id != property_id);- data.properties.push(declaration);- data.drop_shorthands_no_longer_pending_in(property_id);+ for declaration in declarations {+ let property_id = declaration.property_id;+ data.properties.retain(|existing| existing.property_id != property_id);+ data.properties.push(declaration);+ data.drop_shorthands_no_longer_pending_in(property_id);+ }true});}+/// https://drafts.csswg.org/cssom/#dom-cssstyledeclaration-removeproperty+#[unsafe(no_mangle)]+pub extern "C" fn rust_declaration_block_remove_expanding_shorthands(+ block: &mut DeclarationBlock,+ property_id: u16,+) -> bool {+ // 4. Let removed be false.+ let mut removed = false;++ // 5. If property is a shorthand property, for each longhand property longhand that property maps to:+ if property_is_shorthand(property_id) {+ for &longhand in longhands_for_shorthand(property_id) {+ // 1. If longhand is not a property name of a CSS declaration in the declarations, continue.+ // 2. Remove that CSS declaration and let removed be true.+ removed |= rust_declaration_block_remove_expanding_shorthands(block, longhand);+ }+ }+ // 6. Otherwise, if property is a case-sensitive match for a property name of a CSS declaration in the declarations,+ // remove that CSS declaration and let removed be true.+ else {+ removed = block.remove(property_id);+ }+ removed+}+#[unsafe(no_mangle)]pub unsafe extern "C" fn rust_declaration_block_set_custom(block: &mut DeclarationBlock,@@ -1174,11 +1234,6 @@ pub unsafe extern "C" fn rust_declaration_block_set_custom(});}-#[unsafe(no_mangle)]-pub extern "C" fn rust_declaration_block_remove(block: &mut DeclarationBlock, property_id: u16) -> bool {- block.remove(property_id)-}-#[unsafe(no_mangle)]pub extern "C" fn rust_declaration_block_remove_custom(block: &mut DeclarationBlock, name: FfiUtf16View) -> bool {let name = name.to_utf16().unwrap();@@ -1234,7 +1289,7 @@ mod tests {let current = block.data();let mut view = current.properties().get(0).unwrap().view(FfiUtf16View::default());view.important = true;- assert!(unsafe { rust_declaration_block_set(&mut block, &view) });+ assert!(unsafe { rust_declaration_block_set_expanding_shorthands(&mut block, &view) });let name = block.data().custom_properties().get(0).unwrap().name.clone();assert!(rust_declaration_block_remove_custom(&mut block,@@ -1269,14 +1324,20 @@ mod tests {assert_eq!(rust_declaration_block_revision(block), 0);assert!(rust_declaration_block_external_memory_size(block) > 0);let mut fork = unsafe { Box::from_raw(rust_declaration_block_share(block)) };- assert!(!rust_declaration_block_remove(&mut fork, property_id::HEIGHT));+ assert!(!rust_declaration_block_remove_expanding_shorthands(+ &mut fork,+ property_id::HEIGHT+ ));assert!(matches!(*block.state.borrow(), DeclarationBlockState::Immutable(_)));assert!(matches!(*fork.state.borrow(), DeclarationBlockState::Immutable(_)));assert!(SharedDeclarationBlock::ptr_eq(&snapshot, &fork.data()));let mut retained = unsafe { Box::from_raw(rust_declaration_block_retain(block)) };assert!(Rc::ptr_eq(&block.owner(), &retained.owner()));- assert!(rust_declaration_block_remove(&mut retained, property_id::WIDTH));+ assert!(rust_declaration_block_remove_expanding_shorthands(+ &mut retained,+ property_id::WIDTH+ ));assert!(block.data().properties().is_empty());assert_eq!(rust_declaration_block_revision(block), 1);// A different handle's mutation cannot invalidate a pinned snapshot.@@ -1291,7 +1352,10 @@ mod tests {assert_eq!(rust_declaration_block_revision(block), 2);assert!(matches!(*fork.state.borrow(), DeclarationBlockState::Immutable(_)));drop((nested, rule, rules));- assert!(rust_declaration_block_remove(&mut fork, property_id::WIDTH));+ assert!(rust_declaration_block_remove_expanding_shorthands(+ &mut fork,+ property_id::WIDTH+ ));assert!(matches!(*fork.state.borrow(), DeclarationBlockState::Mutable(_)));assert!(fork.data().properties().is_empty());assert_eq!(retained.data().properties().len(), 1);diff --git a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rs b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rsindex 7b7241c2a7f..c19959c009c 100644--- a/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rs+++ b/Libraries/LibWeb/Rust/src/css/parser/syntax_parser/ownership_tests.rs@@ -1074,7 +1074,7 @@ fn declaration_image_traversal_skips_non_resource_values() {#[test]fn declaration_mutation_does_not_change_cached_or_nested_shared_blocks() {use crate::css::declaration_block::{- DeclarationBlock, rust_declaration_block_remove, rust_declaration_block_remove_custom,+ DeclarationBlock, rust_declaration_block_remove_custom, rust_declaration_block_remove_expanding_shorthands,};use crate::css::property_metadata::property_id;let source = utf16("a { margin: 13px; --色: green }");@@ -1089,7 +1089,10 @@ fn declaration_mutation_does_not_change_cached_or_nested_shared_blocks() {let mut changed = DeclarationBlock::new(original.clone());let independent = DeclarationBlock::new(original.clone());assert_eq!(changed.data().properties().len(), 4);- assert!(rust_declaration_block_remove(&mut changed, property_id::MARGIN_TOP));+ assert!(rust_declaration_block_remove_expanding_shorthands(+ &mut changed,+ property_id::MARGIN_TOP+ ));assert!(rust_declaration_block_remove_custom(&mut changed, view(&utf16("--色"))));assert_eq!(independent.data().properties().len(), 4);assert_eq!(independent.data().custom_properties().len(), 1);@@ -1119,7 +1122,10 @@ fn declaration_mutation_does_not_change_cached_or_nested_shared_blocks() {let shared = DeclarationBlock::new(original);assert_eq!(changed.data().properties().len(), 5);assert_eq!(changed.data().custom_properties().len(), 1);- assert!(rust_declaration_block_remove(&mut changed, property_id::MARGIN_LEFT));+ assert!(rust_declaration_block_remove_expanding_shorthands(+ &mut changed,+ property_id::MARGIN_LEFT+ ));assert_eq!(shared.data().properties().len(), 5);}diff --git a/Tests/LibWeb/TestCSSSyntaxParser.cpp b/Tests/LibWeb/TestCSSSyntaxParser.cppindex 582062c390c..d3b0617994c 100644--- a/Tests/LibWeb/TestCSSSyntaxParser.cpp+++ b/Tests/LibWeb/TestCSSSyntaxParser.cpp@@ -413,8 +413,8 @@ TEST_CASE(native_declaration_block_specified_order_and_mutation)auto shared = block.share();auto value = block.properties()[4].value;- EXPECT(block.set(PropertyID::MarginLeft, *value, Important::No));- EXPECT(!block.set(PropertyID::MarginLeft, *value, Important::No));+ EXPECT(block.set_expanding_shorthands(PropertyID::MarginLeft, *value, Important::No));+ EXPECT(!block.set_expanding_shorthands(PropertyID::MarginLeft, *value, Important::No));EXPECT_EQ(shared.properties()[3].important, Important::Yes);EXPECT_EQ(shared.properties()[3].value->to_utf16_string(SerializationMode::Normal), u"2px"sv);EXPECT(block.remove_custom("--色"_utf16_fly_string));@@ -423,7 +423,7 @@ TEST_CASE(native_declaration_block_specified_order_and_mutation)auto logical = parse_native_declaration_block(u"margin-left: 1px; margin-inline-start: 2px"sv);auto original_value = logical.properties()[0].value;- EXPECT(logical.set(PropertyID::MarginLeft, *original_value, Important::No));+ EXPECT(logical.set_expanding_shorthands(PropertyID::MarginLeft, *original_value, Important::No));EXPECT_EQ(logical.properties()[0].property_id, PropertyID::MarginInlineStart);EXPECT_EQ(logical.properties()[1].property_id, PropertyID::MarginLeft);}@@ -442,7 +442,7 @@ TEST_CASE(native_declaration_block_merges_lists_without_expanding_again)EXPECT_EQ(block.custom_properties().begin()->value.value->to_utf16_string(SerializationMode::Normal), u"last"sv);auto shared = block.share();- EXPECT(block.remove(PropertyID::MarginLeft));+ EXPECT(block.remove_expanding_shorthands(PropertyID::MarginLeft));EXPECT_EQ(block.properties().size(), 4u);EXPECT_EQ(shared.properties()[4].value->to_utf16_string(SerializationMode::Normal), u"7px"sv);EXPECT(parse_native_declaration_block(u"@media all { width: 999px; }"sv).is_empty());@@ -454,9 +454,9 @@ TEST_CASE(native_declaration_block_preserves_unchanged_value_wrappers)auto block = parse_native_declaration_block(u"background-image: url(https://example.com/image.png); width: 3px"sv);auto image_value = block.properties()[0].value;auto width_value = block.properties()[1].value;- block.set(PropertyID::Height, *width_value, Important::No);+ block.set_expanding_shorthands(PropertyID::Height, *width_value, Important::No);EXPECT_EQ(block.properties()[0].value.ptr(), image_value.ptr());- block.remove(PropertyID::Width);+ block.remove_expanding_shorthands(PropertyID::Width);EXPECT_EQ(block.properties()[0].value.ptr(), image_value.ptr());}@@ -471,15 +471,15 @@ TEST_CASE(retained_declaration_blocks_observe_mutations_and_replacement)EXPECT_EQ(retained.properties().size(), 1u);EXPECT_EQ(retained.custom_properties().size(), 1u);auto revision = retained.revision();- EXPECT(!block.set(PropertyID::Width, *retained.properties()[0].value, Important::No));+ EXPECT(!block.set_expanding_shorthands(PropertyID::Width, *retained.properties()[0].value, Important::No));EXPECT_EQ(retained.revision(), revision);- EXPECT(block.remove(PropertyID::Width));+ EXPECT(block.remove_expanding_shorthands(PropertyID::Width));EXPECT(retained.revision() > revision);EXPECT(retained.properties().is_empty());EXPECT_EQ(shared.properties().size(), 1u);revision = retained.revision();- EXPECT(!block.remove(PropertyID::Width));+ EXPECT(!block.remove_expanding_shorthands(PropertyID::Width));EXPECT_EQ(retained.revision(), revision);retained.replace(parse_native_declaration_block(u"height: 7px; --色: blue"sv));