diff options
Diffstat (limited to 'src/components/script/dom/text.rs')
-rw-r--r-- | src/components/script/dom/text.rs | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/src/components/script/dom/text.rs b/src/components/script/dom/text.rs index 71c538a7d6c..e0fd493d887 100644 --- a/src/components/script/dom/text.rs +++ b/src/components/script/dom/text.rs @@ -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>> { |