aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--components/layout/css/matching.rs24
-rw-r--r--components/layout/traversal.rs14
-rw-r--r--components/layout/wrapper.rs113
-rw-r--r--components/script/dom/element.rs68
-rw-r--r--components/script/dom/node.rs60
-rw-r--r--components/servo/Cargo.lock2
-rw-r--r--components/style/selector_matching.rs2
-rw-r--r--ports/cef/Cargo.lock2
-rw-r--r--ports/gonk/Cargo.lock2
-rw-r--r--tests/ref/first_child_pseudo_a.html4
-rw-r--r--tests/ref/first_of_type_pseudo_a.html5
-rw-r--r--tests/ref/last_child_pseudo_a.html4
-rw-r--r--tests/ref/last_of_type_pseudo_a.html5
-rw-r--r--tests/ref/nth_child_pseudo_a.html5
-rw-r--r--tests/ref/nth_last_child_pseudo_a.html5
-rw-r--r--tests/ref/nth_last_of_type_pseudo_a.html5
-rw-r--r--tests/ref/nth_of_type_pseudo_a.html5
-rw-r--r--tests/ref/only_of_type_pseudo_a.html5
18 files changed, 171 insertions, 159 deletions
diff --git a/components/layout/css/matching.rs b/components/layout/css/matching.rs
index 466b5fd7ece..1cf48d3b9cc 100644
--- a/components/layout/css/matching.rs
+++ b/components/layout/css/matching.rs
@@ -17,7 +17,7 @@ use wrapper::{LayoutElement, LayoutNode};
use script::dom::characterdata::CharacterDataTypeId;
use script::dom::node::NodeTypeId;
use script::layout_interface::Animation;
-use selectors::{Node, Element};
+use selectors::{Element};
use selectors::bloom::BloomFilter;
use selectors::matching::{CommonStyleAffectingAttributeMode, CommonStyleAffectingAttributes};
use selectors::matching::{common_style_affecting_attributes, rare_style_affecting_attributes};
@@ -222,18 +222,14 @@ impl StyleSharingCandidate {
/// Attempts to create a style sharing candidate from this node. Returns
/// the style sharing candidate or `None` if this node is ineligible for
/// style sharing.
- fn new(node: &LayoutNode) -> Option<StyleSharingCandidate> {
- let parent_node = match node.parent_node() {
+ fn new(element: &LayoutElement) -> Option<StyleSharingCandidate> {
+ let parent_element = match element.parent_element() {
None => return None,
- Some(parent_node) => parent_node,
- };
- let element = match parent_node.as_element() {
- Some(element) => element,
- None => return None
+ Some(parent_element) => parent_element,
};
let style = unsafe {
- match *node.borrow_layout_data_unchecked() {
+ match *element.as_node().borrow_layout_data_unchecked() {
None => return None,
Some(ref layout_data_ref) => {
match layout_data_ref.shared_data.style {
@@ -244,7 +240,7 @@ impl StyleSharingCandidate {
}
};
let parent_style = unsafe {
- match *parent_node.borrow_layout_data_unchecked() {
+ match *parent_element.as_node().borrow_layout_data_unchecked() {
None => return None,
Some(ref parent_layout_data_ref) => {
match parent_layout_data_ref.shared_data.style {
@@ -357,8 +353,8 @@ impl StyleSharingCandidateCache {
self.cache.iter()
}
- pub fn insert_if_possible(&mut self, node: &LayoutNode) {
- match StyleSharingCandidate::new(node) {
+ pub fn insert_if_possible(&mut self, element: &LayoutElement) {
+ match StyleSharingCandidate::new(element) {
None => {}
Some(candidate) => self.cache.insert(candidate, ())
}
@@ -395,7 +391,7 @@ pub trait MatchMethods {
fn match_node(&self,
stylist: &Stylist,
- parent_bf: &Option<Box<BloomFilter>>,
+ parent_bf: Option<&BloomFilter>,
applicable_declarations: &mut ApplicableDeclarations,
shareable: &mut bool);
@@ -540,7 +536,7 @@ impl<'ln> PrivateMatchMethods for LayoutNode<'ln> {
impl<'ln> MatchMethods for LayoutNode<'ln> {
fn match_node(&self,
stylist: &Stylist,
- parent_bf: &Option<Box<BloomFilter>>,
+ parent_bf: Option<&BloomFilter>,
applicable_declarations: &mut ApplicableDeclarations,
shareable: &mut bool) {
let element = self.as_element().unwrap();
diff --git a/components/layout/traversal.rs b/components/layout/traversal.rs
index c60a01e1629..d60729443cc 100644
--- a/components/layout/traversal.rs
+++ b/components/layout/traversal.rs
@@ -16,7 +16,6 @@ use wrapper::{layout_node_to_unsafe_layout_node, LayoutNode};
use wrapper::{ThreadSafeLayoutNode, UnsafeLayoutNode};
use selectors::bloom::BloomFilter;
-use selectors::Node;
use util::opts;
use util::tid::tid;
@@ -162,10 +161,7 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
let parent_opt = node.layout_parent_node(self.layout_context.shared);
// Get the style bloom filter.
- let bf = take_task_local_bloom_filter(parent_opt, self.layout_context);
-
- // Just needs to be wrapped in an option for `match_node`.
- let some_bf = Some(bf);
+ let mut bf = take_task_local_bloom_filter(parent_opt, self.layout_context);
let nonincremental_layout = opts::get().nonincremental_layout;
if nonincremental_layout || node.is_dirty() {
@@ -192,7 +188,7 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
// Perform the CSS selector matching.
let stylist = unsafe { &*self.layout_context.shared.stylist };
node.match_node(stylist,
- &some_bf,
+ Some(&*bf),
&mut applicable_declarations,
&mut shareable);
} else if node.has_changed() {
@@ -211,7 +207,9 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
// Add ourselves to the LRU cache.
if shareable {
- style_sharing_candidate_cache.insert_if_possible(&node);
+ if let Some(element) = node.as_element() {
+ style_sharing_candidate_cache.insert_if_possible(&element);
+ }
}
}
StyleSharingResult::StyleWasShared(index, damage) => {
@@ -221,8 +219,6 @@ impl<'a> PreorderDomTraversal for RecalcStyleForNode<'a> {
}
}
- let mut bf = some_bf.unwrap();
-
let unsafe_layout_node = layout_node_to_unsafe_layout_node(&node);
// Before running the children, we need to insert our nodes into the bloom
diff --git a/components/layout/wrapper.rs b/components/layout/wrapper.rs
index 762f7dba2a0..acadf6fcfca 100644
--- a/components/layout/wrapper.rs
+++ b/components/layout/wrapper.rs
@@ -67,7 +67,6 @@ use std::sync::mpsc::Sender;
use string_cache::{Atom, Namespace};
use style::computed_values::content::ContentItem;
use style::computed_values::{content, display, white_space};
-use selectors::Node as SelectorsNode;
use selectors::matching::DeclarationBlock;
use selectors::parser::{NamespaceConstraint, AttrSelector};
use style::legacy::UnsignedIntegerAttribute;
@@ -144,12 +143,6 @@ impl<'ln> LayoutNode<'ln> {
LayoutTreeIterator::new(self)
}
- fn last_child(self) -> Option<LayoutNode<'ln>> {
- unsafe {
- self.get_jsmanaged().last_child_ref().map(|node| self.new_with_this_lifetime(&node))
- }
- }
-
/// Returns an iterator over this node's children.
pub fn children(self) -> LayoutNodeChildrenIterator<'ln> {
LayoutNodeChildrenIterator {
@@ -209,10 +202,10 @@ impl<'ln> LayoutNode<'ln> {
pub fn debug_id(self) -> usize {
self.opaque().to_untrusted_node_address().0 as usize
}
-}
-impl<'ln> ::selectors::Node for LayoutNode<'ln> {
- type Element = LayoutElement<'ln>;
+ pub fn as_element(&self) -> Option<LayoutElement<'ln>> {
+ as_element(self.node)
+ }
fn parent_node(&self) -> Option<LayoutNode<'ln>> {
unsafe {
@@ -243,34 +236,6 @@ impl<'ln> ::selectors::Node for LayoutNode<'ln> {
self.node.next_sibling_ref().map(|node| self.new_with_this_lifetime(&node))
}
}
-
- /// If this is an element, accesses the element data.
- #[inline]
- fn as_element(&self) -> Option<Self::Element> {
- ElementCast::to_layout_js(&self.node).map(|element| {
- LayoutElement {
- element: element,
- chain: self.chain,
- }
- })
- }
-
- fn is_document(&self) -> bool {
- match self.type_id() {
- NodeTypeId::Document(..) => true,
- _ => false
- }
- }
-
- fn is_element_or_non_empty_text(&self) -> bool {
- if let Some(text) = TextCast::to_layout_js(&self.node) {
- unsafe {
- !CharacterDataCast::from_layout_js(&text).data_for_layout().is_empty()
- }
- } else {
- ElementCast::to_layout_js(&self.node).is_some()
- }
- }
}
impl<'ln> LayoutNode<'ln> {
@@ -387,18 +352,78 @@ impl<'le> LayoutElement<'le> {
&*self.element.style_attribute()
}
}
-}
-
-impl<'le> ::selectors::Element for LayoutElement<'le> {
- type Node = LayoutNode<'le>;
- #[inline]
- fn as_node(&self) -> LayoutNode<'le> {
+ pub fn as_node(&self) -> LayoutNode<'le> {
LayoutNode {
node: NodeCast::from_layout_js(&self.element),
chain: PhantomData,
}
}
+}
+
+fn as_element<'le>(node: LayoutJS<Node>) -> Option<LayoutElement<'le>> {
+ ElementCast::to_layout_js(&node).map(|element| {
+ LayoutElement {
+ element: element,
+ chain: PhantomData,
+ }
+ })
+}
+
+
+impl<'le> ::selectors::Element for LayoutElement<'le> {
+ fn parent_element(&self) -> Option<LayoutElement<'le>> {
+ unsafe {
+ NodeCast::from_layout_js(&self.element).parent_node_ref().and_then(as_element)
+ }
+ }
+
+ fn first_child_element(&self) -> Option<LayoutElement<'le>> {
+ self.as_node().children().filter_map(|n| n.as_element()).next()
+ }
+
+ fn last_child_element(&self) -> Option<LayoutElement<'le>> {
+ self.as_node().rev_children().filter_map(|n| n.as_element()).next()
+ }
+
+ fn prev_sibling_element(&self) -> Option<LayoutElement<'le>> {
+ let mut node = self.as_node();
+ while let Some(sibling) = node.prev_sibling() {
+ if let Some(element) = sibling.as_element() {
+ return Some(element)
+ }
+ node = sibling;
+ }
+ None
+ }
+
+ fn next_sibling_element(&self) -> Option<LayoutElement<'le>> {
+ let mut node = self.as_node();
+ while let Some(sibling) = node.next_sibling() {
+ if let Some(element) = sibling.as_element() {
+ return Some(element)
+ }
+ node = sibling;
+ }
+ None
+ }
+
+ fn is_root(&self) -> bool {
+ match self.as_node().parent_node() {
+ None => false,
+ Some(node) => node.type_id() == NodeTypeId::Document,
+ }
+ }
+
+ fn is_empty(&self) -> bool {
+ self.as_node().children().all(|node| match node.type_id() {
+ NodeTypeId::Element(..) => false,
+ NodeTypeId::CharacterData(CharacterDataTypeId::Text) => unsafe {
+ CharacterDataCast::to_layout_js(&node.node).unwrap().data_for_layout().is_empty()
+ },
+ _ => true
+ })
+ }
#[inline]
fn get_local_name<'a>(&'a self) -> &'a Atom {
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index a5fc6f955da..5e86a33c698 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -16,7 +16,9 @@ use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use dom::bindings::codegen::Bindings::HTMLInputElementBinding::HTMLInputElementMethods;
use dom::bindings::codegen::Bindings::NamedNodeMapBinding::NamedNodeMapMethods;
use dom::bindings::codegen::Bindings::NodeBinding::NodeMethods;
+use dom::bindings::codegen::InheritTypes::CharacterDataCast;
use dom::bindings::codegen::InheritTypes::{ElementCast, ElementDerived, EventTargetCast};
+use dom::bindings::codegen::InheritTypes::DocumentDerived;
use dom::bindings::codegen::InheritTypes::{HTMLBodyElementDerived, HTMLFontElementDerived};
use dom::bindings::codegen::InheritTypes::{HTMLIFrameElementDerived, HTMLInputElementCast};
use dom::bindings::codegen::InheritTypes::{HTMLInputElementDerived, HTMLTableElementCast};
@@ -25,6 +27,7 @@ use dom::bindings::codegen::InheritTypes::{HTMLTableRowElementDerived, HTMLTextA
use dom::bindings::codegen::InheritTypes::{HTMLTableSectionElementDerived, NodeCast};
use dom::bindings::codegen::InheritTypes::HTMLAnchorElementCast;
use dom::bindings::codegen::InheritTypes::HTMLTableDataCellElementDerived;
+use dom::bindings::codegen::InheritTypes::TextCast;
use dom::bindings::codegen::UnionTypes::NodeOrString;
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Error::{InvalidCharacter, Syntax};
@@ -34,6 +37,7 @@ use dom::bindings::js::{Root, RootedReference};
use dom::bindings::trace::RootedVec;
use dom::bindings::utils::{namespace_from_domstring, xml_name_type, validate_and_extract};
use dom::bindings::utils::XMLName::InvalidXMLName;
+use dom::characterdata::CharacterDataHelpers;
use dom::create::create_element;
use dom::domrect::DOMRect;
use dom::domrectlist::DOMRectList;
@@ -1449,7 +1453,7 @@ impl<'a> ElementMethods for &'a Element {
match parse_author_origin_selector_list_from_str(&selectors) {
Err(()) => Err(Syntax),
Ok(ref selectors) => {
- Ok(matches(selectors, &self, &mut None))
+ Ok(matches(selectors, &Root::from_ref(self), None))
}
}
}
@@ -1461,9 +1465,9 @@ impl<'a> ElementMethods for &'a Element {
Ok(ref selectors) => {
let root = NodeCast::from_ref(self);
for element in root.inclusive_ancestors() {
- if let Some(element) = ElementCast::to_ref(element.r()) {
- if matches(selectors, &element, &mut None) {
- return Ok(Some(Root::from_ref(element)));
+ if let Some(element) = ElementCast::to_root(element) {
+ if matches(selectors, &element, None) {
+ return Ok(Some(element));
}
}
}
@@ -1615,16 +1619,44 @@ impl<'a> VirtualMethods for &'a Element {
}
}
-impl<'a> ::selectors::Element for &'a Element {
- type Node = &'a Node;
+impl<'a> ::selectors::Element for Root<Element> {
+ fn parent_element(&self) -> Option<Root<Element>> {
+ NodeCast::from_ref(&**self).GetParentElement()
+ }
+
+ fn first_child_element(&self) -> Option<Root<Element>> {
+ self.node.child_elements().next()
+ }
+
+ fn last_child_element(&self) -> Option<Root<Element>> {
+ self.node.rev_children().filter_map(ElementCast::to_root).next()
+ }
- fn as_node(&self) -> &'a Node {
- NodeCast::from_ref(*self)
+ fn prev_sibling_element(&self) -> Option<Root<Element>> {
+ self.node.preceding_siblings().filter_map(ElementCast::to_root).next()
+ }
+
+ fn next_sibling_element(&self) -> Option<Root<Element>> {
+ self.node.following_siblings().filter_map(ElementCast::to_root).next()
+ }
+
+ fn is_root(&self) -> bool {
+ match self.node.GetParentNode() {
+ None => false,
+ Some(node) => node.is_document(),
+ }
+ }
+
+ fn is_empty(&self) -> bool {
+ self.node.children().all(|node| !node.is_element() && match TextCast::to_ref(&*node) {
+ None => true,
+ Some(text) => CharacterDataCast::from_ref(text).data().is_empty()
+ })
}
fn is_link(&self) -> bool {
// FIXME: This is HTML only.
- let node = NodeCast::from_ref(*self);
+ let node = NodeCast::from_ref(&**self);
match node.type_id() {
// https://html.spec.whatwg.org/multipage/#selector-link
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLAnchorElement)) |
@@ -1647,20 +1679,20 @@ impl<'a> ::selectors::Element for &'a Element {
}
fn get_local_name<'b>(&'b self) -> &'b Atom {
- ElementHelpers::local_name(*self)
+ ElementHelpers::local_name(&**self)
}
fn get_namespace<'b>(&'b self) -> &'b Namespace {
self.namespace()
}
fn get_hover_state(&self) -> bool {
- let node = NodeCast::from_ref(*self);
+ let node = NodeCast::from_ref(&**self);
node.get_hover_state()
}
fn get_focus_state(&self) -> bool {
// TODO: Also check whether the top-level browsing context has the system focus,
// and whether this element is a browsing context container.
// https://html.spec.whatwg.org/multipage/#selector-focus
- let node = NodeCast::from_ref(*self);
+ let node = NodeCast::from_ref(&**self);
node.get_focus_state()
}
fn get_id(&self) -> Option<Atom> {
@@ -1672,29 +1704,29 @@ impl<'a> ::selectors::Element for &'a Element {
})
}
fn get_disabled_state(&self) -> bool {
- let node = NodeCast::from_ref(*self);
+ let node = NodeCast::from_ref(&**self);
node.get_disabled_state()
}
fn get_enabled_state(&self) -> bool {
- let node = NodeCast::from_ref(*self);
+ let node = NodeCast::from_ref(&**self);
node.get_enabled_state()
}
fn get_checked_state(&self) -> bool {
- let input_element: Option<&HTMLInputElement> = HTMLInputElementCast::to_ref(*self);
+ let input_element: Option<&HTMLInputElement> = HTMLInputElementCast::to_ref(&**self);
match input_element {
Some(input) => input.Checked(),
None => false,
}
}
fn get_indeterminate_state(&self) -> bool {
- let input_element: Option<&HTMLInputElement> = HTMLInputElementCast::to_ref(*self);
+ let input_element: Option<&HTMLInputElement> = HTMLInputElementCast::to_ref(&**self);
match input_element {
Some(input) => input.get_indeterminate_state(),
None => false,
}
}
fn has_class(&self, name: &Atom) -> bool {
- AttributeHandlers::has_class(*self, name)
+ AttributeHandlers::has_class(&**self, name)
}
fn each_class<F>(&self, mut callback: F)
where F: FnMut(&Atom)
@@ -1708,7 +1740,7 @@ impl<'a> ::selectors::Element for &'a Element {
}
}
fn has_servo_nonzero_border(&self) -> bool {
- let table_element: Option<&HTMLTableElement> = HTMLTableElementCast::to_ref(*self);
+ let table_element: Option<&HTMLTableElement> = HTMLTableElementCast::to_ref(&**self);
match table_element {
None => false,
Some(this) => {
diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs
index ab48fcd1e35..20984bfbac5 100644
--- a/components/script/dom/node.rs
+++ b/components/script/dom/node.rs
@@ -413,13 +413,14 @@ impl<'a> Iterator for QuerySelectorIterator {
let selectors = &self.selectors;
// TODO(cgaebel): Is it worth it to build a bloom filter here
// (instead of passing `None`)? Probably.
- self.iterator.find(|node| {
- if let Some(element) = ElementCast::to_ref(node.r()) {
- matches(selectors, &element, &mut None)
- } else {
- false
+ self.iterator.by_ref().filter_map(|node| {
+ if let Some(element) = ElementCast::to_root(node) {
+ if matches(selectors, &element, None) {
+ return Some(NodeCast::from_root(element))
+ }
}
- })
+ None
+ }).next()
}
}
@@ -891,7 +892,7 @@ impl<'a> NodeHelpers for &'a Node {
let root = self.ancestors().last();
let root = root.r().unwrap_or(self.clone());
Ok(root.traverse_preorder().filter_map(ElementCast::to_root).find(|element| {
- matches(selectors, &element.r(), &mut None)
+ matches(selectors, element, None)
}))
}
}
@@ -2579,51 +2580,6 @@ impl<'a> VirtualMethods for &'a Node {
}
}
-impl<'a> ::selectors::Node for &'a Node {
- type Element = &'a Element;
-
- fn parent_node(&self) -> Option<&'a Node> {
- (*self).parent_node.get()
- .map(|node| node.root().get_unsound_ref_forever())
- }
-
- fn first_child(&self) -> Option<&'a Node> {
- (*self).first_child.get()
- .map(|node| node.root().get_unsound_ref_forever())
- }
-
- fn last_child(&self) -> Option<&'a Node> {
- (*self).last_child.get()
- .map(|node| node.root().get_unsound_ref_forever())
- }
-
- fn prev_sibling(&self) -> Option<&'a Node> {
- (*self).prev_sibling.get()
- .map(|node| node.root().get_unsound_ref_forever())
- }
-
- fn next_sibling(&self) -> Option<&'a Node> {
- (*self).next_sibling.get()
- .map(|node| node.root().get_unsound_ref_forever())
- }
-
- fn is_document(&self) -> bool {
- DocumentDerived::is_document(*self)
- }
-
- fn as_element(&self) -> Option<Self::Element> {
- ElementCast::to_ref(*self)
- }
-
- fn is_element_or_non_empty_text(&self) -> bool {
- if self.is_text() {
- self.GetTextContent().map_or(false, |s| !s.is_empty())
- } else {
- self.is_element()
- }
- }
-}
-
pub trait DisabledStateHelpers {
fn check_ancestors_disabled_state_for_form_control(self);
fn check_parent_disabled_state_for_option(self);
diff --git a/components/servo/Cargo.lock b/components/servo/Cargo.lock
index 01d677f6870..64d4fd6dca8 100644
--- a/components/servo/Cargo.lock
+++ b/components/servo/Cargo.lock
@@ -1193,7 +1193,7 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.1.0"
-source = "git+https://github.com/servo/rust-selectors#a6cf1fba8f31960254aa62434ab8aeee13aff080"
+source = "git+https://github.com/servo/rust-selectors#625734e1e8d70c012672b248adca302d0276fe08"
dependencies = [
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/components/style/selector_matching.rs b/components/style/selector_matching.rs
index 8f56827b34e..677114f93d8 100644
--- a/components/style/selector_matching.rs
+++ b/components/style/selector_matching.rs
@@ -193,7 +193,7 @@ impl Stylist {
pub fn push_applicable_declarations<E,V>(
&self,
element: &E,
- parent_bf: &Option<Box<BloomFilter>>,
+ parent_bf: Option<&BloomFilter>,
style_attribute: Option<&PropertyDeclarationBlock>,
pseudo_element: Option<PseudoElement>,
applicable_declarations: &mut V)
diff --git a/ports/cef/Cargo.lock b/ports/cef/Cargo.lock
index fffd12ffd01..871779c4f80 100644
--- a/ports/cef/Cargo.lock
+++ b/ports/cef/Cargo.lock
@@ -1164,7 +1164,7 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.1.0"
-source = "git+https://github.com/servo/rust-selectors#a6cf1fba8f31960254aa62434ab8aeee13aff080"
+source = "git+https://github.com/servo/rust-selectors#625734e1e8d70c012672b248adca302d0276fe08"
dependencies = [
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/ports/gonk/Cargo.lock b/ports/gonk/Cargo.lock
index 3220896b1fb..eccaf1481cf 100644
--- a/ports/gonk/Cargo.lock
+++ b/ports/gonk/Cargo.lock
@@ -1072,7 +1072,7 @@ dependencies = [
[[package]]
name = "selectors"
version = "0.1.0"
-source = "git+https://github.com/servo/rust-selectors#a6cf1fba8f31960254aa62434ab8aeee13aff080"
+source = "git+https://github.com/servo/rust-selectors#625734e1e8d70c012672b248adca302d0276fe08"
dependencies = [
"bitflags 0.1.1 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.3.2 (registry+https://github.com/rust-lang/crates.io-index)",
diff --git a/tests/ref/first_child_pseudo_a.html b/tests/ref/first_child_pseudo_a.html
index 467999d711f..c2eabab18b9 100644
--- a/tests/ref/first_child_pseudo_a.html
+++ b/tests/ref/first_child_pseudo_a.html
@@ -3,8 +3,8 @@
<head>
<title>:first-child test</title>
<style type="text/css">
- html:first-child { background: red; }
- html { background: yellow;}
+ html { background: red;}
+ html:first-child { background: yellow; }
p { width: 20px; height: 20px; background: orange; float: left; margin-left: 10px; }
div { clear: both; }
diff --git a/tests/ref/first_of_type_pseudo_a.html b/tests/ref/first_of_type_pseudo_a.html
index 1edc27fa325..439348410fd 100644
--- a/tests/ref/first_of_type_pseudo_a.html
+++ b/tests/ref/first_of_type_pseudo_a.html
@@ -3,8 +3,9 @@
<head>
<title>:first-of-type test</title>
<style type="text/css">
- /* should not match according to Selectors 3 because html has no parent element */
- html:first-of-type { background: red; }
+ html { background: red; }
+ /* Should match according to Selectors Level 4 (changed from Level 3) */
+ html:first-of-type { background: white; }
div > p,
div > div,
diff --git a/tests/ref/last_child_pseudo_a.html b/tests/ref/last_child_pseudo_a.html
index 73f48120e0c..4e68475084f 100644
--- a/tests/ref/last_child_pseudo_a.html
+++ b/tests/ref/last_child_pseudo_a.html
@@ -3,8 +3,8 @@
<head>
<title>:last-child test</title>
<style type="text/css">
- html:last-child { background: red; }
- html { background: yellow;}
+ html { background: red;}
+ html:last-child { background: yellow; }
p { width: 20px; height: 20px; background: orange; float: left; margin-left: 10px; }
div { clear: both; }
diff --git a/tests/ref/last_of_type_pseudo_a.html b/tests/ref/last_of_type_pseudo_a.html
index 244355ff765..b0046f64c82 100644
--- a/tests/ref/last_of_type_pseudo_a.html
+++ b/tests/ref/last_of_type_pseudo_a.html
@@ -3,8 +3,9 @@
<head>
<title>:last-of-type test</title>
<style type="text/css">
- /* should not match according to Selectors 3 because html has no parent element */
- html:last-of-type { background: red; }
+ html { background: red; }
+ /* Should match according to Selectors Level 4 (changed from Level 3) */
+ html:last-of-type { background: white; }
div > p,
div > div,
diff --git a/tests/ref/nth_child_pseudo_a.html b/tests/ref/nth_child_pseudo_a.html
index 9603887b6c1..72e535081de 100644
--- a/tests/ref/nth_child_pseudo_a.html
+++ b/tests/ref/nth_child_pseudo_a.html
@@ -3,8 +3,9 @@
<head>
<title>:nth-child test</title>
<style type="text/css">
- /* should not match according to Selectors 3 because html has no parent element */
- html:nth-child(1) { background: red; }
+ html { background: red; }
+ /* Should match according to Selectors Level 4 (changed from Level 3) */
+ html:nth-child(1) { background: white; }
div > p { float: left; width: 40px; height: 40px; margin-right: 10px; border: 1px solid black; }
div { clear: both; }
diff --git a/tests/ref/nth_last_child_pseudo_a.html b/tests/ref/nth_last_child_pseudo_a.html
index 3afd8e37344..e70312c4804 100644
--- a/tests/ref/nth_last_child_pseudo_a.html
+++ b/tests/ref/nth_last_child_pseudo_a.html
@@ -3,8 +3,9 @@
<head>
<title>:nth-last-child test</title>
<style type="text/css">
- /* should not match according to Selectors 3 because html has no parent element */
- html:nth-last-child(1) { background: red; }
+ html { background: red; }
+ /* Should match according to Selectors Level 4 (changed from Level 3) */
+ html:nth-last-child(1) { background: white; }
div > p { float: left; width: 40px; height: 40px; margin-right: 10px; border: 1px solid black; }
div { clear: both; }
diff --git a/tests/ref/nth_last_of_type_pseudo_a.html b/tests/ref/nth_last_of_type_pseudo_a.html
index 5ad59e770c5..f587e1add18 100644
--- a/tests/ref/nth_last_of_type_pseudo_a.html
+++ b/tests/ref/nth_last_of_type_pseudo_a.html
@@ -3,8 +3,9 @@
<head>
<title>:nth-last-of-type test</title>
<style type="text/css">
- /* should not match according to Selectors 3 because html has no parent element */
- html:nth-last-of-type(1) { background: red; }
+ html { background: red; }
+ /* Should match according to Selectors Level 4 (changed from Level 3) */
+ html:nth-last-of-type(1) { background: white; }
div > p,
div > div,
diff --git a/tests/ref/nth_of_type_pseudo_a.html b/tests/ref/nth_of_type_pseudo_a.html
index 1f4416d7bbc..dfeecdb3afe 100644
--- a/tests/ref/nth_of_type_pseudo_a.html
+++ b/tests/ref/nth_of_type_pseudo_a.html
@@ -3,8 +3,9 @@
<head>
<title>:nth-of-type test</title>
<style type="text/css">
- /* should not match according to Selectors 3 because html has no parent element */
- html:nth-of-type(1) { background: red; }
+ html { background: red; }
+ /* Should match according to Selectors Level 4 (changed from Level 3) */
+ html:nth-of-type(1) { background: white; }
div > p,
div > div,
diff --git a/tests/ref/only_of_type_pseudo_a.html b/tests/ref/only_of_type_pseudo_a.html
index 18b3d4f21dd..ebd8286e834 100644
--- a/tests/ref/only_of_type_pseudo_a.html
+++ b/tests/ref/only_of_type_pseudo_a.html
@@ -3,8 +3,9 @@
<head>
<title>:only-of-type test</title>
<style type="text/css">
- /* should not match according to Selectors 3 because html has no parent element */
- html:only-of-type { background: red; }
+ html { background: red; }
+ /* Should match according to Selectors Level 4 (changed from Level 3) */
+ html:only-of-type { background: white; }
div > p,
div > div,