From 2389650734c31c8cbe7294f0b4ebec11fecf4ddc Mon Sep 17 00:00:00 2001 From: Oriol Brufau Date: Wed, 1 Nov 2023 00:35:22 +0100 Subject: [PATCH] Further changes required by Servo --- components/style/properties/properties.mako.rs | 13 +++++++++++-- components/style/servo/selector_parser.rs | 7 +++---- 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/components/style/properties/properties.mako.rs b/components/style/properties/properties.mako.rs index 5a9dba9468a..21d086e7177 100644 --- a/components/style/properties/properties.mako.rs +++ b/components/style/properties/properties.mako.rs @@ -3289,6 +3289,15 @@ impl ComputedValues { /// Get the initial computed values. pub fn initial_values() -> &'static Self { &*INITIAL_SERVO_VALUES } + /// Converts the computed values to an Arc<> from a reference. + pub fn to_arc(&self) -> Arc { + // SAFETY: We're guaranteed to be allocated as an Arc<> since the + // functions above are the only ones that create ComputedValues + // instances in Servo (and that must be the case since ComputedValues' + // member is private). + unsafe { Arc::from_raw_addrefed(self) } + } + /// Serializes the computed value of this property as a string. pub fn computed_value_to_string(&self, property: PropertyDeclarationId) -> String { match property { @@ -4103,7 +4112,7 @@ mod lazy_static_module { lazy_static! { /// The initial values for all style structs as defined by the specification. - pub static ref INITIAL_SERVO_VALUES: ComputedValues = ComputedValues { + pub static ref INITIAL_SERVO_VALUES : Arc = Arc::new(ComputedValues { inner: ComputedValuesInner { % for style_struct in data.active_style_structs(): ${style_struct.ident}: Arc::new(style_structs::${style_struct.name} { @@ -4131,7 +4140,7 @@ mod lazy_static_module { flags: ComputedValueFlags::empty(), }, pseudo: None, - }; + }); } } diff --git a/components/style/servo/selector_parser.rs b/components/style/servo/selector_parser.rs index db3b43e6cf2..901ef71071e 100644 --- a/components/style/servo/selector_parser.rs +++ b/components/style/servo/selector_parser.rs @@ -23,7 +23,6 @@ use fxhash::FxHashMap; use selectors::attr::{AttrSelectorOperation, CaseSensitivity, NamespaceConstraint}; use selectors::parser::SelectorParseErrorKind; use selectors::visitor::SelectorVisitor; -use servo_arc::Arc; use std::fmt; use std::mem; use std::ops::{Deref, DerefMut}; @@ -411,7 +410,7 @@ pub struct SelectorImpl; /// A set of extra data to carry along with the matching context, either for /// selector-matching or invalidation. #[derive(Debug, Default)] -pub struct ExtraMatchingData { +pub struct ExtraMatchingData<'a> { /// The invalidation data to invalidate doc-state pseudo-classes correctly. pub invalidation_data: InvalidationMatchingData, @@ -421,14 +420,14 @@ pub struct ExtraMatchingData { /// The style of the originating element in order to evaluate @container /// size queries affecting pseudo-elements. - pub originating_element_style: Option>, + pub originating_element_style: Option<&'a ComputedValues>, } impl ::selectors::SelectorImpl for SelectorImpl { type PseudoElement = PseudoElement; type NonTSPseudoClass = NonTSPseudoClass; - type ExtraMatchingData = ExtraMatchingData; + type ExtraMatchingData<'a> = ExtraMatchingData<'a>; type AttrValue = AtomString; type Identifier = AtomIdent; type LocalName = LocalName;