mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Introduce a createText function.
This commit is contained in:
parent
849fba27ab
commit
b5457f7910
1 changed files with 9 additions and 8 deletions
|
@ -331,10 +331,7 @@ impl Document {
|
||||||
for title_child in child.children() {
|
for title_child in child.children() {
|
||||||
child.remove_child(title_child);
|
child.remove_child(title_child);
|
||||||
}
|
}
|
||||||
let new_text = unsafe {
|
child.add_child(self.createText(title.to_str()));
|
||||||
Node::as_abstract_node(cx, @Text::new(title.to_str()))
|
|
||||||
};
|
|
||||||
child.add_child(new_text);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if !has_title {
|
if !has_title {
|
||||||
|
@ -344,10 +341,7 @@ impl Document {
|
||||||
let new_title = unsafe {
|
let new_title = unsafe {
|
||||||
Node::as_abstract_node(cx, new_title)
|
Node::as_abstract_node(cx, new_title)
|
||||||
};
|
};
|
||||||
let new_text = unsafe {
|
new_title.add_child(self.createText(title.to_str()));
|
||||||
Node::as_abstract_node(cx, @Text::new(title.to_str()))
|
|
||||||
};
|
|
||||||
new_title.add_child(new_text);
|
|
||||||
node.add_child(new_title);
|
node.add_child(new_title);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
@ -444,6 +438,13 @@ impl Document {
|
||||||
elem.get_attr("name").is_some() && eq_slice(elem.get_attr("name").unwrap(), name.to_str()))
|
elem.get_attr("name").is_some() && eq_slice(elem.get_attr("name").unwrap(), name.to_str()))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn createText(&self, data: ~str) -> AbstractNode<ScriptView> {
|
||||||
|
let (_scope, cx) = self.get_scope_and_cx();
|
||||||
|
unsafe {
|
||||||
|
Node::as_abstract_node(cx, @Text::new(data))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub fn createHTMLCollection(&self, callback: &fn(elem: &Element) -> bool) -> @mut HTMLCollection {
|
pub fn createHTMLCollection(&self, callback: &fn(elem: &Element) -> bool) -> @mut HTMLCollection {
|
||||||
let mut elements = ~[];
|
let mut elements = ~[];
|
||||||
let _ = for child in self.root.traverse_preorder() {
|
let _ = for child in self.root.traverse_preorder() {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue