mirror of
https://github.com/servo/servo.git
synced 2025-07-22 23:03:42 +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) => {
|
Msg::AddStylesheet(style_info) => {
|
||||||
self.handle_add_stylesheet(style_info, possibly_locked_rw_data)
|
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) => {
|
Msg::GetRPC(response_chan) => {
|
||||||
response_chan.send(box LayoutRPCImpl(self.rw_data.clone()) as
|
response_chan.send(box LayoutRPCImpl(self.rw_data.clone()) as
|
||||||
Box<LayoutRPC + Send>).unwrap();
|
Box<LayoutRPC + Send>).unwrap();
|
||||||
|
@ -772,9 +772,11 @@ impl LayoutThread {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets quirks mode for the document, causing the quirks mode stylesheet to be used.
|
/// 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();
|
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);
|
possibly_locked_rw_data.block(rw_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -542,7 +542,7 @@ impl Document {
|
||||||
self.quirks_mode.set(mode);
|
self.quirks_mode.set(mode);
|
||||||
|
|
||||||
if mode == QuirksMode::Quirks {
|
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 servo_url::ServoUrl;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::sync::mpsc::{Receiver, Sender};
|
use std::sync::mpsc::{Receiver, Sender};
|
||||||
use style::context::ReflowGoal;
|
use style::context::{QuirksMode, ReflowGoal};
|
||||||
use style::properties::PropertyId;
|
use style::properties::PropertyId;
|
||||||
use style::selector_parser::PseudoElement;
|
use style::selector_parser::PseudoElement;
|
||||||
use style::stylesheets::Stylesheet;
|
use style::stylesheets::Stylesheet;
|
||||||
|
@ -27,8 +27,8 @@ pub enum Msg {
|
||||||
/// Adds the given stylesheet to the document.
|
/// Adds the given stylesheet to the document.
|
||||||
AddStylesheet(Arc<Stylesheet>),
|
AddStylesheet(Arc<Stylesheet>),
|
||||||
|
|
||||||
/// Puts a document into quirks mode, causing the quirks mode stylesheet to be loaded.
|
/// Change the quirks mode.
|
||||||
SetQuirksMode,
|
SetQuirksMode(QuirksMode),
|
||||||
|
|
||||||
/// Requests a reflow.
|
/// Requests a reflow.
|
||||||
Reflow(ScriptReflow),
|
Reflow(ScriptReflow),
|
||||||
|
|
|
@ -8,6 +8,7 @@
|
||||||
|
|
||||||
use {Atom, LocalName};
|
use {Atom, LocalName};
|
||||||
use bit_vec::BitVec;
|
use bit_vec::BitVec;
|
||||||
|
use context::QuirksMode;
|
||||||
use data::ComputedStyle;
|
use data::ComputedStyle;
|
||||||
use dom::{AnimationRules, PresentationalHintsSynthetizer, TElement};
|
use dom::{AnimationRules, PresentationalHintsSynthetizer, TElement};
|
||||||
use error_reporting::RustLogReporter;
|
use error_reporting::RustLogReporter;
|
||||||
|
@ -75,7 +76,7 @@ pub struct Stylist {
|
||||||
viewport_constraints: Option<ViewportConstraints>,
|
viewport_constraints: Option<ViewportConstraints>,
|
||||||
|
|
||||||
/// If true, the quirks-mode stylesheet is applied.
|
/// 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.
|
/// If true, the device has changed, and the stylist needs to be updated.
|
||||||
is_device_dirty: bool,
|
is_device_dirty: bool,
|
||||||
|
@ -165,7 +166,7 @@ impl Stylist {
|
||||||
viewport_constraints: None,
|
viewport_constraints: None,
|
||||||
device: Arc::new(device),
|
device: Arc::new(device),
|
||||||
is_device_dirty: true,
|
is_device_dirty: true,
|
||||||
quirks_mode: false,
|
quirks_mode: QuirksMode::NoQuirks,
|
||||||
|
|
||||||
element_map: PerPseudoElementSelectorMap::new(),
|
element_map: PerPseudoElementSelectorMap::new(),
|
||||||
pseudos_map: Default::default(),
|
pseudos_map: Default::default(),
|
||||||
|
@ -268,7 +269,7 @@ impl Stylist {
|
||||||
self.add_stylesheet(&stylesheet, guards.ua_or_user, extra_data);
|
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,
|
self.add_stylesheet(&ua_stylesheets.quirks_mode_stylesheet,
|
||||||
guards.ua_or_user, extra_data);
|
guards.ua_or_user, extra_data);
|
||||||
}
|
}
|
||||||
|
@ -610,14 +611,14 @@ impl Stylist {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Sets the quirks mode of the document.
|
/// 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
|
// FIXME(emilio): We don't seem to change the quirks mode dynamically
|
||||||
// during multiple layout passes, but this is totally bogus, in the
|
// during multiple layout passes, but this is totally bogus, in the
|
||||||
// sense that it's updated asynchronously.
|
// sense that it's updated asynchronously.
|
||||||
//
|
//
|
||||||
// This should probably be an argument to `update`, and use the quirks
|
// This should probably be an argument to `update`, and use the quirks
|
||||||
// mode info in the `SharedLayoutContext`.
|
// mode info in the `SharedLayoutContext`.
|
||||||
self.quirks_mode = enabled;
|
self.quirks_mode = quirks_mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Returns the applicable CSS declarations for the given element.
|
/// Returns the applicable CSS declarations for the given element.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue