Hi all,
I've been poking around quite a bit recently in the WebKit JS
bindings/constructor code, trying to make some sense of their widespread use
of the lexicalGlobalObject() - basically, it seems like looking at the
lexicalGlobalObject() is seldom what they actually want, because it means
that if you call between frames you unexpectedly start pulling things from a
different context.
As a very simple example (bear with me, I'll get to the chrome-specific
question in a second) - imagine that you have a page containing a child
frame. In the parent page, you define this:
function getImage() {
return new Image();
}
...now down in your child frame, you have code that does this:
var image1 = new Image();
var image2 = parent.window.getImage();
assert(image1.__proto__ == image2.__proto__); // Fails in WebKit currently,
because the Image constructor lookup uses the lexicalGlobalObject.
JSC defines dynamicGlobalObject() and lexicalGlobalObject() - I suspect that
they generally want to be using dynamicGlobalObject instead of
lexicalGlobalObject when trying to access something from global scope. Or am
I missing some subtlety here?
That brings me to my Chromium/V8 question - there are 3 context-grabbing
functions in V8: GetEntered(), GetCalling(), GetCurrent(). When is it
appropriate to use one over the others (what are the effective differences)?
The descriptions are kind of terse, and I'm afraid I'm missing some of the
subtleties between "the context of the calling JavaScript code" vs "The
context on the top of the stack" vs "The last entered context" (for example,
I would have naively thought that the calling JavaScript code's context
would *inherently* be the last entered one, and hence would be on the top of
the stack, but clearly that's not true :)
-atw
--~--~---------~--~----~------------~-------~--~----~
Chromium Developers mailing list: [email protected]
View archives, change email options, or unsubscribe:
http://groups.google.com/group/chromium-dev
-~----------~----~----~----~------~----~------~--~---