From 4abe8002e9c33a633c27c3c0485bd1d2b632c1c8 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 19 Sep 2017 15:04:14 -0700 Subject: [PATCH 1/2] Bug 1401317 - Make second pass sharing sensitive to DISABLE_STYLE_SHARING_CACHE. r=emilio MozReview-Commit-ID: 8U0xekMHGg8 --- components/style/sharing/mod.rs | 5 +++++ components/style/style_resolver.rs | 1 + 2 files changed, 6 insertions(+) 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(), From 8000d425821f2017a1c97f77e6ee97c0627b1b86 Mon Sep 17 00:00:00 2001 From: Bobby Holley Date: Tue, 19 Sep 2017 21:43:31 -0700 Subject: [PATCH 2/2] Bug 1401317 - Disable lazy pseudo caching when the originating element's primary style was reused via the rule node. r=emilio MozReview-Commit-ID: IkBa39E1bR1 --- components/style/gecko/generated/bindings.rs | 5 +++++ ports/geckolib/glue.rs | 13 ++++++++++--- 2 files changed, 15 insertions(+), 3 deletions(-) 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/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index eda8d6f8b4c..0211a0a0387 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; @@ -836,13 +836,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;