Re: Workers

On Thu, 24 Jul 2008, Jonas Sicking wrote:
> Ian Hickson wrote:
> > > (why it is "window" btw?)
> > 
> > Because it is implemented by the Window object.
> 
> I don't think this is true.

It's defined to be true at the moment, the way the spec is written.


> Our DOM implementation (which includes the Window object) is not thread 
> safe. We are using a separate object as the global scope for the worker 
> threads.

That's an implementation detail.


> > For legacy reasons the global object is generally called 'window'.  
> > To allow easy porting of code to workers, we have kept the same names.
> 
> I actually found it intensely confusing that it is called Window* since 
> it is a separate object from the Window object.
> 
> I think the name WorkerGlobalScope or some such would be much more 
> intuitive.

Well we need 'window' to be a property of the global object pointing to 
the global object, to allow easy porting of code to workers. It seems 
weird to have 'window' point to an object that isn't a Window.

Note that Window as defined by HTML5 only has a few members:

   http://www.whatwg.org/specs/web-apps/current-work/#window

The majority of the members seen on browsing context global objects are on 
the WindowBrowsingContext interface:

   http://www.whatwg.org/specs/web-apps/current-work/#windowbrowsingcontext

The members on Window are those common to global objects in both browsing 
contexts and workers. It seemed better than duplicating all the members. 
It also allows for the specs to say things like "Objects that implement 
the Window interface must also implement the WindowFoo interface", which 
is how we get WindowWorkerCreators' members in both browsing contexts' and 
workers' global objects:

   http://www.whatwg.org/specs/web-workers/current-work/#windowworkercreators

...and how we get WindowTimers' members in both browsing contexts' and 
workers' global objects:

   http://www.whatwg.org/specs/web-apps/current-work/#windowtimers

None of this requires any particular implementation strategy, as all the 
interfaces except Window itself are marked [NoInterfaceObject], and 
browsing contexts and workers are completely script-isolated.

-- 
Ian Hickson               U+1047E                )\._.,--....,'``.    fL
http://ln.hixie.ch/       U+263A                /,   _.. \   _\  ;`._ ,.
Things that are impossible just take longer.   `._.-(,_..'--(,_..'`-.;.'

Received on Friday, 25 July 2008 02:38:49 UTC