Implement the [Exposed] extended attribute on interfaces.

Fixes #2823.
This commit is contained in:
Ms2ger 2016-07-08 15:48:55 +02:00
parent c064c4950d
commit d678b20616
4 changed files with 54 additions and 16 deletions

View file

@ -4,6 +4,7 @@
//! Machinery to initialise interface prototype objects and interface objects.
use dom::bindings::codegen::InterfaceObjectMap::Globals;
use dom::bindings::codegen::PrototypeList;
use dom::bindings::conversions::get_dom_class;
use dom::bindings::guard::Guard;
@ -484,3 +485,11 @@ unsafe extern "C" fn non_new_constructor(
throw_type_error(cx, "This constructor needs to be called with `new`.");
false
}
/// Returns whether an interface with exposure set given by `globals` should
/// be exposed in the global object `obj`.
pub unsafe fn is_exposed_in(object: HandleObject, globals: Globals) -> bool {
let unwrapped = UncheckedUnwrapObject(object.get(), /* stopAtWindowProxy = */ 0);
let dom_class = get_dom_class(unwrapped).unwrap();
globals.contains(dom_class.global)
}