[V8] add contextForWorld helper function to ScriptController
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2012 11:52:49 +0000 (11:52 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 27 Nov 2012 11:52:49 +0000 (11:52 +0000)
https://bugs.webkit.org/show_bug.cgi?id=103376

Patch by Dan Carney <dcarney@google.com> on 2012-11-27
Reviewed by Kentaro Hara.

Reducing some commonly occuring code with an inline function.

No new tests. No change in functionality.

* bindings/v8/ScriptController.cpp:
(WebCore::ScriptController::contextForWorld):
(WebCore):
(WebCore::ScriptController::currentWorldContext):
(WebCore::ScriptController::mainWorldContext):
* bindings/v8/ScriptController.h:
(ScriptController):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@135846 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebCore/ChangeLog
Source/WebCore/bindings/v8/ScriptController.cpp

index cbe986b..3de79f8 100644 (file)
@@ -1,3 +1,22 @@
+2012-11-27  Dan Carney  <dcarney@google.com>
+
+        [V8] add contextForWorld helper function to ScriptController
+        https://bugs.webkit.org/show_bug.cgi?id=103376
+
+        Reviewed by Kentaro Hara.
+
+        Reducing some commonly occuring code with an inline function.
+
+        No new tests. No change in functionality.
+
+        * bindings/v8/ScriptController.cpp:
+        (WebCore::ScriptController::contextForWorld):
+        (WebCore):
+        (WebCore::ScriptController::currentWorldContext):
+        (WebCore::ScriptController::mainWorldContext):
+        * bindings/v8/ScriptController.h:
+        (ScriptController):
+
 2012-11-26  Allan Sandfeld Jensen  <allan.jensen@digia.com>
 
         [Qt] Implement the mimetype icon methods
index fecde21..fcb0aca 100644 (file)
@@ -434,15 +434,20 @@ void ScriptController::finishedWithEvent(Event* event)
 {
 }
 
+static inline v8::Local<v8::Context> contextForWorld(ScriptController* scriptController, DOMWrapperWorld* world)
+{
+    return v8::Local<v8::Context>::New(scriptController->windowShell(world)->context());
+}
+
 v8::Local<v8::Context> ScriptController::currentWorldContext()
 {
     if (!v8::Context::InContext())
-        return v8::Local<v8::Context>::New(windowShell(mainThreadNormalWorld())->context());
+        return contextForWorld(this, mainThreadNormalWorld());
 
     v8::Handle<v8::Context> context = v8::Context::GetEntered();
     DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::isolated(context);
     if (!isolatedWorld)
-        return v8::Local<v8::Context>::New(windowShell(mainThreadNormalWorld())->context());
+        return contextForWorld(this, mainThreadNormalWorld());
 
     Frame* frame = toFrameIfNotDetached(context);
     if (!m_frame)
@@ -455,12 +460,12 @@ v8::Local<v8::Context> ScriptController::currentWorldContext()
     if (isolatedWorld->createdFromUnitializedWorld())
         return v8::Local<v8::Context>();
 
-    return v8::Local<v8::Context>::New(windowShell(isolatedWorld)->context());
+    return contextForWorld(this, isolatedWorld);
 }
 
 v8::Local<v8::Context> ScriptController::mainWorldContext()
 {
-    return v8::Local<v8::Context>::New(windowShell(mainThreadNormalWorld())->context());
+    return contextForWorld(this, mainThreadNormalWorld());
 }
 
 v8::Local<v8::Context> ScriptController::mainWorldContext(Frame* frame)
@@ -468,7 +473,7 @@ v8::Local<v8::Context> ScriptController::mainWorldContext(Frame* frame)
     if (!frame)
         return v8::Local<v8::Context>();
 
-    return frame->script()->mainWorldContext();
+    return contextForWorld(frame->script(), mainThreadNormalWorld());
 }
 
 // Create a V8 object with an interceptor of NPObjectPropertyGetter.