Implement JSManaged for DOM objects.

This commit is contained in:
Josh Matthews 2013-11-30 21:04:49 +01:00
parent 061269f963
commit 625325434b
137 changed files with 3644 additions and 2778 deletions

View file

@ -4,19 +4,34 @@
//! DOM bindings for `CharacterData`.
use dom::bindings::codegen::InheritTypes::CharacterDataDerived;
use dom::bindings::js::JS;
use dom::bindings::utils::{Fallible, ErrorResult};
use dom::bindings::utils::{Reflectable, Reflector};
use dom::document::AbstractDocument;
use dom::node::{Node, NodeTypeId};
use dom::document::Document;
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::node::{CommentNodeTypeId, Node, NodeTypeId, TextNodeTypeId, ProcessingInstructionNodeTypeId};
use servo_util::str::DOMString;
#[deriving(Encodable)]
pub struct CharacterData {
node: Node,
data: DOMString,
}
impl CharacterDataDerived for EventTarget {
fn is_characterdata(&self) -> bool {
match self.type_id {
NodeTargetTypeId(TextNodeTypeId) |
NodeTargetTypeId(CommentNodeTypeId) |
NodeTargetTypeId(ProcessingInstructionNodeTypeId) => true,
_ => false
}
}
}
impl CharacterData {
pub fn new_inherited(id: NodeTypeId, data: DOMString, document: AbstractDocument) -> CharacterData {
pub fn new_inherited(id: NodeTypeId, data: DOMString, document: JS<Document>) -> CharacterData {
CharacterData {
node: Node::new_inherited(id, document),
data: data