Remove Traceable from characterdata.rs

This commit is contained in:
Manish Goregaokar 2014-09-28 16:45:58 +05:30
parent 8de00ab999
commit 4f574b4732
6 changed files with 27 additions and 28 deletions

View file

@ -8,7 +8,6 @@ use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods
use dom::bindings::codegen::InheritTypes::{CharacterDataDerived, NodeCast};
use dom::bindings::error::{Fallible, ErrorResult, IndexSize};
use dom::bindings::js::JSRef;
use dom::bindings::trace::Traceable;
use dom::bindings::utils::{Reflectable, Reflector};
use dom::document::Document;
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
@ -21,7 +20,7 @@ use std::cell::RefCell;
#[must_root]
pub struct CharacterData {
pub node: Node,
pub data: Traceable<RefCell<DOMString>>,
pub data: RefCell<DOMString>,
}
impl CharacterDataDerived for EventTarget {
@ -39,31 +38,31 @@ impl CharacterData {
pub fn new_inherited(id: NodeTypeId, data: DOMString, document: JSRef<Document>) -> CharacterData {
CharacterData {
node: Node::new_inherited(id, document),
data: Traceable::new(RefCell::new(data)),
data: RefCell::new(data),
}
}
}
impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
fn Data(self) -> DOMString {
self.data.deref().borrow().clone()
self.data.borrow().clone()
}
fn SetData(self, arg: DOMString) -> ErrorResult {
*self.data.deref().borrow_mut() = arg;
*self.data.borrow_mut() = arg;
Ok(())
}
fn Length(self) -> u32 {
self.data.deref().borrow().len() as u32
self.data.borrow().len() as u32
}
fn SubstringData(self, offset: u32, count: u32) -> Fallible<DOMString> {
Ok(self.data.deref().borrow().as_slice().slice(offset as uint, count as uint).to_string())
Ok(self.data.borrow().as_slice().slice(offset as uint, count as uint).to_string())
}
fn AppendData(self, arg: DOMString) -> ErrorResult {
self.data.deref().borrow_mut().push_str(arg.as_slice());
self.data.borrow_mut().push_str(arg.as_slice());
Ok(())
}
@ -76,7 +75,7 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
}
fn ReplaceData(self, offset: u32, count: u32, arg: DOMString) -> ErrorResult {
let length = self.data.deref().borrow().len() as u32;
let length = self.data.borrow().len() as u32;
if offset > length {
return Err(IndexSize);
}
@ -85,10 +84,10 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
} else {
count
};
let mut data = self.data.deref().borrow().as_slice().slice(0, offset as uint).to_string();
let mut data = self.data.borrow().as_slice().slice(0, offset as uint).to_string();
data.push_str(arg.as_slice());
data.push_str(self.data.deref().borrow().as_slice().slice((offset + count) as uint, length as uint));
*self.data.deref().borrow_mut() = data;
data.push_str(self.data.borrow().as_slice().slice((offset + count) as uint, length as uint));
*self.data.borrow_mut() = data;
// FIXME: Once we have `Range`, we should implement step7 to step11
Ok(())
}