mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Generate bindings for Node, CharacterData, Text, Element, and HTMLElement. Hook up text nodes to use the new bindings.
This commit is contained in:
parent
c9bc2046f6
commit
fd4efad70c
20 changed files with 1069 additions and 62 deletions
|
@ -4,8 +4,10 @@
|
|||
|
||||
//! DOM bindings for `CharacterData`.
|
||||
|
||||
use dom::bindings::utils::{DOMString, null_string, str};
|
||||
use dom::bindings::utils::{DOMString, null_string, str, ErrorResult};
|
||||
use dom::bindings::utils::{BindingObject, CacheableWrapper, WrapperCache};
|
||||
use dom::node::{Node, NodeTypeId, ScriptView};
|
||||
use js::jsapi::{JSObject, JSContext};
|
||||
|
||||
pub struct CharacterData {
|
||||
parent: Node<ScriptView>,
|
||||
|
@ -20,12 +22,12 @@ impl CharacterData {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn GetData(&self) -> DOMString {
|
||||
pub fn Data(&self) -> DOMString {
|
||||
copy self.data
|
||||
}
|
||||
|
||||
pub fn SetData(&mut self, arg: DOMString) {
|
||||
self.data = arg;
|
||||
pub fn SetData(&mut self, arg: &DOMString, _rv: &mut ErrorResult) {
|
||||
self.data = (*arg).clone();
|
||||
}
|
||||
|
||||
pub fn Length(&self) -> u32 {
|
||||
|
@ -35,28 +37,43 @@ impl CharacterData {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn SubstringData(&self, offset: u32, count: u32) -> DOMString {
|
||||
pub fn SubstringData(&self, offset: u32, count: u32, _rv: &mut ErrorResult) -> DOMString {
|
||||
match self.data {
|
||||
str(ref s) => str(s.slice(offset as uint, count as uint).to_str()),
|
||||
null_string => null_string
|
||||
}
|
||||
}
|
||||
|
||||
pub fn AppendData(&mut self, arg: DOMString) {
|
||||
pub fn AppendData(&mut self, arg: &DOMString, _rv: &mut ErrorResult) {
|
||||
let s = self.data.to_str();
|
||||
self.data = str(s.append(arg.to_str()));
|
||||
}
|
||||
|
||||
pub fn InsertData(&mut self, _offset: u32, _arg: DOMString) {
|
||||
pub fn InsertData(&mut self, _offset: u32, _arg: &DOMString, _rv: &mut ErrorResult) {
|
||||
fail!("CharacterData::InsertData() is unimplemented")
|
||||
}
|
||||
|
||||
pub fn DeleteData(&mut self, _offset: u32, _count: u32) {
|
||||
pub fn DeleteData(&mut self, _offset: u32, _count: u32, _rv: &mut ErrorResult) {
|
||||
fail!("CharacterData::DeleteData() is unimplemented")
|
||||
}
|
||||
|
||||
pub fn ReplaceData(&mut self, _offset: u32, _count: u32, _arg: DOMString) {
|
||||
pub fn ReplaceData(&mut self, _offset: u32, _count: u32, _arg: &DOMString, _rv: &mut ErrorResult) {
|
||||
fail!("CharacterData::ReplaceData() is unimplemented")
|
||||
}
|
||||
}
|
||||
|
||||
impl CacheableWrapper for CharacterData {
|
||||
fn get_wrappercache(&mut self) -> &mut WrapperCache {
|
||||
self.parent.get_wrappercache()
|
||||
}
|
||||
|
||||
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||
fail!(~"need to implement wrapping");
|
||||
}
|
||||
}
|
||||
|
||||
impl BindingObject for CharacterData {
|
||||
fn GetParentObject(&self, cx: *JSContext) -> Option<@mut CacheableWrapper> {
|
||||
self.parent.GetParentObject(cx)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue