mirror of
https://github.com/servo/servo.git
synced 2025-06-21 15:49:04 +01:00
Rewrite Text::new to current standards.
This commit is contained in:
parent
8c388f6bd4
commit
da37fde44f
3 changed files with 11 additions and 10 deletions
|
@ -250,9 +250,7 @@ impl Document {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn CreateTextNode(&self, abstract_self: AbstractDocument, data: &DOMString) -> AbstractNode<ScriptView> {
|
pub fn CreateTextNode(&self, abstract_self: AbstractDocument, data: &DOMString) -> AbstractNode<ScriptView> {
|
||||||
let cx = self.get_cx();
|
Text::new(null_str_as_empty(data), abstract_self)
|
||||||
let text = @Text::new(null_str_as_empty(data), abstract_self);
|
|
||||||
unsafe { Node::as_abstract_node(cx, text) }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn CreateComment(&self, abstract_self: AbstractDocument, data: &DOMString) -> AbstractNode<ScriptView> {
|
pub fn CreateComment(&self, abstract_self: AbstractDocument, data: &DOMString) -> AbstractNode<ScriptView> {
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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::bindings::utils::{DOMString, Fallible, null_str_as_empty};
|
||||||
use dom::characterdata::CharacterData;
|
use dom::characterdata::CharacterData;
|
||||||
use dom::document::AbstractDocument;
|
use dom::document::AbstractDocument;
|
||||||
|
@ -14,17 +15,19 @@ pub struct Text {
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Text {
|
impl Text {
|
||||||
/// Creates a new HTML text node.
|
pub fn new_inherited(text: ~str, document: AbstractDocument) -> Text {
|
||||||
pub fn new(text: ~str, document: AbstractDocument) -> Text {
|
|
||||||
Text {
|
Text {
|
||||||
element: CharacterData::new(TextNodeTypeId, text, document)
|
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>> {
|
pub fn Constructor(owner: @mut Window, text: &DOMString) -> Fallible<AbstractNode<ScriptView>> {
|
||||||
let cx = owner.get_cx();
|
Ok(Text::new(null_str_as_empty(text), owner.Document()))
|
||||||
let text = @Text::new(null_str_as_empty(text), owner.Document());
|
|
||||||
Ok(unsafe { Node::as_abstract_node(cx, text) })
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn SplitText(&self, _offset: u32) -> Fallible<AbstractNode<ScriptView>> {
|
pub fn SplitText(&self, _offset: u32) -> Fallible<AbstractNode<ScriptView>> {
|
||||||
|
|
|
@ -415,8 +415,8 @@ pub fn parse_html(cx: *JSContext,
|
||||||
},
|
},
|
||||||
create_text: |data: ~str| {
|
create_text: |data: ~str| {
|
||||||
debug!("create text");
|
debug!("create text");
|
||||||
let text = @Text::new(data, document);
|
let text = Text::new(data, document);
|
||||||
unsafe { Node::as_abstract_node(cx, text).to_hubbub_node() }
|
unsafe { text.to_hubbub_node() }
|
||||||
},
|
},
|
||||||
ref_node: |_| {},
|
ref_node: |_| {},
|
||||||
unref_node: |_| {},
|
unref_node: |_| {},
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue