Changeset 207238 in webkit


Ignore:
Timestamp:
Oct 12, 2016 1:41:49 PM (7 years ago)
Author:
Chris Dumez
Message:

Update more events to stop using legacy [ConstructorTemplate=Event]
https://bugs.webkit.org/show_bug.cgi?id=163339

Reviewed by Ryosuke Niwa.

Source/WebCore:

Update more events to stop using legacy [ConstructorTemplate=Event]
and use regular constructors instead.

No new tests, updated existing tests.

  • bindings/scripts/test/JS/JSTestEventConstructor.cpp:

(WebCore::convertDictionary<TestEventConstructor::Init>):
(WebCore::JSTestEventConstructorConstructor::construct):
(WebCore::JSTestEventConstructorConstructor::prototypeForStructure):
(WebCore::JSTestEventConstructor::JSTestEventConstructor):
(WebCore::JSTestEventConstructor::createPrototype):
(WebCore::JSTestEventConstructorPrototype::create): Deleted.
(WebCore::JSTestEventConstructorPrototype::createStructure): Deleted.
(WebCore::JSTestEventConstructorPrototype::JSTestEventConstructorPrototype): Deleted.
(WebCore::setJSTestEventConstructorConstructor): Deleted.
(WebCore::JSTestEventConstructor::getConstructor): Deleted.

  • bindings/scripts/test/JS/JSTestEventConstructor.h:

(WebCore::JSTestEventConstructor::wrapped):
(WebCore::JSTestEventConstructor::create): Deleted.
(WebCore::toJS): Deleted.
(WebCore::toJSNewlyCreated): Deleted.

  • bindings/scripts/test/TestEventConstructor.idl:
  • css/CSSFontFaceLoadEvent.cpp:

(WebCore::CSSFontFaceLoadEvent::CSSFontFaceLoadEvent):

  • css/CSSFontFaceLoadEvent.h:
  • css/CSSFontFaceLoadEvent.idl:
  • html/canvas/WebGLContextEvent.cpp:

(WebCore::WebGLContextEvent::WebGLContextEvent):

  • html/canvas/WebGLContextEvent.h:
  • html/canvas/WebGLContextEvent.idl:
  • storage/StorageEvent.cpp:

(WebCore::StorageEvent::create):
(WebCore::StorageEvent::StorageEvent):

  • storage/StorageEvent.h:
  • storage/StorageEvent.idl:

LayoutTests:

Update existing tests to reflect minor behavior changes.

  • fast/events/constructors/storage-event-constructor-expected.txt:
  • fast/events/constructors/storage-event-constructor.html:
  • fast/events/constructors/webgl-context-event-constructor-expected.txt:
  • fast/events/constructors/webgl-context-event-constructor.html:
Location:
trunk
Files:
22 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r207229 r207238  
     12016-10-12  Chris Dumez  <cdumez@apple.com>
     2
     3        Update more events to stop using legacy [ConstructorTemplate=Event]
     4        https://bugs.webkit.org/show_bug.cgi?id=163339
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Update existing tests to reflect minor behavior changes.
     9
     10        * fast/events/constructors/storage-event-constructor-expected.txt:
     11        * fast/events/constructors/storage-event-constructor.html:
     12        * fast/events/constructors/webgl-context-event-constructor-expected.txt:
     13        * fast/events/constructors/webgl-context-event-constructor.html:
     14
    1152016-10-12  Joseph Pecoraro  <pecoraro@apple.com>
    216
  • trunk/LayoutTests/fast/events/constructors/storage-event-constructor-expected.txt

    r155401 r207238  
    66PASS new StorageEvent('eventType').bubbles is false
    77PASS new StorageEvent('eventType').cancelable is false
    8 PASS new StorageEvent('eventType').key is ""
     8PASS new StorageEvent('eventType').key is null
    99PASS new StorageEvent('eventType').oldValue is null
    1010PASS new StorageEvent('eventType').newValue is null
     
    1717PASS new StorageEvent('eventType', { key: 'abcde' }).key is "abcde"
    1818PASS new StorageEvent('eventType', { key: '' }).key is ""
    19 PASS new StorageEvent('eventType', { key: undefined }).key is "undefined"
    20 PASS new StorageEvent('eventType', { key: null }).key is "null"
     19PASS new StorageEvent('eventType', { key: undefined }).key is null
     20PASS new StorageEvent('eventType', { key: null }).key is null
    2121PASS new StorageEvent('eventType', { key: false }).key is "false"
    2222PASS new StorageEvent('eventType', { key: true }).key is "true"
     
    3030PASS new StorageEvent('eventType', { oldValue: 'abcde' }).oldValue is "abcde"
    3131PASS new StorageEvent('eventType', { oldValue: '' }).oldValue is ""
    32 PASS new StorageEvent('eventType', { oldValue: undefined }).oldValue is "undefined"
    33 PASS new StorageEvent('eventType', { oldValue: null }).oldValue is "null"
     32PASS new StorageEvent('eventType', { oldValue: undefined }).oldValue is null
     33PASS new StorageEvent('eventType', { oldValue: null }).oldValue is null
    3434PASS new StorageEvent('eventType', { oldValue: false }).oldValue is "false"
    3535PASS new StorageEvent('eventType', { oldValue: true }).oldValue is "true"
     
    4343PASS new StorageEvent('eventType', { newValue: 'abcde' }).newValue is "abcde"
    4444PASS new StorageEvent('eventType', { newValue: '' }).newValue is ""
    45 PASS new StorageEvent('eventType', { newValue: undefined }).newValue is "undefined"
    46 PASS new StorageEvent('eventType', { newValue: null }).newValue is "null"
     45PASS new StorageEvent('eventType', { newValue: undefined }).newValue is null
     46PASS new StorageEvent('eventType', { newValue: null }).newValue is null
    4747PASS new StorageEvent('eventType', { newValue: false }).newValue is "false"
    4848PASS new StorageEvent('eventType', { newValue: true }).newValue is "true"
     
    5656PASS new StorageEvent('eventType', { url: 'abcde' }).url is "abcde"
    5757PASS new StorageEvent('eventType', { url: '' }).url is ""
    58 PASS new StorageEvent('eventType', { url: undefined }).url is "undefined"
     58PASS new StorageEvent('eventType', { url: undefined }).url is ""
    5959PASS new StorageEvent('eventType', { url: null }).url is "null"
    6060PASS new StorageEvent('eventType', { url: false }).url is "false"
     
    6969PASS new StorageEvent('eventType', { storageArea: localStorage }).storageArea is localStorage
    7070PASS new StorageEvent('eventType', { storageArea: sessionStorage }).storageArea is sessionStorage
    71 PASS new StorageEvent('eventType', { storageArea: test_object }).storageArea is null
    72 PASS new StorageEvent('eventType', { storageArea: window }).storageArea is null
    73 PASS new StorageEvent('eventType', { storageArea: document }).storageArea is null
     71PASS new StorageEvent('eventType', { storageArea: test_object }) threw exception TypeError: Type error.
     72PASS new StorageEvent('eventType', { storageArea: window }) threw exception TypeError: Type error.
     73PASS new StorageEvent('eventType', { storageArea: document }) threw exception TypeError: Type error.
    7474PASS new StorageEvent('eventType', { storageArea: undefined }).storageArea is null
    7575PASS new StorageEvent('eventType', { storageArea: null }).storageArea is null
    76 PASS new StorageEvent('eventType', { storageArea: false }).storageArea is null
    77 PASS new StorageEvent('eventType', { storageArea: true }).storageArea is null
    78 PASS new StorageEvent('eventType', { storageArea: '' }).storageArea is null
    79 PASS new StorageEvent('eventType', { storageArea: 'chocolate' }).storageArea is null
    80 PASS new StorageEvent('eventType', { storageArea: 12345 }).storageArea is null
    81 PASS new StorageEvent('eventType', { storageArea: 18446744073709551615 }).storageArea is null
    82 PASS new StorageEvent('eventType', { storageArea: NaN }).storageArea is null
    83 PASS new StorageEvent('eventType', { storageArea: {valueOf: function () { return window; } } }).storageArea == window is false
    84 PASS new StorageEvent('eventType', { get storageArea() { return 123; } }).storageArea is null
     76PASS new StorageEvent('eventType', { storageArea: false }) threw exception TypeError: Type error.
     77PASS new StorageEvent('eventType', { storageArea: true }) threw exception TypeError: Type error.
     78PASS new StorageEvent('eventType', { storageArea: '' }) threw exception TypeError: Type error.
     79PASS new StorageEvent('eventType', { storageArea: 'chocolate' }) threw exception TypeError: Type error.
     80PASS new StorageEvent('eventType', { storageArea: 12345 }) threw exception TypeError: Type error.
     81PASS new StorageEvent('eventType', { storageArea: 18446744073709551615 }) threw exception TypeError: Type error.
     82PASS new StorageEvent('eventType', { storageArea: NaN }) threw exception TypeError: Type error.
     83PASS new StorageEvent('eventType', { storageArea: {valueOf: function () { return window; } } }) threw exception TypeError: Type error.
     84PASS new StorageEvent('eventType', { get storageArea() { return 123; } }).storageArea threw exception TypeError: Type error.
    8585PASS new StorageEvent('eventType', { get storageArea() { throw 'StorageEvent Error'; } }) threw exception StorageEvent Error.
    8686PASS new StorageEvent('eventType', { bubbles: true, cancelable: false, key: 'abc', oldValue: 'def', newValue: 'ghi', url: 'jkl', storageArea: localStorage }).bubbles is true
  • trunk/LayoutTests/fast/events/constructors/storage-event-constructor.html

    r155401 r207238  
    1414shouldBe("new StorageEvent('eventType').bubbles", "false");
    1515shouldBe("new StorageEvent('eventType').cancelable", "false");
    16 shouldBeEqualToString("new StorageEvent('eventType').key", "");
     16shouldBe("new StorageEvent('eventType').key", "null");
    1717// Note: oldValue is nullable.
    1818shouldBe("new StorageEvent('eventType').oldValue", "null");
     
    3737
    3838    // Non-strings.
    39     shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": undefined })." + attr, "undefined");
    40     shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": null })." + attr, "null");
     39    if (attr == "key" || attr == "oldValue" || attr == "newValue") {
     40        // Those members are nullable.
     41        shouldBe("new StorageEvent('eventType', { " + attr + ": undefined })." + attr, "null");
     42        shouldBe("new StorageEvent('eventType', { " + attr + ": null })." + attr, "null");
     43    } else {
     44        shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": undefined })." + attr, "");
     45        shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": null })." + attr, "null");
     46    }
    4147    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": false })." + attr, "false");
    4248    shouldBeEqualToString("new StorageEvent('eventType', { " + attr + ": true })." + attr, "true");
     
    5763// Non-Storage objects.
    5864var test_object = {abc: 123};
    59 shouldBe("new StorageEvent('eventType', { storageArea: test_object }).storageArea", "null");
    60 shouldBe("new StorageEvent('eventType', { storageArea: window }).storageArea", "null");
    61 shouldBe("new StorageEvent('eventType', { storageArea: document }).storageArea", "null");
     65shouldThrowErrorName("new StorageEvent('eventType', { storageArea: test_object })", "TypeError");
     66shouldThrowErrorName("new StorageEvent('eventType', { storageArea: window })", "TypeError");
     67shouldThrowErrorName("new StorageEvent('eventType', { storageArea: document })", "TypeError");
    6268shouldBe("new StorageEvent('eventType', { storageArea: undefined }).storageArea", "null");
    6369shouldBe("new StorageEvent('eventType', { storageArea: null }).storageArea", "null");
    64 shouldBe("new StorageEvent('eventType', { storageArea: false }).storageArea", "null");
    65 shouldBe("new StorageEvent('eventType', { storageArea: true }).storageArea", "null");
    66 shouldBe("new StorageEvent('eventType', { storageArea: '' }).storageArea", "null");
    67 shouldBe("new StorageEvent('eventType', { storageArea: 'chocolate' }).storageArea", "null");
    68 shouldBe("new StorageEvent('eventType', { storageArea: 12345 }).storageArea", "null");
    69 shouldBe("new StorageEvent('eventType', { storageArea: 18446744073709551615 }).storageArea", "null");
    70 shouldBe("new StorageEvent('eventType', { storageArea: NaN }).storageArea", "null");
     70shouldThrowErrorName("new StorageEvent('eventType', { storageArea: false })", "TypeError");
     71shouldThrowErrorName("new StorageEvent('eventType', { storageArea: true })", "TypeError");
     72shouldThrowErrorName("new StorageEvent('eventType', { storageArea: '' })", "TypeError");
     73shouldThrowErrorName("new StorageEvent('eventType', { storageArea: 'chocolate' })", "TypeError");
     74shouldThrowErrorName("new StorageEvent('eventType', { storageArea: 12345 })", "TypeError");
     75shouldThrowErrorName("new StorageEvent('eventType', { storageArea: 18446744073709551615 })", "TypeError");
     76shouldThrowErrorName("new StorageEvent('eventType', { storageArea: NaN })", "TypeError");
    7177// Note that valueOf() is not called, when the left hand side is evaluated.
    72 shouldBeFalse("new StorageEvent('eventType', { storageArea: {valueOf: function () { return window; } } }).storageArea == window");
    73 shouldBe("new StorageEvent('eventType', { get storageArea() { return 123; } }).storageArea", "null");
     78shouldThrowErrorName("new StorageEvent('eventType', { storageArea: {valueOf: function () { return window; } } })", "TypeError");
     79shouldThrowErrorName("new StorageEvent('eventType', { get storageArea() { return 123; } }).storageArea", "TypeError");
    7480shouldThrow("new StorageEvent('eventType', { get storageArea() { throw 'StorageEvent Error'; } })");
    7581
  • trunk/LayoutTests/fast/events/constructors/webgl-context-event-constructor-expected.txt

    r101183 r207238  
    1313PASS new WebGLContextEvent('eventType', { statusMessage: 'abcde' }).statusMessage is "abcde"
    1414PASS new WebGLContextEvent('eventType', { statusMessage: '' }).statusMessage is ""
    15 PASS new WebGLContextEvent('eventType', { statusMessage: undefined }).statusMessage is "undefined"
     15PASS new WebGLContextEvent('eventType', { statusMessage: undefined }).statusMessage is ""
    1616PASS new WebGLContextEvent('eventType', { statusMessage: null }).statusMessage is "null"
    1717PASS new WebGLContextEvent('eventType', { statusMessage: false }).statusMessage is "false"
  • trunk/LayoutTests/fast/events/constructors/webgl-context-event-constructor.html

    r155267 r207238  
    3030
    3131// Non-strings.
    32 shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: undefined }).statusMessage", "undefined");
     32shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: undefined }).statusMessage", "");
    3333shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: null }).statusMessage", "null");
    3434shouldBeEqualToString("new WebGLContextEvent('eventType', { statusMessage: false }).statusMessage", "false");
  • trunk/LayoutTests/storage/domstorage/events/basic-expected.txt

    r101453 r207238  
    4343storage.clear()
    4444PASS storageEventList.length is 8
    45 PASS storageEventList[7].key is ""
     45PASS storageEventList[7].key is null
    4646PASS storageEventList[7].oldValue is null
    4747PASS storageEventList[7].newValue is null
     
    8787storage.clear()
    8888PASS storageEventList.length is 8
    89 PASS storageEventList[7].key is ""
     89PASS storageEventList[7].key is null
    9090PASS storageEventList[7].oldValue is null
    9191PASS storageEventList[7].newValue is null
  • trunk/LayoutTests/storage/domstorage/events/basic-setattribute-expected.txt

    r101453 r207238  
    4545storage.clear()
    4646PASS storageEventList.length is 8
    47 PASS storageEventList[7].key is ""
     47PASS storageEventList[7].key is null
    4848PASS storageEventList[7].oldValue is null
    4949PASS storageEventList[7].newValue is null
     
    9191storage.clear()
    9292PASS storageEventList.length is 8
    93 PASS storageEventList[7].key is ""
     93PASS storageEventList[7].key is null
    9494PASS storageEventList[7].oldValue is null
    9595PASS storageEventList[7].newValue is null
  • trunk/LayoutTests/storage/domstorage/events/script-tests/basic-setattribute.js

    r101453 r207238  
    8787{
    8888    shouldBe("storageEventList.length", "8");
    89     shouldBeEqualToString("storageEventList[7].key", "");
     89    shouldBeNull("storageEventList[7].key");
    9090    shouldBeNull("storageEventList[7].oldValue");
    9191    shouldBeNull("storageEventList[7].newValue");
  • trunk/LayoutTests/storage/domstorage/events/script-tests/basic.js

    r101453 r207238  
    8787{
    8888    shouldBe("storageEventList.length", "8");
    89     shouldBeEqualToString("storageEventList[7].key", "");
     89    shouldBeNull("storageEventList[7].key");
    9090    shouldBeNull("storageEventList[7].oldValue");
    9191    shouldBeNull("storageEventList[7].newValue");
  • trunk/Source/WebCore/ChangeLog

    r207234 r207238  
     12016-10-12  Chris Dumez  <cdumez@apple.com>
     2
     3        Update more events to stop using legacy [ConstructorTemplate=Event]
     4        https://bugs.webkit.org/show_bug.cgi?id=163339
     5
     6        Reviewed by Ryosuke Niwa.
     7
     8        Update more events to stop using legacy [ConstructorTemplate=Event]
     9        and use regular constructors instead.
     10
     11        No new tests, updated existing tests.
     12
     13        * bindings/scripts/test/JS/JSTestEventConstructor.cpp:
     14        (WebCore::convertDictionary<TestEventConstructor::Init>):
     15        (WebCore::JSTestEventConstructorConstructor::construct):
     16        (WebCore::JSTestEventConstructorConstructor::prototypeForStructure):
     17        (WebCore::JSTestEventConstructor::JSTestEventConstructor):
     18        (WebCore::JSTestEventConstructor::createPrototype):
     19        (WebCore::JSTestEventConstructorPrototype::create): Deleted.
     20        (WebCore::JSTestEventConstructorPrototype::createStructure): Deleted.
     21        (WebCore::JSTestEventConstructorPrototype::JSTestEventConstructorPrototype): Deleted.
     22        (WebCore::setJSTestEventConstructorConstructor): Deleted.
     23        (WebCore::JSTestEventConstructor::getConstructor): Deleted.
     24        * bindings/scripts/test/JS/JSTestEventConstructor.h:
     25        (WebCore::JSTestEventConstructor::wrapped):
     26        (WebCore::JSTestEventConstructor::create): Deleted.
     27        (WebCore::toJS): Deleted.
     28        (WebCore::toJSNewlyCreated): Deleted.
     29        * bindings/scripts/test/TestEventConstructor.idl:
     30        * css/CSSFontFaceLoadEvent.cpp:
     31        (WebCore::CSSFontFaceLoadEvent::CSSFontFaceLoadEvent):
     32        * css/CSSFontFaceLoadEvent.h:
     33        * css/CSSFontFaceLoadEvent.idl:
     34        * html/canvas/WebGLContextEvent.cpp:
     35        (WebCore::WebGLContextEvent::WebGLContextEvent):
     36        * html/canvas/WebGLContextEvent.h:
     37        * html/canvas/WebGLContextEvent.idl:
     38        * storage/StorageEvent.cpp:
     39        (WebCore::StorageEvent::create):
     40        (WebCore::StorageEvent::StorageEvent):
     41        * storage/StorageEvent.h:
     42        * storage/StorageEvent.idl:
     43
    1442016-10-12  Andreas Kling  <akling@apple.com>
    245
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.cpp

    r207192 r207238  
    2222#include "JSTestEventConstructor.h"
    2323
     24#include "ExceptionCode.h"
    2425#include "JSDOMBinding.h"
    2526#include "JSDOMConstructor.h"
    26 #include "JSDictionary.h"
    2727#include "URL.h"
    2828#include <runtime/Error.h>
    29 #include <runtime/FunctionPrototype.h>
    3029#include <runtime/JSString.h>
    3130#include <wtf/GetPtr.h>
     
    3433
    3534namespace WebCore {
     35
     36template<> Optional<TestEventConstructor::Init> convertDictionary<TestEventConstructor::Init>(ExecState& state, JSValue value)
     37{
     38    VM& vm = state.vm();
     39    auto throwScope = DECLARE_THROW_SCOPE(vm);
     40    bool isNullOrUndefined = value.isUndefinedOrNull();
     41    auto* object = isNullOrUndefined ? nullptr : value.getObject();
     42    if (UNLIKELY(!isNullOrUndefined && !object)) {
     43        throwTypeError(&state, throwScope);
     44        return Nullopt;
     45    }
     46    if (UNLIKELY(object && object->type() == RegExpObjectType)) {
     47        throwTypeError(&state, throwScope);
     48        return Nullopt;
     49    }
     50    TestEventConstructor::Init result;
     51    JSValue bubblesValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "bubbles"));
     52    if (!bubblesValue.isUndefined()) {
     53        result.bubbles = convert<IDLBoolean>(state, bubblesValue);
     54        RETURN_IF_EXCEPTION(throwScope, Nullopt);
     55    } else
     56        result.bubbles = false;
     57    JSValue cancelableValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "cancelable"));
     58    if (!cancelableValue.isUndefined()) {
     59        result.cancelable = convert<IDLBoolean>(state, cancelableValue);
     60        RETURN_IF_EXCEPTION(throwScope, Nullopt);
     61    } else
     62        result.cancelable = false;
     63    JSValue composedValue = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "composed"));
     64    if (!composedValue.isUndefined()) {
     65        result.composed = convert<IDLBoolean>(state, composedValue);
     66        RETURN_IF_EXCEPTION(throwScope, Nullopt);
     67    } else
     68        result.composed = false;
     69    JSValue attr2Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "attr2"));
     70    if (!attr2Value.isUndefined()) {
     71        result.attr2 = convert<IDLDOMString>(state, attr2Value);
     72        RETURN_IF_EXCEPTION(throwScope, Nullopt);
     73    } else
     74        result.attr2 = "";
     75    JSValue attr3Value = isNullOrUndefined ? jsUndefined() : object->get(&state, Identifier::fromString(&state, "attr3"));
     76    if (!attr3Value.isUndefined()) {
     77        result.attr3 = convert<IDLDOMString>(state, attr3Value);
     78        RETURN_IF_EXCEPTION(throwScope, Nullopt);
     79    } else
     80        result.attr3 = "";
     81    return WTFMove(result);
     82}
    3683
    3784// Attributes
     
    76123    VM& vm = state->vm();
    77124    auto throwScope = DECLARE_THROW_SCOPE(vm);
    78     auto* jsConstructor = jsCast<JSTestEventConstructorConstructor*>(state->callee());
    79     ASSERT(jsConstructor);
    80 
    81     if (!jsConstructor->scriptExecutionContext())
    82         return throwConstructorScriptExecutionContextUnavailableError(*state, throwScope, "TestEventConstructor");
    83 
     125    UNUSED_PARAM(throwScope);
     126    auto* castedThis = jsCast<JSTestEventConstructorConstructor*>(state->callee());
     127    ASSERT(castedThis);
    84128    if (UNLIKELY(state->argumentCount() < 1))
    85129        return throwVMError(state, throwScope, createNotEnoughArgumentsError(state));
    86 
    87     AtomicString eventType = state->uncheckedArgument(0).toString(state)->toAtomicString(state);
     130    auto type = state->uncheckedArgument(0).toWTFString(state);
    88131    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
    89 
    90     TestEventConstructorInit eventInit;
    91 
    92     JSValue initializerValue = state->argument(1);
    93     if (!initializerValue.isUndefinedOrNull()) {
    94         // Given the above test, this will always yield an object.
    95         JSObject* initializerObject = initializerValue.toObject(state);
    96         ASSERT(!throwScope.exception());
    97 
    98         // Create the dictionary wrapper from the initializer object.
    99         JSDictionary dictionary(state, initializerObject);
    100 
    101         // Attempt to fill in the EventInit.
    102         if (!fillTestEventConstructorInit(eventInit, dictionary))
    103             return JSValue::encode(jsUndefined());
    104     }
    105 
    106     Ref<TestEventConstructor> event = TestEventConstructor::createForBindings(eventType, eventInit);
    107     return JSValue::encode(createWrapper<TestEventConstructor>(jsConstructor->globalObject(), WTFMove(event)));
    108 }
    109 
    110 bool fillTestEventConstructorInit(TestEventConstructorInit& eventInit, JSDictionary& dictionary)
    111 {
    112     if (!dictionary.tryGetProperty("attr2", eventInit.attr2))
    113         return false;
    114 #if ENABLE(SPECIAL_EVENT)
    115     if (!dictionary.tryGetProperty("attr3", eventInit.attr3))
    116         return false;
    117 #endif
    118     return true;
     132    auto eventInitDict = convert<IDLDictionary<TestEventConstructor::Init>>(*state, state->argument(1));
     133    RETURN_IF_EXCEPTION(throwScope, encodedJSValue());
     134    auto object = TestEventConstructor::create(WTFMove(type), eventInitDict.value());
     135    return JSValue::encode(toJSNewlyCreated(state, castedThis->globalObject(), WTFMove(object)));
    119136}
    120137
    121138template<> JSValue JSTestEventConstructorConstructor::prototypeForStructure(JSC::VM& vm, const JSDOMGlobalObject& globalObject)
    122139{
    123     UNUSED_PARAM(vm);
    124     return globalObject.functionPrototype();
     140    return JSEvent::getConstructor(vm, &globalObject);
    125141}
    126142
     
    159175
    160176JSTestEventConstructor::JSTestEventConstructor(Structure* structure, JSDOMGlobalObject& globalObject, Ref<TestEventConstructor>&& impl)
    161     : JSDOMWrapper<TestEventConstructor>(structure, globalObject, WTFMove(impl))
     177    : JSEvent(structure, globalObject, WTFMove(impl))
    162178{
    163179}
     
    165181JSObject* JSTestEventConstructor::createPrototype(VM& vm, JSGlobalObject* globalObject)
    166182{
    167     return JSTestEventConstructorPrototype::create(vm, globalObject, JSTestEventConstructorPrototype::createStructure(vm, globalObject, globalObject->objectPrototype()));
     183    return JSTestEventConstructorPrototype::create(vm, globalObject, JSTestEventConstructorPrototype::createStructure(vm, globalObject, JSEvent::prototype(vm, globalObject)));
    168184}
    169185
     
    171187{
    172188    return getDOMPrototype<JSTestEventConstructor>(vm, globalObject);
    173 }
    174 
    175 void JSTestEventConstructor::destroy(JSC::JSCell* cell)
    176 {
    177     JSTestEventConstructor* thisObject = static_cast<JSTestEventConstructor*>(cell);
    178     thisObject->JSTestEventConstructor::~JSTestEventConstructor();
    179189}
    180190
     
    262272{
    263273    return getDOMConstructor<JSTestEventConstructorConstructor>(vm, *jsCast<const JSDOMGlobalObject*>(globalObject));
    264 }
    265 
    266 bool JSTestEventConstructorOwner::isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown> handle, void*, SlotVisitor& visitor)
    267 {
    268     UNUSED_PARAM(handle);
    269     UNUSED_PARAM(visitor);
    270     return false;
    271 }
    272 
    273 void JSTestEventConstructorOwner::finalize(JSC::Handle<JSC::Unknown> handle, void* context)
    274 {
    275     auto* jsTestEventConstructor = jsCast<JSTestEventConstructor*>(handle.slot()->asCell());
    276     auto& world = *static_cast<DOMWrapperWorld*>(context);
    277     uncacheWrapper(world, &jsTestEventConstructor->wrapped(), jsTestEventConstructor);
    278274}
    279275
     
    316312}
    317313
    318 TestEventConstructor* JSTestEventConstructor::toWrapped(JSC::JSValue value)
    319 {
    320     if (auto* wrapper = jsDynamicCast<JSTestEventConstructor*>(value))
    321         return &wrapper->wrapped();
    322     return nullptr;
    323 }
    324 
    325 }
     314
     315}
  • trunk/Source/WebCore/bindings/scripts/test/JS/JSTestEventConstructor.h

    r207192 r207238  
    2121#pragma once
    2222
    23 #include "JSDOMWrapper.h"
     23#include "JSDOMConvert.h"
     24#include "JSEvent.h"
    2425#include "TestEventConstructor.h"
    25 #include <wtf/NeverDestroyed.h>
    2626
    2727namespace WebCore {
    2828
    29 class JSDictionary;
    30 
    31 class JSTestEventConstructor : public JSDOMWrapper<TestEventConstructor> {
     29class JSTestEventConstructor : public JSEvent {
    3230public:
    33     using Base = JSDOMWrapper<TestEventConstructor>;
     31    using Base = JSEvent;
     32    using DOMWrapped = TestEventConstructor;
    3433    static JSTestEventConstructor* create(JSC::Structure* structure, JSDOMGlobalObject* globalObject, Ref<TestEventConstructor>&& impl)
    3534    {
     
    4140    static JSC::JSObject* createPrototype(JSC::VM&, JSC::JSGlobalObject*);
    4241    static JSC::JSObject* prototype(JSC::VM&, JSC::JSGlobalObject*);
    43     static TestEventConstructor* toWrapped(JSC::JSValue);
    44     static void destroy(JSC::JSCell*);
    4542
    4643    DECLARE_INFO;
     
    5249
    5350    static JSC::JSValue getConstructor(JSC::VM&, const JSC::JSGlobalObject*);
     51    TestEventConstructor& wrapped() const
     52    {
     53        return static_cast<TestEventConstructor&>(Base::wrapped());
     54    }
    5455protected:
    5556    JSTestEventConstructor(JSC::Structure*, JSDOMGlobalObject&, Ref<TestEventConstructor>&&);
     
    6364};
    6465
    65 class JSTestEventConstructorOwner : public JSC::WeakHandleOwner {
    66 public:
    67     virtual bool isReachableFromOpaqueRoots(JSC::Handle<JSC::Unknown>, void* context, JSC::SlotVisitor&);
    68     virtual void finalize(JSC::Handle<JSC::Unknown>, void* context);
    69 };
    70 
    71 inline JSC::WeakHandleOwner* wrapperOwner(DOMWrapperWorld&, TestEventConstructor*)
    72 {
    73     static NeverDestroyed<JSTestEventConstructorOwner> owner;
    74     return &owner.get();
    75 }
    76 
    77 inline void* wrapperKey(TestEventConstructor* wrappableObject)
    78 {
    79     return wrappableObject;
    80 }
    81 
    8266JSC::JSValue toJS(JSC::ExecState*, JSDOMGlobalObject*, TestEventConstructor&);
    8367inline JSC::JSValue toJS(JSC::ExecState* state, JSDOMGlobalObject* globalObject, TestEventConstructor* impl) { return impl ? toJS(state, globalObject, *impl) : JSC::jsNull(); }
     
    8569inline JSC::JSValue toJSNewlyCreated(JSC::ExecState* state, JSDOMGlobalObject* globalObject, RefPtr<TestEventConstructor>&& impl) { return impl ? toJSNewlyCreated(state, globalObject, impl.releaseNonNull()) : JSC::jsNull(); }
    8670
    87 bool fillTestEventConstructorInit(TestEventConstructorInit&, JSDictionary&);
    88 
    8971template<> struct JSDOMWrapperConverterTraits<TestEventConstructor> {
    9072    using WrapperClass = JSTestEventConstructor;
    9173};
     74template<> Optional<TestEventConstructor::Init> convertDictionary<TestEventConstructor::Init>(JSC::ExecState&, JSC::JSValue);
     75
    9276
    9377} // namespace WebCore
  • trunk/Source/WebCore/bindings/scripts/test/TestEventConstructor.idl

    r198056 r207238  
    3030// changes in its ouput.
    3131[
    32     ConstructorTemplate=Event
    33 ] interface TestEventConstructor {
     32    Constructor(DOMString type, optional TestEventConstructorInit eventInitDict),
     33] interface TestEventConstructor : Event {
    3434    // Attributes
    3535    readonly attribute DOMString attr1;
    36     [InitializedByEventConstructor] readonly attribute DOMString attr2;
    37     [InitializedByEventConstructor, Conditional=SPECIAL_EVENT] readonly attribute DOMString attr3;
     36    readonly attribute DOMString attr2;
     37    [Conditional=SPECIAL_EVENT] readonly attribute DOMString attr3;
    3838};
     39
     40dictionary TestEventConstructorInit : EventInit {
     41    DOMString attr2 = "";
     42    [Conditional=SPECIAL_EVENT]  DOMString attr3 = "";
     43};
  • trunk/Source/WebCore/css/CSSFontFaceLoadEvent.cpp

    r201113 r207238  
    4747}
    4848
    49 CSSFontFaceLoadEvent::CSSFontFaceLoadEvent(const AtomicString& type, const CSSFontFaceLoadEventInit& initializer)
    50     : Event(type, initializer)
     49CSSFontFaceLoadEvent::CSSFontFaceLoadEvent(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
     50    : Event(type, initializer, isTrusted)
    5151    , m_fontface(initializer.fontface)
    5252    , m_error(initializer.error)
  • trunk/Source/WebCore/css/CSSFontFaceLoadEvent.h

    r205093 r207238  
    4343class DOMError;
    4444
    45 struct CSSFontFaceLoadEventInit : public EventInit {
    46     RefPtr<CSSFontFaceRule> fontface;
    47     RefPtr<DOMError> error;
    48 };
    49 
    5045class CSSFontFaceLoadEvent final : public Event {
    5146public:
     
    5550    }
    5651
    57     static Ref<CSSFontFaceLoadEvent> create(const AtomicString& type, const CSSFontFaceLoadEventInit& initializer)
     52    struct Init : EventInit {
     53        RefPtr<CSSFontFaceRule> fontface;
     54        RefPtr<DOMError> error;
     55    };
     56
     57    static Ref<CSSFontFaceLoadEvent> create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No)
    5858    {
    59         return adoptRef<CSSFontFaceLoadEvent>(*new CSSFontFaceLoadEvent(type, initializer));
     59        return adoptRef<CSSFontFaceLoadEvent>(*new CSSFontFaceLoadEvent(type, initializer, isTrusted));
    6060    }
    6161
     
    8080    CSSFontFaceLoadEvent();
    8181    CSSFontFaceLoadEvent(const AtomicString&, RefPtr<CSSFontFaceRule>&&, RefPtr<DOMError>&&);
    82     CSSFontFaceLoadEvent(const AtomicString&, const CSSFontFaceLoadEventInit&);
     82    CSSFontFaceLoadEvent(const AtomicString&, const Init&, IsTrusted);
    8383
    8484    RefPtr<CSSFontFaceRule> m_fontface;
  • trunk/Source/WebCore/css/CSSFontFaceLoadEvent.idl

    r171824 r207238  
    3030
    3131[
    32     NoInterfaceObject,
    3332    Conditional=FONT_LOAD_EVENTS,
    34     ConstructorTemplate=Event
     33    Constructor(DOMString type, optional CSSFontFaceLoadEventInit eventInit),
    3534] interface CSSFontFaceLoadEvent : Event {
    36     [InitializedByEventConstructor] readonly attribute CSSFontFaceRule fontface;
    37     [InitializedByEventConstructor] readonly attribute DOMError error;
     35    readonly attribute CSSFontFaceRule? fontface;
     36    readonly attribute DOMError? error;
    3837};
     38
     39dictionary CSSFontFaceLoadEventInit : EventInit {
     40    CSSFontFaceRule? fontface = null;
     41    DOMError? error = null;
     42};
  • trunk/Source/WebCore/html/canvas/WebGLContextEvent.cpp

    r196400 r207238  
    3939}
    4040
    41 WebGLContextEvent::WebGLContextEvent(const AtomicString& type, const WebGLContextEventInit& initializer)
    42     : Event(type, initializer)
     41WebGLContextEvent::WebGLContextEvent(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
     42    : Event(type, initializer, isTrusted)
    4343    , m_statusMessage(initializer.statusMessage)
    4444{
  • trunk/Source/WebCore/html/canvas/WebGLContextEvent.h

    r197563 r207238  
    3131namespace WebCore {
    3232
    33 struct WebGLContextEventInit : public EventInit {
    34     String statusMessage;
    35 };
    36 
    3733class WebGLContextEvent final : public Event {
    3834public:
     
    4137        return adoptRef(*new WebGLContextEvent(type, canBubble, cancelable, statusMessage));
    4238    }
    43     static Ref<WebGLContextEvent> createForBindings(const AtomicString& type, const WebGLContextEventInit& initializer)
     39
     40    struct Init : EventInit {
     41        String statusMessage;
     42    };
     43
     44    static Ref<WebGLContextEvent> create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted = IsTrusted::No)
    4445    {
    45         return adoptRef(*new WebGLContextEvent(type, initializer));
     46        return adoptRef(*new WebGLContextEvent(type, initializer, isTrusted));
    4647    }
    4748    virtual ~WebGLContextEvent();
     
    5354private:
    5455    WebGLContextEvent(const AtomicString& type, bool canBubble, bool cancelable, const String& statusMessage);
    55     WebGLContextEvent(const AtomicString&, const WebGLContextEventInit&);
     56    WebGLContextEvent(const AtomicString&, const Init&, IsTrusted);
    5657
    5758    String m_statusMessage;
  • trunk/Source/WebCore/html/canvas/WebGLContextEvent.idl

    r131172 r207238  
    2626[
    2727    Conditional=WEBGL,
    28     ConstructorTemplate=Event
     28    Constructor(DOMString type, optional WebGLContextEventInit eventInit),
    2929] interface WebGLContextEvent : Event {
    30     [InitializedByEventConstructor] readonly attribute DOMString statusMessage;
     30    readonly attribute DOMString statusMessage;
    3131};
    3232
     33dictionary WebGLContextEventInit : EventInit {
     34    DOMString statusMessage = "";
     35};
  • trunk/Source/WebCore/storage/StorageEvent.cpp

    r196400 r207238  
    5050}
    5151
    52 Ref<StorageEvent> StorageEvent::createForBindings(const AtomicString& type, const StorageEventInit& initializer)
     52Ref<StorageEvent> StorageEvent::create(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
    5353{
    54     return adoptRef(*new StorageEvent(type, initializer));
     54    return adoptRef(*new StorageEvent(type, initializer, isTrusted));
    5555}
    5656
     
    6565}
    6666
    67 StorageEvent::StorageEvent(const AtomicString& type, const StorageEventInit& initializer)
    68     : Event(type, initializer)
     67StorageEvent::StorageEvent(const AtomicString& type, const Init& initializer, IsTrusted isTrusted)
     68    : Event(type, initializer, isTrusted)
    6969    , m_key(initializer.key)
    7070    , m_oldValue(initializer.oldValue)
  • trunk/Source/WebCore/storage/StorageEvent.h

    r196400 r207238  
    3434class Storage;
    3535
    36 struct StorageEventInit : public EventInit {
    37     String key;
    38     String oldValue;
    39     String newValue;
    40     String url;
    41     RefPtr<Storage> storageArea;
    42 };
    43 
    4436class StorageEvent : public Event {
    4537public:
    4638    static Ref<StorageEvent> create(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
    4739    static Ref<StorageEvent> createForBindings();
    48     static Ref<StorageEvent> createForBindings(const AtomicString&, const StorageEventInit&);
     40
     41    struct Init : EventInit {
     42        String key;
     43        String oldValue;
     44        String newValue;
     45        String url;
     46        RefPtr<Storage> storageArea;
     47    };
     48
     49    static Ref<StorageEvent> create(const AtomicString&, const Init&, IsTrusted = IsTrusted::No);
    4950    virtual ~StorageEvent();
    5051
     
    6566    StorageEvent();
    6667    StorageEvent(const AtomicString& type, const String& key, const String& oldValue, const String& newValue, const String& url, Storage* storageArea);
    67     StorageEvent(const AtomicString&, const StorageEventInit&);
     68    StorageEvent(const AtomicString&, const Init&, IsTrusted);
    6869
    6970    String m_key;
  • trunk/Source/WebCore/storage/StorageEvent.idl

    r204215 r207238  
    2525
    2626[
    27     ConstructorTemplate=Event,
     27    Constructor(DOMString type, optional StorageEventInit eventInitDict)
    2828] interface StorageEvent : Event {
    29     [InitializedByEventConstructor] readonly attribute DOMString key;
    30     [InitializedByEventConstructor] readonly attribute DOMString? oldValue;
    31     [InitializedByEventConstructor] readonly attribute DOMString? newValue;
    32     [InitializedByEventConstructor] readonly attribute USVString url;
    33     [InitializedByEventConstructor] readonly attribute Storage storageArea;
     29    readonly attribute DOMString? key;
     30    readonly attribute DOMString? oldValue;
     31    readonly attribute DOMString? newValue;
     32    readonly attribute USVString url;
     33    readonly attribute Storage? storageArea;
    3434
    3535    // FIXME: Using "undefined" as default parameter value is wrong.
     
    4747};
    4848
     49dictionary StorageEventInit : EventInit {
     50    DOMString? key = null;
     51    DOMString? oldValue = null;
     52    DOMString? newValue = null;
     53    USVString url = "";
     54    Storage? storageArea = null;
     55};
Note: See TracChangeset for help on using the changeset viewer.