Changeset 111611 in webkit


Ignore:
Timestamp:
Mar 21, 2012 3:34:29 PM (12 years ago)
Author:
adamk@chromium.org
Message:

"this" argument for MutationCallbacks should be the MutationObserver
https://bugs.webkit.org/show_bug.cgi?id=81712

Reviewed by Adam Barth.

Source/WebCore:

Test: fast/mutation/callback-arguments.html

  • bindings/js/JSCallbackData.cpp:

(WebCore::JSCallbackData::invokeCallback): Add an overload that takes
an explicit this argument and have the old method call the new one.

  • bindings/js/JSCallbackData.h:

(JSCallbackData):

  • bindings/js/JSMutationCallbackCustom.cpp:

(WebCore::JSMutationCallback::handleEvent): Call the new overload.

  • bindings/v8/custom/V8CustomVoidCallback.cpp:

(WebCore::invokeCallback): Add an overload that takes an explicit this
argument and have the old method call the new one.

  • bindings/v8/custom/V8CustomVoidCallback.h:

(WebCore):

  • bindings/v8/custom/V8MutationCallbackCustom.cpp:

(WebCore::V8MutationCallback::handleEvent): Call the new overload.

LayoutTests:

Merged new test with existing second-argument test.

  • fast/mutation/callback-arguments-expected.txt: Added.
  • fast/mutation/callback-arguments.html: Added.
  • fast/mutation/callback-second-argument-expected.txt: Removed.
  • fast/mutation/callback-second-argument.html: Removed.
Location:
trunk
Files:
2 added
2 deleted
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r111610 r111611  
     12012-03-21  Adam Klein  <adamk@chromium.org>
     2
     3        "this" argument for MutationCallbacks should be the MutationObserver
     4        https://bugs.webkit.org/show_bug.cgi?id=81712
     5
     6        Reviewed by Adam Barth.
     7
     8        Merged new test with existing second-argument test.
     9
     10        * fast/mutation/callback-arguments-expected.txt: Added.
     11        * fast/mutation/callback-arguments.html: Added.
     12        * fast/mutation/callback-second-argument-expected.txt: Removed.
     13        * fast/mutation/callback-second-argument.html: Removed.
     14
    1152012-03-21  Alexandru Chiculita  <achicu@adobe.com>
    216
  • trunk/Source/WebCore/ChangeLog

    r111610 r111611  
     12012-03-21  Adam Klein  <adamk@chromium.org>
     2
     3        "this" argument for MutationCallbacks should be the MutationObserver
     4        https://bugs.webkit.org/show_bug.cgi?id=81712
     5
     6        Reviewed by Adam Barth.
     7
     8        Test: fast/mutation/callback-arguments.html
     9
     10        * bindings/js/JSCallbackData.cpp:
     11        (WebCore::JSCallbackData::invokeCallback): Add an overload that takes
     12        an explicit this argument and have the old method call the new one.
     13        * bindings/js/JSCallbackData.h:
     14        (JSCallbackData):
     15        * bindings/js/JSMutationCallbackCustom.cpp:
     16        (WebCore::JSMutationCallback::handleEvent): Call the new overload.
     17        * bindings/v8/custom/V8CustomVoidCallback.cpp:
     18        (WebCore::invokeCallback): Add an overload that takes an explicit this
     19        argument and have the old method call the new one.
     20        * bindings/v8/custom/V8CustomVoidCallback.h:
     21        (WebCore):
     22        * bindings/v8/custom/V8MutationCallbackCustom.cpp:
     23        (WebCore::V8MutationCallback::handleEvent): Call the new overload.
     24
    1252012-03-21  Alexandru Chiculita  <achicu@adobe.com>
    226
  • trunk/Source/WebCore/bindings/js/JSCallbackData.cpp

    r109568 r111611  
    4646{
    4747    ASSERT(callback());
     48    return invokeCallback(callback(), args, raisedException);
     49}
     50
     51JSValue JSCallbackData::invokeCallback(JSValue thisValue, MarkedArgumentBuffer& args, bool* raisedException)
     52{
     53    ASSERT(callback());
    4854    ASSERT(globalObject());
    4955
     
    5965            return JSValue();
    6066    }
    61    
     67
    6268    ScriptExecutionContext* context = globalObject()->scriptExecutionContext();
    6369    // We will fail to get the context if the frame has been detached.
     
    7076    bool contextIsDocument = context->isDocument();
    7177    JSValue result = contextIsDocument
    72         ? JSMainThreadExecState::call(exec, function, callType, callData, callback(), args)
    73         : JSC::call(exec, function, callType, callData, callback(), args);
     78        ? JSMainThreadExecState::call(exec, function, callType, callData, thisValue, args)
     79        : JSC::call(exec, function, callType, callData, thisValue, args);
    7480
    7581    InspectorInstrumentation::didCallFunction(cookie);
     
    8591        return result;
    8692    }
    87    
     93
    8894    return result;
    8995}
    90    
     96
    9197} // namespace WebCore
  • trunk/Source/WebCore/bindings/js/JSCallbackData.h

    r96465 r111611  
    6666   
    6767    JSC::JSValue invokeCallback(JSC::MarkedArgumentBuffer&, bool* raisedException = 0);
     68    JSC::JSValue invokeCallback(JSC::JSValue thisValue, JSC::MarkedArgumentBuffer&, bool* raisedException = 0);
    6869
    6970private:
  • trunk/Source/WebCore/bindings/js/JSMutationCallbackCustom.cpp

    r97159 r111611  
    5959        mutationList.append(toJS(exec, m_data->globalObject(), mutations->at(i).get()));
    6060
     61    JSValue jsObserver = toJS(exec, m_data->globalObject(), observer);
     62
    6163    MarkedArgumentBuffer args;
    6264    args.append(constructArray(exec, m_data->globalObject(), mutationList));
    63     args.append(toJS(exec, m_data->globalObject(), observer));
     65    args.append(jsObserver);
    6466
    6567    bool raisedException = false;
    66     m_data->invokeCallback(args, &raisedException);
     68    m_data->invokeCallback(jsObserver, args, &raisedException);
    6769    return !raisedException;
    6870}
  • trunk/Source/WebCore/bindings/v8/custom/V8CustomVoidCallback.cpp

    r107170 r111611  
    6666bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext)
    6767{
     68    return invokeCallback(callback, v8::Context::GetCurrent()->Global(), argc, argv, callbackReturnValue, scriptExecutionContext);
     69}
     70
     71bool invokeCallback(v8::Persistent<v8::Object> callback, v8::Handle<v8::Object> thisObject, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext)
     72{
    6873    v8::TryCatch exceptionCatcher;
    6974    exceptionCatcher.SetVerbose(true);
     
    8287        return false;
    8388
    84     v8::Handle<v8::Object> thisObject = v8::Context::GetCurrent()->Global();
    85 
    8689    Frame* frame = scriptExecutionContext && scriptExecutionContext->isDocument() ? static_cast<Document*>(scriptExecutionContext)->frame() : 0;
    8790    v8::Handle<v8::Value> result = V8Proxy::instrumentedCallFunction(frame, callbackFunction, thisObject, argc, argv);
  • trunk/Source/WebCore/bindings/v8/custom/V8CustomVoidCallback.h

    r95901 r111611  
    6262
    6363// Returns false if callback failed (null, wrong type, or threw exception).
    64 bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext* scriptExecutionContext);
     64bool invokeCallback(v8::Persistent<v8::Object> callback, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext*);
     65bool invokeCallback(v8::Persistent<v8::Object> callback, v8::Handle<v8::Object> thisObject, int argc, v8::Handle<v8::Value> argv[], bool& callbackReturnValue, ScriptExecutionContext*);
    6566
    6667} // namespace WebCore
  • trunk/Source/WebCore/bindings/v8/custom/V8MutationCallbackCustom.cpp

    r110131 r111611  
    7676    }
    7777
     78    if (!observerHandle->IsObject())
     79        return true;
     80
    7881    v8::Handle<v8::Value> argv[] = {
    7982        mutationsArray,
     
    8285
    8386    bool callbackReturnValue = false;
    84     return !invokeCallback(m_callback, 2, argv, callbackReturnValue, scriptExecutionContext());
     87    return !invokeCallback(m_callback, v8::Handle<v8::Object>::Cast(observerHandle), 2, argv, callbackReturnValue, scriptExecutionContext());
    8588}
    8689
Note: See TracChangeset for help on using the changeset viewer.