⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 136168 in webkit


Ignore:
Timestamp:
Nov 29, 2012, 2:59:14 PM (14 years ago)
Author:
abarth@webkit.org
Message:

[V8] DOM callbacks shouldn't reimplement ScopedPersistent they should use it
​https://bugs.webkit.org/show_bug.cgi?id=103662

Reviewed by Eric Seidel.

This patch replaces yet another instance of the ScopedPersistent
pattern with ScopedPersistent.

  • bindings/scripts/CodeGeneratorV8.pm:

(GenerateCallbackHeader):
(GenerateCallbackImplementation):

  • bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp:

(WebCore::V8SQLStatementErrorCallback::handleEvent):

  • bindings/v8/custom/V8MutationCallbackCustom.cpp:

(WebCore::V8MutationCallback::handleEvent):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r136167 r136168  
     12012-11-29  Adam Barth  <abarth@webkit.org>
     2
     3        [V8] DOM callbacks shouldn't reimplement ScopedPersistent they should use it
     4        https://bugs.webkit.org/show_bug.cgi?id=103662
     5
     6        Reviewed by Eric Seidel.
     7
     8        This patch replaces yet another instance of the ScopedPersistent
     9        pattern with ScopedPersistent.
     10
     11        * bindings/scripts/CodeGeneratorV8.pm:
     12        (GenerateCallbackHeader):
     13        (GenerateCallbackImplementation):
     14        * bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp:
     15        (WebCore::V8SQLStatementErrorCallback::handleEvent):
     16        * bindings/v8/custom/V8MutationCallbackCustom.cpp:
     17        (WebCore::V8MutationCallback::handleEvent):
     18
    1192012-11-29  Min Qin  <qinmin@chromium.org>
    220
  • trunk/Source/WebCore/bindings/scripts/CodeGeneratorV8.pm

    r136015 r136168  
    32643264    push(@unsortedIncludes, "#include \"ActiveDOMCallback.h\"");
    32653265    push(@unsortedIncludes, "#include \"$interfaceName.h\"");
     3266    push(@unsortedIncludes, "#include \"ScopedPersistent.h\"");
    32663267    push(@unsortedIncludes, "#include \"WorldContextHandle.h\"");
    32673268    push(@unsortedIncludes, "#include <v8.h>");
    … …  
    33163317    {
    33173318        ${v8InterfaceName}* object = static_cast<${v8InterfaceName}*>(parameter);
    3318         object->m_callback.Dispose();
    3319         object->m_callback.Clear();
    3320     }
    3321 
    3322     // FIXME: m_callback should be a ScopedPersistent.
    3323     v8::Persistent<v8::Object> m_callback;
     3319        object->m_callback.clear();
     3320    }
     3321
     3322    ScopedPersistent<v8::Object> m_callback;
    33243323    WorldContextHandle m_worldContext;
    33253324};
    … …  
    33533352${v8InterfaceName}::${v8InterfaceName}(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
    33543353    : ActiveDOMCallback(context)
    3355     , m_callback(v8::Persistent<v8::Object>::New(callback))
     3354    , m_callback(callback)
    33563355    , m_worldContext(UseCurrentWorld)
    33573356{
    3358     if (!owner.IsEmpty()) {
    3359         owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
    3360         m_callback.MakeWeak(this, &${v8InterfaceName}::weakCallback);
    3361     }
     3357    if (owner.IsEmpty())
     3358        return;
     3359    owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
     3360    m_callback.get().MakeWeak(this, &${v8InterfaceName}::weakCallback);
    33623361}
    33633362
    33643363${v8InterfaceName}::~${v8InterfaceName}()
    33653364{
    3366     if (!m_callback.IsEmpty())
    3367         m_callback.Dispose();
    33683365}
    33693366
    … …  
    34353432                    next if $param->type ne $thisType;
    34363433                    my $paramName = $param->name;
    3437                     push(@implContent, "    return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(${paramName}Handle), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
     3434                    push(@implContent, "    return !invokeCallback(m_callback.get(), v8::Handle<v8::Object>::Cast(${paramName}Handle), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
    34383435                    last;
    34393436                }
    34403437            } else {
    3441                 push(@implContent, "    return !invokeCallback(m_callback, " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
     3438                push(@implContent, "    return !invokeCallback(m_callback.get(), " . scalar(@params) . ", argv, callbackReturnValue, scriptExecutionContext());\n");
    34423439            }
    34433440            push(@implContent, "}\n");
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.cpp

    r135305 r136168  
    4242V8TestCallback::V8TestCallback(v8::Handle<v8::Object> callback, ScriptExecutionContext* context, v8::Handle<v8::Object> owner)
    4343    : ActiveDOMCallback(context)
    44     , m_callback(v8::Persistent<v8::Object>::New(callback))
     44    , m_callback(callback)
    4545    , m_worldContext(UseCurrentWorld)
    4646{
    47     if (!owner.IsEmpty()) {
    48         owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
    49         m_callback.MakeWeak(this, &V8TestCallback::weakCallback);
    50     }
     47    if (owner.IsEmpty())
     48        return;
     49    owner->SetHiddenValue(V8HiddenPropertyName::callback(), callback);
     50    m_callback.get().MakeWeak(this, &V8TestCallback::weakCallback);
    5151}
    5252
    5353V8TestCallback::~V8TestCallback()
    5454{
    55     if (!m_callback.IsEmpty())
    56         m_callback.Dispose();
    5755}
    5856
    … …  
    7674
    7775    bool callbackReturnValue = false;
    78     return !invokeCallback(m_callback, 0, argv, callbackReturnValue, scriptExecutionContext());
     76    return !invokeCallback(m_callback.get(), 0, argv, callbackReturnValue, scriptExecutionContext());
    7977}
    8078
    … …  
    104102
    105103    bool callbackReturnValue = false;
    106     return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
     104    return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());
    107105}
    108106
    … …  
    139137
    140138    bool callbackReturnValue = false;
    141     return !invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext());
     139    return !invokeCallback(m_callback.get(), 2, argv, callbackReturnValue, scriptExecutionContext());
    142140}
    143141
    … …  
    167165
    168166    bool callbackReturnValue = false;
    169     return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
     167    return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());
    170168}
    171169
    … …  
    195193
    196194    bool callbackReturnValue = false;
    197     return !invokeCallback(m_callback, 1, argv, callbackReturnValue, scriptExecutionContext());
     195    return !invokeCallback(m_callback.get(), 1, argv, callbackReturnValue, scriptExecutionContext());
    198196}
    199197
    … …  
    232230
    233231    bool callbackReturnValue = false;
    234     return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(thisClassParamHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
     232    return !invokeCallback(m_callback.get(), v8::Handle<v8::Object>::Cast(thisClassParamHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
    235233}
    236234
  • trunk/Source/WebCore/bindings/scripts/test/V8/V8TestCallback.h

    r135320 r136168  
    2525
    2626#include "ActiveDOMCallback.h"
     27#include "ScopedPersistent.h"
    2728#include "TestCallback.h"
    2829#include "WorldContextHandle.h"
    … …  
    6162    {
    6263        V8TestCallback* object = static_cast<V8TestCallback*>(parameter);
    63         object->m_callback.Dispose();
    64         object->m_callback.Clear();
     64        object->m_callback.clear();
    6565    }
    6666
    67     // FIXME: m_callback should be a ScopedPersistent.
    68     v8::Persistent<v8::Object> m_callback;
     67    ScopedPersistent<v8::Object> m_callback;
    6968    WorldContextHandle m_worldContext;
    7069};
  • trunk/Source/WebCore/bindings/v8/custom/V8CustomSQLStatementErrorCallback.cpp

    r126399 r136168  
    7474    // the error callback did not return false, or there was no error callback.
    7575    // Jump to the last step in the overall steps.
    76     return invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext()) || callbackReturnValue;
     76    return invokeCallback(m_callback.get(), 2, argv, callbackReturnValue, scriptExecutionContext()) || callbackReturnValue;
    7777}
    7878
  • trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp

    r126399 r136168  
    8484
    8585    bool callbackReturnValue = false;
    86     return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(observerHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
     86    return !invokeCallback(m_callback.get(), v8::Handle<v8::Object>::Cast(observerHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
    8787}
    8888
Note: See TracChangeset for help on using the changeset viewer.