Title: [135846] trunk/Source/WebCore
Revision
135846
Author
[email protected]
Date
2012-11-27 03:52:49 -0800 (Tue, 27 Nov 2012)

Log Message

[V8] add contextForWorld helper function to ScriptController
https://bugs.webkit.org/show_bug.cgi?id=103376

Patch by Dan Carney <[email protected]> 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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (135845 => 135846)


--- trunk/Source/WebCore/ChangeLog	2012-11-27 11:41:46 UTC (rev 135845)
+++ trunk/Source/WebCore/ChangeLog	2012-11-27 11:52:49 UTC (rev 135846)
@@ -1,3 +1,22 @@
+2012-11-27  Dan Carney  <[email protected]>
+
+        [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  <[email protected]>
 
         [Qt] Implement the mimetype icon methods

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (135845 => 135846)


--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-11-27 11:41:46 UTC (rev 135845)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp	2012-11-27 11:52:49 UTC (rev 135846)
@@ -434,15 +434,20 @@
 {
 }
 
+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 @@
     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 @@
     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.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to