Title: [126363] trunk/Source
Revision
126363
Author
[email protected]
Date
2012-08-22 15:52:16 -0700 (Wed, 22 Aug 2012)

Log Message

[V8] Move context() from V8Proxy to ScriptController
https://bugs.webkit.org/show_bug.cgi?id=94593

Reviewed by Adam Barth.

Source/WebCore:

- This patch removes V8Proxy::context(Frame*).
- This patch moves V8Proxy::context() to ScriptController::context().
- This patch renames ScriptController::context() to ScriptController::currentWorldContext(),
for naming consistency with ScriptController::maintWorldContext().

No tests. No change in behavior.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateToV8Converters):
* bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
(WebCore::V8TestActiveDOMObject::wrapSlow):
* bindings/scripts/test/V8/V8TestNode.cpp:
(WebCore::V8TestNode::wrapSlow):
* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::context):
(WebCore):
* bindings/v8/ScriptController.h:
(ScriptController):
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::setNamedHiddenWindowReference):
* bindings/v8/V8Proxy.cpp:
* bindings/v8/V8Proxy.h:
(V8Proxy):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::WindowSetTimeoutImpl):
(WebCore::V8DOMWindow::eventAccessorGetter):
(WebCore::V8DOMWindow::eventAccessorSetter):
(WebCore::DialogHandler::dialogCreated):
(WebCore::toV8):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::V8HTMLDocument::openCallback):

Source/WebKit/chromium:

To kill V8Proxy, we can move context() from V8Proxy to ScriptController.

No tests. No change in behavior.

* src/InspectorFrontendClientImpl.cpp:
(WebKit::InspectorFrontendClientImpl::windowObjectCleared):
* src/WebDevToolsFrontendImpl.cpp:
(WebKit::WebDevToolsFrontendImpl::dispatchOnInspectorFrontend):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (126362 => 126363)


--- trunk/Source/WebCore/ChangeLog	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebCore/ChangeLog	2012-08-22 22:52:16 UTC (rev 126363)
@@ -1,5 +1,44 @@
 2012-08-22  Kentaro Hara  <[email protected]>
 
+        [V8] Move context() from V8Proxy to ScriptController
+        https://bugs.webkit.org/show_bug.cgi?id=94593
+
+        Reviewed by Adam Barth.
+
+        - This patch removes V8Proxy::context(Frame*).
+        - This patch moves V8Proxy::context() to ScriptController::context().
+        - This patch renames ScriptController::context() to ScriptController::currentWorldContext(),
+        for naming consistency with ScriptController::maintWorldContext().
+
+        No tests. No change in behavior.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateToV8Converters):
+        * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
+        (WebCore::V8TestActiveDOMObject::wrapSlow):
+        * bindings/scripts/test/V8/V8TestNode.cpp:
+        (WebCore::V8TestNode::wrapSlow):
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::context):
+        (WebCore):
+        * bindings/v8/ScriptController.h:
+        (ScriptController):
+        * bindings/v8/V8DOMWrapper.cpp:
+        (WebCore::V8DOMWrapper::setNamedHiddenWindowReference):
+        * bindings/v8/V8Proxy.cpp:
+        * bindings/v8/V8Proxy.h:
+        (V8Proxy):
+        * bindings/v8/custom/V8DOMWindowCustom.cpp:
+        (WebCore::WindowSetTimeoutImpl):
+        (WebCore::V8DOMWindow::eventAccessorGetter):
+        (WebCore::V8DOMWindow::eventAccessorSetter):
+        (WebCore::DialogHandler::dialogCreated):
+        (WebCore::toV8):
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        (WebCore::V8HTMLDocument::openCallback):
+
+2012-08-22  Kentaro Hara  <[email protected]>
+
         [V8] Remove V8Proxy from V8DOMWrapper::instantiateV8Object()
         https://bugs.webkit.org/show_bug.cgi?id=94713
 

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (126362 => 126363)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-08-22 22:52:16 UTC (rev 126363)
@@ -3397,7 +3397,7 @@
     if (proxy && !proxy->matchesCurrentContext()) {
         // For performance, we enter the context only if the currently running context
         // is different from the context that we are about to enter.
-        context = proxy->context();
+        context = proxy->frame()->script()->currentWorldContext();
         if (!context.IsEmpty())
             context->Enter();
     }

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp (126362 => 126363)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp	2012-08-22 22:52:16 UTC (rev 126363)
@@ -191,7 +191,7 @@
     if (proxy && !proxy->matchesCurrentContext()) {
         // For performance, we enter the context only if the currently running context
         // is different from the context that we are about to enter.
-        context = proxy->context();
+        context = proxy->frame()->script()->currentWorldContext();
         if (!context.IsEmpty())
             context->Enter();
     }

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp (126362 => 126363)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp	2012-08-22 22:52:16 UTC (rev 126363)
@@ -121,7 +121,7 @@
     if (proxy && !proxy->matchesCurrentContext()) {
         // For performance, we enter the context only if the currently running context
         // is different from the context that we are about to enter.
-        context = proxy->context();
+        context = proxy->frame()->script()->currentWorldContext();
         if (!context.IsEmpty())
             context->Enter();
     }

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (126362 => 126363)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-22 22:52:16 UTC (rev 126363)
@@ -376,6 +376,17 @@
     m_proxy->finishedWithEvent(event);
 }
 
+v8::Local<v8::Context> ScriptController::currentWorldContext()
+{
+    if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) {
+        RefPtr<SharedPersistent<v8::Context> > context = isolatedContext->sharedContext();
+        if (m_frame != toFrameIfNotDetached(context->get()))
+            return v8::Local<v8::Context>();
+        return v8::Local<v8::Context>::New(context->get());
+    }
+    return mainWorldContext();
+}
+
 v8::Local<v8::Context> ScriptController::mainWorldContext()
 {
     windowShell()->initContextIfNeeded();

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.h (126362 => 126363)


--- trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-08-22 22:52:16 UTC (rev 126363)
@@ -154,10 +154,11 @@
     // V8Proxy::retrieveFrameForEnteredContext() for more information.
     static Frame* retrieveFrameForCurrentContext();
 
-    // Returns V8 Context of a frame. If none exists, creates
-    // a new context. It is potentially slow and consumes memory.
+    // Returns V8 Context. If none exists, creates a new context.
+    // It is potentially slow and consumes memory.
     static v8::Local<v8::Context> mainWorldContext(Frame*);
     v8::Local<v8::Context> mainWorldContext();
+    v8::Local<v8::Context> currentWorldContext();
 
     // Pass command-line flags to the JS engine.
     static void setFlags(const char* string, int length);

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp (126362 => 126363)


--- trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp	2012-08-22 22:52:16 UTC (rev 126363)
@@ -129,7 +129,7 @@
     // Get DOMWindow
     if (!frame)
         return; // Object might be detached from window
-    v8::Handle<v8::Context> context = V8Proxy::context(frame);
+    v8::Handle<v8::Context> context = frame->script()->currentWorldContext();
     if (context.IsEmpty())
         return;
 

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (126362 => 126363)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-22 22:52:16 UTC (rev 126363)
@@ -178,32 +178,6 @@
     return frame()->script()->windowShell();
 }
 
-v8::Local<v8::Context> V8Proxy::context(Frame* frame)
-{
-    v8::Local<v8::Context> context = ScriptController::mainWorldContext(frame);
-    if (context.IsEmpty())
-        return v8::Local<v8::Context>();
-
-    if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) {
-        context = v8::Local<v8::Context>::New(isolatedContext->context());
-        if (frame != toFrameIfNotDetached(context))
-            return v8::Local<v8::Context>();
-    }
-
-    return context;
-}
-
-v8::Local<v8::Context> V8Proxy::context()
-{
-    if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) {
-        RefPtr<SharedPersistent<v8::Context> > context = isolatedContext->sharedContext();
-        if (m_frame != toFrameIfNotDetached(context->get()))
-            return v8::Local<v8::Context>();
-        return v8::Local<v8::Context>::New(context->get());
-    }
-    return frame()->script()->mainWorldContext();
-}
-
 v8::Local<v8::Context> V8Proxy::isolatedWorldContext(int worldId)
 {
     IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldId);

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (126362 => 126363)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-22 22:52:16 UTC (rev 126363)
@@ -97,11 +97,6 @@
         // Run an already compiled script.
         v8::Local<v8::Value> runScript(v8::Handle<v8::Script>);
 
-        // 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*);
-
-        v8::Local<v8::Context> context();
         v8::Local<v8::Context> isolatedWorldContext(int worldId);
         bool matchesCurrentContext();
 

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


--- trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2012-08-22 22:52:16 UTC (rev 126363)
@@ -61,7 +61,6 @@
 #include "V8HiddenPropertyName.h"
 #include "V8HTMLCollection.h"
 #include "V8Node.h"
-#include "V8Proxy.h"
 #include "V8Utilities.h"
 #include "WindowFeatures.h"
 #include <wtf/ArrayBuffer.h>
@@ -121,7 +120,8 @@
         }
 
         // params is passed to action, and released in action's destructor
-        OwnPtr<ScheduledAction> action = "" ScheduledAction(V8Proxy::context(imp->frame()), v8::Handle<v8::Function>::Cast(function), paramCount, params));
+        ASSERT(imp->frame());
+        OwnPtr<ScheduledAction> action = "" ScheduledAction(imp->frame()->script()->currentWorldContext(), v8::Handle<v8::Function>::Cast(function), paramCount, params));
 
         // FIXME: We should use OwnArrayPtr for params.
         delete[] params;
@@ -131,7 +131,8 @@
         RefPtr<ScriptCallStack> callStack(createScriptCallStackForInspector());
         if (imp->document() && !imp->document()->contentSecurityPolicy()->allowEval(callStack.release()))
             return v8Integer(0, args.GetIsolate());
-        id = DOMTimer::install(scriptContext, adoptPtr(new ScheduledAction(V8Proxy::context(imp->frame()), functionString)), timeout, singleShot);
+        ASSERT(imp->frame());
+        id = DOMTimer::install(scriptContext, adoptPtr(new ScheduledAction(imp->frame()->script()->currentWorldContext(), functionString)), timeout, singleShot);
     }
 
     // Try to do the idle notification before the timeout expires to get better
@@ -154,7 +155,8 @@
     if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), frame))
         return v8::Undefined();
 
-    v8::Local<v8::Context> context = V8Proxy::context(frame);
+    ASSERT(frame);
+    v8::Local<v8::Context> context = frame->script()->currentWorldContext();
     if (context.IsEmpty())
         return v8::Undefined();
 
@@ -175,7 +177,8 @@
     if (!BindingSecurity::shouldAllowAccessToFrame(BindingState::instance(), frame))
         return;
 
-    v8::Local<v8::Context> context = V8Proxy::context(frame);
+    ASSERT(frame);
+    v8::Local<v8::Context> context = frame->script()->currentWorldContext();
     if (context.IsEmpty())
         return;
 
@@ -402,7 +405,7 @@
 
 inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame)
 {
-    m_dialogContext = V8Proxy::context(dialogFrame->frame());
+    m_dialogContext = dialogFrame->frame() ? dialogFrame->frame()->script()->currentWorldContext() : v8::Local<v8::Context>();
     if (m_dialogContext.IsEmpty())
         return;
     if (m_dialogArguments.IsEmpty())
@@ -621,7 +624,7 @@
     }
 
     // Otherwise, return the global object associated with this frame.
-    v8::Handle<v8::Context> context = V8Proxy::context(frame);
+    v8::Handle<v8::Context> context = frame->script()->currentWorldContext();
     if (context.IsEmpty())
         return v8Undefined();
 

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


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-08-22 22:52:16 UTC (rev 126363)
@@ -44,7 +44,6 @@
 #include "V8HTMLCollection.h"
 #include "V8IsolatedContext.h"
 #include "V8Node.h"
-#include "V8Proxy.h"
 #include "V8RecursionScope.h"
 #include <wtf/text/StringBuilder.h>
 #include <wtf/OwnArrayPtr.h>
@@ -142,7 +141,7 @@
     if (args.Length() > 2) {
         if (RefPtr<Frame> frame = htmlDocument->frame()) {
             // Fetch the global object for the frame.
-            v8::Local<v8::Context> context = V8Proxy::context(frame.get());
+            v8::Local<v8::Context> context = frame->script()->currentWorldContext();
             // Bail out if we cannot get the context.
             if (context.IsEmpty())
                 return v8::Undefined();

Modified: trunk/Source/WebKit/chromium/ChangeLog (126362 => 126363)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-08-22 22:52:16 UTC (rev 126363)
@@ -1,3 +1,19 @@
+2012-08-22  Kentaro Hara  <[email protected]>
+
+        [V8] Move context() from V8Proxy to ScriptController
+        https://bugs.webkit.org/show_bug.cgi?id=94593
+
+        Reviewed by Adam Barth.
+
+        To kill V8Proxy, we can move context() from V8Proxy to ScriptController.
+
+        No tests. No change in behavior.
+
+        * src/InspectorFrontendClientImpl.cpp:
+        (WebKit::InspectorFrontendClientImpl::windowObjectCleared):
+        * src/WebDevToolsFrontendImpl.cpp:
+        (WebKit::WebDevToolsFrontendImpl::dispatchOnInspectorFrontend):
+
 2012-08-22  Nikhil Bhargava  <[email protected]>
 
         Reduce Font.h includes across project -- improves RenderObject.h compile time

Modified: trunk/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp (126362 => 126363)


--- trunk/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp	2012-08-22 22:52:16 UTC (rev 126363)
@@ -36,8 +36,8 @@
 #include "InspectorFrontendHost.h"
 #include "Page.h"
 #include "PlatformString.h"
+#include "ScriptController.h"
 #include "V8InspectorFrontendHost.h"
-#include "V8Proxy.h"
 #include "WebDevToolsFrontendClient.h"
 #include "WebDevToolsFrontendImpl.h"
 #include "platform/WebFloatPoint.h"
@@ -63,7 +63,7 @@
 void InspectorFrontendClientImpl::windowObjectCleared()
 {
     v8::HandleScope handleScope;
-    v8::Handle<v8::Context> frameContext = V8Proxy::context(m_frontendPage->mainFrame());
+    v8::Handle<v8::Context> frameContext = m_frontendPage->mainFrame() ? m_frontendPage->mainFrame()->script()->currentWorldContext() : v8::Local<v8::Context>();
     v8::Context::Scope contextScope(frameContext);
 
     ASSERT(!m_frontendHost);

Modified: trunk/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp (126362 => 126363)


--- trunk/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp	2012-08-22 22:44:33 UTC (rev 126362)
+++ trunk/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp	2012-08-22 22:52:16 UTC (rev 126363)
@@ -44,6 +44,7 @@
 #include "Page.h"
 #include "Pasteboard.h"
 #include "PlatformString.h"
+#include "ScriptController.h"
 #include "SecurityOrigin.h"
 #include "Settings.h"
 #include "V8Binding.h"
@@ -51,7 +52,6 @@
 #include "V8InspectorFrontendHost.h"
 #include "V8MouseEvent.h"
 #include "V8Node.h"
-#include "V8Proxy.h"
 #include "V8Utilities.h"
 #include "WebDevToolsFrontendClient.h"
 #include "WebFrameImpl.h"
@@ -107,7 +107,7 @@
 {
     WebFrameImpl* frame = m_webViewImpl->mainFrameImpl();
     v8::HandleScope scope;
-    v8::Handle<v8::Context> frameContext = V8Proxy::context(frame->frame());
+    v8::Handle<v8::Context> frameContext = frame->frame() ? frame->frame()->script()->currentWorldContext() : v8::Local<v8::Context>();
     v8::Context::Scope contextScope(frameContext);
     v8::Handle<v8::Value> inspectorBackendValue = frameContext->Global()->Get(v8::String::New("InspectorBackend"));
     if (!inspectorBackendValue->IsObject())
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to