Bug 1341721 Part 3: Pass the author_style_disabled flag through ExtraStyleData and ignore document styles during update, if set.
MozReview-Commit-ID: KmPQGmlkc32
--- a/servo/components/layout_thread/lib.rs
+++ b/servo/components/layout_thread/lib.rs
@@ -1079,16 +1079,17 @@ impl LayoutThread {
let ua_stylesheets = &*UA_STYLESHEETS;
let ua_or_user_guard = ua_stylesheets.shared_lock.read();
let guards = StylesheetGuards {
author: &author_guard,
ua_or_user: &ua_or_user_guard,
};
let mut extra_data = ExtraStyleData {
marker: PhantomData,
+ author_style_disabled: data.author_style_disabled,
};
let needs_dirtying = Arc::get_mut(&mut rw_data.stylist).unwrap().update(
&data.document_stylesheets,
&guards,
Some(ua_stylesheets),
data.stylesheets_changed,
&mut extra_data);
let needs_reflow = viewport_size_changed && !needs_dirtying;
--- a/servo/components/style/gecko/data.rs
+++ b/servo/components/style/gecko/data.rs
@@ -102,16 +102,17 @@ impl PerDocumentStyleDataImpl {
}
/// Recreate the style data if the stylesheets have changed.
pub fn flush_stylesheets(&mut self, guard: &SharedRwLockReadGuard) {
if self.stylesheets_changed {
let mut stylist = Arc::get_mut(&mut self.stylist).unwrap();
let mut extra_data = ExtraStyleData {
font_faces: &mut self.font_faces,
+ author_style_disabled: self.author_style_disabled,
};
stylist.update(&self.stylesheets, &StylesheetGuards::same(guard),
None, true, &mut extra_data);
self.stylesheets_changed = false;
}
}
/// Get the default computed values for this document.
--- a/servo/components/style/stylist.rs
+++ b/servo/components/style/stylist.rs
@@ -123,16 +123,19 @@ pub struct Stylist {
/// This struct holds data which user of Stylist may want to extract
/// from stylesheets which can be done at the same time as updating.
pub struct ExtraStyleData<'a> {
/// A list of effective font-face rules and their origin.
#[cfg(feature = "gecko")]
pub font_faces: &'a mut Vec<(Arc<Locked<FontFaceRule>>, Origin)>,
+ /// A parameter to note whether we should ignore author styles.
+ pub author_style_disabled: bool,
+
#[allow(missing_docs)]
#[cfg(feature = "servo")]
pub marker: PhantomData<&'a usize>,
}
#[cfg(feature = "gecko")]
impl<'a> ExtraStyleData<'a> {
/// Clear the internal @font-face rule list.
@@ -236,18 +239,20 @@ impl Stylist {
}
if self.quirks_mode {
self.add_stylesheet(&ua_stylesheets.quirks_mode_stylesheet,
guards.ua_or_user, extra_data);
}
}
- for ref stylesheet in doc_stylesheets.iter() {
- self.add_stylesheet(stylesheet, guards.author, extra_data);
+ if !extra_data.author_style_disabled {
+ for ref stylesheet in doc_stylesheets.iter() {
+ self.add_stylesheet(stylesheet, guards.author, extra_data);
+ }
}
debug!("Stylist stats:");
debug!(" - Got {} sibling-affecting selectors",
self.sibling_affecting_selectors.len());
debug!(" - Got {} non-common-style-attribute-affecting selectors",
self.style_affecting_attributes_selectors.len());
debug!(" - Got {} deps for style-hint calculation",