aboutsummaryrefslogtreecommitdiffstats
path: root/src/components/script/dom/text.rs
diff options
context:
space:
mode:
authorMs2ger <ms2ger@gmail.com>2013-11-02 21:55:36 +0100
committerMs2ger <ms2ger@gmail.com>2013-11-02 21:55:36 +0100
commitda37fde44f634ae9ef57dc09ed5a6e01391527d1 (patch)
tree5d803b001097372337945b25cdca5e3417284a2d /src/components/script/dom/text.rs
parent8c388f6bd4650858faedf19ed90262507447b00d (diff)
downloadservo-da37fde44f634ae9ef57dc09ed5a6e01391527d1.tar.gz
servo-da37fde44f634ae9ef57dc09ed5a6e01391527d1.zip
Rewrite Text::new to current standards.
Diffstat (limited to 'src/components/script/dom/text.rs')
-rw-r--r--src/components/script/dom/text.rs13
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>> {