stylo: Honor the relevant link visited pref.

MozReview-Commit-ID: D5NiEJUpONQ
This commit is contained in:
Emilio Cobos Álvarez 2017-07-23 17:37:46 +02:00
parent 04e855c38d
commit 9b2d96f7e7
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
5 changed files with 20 additions and 2 deletions

View file

@ -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),

View file

@ -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,

View file

@ -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::<nsIDocument>();
unsafe { bindings::Gecko_IsPrivateBrowsingEnabled(doc) }
}
/// Get the default computed values for this document.
pub fn default_computed_values(&self) -> &Arc<ComputedValues> {
self.stylist.device().default_computed_values_arc()

View file

@ -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);
}
}

View file

@ -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(),