Changeset 104694 in webkit


Ignore:
Timestamp:
Jan 11, 2012 2:58:00 AM (12 years ago)
Author:
jochen@chromium.org
Message:

Move the check for canExecuteScripts out of V8Proxy::retrieve
https://bugs.webkit.org/show_bug.cgi?id=75533

Reviewed by Adam Barth.

Source/WebCore:

This change doesn't move the check to custom/generated bindings for
individual objects, as these won't get executed if scripts are disabled
anyway.

No new tests. No functional change.

  • bindings/v8/PageScriptDebugServer.cpp:

(WebCore::PageScriptDebugServer::addListener):

  • bindings/v8/ScheduledAction.cpp:

(WebCore::ScheduledAction::execute):

  • bindings/v8/ScriptCachedFrameData.cpp:

(WebCore::ScriptCachedFrameData::restore):

  • bindings/v8/V8DOMWrapper.cpp:

(WebCore::V8DOMWrapper::instantiateV8Object):

  • bindings/v8/V8EventListener.cpp:

(WebCore::V8EventListener::callListenerFunction):

  • bindings/v8/V8LazyEventListener.cpp:

(WebCore::V8LazyEventListener::callListenerFunction):
(WebCore::V8LazyEventListener::prepareListenerObject):

  • bindings/v8/V8Proxy.cpp:

(WebCore::V8Proxy::handleOutOfMemory):
(WebCore::V8Proxy::retrieve):
(WebCore::toV8Context):

Source/WebKit/chromium:

  • src/WebDevToolsAgentImpl.cpp:

(WebKit::WebDevToolsAgentImpl::didClearWindowObject):

Location:
trunk/Source
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r104690 r104694  
     12012-01-11  Jochen Eisinger  <jochen@chromium.org>
     2
     3        Move the check for canExecuteScripts out of V8Proxy::retrieve
     4        https://bugs.webkit.org/show_bug.cgi?id=75533
     5
     6        Reviewed by Adam Barth.
     7
     8        This change doesn't move the check to custom/generated bindings for
     9        individual objects, as these won't get executed if scripts are disabled
     10        anyway.
     11
     12        No new tests. No functional change.
     13
     14        * bindings/v8/PageScriptDebugServer.cpp:
     15        (WebCore::PageScriptDebugServer::addListener):
     16        * bindings/v8/ScheduledAction.cpp:
     17        (WebCore::ScheduledAction::execute):
     18        * bindings/v8/ScriptCachedFrameData.cpp:
     19        (WebCore::ScriptCachedFrameData::restore):
     20        * bindings/v8/V8DOMWrapper.cpp:
     21        (WebCore::V8DOMWrapper::instantiateV8Object):
     22        * bindings/v8/V8EventListener.cpp:
     23        (WebCore::V8EventListener::callListenerFunction):
     24        * bindings/v8/V8LazyEventListener.cpp:
     25        (WebCore::V8LazyEventListener::callListenerFunction):
     26        (WebCore::V8LazyEventListener::prepareListenerObject):
     27        * bindings/v8/V8Proxy.cpp:
     28        (WebCore::V8Proxy::handleOutOfMemory):
     29        (WebCore::V8Proxy::retrieve):
     30        (WebCore::toV8Context):
     31
    1322012-01-11  Kentaro Hara  <haraken@chromium.org>
    233
  • trunk/Source/WebCore/bindings/v8/PageScriptDebugServer.cpp

    r101156 r104694  
    7777void PageScriptDebugServer::addListener(ScriptDebugListener* listener, Page* page)
    7878{
     79    ScriptController* scriptController = page->mainFrame()->script();
     80    if (!scriptController->canExecuteScripts(NotAboutToExecuteScript))
     81        return;
    7982    V8Proxy* proxy = V8Proxy::retrieve(page->mainFrame());
    80     if (!proxy)
    81         return;
    8283
    8384    v8::HandleScope scope;
  • trunk/Source/WebCore/bindings/v8/ScheduledAction.cpp

    r95901 r104694  
    9595void ScheduledAction::execute(ScriptExecutionContext* context)
    9696{
    97     V8Proxy* proxy = V8Proxy::retrieve(context);
    98     if (proxy)
     97    if (context->isDocument()) {
     98        Frame* frame = static_cast<Document*>(context)->frame();
     99        ScriptController* scriptController = frame->script();
     100        if (!scriptController->canExecuteScripts(NotAboutToExecuteScript))
     101            return;
     102        V8Proxy* proxy = V8Proxy::retrieve(frame);
    99103        execute(proxy);
     104    }
    100105#if ENABLE(WORKERS)
    101     else if (context->isWorkerContext())
     106    else {
     107        ASSERT(context->isWorkerContext());
    102108        execute(static_cast<WorkerContext*>(context));
     109    }
    103110#endif
    104     // It's possible that Javascript is disabled and that we have neither a V8Proxy
    105     // nor a WorkerContext.  Do nothing in that case.
    106111}
    107112
  • trunk/Source/WebCore/bindings/v8/ScriptCachedFrameData.cpp

    r95901 r104694  
    6060        return;
    6161
     62    if (!frame->script()->canExecuteScripts(NotAboutToExecuteScript))
     63        return;
     64
    6265    v8::HandleScope handleScope;
    6366    v8::Context::Scope contextScope(m_context.get());
  • trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp

    r100307 r104694  
    217217        if (!context.IsEmpty()) {
    218218            v8::Handle<v8::Object> globalPrototype = v8::Handle<v8::Object>::Cast(context->Global()->GetPrototype());
    219             if (isWrapperOfType(globalPrototype, &V8DOMWindow::info))
    220                 proxy = V8Proxy::retrieve(V8DOMWindow::toNative(globalPrototype)->frame());
     219            if (isWrapperOfType(globalPrototype, &V8DOMWindow::info)) {
     220                Frame* frame = V8DOMWindow::toNative(globalPrototype)->frame();
     221                if (frame && frame->script()->canExecuteScripts(NotAboutToExecuteScript))
     222                    proxy = V8Proxy::retrieve(frame);
     223            }
    221224#if ENABLE(WORKERS)
    222225            else
  • trunk/Source/WebCore/bindings/v8/V8EventListener.cpp

    r95901 r104694  
    3636#endif
    3737
     38#include "Document.h"
     39#include "Frame.h"
    3840#include "V8Proxy.h"
    3941
     
    8284#endif
    8385
    84     if (V8Proxy* proxy = V8Proxy::retrieve(context))
    85         return proxy->callFunction(handlerFunction, receiver, 1, parameters);
     86    if (V8Proxy* proxy = V8Proxy::retrieve(context)) {
     87        Frame* frame = static_cast<Document*>(context)->frame();
     88        if (frame->script()->canExecuteScripts(NotAboutToExecuteScript))
     89            return proxy->callFunction(handlerFunction, receiver, 1, parameters);
     90    }
    8691
    8792    return v8::Local<v8::Value>();
  • trunk/Source/WebCore/bindings/v8/V8LazyEventListener.cpp

    r102424 r104694  
    6666    v8::Handle<v8::Value> parameters[1] = { jsEvent };
    6767
    68     if (V8Proxy* proxy = V8Proxy::retrieve(context))
    69         return proxy->callFunction(handlerFunction, receiver, 1, parameters);
     68    if (V8Proxy* proxy = V8Proxy::retrieve(context)) {
     69        Frame* frame = static_cast<Document*>(context)->frame();
     70        if (frame->script()->canExecuteScripts(NotAboutToExecuteScript))
     71            return proxy->callFunction(handlerFunction, receiver, 1, parameters);
     72    }
    7073
    7174    return v8::Local<v8::Value>();
     
    8992    V8Proxy* proxy = V8Proxy::retrieve(context);
    9093    if (!proxy)
     94        return;
     95    ASSERT(context->isDocument());
     96    if (!static_cast<Document*>(context)->frame()->script()->canExecuteScripts(NotAboutToExecuteScript))
    9197        return;
    9298
  • trunk/Source/WebCore/bindings/v8/V8Proxy.cpp

    r102871 r104694  
    191191
    192192    V8Proxy* proxy = V8Proxy::retrieve(frame);
    193     if (proxy) {
     193    if (proxy && frame->script()->canExecuteScripts(NotAboutToExecuteScript)) {
    194194        // Clean m_context, and event handlers.
    195195        proxy->clearForClose();
     
    506506V8Proxy* V8Proxy::retrieve(Frame* frame)
    507507{
    508     if (!frame)
    509         return 0;
    510     return frame->script()->canExecuteScripts(NotAboutToExecuteScript) ? frame->script()->proxy() : 0;
     508    return frame ? frame->script()->proxy() : 0;
    511509}
    512510
     
    709707{
    710708    if (context->isDocument()) {
    711         if (V8Proxy* proxy = V8Proxy::retrieve(context))
    712             return worldContext.adjustedContext(proxy);
     709        if (V8Proxy* proxy = V8Proxy::retrieve(context)) {
     710            Frame* frame = static_cast<Document*>(context)->frame();
     711            if (frame->script()->canExecuteScripts(NotAboutToExecuteScript))
     712                return worldContext.adjustedContext(proxy);
     713        }
    713714#if ENABLE(WORKERS)
    714715    } else if (context->isWorkerContext()) {
  • trunk/Source/WebKit/chromium/ChangeLog

    r104650 r104694  
     12012-01-11  Jochen Eisinger  <jochen@chromium.org>
     2
     3        Move the check for canExecuteScripts out of V8Proxy::retrieve
     4        https://bugs.webkit.org/show_bug.cgi?id=75533
     5
     6        Reviewed by Adam Barth.
     7
     8        * src/WebDevToolsAgentImpl.cpp:
     9        (WebKit::WebDevToolsAgentImpl::didClearWindowObject):
     10
    1112012-01-10  Daniel Cheng  <dcheng@chromium.org>
    212
  • trunk/Source/WebKit/chromium/src/WebDevToolsAgentImpl.cpp

    r102620 r104694  
    228228{
    229229    WebCore::V8Proxy* proxy = WebCore::V8Proxy::retrieve(webframe->frame());
    230     if (proxy)
     230    if (proxy && webframe->frame()->script()->canExecuteScripts(NotAboutToExecuteScript))
    231231        proxy->setContextDebugId(m_hostId);
    232232}
Note: See TracChangeset for help on using the changeset viewer.