Changeset 126363 in webkit


Ignore:
Timestamp:
Aug 22, 2012 3:52:16 PM (12 years ago)
Author:
haraken@chromium.org
Message:

[V8] Move context() from V8Proxy to ScriptController
https://bugs.webkit.org/show_bug.cgi?id=94593

Reviewed by Adam Barth.

Source/WebCore:

  • This patch removes V8Proxy::context(Frame*).
  • This patch moves V8Proxy::context() to ScriptController::context().
  • This patch renames ScriptController::context() to ScriptController::currentWorldContext(),

for naming consistency with ScriptController::maintWorldContext().

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::context):
(WebCore):

  • bindings/v8/ScriptController.h:

(ScriptController):

  • bindings/v8/V8DOMWrapper.cpp:

(WebCore::V8DOMWrapper::setNamedHiddenWindowReference):

  • bindings/v8/V8Proxy.cpp:
  • bindings/v8/V8Proxy.h:

(V8Proxy):

  • bindings/v8/custom/V8DOMWindowCustom.cpp:

(WebCore::WindowSetTimeoutImpl):
(WebCore::V8DOMWindow::eventAccessorGetter):
(WebCore::V8DOMWindow::eventAccessorSetter):
(WebCore::DialogHandler::dialogCreated):
(WebCore::toV8):

  • bindings/v8/custom/V8HTMLDocumentCustom.cpp:

(WebCore::V8HTMLDocument::openCallback):

Source/WebKit/chromium:

To kill V8Proxy, we can move context() from V8Proxy to ScriptController.

No tests. No change in behavior.

  • src/InspectorFrontendClientImpl.cpp:

(WebKit::InspectorFrontendClientImpl::windowObjectCleared):

  • src/WebDevToolsFrontendImpl.cpp:

(WebKit::WebDevToolsFrontendImpl::dispatchOnInspectorFrontend):

Location:
trunk/Source
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r126362 r126363  
     12012-08-22  Kentaro Hara  <haraken@chromium.org>
     2
     3        [V8] Move context() from V8Proxy to ScriptController
     4        https://bugs.webkit.org/show_bug.cgi?id=94593
     5
     6        Reviewed by Adam Barth.
     7
     8        - This patch removes V8Proxy::context(Frame*).
     9        - This patch moves V8Proxy::context() to ScriptController::context().
     10        - This patch renames ScriptController::context() to ScriptController::currentWorldContext(),
     11        for naming consistency with ScriptController::maintWorldContext().
     12
     13        No tests. No change in behavior.
     14
     15        * bindings/scripts/CodeGeneratorV8.pm:
     16        (GenerateToV8Converters):
     17        * bindings/scripts/test/V8/V8TestActiveDOMObject.cpp:
     18        (WebCore::V8TestActiveDOMObject::wrapSlow):
     19        * bindings/scripts/test/V8/V8TestNode.cpp:
     20        (WebCore::V8TestNode::wrapSlow):
     21        * bindings/v8/ScriptController.cpp:
     22        (WebCore::ScriptController::context):
     23        (WebCore):
     24        * bindings/v8/ScriptController.h:
     25        (ScriptController):
     26        * bindings/v8/V8DOMWrapper.cpp:
     27        (WebCore::V8DOMWrapper::setNamedHiddenWindowReference):
     28        * bindings/v8/V8Proxy.cpp:
     29        * bindings/v8/V8Proxy.h:
     30        (V8Proxy):
     31        * bindings/v8/custom/V8DOMWindowCustom.cpp:
     32        (WebCore::WindowSetTimeoutImpl):
     33        (WebCore::V8DOMWindow::eventAccessorGetter):
     34        (WebCore::V8DOMWindow::eventAccessorSetter):
     35        (WebCore::DialogHandler::dialogCreated):
     36        (WebCore::toV8):
     37        * bindings/v8/custom/V8HTMLDocumentCustom.cpp:
     38        (WebCore::V8HTMLDocument::openCallback):
     39
    1402012-08-22  Kentaro Hara  <haraken@chromium.org>
    241
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r126362 r126363  
    33983398        // For performance, we enter the context only if the currently running context
    33993399        // is different from the context that we are about to enter.
    3400         context = proxy->context();
     3400        context = proxy->frame()->script()->currentWorldContext();
    34013401        if (!context.IsEmpty())
    34023402            context->Enter();
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestActiveDOMObject.cpp

    r126362 r126363  
    192192        // For performance, we enter the context only if the currently running context
    193193        // is different from the context that we are about to enter.
    194         context = proxy->context();
     194        context = proxy->frame()->script()->currentWorldContext();
    195195        if (!context.IsEmpty())
    196196            context->Enter();
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestNode.cpp

    r126362 r126363  
    122122        // For performance, we enter the context only if the currently running context
    123123        // is different from the context that we are about to enter.
    124         context = proxy->context();
     124        context = proxy->frame()->script()->currentWorldContext();
    125125        if (!context.IsEmpty())
    126126            context->Enter();
  • trunk/Source/WebCore/bindings/v8/ScriptController.cpp

    r126123 r126363  
    377377}
    378378
     379v8::Local<v8::Context> ScriptController::currentWorldContext()
     380{
     381    if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) {
     382        RefPtr<SharedPersistent<v8::Context> > context = isolatedContext->sharedContext();
     383        if (m_frame != toFrameIfNotDetached(context->get()))
     384            return v8::Local<v8::Context>();
     385        return v8::Local<v8::Context>::New(context->get());
     386    }
     387    return mainWorldContext();
     388}
     389
    379390v8::Local<v8::Context> ScriptController::mainWorldContext()
    380391{
  • trunk/Source/WebCore/bindings/v8/ScriptController.h

    r126222 r126363  
    155155    static Frame* retrieveFrameForCurrentContext();
    156156
    157     // Returns V8 Context of a frame. If none exists, creates
    158     // a new context. It is potentially slow and consumes memory.
     157    // Returns V8 Context. If none exists, creates a new context.
     158    // It is potentially slow and consumes memory.
    159159    static v8::Local<v8::Context> mainWorldContext(Frame*);
    160160    v8::Local<v8::Context> mainWorldContext();
     161    v8::Local<v8::Context> currentWorldContext();
    161162
    162163    // Pass command-line flags to the JS engine.
  • trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp

    r126362 r126363  
    130130    if (!frame)
    131131        return; // Object might be detached from window
    132     v8::Handle<v8::Context> context = V8Proxy::context(frame);
     132    v8::Handle<v8::Context> context = frame->script()->currentWorldContext();
    133133    if (context.IsEmpty())
    134134        return;
  • trunk/Source/WebCore/bindings/v8/V8Proxy.cpp

    r126360 r126363  
    179179}
    180180
    181 v8::Local<v8::Context> V8Proxy::context(Frame* frame)
    182 {
    183     v8::Local<v8::Context> context = ScriptController::mainWorldContext(frame);
    184     if (context.IsEmpty())
    185         return v8::Local<v8::Context>();
    186 
    187     if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) {
    188         context = v8::Local<v8::Context>::New(isolatedContext->context());
    189         if (frame != toFrameIfNotDetached(context))
    190             return v8::Local<v8::Context>();
    191     }
    192 
    193     return context;
    194 }
    195 
    196 v8::Local<v8::Context> V8Proxy::context()
    197 {
    198     if (V8IsolatedContext* isolatedContext = V8IsolatedContext::getEntered()) {
    199         RefPtr<SharedPersistent<v8::Context> > context = isolatedContext->sharedContext();
    200         if (m_frame != toFrameIfNotDetached(context->get()))
    201             return v8::Local<v8::Context>();
    202         return v8::Local<v8::Context>::New(context->get());
    203     }
    204     return frame()->script()->mainWorldContext();
    205 }
    206 
    207181v8::Local<v8::Context> V8Proxy::isolatedWorldContext(int worldId)
    208182{
  • trunk/Source/WebCore/bindings/v8/V8Proxy.h

    r126360 r126363  
    9898        v8::Local<v8::Value> runScript(v8::Handle<v8::Script>);
    9999
    100         // Returns V8 Context of a frame. If none exists, creates
    101         // a new context. It is potentially slow and consumes memory.
    102         static v8::Local<v8::Context> context(Frame*);
    103 
    104         v8::Local<v8::Context> context();
    105100        v8::Local<v8::Context> isolatedWorldContext(int worldId);
    106101        bool matchesCurrentContext();
  • trunk/Source/WebCore/bindings/v8/custom/V8DOMWindowCustom.cpp

    r125615 r126363  
    6262#include "V8HTMLCollection.h"
    6363#include "V8Node.h"
    64 #include "V8Proxy.h"
    6564#include "V8Utilities.h"
    6665#include "WindowFeatures.h"
     
    122121
    123122        // params is passed to action, and released in action's destructor
    124         OwnPtr<ScheduledAction> action = adoptPtr(new ScheduledAction(V8Proxy::context(imp->frame()), v8::Handle<v8::Function>::Cast(function), paramCount, params));
     123        ASSERT(imp->frame());
     124        OwnPtr<ScheduledAction> action = adoptPtr(new ScheduledAction(imp->frame()->script()->currentWorldContext(), v8::Handle<v8::Function>::Cast(function), paramCount, params));
    125125
    126126        // FIXME: We should use OwnArrayPtr for params.
     
    132132        if (imp->document() && !imp->document()->contentSecurityPolicy()->allowEval(callStack.release()))
    133133            return v8Integer(0, args.GetIsolate());
    134         id = DOMTimer::install(scriptContext, adoptPtr(new ScheduledAction(V8Proxy::context(imp->frame()), functionString)), timeout, singleShot);
     134        ASSERT(imp->frame());
     135        id = DOMTimer::install(scriptContext, adoptPtr(new ScheduledAction(imp->frame()->script()->currentWorldContext(), functionString)), timeout, singleShot);
    135136    }
    136137
     
    155156        return v8::Undefined();
    156157
    157     v8::Local<v8::Context> context = V8Proxy::context(frame);
     158    ASSERT(frame);
     159    v8::Local<v8::Context> context = frame->script()->currentWorldContext();
    158160    if (context.IsEmpty())
    159161        return v8::Undefined();
     
    176178        return;
    177179
    178     v8::Local<v8::Context> context = V8Proxy::context(frame);
     180    ASSERT(frame);
     181    v8::Local<v8::Context> context = frame->script()->currentWorldContext();
    179182    if (context.IsEmpty())
    180183        return;
     
    403406inline void DialogHandler::dialogCreated(DOMWindow* dialogFrame)
    404407{
    405     m_dialogContext = V8Proxy::context(dialogFrame->frame());
     408    m_dialogContext = dialogFrame->frame() ? dialogFrame->frame()->script()->currentWorldContext() : v8::Local<v8::Context>();
    406409    if (m_dialogContext.IsEmpty())
    407410        return;
     
    622625
    623626    // Otherwise, return the global object associated with this frame.
    624     v8::Handle<v8::Context> context = V8Proxy::context(frame);
     627    v8::Handle<v8::Context> context = frame->script()->currentWorldContext();
    625628    if (context.IsEmpty())
    626629        return v8Undefined();
  • trunk/Source/WebCore/bindings/v8/custom/V8HTMLDocumentCustom.cpp

    r125998 r126363  
    4545#include "V8IsolatedContext.h"
    4646#include "V8Node.h"
    47 #include "V8Proxy.h"
    4847#include "V8RecursionScope.h"
    4948#include <wtf/text/StringBuilder.h>
     
    143142        if (RefPtr<Frame> frame = htmlDocument->frame()) {
    144143            // Fetch the global object for the frame.
    145             v8::Local<v8::Context> context = V8Proxy::context(frame.get());
     144            v8::Local<v8::Context> context = frame->script()->currentWorldContext();
    146145            // Bail out if we cannot get the context.
    147146            if (context.IsEmpty())
  • trunk/Source/WebKit/chromium/ChangeLog

    r126359 r126363  
     12012-08-22  Kentaro Hara  <haraken@chromium.org>
     2
     3        [V8] Move context() from V8Proxy to ScriptController
     4        https://bugs.webkit.org/show_bug.cgi?id=94593
     5
     6        Reviewed by Adam Barth.
     7
     8        To kill V8Proxy, we can move context() from V8Proxy to ScriptController.
     9
     10        No tests. No change in behavior.
     11
     12        * src/InspectorFrontendClientImpl.cpp:
     13        (WebKit::InspectorFrontendClientImpl::windowObjectCleared):
     14        * src/WebDevToolsFrontendImpl.cpp:
     15        (WebKit::WebDevToolsFrontendImpl::dispatchOnInspectorFrontend):
     16
    1172012-08-22  Nikhil Bhargava  <nbhargava@google.com>
    218
  • trunk/Source/WebKit/chromium/src/InspectorFrontendClientImpl.cpp

    r124765 r126363  
    3737#include "Page.h"
    3838#include "PlatformString.h"
     39#include "ScriptController.h"
    3940#include "V8InspectorFrontendHost.h"
    40 #include "V8Proxy.h"
    4141#include "WebDevToolsFrontendClient.h"
    4242#include "WebDevToolsFrontendImpl.h"
     
    6464{
    6565    v8::HandleScope handleScope;
    66     v8::Handle<v8::Context> frameContext = V8Proxy::context(m_frontendPage->mainFrame());
     66    v8::Handle<v8::Context> frameContext = m_frontendPage->mainFrame() ? m_frontendPage->mainFrame()->script()->currentWorldContext() : v8::Local<v8::Context>();
    6767    v8::Context::Scope contextScope(frameContext);
    6868
  • trunk/Source/WebKit/chromium/src/WebDevToolsFrontendImpl.cpp

    r126109 r126363  
    4545#include "Pasteboard.h"
    4646#include "PlatformString.h"
     47#include "ScriptController.h"
    4748#include "SecurityOrigin.h"
    4849#include "Settings.h"
     
    5253#include "V8MouseEvent.h"
    5354#include "V8Node.h"
    54 #include "V8Proxy.h"
    5555#include "V8Utilities.h"
    5656#include "WebDevToolsFrontendClient.h"
     
    108108    WebFrameImpl* frame = m_webViewImpl->mainFrameImpl();
    109109    v8::HandleScope scope;
    110     v8::Handle<v8::Context> frameContext = V8Proxy::context(frame->frame());
     110    v8::Handle<v8::Context> frameContext = frame->frame() ? frame->frame()->script()->currentWorldContext() : v8::Local<v8::Context>();
    111111    v8::Context::Scope contextScope(frameContext);
    112112    v8::Handle<v8::Value> inspectorBackendValue = frameContext->Global()->Get(v8::String::New("InspectorBackend"));
Note: See TracChangeset for help on using the changeset viewer.