style: Disable :visited if the document is being used as an image.

Bug: 1420001
Reviewed-by: dholbert
MozReview-Commit-ID: F9MeT1kXZER
This commit is contained in:
Emilio Cobos Álvarez 2017-11-24 21:26:30 +01:00
parent 6d49ec83a1
commit f94601d0a7
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C

View file

@ -164,12 +164,20 @@ impl PerDocumentStyleDataImpl {
} }
/// Returns whether private browsing is enabled. /// Returns whether private browsing is enabled.
pub fn is_private_browsing_enabled(&self) -> bool { fn is_private_browsing_enabled(&self) -> bool {
let doc = let doc =
self.stylist.device().pres_context().mDocument.raw::<nsIDocument>(); self.stylist.device().pres_context().mDocument.raw::<nsIDocument>();
unsafe { bindings::Gecko_IsPrivateBrowsingEnabled(doc) } 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. /// Get the default computed values for this document.
pub fn default_computed_values(&self) -> &Arc<ComputedValues> { pub fn default_computed_values(&self) -> &Arc<ComputedValues> {
self.stylist.device().default_computed_values_arc() self.stylist.device().default_computed_values_arc()
@ -179,9 +187,22 @@ impl PerDocumentStyleDataImpl {
fn visited_links_enabled(&self) -> bool { fn visited_links_enabled(&self) -> bool {
unsafe { structs::StylePrefs_sVisitedLinksEnabled } unsafe { structs::StylePrefs_sVisitedLinksEnabled }
} }
/// Returns whether visited styles are enabled. /// Returns whether visited styles are enabled.
pub fn visited_styles_enabled(&self) -> bool { 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. /// Measure heap usage.