servo: Merge #19398 - style: Disable :visited if the document is being used as an image (from emilio:visited-as-an-image); r=dholbert

Bug: 1420001
Reviewed-by: dholbert
MozReview-Commit-ID: F9MeT1kXZER
Source-Repo: https://github.com/servo/servo
Source-Revision: 7c99ae3bb8056f7e30a3b40340200eced385902d

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : 1dbc92124efa960b3c4e4b83dd6aa02576dc0ade
This commit is contained in:
Emilio Cobos Álvarez 2017-11-27 14:57:57 -06:00
Родитель 78b70a134c
Коммит e264f3413f
1 изменённых файлов: 23 добавлений и 2 удалений

Просмотреть файл

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