Title: [124563] trunk/Source/WebCore
Revision
124563
Author
[email protected]
Date
2012-08-02 22:32:32 -0700 (Thu, 02 Aug 2012)

Log Message

V8Proxy::retrieveFrameFor*Context are used only by BindingState and should be removed as separate functions
https://bugs.webkit.org/show_bug.cgi?id=93049

Reviewed by Eric Seidel.

No one calls these functions directly anymore. This patch removes them
from V8Proxy and inlines their logic into BindingState.cpp.

* bindings/v8/BindingState.cpp:
(WebCore::activeContext):
(WebCore):
(WebCore::activeWindow):
(WebCore::activeFrame):
(WebCore::firstFrame):
(WebCore::currentFrame):
* bindings/v8/V8Proxy.cpp:
* bindings/v8/V8Proxy.h:
(V8Proxy):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124562 => 124563)


--- trunk/Source/WebCore/ChangeLog	2012-08-03 05:26:13 UTC (rev 124562)
+++ trunk/Source/WebCore/ChangeLog	2012-08-03 05:32:32 UTC (rev 124563)
@@ -1,3 +1,24 @@
+2012-08-02  Adam Barth  <[email protected]>
+
+        V8Proxy::retrieveFrameFor*Context are used only by BindingState and should be removed as separate functions
+        https://bugs.webkit.org/show_bug.cgi?id=93049
+
+        Reviewed by Eric Seidel.
+
+        No one calls these functions directly anymore. This patch removes them
+        from V8Proxy and inlines their logic into BindingState.cpp.
+
+        * bindings/v8/BindingState.cpp:
+        (WebCore::activeContext):
+        (WebCore):
+        (WebCore::activeWindow):
+        (WebCore::activeFrame):
+        (WebCore::firstFrame):
+        (WebCore::currentFrame):
+        * bindings/v8/V8Proxy.cpp:
+        * bindings/v8/V8Proxy.h:
+        (V8Proxy):
+
 2012-08-02  Yoshifumi Inoue  <[email protected]>
 
         Make order of attribute/method in HTMLTrackElement.idl as same as specification

Modified: trunk/Source/WebCore/bindings/v8/BindingState.cpp (124562 => 124563)


--- trunk/Source/WebCore/bindings/v8/BindingState.cpp	2012-08-03 05:26:13 UTC (rev 124562)
+++ trunk/Source/WebCore/bindings/v8/BindingState.cpp	2012-08-03 05:32:32 UTC (rev 124563)
@@ -44,15 +44,20 @@
     return &bindingStateForV8;
 }
 
+static v8::Handle<v8::Context> activeContext()
+{
+    v8::Handle<v8::Context> context = v8::Context::GetCalling();
+    if (!context.IsEmpty())
+        return context;
+    // Unfortunately, when processing script from a plug-in, we might not
+    // have a calling context. In those cases, we fall back to the
+    // entered context.
+    return v8::Context::GetEntered();
+}
+
 DOMWindow* activeWindow(BindingState*)
 {
-    v8::Local<v8::Context> activeContext = v8::Context::GetCalling();
-    if (activeContext.IsEmpty()) {
-        // There is a single activation record on the stack, so that must
-        // be the activeContext.
-        activeContext = v8::Context::GetCurrent();
-    }
-    return V8Proxy::retrieveWindow(activeContext);
+    return V8Proxy::retrieveWindow(activeContext());
 }
 
 DOMWindow* firstWindow(BindingState*)
@@ -62,26 +67,26 @@
 
 Frame* activeFrame(BindingState*)
 {
-    Frame* frame = V8Proxy::retrieveFrameForCallingContext();
-    if (!frame) {
-        // Unfortunately, when processing script from a plug-in, we might not
-        // have a calling context. In those cases, we fall back to the
-        // entered context for security checks.
-        // FIXME: We need a better API for retrieving frames that abstracts
-        //        away this concern.
-        frame = V8Proxy::retrieveFrameForEnteredContext();
-    }
-    return frame;
+    v8::Handle<v8::Context> context = activeContext();
+    if (context.IsEmpty())
+        return 0;
+    return V8Proxy::retrieveFrame(context);
 }
 
 Frame* firstFrame(BindingState*)
 {
-    return V8Proxy::retrieveFrameForEnteredContext();
+    v8::Handle<v8::Context> context = v8::Context::GetEntered();
+    if (context.IsEmpty())
+        return 0;
+    return V8Proxy::retrieveFrame(context);
 }
 
 Frame* currentFrame(BindingState*)
 {
-    return V8Proxy::retrieveFrameForCurrentContext();
+    v8::Handle<v8::Context> context = v8::Context::GetCurrent();
+    if (context.IsEmpty())
+        return 0;
+    return V8Proxy::retrieveFrame(context);
 }
 
 void immediatelyReportUnsafeAccessTo(BindingState*, Frame* target)

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (124562 => 124563)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-03 05:26:13 UTC (rev 124562)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-03 05:32:32 UTC (rev 124563)
@@ -490,30 +490,6 @@
     return 0;
 }
 
-Frame* V8Proxy::retrieveFrameForEnteredContext()
-{
-    v8::Handle<v8::Context> context = v8::Context::GetEntered();
-    if (context.IsEmpty())
-        return 0;
-    return retrieveFrame(context);
-}
-
-Frame* V8Proxy::retrieveFrameForCurrentContext()
-{
-    v8::Handle<v8::Context> context = v8::Context::GetCurrent();
-    if (context.IsEmpty())
-        return 0;
-    return retrieveFrame(context);
-}
-
-Frame* V8Proxy::retrieveFrameForCallingContext()
-{
-    v8::Handle<v8::Context> context = v8::Context::GetCalling();
-    if (context.IsEmpty())
-        return 0;
-    return retrieveFrame(context);
-}
-
 V8Proxy* V8Proxy::retrieve()
 {
     DOMWindow* window = retrieveWindow(v8::Context::GetCurrent());

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (124562 => 124563)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-03 05:26:13 UTC (rev 124562)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-03 05:32:32 UTC (rev 124563)
@@ -185,38 +185,6 @@
 
         static V8BindingPerContextData* retrievePerContextData(Frame*);
 
-        // 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'
-        // frame is.
-        //
-        // 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.
         static v8::Local<v8::Context> context(Frame*);
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to