Bug 153903 - Rename *Event::create* which creates events for bindings to *Event::createForBindings* and cleanup corresponding paths
Summary: Rename *Event::create* which creates events for bindings to *Event::createFor...
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: UI Events (show other bugs)
Version: WebKit Nightly Build
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Jiewen Tan
URL:
Keywords: InRadar
Depends on:
Blocks: 76121
  Show dependency treegraph
 
Reported: 2016-02-04 17:13 PST by Jiewen Tan
Modified: 2016-02-10 17:01 PST (History)
8 users (show)

See Also:


Attachments
Patch (111.17 KB, patch)
2016-02-04 18:19 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Patch (111.13 KB, patch)
2016-02-04 18:38 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Archive of layout-test-results from ews101 for mac-yosemite (902.26 KB, application/zip)
2016-02-04 19:32 PST, Build Bot
no flags Details
Archive of layout-test-results from ews106 for mac-yosemite-wk2 (943.02 KB, application/zip)
2016-02-04 19:36 PST, Build Bot
no flags Details
Archive of layout-test-results from ews113 for mac-yosemite (817.93 KB, application/zip)
2016-02-04 19:41 PST, Build Bot
no flags Details
Patch (114.89 KB, patch)
2016-02-05 17:28 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Patch (114.89 KB, patch)
2016-02-05 17:46 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Patch (116.68 KB, patch)
2016-02-05 18:51 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Patch (119.94 KB, patch)
2016-02-08 10:28 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Patch (119.96 KB, patch)
2016-02-08 11:52 PST, Jiewen Tan
darin: review+
Details | Formatted Diff | Diff
Patch for committing (136.40 KB, patch)
2016-02-09 23:01 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff
Patch for committing v2 (147.23 KB, patch)
2016-02-10 14:25 PST, Jiewen Tan
no flags Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jiewen Tan 2016-02-04 17:13:00 PST
Rename Event::create(const AtomicString& type, const EventInit& initializer) to Event::createForBindings(const AtomicString& type, const EventInit& initializer) and for all the subclasses as well in order to support Event.isTrusted. Since this one is the DOM API, the isTrusted flag will be unset here using the Event(const AtomicString& type, const EventInit&) constructor in the following patch Bug 76121. Correspondingly, Event::create(const AtomicString& type, bool canBubble, bool cancelable) will set the isTrusted flag. From my inspection, some of the subclasses such as MediaKeyEvent* and UIEventWithKeyState* will use DOM API for C++ code path as well. Therefore, besides renaming, this patch will also cleanup the path. What's more, there is another Event::create() method. This one needs to be rename to Event::createForBindings() as well and a path cleanup. For legacy content, it is combined with Event::initEvent to create an event for bindings.
Comment 1 Jiewen Tan 2016-02-04 18:19:08 PST
Created attachment 270713 [details]
Patch
Comment 2 Radar WebKit Bug Importer 2016-02-04 18:33:41 PST
<rdar://problem/24518146>
Comment 3 Jiewen Tan 2016-02-04 18:38:28 PST
Created attachment 270714 [details]
Patch
Comment 4 WebKit Commit Bot 2016-02-04 18:40:26 PST
Attachment 270714 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/UIEventWithKeyState.h:72:  When wrapping a line, only indent 4 spaces.  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/UIEventWithKeyState.h:73:  Wrong number of spaces before statement. (expected: 28)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/UIEventWithKeyState.h:74:  Wrong number of spaces before statement. (expected: 28)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/UIEventWithKeyState.h:75:  Wrong number of spaces before statement. (expected: 28)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/UIEventWithKeyState.h:76:  Wrong number of spaces before statement. (expected: 28)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/UIEventWithKeyState.h:77:  Wrong number of spaces before statement. (expected: 28)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/UIEventWithKeyState.h:82:  When wrapping a line, only indent 4 spaces.  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/UIEventWithKeyState.h:83:  Wrong number of spaces before statement. (expected: 28)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/UIEventWithKeyState.h:84:  Wrong number of spaces before statement. (expected: 28)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/UIEventWithKeyState.h:85:  Wrong number of spaces before statement. (expected: 28)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/UIEventWithKeyState.h:86:  Wrong number of spaces before statement. (expected: 28)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/UIEventWithKeyState.h:87:  Wrong number of spaces before statement. (expected: 28)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:73:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:75:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:77:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:78:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:90:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:92:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:94:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:95:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:106:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:107:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:108:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:142:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:143:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:144:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:145:  Wrong number of spaces before statement. (expected: 27)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:145:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:146:  Wrong number of spaces before statement. (expected: 27)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:146:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:148:  Wrong number of spaces before statement. (expected: 27)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:148:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:151:  Wrong number of spaces before statement. (expected: 27)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:152:  Wrong number of spaces before statement. (expected: 27)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:153:  Wrong number of spaces before statement. (expected: 27)  [whitespace/indent] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:146:  When wrapping a line, only indent 4 spaces.  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:155:  When wrapping a line, only indent 4 spaces.  [whitespace/indent] [3]
Total errors found: 37 in 80 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 5 Build Bot 2016-02-04 19:32:22 PST
Comment on attachment 270714 [details]
Patch

Attachment 270714 [details] did not pass mac-ews (mac):
Output: http://webkit-queues.webkit.org/results/784196

New failing tests:
http/tests/eventsource/eventsource-parse-event-stream.html
http/tests/eventsource/eventsource-eof.html
Comment 6 Build Bot 2016-02-04 19:32:26 PST
Created attachment 270716 [details]
Archive of layout-test-results from ews101 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-ews.
Bot: ews101  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 7 Build Bot 2016-02-04 19:36:35 PST
Comment on attachment 270714 [details]
Patch

Attachment 270714 [details] did not pass mac-wk2-ews (mac-wk2):
Output: http://webkit-queues.webkit.org/results/784199

New failing tests:
http/tests/eventsource/eventsource-parse-event-stream.html
http/tests/eventsource/eventsource-eof.html
Comment 8 Build Bot 2016-02-04 19:36:39 PST
Created attachment 270717 [details]
Archive of layout-test-results from ews106 for mac-yosemite-wk2

The attached test failures were seen while running run-webkit-tests on the mac-wk2-ews.
Bot: ews106  Port: mac-yosemite-wk2  Platform: Mac OS X 10.10.5
Comment 9 Build Bot 2016-02-04 19:41:01 PST
Comment on attachment 270714 [details]
Patch

Attachment 270714 [details] did not pass mac-debug-ews (mac):
Output: http://webkit-queues.webkit.org/results/784204

New failing tests:
http/tests/eventsource/eventsource-parse-event-stream.html
http/tests/eventsource/eventsource-eof.html
Comment 10 Build Bot 2016-02-04 19:41:04 PST
Created attachment 270718 [details]
Archive of layout-test-results from ews113 for mac-yosemite

The attached test failures were seen while running run-webkit-tests on the mac-debug-ews.
Bot: ews113  Port: mac-yosemite  Platform: Mac OS X 10.10.5
Comment 11 Jiewen Tan 2016-02-05 17:28:26 PST
Created attachment 270782 [details]
Patch
Comment 12 WebKit Commit Bot 2016-02-05 17:31:00 PST
Attachment 270782 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/MouseEvent.cpp:73:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:75:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:77:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:78:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:90:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:92:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:94:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:95:  Weird number of spaces at line-start.  Are you using a 4-space indent?  [whitespace/indent] [3]
ERROR: Source/WebCore/dom/MouseEvent.cpp:139:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:140:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:142:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:140:  When wrapping a line, only indent 4 spaces.  [whitespace/indent] [3]
Total errors found: 12 in 82 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 13 Jiewen Tan 2016-02-05 17:46:53 PST
Created attachment 270783 [details]
Patch
Comment 14 WebKit Commit Bot 2016-02-05 17:47:51 PST
Attachment 270783 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/MouseEvent.cpp:135:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:137:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
Total errors found: 2 in 82 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 15 Jiewen Tan 2016-02-05 18:51:06 PST
Created attachment 270784 [details]
Patch
Comment 16 WebKit Commit Bot 2016-02-05 18:53:37 PST
Attachment 270784 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/MouseEvent.cpp:135:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:137:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
Total errors found: 2 in 82 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 17 Jiewen Tan 2016-02-08 10:28:15 PST
Created attachment 270862 [details]
Patch
Comment 18 Jiewen Tan 2016-02-08 11:52:50 PST
Created attachment 270873 [details]
Patch
Comment 19 WebKit Commit Bot 2016-02-08 11:55:42 PST
Attachment 270873 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/MouseEvent.cpp:135:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:137:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
Total errors found: 2 in 83 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 20 Jiewen Tan 2016-02-08 12:06:59 PST
File Bug 153999 to track the style checking issue.
Comment 21 Darin Adler 2016-02-08 13:24:51 PST
Comment on attachment 270873 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=270873&action=review

> Source/WebCore/Modules/encryptedmedia/MediaKeyMessageEvent.h:48
> +    static Ref<MediaKeyMessageEvent> create(const AtomicString& type, RefPtr<Uint8Array> message, const String& destinationURL)

The argument type here should not be RefPtr. If the caller is handing off ownership, then it should be Ref<Uint8Array>&& or RefPtr<Uint8Array>&&. If the caller is not handing off ownership, it should be Uint8Array& or Uint8Array*.

> Source/WebCore/Modules/encryptedmedia/MediaKeyMessageEvent.h:70
> +    MediaKeyMessageEvent(const AtomicString& type, RefPtr<Uint8Array> message, const String& destinationURL);

Ditto.

> Source/WebCore/Modules/encryptedmedia/MediaKeyNeededEvent.h:46
> +    static Ref<MediaKeyNeededEvent> create(const AtomicString& type, RefPtr<Uint8Array> initData)

Ditto.

> Source/WebCore/Modules/encryptedmedia/MediaKeyNeededEvent.h:67
> +    MediaKeyNeededEvent(const AtomicString& type, RefPtr<Uint8Array> initData);

Ditto.

> Source/WebCore/Modules/speech/SpeechSynthesisEvent.h:38
>      static Ref<SpeechSynthesisEvent> create(const AtomicString& type, unsigned long charIndex, float elapsedTime, const String& name);

Not new to this patch, but the type here is wrong. It should be "unsigned", not "unsigned long". This is a common error made when people are working with IDL, since the IDL syntax for this type *is* "unsigned long".

> Source/WebCore/bindings/objc/DOM.mm:521
> +    RefPtr<KeyboardEvent> key = KeyboardEvent::createForBindings();

Does not make sense to use createForBindings here.

> Source/WebCore/bindings/objc/DOM.mm:531
> +    RefPtr<KeyboardEvent> key = KeyboardEvent::createForBindings();

Ditto.

> Source/WebCore/dom/MouseEvent.cpp:39
> +    : clientX(0)
> +    , clientY(0)
> +    , button(0)

To avoid repeating these it’s better to initialize data members in the struct definition itself rather than in the constructors.

> Source/WebCore/dom/OverflowEvent.cpp:-41
>  OverflowEvent::OverflowEvent()
> -    : Event(eventNames().overflowchangedEvent, false, false)

Why is this change OK?

> Source/WebCore/html/HTMLMediaElement.cpp:2234
> +    RefPtr<Event> event = MediaKeyEvent::create(eventNames().webkitkeyaddedEvent, keySystem, sessionId, nullptr, nullptr, "", nullptr, 0);

Should use emptyString(), not "".

Return type should be Ref, not RefPtr.

> Source/WebCore/html/HTMLMediaElement.cpp:2263
> +    RefPtr<Event> event = MediaKeyEvent::create(eventNames().webkitkeyerrorEvent, keySystem, sessionId, nullptr, nullptr, "", MediaKeyError::create(mediaKeyErrorCode), systemCode);

Ditto.

> Source/WebCore/html/MediaKeyEvent.h:52
> +    static Ref<MediaKeyEvent> create(const AtomicString& type, const String& keySystem, const String& sessionId, RefPtr<Uint8Array> initData, RefPtr<Uint8Array> message, const String& defaultURL, RefPtr<MediaKeyError> errorCode, uint32_t systemCode)

Arguments should not be RefPtr. They should be RefPtr&& or Ref&& or a reference or a pointer.

> Source/WebCore/html/MediaKeyEvent.h:79
> +    MediaKeyEvent(const AtomicString& type, const String& keySystem, const String& sessionId, RefPtr<Uint8Array> initData, RefPtr<Uint8Array> message, const String& defaultURL, RefPtr<MediaKeyError> errorCode, uint32_t systemCode);

Ditto.

> Source/WebCore/html/track/TrackEvent.cpp:45
> +TrackEvent::TrackEvent(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<TrackBase> track)

Ditto.

> Source/WebCore/html/track/TrackEvent.h:46
> +    static Ref<TrackEvent> create(const AtomicString& type, bool canBubble, bool cancelable, RefPtr<TrackBase> track)

Ditto.

> Source/WebCore/page/EventSource.cpp:416
> +    Ref<MessageEvent> event = MessageEvent::create(m_eventName.isEmpty() ? eventNames().messageEvent : AtomicString(m_eventName), false, false, SerializedScriptValue::create(String::adopt(m_data)), m_eventStreamOrigin, m_lastEventId);
>      return event;

No need for the local variable. It was there before so we could call init. Please just use return directly.

> Source/WebCore/page/csp/ContentSecurityPolicy.cpp:1616
> +        RefPtr<ScriptCallStack> stack = createScriptCallStack(JSMainThreadExecState::currentState(), 2);

Should be Ref instead of RefPtr.
Comment 22 Jiewen Tan 2016-02-09 20:02:17 PST
Comment on attachment 270873 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=270873&action=review

>> Source/WebCore/bindings/objc/DOM.mm:521
>> +    RefPtr<KeyboardEvent> key = KeyboardEvent::createForBindings();
> 
> Does not make sense to use createForBindings here.

It looks like that this KeyboardEvent is never used.
I have examined all the paths that the event is passed to. None of them seems to use the event. Even if I could miss something, this event is useless without KeyboardEvent::initKeyboardEvent. There is no information inside it. Therefore, it could be another bug.

>> Source/WebCore/dom/OverflowEvent.cpp:-41
>> -    : Event(eventNames().overflowchangedEvent, false, false)
> 
> Why is this change OK?

Normally, the default constructor (default createForBindings method) is used with init*Event in order to create an event. Therefore, the event type and flags should be set by OverflowEvent::initOverflowEvent. Unfortunately, this class have done it completely wrong as OverflowEvent:: initOverflowEvent doesn't call the Event::initEvent to set the members. Instead, it relies on the constructor. I will double check if there is any other class which does the same thing.
Comment 23 Jiewen Tan 2016-02-09 21:26:54 PST
Comment on attachment 270873 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=270873&action=review

>>> Source/WebCore/bindings/objc/DOM.mm:521
>>> +    RefPtr<KeyboardEvent> key = KeyboardEvent::createForBindings();
>> 
>> Does not make sense to use createForBindings here.
> 
> It looks like that this KeyboardEvent is never used.
> I have examined all the paths that the event is passed to. None of them seems to use the event. Even if I could miss something, this event is useless without KeyboardEvent::initKeyboardEvent. There is no information inside it. Therefore, it could be another bug.

I don't have a good solution for it. First, there is already a default constructor which is for bindings. It is not possible to have another. However, I am not sure if we should fake one for it.
Comment 24 Jiewen Tan 2016-02-09 23:01:50 PST
Created attachment 270977 [details]
Patch for committing
Comment 25 WebKit Commit Bot 2016-02-09 23:02:57 PST
Attachment 270977 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/MouseEvent.cpp:119:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:121:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
Total errors found: 2 in 83 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 26 Darin Adler 2016-02-10 08:59:19 PST
Comment on attachment 270873 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=270873&action=review

>>>> Source/WebCore/bindings/objc/DOM.mm:521
>>>> +    RefPtr<KeyboardEvent> key = KeyboardEvent::createForBindings();
>>> 
>>> Does not make sense to use createForBindings here.
>> 
>> It looks like that this KeyboardEvent is never used.
>> I have examined all the paths that the event is passed to. None of them seems to use the event. Even if I could miss something, this event is useless without KeyboardEvent::initKeyboardEvent. There is no information inside it. Therefore, it could be another bug.
> 
> I don't have a good solution for it. First, there is already a default constructor which is for bindings. It is not possible to have another. However, I am not sure if we should fake one for it.

We can easily have two constructors that don’t need to take any arguments. We simply create a placeholder argument with a value that is ignored for the second constructor.

One of the many examples of this idiom in WebKit is the String(WTF::HashTableDeletedValueType) constructor.
Comment 27 Darin Adler 2016-02-10 09:01:07 PST
Comment on attachment 270873 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=270873&action=review

>>>>> Source/WebCore/bindings/objc/DOM.mm:521
>>>>> +    RefPtr<KeyboardEvent> key = KeyboardEvent::createForBindings();
>>>> 
>>>> Does not make sense to use createForBindings here.
>>> 
>>> It looks like that this KeyboardEvent is never used.
>>> I have examined all the paths that the event is passed to. None of them seems to use the event. Even if I could miss something, this event is useless without KeyboardEvent::initKeyboardEvent. There is no information inside it. Therefore, it could be another bug.
>> 
>> I don't have a good solution for it. First, there is already a default constructor which is for bindings. It is not possible to have another. However, I am not sure if we should fake one for it.
> 
> We can easily have two constructors that don’t need to take any arguments. We simply create a placeholder argument with a value that is ignored for the second constructor.
> 
> One of the many examples of this idiom in WebKit is the String(WTF::HashTableDeletedValueType) constructor.

I think the right thing to do here is to add a new function other than createForBindings that is called here. It could be called createDummyEvent or something like that. And you can have a comment about the fact that you’d like to return and delete that function. By giving it a special name you make it easy to search for callers, and make it unlikely that later programmers will be tempted to call it.

That’s better than using createForBindings here.
Comment 28 Jiewen Tan 2016-02-10 14:25:59 PST
Created attachment 271029 [details]
Patch for committing v2
Comment 29 WebKit Commit Bot 2016-02-10 14:27:07 PST
Attachment 271029 [details] did not pass style-queue:


ERROR: Source/WebCore/dom/MouseEvent.cpp:119:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
ERROR: Source/WebCore/dom/MouseEvent.cpp:121:  Comma should be at the beginning of the line in a member initialization list.  [whitespace/init] [4]
Total errors found: 2 in 75 files


If any of these errors are false positives, please file a bug against check-webkit-style.
Comment 30 Jiewen Tan 2016-02-10 16:03:13 PST
Committed r196400: <http://trac.webkit.org/changeset/196400>
Comment 31 Jiewen Tan 2016-02-10 16:09:54 PST
Bug 154094 is filed to keep tracking of Cleanup KeyboardEvent::createForDummy().
Comment 32 Jiewen Tan 2016-02-10 16:12:33 PST
Also, <rdar://problem/24596445> is filed to cleanup GestureEvent and TouchEvent in the Internal repository.
Comment 33 Ryan Haddad 2016-02-10 17:01:59 PST
Fixed bindings test failure after this change with <https://trac.webkit.org/r196407>