From 4651b94ff0d180691442c357b6d6c6ae96860e80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Emilio=20Cobos=20=C3=81lvarez?= Date: Tue, 18 Apr 2017 18:55:38 +0200 Subject: [PATCH] style: Simplify author_style_disabled handling. --- components/layout_thread/lib.rs | 2 +- components/style/gecko/data.rs | 10 +++++++--- components/style/stylist.rs | 21 +++++---------------- 3 files changed, 13 insertions(+), 20 deletions(-) diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index 9683afcbd29..286d49484f6 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -1083,7 +1083,6 @@ 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( @@ -1091,6 +1090,7 @@ impl LayoutThread { &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 { diff --git a/components/style/gecko/data.rs b/components/style/gecko/data.rs index 43596bfefb4..7efad2a9fbe 100644 --- a/components/style/gecko/data.rs +++ b/components/style/gecko/data.rs @@ -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. diff --git a/components/style/stylist.rs b/components/style/stylist.rs index d91a4b6250d..35037a6b152 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -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, @@ -137,10 +134,6 @@ pub struct ExtraStyleData<'a> { #[cfg(feature = "gecko")] pub font_faces: &'a mut Vec<(Arc>, 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, - #[allow(missing_docs)] #[cfg(feature = "servo")] pub marker: PhantomData<&'a usize>, @@ -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(), @@ -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; @@ -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); }