diff options
author | Ms2ger <ms2ger@gmail.com> | 2013-11-02 21:55:36 +0100 |
---|---|---|
committer | Ms2ger <ms2ger@gmail.com> | 2013-11-02 21:55:36 +0100 |
commit | da37fde44f634ae9ef57dc09ed5a6e01391527d1 (patch) | |
tree | 5d803b001097372337945b25cdca5e3417284a2d /src | |
parent | 8c388f6bd4650858faedf19ed90262507447b00d (diff) | |
download | servo-da37fde44f634ae9ef57dc09ed5a6e01391527d1.tar.gz servo-da37fde44f634ae9ef57dc09ed5a6e01391527d1.zip |
Rewrite Text::new to current standards.
Diffstat (limited to 'src')
-rw-r--r-- | src/components/script/dom/document.rs | 4 | ||||
-rw-r--r-- | src/components/script/dom/text.rs | 13 | ||||
-rw-r--r-- | src/components/script/html/hubbub_html_parser.rs | 4 |
3 files changed, 11 insertions, 10 deletions
diff --git a/src/components/script/dom/document.rs b/src/components/script/dom/document.rs index f889c5ddde2..32ea8cab74f 100644 --- a/src/components/script/dom/document.rs +++ b/src/components/script/dom/document.rs @@ -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> { 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>> { diff --git a/src/components/script/html/hubbub_html_parser.rs b/src/components/script/html/hubbub_html_parser.rs index d9813d502f4..155b60ccf85 100644 --- a/src/components/script/html/hubbub_html_parser.rs +++ b/src/components/script/html/hubbub_html_parser.rs @@ -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: |_| {}, |