diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 2f0fa57e5a3..576588abda8 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -594,6 +594,7 @@ impl LayoutThread { stylist: &self.stylist, options: StyleSystemOptions::default(), guards: guards, + visited_styles_enabled: false, running_animations: self.running_animations.clone(), expired_animations: self.expired_animations.clone(), local_context_creation_data: Mutex::new(thread_local_style_context_creation_data), diff --git a/components/style/context.rs b/components/style/context.rs index e9733cb0985..d53af678a40 100644 --- a/components/style/context.rs +++ b/components/style/context.rs @@ -117,6 +117,9 @@ pub struct SharedStyleContext<'a> { /// The CSS selector stylist. pub stylist: &'a Stylist, + /// Whether visited styles are enabled. + pub visited_styles_enabled: bool, + /// Configuration options. pub options: StyleSystemOptions, diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs index 08cb11a4fe3..f845ec421c2 100644 --- a/components/style/gecko/data.rs +++ b/components/style/gecko/data.rs @@ -187,6 +187,13 @@ impl PerDocumentStyleDataImpl { ); } + /// Returns whether private browsing is enabled. + pub fn is_private_browsing_enabled(&self) -> bool { + let doc = + self.stylist.device().pres_context().mDocument.raw::(); + unsafe { bindings::Gecko_IsPrivateBrowsingEnabled(doc) } + } + /// Get the default computed values for this document. pub fn default_computed_values(&self) -> &Arc { self.stylist.device().default_computed_values_arc() diff --git a/components/style/style_resolver.rs b/components/style/style_resolver.rs index d2c6c545cf9..204f6021907 100644 --- a/components/style/style_resolver.rs +++ b/components/style/style_resolver.rs @@ -12,7 +12,8 @@ use dom::TElement; use log::LogLevel::Trace; use matching::{CascadeVisitedMode, MatchMethods}; use properties::{AnimationRules, CascadeFlags, ComputedValues}; -use properties::{IS_LINK, IS_ROOT_ELEMENT, IS_VISITED_LINK, PROHIBIT_DISPLAY_CONTENTS, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP}; +use properties::{IS_LINK, IS_ROOT_ELEMENT, IS_VISITED_LINK}; +use properties::{PROHIBIT_DISPLAY_CONTENTS, SKIP_ROOT_AND_ITEM_BASED_DISPLAY_FIXUP}; use properties::{VISITED_DEPENDENT_ONLY, cascade}; use rule_tree::StrongRuleNode; use selector_parser::{PseudoElement, SelectorImpl}; @@ -476,7 +477,8 @@ where if pseudo.is_none() && self.element.is_link() { cascade_flags.insert(IS_LINK); - if self.element.is_visited_link() { + if self.element.is_visited_link() && + self.context.shared.visited_styles_enabled { cascade_flags.insert(IS_VISITED_LINK); } } diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs index 0164bf9e280..716f8a3ed5c 100644 --- a/ports/geckolib/glue.rs +++ b/ports/geckolib/glue.rs @@ -182,8 +182,13 @@ fn create_shared_context<'a>(global_style_data: &GlobalStyleData, traversal_flags: TraversalFlags, snapshot_map: &'a ServoElementSnapshotTable) -> SharedStyleContext<'a> { + let visited_styles_enabled = + unsafe { bindings::Gecko_AreVisitedLinksEnabled() } && + !per_doc_data.is_private_browsing_enabled(); + SharedStyleContext { stylist: &per_doc_data.stylist, + visited_styles_enabled: visited_styles_enabled, options: global_style_data.options.clone(), guards: StylesheetGuards::same(guard), timer: Timer::new(),