diff options
author | Simon Sapin <simon.sapin@exyr.org> | 2015-02-21 20:58:11 +0100 |
---|---|---|
committer | Simon Sapin <simon.sapin@exyr.org> | 2015-02-23 16:29:34 +0100 |
commit | 2a50755c8a751218c8e3d5de53c831deaf061e64 (patch) | |
tree | d82d835f99d9d0dd333785da3928ae91326484c5 /components/style/node.rs | |
parent | 2e1adb3fa670504fb0fedaa517f312ba233bf67b (diff) | |
download | servo-2a50755c8a751218c8e3d5de53c831deaf061e64.tar.gz servo-2a50755c8a751218c8e3d5de53c831deaf061e64.zip |
Move selector matching to an external library, for use outside Servo.
Diffstat (limited to 'components/style/node.rs')
-rw-r--r-- | components/style/node.rs | 49 |
1 files changed, 1 insertions, 48 deletions
diff --git a/components/style/node.rs b/components/style/node.rs index df4a4864303..c3bd70a44bf 100644 --- a/components/style/node.rs +++ b/components/style/node.rs @@ -7,56 +7,9 @@ use cssparser::RGBA; use legacy::{IntegerAttribute, LengthAttribute, SimpleColorAttribute, UnsignedIntegerAttribute}; -use selectors::AttrSelector; use util::str::LengthOrPercentageOrAuto; -use string_cache::{Atom, Namespace}; -pub trait TNode<'a, E: TElement<'a>> : Clone + Copy { - fn parent_node(self) -> Option<Self>; - fn first_child(self) -> Option<Self>; - fn last_child(self) -> Option<Self>; - fn prev_sibling(self) -> Option<Self>; - fn next_sibling(self) -> Option<Self>; - fn is_document(self) -> bool; - fn is_element(self) -> bool; - fn as_element(self) -> E; - fn match_attr<F>(self, attr: &AttrSelector, test: F) -> bool where F: Fn(&str) -> bool; - fn is_html_element_in_html_document(self) -> bool; - - fn has_changed(self) -> bool; - unsafe fn set_changed(self, value: bool); - - fn is_dirty(self) -> bool; - unsafe fn set_dirty(self, value: bool); - - fn has_dirty_siblings(self) -> bool; - unsafe fn set_dirty_siblings(self, value: bool); - - fn has_dirty_descendants(self) -> bool; - unsafe fn set_dirty_descendants(self, value: bool); -} - -pub trait TElement<'a> : Copy { - fn get_attr(self, namespace: &Namespace, attr: &Atom) -> Option<&'a str>; - fn get_attrs(self, attr: &Atom) -> Vec<&'a str>; - fn get_link(self) -> Option<&'a str>; - fn get_local_name(self) -> &'a Atom; - fn get_namespace(self) -> &'a Namespace; - fn get_hover_state(self) -> bool; - fn get_id(self) -> Option<Atom>; - fn get_disabled_state(self) -> bool; - fn get_enabled_state(self) -> bool; - fn get_checked_state(self) -> bool; - fn get_indeterminate_state(self) -> bool; - fn has_class(self, name: &Atom) -> bool; - fn has_nonzero_border(self) -> bool; - - // Ordinarily I wouldn't use callbacks like this, but the alternative is - // really messy, since there is a `JSRef` and a `RefCell` involved. Maybe - // in the future when we have associated types and/or a more convenient - // JS GC story... --pcwalton - fn each_class<F>(self, callback: F) where F: FnMut(&Atom); -} +pub use selectors::tree::{TNode, TElement}; pub trait TElementAttributes : Copy { fn get_length_attribute(self, attribute: LengthAttribute) -> LengthOrPercentageOrAuto; |