Changeset 128361 in webkit


Ignore:
Timestamp:
Sep 12, 2012 2:36:48 PM (12 years ago)
Author:
commit-queue@webkit.org
Message:

[V8] V8DOMWrapper::constructorForType is unnecessary now that we can get V8PerContextData from the v8::Context
https://bugs.webkit.org/show_bug.cgi?id=96556

Patch by Adam Barth <abarth@chromium.org> on 2012-09-12
Reviewed by Eric Seidel.

These functions no longer serve a purpose now that we can get the
V8PerContextData directly from the context. Previously we had to find
the Frame in order to find the per-context data.

  • bindings/scripts/CodeGeneratorV8.pm:

(GenerateConstructorGetter):

  • bindings/v8/V8DOMWindowShell.cpp:

(WebCore::V8DOMWindowShell::installDOMWindow):

  • bindings/v8/V8DOMWrapper.cpp:

(WebCore::V8DOMWrapper::instantiateV8Object):

  • bindings/v8/V8DOMWrapper.h:

(V8DOMWrapper):

  • bindings/v8/V8PerContextData.cpp:

(WebCore::V8PerContextData::from):

  • bindings/v8/V8PerContextData.h:

(V8PerContextData):

  • Changed this function to accept an arbitrary context rather than requiring the caller to use the current context.
Location:
trunk/Source/WebCore
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r128353 r128361  
     12012-09-12  Adam Barth  <abarth@chromium.org>
     2
     3        [V8] V8DOMWrapper::constructorForType is unnecessary now that we can get V8PerContextData from the v8::Context
     4        https://bugs.webkit.org/show_bug.cgi?id=96556
     5
     6        Reviewed by Eric Seidel.
     7
     8        These functions no longer serve a purpose now that we can get the
     9        V8PerContextData directly from the context. Previously we had to find
     10        the Frame in order to find the per-context data.
     11
     12        * bindings/scripts/CodeGeneratorV8.pm:
     13        (GenerateConstructorGetter):
     14        * bindings/v8/V8DOMWindowShell.cpp:
     15        (WebCore::V8DOMWindowShell::installDOMWindow):
     16        * bindings/v8/V8DOMWrapper.cpp:
     17        (WebCore::V8DOMWrapper::instantiateV8Object):
     18        * bindings/v8/V8DOMWrapper.h:
     19        (V8DOMWrapper):
     20        * bindings/v8/V8PerContextData.cpp:
     21        (WebCore::V8PerContextData::from):
     22        * bindings/v8/V8PerContextData.h:
     23        (V8PerContextData):
     24            - Changed this function to accept an arbitrary context rather than
     25              requiring the caller to use the current context.
     26
    1272012-09-12  Sheriff Bot  <webkit.review.bot@gmail.com>
    228
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r128248 r128361  
    805805    v8::Handle<v8::Value> data = info.Data();
    806806    ASSERT(data->IsExternal() || data->IsNumber());
    807     WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
    808 END
    809 
    810     if ($implClassName eq "DOMWindow") {
    811         push(@implContentDecls, <<END);
    812     // Get the proxy corresponding to the DOMWindow if possible to
    813     // make sure that the constructor function is constructed in the
    814     // context of the DOMWindow and not in the context of the caller.
    815     return V8DOMWrapper::constructorForType(type, V8DOMWindow::toNative(info.Holder()));
    816 END
    817     } elsif ($dataNode->extendedAttributes->{"IsWorkerContext"}) {
    818         push(@implContentDecls, <<END);
    819     return V8DOMWrapper::constructorForType(type, V8WorkerContext::toNative(info.Holder()));
    820 END
    821     } else {
    822         push(@implContentDecls, "    return v8Undefined();");
    823     }
    824 
    825     push(@implContentDecls, <<END);
     807    V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
     808    if (!perContextData)
     809        return v8Undefined();
     810    return perContextData->constructorForType(WrapperTypeInfo::unwrap(data));
    826811}
    827812
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestObj.cpp

    r128251 r128361  
    10401040    v8::Handle<v8::Value> data = info.Data();
    10411041    ASSERT(data->IsExternal() || data->IsNumber());
    1042     WrapperTypeInfo* type = WrapperTypeInfo::unwrap(data);
    1043     return v8Undefined();}
     1042    V8PerContextData* perContextData = V8PerContextData::from(info.Holder()->CreationContext());
     1043    if (!perContextData)
     1044        return v8Undefined();
     1045    return perContextData->constructorForType(WrapperTypeInfo::unwrap(data));
     1046}
    10441047
    10451048static void TestObjReplaceableAttrSetter(v8::Local<v8::String> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
  • trunk/Source/WebCore/bindings/v8/V8DOMWindowShell.cpp

    r128159 r128361  
    436436{
    437437    DOMWindow* window = m_frame->document()->domWindow();
    438     v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(V8DOMWrapper::constructorForType(&V8DOMWindow::info, window));
     438    v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(V8PerContextData::from(m_context.get())->constructorForType(&V8DOMWindow::info));
    439439    if (windowWrapper.IsEmpty())
    440440        return false;
  • trunk/Source/WebCore/bindings/v8/V8DOMWrapper.cpp

    r128303 r128361  
    8787}
    8888
    89 v8::Local<v8::Function> V8DOMWrapper::constructorForType(WrapperTypeInfo* type, DOMWindow* window)
    90 {
    91     Frame* frame = window->frame();
    92     if (!frame)
    93         return v8::Local<v8::Function>();
    94 
    95     if (V8PerContextData* contextData = perContextDataForCurrentWorld(frame))
    96         return contextData->constructorForType(type);
    97 
    98     return v8::Local<v8::Function>();
    99 }
    100 
    101 #if ENABLE(WORKERS)
    102 v8::Local<v8::Function> V8DOMWrapper::constructorForType(WrapperTypeInfo* type, WorkerContext*)
    103 {
    104     WorkerScriptController* controller = WorkerScriptController::controllerForContext();
    105     WorkerContextExecutionProxy* proxy = controller ? controller->proxy() : 0;
    106     return proxy ? proxy->perContextData()->constructorForType(type) : v8::Local<v8::Function>();
    107 }
    108 #endif
    109 
    11089#if ENABLE(WORKERS)
    11190V8PerContextData* V8DOMWrapper::perContextData(WorkerContext*)
     
    151130        perContextData = perContextDataForCurrentWorld(document->frame());
    152131    else
    153         perContextData = V8PerContextData::current();
     132        perContextData = V8PerContextData::from(v8::Context::GetCurrent());
    154133
    155134    v8::Local<v8::Object> instance = perContextData ? perContextData->createWrapperFromCache(type) : V8ObjectConstructor::newInstance(type->getTemplate()->GetFunction());
  • trunk/Source/WebCore/bindings/v8/V8DOMWrapper.h

    r128242 r128361  
    9494        static PassRefPtr<NodeFilter> wrapNativeNodeFilter(v8::Handle<v8::Value>);
    9595
    96         static v8::Local<v8::Function> constructorForType(WrapperTypeInfo*, DOMWindow*);
    97 #if ENABLE(WORKERS)
    98         static v8::Local<v8::Function> constructorForType(WrapperTypeInfo*, WorkerContext*);
    99 #endif
    100 
    10196        template<typename T>
    10297        static v8::Persistent<v8::Object> setJSWrapperForDOMObject(PassRefPtr<T>, v8::Handle<v8::Object>, v8::Isolate* = 0);
  • trunk/Source/WebCore/bindings/v8/V8PerContextData.cpp

    r127972 r128361  
    3838namespace WebCore {
    3939
    40 V8PerContextData* V8PerContextData::current()
     40V8PerContextData* V8PerContextData::from(v8::Handle<v8::Context> context)
    4141{
    42     v8::Handle<v8::Value> wrappedPerContextData = toInnerGlobalObject(v8::Context::GetCurrent())->GetHiddenValue(V8HiddenPropertyName::perContextData());
     42    v8::Handle<v8::Value> wrappedPerContextData = toInnerGlobalObject(context)->GetHiddenValue(V8HiddenPropertyName::perContextData());
    4343    if (wrappedPerContextData.IsEmpty())
    4444        return 0;
  • trunk/Source/WebCore/bindings/v8/V8PerContextData.h

    r127978 r128361  
    5454    bool init();
    5555
    56     static V8PerContextData* current();
     56    static V8PerContextData* from(v8::Handle<v8::Context>);
    5757
    5858    // To create JS Wrapper objects, we create a cache of a 'boiler plate'
Note: See TracChangeset for help on using the changeset viewer.