diff options
-rw-r--r-- | webkit/port/bindings/v8/v8_proxy.cpp | 9 | ||||
-rw-r--r-- | webkit/port/bindings/v8/v8_proxy.h | 17 |
2 files changed, 23 insertions, 3 deletions
diff --git a/webkit/port/bindings/v8/v8_proxy.cpp b/webkit/port/bindings/v8/v8_proxy.cpp index 03c657d..3f6aa21 100644 --- a/webkit/port/bindings/v8/v8_proxy.cpp +++ b/webkit/port/bindings/v8/v8_proxy.cpp @@ -1653,6 +1653,15 @@ Frame* V8Proxy::retrieveFrameForCurrentContext() } +Frame* V8Proxy::retrieveFrameForCallingContext() +{ + v8::Handle<v8::Context> context = v8::Context::GetCalling(); + if (context.IsEmpty()) + return 0; + return retrieveFrame(context); +} + + Frame* V8Proxy::retrieveFrame() { DOMWindow* window = retrieveWindow(); diff --git a/webkit/port/bindings/v8/v8_proxy.h b/webkit/port/bindings/v8/v8_proxy.h index 4cb6892..c2bb66f 100644 --- a/webkit/port/bindings/v8/v8_proxy.h +++ b/webkit/port/bindings/v8/v8_proxy.h @@ -285,9 +285,9 @@ class V8Proxy { static Frame* retrieveFrame(v8::Handle<v8::Context> context); - // The two functions below retrieve WebFrame instances relating the currently - // executing JavaScript. Since JavaScript can make function calls across - // frames, though, we need to be more precise. + // The three functions below retrieve WebFrame instances relating the + // currently executing JavaScript. Since JavaScript can make function calls + // across frames, though, we need to be more precise. // // For example, imagine that a JS function in frame A calls a function in // frame B, which calls native code, which wants to know what the 'active' @@ -296,15 +296,26 @@ class V8Proxy { // The 'entered context' is the context where execution first entered the // script engine; the context that is at the bottom of the JS function stack. // RetrieveFrameForEnteredContext() would return Frame A in our example. + // This frame is often referred to as the "dynamic global object." // // The 'current context' is the context the JS engine is currently inside of; // the context that is at the top of the JS function stack. // RetrieveFrameForCurrentContext() would return Frame B in our example. + // This frame is often referred to as the "lexical global object." + // + // Finally, the 'calling context' is the context one below the current + // context on the JS function stack. For example, if function f calls + // function g, then the calling context will be the context associated with + // f. This context is commonly used by DOM security checks because they want + // to know who called them. + // + // If you are unsure which of these functions to use, ask abarth. // // NOTE: These cannot be declared as inline function, because VS complains at // linking time. static Frame* retrieveFrameForEnteredContext(); static Frame* retrieveFrameForCurrentContext(); + static Frame* retrieveFrameForCallingContext(); // Returns V8 Context of a frame. If none exists, creates // a new context. It is potentially slow and consumes memory. |