diff --git a/components/style/gecko/generated/bindings.rs b/components/style/gecko/generated/bindings.rs index 3487ec2f534..59c97a0658e 100644 --- a/components/style/gecko/generated/bindings.rs +++ b/components/style/gecko/generated/bindings.rs @@ -1936,6 +1936,11 @@ extern "C" { pub fn Servo_Element_IsDisplayNone(element: RawGeckoElementBorrowed) -> bool; } +extern "C" { + pub fn Servo_Element_IsPrimaryStyleReusedViaRuleNode(element: + RawGeckoElementBorrowed) + -> bool; +} extern "C" { pub fn Servo_StyleSheet_FromUTF8Bytes(loader: *mut Loader, gecko_stylesheet: diff --git a/components/style/sharing/mod.rs b/components/style/sharing/mod.rs index 83ad650c5e2..72214d79f90 100644 --- a/components/style/sharing/mod.rs +++ b/components/style/sharing/mod.rs @@ -745,11 +745,16 @@ impl StyleSharingCache { /// Attempts to find an element in the cache with the given primary rule node and parent. pub fn lookup_by_rules( &mut self, + shared_context: &SharedStyleContext, inherited: &ComputedValues, rules: &StrongRuleNode, visited_rules: Option<&StrongRuleNode>, target: E, ) -> Option { + if shared_context.options.disable_style_sharing_cache { + return None; + } + self.cache_mut().lookup(|candidate| { debug_assert_ne!(candidate.element, target); if !candidate.parent_style_identity().eq(inherited) { diff --git a/components/style/style_resolver.rs b/components/style/style_resolver.rs index 41b7ed86237..ee66b56a1d9 100644 --- a/components/style/style_resolver.rs +++ b/components/style/style_resolver.rs @@ -195,6 +195,7 @@ where if may_reuse { let cached = self.context.thread_local.sharing_cache.lookup_by_rules( + self.context.shared, parent_style.unwrap(), inputs.rules.as_ref().unwrap(), inputs.visited_rules.as_ref(), diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 21785498be6..61d9a754293 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -18,7 +18,7 @@ use std::ptr; use style::applicable_declarations::ApplicableDeclarationBlock; use style::context::{CascadeInputs, QuirksMode, SharedStyleContext, StyleContext}; use style::context::ThreadLocalStyleContext; -use style::data::ElementStyles; +use style::data::{ElementStyles, self}; use style::dom::{ShowSubtreeData, TElement, TNode}; use style::driver; use style::element_state::ElementState; @@ -842,13 +842,20 @@ pub extern "C" fn Servo_Element_GetPseudoComputedValues(element: RawGeckoElement } #[no_mangle] -pub extern "C" fn Servo_Element_IsDisplayNone(element: RawGeckoElementBorrowed) -> bool -{ +pub extern "C" fn Servo_Element_IsDisplayNone(element: RawGeckoElementBorrowed) -> bool { let element = GeckoElement(element); let data = element.borrow_data().expect("Invoking Servo_Element_IsDisplayNone on unstyled element"); data.styles.is_display_none() } +#[no_mangle] +pub extern "C" fn Servo_Element_IsPrimaryStyleReusedViaRuleNode(element: RawGeckoElementBorrowed) -> bool { + let element = GeckoElement(element); + let data = element.borrow_data() + .expect("Invoking Servo_Element_IsPrimaryStyleReusedViaRuleNode on unstyled element"); + data.flags.contains(data::PRIMARY_STYLE_REUSED_VIA_RULE_NODE) +} + #[no_mangle] pub extern "C" fn Servo_StyleSheet_Empty(mode: SheetParsingMode) -> RawServoStyleSheetContentsStrong { let global_style_data = &*GLOBAL_STYLE_DATA;