mirror of
https://github.com/servo/servo.git
synced 2025-08-04 13:10:20 +01:00
style: Simplify author_style_disabled handling.
This commit is contained in:
parent
97235d0bf7
commit
4651b94ff0
3 changed files with 13 additions and 20 deletions
|
@ -1083,7 +1083,6 @@ impl LayoutThread {
|
||||||
ua_or_user: &ua_or_user_guard,
|
ua_or_user: &ua_or_user_guard,
|
||||||
};
|
};
|
||||||
let mut extra_data = ExtraStyleData {
|
let mut extra_data = ExtraStyleData {
|
||||||
author_style_disabled: None,
|
|
||||||
marker: PhantomData,
|
marker: PhantomData,
|
||||||
};
|
};
|
||||||
let needs_dirtying = Arc::get_mut(&mut rw_data.stylist).unwrap().update(
|
let needs_dirtying = Arc::get_mut(&mut rw_data.stylist).unwrap().update(
|
||||||
|
@ -1091,6 +1090,7 @@ impl LayoutThread {
|
||||||
&guards,
|
&guards,
|
||||||
Some(ua_stylesheets),
|
Some(ua_stylesheets),
|
||||||
data.stylesheets_changed,
|
data.stylesheets_changed,
|
||||||
|
/* author_styles_disabled = */ false,
|
||||||
&mut extra_data);
|
&mut extra_data);
|
||||||
let needs_reflow = viewport_size_changed && !needs_dirtying;
|
let needs_reflow = viewport_size_changed && !needs_dirtying;
|
||||||
if needs_dirtying {
|
if needs_dirtying {
|
||||||
|
|
|
@ -103,12 +103,16 @@ impl PerDocumentStyleDataImpl {
|
||||||
let mut stylist = Arc::get_mut(&mut self.stylist).unwrap();
|
let mut stylist = Arc::get_mut(&mut self.stylist).unwrap();
|
||||||
let mut extra_data = ExtraStyleData {
|
let mut extra_data = ExtraStyleData {
|
||||||
font_faces: &mut self.font_faces,
|
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),
|
&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.
|
/// Get the default computed values for this document.
|
||||||
|
|
|
@ -78,9 +78,6 @@ pub struct Stylist {
|
||||||
/// If true, the quirks-mode stylesheet is applied.
|
/// If true, the quirks-mode stylesheet is applied.
|
||||||
quirks_mode: bool,
|
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.
|
/// If true, the device has changed, and the stylist needs to be updated.
|
||||||
is_device_dirty: bool,
|
is_device_dirty: bool,
|
||||||
|
|
||||||
|
@ -137,10 +134,6 @@ pub struct ExtraStyleData<'a> {
|
||||||
#[cfg(feature = "gecko")]
|
#[cfg(feature = "gecko")]
|
||||||
pub font_faces: &'a mut Vec<(Arc<Locked<FontFaceRule>>, Origin)>,
|
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)]
|
#[allow(missing_docs)]
|
||||||
#[cfg(feature = "servo")]
|
#[cfg(feature = "servo")]
|
||||||
pub marker: PhantomData<&'a usize>,
|
pub marker: PhantomData<&'a usize>,
|
||||||
|
@ -174,7 +167,6 @@ impl Stylist {
|
||||||
device: Arc::new(device),
|
device: Arc::new(device),
|
||||||
is_device_dirty: true,
|
is_device_dirty: true,
|
||||||
quirks_mode: false,
|
quirks_mode: false,
|
||||||
author_style_disabled: false,
|
|
||||||
|
|
||||||
element_map: PerPseudoElementSelectorMap::new(),
|
element_map: PerPseudoElementSelectorMap::new(),
|
||||||
pseudos_map: Default::default(),
|
pseudos_map: Default::default(),
|
||||||
|
@ -234,6 +226,7 @@ impl Stylist {
|
||||||
guards: &StylesheetGuards,
|
guards: &StylesheetGuards,
|
||||||
ua_stylesheets: Option<&UserAgentStylesheets>,
|
ua_stylesheets: Option<&UserAgentStylesheets>,
|
||||||
stylesheets_changed: bool,
|
stylesheets_changed: bool,
|
||||||
|
author_style_disabled: bool,
|
||||||
extra_data: &mut ExtraStyleData<'a>) -> bool {
|
extra_data: &mut ExtraStyleData<'a>) -> bool {
|
||||||
if !(self.is_device_dirty || stylesheets_changed) {
|
if !(self.is_device_dirty || stylesheets_changed) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -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.
|
// 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| {
|
||||||
let sheets_to_add = doc_stylesheets.iter().filter(
|
!author_style_disabled || s.origin != Origin::Author
|
||||||
|&s| author_style_enabled || s.origin != Origin::Author);
|
});
|
||||||
|
|
||||||
for ref stylesheet in sheets_to_add {
|
for ref stylesheet in sheets_to_add {
|
||||||
self.add_stylesheet(stylesheet, guards.author, extra_data);
|
self.add_stylesheet(stylesheet, guards.author, extra_data);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue