mirror of
https://github.com/servo/servo.git
synced 2025-08-02 20:20:14 +01:00
style: Implement quirks mode rules.
This commit is contained in:
parent
56b78de5bc
commit
17835ba0cb
4 changed files with 33 additions and 2 deletions
|
@ -40,7 +40,7 @@ use script::layout_interface::{ContentBoxesQuery, ContentBoxQuery, ExitNowMsg, G
|
||||||
use script::layout_interface::{HitTestResponse, LayoutChan, LayoutRPC, LoadStylesheetMsg};
|
use script::layout_interface::{HitTestResponse, LayoutChan, LayoutRPC, LoadStylesheetMsg};
|
||||||
use script::layout_interface::{MouseOverResponse, Msg, NoQuery, PrepareToExitMsg};
|
use script::layout_interface::{MouseOverResponse, Msg, NoQuery, PrepareToExitMsg};
|
||||||
use script::layout_interface::{ReapLayoutDataMsg, Reflow, ReflowForDisplay, ReflowMsg};
|
use script::layout_interface::{ReapLayoutDataMsg, Reflow, ReflowForDisplay, ReflowMsg};
|
||||||
use script::layout_interface::{ScriptLayoutChan, TrustedNodeAddress};
|
use script::layout_interface::{ScriptLayoutChan, SetQuirksModeMsg, TrustedNodeAddress};
|
||||||
use script_traits::{SendEventMsg, ReflowEvent, ReflowCompleteMsg, OpaqueScriptLayoutChannel};
|
use script_traits::{SendEventMsg, ReflowEvent, ReflowCompleteMsg, OpaqueScriptLayoutChannel};
|
||||||
use script_traits::{ScriptControlChan, UntrustedNodeAddress};
|
use script_traits::{ScriptControlChan, UntrustedNodeAddress};
|
||||||
use servo_msg::compositor_msg::Scrollable;
|
use servo_msg::compositor_msg::Scrollable;
|
||||||
|
@ -390,6 +390,7 @@ impl LayoutTask {
|
||||||
match request {
|
match request {
|
||||||
AddStylesheetMsg(sheet) => self.handle_add_stylesheet(sheet, possibly_locked_rw_data),
|
AddStylesheetMsg(sheet) => self.handle_add_stylesheet(sheet, possibly_locked_rw_data),
|
||||||
LoadStylesheetMsg(url) => self.handle_load_stylesheet(url, possibly_locked_rw_data),
|
LoadStylesheetMsg(url) => self.handle_load_stylesheet(url, possibly_locked_rw_data),
|
||||||
|
SetQuirksModeMsg => self.handle_set_quirks_mode(possibly_locked_rw_data),
|
||||||
GetRPCMsg(response_chan) => {
|
GetRPCMsg(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>);
|
Box<LayoutRPC + Send>);
|
||||||
|
@ -500,6 +501,15 @@ impl LayoutTask {
|
||||||
LayoutTask::return_rw_data(possibly_locked_rw_data, rw_data);
|
LayoutTask::return_rw_data(possibly_locked_rw_data, rw_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Sets quirks mode for the document, causing the quirks mode stylesheet to be loaded.
|
||||||
|
fn handle_set_quirks_mode<'a>(&'a self,
|
||||||
|
possibly_locked_rw_data:
|
||||||
|
&mut Option<MutexGuard<'a, LayoutTaskData>>) {
|
||||||
|
let mut rw_data = self.lock_rw_data(possibly_locked_rw_data);
|
||||||
|
rw_data.stylist.add_quirks_mode_stylesheet();
|
||||||
|
LayoutTask::return_rw_data(possibly_locked_rw_data, rw_data);
|
||||||
|
}
|
||||||
|
|
||||||
/// Retrieves the flow tree root from the root node.
|
/// Retrieves the flow tree root from the root node.
|
||||||
fn try_get_layout_root(&self, node: LayoutNode) -> Option<FlowRef> {
|
fn try_get_layout_root(&self, node: LayoutNode) -> Option<FlowRef> {
|
||||||
let mut layout_data_ref = node.mutate_layout_data();
|
let mut layout_data_ref = node.mutate_layout_data();
|
||||||
|
|
|
@ -61,6 +61,7 @@ use servo_util::namespace;
|
||||||
use servo_util::str::{DOMString, split_html_space_chars};
|
use servo_util::str::{DOMString, split_html_space_chars};
|
||||||
|
|
||||||
use html5ever::tree_builder::{QuirksMode, NoQuirks, LimitedQuirks, Quirks};
|
use html5ever::tree_builder::{QuirksMode, NoQuirks, LimitedQuirks, Quirks};
|
||||||
|
use layout_interface::{LayoutChan, SetQuirksModeMsg};
|
||||||
use string_cache::{Atom, QualName};
|
use string_cache::{Atom, QualName};
|
||||||
use url::Url;
|
use url::Url;
|
||||||
|
|
||||||
|
@ -217,6 +218,15 @@ impl<'a> DocumentHelpers<'a> for JSRef<'a, Document> {
|
||||||
|
|
||||||
fn set_quirks_mode(self, mode: QuirksMode) {
|
fn set_quirks_mode(self, mode: QuirksMode) {
|
||||||
self.quirks_mode.set(mode);
|
self.quirks_mode.set(mode);
|
||||||
|
|
||||||
|
match mode {
|
||||||
|
Quirks => {
|
||||||
|
let window = self.window.root();
|
||||||
|
let LayoutChan(ref layout_chan) = window.page().layout_chan;
|
||||||
|
layout_chan.send(SetQuirksModeMsg);
|
||||||
|
}
|
||||||
|
NoQuirks | LimitedQuirks => {}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn set_last_modified(self, value: DOMString) {
|
fn set_last_modified(self, value: DOMString) {
|
||||||
|
|
|
@ -29,6 +29,9 @@ pub enum Msg {
|
||||||
/// Adds the given stylesheet to the document.
|
/// Adds the given stylesheet to the document.
|
||||||
LoadStylesheetMsg(Url),
|
LoadStylesheetMsg(Url),
|
||||||
|
|
||||||
|
/// Puts a document into quirks mode, causing the quirks mode stylesheet to be loaded.
|
||||||
|
SetQuirksModeMsg,
|
||||||
|
|
||||||
/// Requests a reflow.
|
/// Requests a reflow.
|
||||||
ReflowMsg(Box<Reflow>),
|
ReflowMsg(Box<Reflow>),
|
||||||
|
|
||||||
|
|
|
@ -292,7 +292,6 @@ impl Stylist {
|
||||||
after_map: PerPseudoElementSelectorMap::new(),
|
after_map: PerPseudoElementSelectorMap::new(),
|
||||||
rules_source_order: 0u,
|
rules_source_order: 0u,
|
||||||
};
|
};
|
||||||
// FIXME: Add quirks-mode.css in quirks mode.
|
|
||||||
// FIXME: Add iso-8859-9.css when the document’s encoding is ISO-8859-8.
|
// FIXME: Add iso-8859-9.css when the document’s encoding is ISO-8859-8.
|
||||||
// FIXME: presentational-hints.css should be at author origin with zero specificity.
|
// FIXME: presentational-hints.css should be at author origin with zero specificity.
|
||||||
// (Does it make a difference?)
|
// (Does it make a difference?)
|
||||||
|
@ -388,6 +387,15 @@ impl Stylist {
|
||||||
self.is_dirty |= is_dirty;
|
self.is_dirty |= is_dirty;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn add_quirks_mode_stylesheet(&mut self) {
|
||||||
|
self.add_stylesheet(Stylesheet::from_bytes(
|
||||||
|
read_resource_file(["quirks-mode.css"]).unwrap().as_slice(),
|
||||||
|
Url::parse("chrome:///quirks-mode.css").unwrap(),
|
||||||
|
None,
|
||||||
|
None,
|
||||||
|
UserAgentOrigin))
|
||||||
|
}
|
||||||
|
|
||||||
pub fn add_stylesheet(&mut self, stylesheet: Stylesheet) {
|
pub fn add_stylesheet(&mut self, stylesheet: Stylesheet) {
|
||||||
self.stylesheets.push(stylesheet);
|
self.stylesheets.push(stylesheet);
|
||||||
self.is_dirty = true;
|
self.is_dirty = true;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue