mirror of
https://github.com/servo/servo.git
synced 2025-08-05 21:50:18 +01:00
Cleanup DOMParser binding.
This commit is contained in:
parent
13644ccab1
commit
4c69d748bd
3 changed files with 27 additions and 37 deletions
|
@ -1,27 +0,0 @@
|
||||||
/* 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::{Reflectable, Reflector};
|
|
||||||
use dom::domparser::DOMParser;
|
|
||||||
|
|
||||||
use js::jsapi::{JSContext, JSObject};
|
|
||||||
|
|
||||||
impl Reflectable for DOMParser {
|
|
||||||
fn reflector<'a>(&'a self) -> &'a Reflector {
|
|
||||||
&self.reflector_
|
|
||||||
}
|
|
||||||
|
|
||||||
fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector {
|
|
||||||
&mut self.reflector_
|
|
||||||
}
|
|
||||||
|
|
||||||
fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject {
|
|
||||||
DOMParserBinding::Wrap(cx, scope, self)
|
|
||||||
}
|
|
||||||
|
|
||||||
fn GetParentObject(&self, _cx: *JSContext) -> Option<@mut Reflectable> {
|
|
||||||
Some(self.owner as @mut Reflectable)
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -4,28 +4,29 @@
|
||||||
|
|
||||||
use dom::bindings::codegen::DOMParserBinding;
|
use dom::bindings::codegen::DOMParserBinding;
|
||||||
use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml};
|
use dom::bindings::codegen::DOMParserBinding::SupportedTypeValues::{Text_html, Text_xml};
|
||||||
use dom::bindings::utils::{DOMString, Fallible, Reflector, Reflectable, FailureUnknown};
|
use dom::bindings::utils::{DOMString, Fallible, Reflector, Reflectable, FailureUnknown, reflect_dom_object};
|
||||||
use dom::document::{AbstractDocument, Document, XML};
|
use dom::document::{AbstractDocument, Document, XML};
|
||||||
use dom::htmldocument::HTMLDocument;
|
use dom::htmldocument::HTMLDocument;
|
||||||
use dom::window::Window;
|
use dom::window::Window;
|
||||||
|
|
||||||
|
use js::jsapi::{JSContext, JSObject};
|
||||||
|
|
||||||
pub struct DOMParser {
|
pub struct DOMParser {
|
||||||
owner: @mut Window, //XXXjdm Document instead?
|
owner: @mut Window, //XXXjdm Document instead?
|
||||||
reflector_: Reflector
|
reflector_: Reflector
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DOMParser {
|
impl DOMParser {
|
||||||
pub fn new(owner: @mut Window) -> @mut DOMParser {
|
pub fn new_inherited(owner: @mut Window) -> DOMParser {
|
||||||
let parser = @mut DOMParser {
|
DOMParser {
|
||||||
owner: owner,
|
owner: owner,
|
||||||
reflector_: Reflector::new()
|
reflector_: Reflector::new()
|
||||||
};
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// TODO(tkuehn): This just handles the top-level page. Need to handle subframes.
|
pub fn new(owner: @mut Window) -> @mut DOMParser {
|
||||||
let cx = owner.get_cx();
|
reflect_dom_object(@mut DOMParser::new_inherited(owner), owner,
|
||||||
let scope = owner.reflector().get_jsobject();
|
DOMParserBinding::Wrap)
|
||||||
parser.wrap_object_shared(cx, scope);
|
|
||||||
parser
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Constructor(owner: @mut Window) -> Fallible<@mut DOMParser> {
|
pub fn Constructor(owner: @mut Window) -> Fallible<@mut DOMParser> {
|
||||||
|
@ -51,3 +52,20 @@ impl DOMParser {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Reflectable for DOMParser {
|
||||||
|
fn reflector<'a>(&'a self) -> &'a Reflector {
|
||||||
|
&self.reflector_
|
||||||
|
}
|
||||||
|
|
||||||
|
fn mut_reflector<'a>(&'a mut self) -> &'a mut Reflector {
|
||||||
|
&mut self.reflector_
|
||||||
|
}
|
||||||
|
|
||||||
|
fn wrap_object_shared(@mut self, _cx: *JSContext, _scope: *JSObject) -> *JSObject {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
|
||||||
|
fn GetParentObject(&self, _cx: *JSContext) -> Option<@mut Reflectable> {
|
||||||
|
Some(self.owner as @mut Reflectable)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ pub mod dom {
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
pub mod conversions;
|
pub mod conversions;
|
||||||
pub mod proxyhandler;
|
pub mod proxyhandler;
|
||||||
pub mod domparser;
|
|
||||||
pub mod codegen {
|
pub mod codegen {
|
||||||
pub use self::BindingDeclarations::*;
|
pub use self::BindingDeclarations::*;
|
||||||
pub mod InterfaceTypes;
|
pub mod InterfaceTypes;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue