Diff
Modified: trunk/Source/WebCore/ChangeLog (126369 => 126370)
--- trunk/Source/WebCore/ChangeLog 2012-08-23 00:36:06 UTC (rev 126369)
+++ trunk/Source/WebCore/ChangeLog 2012-08-23 00:38:08 UTC (rev 126370)
@@ -1,3 +1,34 @@
+2012-08-21 Kentaro Hara <[email protected]>
+
+ [V8] Move matchesCurrentContext() from V8Proxy to ScriptController
+ https://bugs.webkit.org/show_bug.cgi?id=94596
+
+ Reviewed by Adam Barth.
+
+ To kill V8Proxy:
+
+ - We can move matchesCurrentContext() from V8Proxy to ScriptController.
+ - We can remove V8Proxy::isolatedWorldContext() since it is not used by anybody.
+ - We can remove V8Proxy::finishedWithEvent() since it is empty.
+
+ 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::finishedWithEvent):
+ (WebCore::ScriptController::matchesCurrentContext):
+ (WebCore):
+ * bindings/v8/ScriptController.h:
+ (ScriptController):
+ * bindings/v8/V8Proxy.cpp:
+ * bindings/v8/V8Proxy.h:
+ (V8Proxy):
+
2012-08-22 Alejandro PiƱeiro <[email protected]>
[Gtk] Dojo toggle buttons should expose ROLE_TOGGLE_BUTTON not ROLE_PUSH_BUTTON
Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (126369 => 126370)
--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-08-23 00:36:06 UTC (rev 126369)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm 2012-08-23 00:38:08 UTC (rev 126370)
@@ -3394,7 +3394,7 @@
// Enter the node's context and create the wrapper in that context.
v8::Handle<v8::Context> context;
- if (proxy && !proxy->matchesCurrentContext()) {
+ if (proxy && !proxy->frame()->script()->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->frame()->script()->currentWorldContext();
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp (126369 => 126370)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp 2012-08-23 00:36:06 UTC (rev 126369)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp 2012-08-23 00:38:08 UTC (rev 126370)
@@ -188,7 +188,7 @@
// Enter the node's context and create the wrapper in that context.
v8::Handle<v8::Context> context;
- if (proxy && !proxy->matchesCurrentContext()) {
+ if (proxy && !proxy->frame()->script()->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->frame()->script()->currentWorldContext();
Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp (126369 => 126370)
--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp 2012-08-23 00:36:06 UTC (rev 126369)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp 2012-08-23 00:38:08 UTC (rev 126370)
@@ -118,7 +118,7 @@
// Enter the node's context and create the wrapper in that context.
v8::Handle<v8::Context> context;
- if (proxy && !proxy->matchesCurrentContext()) {
+ if (proxy && !proxy->frame()->script()->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->frame()->script()->currentWorldContext();
Modified: trunk/Source/WebCore/bindings/v8/ScriptController.cpp (126369 => 126370)
--- trunk/Source/WebCore/bindings/v8/ScriptController.cpp 2012-08-23 00:36:06 UTC (rev 126369)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.cpp 2012-08-23 00:38:08 UTC (rev 126370)
@@ -373,7 +373,6 @@
void ScriptController::finishedWithEvent(Event* event)
{
- m_proxy->finishedWithEvent(event);
}
v8::Local<v8::Context> ScriptController::currentWorldContext()
@@ -401,6 +400,24 @@
return frame->script()->mainWorldContext();
}
+bool ScriptController::matchesCurrentContext()
+{
+ // This method is equivalent to 'return v8::Context::GetCurrent() == contextForCurrentWorld()',
+ // but is written without using contextForCurrentWorld().
+ // Given that this method is used by a hot call path of DOM object constructor,
+ // we want to avoid the overhead of contextForCurrentWorld() creating Local<Context> every time.
+ v8::Handle<v8::Context> context;
+ if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) {
+ context = isolatedContext->sharedContext()->get();
+ if (m_frame != toFrameIfNotDetached(context))
+ return false;
+ } else {
+ windowShell()->initContextIfNeeded();
+ context = windowShell()->context();
+ }
+ return context == v8::Context::GetCurrent();
+}
+
// Create a V8 object with an interceptor of NPObjectPropertyGetter.
void ScriptController::bindToWindowObject(Frame* frame, const String& key, NPObject* object)
{
Modified: trunk/Source/WebCore/bindings/v8/ScriptController.h (126369 => 126370)
--- trunk/Source/WebCore/bindings/v8/ScriptController.h 2012-08-23 00:36:06 UTC (rev 126369)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.h 2012-08-23 00:38:08 UTC (rev 126370)
@@ -160,6 +160,8 @@
v8::Local<v8::Context> mainWorldContext();
v8::Local<v8::Context> currentWorldContext();
+ bool matchesCurrentContext();
+
// Pass command-line flags to the JS engine.
static void setFlags(const char* string, int length);
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (126369 => 126370)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2012-08-23 00:36:06 UTC (rev 126369)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp 2012-08-23 00:38:08 UTC (rev 126370)
@@ -178,26 +178,4 @@
return frame()->script()->windowShell();
}
-v8::Local<v8::Context> V8Proxy::isolatedWorldContext(int worldId)
-{
- IsolatedWorldMap::iterator iter = m_isolatedWorlds.find(worldId);
- if (iter == m_isolatedWorlds.end())
- return v8::Local<v8::Context>();
- return v8::Local<v8::Context>::New(iter->second->context());
-}
-
-bool V8Proxy::matchesCurrentContext()
-{
- v8::Handle<v8::Context> context;
- if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) {
- context = isolatedContext->sharedContext()->get();
- if (m_frame != toFrameIfNotDetached(context))
- return false;
- } else {
- windowShell()->initContextIfNeeded();
- context = windowShell()->context();
- }
- return context == context->GetCurrent();
-}
-
} // namespace WebCore
Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (126369 => 126370)
--- trunk/Source/WebCore/bindings/v8/V8Proxy.h 2012-08-23 00:36:06 UTC (rev 126369)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h 2012-08-23 00:38:08 UTC (rev 126370)
@@ -87,8 +87,6 @@
Frame* frame() const { return m_frame; }
- void finishedWithEvent(Event*) { }
-
// Evaluate a script file in the current execution environment.
// The caller must hold an execution context.
// If cannot evalute the script, it returns an error.
@@ -97,9 +95,6 @@
// Run an already compiled script.
v8::Local<v8::Value> runScript(v8::Handle<v8::Script>);
- v8::Local<v8::Context> isolatedWorldContext(int worldId);
- bool matchesCurrentContext();
-
// FIXME: This should eventually take DOMWrapperWorld argument!
// FIXME: This method will be soon removed, as all methods that access windowShell()
// will be moved to ScriptController.