mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
Instate a pre-wrap hook that outerizes its argument, to satisfy an undocumented JSAPI requirement.
This commit is contained in:
parent
8f63c9e1c8
commit
85285113e4
3 changed files with 24 additions and 4 deletions
|
@ -610,6 +610,25 @@ pub extern fn wrap_for_same_compartment(cx: *JSContext, obj: *JSObject) -> *JSOb
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub extern fn pre_wrap(cx: *mut JSContext, _scope: *mut JSObject,
|
||||||
|
obj: *mut JSObject, flags: c_uint) -> *mut JSObject {
|
||||||
|
unsafe {
|
||||||
|
let clasp = JS_GetClass(obj as *_);
|
||||||
|
let clasp = clasp as *js::Class;
|
||||||
|
match (*clasp).ext.outerObject {
|
||||||
|
Some(outerize) => {
|
||||||
|
debug!("found an outerize hook");
|
||||||
|
let obj = JSHandleObject { unnamed: &(obj as *_) };
|
||||||
|
outerize(cx as *_, obj) as *mut _
|
||||||
|
}
|
||||||
|
None => {
|
||||||
|
debug!("no outerize hook found");
|
||||||
|
obj
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub extern fn outerize_global(_cx: *JSContext, obj: JSHandleObject) -> *JSObject {
|
pub extern fn outerize_global(_cx: *JSContext, obj: JSHandleObject) -> *JSObject {
|
||||||
unsafe {
|
unsafe {
|
||||||
debug!("outerizing");
|
debug!("outerizing");
|
||||||
|
|
|
@ -11,7 +11,8 @@ use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, ElementCas
|
||||||
use dom::bindings::js::{JS, JSRef, RootCollection, Temporary, OptionalSettable};
|
use dom::bindings::js::{JS, JSRef, RootCollection, Temporary, OptionalSettable};
|
||||||
use dom::bindings::js::OptionalRootable;
|
use dom::bindings::js::OptionalRootable;
|
||||||
use dom::bindings::trace::{Traceable, Untraceable};
|
use dom::bindings::trace::{Traceable, Untraceable};
|
||||||
use dom::bindings::utils::{Reflectable, GlobalStaticData, wrap_for_same_compartment};
|
use dom::bindings::utils::{Reflectable, GlobalStaticData};
|
||||||
|
use dom::bindings::utils::{wrap_for_same_compartment, pre_wrap};
|
||||||
use dom::document::{Document, HTMLDocument, DocumentMethods, DocumentHelpers};
|
use dom::document::{Document, HTMLDocument, DocumentMethods, DocumentHelpers};
|
||||||
use dom::element::{Element, AttributeHandlers};
|
use dom::element::{Element, AttributeHandlers};
|
||||||
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
|
use dom::event::{Event_, ResizeEvent, ReflowEvent, ClickEvent, MouseDownEvent, MouseMoveEvent, MouseUpEvent};
|
||||||
|
@ -647,11 +648,11 @@ impl ScriptTask {
|
||||||
let callback = JS_SetWrapObjectCallbacks((*js_runtime).ptr,
|
let callback = JS_SetWrapObjectCallbacks((*js_runtime).ptr,
|
||||||
ptr::null(),
|
ptr::null(),
|
||||||
wrap_for_same_compartment,
|
wrap_for_same_compartment,
|
||||||
ptr::null());
|
None);
|
||||||
JS_SetWrapObjectCallbacks((*js_runtime).ptr,
|
JS_SetWrapObjectCallbacks((*js_runtime).ptr,
|
||||||
callback,
|
callback,
|
||||||
wrap_for_same_compartment,
|
wrap_for_same_compartment,
|
||||||
ptr::null());
|
Some(pre_wrap));
|
||||||
}
|
}
|
||||||
|
|
||||||
let js_context = js_runtime.cx();
|
let js_context = js_runtime.cx();
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit 07acb44df9b3f638743931f392c0ebe7040a7bab
|
Subproject commit 07f19496bd7703b502812a6b4228f08dec59ec0b
|
Loading…
Add table
Add a link
Reference in a new issue