Auto merge of #6427 - servo:selector-traits-refactor, r=Ms2ger

Update rust-selectors

https://github.com/servo/rust-selectors/pull/30

r? @Ms2ger

This conflicts with the SpiderMonkey upgrade #6150. I’m happy to wait until that lands and rebase.

<!-- Reviewable:start -->
[<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6427)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2015-06-21 11:12:07 -06:00
commit c119b59e82
10 changed files with 101 additions and 120 deletions

View file

@ -1622,10 +1622,10 @@ impl<'a> VirtualMethods for &'a Element {
}
}
impl<'a> style::node::TElement<'a> for &'a Element {
fn is_link(self) -> bool {
impl<'a> style::node::TElement for &'a Element {
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)) |
@ -1638,45 +1638,45 @@ impl<'a> style::node::TElement<'a> for &'a Element {
}
#[inline]
fn is_unvisited_link(self) -> bool {
fn is_unvisited_link(&self) -> bool {
self.is_link()
}
#[inline]
fn is_visited_link(self) -> bool {
fn is_visited_link(&self) -> bool {
false
}
fn get_local_name(self) -> &'a Atom {
fn get_local_name<'b>(&'b self) -> &'b Atom {
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
// of disambiguating methods.
fn get_local_name<'a, T: ElementHelpers<'a>>(this: T) -> &'a Atom {
this.local_name()
}
get_local_name(self)
get_local_name(*self)
}
fn get_namespace(self) -> &'a Namespace {
fn get_namespace<'b>(&'b self) -> &'b Namespace {
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
// of disambiguating methods.
fn get_namespace<'a, T: ElementHelpers<'a>>(this: T) -> &'a Namespace {
this.namespace()
}
get_namespace(self)
get_namespace(*self)
}
fn get_hover_state(self) -> bool {
let node = NodeCast::from_ref(self);
fn get_hover_state(&self) -> bool {
let node = NodeCast::from_ref(*self);
node.get_hover_state()
}
fn get_focus_state(self) -> bool {
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> {
fn get_id(&self) -> Option<Atom> {
self.get_attribute(&ns!(""), &atom!("id")).map(|attr| {
// FIXME(https://github.com/rust-lang/rust/issues/23338)
let attr = attr.r();
@ -1687,38 +1687,38 @@ impl<'a> style::node::TElement<'a> for &'a Element {
}
})
}
fn get_disabled_state(self) -> bool {
let node = NodeCast::from_ref(self);
fn get_disabled_state(&self) -> bool {
let node = NodeCast::from_ref(*self);
node.get_disabled_state()
}
fn get_enabled_state(self) -> bool {
let node = NodeCast::from_ref(self);
fn get_enabled_state(&self) -> bool {
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);
fn get_checked_state(&self) -> bool {
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);
fn get_indeterminate_state(&self) -> bool {
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 {
fn has_class(&self, name: &Atom) -> bool {
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
// of disambiguating methods.
fn has_class<T: AttributeHandlers>(this: T, name: &Atom) -> bool {
this.has_class(name)
}
has_class(self, name)
has_class(*self, name)
}
fn each_class<F>(self, mut callback: F)
fn each_class<F>(&self, mut callback: F)
where F: FnMut(&Atom)
{
if let Some(ref attr) = self.get_attribute(&ns!(""), &atom!("class")) {
@ -1729,8 +1729,8 @@ impl<'a> style::node::TElement<'a> for &'a Element {
}
}
}
fn has_nonzero_border(self) -> bool {
let table_element: Option<&HTMLTableElement> = HTMLTableElementCast::to_ref(self);
fn has_servo_nonzero_border(&self) -> bool {
let table_element: Option<&HTMLTableElement> = HTMLTableElementCast::to_ref(*self);
match table_element {
None => false,
Some(this) => {

View file

@ -2492,59 +2492,59 @@ impl<'a> VirtualMethods for &'a Node {
}
}
impl<'a> style::node::TNode<'a> for &'a Node {
impl<'a> style::node::TNode for &'a Node {
type Element = &'a Element;
fn parent_node(self) -> Option<&'a Node> {
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> {
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> {
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> {
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> {
fn next_sibling(&self) -> Option<&'a Node> {
(*self).next_sibling.get()
.map(|node| node.root().get_unsound_ref_forever())
}
fn is_document(self) -> bool {
fn is_document(&self) -> bool {
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
// of disambiguating methods.
fn is_document<'a, T: DocumentDerived>(this: &T) -> bool {
this.is_document()
}
is_document(self)
is_document(*self)
}
fn is_element(self) -> bool {
fn is_element(&self) -> bool {
// FIXME(zwarich): Remove this when UFCS lands and there is a better way
// of disambiguating methods.
fn is_element<'a, T: ElementDerived>(this: &T) -> bool {
this.is_element()
}
is_element(self)
is_element(*self)
}
fn as_element(self) -> &'a Element {
ElementCast::to_ref(self).unwrap()
fn as_element(&self) -> &'a Element {
ElementCast::to_ref(*self).unwrap()
}
fn match_attr<F>(self, attr: &AttrSelector, test: F) -> bool
fn match_attr<F>(&self, attr: &AttrSelector, test: F) -> bool
where F: Fn(&str) -> bool
{
let local_name = {
@ -2577,25 +2577,9 @@ impl<'a> style::node::TNode<'a> for &'a Node {
}
}
fn is_html_element_in_html_document(self) -> bool {
fn is_html_element_in_html_document(&self) -> bool {
self.as_element().html_element_in_html_document()
}
fn has_changed(self) -> bool { self.get_has_changed() }
#[allow(unsafe_code)]
unsafe fn set_changed(self, value: bool) { self.set_has_changed(value) }
fn is_dirty(self) -> bool { self.get_is_dirty() }
#[allow(unsafe_code)]
unsafe fn set_dirty(self, value: bool) { self.set_is_dirty(value) }
fn has_dirty_siblings(self) -> bool { self.get_has_dirty_siblings() }
#[allow(unsafe_code)]
unsafe fn set_dirty_siblings(self, value: bool) { self.set_has_dirty_siblings(value) }
fn has_dirty_descendants(self) -> bool { self.get_has_dirty_descendants() }
#[allow(unsafe_code)]
unsafe fn set_dirty_descendants(self, value: bool) { self.set_has_dirty_descendants(value) }
}
pub trait DisabledStateHelpers {