Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor flow #416

Merged
merged 12 commits into from May 7, 2013

Fix code style in DOMParser

  • Loading branch information
pcwalton committed May 6, 2013
commit b17fffa9d926f4a2a805445c68f120c7912f2c57
@@ -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 dom::bindings::utils::{DOMString, ErrorResult, WrapperCache, CacheableWrapper};
use dom::bindings::codegen::DOMParserBinding;
use dom::bindings::utils::{DOMString, ErrorResult, WrapperCache, CacheableWrapper};
use dom::document::Document;
use dom::element::{Element, HTMLHtmlElement, HTMLHtmlElementTypeId};
use dom::node::Node;
@@ -11,26 +15,37 @@ pub struct DOMParser {
wrapper: WrapperCache
}

pub impl DOMParser {
fn new(owner: @mut Window) -> @mut DOMParser {
impl DOMParser {
pub fn new(owner: @mut Window) -> @mut DOMParser {
let parser = @mut DOMParser {
owner: owner,
wrapper: WrapperCache::new()
};

let cx = global_content().compartment.get().cx.ptr;
let cache = owner.get_wrappercache();
let scope = cache.get_wrapper();
parser.wrap_object_shared(cx, scope);
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)
}

fn ParseFromString(&self, _s: DOMString, _type_: DOMParserBinding::SupportedType, _rv: &mut ErrorResult) -> @mut Document {
let root = ~HTMLHtmlElement { parent: Element::new(HTMLHtmlElementTypeId, ~"html") };
let root = unsafe { Node::as_abstract_node(root) };
Document(root, None)
pub fn ParseFromString(&self,
_s: DOMString,
_type: DOMParserBinding::SupportedType,
_rv: &mut ErrorResult)
-> @mut Document {
unsafe {
let root = ~HTMLHtmlElement {
parent: Element::new(HTMLHtmlElementTypeId, ~"html")
};

let root = Node::as_abstract_node(root);
Document(root, None)
}
}
}
}

ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.