From 5be81d04a77a96407d9c6fce534a6c0654cf96f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Thu, 14 Sep 2017 20:55:45 +0200 Subject: [PATCH] style: Clear the UA cache on shutdown. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit MozReview-Commit-ID: KAGdhFb67hq Signed-off-by: Emilio Cobos Álvarez --- components/style/stylist.rs | 9 +++++++++ ports/geckolib/glue.rs | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 8dcf9aace05..841b7483a8e 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -131,6 +131,10 @@ impl UserAgentCascadeDataCache { fn expire_unused(&mut self) { self.entries.retain(|e| !e.is_unique()) } + + fn clear(&mut self) { + self.entries.clear(); + } } type PrecomputedPseudoElementDeclarations = @@ -1502,6 +1506,11 @@ impl Stylist { // We may measure other fields in the future if DMD says it's worth it. } + + /// Shutdown the static data that this module stores. + pub fn shutdown() { + UA_CASCADE_DATA_CACHE.lock().unwrap().clear() + } } /// This struct holds data which users of Stylist may want to extract diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 452f373b0ff..46efbc51aef 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -130,7 +130,7 @@ use style::stylesheets::{StylesheetContents, SupportsRule}; use style::stylesheets::StylesheetLoader as StyleStylesheetLoader; use style::stylesheets::keyframes_rule::{Keyframe, KeyframeSelector, KeyframesStepValue}; use style::stylesheets::supports_rule::parse_condition_or_declaration; -use style::stylist::RuleInclusion; +use style::stylist::{RuleInclusion, Stylist}; use style::thread_state; use style::timer::Timer; use style::traversal::DomTraversal; @@ -186,6 +186,7 @@ pub extern "C" fn Servo_Shutdown() { // The dummy url will be released after shutdown, so clear the // reference to avoid use-after-free. unsafe { DUMMY_URL_DATA = ptr::null_mut(); } + Stylist::shutdown(); } unsafe fn dummy_url_data() -> &'static RefPtr {