Title: [126083] trunk/Source
Revision
126083
Author
hara...@chromium.org
Date
2012-08-20 15:42:35 -0700 (Mon, 20 Aug 2012)

Log Message

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

Reviewed by Adam Barth.

This patch moves mainWorldContext() from V8Proxy to ScriptController.
In addition, this patch removes dependency on V8Proxy from WorldContextHandle.

No tests. No change in behavior.

Source/WebCore:

* bindings/v8/DOMTransaction.cpp:
(WebCore::DOMTransaction::callFunction):
* bindings/v8/NPV8Object.cpp:
(WebCore::toV8Context):
* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::evaluate):
(WebCore::ScriptController::mainWorldContext):
(WebCore):
(WebCore::ScriptController::bindToWindowObject):
(WebCore::createScriptObject):
(WebCore::ScriptController::createScriptObjectForPluginElement):
* bindings/v8/ScriptController.h:
(ScriptController):
* bindings/v8/ScriptState.cpp:
(WebCore::mainWorldScriptState):
* bindings/v8/V8LazyEventListener.cpp:
(WebCore::V8LazyEventListener::prepareListenerObject):
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::context):
(WebCore::toV8Context):
* bindings/v8/V8Proxy.h:
(V8Proxy):
* bindings/v8/WorldContextHandle.cpp:
(WebCore::WorldContextHandle::adjustedContext):
* bindings/v8/WorldContextHandle.h:
(WebCore):
(WorldContextHandle):

Source/WebKit/chromium:

* src/WebFrameImpl.cpp:
(WebKit::WebFrameImpl::mainWorldScriptContext):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (126082 => 126083)


--- trunk/Source/WebCore/ChangeLog	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebCore/ChangeLog	2012-08-20 22:42:35 UTC (rev 126083)
@@ -1,3 +1,43 @@
+2012-08-20  Kentaro Hara  <hara...@chromium.org>
+
+        [V8] Move mainWorldContext() from V8Proxy to ScriptController
+        https://bugs.webkit.org/show_bug.cgi?id=94453
+
+        Reviewed by Adam Barth.
+
+        This patch moves mainWorldContext() from V8Proxy to ScriptController.
+        In addition, this patch removes dependency on V8Proxy from WorldContextHandle.
+
+        No tests. No change in behavior.
+
+        * bindings/v8/DOMTransaction.cpp:
+        (WebCore::DOMTransaction::callFunction):
+        * bindings/v8/NPV8Object.cpp:
+        (WebCore::toV8Context):
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::evaluate):
+        (WebCore::ScriptController::mainWorldContext):
+        (WebCore):
+        (WebCore::ScriptController::bindToWindowObject):
+        (WebCore::createScriptObject):
+        (WebCore::ScriptController::createScriptObjectForPluginElement):
+        * bindings/v8/ScriptController.h:
+        (ScriptController):
+        * bindings/v8/ScriptState.cpp:
+        (WebCore::mainWorldScriptState):
+        * bindings/v8/V8LazyEventListener.cpp:
+        (WebCore::V8LazyEventListener::prepareListenerObject):
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::context):
+        (WebCore::toV8Context):
+        * bindings/v8/V8Proxy.h:
+        (V8Proxy):
+        * bindings/v8/WorldContextHandle.cpp:
+        (WebCore::WorldContextHandle::adjustedContext):
+        * bindings/v8/WorldContextHandle.h:
+        (WebCore):
+        (WorldContextHandle):
+
 2012-08-20  Adam Klein  <ad...@chromium.org>
 
         Remove redundant TOUCH_LISTENER event type

Modified: trunk/Source/WebCore/bindings/v8/DOMTransaction.cpp (126082 => 126083)


--- trunk/Source/WebCore/bindings/v8/DOMTransaction.cpp	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebCore/bindings/v8/DOMTransaction.cpp	2012-08-20 22:42:35 UTC (rev 126083)
@@ -105,7 +105,7 @@
     if (function.IsEmpty())
         return;
 
-    v8::Local<v8::Context> v8Context = m_worldContext.adjustedContext(frame->script()->proxy());
+    v8::Local<v8::Context> v8Context = m_worldContext.adjustedContext(frame->script());
     if (v8Context.IsEmpty())
         return;
 

Modified: trunk/Source/WebCore/bindings/v8/NPV8Object.cpp (126082 => 126083)


--- trunk/Source/WebCore/bindings/v8/NPV8Object.cpp	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebCore/bindings/v8/NPV8Object.cpp	2012-08-20 22:42:35 UTC (rev 126083)
@@ -66,7 +66,7 @@
     DOMWindow* window = object->rootObject;
     if (!window || !window->isCurrentlyDisplayedInFrame())
         return v8::Local<v8::Context>();
-    return V8Proxy::mainWorldContext(object->rootObject->frame());
+    return ScriptController::mainWorldContext(object->rootObject->frame());
 }
 
 static V8Proxy* toV8Proxy(NPObject* npObject)

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (126082 => 126083)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-08-20 22:42:35 UTC (rev 126083)
@@ -256,7 +256,7 @@
     m_sourceURL = &sourceURL;
 
     v8::HandleScope handleScope;
-    v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(m_proxy->frame());
+    v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(m_proxy->frame());
     if (v8Context.IsEmpty())
         return ScriptValue();
 
@@ -287,12 +287,26 @@
     m_proxy->finishedWithEvent(event);
 }
 
+v8::Local<v8::Context> ScriptController::mainWorldContext()
+{
+    windowShell()->initContextIfNeeded();
+    return v8::Local<v8::Context>::New(windowShell()->context());
+}
+
+v8::Local<v8::Context> ScriptController::mainWorldContext(Frame* frame)
+{
+    if (!frame)
+        return v8::Local<v8::Context>();
+
+    return frame->script()->mainWorldContext();
+}
+
 // Create a V8 object with an interceptor of NPObjectPropertyGetter.
 void ScriptController::bindToWindowObject(Frame* frame, const String& key, NPObject* object)
 {
     v8::HandleScope handleScope;
 
-    v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(frame);
+    v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(frame);
     if (v8Context.IsEmpty())
         return;
 
@@ -449,7 +463,7 @@
 static NPObject* createScriptObject(Frame* frame)
 {
     v8::HandleScope handleScope;
-    v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(frame);
+    v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(frame);
     if (v8Context.IsEmpty())
         return createNoScriptObject();
 
@@ -489,7 +503,7 @@
         return createNoScriptObject();
 
     v8::HandleScope handleScope;
-    v8::Handle<v8::Context> v8Context = V8Proxy::mainWorldContext(m_frame);
+    v8::Handle<v8::Context> v8Context = ScriptController::mainWorldContext(m_frame);
     if (v8Context.IsEmpty())
         return createNoScriptObject();
     v8::Context::Scope scope(v8Context);

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.h (126082 => 126083)


--- trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-08-20 22:42:35 UTC (rev 126083)
@@ -158,6 +158,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.
+    static v8::Local<v8::Context> mainWorldContext(Frame*);
+    v8::Local<v8::Context> mainWorldContext();
+
     // Pass command-line flags to the JS engine.
     static void setFlags(const char* string, int length);
 

Modified: trunk/Source/WebCore/bindings/v8/ScriptState.cpp (126082 => 126083)


--- trunk/Source/WebCore/bindings/v8/ScriptState.cpp	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebCore/bindings/v8/ScriptState.cpp	2012-08-20 22:42:35 UTC (rev 126083)
@@ -145,8 +145,7 @@
 ScriptState* mainWorldScriptState(Frame* frame)
 {
     v8::HandleScope handleScope;
-    V8Proxy* proxy = frame->script()->proxy();
-    return ScriptState::forContext(proxy->mainWorldContext());
+    return ScriptState::forContext(frame->script()->mainWorldContext());
 }
 
 ScriptState* scriptStateFromNode(DOMWrapperWorld*, Node* node)

Modified: trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp (126082 => 126083)


--- trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2012-08-20 22:42:35 UTC (rev 126083)
@@ -124,7 +124,7 @@
     if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript))
         return;
     // Use the outer scope to hold context.
-    v8::Local<v8::Context> v8Context = worldContext().adjustedContext(frame->script()->proxy());
+    v8::Local<v8::Context> v8Context = worldContext().adjustedContext(frame->script());
     // Bail out if we cannot get the context.
     if (v8Context.IsEmpty())
         return;

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (126082 => 126083)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-20 22:42:35 UTC (rev 126083)
@@ -374,7 +374,7 @@
 
 v8::Local<v8::Context> V8Proxy::context(Frame* frame)
 {
-    v8::Local<v8::Context> context = V8Proxy::mainWorldContext(frame);
+    v8::Local<v8::Context> context = ScriptController::mainWorldContext(frame);
     if (context.IsEmpty())
         return v8::Local<v8::Context>();
 
@@ -395,15 +395,9 @@
             return v8::Local<v8::Context>();
         return v8::Local<v8::Context>::New(context->get());
     }
-    return mainWorldContext();
+    return frame()->script()->mainWorldContext();
 }
 
-v8::Local<v8::Context> V8Proxy::mainWorldContext()
-{
-    windowShell()->initContextIfNeeded();
-    return v8::Local<v8::Context>::New(windowShell()->context());
-}
-
 v8::Local<v8::Context> V8Proxy::isolatedWorldContext(int worldId)
 {
     IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldId);
@@ -426,19 +420,11 @@
     return context == context->GetCurrent();
 }
 
-v8::Local<v8::Context> V8Proxy::mainWorldContext(Frame* frame)
-{
-    if (!frame)
-        return v8::Local<v8::Context>();
-
-    return frame->script()->proxy()->mainWorldContext();
-}
-
 v8::Local<v8::Context> toV8Context(ScriptExecutionContext* context, const WorldContextHandle& worldContext)
 {
     if (context->isDocument()) {
         if (Frame* frame = static_cast<Document*>(context)->frame())
-            return worldContext.adjustedContext(frame->script()->proxy());
+            return worldContext.adjustedContext(frame->script());
 #if ENABLE(WORKERS)
     } else if (context->isWorkerContext()) {
         if (WorkerContextExecutionProxy* proxy = static_cast<WorkerContext*>(context)->script()->proxy())

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (126082 => 126083)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-20 22:42:35 UTC (rev 126083)
@@ -118,7 +118,6 @@
         // 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*);
-        static v8::Local<v8::Context> mainWorldContext(Frame*);
 
         // If the current context causes out of memory, _javascript_ setting
         // is disabled and it returns true.
@@ -127,7 +126,6 @@
         static v8::Handle<v8::Script> compileScript(v8::Handle<v8::String> code, const String& fileName, const TextPosition& scriptStartPosition, v8::ScriptData* = 0);
 
         v8::Local<v8::Context> context();
-        v8::Local<v8::Context> mainWorldContext();
         v8::Local<v8::Context> isolatedWorldContext(int worldId);
         bool matchesCurrentContext();
 

Modified: trunk/Source/WebCore/bindings/v8/WorldContextHandle.cpp (126082 => 126083)


--- trunk/Source/WebCore/bindings/v8/WorldContextHandle.cpp	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebCore/bindings/v8/WorldContextHandle.cpp	2012-08-20 22:42:35 UTC (rev 126083)
@@ -31,8 +31,8 @@
 #include "config.h"
 #include "WorldContextHandle.h"
 
+#include "ScriptController.h"
 #include "V8IsolatedContext.h"
-#include "V8Proxy.h"
 
 namespace WebCore {
 
@@ -46,10 +46,10 @@
         m_context = context->sharedContext();
 }
 
-v8::Local<v8::Context> WorldContextHandle::adjustedContext(V8Proxy* proxy) const
+v8::Local<v8::Context> WorldContextHandle::adjustedContext(ScriptController* script) const
 {
     if (m_worldToUse == UseMainWorld || !m_context || m_context->get().IsEmpty())
-        return proxy->mainWorldContext();
+        return script->mainWorldContext();
 
     return v8::Local<v8::Context>::New(m_context->get());
 }

Modified: trunk/Source/WebCore/bindings/v8/WorldContextHandle.h (126082 => 126083)


--- trunk/Source/WebCore/bindings/v8/WorldContextHandle.h	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebCore/bindings/v8/WorldContextHandle.h	2012-08-20 22:42:35 UTC (rev 126083)
@@ -38,14 +38,14 @@
 
 namespace WebCore {
 
-class V8Proxy;
+class ScriptController;
 
 enum WorldToUse { UseMainWorld, UseCurrentWorld };
 
 class WorldContextHandle {
 public:
     WorldContextHandle(WorldToUse);
-    v8::Local<v8::Context> adjustedContext(V8Proxy*) const;
+    v8::Local<v8::Context> adjustedContext(ScriptController*) const;
 
 private:
     WorldToUse m_worldToUse;

Modified: trunk/Source/WebKit/chromium/ChangeLog (126082 => 126083)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-08-20 22:42:35 UTC (rev 126083)
@@ -1,3 +1,18 @@
+2012-08-20  Kentaro Hara  <hara...@chromium.org>
+
+        [V8] Move mainWorldContext() from V8Proxy to ScriptController
+        https://bugs.webkit.org/show_bug.cgi?id=94453
+
+        Reviewed by Adam Barth.
+
+        This patch moves mainWorldContext() from V8Proxy to ScriptController.
+        In addition, this patch removes dependency on V8Proxy from WorldContextHandle.
+
+        No tests. No change in behavior.
+
+        * src/WebFrameImpl.cpp:
+        (WebKit::WebFrameImpl::mainWorldScriptContext):
+
 2012-08-20  Adam Klein  <ad...@chromium.org>
 
         Remove redundant TOUCH_LISTENER event type

Modified: trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp (126082 => 126083)


--- trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-08-20 22:41:06 UTC (rev 126082)
+++ trunk/Source/WebKit/chromium/src/WebFrameImpl.cpp	2012-08-20 22:42:35 UTC (rev 126083)
@@ -960,7 +960,7 @@
     if (!m_frame)
         return v8::Local<v8::Context>();
 
-    return V8Proxy::mainWorldContext(m_frame);
+    return ScriptController::mainWorldContext(m_frame);
 }
 
 v8::Handle<v8::Value> WebFrameImpl::createFileSystem(WebFileSystem::Type type,
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to