Skip to content

Commit

Permalink
Auto merge of #19398 - emilio:visited-as-an-image, r=dholbert
Browse files Browse the repository at this point in the history
style: Disable :visited if the document is being used as an image.

Bug: 1420001
Reviewed-by: dholbert
MozReview-Commit-ID: F9MeT1kXZER
  • Loading branch information
bors-servo committed Nov 27, 2017
2 parents 769b643 + f94601d commit 7c99ae3
Showing 1 changed file with 23 additions and 2 deletions.
25 changes: 23 additions & 2 deletions components/style/gecko/data.rs
Expand Up @@ -164,12 +164,20 @@ impl PerDocumentStyleDataImpl {
}

/// Returns whether private browsing is enabled.
pub fn is_private_browsing_enabled(&self) -> bool {
fn is_private_browsing_enabled(&self) -> bool {
let doc =
self.stylist.device().pres_context().mDocument.raw::<nsIDocument>();
unsafe { bindings::Gecko_IsPrivateBrowsingEnabled(doc) }
}

/// Returns whether the document is being used as an image.
fn is_being_used_as_an_image(&self) -> bool {
let doc =
self.stylist.device().pres_context().mDocument.raw::<nsIDocument>();

unsafe { (*doc).mIsBeingUsedAsImage() }
}

/// Get the default computed values for this document.
pub fn default_computed_values(&self) -> &Arc<ComputedValues> {
self.stylist.device().default_computed_values_arc()
Expand All @@ -179,9 +187,22 @@ impl PerDocumentStyleDataImpl {
fn visited_links_enabled(&self) -> bool {
unsafe { structs::StylePrefs_sVisitedLinksEnabled }
}

/// Returns whether visited styles are enabled.
pub fn visited_styles_enabled(&self) -> bool {
self.visited_links_enabled() && !self.is_private_browsing_enabled()
if !self.visited_links_enabled() {
return false;
}

if self.is_private_browsing_enabled() {
return false;
}

if self.is_being_used_as_an_image() {
return false;
}

true
}

/// Measure heap usage.
Expand Down

0 comments on commit 7c99ae3

Please sign in to comment.