aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/characterdata.rs
diff options
context:
space:
mode:
authorJinwoo Song <jinwoo7.song@samsung.com>2015-04-28 14:09:31 +0900
committerJinwoo Song <jinwoo7.song@samsung.com>2015-04-29 13:30:21 +0900
commitf404853c99a5e4912bff09882d20e1856fbd405b (patch)
tree480b9d9e5af1e091bd419d62c0a8e14107647b0b /components/script/dom/characterdata.rs
parent1e150140bd12624ad357e3168fb496079fb8ec7c (diff)
downloadservo-f404853c99a5e4912bff09882d20e1856fbd405b.tar.gz
servo-f404853c99a5e4912bff09882d20e1856fbd405b.zip
Make NodeTypeId include CharacterData variant
NodeTypeId is supposed to reflect the WebIDL inheritance hierarchy. All of Text/ProcessingInstruction/Comment inherit from CharacterData, which inherits from Node. There should be a CharacterDataTypeId value that differentiates between those, instead.
Diffstat (limited to 'components/script/dom/characterdata.rs')
-rw-r--r--components/script/dom/characterdata.rs17
1 files changed, 12 insertions, 5 deletions
diff --git a/components/script/dom/characterdata.rs b/components/script/dom/characterdata.rs
index 677541045d8..3ea3609c7d7 100644
--- a/components/script/dom/characterdata.rs
+++ b/components/script/dom/characterdata.rs
@@ -33,18 +33,16 @@ pub struct CharacterData {
impl CharacterDataDerived for EventTarget {
fn is_characterdata(&self) -> bool {
match *self.type_id() {
- EventTargetTypeId::Node(NodeTypeId::Text) |
- EventTargetTypeId::Node(NodeTypeId::Comment) |
- EventTargetTypeId::Node(NodeTypeId::ProcessingInstruction) => true,
+ EventTargetTypeId::Node(NodeTypeId::CharacterData(_)) => true,
_ => false
}
}
}
impl CharacterData {
- pub fn new_inherited(id: NodeTypeId, data: DOMString, document: JSRef<Document>) -> CharacterData {
+ pub fn new_inherited(id: CharacterDataTypeId, data: DOMString, document: JSRef<Document>) -> CharacterData {
CharacterData {
- node: Node::new_inherited(id, document),
+ node: Node::new_inherited(NodeTypeId::CharacterData(id), document),
data: DOMRefCell::new(data),
}
}
@@ -153,6 +151,15 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
}
}
+/// The different types of CharacterData.
+#[derive(Copy, Clone, PartialEq, Debug)]
+#[jstraceable]
+pub enum CharacterDataTypeId {
+ Comment,
+ Text,
+ ProcessingInstruction,
+}
+
pub trait CharacterDataHelpers<'a> {
fn data(self) -> Ref<'a, DOMString>;
}