Rewrite Text::new to current standards.

This commit is contained in:
Ms2ger 2013-11-02 21:55:36 +01:00
parent 8c388f6bd4
commit da37fde44f
3 changed files with 11 additions and 10 deletions

View file

@ -250,9 +250,7 @@ impl Document {
}
pub fn CreateTextNode(&self, abstract_self: AbstractDocument, data: &DOMString) -> AbstractNode<ScriptView> {
let cx = self.get_cx();
let text = @Text::new(null_str_as_empty(data), abstract_self);
unsafe { Node::as_abstract_node(cx, text) }
Text::new(null_str_as_empty(data), abstract_self)
}
pub fn CreateComment(&self, abstract_self: AbstractDocument, data: &DOMString) -> AbstractNode<ScriptView> {

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::bindings::codegen::TextBinding;
use dom::bindings::utils::{DOMString, Fallible, null_str_as_empty};
use dom::characterdata::CharacterData;
use dom::document::AbstractDocument;
@ -14,17 +15,19 @@ pub struct Text {
}
impl Text {
/// Creates a new HTML text node.
pub fn new(text: ~str, document: AbstractDocument) -> Text {
pub fn new_inherited(text: ~str, document: AbstractDocument) -> Text {
Text {
element: CharacterData::new(TextNodeTypeId, text, document)
}
}
pub fn new(text: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> {
let node = Text::new_inherited(text, document);
Node::reflect_node(@mut node, document, TextBinding::Wrap)
}
pub fn Constructor(owner: @mut Window, text: &DOMString) -> Fallible<AbstractNode<ScriptView>> {
let cx = owner.get_cx();
let text = @Text::new(null_str_as_empty(text), owner.Document());
Ok(unsafe { Node::as_abstract_node(cx, text) })
Ok(Text::new(null_str_as_empty(text), owner.Document()))
}
pub fn SplitText(&self, _offset: u32) -> Fallible<AbstractNode<ScriptView>> {

View file

@ -415,8 +415,8 @@ pub fn parse_html(cx: *JSContext,
},
create_text: |data: ~str| {
debug!("create text");
let text = @Text::new(data, document);
unsafe { Node::as_abstract_node(cx, text).to_hubbub_node() }
let text = Text::new(data, document);
unsafe { text.to_hubbub_node() }
},
ref_node: |_| {},
unref_node: |_| {},