diff options
author | Patrick Walton <pcwalton@mimiga.net> | 2013-05-28 17:13:40 -0700 |
---|---|---|
committer | Patrick Walton <pcwalton@mimiga.net> | 2013-05-28 17:13:40 -0700 |
commit | bf82bc54f349dd0944c37129af28dec6b43041fe (patch) | |
tree | 685e113347e8afd1965793aefc9743cd9f1f8494 /src/components/script/dom/bindings/domparser.rs | |
parent | 0ea1a94f8e8a07378d23552a620a45d610db31c7 (diff) | |
download | servo-bf82bc54f349dd0944c37129af28dec6b43041fe.tar.gz servo-bf82bc54f349dd0944c37129af28dec6b43041fe.zip |
Separate the DOM and layout into separate crates.
Diffstat (limited to 'src/components/script/dom/bindings/domparser.rs')
-rw-r--r-- | src/components/script/dom/bindings/domparser.rs | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/src/components/script/dom/bindings/domparser.rs b/src/components/script/dom/bindings/domparser.rs new file mode 100644 index 00000000000..21744e43eb2 --- /dev/null +++ b/src/components/script/dom/bindings/domparser.rs @@ -0,0 +1,44 @@ +/* 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::{CacheableWrapper, WrapperCache}; +use dom::bindings::utils::{BindingObject, DerivedWrapper}; +use dom::domparser::DOMParser; + +use js::jsapi::{JSContext, JSObject, JSVal}; +use js::glue::bindgen::{RUST_OBJECT_TO_JSVAL}; + +impl CacheableWrapper for DOMParser { + fn get_wrappercache(&mut self) -> &mut WrapperCache { + unsafe { cast::transmute(&self.wrapper) } + } + + fn wrap_object_shared(@mut self, cx: *JSContext, scope: *JSObject) -> *JSObject { + let mut unused = false; + DOMParserBinding::Wrap(cx, scope, self, &mut unused) + } +} + +impl BindingObject for DOMParser { + fn GetParentObject(&self, _cx: *JSContext) -> @mut CacheableWrapper { + return self.owner as @mut CacheableWrapper; + } +} + +impl DerivedWrapper for DOMParser { + fn wrap(&mut self, _cx: *JSContext, _scope: *JSObject, _vp: *mut JSVal) -> i32 { + fail!(~"nyi") + } + + fn wrap_shared(@mut self, cx: *JSContext, scope: *JSObject, vp: *mut JSVal) -> i32 { + let obj = self.wrap_object_shared(cx, scope); + if obj.is_null() { + return 0; + } else { + unsafe { *vp = RUST_OBJECT_TO_JSVAL(obj) }; + return 1; + } + } +} |