Bug 1420001 - style: Disable :visited if the document is being used as an image (from emilio:visited-as-an-image). r=dholbert, a=abillings
authorEmilio Cobos Álvarez <emilio@crisal.io>
Mon, 27 Nov 2017 14:57:57 -0600
changeset 444994 d1599028c579f31e1441b9df277bf8f38c0e7f56
parent 444993 a34fb2beb5f389057ea35ec120401a2d28bd46a4
child 444995 be010bf7bfcc8b7c2023b3562f05c19fa7a5272a
push id1618
push userCallek@gmail.com
push dateThu, 11 Jan 2018 17:45:48 +0000
treeherdermozilla-release@882ca853e05a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert, abillings
bugs1420001
milestone58.0
Bug 1420001 - style: Disable :visited if the document is being used as an image (from emilio:visited-as-an-image). r=dholbert, a=abillings MozReview-Commit-ID: F9MeT1kXZER Source-Repo: https://github.com/servo/servo Source-Revision: 7c99ae3bb8056f7e30a3b40340200eced385902d
servo/components/style/gecko/data.rs
--- a/servo/components/style/gecko/data.rs
+++ b/servo/components/style/gecko/data.rs
@@ -160,34 +160,55 @@ impl PerDocumentStyleDataImpl {
     {
         self.stylist.flush(
             &StylesheetGuards::same(guard),
             document_element,
         )
     }
 
     /// 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()
     }
 
     /// Returns whether visited links are enabled.
     fn visited_links_enabled(&self) -> bool {
         unsafe { bindings::Gecko_AreVisitedLinksEnabled() }
     }
+
     /// 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.
     pub fn add_size_of(&self, ops: &mut MallocSizeOfOps, sizes: &mut ServoStyleSetSizes) {
         self.stylist.add_size_of(ops, sizes);
     }
 }