[webkit-dev] JavaJSObject vs JSObject

Per Bothner per.bothner at oracle.com
Mon Mar 21 18:00:43 PDT 2011


On 03/21/2011 04:55 PM, Darin Adler wrote:
> On Mar 21, 2011, at 4:48 PM, Per Bothner wrote:
>
>> Some Googling found references to webkit_web_frame_get_global_context() and
>> WebFrame::globalContext() but I didn't find these - maybe they're Cacoa-specific?
>...
> Depending on what platform you’re building on there will be some way to get the global context, and from there you can get the global object, which is the window object if the global context is for a webpage frame.

We're not building *on* a platform - we're building a *new* platform.
And there doesn't seem to be any method to directly get the global context.
So we'll add one.  As mentioned, the existing code does this various places:
toGlobalRef(frame()->script()->globalObject(mainThreadNormalWorld())->globalExec())
So it seems correct to wrap this up into a new getGlobalContext function.

>> The latter might be more efficient, but only as long as a the JSGlobalContextRef is stable.
>
> You’ll have one JSGlobalContextRef for each window object. It will only change when you load a new document into a frame or go away when you close the frame.
>
> At this point, though, I realize that I’m giving webkit-help kinds of information on webkit-dev that is supposed to be about development of WebKit, not use of WebKit for development of something else.

It's a gray area, it seems to me, since what we're doing is porting webkit
to a new platform.  It's not a just the Java bindings to JavaScript (though
that is what I'm focusing on right now) - we're also calling back into Java
for rending.
-- 
	--Per Bothner
per.bothner at oracle.com   per at bothner.com   http://per.bothner.com/


More information about the webkit-dev mailing list