Fix code style in DOMParser

This commit is contained in:
Patrick Walton 2013-05-03 15:41:23 -07:00
parent a178a7a5d1
commit b17fffa9d9

View file

@ -1,6 +1,10 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 content::content_task::global_content; use content::content_task::global_content;
use dom::bindings::utils::{DOMString, ErrorResult, WrapperCache, CacheableWrapper};
use dom::bindings::codegen::DOMParserBinding; use dom::bindings::codegen::DOMParserBinding;
use dom::bindings::utils::{DOMString, ErrorResult, WrapperCache, CacheableWrapper};
use dom::document::Document; use dom::document::Document;
use dom::element::{Element, HTMLHtmlElement, HTMLHtmlElementTypeId}; use dom::element::{Element, HTMLHtmlElement, HTMLHtmlElementTypeId};
use dom::node::Node; use dom::node::Node;
@ -11,12 +15,13 @@ pub struct DOMParser {
wrapper: WrapperCache wrapper: WrapperCache
} }
pub impl DOMParser { impl DOMParser {
fn new(owner: @mut Window) -> @mut DOMParser { pub fn new(owner: @mut Window) -> @mut DOMParser {
let parser = @mut DOMParser { let parser = @mut DOMParser {
owner: owner, owner: owner,
wrapper: WrapperCache::new() wrapper: WrapperCache::new()
}; };
let cx = global_content().compartment.get().cx.ptr; let cx = global_content().compartment.get().cx.ptr;
let cache = owner.get_wrappercache(); let cache = owner.get_wrappercache();
let scope = cache.get_wrapper(); let scope = cache.get_wrapper();
@ -24,13 +29,23 @@ pub impl DOMParser {
parser parser
} }
fn Constructor(owner: @mut Window, _rv: &mut ErrorResult) -> @mut DOMParser { pub fn Constructor(owner: @mut Window, _rv: &mut ErrorResult) -> @mut DOMParser {
DOMParser::new(owner) DOMParser::new(owner)
} }
fn ParseFromString(&self, _s: DOMString, _type_: DOMParserBinding::SupportedType, _rv: &mut ErrorResult) -> @mut Document { pub fn ParseFromString(&self,
let root = ~HTMLHtmlElement { parent: Element::new(HTMLHtmlElementTypeId, ~"html") }; _s: DOMString,
let root = unsafe { Node::as_abstract_node(root) }; _type: DOMParserBinding::SupportedType,
Document(root, None) _rv: &mut ErrorResult)
-> @mut Document {
unsafe {
let root = ~HTMLHtmlElement {
parent: Element::new(HTMLHtmlElementTypeId, ~"html")
};
let root = Node::as_abstract_node(root);
Document(root, None)
}
} }
} }