mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Make Stylist::quirks_mode hold a QuirksMode
This commit is contained in:
parent
8f1356de60
commit
f872fdac9a
4 changed files with 15 additions and 12 deletions
|
@ -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<LayoutRPC + Send>).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);
|
||||
}
|
||||
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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<Stylesheet>),
|
||||
|
||||
/// 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),
|
||||
|
|
|
@ -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<ViewportConstraints>,
|
||||
|
||||
/// 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.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue