aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/node.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/style/node.rs')
-rw-r--r--components/style/node.rs34
1 files changed, 34 insertions, 0 deletions
diff --git a/components/style/node.rs b/components/style/node.rs
new file mode 100644
index 00000000000..85a4429e767
--- /dev/null
+++ b/components/style/node.rs
@@ -0,0 +1,34 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+//! Traits that nodes must implement. Breaks the otherwise-cyclic dependency between layout and
+//! style.
+
+use selectors::AttrSelector;
+use servo_util::atom::Atom;
+use servo_util::namespace::Namespace;
+
+
+pub trait TNode<E:TElement> : Clone {
+ fn parent_node(&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(&self, attr: &AttrSelector, test: |&str| -> bool) -> bool;
+ fn is_html_element_in_html_document(&self) -> bool;
+}
+
+pub trait TElement {
+ fn get_attr(&self, namespace: &Namespace, attr: &str) -> Option<&'static str>;
+ fn get_link(&self) -> Option<&'static str>;
+ fn get_local_name<'a>(&'a self) -> &'a Atom;
+ fn get_namespace<'a>(&'a 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;
+}
+