mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Remove Traceable from characterdata.rs
This commit is contained in:
parent
8de00ab999
commit
4f574b4732
6 changed files with 27 additions and 28 deletions
|
@ -187,7 +187,7 @@ impl<'ln> TLayoutNode for LayoutNode<'ln> {
|
||||||
unsafe {
|
unsafe {
|
||||||
if self.get().is_text() {
|
if self.get().is_text() {
|
||||||
let text: JS<Text> = self.get_jsmanaged().transmute_copy();
|
let text: JS<Text> = self.get_jsmanaged().transmute_copy();
|
||||||
(*text.unsafe_get()).characterdata.data.deref().borrow().clone()
|
(*text.unsafe_get()).characterdata.data.borrow().clone()
|
||||||
} else if self.get().is_htmlinputelement() {
|
} else if self.get().is_htmlinputelement() {
|
||||||
let input: JS<HTMLInputElement> = self.get_jsmanaged().transmute_copy();
|
let input: JS<HTMLInputElement> = self.get_jsmanaged().transmute_copy();
|
||||||
input.get_value_for_layout()
|
input.get_value_for_layout()
|
||||||
|
@ -711,7 +711,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
||||||
Some(TextNodeTypeId) => {
|
Some(TextNodeTypeId) => {
|
||||||
unsafe {
|
unsafe {
|
||||||
let text: JS<Text> = self.get_jsmanaged().transmute_copy();
|
let text: JS<Text> = self.get_jsmanaged().transmute_copy();
|
||||||
if !is_whitespace((*text.unsafe_get()).characterdata.data.deref().borrow().as_slice()) {
|
if !is_whitespace((*text.unsafe_get()).characterdata.data.borrow().as_slice()) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,6 @@ use dom::bindings::codegen::Bindings::CharacterDataBinding::CharacterDataMethods
|
||||||
use dom::bindings::codegen::InheritTypes::{CharacterDataDerived, NodeCast};
|
use dom::bindings::codegen::InheritTypes::{CharacterDataDerived, NodeCast};
|
||||||
use dom::bindings::error::{Fallible, ErrorResult, IndexSize};
|
use dom::bindings::error::{Fallible, ErrorResult, IndexSize};
|
||||||
use dom::bindings::js::JSRef;
|
use dom::bindings::js::JSRef;
|
||||||
use dom::bindings::trace::Traceable;
|
|
||||||
use dom::bindings::utils::{Reflectable, Reflector};
|
use dom::bindings::utils::{Reflectable, Reflector};
|
||||||
use dom::document::Document;
|
use dom::document::Document;
|
||||||
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
||||||
|
@ -21,7 +20,7 @@ use std::cell::RefCell;
|
||||||
#[must_root]
|
#[must_root]
|
||||||
pub struct CharacterData {
|
pub struct CharacterData {
|
||||||
pub node: Node,
|
pub node: Node,
|
||||||
pub data: Traceable<RefCell<DOMString>>,
|
pub data: RefCell<DOMString>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharacterDataDerived for EventTarget {
|
impl CharacterDataDerived for EventTarget {
|
||||||
|
@ -39,31 +38,31 @@ impl CharacterData {
|
||||||
pub fn new_inherited(id: NodeTypeId, data: DOMString, document: JSRef<Document>) -> CharacterData {
|
pub fn new_inherited(id: NodeTypeId, data: DOMString, document: JSRef<Document>) -> CharacterData {
|
||||||
CharacterData {
|
CharacterData {
|
||||||
node: Node::new_inherited(id, document),
|
node: Node::new_inherited(id, document),
|
||||||
data: Traceable::new(RefCell::new(data)),
|
data: RefCell::new(data),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
|
impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
|
||||||
fn Data(self) -> DOMString {
|
fn Data(self) -> DOMString {
|
||||||
self.data.deref().borrow().clone()
|
self.data.borrow().clone()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn SetData(self, arg: DOMString) -> ErrorResult {
|
fn SetData(self, arg: DOMString) -> ErrorResult {
|
||||||
*self.data.deref().borrow_mut() = arg;
|
*self.data.borrow_mut() = arg;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn Length(self) -> u32 {
|
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> {
|
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 {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -76,7 +75,7 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn ReplaceData(self, offset: u32, count: u32, arg: DOMString) -> ErrorResult {
|
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 {
|
if offset > length {
|
||||||
return Err(IndexSize);
|
return Err(IndexSize);
|
||||||
}
|
}
|
||||||
|
@ -85,10 +84,10 @@ impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
|
||||||
} else {
|
} else {
|
||||||
count
|
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(arg.as_slice());
|
||||||
data.push_str(self.data.deref().borrow().as_slice().slice((offset + count) as uint, length as uint));
|
data.push_str(self.data.borrow().as_slice().slice((offset + count) as uint, length as uint));
|
||||||
*self.data.deref().borrow_mut() = data;
|
*self.data.borrow_mut() = data;
|
||||||
// FIXME: Once we have `Range`, we should implement step7 to step11
|
// FIXME: Once we have `Range`, we should implement step7 to step11
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -648,7 +648,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
for child in title_elem.children() {
|
for child in title_elem.children() {
|
||||||
if child.is_text() {
|
if child.is_text() {
|
||||||
let text: JSRef<Text> = TextCast::to_ref(child).unwrap();
|
let text: JSRef<Text> = TextCast::to_ref(child).unwrap();
|
||||||
title.push_str(text.deref().characterdata.data.deref().borrow().as_slice());
|
title.push_str(text.deref().characterdata.data.borrow().as_slice());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -69,7 +69,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> String {
|
||||||
|
|
||||||
fn serialize_comment(comment: JSRef<Comment>, html: &mut String) {
|
fn serialize_comment(comment: JSRef<Comment>, html: &mut String) {
|
||||||
html.push_str("<!--");
|
html.push_str("<!--");
|
||||||
html.push_str(comment.deref().characterdata.data.deref().borrow().as_slice());
|
html.push_str(comment.deref().characterdata.data.borrow().as_slice());
|
||||||
html.push_str("-->");
|
html.push_str("-->");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,11 +82,11 @@ fn serialize_text(text: JSRef<Text>, html: &mut String) {
|
||||||
"style" | "script" | "xmp" | "iframe" |
|
"style" | "script" | "xmp" | "iframe" |
|
||||||
"noembed" | "noframes" | "plaintext" |
|
"noembed" | "noframes" | "plaintext" |
|
||||||
"noscript" if elem.deref().namespace == ns!(HTML)
|
"noscript" if elem.deref().namespace == ns!(HTML)
|
||||||
=> html.push_str(text.deref().characterdata.data.deref().borrow().as_slice()),
|
=> html.push_str(text.deref().characterdata.data.borrow().as_slice()),
|
||||||
_ => escape(text.deref().characterdata.data.deref().borrow().as_slice(), false, html)
|
_ => escape(text.deref().characterdata.data.borrow().as_slice(), false, html)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_ => escape(text.deref().characterdata.data.deref().borrow().as_slice(), false, html)
|
_ => escape(text.deref().characterdata.data.borrow().as_slice(), false, html)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -95,7 +95,7 @@ fn serialize_processing_instruction(processing_instruction: JSRef<ProcessingInst
|
||||||
html.push_str("<?");
|
html.push_str("<?");
|
||||||
html.push_str(processing_instruction.deref().target.as_slice());
|
html.push_str(processing_instruction.deref().target.as_slice());
|
||||||
html.push_char(' ');
|
html.push_char(' ');
|
||||||
html.push_str(processing_instruction.deref().characterdata.data.deref().borrow().as_slice());
|
html.push_str(processing_instruction.deref().characterdata.data.borrow().as_slice());
|
||||||
html.push_str("?>");
|
html.push_str("?>");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,7 +120,7 @@ fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &
|
||||||
match node.first_child().map(|child| child.root()) {
|
match node.first_child().map(|child| child.root()) {
|
||||||
Some(ref child) if child.is_text() => {
|
Some(ref child) if child.is_text() => {
|
||||||
let text: JSRef<CharacterData> = CharacterDataCast::to_ref(**child).unwrap();
|
let text: JSRef<CharacterData> = CharacterDataCast::to_ref(**child).unwrap();
|
||||||
if text.deref().data.deref().borrow().len() > 0 && text.deref().data.deref().borrow().as_slice().char_at(0) == '\n' {
|
if text.deref().data.borrow().len() > 0 && text.deref().data.borrow().as_slice().char_at(0) == '\n' {
|
||||||
html.push_char('\x0A');
|
html.push_char('\x0A');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
|
@ -1362,7 +1362,7 @@ impl Node {
|
||||||
CommentNodeTypeId => {
|
CommentNodeTypeId => {
|
||||||
let comment: JSRef<Comment> = CommentCast::to_ref(node).unwrap();
|
let comment: JSRef<Comment> = CommentCast::to_ref(node).unwrap();
|
||||||
let comment = comment.deref();
|
let comment = comment.deref();
|
||||||
let comment = Comment::new(comment.characterdata.data.deref().borrow().clone(), *document);
|
let comment = Comment::new(comment.characterdata.data.borrow().clone(), *document);
|
||||||
NodeCast::from_temporary(comment)
|
NodeCast::from_temporary(comment)
|
||||||
},
|
},
|
||||||
DocumentNodeTypeId => {
|
DocumentNodeTypeId => {
|
||||||
|
@ -1386,14 +1386,14 @@ impl Node {
|
||||||
TextNodeTypeId => {
|
TextNodeTypeId => {
|
||||||
let text: JSRef<Text> = TextCast::to_ref(node).unwrap();
|
let text: JSRef<Text> = TextCast::to_ref(node).unwrap();
|
||||||
let text = text.deref();
|
let text = text.deref();
|
||||||
let text = Text::new(text.characterdata.data.deref().borrow().clone(), *document);
|
let text = Text::new(text.characterdata.data.borrow().clone(), *document);
|
||||||
NodeCast::from_temporary(text)
|
NodeCast::from_temporary(text)
|
||||||
},
|
},
|
||||||
ProcessingInstructionNodeTypeId => {
|
ProcessingInstructionNodeTypeId => {
|
||||||
let pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
|
let pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
|
||||||
let pi = pi.deref();
|
let pi = pi.deref();
|
||||||
let pi = ProcessingInstruction::new(pi.target.clone(),
|
let pi = ProcessingInstruction::new(pi.target.clone(),
|
||||||
pi.characterdata.data.deref().borrow().clone(), *document);
|
pi.characterdata.data.borrow().clone(), *document);
|
||||||
NodeCast::from_temporary(pi)
|
NodeCast::from_temporary(pi)
|
||||||
},
|
},
|
||||||
}.root();
|
}.root();
|
||||||
|
@ -1660,7 +1660,7 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
self.wait_until_safe_to_modify_dom();
|
self.wait_until_safe_to_modify_dom();
|
||||||
|
|
||||||
let characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(self).unwrap();
|
let characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(self).unwrap();
|
||||||
*characterdata.data.deref().borrow_mut() = value;
|
*characterdata.data.borrow_mut() = value;
|
||||||
|
|
||||||
// Notify the document that the content of this node is different
|
// Notify the document that the content of this node is different
|
||||||
let document = self.owner_doc().root();
|
let document = self.owner_doc().root();
|
||||||
|
@ -1873,12 +1873,12 @@ impl<'a> NodeMethods for JSRef<'a, Node> {
|
||||||
let pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
|
let pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(node).unwrap();
|
||||||
let other_pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(other).unwrap();
|
let other_pi: JSRef<ProcessingInstruction> = ProcessingInstructionCast::to_ref(other).unwrap();
|
||||||
(pi.deref().target == other_pi.deref().target) &&
|
(pi.deref().target == other_pi.deref().target) &&
|
||||||
(*pi.deref().characterdata.data.deref().borrow() == *other_pi.deref().characterdata.data.deref().borrow())
|
(*pi.deref().characterdata.data.borrow() == *other_pi.deref().characterdata.data.borrow())
|
||||||
}
|
}
|
||||||
fn is_equal_characterdata(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
fn is_equal_characterdata(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
||||||
let characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(node).unwrap();
|
let characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(node).unwrap();
|
||||||
let other_characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(other).unwrap();
|
let other_characterdata: JSRef<CharacterData> = CharacterDataCast::to_ref(other).unwrap();
|
||||||
*characterdata.deref().data.deref().borrow() == *other_characterdata.deref().data.deref().borrow()
|
*characterdata.deref().data.borrow() == *other_characterdata.deref().data.borrow()
|
||||||
}
|
}
|
||||||
fn is_equal_element_attrs(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
fn is_equal_element_attrs(node: JSRef<Node>, other: JSRef<Node>) -> bool {
|
||||||
let element: JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
let element: JSRef<Element> = ElementCast::to_ref(node).unwrap();
|
||||||
|
|
|
@ -492,7 +492,7 @@ pub fn parse_html(page: &Page,
|
||||||
for child in scriptnode.children() {
|
for child in scriptnode.children() {
|
||||||
debug!("child = {:?}", child);
|
debug!("child = {:?}", child);
|
||||||
let text: JSRef<Text> = TextCast::to_ref(child).unwrap();
|
let text: JSRef<Text> = TextCast::to_ref(child).unwrap();
|
||||||
data.push_str(text.deref().characterdata.data.deref().borrow().as_slice());
|
data.push_str(text.deref().characterdata.data.borrow().as_slice());
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("script data = {:?}", data);
|
debug!("script data = {:?}", data);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue