Bug 80513 - Speech JavaScript API: SpeechRecognitionEvent
Summary: Speech JavaScript API: SpeechRecognitionEvent
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: New Bugs (show other bugs)
Version: 528+ (Nightly build)
Hardware: Unspecified Unspecified
: P2 Normal
Assignee: Hans Wennborg
URL:
Keywords:
Depends on: 80424
Blocks:
  Show dependency treegraph
 
Reported: 2012-03-07 07:43 PST by Hans Wennborg
Modified: 2012-03-12 04:28 PDT (History)
7 users (show)

See Also:


Attachments
Patch (13.35 KB, patch)
2012-03-07 07:48 PST, Hans Wennborg
no flags Details | Formatted Diff | Diff
Patch (13.36 KB, patch)
2012-03-08 06:33 PST, Hans Wennborg
no flags Details | Formatted Diff | Diff
Patch (27.32 KB, patch)
2012-03-09 10:24 PST, Hans Wennborg
abarth: review+
abarth: commit-queue-
Details | Formatted Diff | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Hans Wennborg 2012-03-07 07:43:55 PST
Speech JavaScript API: SpeechRecognitionEvent
Comment 1 Hans Wennborg 2012-03-07 07:48:11 PST
Created attachment 130625 [details]
Patch
Comment 2 Hans Wennborg 2012-03-08 06:33:33 PST
Created attachment 130818 [details]
Patch

Rebase, const-qualify readonly attribute getters, return raw pointers.
Comment 3 Adam Barth 2012-03-08 14:16:03 PST
Comment on attachment 130818 [details]
Patch

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

> Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl:29
> +    interface [
> +        Conditional=SCRIPTED_SPEECH
> +    ] SpeechRecognitionEvent : Event {

Please use the ConstructorTemplate=Event and InitializedByEventConstructor:

https://trac.webkit.org/wiki/WebKitIDL#ConstructorTemplate

This will generate DOM4-style event constructors.
Comment 4 Adam Barth 2012-03-08 14:16:35 PST
+haraken because of ConstructorTemplate=Event
Comment 5 Adam Barth 2012-03-08 14:17:27 PST
Comment on attachment 130818 [details]
Patch

Once you have a DOM4-style event constructor, you can write tests that exercise this class.  Note: you should also be able to exercise it with document.createEvent.
Comment 6 Kentaro Hara 2012-03-08 15:43:40 PST
Comment on attachment 130818 [details]
Patch

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

>> Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl:29
>> +    ] SpeechRecognitionEvent : Event {
> 
> Please use the ConstructorTemplate=Event and InitializedByEventConstructor:
> 
> https://trac.webkit.org/wiki/WebKitIDL#ConstructorTemplate
> 
> This will generate DOM4-style event constructors.

And please add fast/events/constructors/speech-recognition-event-constructors.html for tests.
Comment 7 Hans Wennborg 2012-03-09 10:23:49 PST
(In reply to comment #6)
> (From update of attachment 130818 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=130818&action=review
> 

Thanks very much for the input!

> >> Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl:29
> >> +    ] SpeechRecognitionEvent : Event {
> > 
> > Please use the ConstructorTemplate=Event and InitializedByEventConstructor:
> > 
> > https://trac.webkit.org/wiki/WebKitIDL#ConstructorTemplate
> > 
> > This will generate DOM4-style event constructors.
Done.

> 
> And please add fast/events/constructors/speech-recognition-event-constructors.html for tests.
Done.

New patch coming up.
Comment 8 Hans Wennborg 2012-03-09 10:24:21 PST
Created attachment 131057 [details]
Patch
Comment 9 Adam Barth 2012-03-09 14:45:23 PST
Comment on attachment 131057 [details]
Patch

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

> Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp:32
> +

You've got an extra blank line here.

> Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp:70
> +void SpeechRecognitionEvent::initSpeechRecognitionEvent(const AtomicString& type, bool canBubble, bool cancelable, SpeechRecognitionResult* result, SpeechRecognitionError* error, short resultIndex, SpeechRecognitionResultList* resultHistory)

Oh, you can skip these init functions.  DOM4-style events don't need them because you can just construct the event directly.  We've been removing them from the platform.

> Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl:42
> +        void initSpeechRecognitionEvent(in [Optional=DefaultIsUndefined] DOMString typeArg,
> +                                        in [Optional=DefaultIsUndefined] boolean canBubbleArg,
> +                                        in [Optional=DefaultIsUndefined] boolean cancelableArg,
> +                                        in [Optional=DefaultIsUndefined] SpeechRecognitionResult resultArg,
> +                                        in [Optional=DefaultIsUndefined] SpeechRecognitionError errorArg,
> +                                        in [Optional=DefaultIsUndefined] short resultIndexArg,
> +                                        in [Optional=DefaultIsUndefined] SpeechRecognitionResultList resultHistoryArg);

We should skip this.  Sorry I didn't notice it in your previous patch.

> LayoutTests/fast/events/constructors/speech-recognition-event-constructor.html:30
> +// Test passing resultIndex in the initializer.
> +shouldBe("new webkitSpeechRecognitionEvent('eventType', { resultIndex: 42 }).resultIndex", "42");

I mean, you can also test the other properties, but maybe that's not worth while.
Comment 10 Hans Wennborg 2012-03-12 04:25:56 PDT
(In reply to comment #9)
> (From update of attachment 131057 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=131057&action=review

Thanks very much for the review!

> > Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp:32
> > +
> 
> You've got an extra blank line here.
Done.

> > Source/WebCore/Modules/speech/SpeechRecognitionEvent.cpp:70
> > +void SpeechRecognitionEvent::initSpeechRecognitionEvent(const AtomicString& type, bool canBubble, bool cancelable, SpeechRecognitionResult* result, SpeechRecognitionError* error, short resultIndex, SpeechRecognitionResultList* resultHistory)
> 
> Oh, you can skip these init functions.  DOM4-style events don't need them because you can just construct the event directly.  We've been removing them from the platform.
Done.

> > Source/WebCore/Modules/speech/SpeechRecognitionEvent.idl:42
> > +        void initSpeechRecognitionEvent(in [Optional=DefaultIsUndefined] DOMString typeArg,
> > +                                        in [Optional=DefaultIsUndefined] boolean canBubbleArg,
> > +                                        in [Optional=DefaultIsUndefined] boolean cancelableArg,
> > +                                        in [Optional=DefaultIsUndefined] SpeechRecognitionResult resultArg,
> > +                                        in [Optional=DefaultIsUndefined] SpeechRecognitionError errorArg,
> > +                                        in [Optional=DefaultIsUndefined] short resultIndexArg,
> > +                                        in [Optional=DefaultIsUndefined] SpeechRecognitionResultList resultHistoryArg);
> 
> We should skip this.  Sorry I didn't notice it in your previous patch.
Done.

It wasn't in the first patch. I copied it from StorageEvent.idl when adding ConstructorTemplate=Event, thinking maybe it was supposed to be there too. Thanks for clarifying.

> > LayoutTests/fast/events/constructors/speech-recognition-event-constructor.html:30
> > +// Test passing resultIndex in the initializer.
> > +shouldBe("new webkitSpeechRecognitionEvent('eventType', { resultIndex: 42 }).resultIndex", "42");
> 
> I mean, you can also test the other properties, but maybe that's not worth while.

The SpeechRecognitionResult, Error and ResultList don't have constructors, so there's no straightforward way of testing those properties :/ Maybe I should just add constructors for them.

Also realized I forgot to add this layout test to the Skipped files for the other ports. Doing that now.
Comment 11 Hans Wennborg 2012-03-12 04:28:24 PDT
Committed r110420: <http://trac.webkit.org/changeset/110420>