mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Separate the DOM and layout into separate crates.
This commit is contained in:
parent
0ea1a94f8e
commit
bf82bc54f3
156 changed files with 192 additions and 157 deletions
51
src/components/script/dom/domparser.rs
Normal file
51
src/components/script/dom/domparser.rs
Normal file
|
@ -0,0 +1,51 @@
|
|||
/* 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 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;
|
||||
use dom::window::Window;
|
||||
use script_task::global_script_context;
|
||||
|
||||
pub struct DOMParser {
|
||||
owner: @mut Window, //XXXjdm Document instead?
|
||||
wrapper: WrapperCache
|
||||
}
|
||||
|
||||
impl DOMParser {
|
||||
pub fn new(owner: @mut Window) -> @mut DOMParser {
|
||||
let parser = @mut DOMParser {
|
||||
owner: owner,
|
||||
wrapper: WrapperCache::new()
|
||||
};
|
||||
|
||||
let cx = global_script_context().js_compartment.cx.ptr;
|
||||
let cache = owner.get_wrappercache();
|
||||
let scope = cache.get_wrapper();
|
||||
parser.wrap_object_shared(cx, scope);
|
||||
parser
|
||||
}
|
||||
|
||||
pub fn Constructor(owner: @mut Window, _rv: &mut ErrorResult) -> @mut DOMParser {
|
||||
DOMParser::new(owner)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Add table
Add a link
Reference in a new issue