Skip to content

Commit

Permalink
style: Simplify author_style_disabled handling.
Browse files Browse the repository at this point in the history
  • Loading branch information
emilio committed Apr 19, 2017
1 parent 97235d0 commit 4651b94
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 20 deletions.
2 changes: 1 addition & 1 deletion components/layout_thread/lib.rs
Expand Up @@ -1083,14 +1083,14 @@ impl LayoutThread {
ua_or_user: &ua_or_user_guard,
};
let mut extra_data = ExtraStyleData {
author_style_disabled: None,
marker: PhantomData,
};
let needs_dirtying = Arc::get_mut(&mut rw_data.stylist).unwrap().update(
&data.document_stylesheets,
&guards,
Some(ua_stylesheets),
data.stylesheets_changed,
/* author_styles_disabled = */ false,
&mut extra_data);
let needs_reflow = viewport_size_changed && !needs_dirtying;
if needs_dirtying {
Expand Down
10 changes: 7 additions & 3 deletions components/style/gecko/data.rs
Expand Up @@ -103,12 +103,16 @@ impl PerDocumentStyleDataImpl {
let mut stylist = Arc::get_mut(&mut self.stylist).unwrap();
let mut extra_data = ExtraStyleData {
font_faces: &mut self.font_faces,
author_style_disabled: Some(self.stylesheets.author_style_disabled()),
};

stylist.update(&self.stylesheets.flush(),
let author_style_disabled = self.stylesheets.author_style_disabled();
let stylesheets = self.stylesheets.flush();
stylist.update(stylesheets,
&StylesheetGuards::same(guard),
None, true, &mut extra_data);
/* ua_sheets = */ None,
/* stylesheets_changed = */ true,
author_style_disabled,
&mut extra_data);
}

/// Get the default computed values for this document.
Expand Down
21 changes: 5 additions & 16 deletions components/style/stylist.rs
Expand Up @@ -78,9 +78,6 @@ pub struct Stylist {
/// If true, the quirks-mode stylesheet is applied.
quirks_mode: bool,

/// If true, authored styles are ignored.
author_style_disabled: bool,

/// If true, the device has changed, and the stylist needs to be updated.
is_device_dirty: bool,

Expand Down Expand Up @@ -137,10 +134,6 @@ pub struct ExtraStyleData<'a> {
#[cfg(feature = "gecko")]
pub font_faces: &'a mut Vec<(Arc<Locked<FontFaceRule>>, Origin)>,

/// A parameter to change a setting to ignore author styles during update.
/// A None value indicates that update should use existing settings.
pub author_style_disabled: Option<bool>,

#[allow(missing_docs)]
#[cfg(feature = "servo")]
pub marker: PhantomData<&'a usize>,
Expand Down Expand Up @@ -174,7 +167,6 @@ impl Stylist {
device: Arc::new(device),
is_device_dirty: true,
quirks_mode: false,
author_style_disabled: false,

element_map: PerPseudoElementSelectorMap::new(),
pseudos_map: Default::default(),
Expand Down Expand Up @@ -234,6 +226,7 @@ impl Stylist {
guards: &StylesheetGuards,
ua_stylesheets: Option<&UserAgentStylesheets>,
stylesheets_changed: bool,
author_style_disabled: bool,
extra_data: &mut ExtraStyleData<'a>) -> bool {
if !(self.is_device_dirty || stylesheets_changed) {
return false;
Expand Down Expand Up @@ -282,15 +275,11 @@ impl Stylist {
}
}

// Absorb changes to author_style_disabled, if supplied.
if let Some(author_style_disabled) = extra_data.author_style_disabled {
self.author_style_disabled = author_style_disabled;
}

// Only use author stylesheets if author styles are enabled.
let author_style_enabled = !self.author_style_disabled;
let sheets_to_add = doc_stylesheets.iter().filter(
|&s| author_style_enabled || s.origin != Origin::Author);
let sheets_to_add = doc_stylesheets.iter().filter(|s| {
!author_style_disabled || s.origin != Origin::Author
});

for ref stylesheet in sheets_to_add {
self.add_stylesheet(stylesheet, guards.author, extra_data);
}
Expand Down

0 comments on commit 4651b94

Please sign in to comment.