Implement stub classes for WorkerGlobalScope and DedicatedWorkerGlobalScope.

Part of #2811.
This commit is contained in:
Ms2ger 2014-07-12 17:25:59 +02:00
parent 712955e96a
commit a345f413cb
8 changed files with 104 additions and 0 deletions

View file

@ -15,6 +15,9 @@
DOMInterfaces = {
'DedicatedWorkerGlobalScope': {
'createGlobal': True,
},
'EventListener': {
'nativeType': 'EventListenerBinding::EventListener',
},

View file

@ -0,0 +1,33 @@
/* 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::InheritTypes::DedicatedWorkerGlobalScopeDerived;
use dom::bindings::utils::{Reflectable, Reflector};
use dom::eventtarget::EventTarget;
use dom::eventtarget::WorkerGlobalScopeTypeId;
use dom::workerglobalscope::DedicatedGlobalScope;
use dom::workerglobalscope::WorkerGlobalScope;
#[deriving(Encodable)]
pub struct DedicatedWorkerGlobalScope {
workerglobalscope: WorkerGlobalScope,
}
pub trait DedicatedWorkerGlobalScopeMethods {
}
impl Reflectable for DedicatedWorkerGlobalScope {
fn reflector<'a>(&'a self) -> &'a Reflector {
self.workerglobalscope.reflector()
}
}
impl DedicatedWorkerGlobalScopeDerived for EventTarget {
fn is_dedicatedworkerglobalscope(&self) -> bool {
match self.type_id {
WorkerGlobalScopeTypeId(DedicatedGlobalScope) => true,
_ => false
}
}
}

View file

@ -12,6 +12,7 @@ use dom::bindings::utils::{Reflectable, Reflector};
use dom::event::Event;
use dom::eventdispatcher::dispatch_event;
use dom::node::NodeTypeId;
use dom::workerglobalscope::WorkerGlobalScopeId;
use dom::xmlhttprequest::XMLHttpRequestId;
use dom::virtualmethods::VirtualMethods;
use js::jsapi::{JS_CompileUCFunction, JS_GetFunctionObject, JS_CloneFunctionObject};
@ -34,6 +35,7 @@ pub enum ListenerPhase {
pub enum EventTargetTypeId {
NodeTargetTypeId(NodeTypeId),
WindowTypeId,
WorkerGlobalScopeTypeId(WorkerGlobalScopeId),
XMLHttpRequestTargetTypeId(XMLHttpRequestId)
}

View file

@ -0,0 +1,10 @@
/* 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/. */
// http://www.whatwg.org/html/#dedicatedworkerglobalscope
[Global/*=Worker,DedicatedWorker*/]
/*sealed*/ interface DedicatedWorkerGlobalScope : WorkerGlobalScope {
//void postMessage(any message, optional sequence<Transferable> transfer);
// attribute EventHandler onmessage;
};

View file

@ -0,0 +1,27 @@
/* 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/. */
// http://www.whatwg.org/html/#workerglobalscope
//[Exposed=Worker]
interface WorkerGlobalScope : EventTarget {
//readonly attribute WorkerGlobalScope self;
//readonly attribute WorkerLocation location;
//void close();
// attribute OnErrorEventHandler onerror;
// attribute EventHandler onlanguagechange;
// attribute EventHandler onoffline;
// attribute EventHandler ononline;
// also has obsolete members
};
// http://www.whatwg.org/html/#WorkerGlobalScope-partial
//[Exposed=Worker]
partial interface WorkerGlobalScope {
//void importScripts(DOMString... urls);
//readonly attribute WorkerNavigator navigator;
};
//WorkerGlobalScope implements WindowTimers;
//WorkerGlobalScope implements WindowBase64;

View file

@ -0,0 +1,25 @@
/* 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::utils::{Reflectable, Reflector};
use dom::eventtarget::EventTarget;
#[deriving(PartialEq,Encodable)]
pub enum WorkerGlobalScopeId {
DedicatedGlobalScope,
}
#[deriving(Encodable)]
pub struct WorkerGlobalScope {
pub eventtarget: EventTarget,
}
pub trait WorkerGlobalScopeMethods {
}
impl Reflectable for WorkerGlobalScope {
fn reflector<'a>(&'a self) -> &'a Reflector {
self.eventtarget.reflector()
}
}

View file

@ -75,6 +75,7 @@ pub mod dom {
pub mod comment;
pub mod console;
pub mod customevent;
pub mod dedicatedworkerglobalscope;
pub mod document;
pub mod documentfragment;
pub mod documenttype;
@ -174,6 +175,7 @@ pub mod dom {
pub mod virtualmethods;
pub mod window;
pub mod worker;
pub mod workerglobalscope;
pub mod xmlhttprequest;
pub mod xmlhttprequesteventtarget;
pub mod xmlhttprequestupload;

View file

@ -59,6 +59,7 @@ var interfaceNamesInGlobalScope = [
"Comment",
"Console",
"CustomEvent",
"DedicatedWorkerGlobalScope", // #2823
"Document",
"DocumentFragment",
"DocumentType",
@ -156,6 +157,7 @@ var interfaceNamesInGlobalScope = [
"ValidityState",
"Window",
"Worker",
"WorkerGlobalScope", // #2823
"XMLHttpRequest",
"XMLHttpRequestUpload",
];