mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
stylo: Honor the relevant link visited pref.
MozReview-Commit-ID: D5NiEJUpONQ
This commit is contained in:
parent
04e855c38d
commit
9b2d96f7e7
5 changed files with 20 additions and 2 deletions
|
@ -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),
|
||||
|
|
|
@ -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,
|
||||
|
||||
|
|
|
@ -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()
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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(),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue