Title: [124583] trunk/Source
Revision
124583
Author
[email protected]
Date
2012-08-03 01:56:08 -0700 (Fri, 03 Aug 2012)

Log Message

V8Proxy::retrieve(*) leads to really obfuscated code and should be removed
https://bugs.webkit.org/show_bug.cgi?id=93072

Reviewed by Eric Seidel.

Source/WebCore:

Once upon a time, V8Proxy::retrieve did a bunch of checks before
returning the V8Proxy object (such as checking whether script was
enabled). Over time, we've removed all of these checks in order to fix
various bugs. Now all it does is check whether the Frame is 0. However,
because the function ends up returning 0 when its argument is 0, the
caller sill needs to have a null check.

This patch deletes all the variations of V8Proxy::retrieve(*) and
inlines them into their callers. In several cases, inlining the
function call showed that we were testing the Frame for 0 twice, and
I've removed the redundant null checks. In other cases, I've
uncontorted the callers to make the code more readable.

* bindings/scripts/CodeGeneratorV8.pm:
(GenerateToV8Converters):
* bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
(WebCore::V8TestActiveDOMObject::wrapSlow):
* bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
(WebCore::V8TestNamedConstructorConstructorCallback):
* bindings/scripts/test/V8/V8TestNode.cpp:
(WebCore::V8TestNode::wrapSlow):
* bindings/v8/PageScriptDebugServer.cpp:
(WebCore::PageScriptDebugServer::addListener):
* bindings/v8/ScheduledAction.cpp:
(WebCore::ScheduledAction::execute):
* bindings/v8/ScriptController.h:
(WebCore::ScriptController::windowShell):
* bindings/v8/V8DOMWrapper.cpp:
(WebCore::V8DOMWrapper::instantiateV8Object):
* bindings/v8/V8EventListener.cpp:
(WebCore::V8EventListener::callListenerFunction):
* bindings/v8/V8Helpers.cpp:
(WebCore::toV8Proxy):
* bindings/v8/V8LazyEventListener.cpp:
(WebCore::V8LazyEventListener::callListenerFunction):
(WebCore::V8LazyEventListener::prepareListenerObject):
* bindings/v8/V8Proxy.cpp:
(WebCore::V8Proxy::handleOutOfMemory):
(WebCore::V8Proxy::retrievePerContextData):
(WebCore::V8Proxy::mainWorldContext):
(WebCore::toV8Context):
* bindings/v8/V8Proxy.h:
(V8Proxy):
* bindings/v8/custom/V8DOMWindowCustom.cpp:
(WebCore::V8DOMWindow::addEventListenerCallback):
(WebCore::V8DOMWindow::removeEventListenerCallback):
* bindings/v8/custom/V8DocumentCustom.cpp:
(WebCore::toV8):
* bindings/v8/custom/V8HTMLDocumentCustom.cpp:
(WebCore::V8HTMLDocument::openCallback):
(WebCore::toV8):
* bindings/v8/custom/V8SVGDocumentCustom.cpp:
(WebCore::toV8):

Source/WebKit/chromium:

* src/WebDevToolsAgentImpl.cpp:
(WebKit::WebDevToolsAgentImpl::didCreateScriptContext):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (124582 => 124583)


--- trunk/Source/WebCore/ChangeLog	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/ChangeLog	2012-08-03 08:56:08 UTC (rev 124583)
@@ -1,3 +1,64 @@
+2012-08-03  Adam Barth  <[email protected]>
+
+        V8Proxy::retrieve(*) leads to really obfuscated code and should be removed
+        https://bugs.webkit.org/show_bug.cgi?id=93072
+
+        Reviewed by Eric Seidel.
+
+        Once upon a time, V8Proxy::retrieve did a bunch of checks before
+        returning the V8Proxy object (such as checking whether script was
+        enabled). Over time, we've removed all of these checks in order to fix
+        various bugs. Now all it does is check whether the Frame is 0. However,
+        because the function ends up returning 0 when its argument is 0, the
+        caller sill needs to have a null check.
+
+        This patch deletes all the variations of V8Proxy::retrieve(*) and
+        inlines them into their callers. In several cases, inlining the
+        function call showed that we were testing the Frame for 0 twice, and
+        I've removed the redundant null checks. In other cases, I've
+        uncontorted the callers to make the code more readable.
+
+        * bindings/scripts/CodeGeneratorV8.pm:
+        (GenerateToV8Converters):
+        * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
+        (WebCore::V8TestActiveDOMObject::wrapSlow):
+        * bindings/scripts/test/V8/V8TestNamedConstructor.cpp:
+        (WebCore::V8TestNamedConstructorConstructorCallback):
+        * bindings/scripts/test/V8/V8TestNode.cpp:
+        (WebCore::V8TestNode::wrapSlow):
+        * bindings/v8/PageScriptDebugServer.cpp:
+        (WebCore::PageScriptDebugServer::addListener):
+        * bindings/v8/ScheduledAction.cpp:
+        (WebCore::ScheduledAction::execute):
+        * bindings/v8/ScriptController.h:
+        (WebCore::ScriptController::windowShell):
+        * bindings/v8/V8DOMWrapper.cpp:
+        (WebCore::V8DOMWrapper::instantiateV8Object):
+        * bindings/v8/V8EventListener.cpp:
+        (WebCore::V8EventListener::callListenerFunction):
+        * bindings/v8/V8Helpers.cpp:
+        (WebCore::toV8Proxy):
+        * bindings/v8/V8LazyEventListener.cpp:
+        (WebCore::V8LazyEventListener::callListenerFunction):
+        (WebCore::V8LazyEventListener::prepareListenerObject):
+        * bindings/v8/V8Proxy.cpp:
+        (WebCore::V8Proxy::handleOutOfMemory):
+        (WebCore::V8Proxy::retrievePerContextData):
+        (WebCore::V8Proxy::mainWorldContext):
+        (WebCore::toV8Context):
+        * bindings/v8/V8Proxy.h:
+        (V8Proxy):
+        * bindings/v8/custom/V8DOMWindowCustom.cpp:
+        (WebCore::V8DOMWindow::addEventListenerCallback):
+        (WebCore::V8DOMWindow::removeEventListenerCallback):
+        * bindings/v8/custom/V8DocumentCustom.cpp:
+        (WebCore::toV8):
+        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
+        (WebCore::V8HTMLDocument::openCallback):
+        (WebCore::toV8):
+        * bindings/v8/custom/V8SVGDocumentCustom.cpp:
+        (WebCore::toV8):
+
 2012-08-03  Gyuyoung Kim  <[email protected]>
 
         Add *explicit* keyword to constructors in WebCore/accessibility

Modified: trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm (124582 => 124583)


--- trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm	2012-08-03 08:56:08 UTC (rev 124583)
@@ -3294,10 +3294,10 @@
 
     my $proxyInit;
     if (IsNodeSubType($dataNode)) {
-        $proxyInit = "V8Proxy::retrieve(impl->document()->frame())";
+        $proxyInit = "impl->document()->frame() ? impl->document()->frame()->script()->proxy() : 0";
         # DocumentType nodes are the only nodes that may have a NULL document.
         if ($interfaceName eq "DocumentType") {
-            $proxyInit = "impl->document() ? $proxyInit : 0";
+            $proxyInit = "impl->document() ? ($proxyInit) : 0";
         }
     } else {
         $proxyInit = "0";
@@ -3321,9 +3321,8 @@
     if (IsVisibleAcrossOrigins($dataNode)) {
         push(@implContent, <<END);
     if (impl->frame()) {
-        proxy = V8Proxy::retrieve(impl->frame());
-        if (proxy)
-            proxy->windowShell()->initContextIfNeeded();
+        proxy = impl->frame()->script()->proxy();
+        proxy->windowShell()->initContextIfNeeded();
     }
 END
     }

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


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -164,9 +164,9 @@
     v8::Handle<v8::Object> wrapper;
     V8Proxy* proxy = 0;
     if (impl->frame()) {
-        proxy = V8Proxy::retrieve(impl->frame());
-        if (proxy)
-            proxy->windowShell()->initContextIfNeeded();
+        proxy = impl->frame()->script()->proxy();
+        frame->script()->windowShell()->initContextIfNeeded();
+        proxy->windowShell()->initContextIfNeeded();
     }
 
     // Enter the node's context and create the wrapper in that context.

Modified: trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp (124582 => 124583)


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNamedConstructor.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -54,7 +54,7 @@
     if (ConstructorMode::current() == ConstructorMode::WrapExistingObject)
         return args.Holder();
 
-    Frame* frame = V8Proxy::retrieveFrameForCurrentContext();
+    Frame* frame = currentFrame(BindingState::instance());
     if (!frame)
         return V8Proxy::throwError(V8Proxy::ReferenceError, "TestNamedConstructor constructor associated frame is unavailable", args.GetIsolate());
 

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


--- trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -112,7 +112,7 @@
 v8::Handle<v8::Object> V8TestNode::wrapSlow(PassRefPtr<TestNode> impl, v8::Isolate* isolate)
 {
     v8::Handle<v8::Object> wrapper;
-    V8Proxy* proxy = V8Proxy::retrieve(impl->document()->frame());
+    V8Proxy* proxy = impl->document()->frame() ? impl->document()->frame()->script()->proxy() : 0;
 
     // Enter the node's context and create the wrapper in that context.
     v8::Handle<v8::Context> context;

Modified: trunk/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp (124582 => 124583)


--- trunk/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -78,9 +78,6 @@
 
 void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* page)
 {
-    V8Proxy* proxy = V8Proxy::retrieve(page->mainFrame());
-    if (!proxy)
-        return;
     ScriptController* scriptController = page->mainFrame()->script();
     if (!scriptController->canExecuteScripts(NotAboutToExecuteScript))
         return;
@@ -96,7 +93,7 @@
     }
     m_listenersMap.set(page, listener);
 
-    V8DOMWindowShell* shell = proxy->windowShell();
+    V8DOMWindowShell* shell = scriptController->windowShell();
     if (!shell->isContextInitialized())
         return;
     v8::Handle<v8::Context> context = shell->context();

Modified: trunk/Source/WebCore/bindings/v8/ScheduledAction.cpp (124582 => 124583)


--- trunk/Source/WebCore/bindings/v8/ScheduledAction.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/ScheduledAction.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -99,11 +99,9 @@
         Frame* frame = static_cast<Document*>(context)->frame();
         if (!frame)
             return;
-        ScriptController* scriptController = frame->script();
-        if (!scriptController->canExecuteScripts(AboutToExecuteScript))
+        if (!frame->script()->canExecuteScripts(AboutToExecuteScript))
             return;
-        V8Proxy* proxy = V8Proxy::retrieve(frame);
-        execute(proxy);
+        execute(frame->script()->proxy());
     }
 #if ENABLE(WORKERS)
     else {

Modified: trunk/Source/WebCore/bindings/v8/ScriptController.h (124582 => 124583)


--- trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/ScriptController.h	2012-08-03 08:56:08 UTC (rev 124583)
@@ -65,6 +65,7 @@
     // FIXME: V8Proxy should either be folded into ScriptController
     // or this accessor should be made JSProxy*
     V8Proxy* proxy() { return m_proxy.get(); }
+    V8DOMWindowShell* windowShell() { return m_proxy->windowShell(); }
 
     ScriptValue executeScript(const ScriptSourceCode&);
     ScriptValue executeScript(const String& script, bool forceUserGesture = false);

Modified: trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp (124582 => 124583)


--- trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -177,7 +177,7 @@
             if (isWrapperOfType(globalPrototype, &V8DOMWindow::info)) {
                 Frame* frame = V8DOMWindow::toNative(globalPrototype)->frame();
                 if (frame && frame->script()->canExecuteScripts(NotAboutToExecuteScript))
-                    proxy = V8Proxy::retrieve(frame);
+                    proxy = frame->script()->proxy();
             }
 #if ENABLE(WORKERS)
             else if (isWrapperOfType(globalPrototype, &V8WorkerContext::info))

Modified: trunk/Source/WebCore/bindings/v8/V8EventListener.cpp (124582 => 124583)


--- trunk/Source/WebCore/bindings/v8/V8EventListener.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/V8EventListener.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -79,13 +79,21 @@
 
     v8::Handle<v8::Value> parameters[1] = { jsEvent };
 
-    if (V8Proxy* proxy = V8Proxy::retrieve(context)) {
-        Frame* frame = static_cast<Document*>(context)->frame();
-        if (frame->script()->canExecuteScripts(AboutToExecuteScript))
-            return proxy->callFunction(handlerFunction, receiver, 1, parameters);
-    }
+    // FIXME: Can |context| be 0 here?
+    if (!context)
+        return v8::Local<v8::Value>();
 
-    return v8::Local<v8::Value>();
+    if (!context->isDocument())
+        return v8::Local<v8::Value>();
+
+    Frame* frame = static_cast<Document*>(context)->frame();
+    if (!frame)
+        return v8::Local<v8::Value>();
+
+    if (!frame->script()->canExecuteScripts(AboutToExecuteScript))
+        return v8::Local<v8::Value>();
+
+    return frame->script()->proxy()->callFunction(handlerFunction, receiver, 1, parameters);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/V8Helpers.cpp (124582 => 124583)


--- trunk/Source/WebCore/bindings/v8/V8Helpers.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/V8Helpers.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -51,7 +51,9 @@
 {
     V8NPObject* object = reinterpret_cast<V8NPObject*>(npObject);
     Frame* frame = object->rootObject->frame();
-    return V8Proxy::retrieve(frame);
+    if (!frame)
+        return 0;
+    return frame->script()->proxy();
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp (124582 => 124583)


--- trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -86,13 +86,21 @@
 
     v8::Handle<v8::Value> parameters[1] = { jsEvent };
 
-    if (V8Proxy* proxy = V8Proxy::retrieve(context)) {
-        Frame* frame = static_cast<Document*>(context)->frame();
-        if (frame->script()->canExecuteScripts(AboutToExecuteScript))
-            return proxy->callFunction(handlerFunction, receiver, 1, parameters);
-    }
+    // FIXME: Can |context| be 0 here?
+    if (!context)
+        return v8::Local<v8::Value>();
 
-    return v8::Local<v8::Value>();
+    if (!context->isDocument())
+        return v8::Local<v8::Value>();
+
+    Frame* frame = static_cast<Document*>(context)->frame();
+    if (!frame)
+        return v8::Local<v8::Value>();
+
+    if (!frame->script()->canExecuteScripts(AboutToExecuteScript))
+        return v8::Local<v8::Value>();
+
+    return frame->script()->proxy()->callFunction(handlerFunction, receiver, 1, parameters);
 }
 
 static v8::Handle<v8::Value> V8LazyEventListenerToString(const v8::Arguments& args)
@@ -110,15 +118,13 @@
 
     v8::HandleScope handleScope;
 
-    V8Proxy* proxy = V8Proxy::retrieve(context);
-    if (!proxy)
-        return;
     ASSERT(context->isDocument());
-    if (!static_cast<Document*>(context)->frame()->script()->canExecuteScripts(NotAboutToExecuteScript))
+    Frame* frame = static_cast<Document*>(context)->frame();
+    ASSERT(frame);
+    if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript))
         return;
-
     // Use the outer scope to hold context.
-    v8::Local<v8::Context> v8Context = worldContext().adjustedContext(proxy);
+    v8::Local<v8::Context> v8Context = worldContext().adjustedContext(frame->script()->proxy());
     // Bail out if we cannot get the context.
     if (v8Context.IsEmpty())
         return;

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.cpp (124582 => 124583)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -197,23 +197,18 @@
 
     // Warning, error, disable JS for this frame?
     Frame* frame = V8Proxy::retrieveFrame(context);
+    if (!frame)
+        return true;
 
-    V8Proxy* proxy = V8Proxy::retrieve(frame);
-    if (proxy) {
-        // Clean m_context, and event handlers.
-        proxy->clearForClose();
+    frame->script()->proxy()->clearForClose();
+    frame->script()->windowShell()->destroyGlobal();
 
-        proxy->windowShell()->destroyGlobal();
-    }
-
 #if PLATFORM(CHROMIUM)
     PlatformSupport::notifyJSOutOfMemory(frame);
 #endif
 
-    // Disable JS.
-    Settings* settings = frame->settings();
-    ASSERT(settings);
-    settings->setScriptEnabled(false);
+    if (Settings* settings = frame->settings())
+        settings->setScriptEnabled(false);
 
     return true;
 }
@@ -490,31 +485,12 @@
     return 0;
 }
 
-V8Proxy* V8Proxy::retrieve()
-{
-    DOMWindow* window = retrieveWindow(v8::Context::GetCurrent());
-    ASSERT(window);
-    return retrieve(window->frame());
-}
-
-V8Proxy* V8Proxy::retrieve(Frame* frame)
-{
-    return frame ? frame->script()->proxy() : 0;
-}
-
-V8Proxy* V8Proxy::retrieve(ScriptExecutionContext* context)
-{
-    if (!context || !context->isDocument())
-        return 0;
-    return retrieve(static_cast<Document*>(context)->frame());
-}
-
 V8BindingPerContextData* V8Proxy::retrievePerContextData(Frame* frame)
 {
     V8IsolatedContext* isolatedContext;
     if (UNLIKELY(!!(isolatedContext = V8IsolatedContext::getEntered())))
         return isolatedContext->perContextData();
-    return V8Proxy::retrieve(frame)->windowShell()->perContextData();
+    return frame->script()->windowShell()->perContextData();
 }
 
 void V8Proxy::resetIsolatedWorlds()
@@ -685,11 +661,10 @@
 
 v8::Local<v8::Context> V8Proxy::mainWorldContext(Frame* frame)
 {
-    V8Proxy* proxy = retrieve(frame);
-    if (!proxy)
+    if (!frame)
         return v8::Local<v8::Context>();
 
-    return proxy->mainWorldContext();
+    return frame->script()->proxy()->mainWorldContext();
 }
 
 v8::Handle<v8::Value> V8Proxy::checkNewLegal(const v8::Arguments& args)
@@ -778,8 +753,8 @@
 v8::Local<v8::Context> toV8Context(ScriptExecutionContext* context, const WorldContextHandle& worldContext)
 {
     if (context->isDocument()) {
-        if (V8Proxy* proxy = V8Proxy::retrieve(context))
-            return worldContext.adjustedContext(proxy);
+        if (Frame* frame = static_cast<Document*>(context)->frame())
+            return worldContext.adjustedContext(frame->script()->proxy());
 #if ENABLE(WORKERS)
     } else if (context->isWorkerContext()) {
         if (WorkerContextExecutionProxy* proxy = static_cast<WorkerContext*>(context)->script()->proxy())

Modified: trunk/Source/WebCore/bindings/v8/V8Proxy.h (124582 => 124583)


--- trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/V8Proxy.h	2012-08-03 08:56:08 UTC (rev 124583)
@@ -172,13 +172,6 @@
         // Returns the window object associated with a context.
         static DOMWindow* retrieveWindow(v8::Handle<v8::Context>);
 
-        // Returns V8Proxy object of the currently executing context.
-        static V8Proxy* retrieve();
-        // Returns V8Proxy object associated with a frame.
-        static V8Proxy* retrieve(Frame*);
-        // Returns V8Proxy object associated with a script execution context.
-        static V8Proxy* retrieve(ScriptExecutionContext*);
-
         // Returns the frame object of the window object associated with
         // a context.
         static Frame* retrieveFrame(v8::Handle<v8::Context>);

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


--- trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -243,8 +243,7 @@
         return v8::Undefined();
 
     // FIXME: Check if there is not enough arguments
-    V8Proxy* proxy = V8Proxy::retrieve(imp->frame());
-    if (!proxy)
+    if (!imp->frame())
         return v8::Undefined();
 
     RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOrCreate);
@@ -275,8 +274,7 @@
     if (!doc)
         return v8::Undefined();
 
-    V8Proxy* proxy = V8Proxy::retrieve(imp->frame());
-    if (!proxy)
+    if (!imp->frame())
         return v8::Undefined();
 
     RefPtr<EventListener> listener = V8DOMWrapper::getEventListener(args[1], false, ListenerFindOnly);

Modified: trunk/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp (124582 => 124583)


--- trunk/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/custom/V8DocumentCustom.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -131,8 +131,8 @@
     if (wrapper.IsEmpty())
         return wrapper;
     if (!V8IsolatedContext::getEntered()) {
-        if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame()))
-            proxy->windowShell()->updateDocumentWrapper(wrapper);
+        if (Frame* frame = impl->frame())
+            frame->script()->windowShell()->updateDocumentWrapper(wrapper);
     }
     return wrapper;
 }

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


--- trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -156,12 +156,7 @@
             for (int i = 0; i < args.Length(); i++)
                 params[i] = args[i];
 
-            V8Proxy* proxy = V8Proxy::retrieve(frame.get());
-            if (!proxy)
-                return v8::Undefined();
-
-            v8::Local<v8::Value> result = proxy->callFunction(v8::Local<v8::Function>::Cast(function), global, args.Length(), params.get());
-            return result;
+            return frame->script()->proxy()->callFunction(v8::Local<v8::Function>::Cast(function), global, args.Length(), params.get());
         }
     }
 
@@ -193,8 +188,8 @@
     if (wrapper.IsEmpty())
         return wrapper;
     if (!V8IsolatedContext::getEntered()) {
-        if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame()))
-            proxy->windowShell()->updateDocumentWrapper(wrapper);
+        if (Frame* frame = impl->frame())
+            frame->script()->windowShell()->updateDocumentWrapper(wrapper);
     }
     return wrapper;
 }

Modified: trunk/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp (124582 => 124583)


--- trunk/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebCore/bindings/v8/custom/V8SVGDocumentCustom.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -46,8 +46,8 @@
     if (wrapper.IsEmpty())
         return wrapper;
     if (!V8IsolatedContext::getEntered()) {
-        if (V8Proxy* proxy = V8Proxy::retrieve(impl->frame()))
-            proxy->windowShell()->updateDocumentWrapper(wrapper);
+        if (Frame* frame = impl->frame())
+            frame->script()->windowShell()->updateDocumentWrapper(wrapper);
     }
     return wrapper;
 }

Modified: trunk/Source/WebKit/chromium/ChangeLog (124582 => 124583)


--- trunk/Source/WebKit/chromium/ChangeLog	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebKit/chromium/ChangeLog	2012-08-03 08:56:08 UTC (rev 124583)
@@ -1,3 +1,13 @@
+2012-08-03  Adam Barth  <[email protected]>
+
+        V8Proxy::retrieve(*) leads to really obfuscated code and should be removed
+        https://bugs.webkit.org/show_bug.cgi?id=93072
+
+        Reviewed by Eric Seidel.
+
+        * src/WebDevToolsAgentImpl.cpp:
+        (WebKit::WebDevToolsAgentImpl::didCreateScriptContext):
+
 2012-08-02  Ilya Tikhonovsky  <[email protected]>
 
         Web Inspector: extend test coverage for nmi code and fix 2 bugs.

Modified: trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp (124582 => 124583)


--- trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp	2012-08-03 08:41:07 UTC (rev 124582)
+++ trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp	2012-08-03 08:56:08 UTC (rev 124583)
@@ -423,8 +423,8 @@
     // Skip non main world contexts.
     if (worldId)
         return;
-    if (WebCore::V8Proxy* proxy = WebCore::V8Proxy::retrieve(webframe->frame()))
-        proxy->setContextDebugId(m_hostId);
+    if (WebCore::Frame* frame = webframe->frame())
+        frame->script()->proxy()->setContextDebugId(m_hostId);
 }
 
 void WebDevToolsAgentImpl::mainFrameViewCreated(WebFrameImpl* webFrame)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to