aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/layout_thread/lib.rs8
-rw-r--r--components/script/dom/bindings/trace.rs2
-rw-r--r--components/script/dom/document.rs17
-rw-r--r--components/script/dom/element.rs27
-rw-r--r--components/script/dom/node.rs2
-rw-r--r--components/script/dom/servoparser/html.rs6
-rw-r--r--components/script/layout_wrapper.rs6
-rw-r--r--components/style/context.rs11
-rw-r--r--ports/geckolib/glue.rs4
9 files changed, 58 insertions, 25 deletions
diff --git a/components/layout_thread/lib.rs b/components/layout_thread/lib.rs
index 21bcd894a0d..d2bdf3a8f35 100644
--- a/components/layout_thread/lib.rs
+++ b/components/layout_thread/lib.rs
@@ -110,7 +110,7 @@ use std::sync::atomic::{AtomicUsize, Ordering};
use std::sync::mpsc::{Receiver, Sender, channel};
use std::thread;
use style::animation::Animation;
-use style::context::{ReflowGoal, SharedStyleContext, ThreadLocalStyleContextCreationInfo};
+use style::context::{QuirksMode, ReflowGoal, SharedStyleContext, ThreadLocalStyleContextCreationInfo};
use style::data::StoredRestyleHint;
use style::dom::{ShowSubtree, ShowSubtreeDataAndPrimaryValues, TElement, TNode};
use style::error_reporting::{ParseErrorReporter, StdoutErrorReporter};
@@ -233,6 +233,9 @@ pub struct LayoutThread {
// Number of layout threads. This is copied from `servo_config::opts`, but we'd
// rather limit the dependency on that module here.
layout_threads: usize,
+
+ /// Which quirks mode are we rendering the document in?
+ quirks_mode: Option<QuirksMode>
}
impl LayoutThreadFactory for LayoutThread {
@@ -485,6 +488,7 @@ impl LayoutThread {
Timer::new()
},
layout_threads: layout_threads,
+ quirks_mode: None,
}
}
@@ -522,6 +526,7 @@ impl LayoutThread {
error_reporter: self.error_reporter.clone(),
local_context_creation_data: Mutex::new(thread_local_style_context_creation_data),
timer: self.timer.clone(),
+ quirks_mode: self.quirks_mode.unwrap(),
},
image_cache_thread: Mutex::new(self.image_cache_thread.clone()),
image_cache_sender: Mutex::new(self.image_cache_sender.clone()),
@@ -977,6 +982,7 @@ impl LayoutThread {
possibly_locked_rw_data: &mut RwData<'a, 'b>) {
let document = unsafe { ServoLayoutNode::new(&data.document) };
let document = document.as_document().unwrap();
+ self.quirks_mode = Some(document.quirks_mode());
// FIXME(pcwalton): Combine `ReflowGoal` and `ReflowQueryType`. Then remove this assert.
debug_assert!((data.reflow_info.goal == ReflowGoal::ForDisplay &&
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index 3365c106bd9..850bef189c7 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -48,7 +48,6 @@ use euclid::length::Length as EuclidLength;
use euclid::rect::Rect;
use euclid::size::Size2D;
use html5ever::tokenizer::buffer_queue::BufferQueue;
-use html5ever::tree_builder::QuirksMode;
use html5ever_atoms::{Prefix, LocalName, Namespace, QualName};
use hyper::header::Headers;
use hyper::method::Method;
@@ -92,6 +91,7 @@ use std::sync::atomic::{AtomicBool, AtomicUsize};
use std::sync::mpsc::{Receiver, Sender};
use std::time::{SystemTime, Instant};
use style::attr::{AttrIdentifier, AttrValue, LengthOrPercentageOrAuto};
+use style::context::QuirksMode;
use style::element_state::*;
use style::font_face::FontFaceRule;
use style::keyframes::Keyframe;
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 36a2af07e63..6f8f2435311 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -91,7 +91,6 @@ use encoding::EncodingRef;
use encoding::all::UTF_8;
use euclid::point::Point2D;
use gfx_traits::ScrollRootId;
-use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks, QuirksMode};
use html5ever_atoms::{LocalName, QualName};
use hyper::header::{Header, SetCookie};
use hyper_serde::Serde;
@@ -129,7 +128,7 @@ use std::rc::Rc;
use std::sync::Arc;
use std::time::{Duration, Instant};
use style::attr::AttrValue;
-use style::context::ReflowGoal;
+use style::context::{QuirksMode, ReflowGoal};
use style::restyle_hints::RestyleHint;
use style::selector_parser::{RestyleDamage, Snapshot};
use style::str::{split_html_space_chars, str_join};
@@ -490,7 +489,7 @@ impl Document {
pub fn set_quirks_mode(&self, mode: QuirksMode) {
self.quirks_mode.set(mode);
- if mode == Quirks {
+ if mode == QuirksMode::Quirks {
self.window.layout_chan().send(Msg::SetQuirksMode).unwrap();
}
}
@@ -1777,6 +1776,7 @@ pub trait LayoutDocumentHelpers {
unsafe fn drain_pending_restyles(&self) -> Vec<(LayoutJS<Element>, PendingRestyle)>;
unsafe fn needs_paint_from_layout(&self);
unsafe fn will_paint(&self);
+ unsafe fn quirks_mode(&self) -> QuirksMode;
}
#[allow(unsafe_code)]
@@ -1803,6 +1803,11 @@ impl LayoutDocumentHelpers for LayoutJS<Document> {
unsafe fn will_paint(&self) {
(*self.unsafe_get()).needs_paint.set(false)
}
+
+ #[inline]
+ unsafe fn quirks_mode(&self) -> QuirksMode {
+ (*self.unsafe_get()).quirks_mode()
+ }
}
/// https://url.spec.whatwg.org/#network-scheme
@@ -1860,7 +1865,7 @@ impl Document {
last_modified: last_modified,
url: DOMRefCell::new(url),
// https://dom.spec.whatwg.org/#concept-document-quirks
- quirks_mode: Cell::new(NoQuirks),
+ quirks_mode: Cell::new(QuirksMode::NoQuirks),
// https://dom.spec.whatwg.org/#concept-document-encoding
encoding: Cell::new(UTF_8),
is_html_document: is_html_document == IsHTMLDocument::HTMLDocument,
@@ -2303,8 +2308,8 @@ impl DocumentMethods for Document {
// https://dom.spec.whatwg.org/#dom-document-compatmode
fn CompatMode(&self) -> DOMString {
DOMString::from(match self.quirks_mode.get() {
- LimitedQuirks | NoQuirks => "CSS1Compat",
- Quirks => "BackCompat",
+ QuirksMode::LimitedQuirks | QuirksMode::NoQuirks => "CSS1Compat",
+ QuirksMode::Quirks => "BackCompat",
})
}
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index 21dfde99f22..27386eb2da8 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -77,7 +77,6 @@ use html5ever::serialize;
use html5ever::serialize::SerializeOpts;
use html5ever::serialize::TraversalScope;
use html5ever::serialize::TraversalScope::{ChildrenOnly, IncludeNode};
-use html5ever::tree_builder::{LimitedQuirks, NoQuirks, Quirks};
use html5ever_atoms::{Prefix, LocalName, Namespace, QualName};
use js::jsapi::{HandleValue, JSAutoCompartment};
use parking_lot::RwLock;
@@ -98,7 +97,7 @@ use std::rc::Rc;
use std::sync::Arc;
use std::sync::atomic::{AtomicUsize, Ordering};
use style::attr::{AttrValue, LengthOrPercentageOrAuto};
-use style::context::ReflowGoal;
+use style::context::{QuirksMode, ReflowGoal};
use style::element_state::*;
use style::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
use style::parser::ParserContextExtraData;
@@ -1084,8 +1083,8 @@ impl Element {
let quirks_mode = document_from_node(self).quirks_mode();
let is_equal = |lhs: &Atom, rhs: &Atom| {
match quirks_mode {
- NoQuirks | LimitedQuirks => lhs == rhs,
- Quirks => lhs.eq_ignore_ascii_case(&rhs),
+ QuirksMode::NoQuirks | QuirksMode::LimitedQuirks => lhs == rhs,
+ QuirksMode::Quirks => lhs.eq_ignore_ascii_case(&rhs),
}
};
self.get_attribute(&ns!(), &local_name!("class"))
@@ -1265,7 +1264,7 @@ impl Element {
// Step 7
if *self.root_element() == *self {
- if doc.quirks_mode() != Quirks {
+ if doc.quirks_mode() != QuirksMode::Quirks {
win.scroll(x, y, behavior);
}
@@ -1274,7 +1273,7 @@ impl Element {
// Step 9
if doc.GetBody().r() == self.downcast::<HTMLElement>() &&
- doc.quirks_mode() == Quirks &&
+ doc.quirks_mode() == QuirksMode::Quirks &&
!self.potentially_scrollable() {
win.scroll(x, y, behavior);
return;
@@ -1645,7 +1644,7 @@ impl ElementMethods for Element {
// Step 5
if *self.root_element() == *self {
- if doc.quirks_mode() == Quirks {
+ if doc.quirks_mode() == QuirksMode::Quirks {
return 0.0;
}
@@ -1655,7 +1654,7 @@ impl ElementMethods for Element {
// Step 7
if doc.GetBody().r() == self.downcast::<HTMLElement>() &&
- doc.quirks_mode() == Quirks &&
+ doc.quirks_mode() == QuirksMode::Quirks &&
!self.potentially_scrollable() {
return win.ScrollY() as f64;
}
@@ -1696,7 +1695,7 @@ impl ElementMethods for Element {
// Step 7
if *self.root_element() == *self {
- if doc.quirks_mode() != Quirks {
+ if doc.quirks_mode() != QuirksMode::Quirks {
win.scroll(win.ScrollX() as f64, y, behavior);
}
@@ -1705,7 +1704,7 @@ impl ElementMethods for Element {
// Step 9
if doc.GetBody().r() == self.downcast::<HTMLElement>() &&
- doc.quirks_mode() == Quirks &&
+ doc.quirks_mode() == QuirksMode::Quirks &&
!self.potentially_scrollable() {
win.scroll(win.ScrollX() as f64, y, behavior);
return;
@@ -1737,7 +1736,7 @@ impl ElementMethods for Element {
// Step 5
if *self.root_element() == *self {
- if doc.quirks_mode() != Quirks {
+ if doc.quirks_mode() != QuirksMode::Quirks {
// Step 6
return win.ScrollX() as f64;
}
@@ -1747,7 +1746,7 @@ impl ElementMethods for Element {
// Step 7
if doc.GetBody().r() == self.downcast::<HTMLElement>() &&
- doc.quirks_mode() == Quirks &&
+ doc.quirks_mode() == QuirksMode::Quirks &&
!self.potentially_scrollable() {
return win.ScrollX() as f64;
}
@@ -1788,7 +1787,7 @@ impl ElementMethods for Element {
// Step 7
if *self.root_element() == *self {
- if doc.quirks_mode() == Quirks {
+ if doc.quirks_mode() == QuirksMode::Quirks {
return;
}
@@ -1798,7 +1797,7 @@ impl ElementMethods for Element {
// Step 9
if doc.GetBody().r() == self.downcast::<HTMLElement>() &&
- doc.quirks_mode() == Quirks &&
+ doc.quirks_mode() == QuirksMode::Quirks &&
!self.potentially_scrollable() {
win.scroll(x, win.ScrollY() as f64, behavior);
return;
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index 7146154a647..3e2de9bfa8e 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -57,7 +57,6 @@ use euclid::point::Point2D;
use euclid::rect::Rect;
use euclid::size::Size2D;
use heapsize::{HeapSizeOf, heap_size_of};
-use html5ever::tree_builder::QuirksMode;
use html5ever_atoms::{Prefix, Namespace, QualName};
use js::jsapi::{JSContext, JSObject, JSRuntime};
use libc::{self, c_void, uintptr_t};
@@ -78,6 +77,7 @@ use std::iter;
use std::mem;
use std::ops::Range;
use std::sync::Arc;
+use style::context::QuirksMode;
use style::dom::OpaqueNode;
use style::selector_parser::{SelectorImpl, SelectorParser};
use style::stylesheets::Stylesheet;
diff --git a/components/script/dom/servoparser/html.rs b/components/script/dom/servoparser/html.rs
index ac6330c3ca2..28f8735891e 100644
--- a/components/script/dom/servoparser/html.rs
+++ b/components/script/dom/servoparser/html.rs
@@ -34,6 +34,7 @@ use js::jsapi::JSTracer;
use servo_url::ServoUrl;
use std::borrow::Cow;
use std::io::{self, Write};
+use style::context::QuirksMode as ServoQuirksMode;
#[derive(HeapSizeOf, JSTraceable)]
#[must_root]
@@ -187,6 +188,11 @@ impl<'a> TreeSink for Sink {
}
fn set_quirks_mode(&mut self, mode: QuirksMode) {
+ let mode = match mode {
+ QuirksMode::Quirks => ServoQuirksMode::Quirks,
+ QuirksMode::LimitedQuirks => ServoQuirksMode::LimitedQuirks,
+ QuirksMode::NoQuirks => ServoQuirksMode::NoQuirks,
+ };
self.document.set_quirks_mode(mode);
}
diff --git a/components/script/layout_wrapper.rs b/components/script/layout_wrapper.rs
index 0fa54e6fe75..dca0750e0ee 100644
--- a/components/script/layout_wrapper.rs
+++ b/components/script/layout_wrapper.rs
@@ -61,7 +61,7 @@ use std::sync::atomic::Ordering;
use style::atomic_refcell::AtomicRefCell;
use style::attr::AttrValue;
use style::computed_values::display;
-use style::context::SharedStyleContext;
+use style::context::{QuirksMode, SharedStyleContext};
use style::data::ElementData;
use style::dom::{LayoutIterator, NodeInfo, OpaqueNode, PresentationalHintsSynthetizer, TElement, TNode};
use style::dom::UnsafeNode;
@@ -321,6 +321,10 @@ impl<'ld> ServoLayoutDocument<'ld> {
unsafe { self.document.will_paint(); }
}
+ pub fn quirks_mode(&self) -> QuirksMode {
+ unsafe { self.document.quirks_mode() }
+ }
+
pub fn from_layout_js(doc: LayoutJS<Document>) -> ServoLayoutDocument<'ld> {
ServoLayoutDocument {
document: doc,
diff --git a/components/style/context.rs b/components/style/context.rs
index 824c3bfeb94..ffe9668bd32 100644
--- a/components/style/context.rs
+++ b/components/style/context.rs
@@ -31,6 +31,14 @@ impl ThreadLocalStyleContextCreationInfo {
}
}
+#[derive(PartialEq, Eq, Copy, Clone, Hash, Debug)]
+#[cfg_attr(feature = "servo", derive(HeapSizeOf))]
+pub enum QuirksMode {
+ Quirks,
+ LimitedQuirks,
+ NoQuirks,
+}
+
pub struct SharedStyleContext {
/// The current viewport size.
pub viewport_size: Size2D<Au>,
@@ -63,6 +71,9 @@ pub struct SharedStyleContext {
/// The current timer for transitions and animations. This is needed to test
/// them.
pub timer: Timer,
+
+ /// The QuirksMode state which the document needs to be rendered with
+ pub quirks_mode: QuirksMode,
}
pub struct ThreadLocalStyleContext {
diff --git a/ports/geckolib/glue.rs b/ports/geckolib/glue.rs
index 2073e2c8649..3194001b450 100644
--- a/ports/geckolib/glue.rs
+++ b/ports/geckolib/glue.rs
@@ -16,7 +16,7 @@ use std::ptr;
use std::sync::{Arc, Mutex};
use style::arc_ptr_eq;
use style::atomic_refcell::AtomicRefMut;
-use style::context::{ThreadLocalStyleContextCreationInfo, ReflowGoal, SharedStyleContext, StyleContext};
+use style::context::{ThreadLocalStyleContextCreationInfo, QuirksMode, ReflowGoal, SharedStyleContext, StyleContext};
use style::data::{ElementData, RestyleData};
use style::dom::{ShowSubtreeData, TElement, TNode};
use style::error_reporting::StdoutErrorReporter;
@@ -114,6 +114,8 @@ fn create_shared_context(mut per_doc_data: &mut AtomicRefMut<PerDocumentStyleDat
error_reporter: Box::new(StdoutErrorReporter),
local_context_creation_data: Mutex::new(local_context_data),
timer: Timer::new(),
+ // FIXME Find the real QuirksMode information for this document
+ quirks_mode: QuirksMode::NoQuirks,
}
}