diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs index c17d3bd9b48..e69e55512d4 100644 --- a/components/layout_thread/lib.rs +++ b/components/layout_thread/lib.rs @@ -601,7 +601,7 @@ impl LayoutThread { Msg::AddStylesheet(style_info) => { self.handle_add_stylesheet(style_info, possibly_locked_rw_data) } - Msg::SetQuirksMode => self.handle_set_quirks_mode(possibly_locked_rw_data), + Msg::SetQuirksMode(mode) => self.handle_set_quirks_mode(possibly_locked_rw_data, mode), Msg::GetRPC(response_chan) => { response_chan.send(box LayoutRPCImpl(self.rw_data.clone()) as Box).unwrap(); @@ -772,9 +772,11 @@ impl LayoutThread { } /// Sets quirks mode for the document, causing the quirks mode stylesheet to be used. - fn handle_set_quirks_mode<'a, 'b>(&self, possibly_locked_rw_data: &mut RwData<'a, 'b>) { + fn handle_set_quirks_mode<'a, 'b>(&self, + possibly_locked_rw_data: &mut RwData<'a, 'b>, + quirks_mode: QuirksMode) { let mut rw_data = possibly_locked_rw_data.lock(); - Arc::get_mut(&mut rw_data.stylist).unwrap().set_quirks_mode(true); + Arc::get_mut(&mut rw_data.stylist).unwrap().set_quirks_mode(quirks_mode); possibly_locked_rw_data.block(rw_data); } diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs index ab124ba1734..06b8f7596cf 100644 --- a/components/script/dom/document.rs +++ b/components/script/dom/document.rs @@ -542,7 +542,7 @@ impl Document { self.quirks_mode.set(mode); if mode == QuirksMode::Quirks { - self.window.layout_chan().send(Msg::SetQuirksMode).unwrap(); + self.window.layout_chan().send(Msg::SetQuirksMode(mode)).unwrap(); } } diff --git a/components/script_layout_interface/message.rs b/components/script_layout_interface/message.rs index 69dfd125e12..b94b6cd8d14 100644 --- a/components/script_layout_interface/message.rs +++ b/components/script_layout_interface/message.rs @@ -17,7 +17,7 @@ use script_traits::{LayoutMsg as ConstellationMsg, StackingContextScrollState, W use servo_url::ServoUrl; use std::sync::Arc; use std::sync::mpsc::{Receiver, Sender}; -use style::context::ReflowGoal; +use style::context::{QuirksMode, ReflowGoal}; use style::properties::PropertyId; use style::selector_parser::PseudoElement; use style::stylesheets::Stylesheet; @@ -27,8 +27,8 @@ pub enum Msg { /// Adds the given stylesheet to the document. AddStylesheet(Arc), - /// Puts a document into quirks mode, causing the quirks mode stylesheet to be loaded. - SetQuirksMode, + /// Change the quirks mode. + SetQuirksMode(QuirksMode), /// Requests a reflow. Reflow(ScriptReflow), diff --git a/components/style/stylist.rs b/components/style/stylist.rs index 8ae9998c4cb..190226bb0cc 100644 --- a/components/style/stylist.rs +++ b/components/style/stylist.rs @@ -8,6 +8,7 @@ use {Atom, LocalName}; use bit_vec::BitVec; +use context::QuirksMode; use data::ComputedStyle; use dom::{AnimationRules, PresentationalHintsSynthetizer, TElement}; use error_reporting::RustLogReporter; @@ -75,7 +76,7 @@ pub struct Stylist { viewport_constraints: Option, /// If true, the quirks-mode stylesheet is applied. - quirks_mode: bool, + quirks_mode: QuirksMode, /// If true, the device has changed, and the stylist needs to be updated. is_device_dirty: bool, @@ -165,7 +166,7 @@ impl Stylist { viewport_constraints: None, device: Arc::new(device), is_device_dirty: true, - quirks_mode: false, + quirks_mode: QuirksMode::NoQuirks, element_map: PerPseudoElementSelectorMap::new(), pseudos_map: Default::default(), @@ -268,7 +269,7 @@ impl Stylist { self.add_stylesheet(&stylesheet, guards.ua_or_user, extra_data); } - if self.quirks_mode { + if self.quirks_mode != QuirksMode::NoQuirks { self.add_stylesheet(&ua_stylesheets.quirks_mode_stylesheet, guards.ua_or_user, extra_data); } @@ -610,14 +611,14 @@ impl Stylist { } /// Sets the quirks mode of the document. - pub fn set_quirks_mode(&mut self, enabled: bool) { + pub fn set_quirks_mode(&mut self, quirks_mode: QuirksMode) { // FIXME(emilio): We don't seem to change the quirks mode dynamically // during multiple layout passes, but this is totally bogus, in the // sense that it's updated asynchronously. // // This should probably be an argument to `update`, and use the quirks // mode info in the `SharedLayoutContext`. - self.quirks_mode = enabled; + self.quirks_mode = quirks_mode; } /// Returns the applicable CSS declarations for the given element.