Title: [124547] trunk/Source/WebCore
Revision
124547
Author
[email protected]
Date
2012-08-02 18:51:35 -0700 (Thu, 02 Aug 2012)

Log Message

V8 bindings code that tries to find its context should use BindingState functions rather than V8Proxy
https://bugs.webkit.org/show_bug.cgi?id=93038

Reviewed by Eric Seidel.

After this patch, most code in the V8 bindings that tries to determine
it's "context" goes through BindingState.h rather than V8Proxy. This
patch is a step towards unifying all these code paths.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateNamedConstructorCallback):
* bindings/v8/BindingState.cpp:
(WebCore::currentFrame):
(WebCore):
* bindings/v8/BindingState.h:
(WebCore):
* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::retrieveFrameForEnteredContext):
(WebCore::ScriptController::retrieveFrameForCurrentContext):
* bindings/v8/V8DOMWindowShell.cpp:
(WebCore::v8UncaughtExceptionHandler):
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::reportUnsafeAccessTo):
* bindings/v8/V8Proxy.h:
(V8Proxy):
* bindings/v8/V8Utilities.cpp:
(WebCore::getScriptExecutionContext):
* bindings/v8/custom/V8AudioContextCustom.cpp:
(WebCore::V8AudioContext::constructorCallback):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::handlePostMessageCallback):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::V8HTMLDocument::writeCallback):
(WebCore::V8HTMLDocument::writelnCallback):
(WebCore::V8HTMLDocument::openCallback):
* bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
(WebCore::v8HTMLImageElementConstructorCallback):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124546 => 124547)


--- trunk/Source/WebCore/ChangeLog	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/ChangeLog	2012-08-03 01:51:35 UTC (rev 124547)
@@ -1,3 +1,43 @@
+2012-08-02  Adam Barth  <[email protected]>
+
+        V8 bindings code that tries to find its context should use BindingState functions rather than V8Proxy
+        https://bugs.webkit.org/show_bug.cgi?id=93038
+
+        Reviewed by Eric Seidel.
+
+        After this patch, most code in the V8 bindings that tries to determine
+        it's "context" goes through BindingState.h rather than V8Proxy. This
+        patch is a step towards unifying all these code paths.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateNamedConstructorCallback):
+        * bindings/v8/BindingState.cpp:
+        (WebCore::currentFrame):
+        (WebCore):
+        * bindings/v8/BindingState.h:
+        (WebCore):
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::retrieveFrameForEnteredContext):
+        (WebCore::ScriptController::retrieveFrameForCurrentContext):
+        * bindings/v8/V8DOMWindowShell.cpp:
+        (WebCore::v8UncaughtExceptionHandler):
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::reportUnsafeAccessTo):
+        * bindings/v8/V8Proxy.h:
+        (V8Proxy):
+        * bindings/v8/V8Utilities.cpp:
+        (WebCore::getScriptExecutionContext):
+        * bindings/v8/custom/V8AudioContextCustom.cpp:
+        (WebCore::V8AudioContext::constructorCallback):
+        * bindings/v8/custom/V8DOMWindowCustom.cpp:
+        (WebCore::handlePostMessageCallback):
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        (WebCore::V8HTMLDocument::writeCallback):
+        (WebCore::V8HTMLDocument::writelnCallback):
+        (WebCore::V8HTMLDocument::openCallback):
+        * bindings/v8/custom/V8HTMLImageElementConstructor.cpp:
+        (WebCore::v8HTMLImageElementConstructorCallback):
+
 2012-08-02  Sheriff Bot  <[email protected]>
 
         Unreviewed, rolling out r124540.

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (124546 => 124547)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-08-03 01:51:35 UTC (rev 124547)
@@ -1975,7 +1975,7 @@
     if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
         return args.Holder();
 
-    Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
+    Frame* frame = currentFrame(BindingState::instance());
     if (!frame)
         return V8Proxy::throwError(V8Proxy::ReferenceError, "${implClassName} constructor associated frame is unavailable", args.GetIsolate());
 

Modified: trunk/Source/WebCore/bindings/v8/BindingState.cpp (124546 => 124547)


--- trunk/Source/WebCore/bindings/v8/BindingState.cpp	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/v8/BindingState.cpp	2012-08-03 01:51:35 UTC (rev 124547)
@@ -79,6 +79,11 @@
     return V8Proxy::retrieveFrameForEnteredContext();
 }
 
+Frame* currentFrame(BindingState*)
+{
+    return V8Proxy::retrieveFrameForCurrentContext();
+}
+
 void immediatelyReportUnsafeAccessTo(BindingState*, Frame* target)
 {
     V8Proxy::reportUnsafeAccessTo(target);

Modified: trunk/Source/WebCore/bindings/v8/BindingState.h (124546 => 124547)


--- trunk/Source/WebCore/bindings/v8/BindingState.h	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/v8/BindingState.h	2012-08-03 01:51:35 UTC (rev 124547)
@@ -49,6 +49,10 @@
 Frame* activeFrame(BindingState*);
 Frame* firstFrame(BindingState*);
 
+// FIXME: When implementing this function for JSC, we need to understand if there
+// are any subtle differences between the currentFrame and the lexicalGlobalObject.
+Frame* currentFrame(BindingState*);
+
 void immediatelyReportUnsafeAccessTo(BindingState*, Frame*);
 
 }

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (124546 => 124547)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-03 01:51:35 UTC (rev 124547)
@@ -87,12 +87,12 @@
 
 Frame* ScriptController::retrieveFrameForEnteredContext()
 {
-    return V8Proxy::retrieveFrameForEnteredContext();
+    return firstFrame(BindingState::instance());
 }
 
 Frame* ScriptController::retrieveFrameForCurrentContext()
 {
-    return V8Proxy::retrieveFrameForCurrentContext();
+    return currentFrame(BindingState::instance());
 }
 
 bool ScriptController::canAccessFromCurrentOrigin(Frame *frame)

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp (124546 => 124547)


--- trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp	2012-08-03 01:51:35 UTC (rev 124547)
@@ -104,7 +104,7 @@
 static void v8UncaughtExceptionHandler(v8::Handle<v8::Message> message, v8::Handle<v8::Value> data)
 {
     // Use the frame where _javascript_ is called from.
-    Frame* frame = V8Proxy::retrieveFrameForEnteredContext();
+    Frame* frame = firstFrame(BindingState::instance());
     if (!frame)
         return;
 

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (124546 => 124547)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-03 01:51:35 UTC (rev 124547)
@@ -131,7 +131,7 @@
     if (!targetDocument)
         return;
 
-    Frame* source = V8Proxy::retrieveFrameForEnteredContext();
+    Frame* source = firstFrame(BindingState::instance());
     if (!source)
         return;
 
@@ -506,14 +506,6 @@
     return retrieveFrame(context);
 }
 
-DOMWindow* V8Proxy::retrieveWindowForCallingContext()
-{
-    v8::Handle<v8::Context> context = v8::Context::GetCalling();
-    if (context.IsEmpty())
-        return 0;
-    return retrieveWindow(context);
-}
-
 Frame* V8Proxy::retrieveFrameForCallingContext()
 {
     v8::Handle<v8::Context> context = v8::Context::GetCalling();

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (124546 => 124547)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-03 01:51:35 UTC (rev 124547)
@@ -215,7 +215,6 @@
         // linking time.
         static Frame* retrieveFrameForEnteredContext();
         static Frame* retrieveFrameForCurrentContext();
-        static DOMWindow* retrieveWindowForCallingContext();
         static Frame* retrieveFrameForCallingContext();
 
         // Returns V8 Context of a frame. If none exists, creates

Modified: trunk/Source/WebCore/bindings/v8/V8Utilities.cpp (124546 => 124547)


--- trunk/Source/WebCore/bindings/v8/V8Utilities.cpp	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/v8/V8Utilities.cpp	2012-08-03 01:51:35 UTC (rev 124547)
@@ -185,7 +185,7 @@
         return controller->workerContext();
 #endif
 
-    if (Frame* frame = V8Proxy::retrieveFrameForCurrentContext())
+    if (Frame* frame = currentFrame(BindingState::instance()))
         return frame->document()->scriptExecutionContext();
 
     return 0;

Modified: trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp (124546 => 124547)


--- trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/v8/custom/V8AudioContextCustom.cpp	2012-08-03 01:51:35 UTC (rev 124547)
@@ -28,14 +28,15 @@
 
 #include "V8AudioContext.h"
 
-#include <wtf/ArrayBuffer.h>
 #include "AudioBuffer.h"
 #include "AudioContext.h"
+#include "BindingState.h"
 #include "Frame.h"
 #include "V8ArrayBuffer.h"
 #include "V8AudioBuffer.h"
 #include "V8Binding.h"
 #include "V8Proxy.h"
+#include <wtf/ArrayBuffer.h>
 
 namespace WebCore {
 
@@ -49,7 +50,7 @@
     if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
         return args.Holder();
 
-    Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
+    Frame* frame = currentFrame(BindingState::instance());
     if (!frame)
         return V8Proxy::throwError(V8Proxy::ReferenceError, "AudioContext constructor associated frame is unavailable", args.GetIsolate());
 

Modified: trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp (124546 => 124547)


--- trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2012-08-03 01:51:35 UTC (rev 124547)
@@ -302,7 +302,7 @@
     // None of these need to be RefPtr because args and context are guaranteed
     // to hold on to them.
     DOMWindow* window = V8DOMWindow::toNative(args.Holder());
-    DOMWindow* source = V8Proxy::retrieveWindowForCallingContext();
+    DOMWindow* source = activeWindow(BindingState::instance());
 
     // If called directly by WebCore we don't have a calling context.
     if (!source)

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp (124546 => 124547)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-08-03 01:51:35 UTC (rev 124547)
@@ -31,6 +31,7 @@
 #include "config.h"
 #include "V8HTMLDocument.h"
 
+#include "BindingState.h"
 #include "Frame.h"
 #include "HTMLAllCollection.h"
 #include "HTMLDocument.h"
@@ -118,7 +119,7 @@
 {
     INC_STATS("DOM.HTMLDocument.write()");
     HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder());
-    Frame* frame = V8Proxy::retrieveFrameForCallingContext();
+    Frame* frame = activeFrame(BindingState::instance());
     htmlDocument->write(writeHelperGetString(args), frame ? frame->document() : NULL);
     return v8::Undefined();
 }
@@ -127,7 +128,7 @@
 {
     INC_STATS("DOM.HTMLDocument.writeln()");
     HTMLDocument* htmlDocument = V8HTMLDocument::toNative(args.Holder());
-    Frame* frame = V8Proxy::retrieveFrameForCallingContext();
+    Frame* frame = activeFrame(BindingState::instance());
     htmlDocument->writeln(writeHelperGetString(args), frame ? frame->document() : NULL);
     return v8::Undefined();
 }
@@ -164,7 +165,7 @@
         }
     }
 
-    Frame* frame = V8Proxy::retrieveFrameForCallingContext();
+    Frame* frame = activeFrame(BindingState::instance());
     htmlDocument->open(frame ? frame->document() : NULL);
     // Return the document.
     return args.Holder();

Modified: trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp (124546 => 124547)


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp	2012-08-03 01:43:05 UTC (rev 124546)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLImageElementConstructor.cpp	2012-08-03 01:51:35 UTC (rev 124547)
@@ -31,15 +31,15 @@
 #include "config.h"
 #include "V8HTMLImageElementConstructor.h"
 
-#include "HTMLImageElement.h"
+#include "BindingState.h"
 #include "Document.h"
 #include "Frame.h"
+#include "HTMLImageElement.h"
 #include "HTMLNames.h"
 #include "V8Binding.h"
 #include "V8Document.h"
 #include "V8HTMLImageElement.h"
 #include "V8Proxy.h"
-
 #include <wtf/RefPtr.h>
 
 namespace WebCore {
@@ -56,7 +56,7 @@
     if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
         return args.Holder();
 
-    Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
+    Frame* frame = currentFrame(BindingState::instance());
     if (!frame)
         return V8Proxy::throwError(V8Proxy::ReferenceError, "Image constructor associated frame is unavailable", args.GetIsolate());
 
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to