Changeset 291124 in webkit


Ignore:
Timestamp:
Mar 10, 2022 12:15:28 PM (4 months ago)
Author:
Chris Fleizach
Message:

AX: Support updated WebSpeech API
https://bugs.webkit.org/show_bug.cgi?id=237614
<rdar://problem/89981851>

Reviewed by Andres Gonzalez.

LayoutTests/imported/w3c:

  • web-platform-tests/speech-api/SpeechSynthesisErrorEvent-constructor-expected.txt:
  • web-platform-tests/speech-api/SpeechSynthesisEvent-constructor-expected.txt:
  • web-platform-tests/speech-api/idlharness.window-expected.txt:

Source/WebCore:

Adopt WebSpeech (18 August 2020) changes from
https://wicg.github.io/speech-api/

Tests Fixed:

imported/w3c/web-platform-tests/speech-api/

  • DerivedSources-input.xcfilelist:
  • DerivedSources-output.xcfilelist:
  • DerivedSources.make:
  • Modules/speech/DOMWindow+SpeechSynthesis.idl:
  • Modules/speech/DOMWindowSpeechSynthesis.cpp:

(WebCore::DOMWindowSpeechSynthesis::speechSynthesis):

  • Modules/speech/SpeechSynthesis.cpp:

(WebCore::Ref<SpeechSynthesis>SpeechSynthesis::create):
(WebCore::SpeechSynthesis::SpeechSynthesis):
(WebCore::SpeechSynthesis::voicesDidChange):
(WebCore::SpeechSynthesis::fireEvent const):
(WebCore::SpeechSynthesis::fireErrorEvent const):
(WebCore::SpeechSynthesis::handleSpeakingCompleted):
(WebCore::SpeechSynthesis::boundaryEventOccurred):
(WebCore::SpeechSynthesis::didStartSpeaking):
(WebCore::SpeechSynthesis::didPauseSpeaking):
(WebCore::SpeechSynthesis::didResumeSpeaking):
(WebCore::SpeechSynthesis::create): Deleted.
(WebCore::SpeechSynthesis::fireEvent): Deleted.

  • Modules/speech/SpeechSynthesis.h:
  • Modules/speech/SpeechSynthesis.idl:
  • Modules/speech/SpeechSynthesisErrorCode.h: Added.
  • Modules/speech/SpeechSynthesisErrorCode.idl: Copied from Source/WebCore/Modules/speech/DOMWindow+SpeechSynthesis.idl.
  • Modules/speech/SpeechSynthesisErrorEvent.cpp: Copied from Source/WebCore/Modules/speech/SpeechSynthesisEvent.cpp.

(WebCore::SpeechSynthesisErrorEvent::create):
(WebCore::SpeechSynthesisErrorEvent::SpeechSynthesisErrorEvent):

  • Modules/speech/SpeechSynthesisErrorEvent.h: Copied from Source/WebCore/Modules/speech/SpeechSynthesisEvent.h.
  • Modules/speech/SpeechSynthesisErrorEvent.idl: Copied from Source/WebCore/Modules/speech/SpeechSynthesisEvent.idl.
  • Modules/speech/SpeechSynthesisErrorEventInit.h: Copied from Source/WebCore/Modules/speech/DOMWindow+SpeechSynthesis.idl.
  • Modules/speech/SpeechSynthesisErrorEventInit.idl: Copied from Source/WebCore/Modules/speech/DOMWindow+SpeechSynthesis.idl.
  • Modules/speech/SpeechSynthesisEvent.cpp:

(WebCore::SpeechSynthesisEvent::create):
(WebCore::SpeechSynthesisEvent::SpeechSynthesisEvent):

  • Modules/speech/SpeechSynthesisEvent.h:

(WebCore::SpeechSynthesisEvent::utterance const):
(WebCore::SpeechSynthesisEvent::charLength const):
(): Deleted.

  • Modules/speech/SpeechSynthesisEvent.idl:
  • Modules/speech/SpeechSynthesisEventInit.h: Copied from Source/WebCore/Modules/speech/SpeechSynthesisEvent.h.

(WebCore::SpeechSynthesisEventInit::SpeechSynthesisEventInit):

  • Modules/speech/SpeechSynthesisEventInit.idl: Copied from Source/WebCore/Modules/speech/DOMWindow+SpeechSynthesis.idl.
  • Modules/speech/SpeechSynthesisUtterance.cpp:

(WebCore::SpeechSynthesisUtterance::SpeechSynthesisUtterance):

  • Modules/speech/SpeechSynthesisUtterance.h:
  • Modules/speech/SpeechSynthesisVoice.idl:
  • Sources.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/EventNames.h:
  • dom/EventNames.in:
  • dom/EventTargetFactory.in:
  • page/SpeechSynthesisClient.h:
  • platform/PlatformSpeechSynthesizer.h:
  • platform/cocoa/PlatformSpeechSynthesizerCocoa.mm:

(-[WebSpeechSynthesisWrapper speechSynthesizer:willSpeakRangeOfSpeechString:utterance:]):
(WebCore::PlatformSpeechSynthesizer::initializeVoiceList):

  • platform/mock/PlatformSpeechSynthesizerMock.cpp:

(WebCore::PlatformSpeechSynthesizerMock::speak):

Source/WebKit:

  • UIProcess/Cocoa/WebPageProxyCocoa.mm:

(WebKit::WebPageProxy::boundaryEventOccurred):

  • UIProcess/WebPageProxy.h:
  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::boundaryEventOccurred):

  • WebProcess/WebPage/WebPage.h:
  • WebProcess/WebPage/WebPage.messages.in:

LayoutTests:

Fixed expectations:

  • imported/w3c/web-platform-tests/speech-api/SpeechSynthesisEvent-constructor-expected.txt: Updated.
  • imported/w3c/web-platform-tests/speech-api/SpeechSynthesisErrorEvent-constructor-expected.txt: Updated.
  • fast/speechsynthesis/speech-synthesis-boundary-events.html: Updated.
  • fast/speechsynthesis/speech-synthesis-boundary-events-expected.txt: Updated.
Location:
trunk
Files:
1 added
39 edited
8 copied

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r291119 r291124  
     12022-03-10  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Support updated WebSpeech API
     4        https://bugs.webkit.org/show_bug.cgi?id=237614
     5        <rdar://problem/89981851>
     6
     7        Reviewed by Andres Gonzalez.
     8
     9        Fixed expectations:
     10        * imported/w3c/web-platform-tests/speech-api/SpeechSynthesisEvent-constructor-expected.txt: Updated.
     11        * imported/w3c/web-platform-tests/speech-api/SpeechSynthesisErrorEvent-constructor-expected.txt: Updated.
     12        * fast/speechsynthesis/speech-synthesis-boundary-events.html: Updated.
     13        * fast/speechsynthesis/speech-synthesis-boundary-events-expected.txt: Updated.
     14
    1152022-03-10  Antoine Quint  <graouts@webkit.org>
    216
  • trunk/LayoutTests/fast/speechsynthesis/speech-synthesis-boundary-events-expected.txt

    r173000 r291124  
    55
    66Speech started
    7 Boundary event: word, Character index: 0
    8 Boundary event: sentence, Character index: 14
     7Boundary event: word, Character index: 0, length: 3
     8Boundary event: sentence, Character index: 0, length: 14
    99PASS successfullyParsed is true
    1010
  • trunk/LayoutTests/fast/speechsynthesis/speech-synthesis-boundary-events.html

    r173000 r291124  
    2626
    2727    u.onboundary = function(event) {
    28        debug("Boundary event: " + event.name + ", Character index: " + event.charIndex);
     28       debug(`Boundary event: ${event.name}, Character index: ${event.charIndex}, length: ${event.charLength}`);
    2929    }
    3030
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r291122 r291124  
     12022-03-10  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Support updated WebSpeech API
     4        https://bugs.webkit.org/show_bug.cgi?id=237614
     5        <rdar://problem/89981851>
     6
     7        Reviewed by Andres Gonzalez.
     8
     9        * web-platform-tests/speech-api/SpeechSynthesisErrorEvent-constructor-expected.txt:
     10        * web-platform-tests/speech-api/SpeechSynthesisEvent-constructor-expected.txt:
     11        * web-platform-tests/speech-api/idlharness.window-expected.txt:
     12
    1132022-03-10  Antoine Quint  <graouts@webkit.org>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/speech-api/SpeechSynthesisErrorEvent-constructor-expected.txt

    r279400 r291124  
    11
    2 FAIL SpeechSynthesisErrorEvent with no arguments throws TypeError assert_throws_js: function "() => {
    3     new SpeechSynthesisErrorEvent();
    4   }" threw object "ReferenceError: Can't find variable: SpeechSynthesisErrorEvent" ("ReferenceError") expected instance of function "function TypeError() {
    5     [native code]
    6 }" ("TypeError")
    7 FAIL SpeechSynthesisErrorEvent with no eventInitDict throws TypeError assert_throws_js: function "() => {
    8     new SpeechSynthesisErrorEvent("type");
    9   }" threw object "ReferenceError: Can't find variable: SpeechSynthesisErrorEvent" ("ReferenceError") expected instance of function "function TypeError() {
    10     [native code]
    11 }" ("TypeError")
    12 FAIL SpeechSynthesisErrorEvent with empty eventInitDict throws TypeError (requires
    13     utterance and error) assert_throws_js: function "() => {
    14     new SpeechSynthesisErrorEvent("type", {});
    15   }" threw object "ReferenceError: Can't find variable: SpeechSynthesisErrorEvent" ("ReferenceError") expected instance of function "function TypeError() {
    16     [native code]
    17 }" ("TypeError")
    18 FAIL SpeechSynthesisErrorEvent with eventInitDict without utterance throws
    19     TypeError assert_throws_js: function "() => {
    20     new SpeechSynthesisErrorEvent("type", {error:"not-allowed"});
    21   }" threw object "ReferenceError: Can't find variable: SpeechSynthesisErrorEvent" ("ReferenceError") expected instance of function "function TypeError() {
    22     [native code]
    23 }" ("TypeError")
    24 FAIL SpeechSynthesisErrorEvent with eventInitDict without error throws
    25     TypeError assert_throws_js: function "() => {
    26     new SpeechSynthesisErrorEvent("type", {utterance: new SpeechSynthesisUtterance()});
    27   }" threw object "ReferenceError: Can't find variable: SpeechSynthesisErrorEvent" ("ReferenceError") expected instance of function "function TypeError() {
    28     [native code]
    29 }" ("TypeError")
    30 FAIL SpeechSynthesisErrorEvent with eventInitDict having utterance and error Can't find variable: SpeechSynthesisErrorEvent
    31 FAIL SpeechSynthesisErrorEvent with custom eventInitDict Can't find variable: SpeechSynthesisErrorEvent
    32 FAIL SpeechSynthesisErrorEvent with wrong error enum assert_throws_js: function "() => {
    33       new SpeechSynthesisErrorEvent("type", {
    34         utterance: new SpeechSynthesisUtterance(),
    35         error: error
    36       });
    37     }" threw object "ReferenceError: Can't find variable: SpeechSynthesisErrorEvent" ("ReferenceError") expected instance of function "function TypeError() {
    38     [native code]
    39 }" ("TypeError")
     2PASS SpeechSynthesisErrorEvent with no arguments throws TypeError
     3PASS SpeechSynthesisErrorEvent with no eventInitDict throws TypeError
     4PASS SpeechSynthesisErrorEvent with empty eventInitDict throws TypeError (requires
     5    utterance and error)
     6PASS SpeechSynthesisErrorEvent with eventInitDict without utterance throws
     7    TypeError
     8PASS SpeechSynthesisErrorEvent with eventInitDict without error throws
     9    TypeError
     10PASS SpeechSynthesisErrorEvent with eventInitDict having utterance and error
     11PASS SpeechSynthesisErrorEvent with custom eventInitDict
     12PASS SpeechSynthesisErrorEvent with wrong error enum
    4013
  • trunk/LayoutTests/imported/w3c/web-platform-tests/speech-api/SpeechSynthesisEvent-constructor-expected.txt

    r279400 r291124  
    66PASS SpeechSynthesisEvent with eventInitDict not having utterance throws
    77    TypeError
    8 FAIL SpeechSynthesisEvent with eventInitDict having an utterance Illegal constructor
    9 FAIL SpeechSynthesisEvent with custom eventInitDict Illegal constructor
     8PASS SpeechSynthesisEvent with eventInitDict having an utterance
     9PASS SpeechSynthesisEvent with custom eventInitDict
    1010
  • trunk/LayoutTests/imported/w3c/web-platform-tests/speech-api/idlharness.window-expected.txt

    r270868 r291124  
    130130FAIL SpeechGrammarList interface: new SpeechGrammarList() must inherit property "addFromString(DOMString, optional float)" with the proper type assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: SpeechGrammarList"
    131131FAIL SpeechGrammarList interface: calling addFromString(DOMString, optional float) on new SpeechGrammarList() with too few arguments must throw TypeError assert_equals: Unexpected exception when evaluating object expected null but got object "ReferenceError: Can't find variable: SpeechGrammarList"
    132 FAIL SpeechSynthesis interface: existence and properties of interface object assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    133 FAIL SpeechSynthesis interface object length assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    134 FAIL SpeechSynthesis interface object name assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    135 FAIL SpeechSynthesis interface: existence and properties of interface prototype object assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    136 FAIL SpeechSynthesis interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    137 FAIL SpeechSynthesis interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    138 FAIL SpeechSynthesis interface: attribute pending assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    139 FAIL SpeechSynthesis interface: attribute speaking assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    140 FAIL SpeechSynthesis interface: attribute paused assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    141 FAIL SpeechSynthesis interface: attribute onvoiceschanged assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    142 FAIL SpeechSynthesis interface: operation speak(SpeechSynthesisUtterance) assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    143 FAIL SpeechSynthesis interface: operation cancel() assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    144 FAIL SpeechSynthesis interface: operation pause() assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    145 FAIL SpeechSynthesis interface: operation resume() assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    146 FAIL SpeechSynthesis interface: operation getVoices() assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
    147 FAIL SpeechSynthesis must be primary interface of speechSynthesis assert_own_property: self does not have own property "SpeechSynthesis" expected property "SpeechSynthesis" missing
     132PASS SpeechSynthesis interface: existence and properties of interface object
     133PASS SpeechSynthesis interface object length
     134PASS SpeechSynthesis interface object name
     135PASS SpeechSynthesis interface: existence and properties of interface prototype object
     136PASS SpeechSynthesis interface: existence and properties of interface prototype object's "constructor" property
     137PASS SpeechSynthesis interface: existence and properties of interface prototype object's @@unscopables property
     138PASS SpeechSynthesis interface: attribute pending
     139PASS SpeechSynthesis interface: attribute speaking
     140PASS SpeechSynthesis interface: attribute paused
     141PASS SpeechSynthesis interface: attribute onvoiceschanged
     142PASS SpeechSynthesis interface: operation speak(SpeechSynthesisUtterance)
     143PASS SpeechSynthesis interface: operation cancel()
     144PASS SpeechSynthesis interface: operation pause()
     145PASS SpeechSynthesis interface: operation resume()
     146PASS SpeechSynthesis interface: operation getVoices()
     147PASS SpeechSynthesis must be primary interface of speechSynthesis
    148148PASS Stringification of speechSynthesis
    149149PASS SpeechSynthesis interface: speechSynthesis must inherit property "pending" with the proper type
    150150PASS SpeechSynthesis interface: speechSynthesis must inherit property "speaking" with the proper type
    151151PASS SpeechSynthesis interface: speechSynthesis must inherit property "paused" with the proper type
    152 FAIL SpeechSynthesis interface: speechSynthesis must inherit property "onvoiceschanged" with the proper type assert_inherits: property "onvoiceschanged" not found in prototype chain
     152PASS SpeechSynthesis interface: speechSynthesis must inherit property "onvoiceschanged" with the proper type
    153153PASS SpeechSynthesis interface: speechSynthesis must inherit property "speak(SpeechSynthesisUtterance)" with the proper type
    154154PASS SpeechSynthesis interface: calling speak(SpeechSynthesisUtterance) on speechSynthesis with too few arguments must throw TypeError
     
    192192PASS SpeechSynthesisUtterance interface: new SpeechSynthesisUtterance() must inherit property "onboundary" with the proper type
    193193PASS SpeechSynthesisEvent interface: existence and properties of interface object
    194 FAIL SpeechSynthesisEvent interface object length assert_equals: wrong value for SpeechSynthesisEvent.length expected 2 but got 0
     194PASS SpeechSynthesisEvent interface object length
    195195PASS SpeechSynthesisEvent interface object name
    196196PASS SpeechSynthesisEvent interface: existence and properties of interface prototype object
    197197PASS SpeechSynthesisEvent interface: existence and properties of interface prototype object's "constructor" property
    198198PASS SpeechSynthesisEvent interface: existence and properties of interface prototype object's @@unscopables property
    199 FAIL SpeechSynthesisEvent interface: attribute utterance assert_true: The prototype object must have a property "utterance" expected true got false
     199PASS SpeechSynthesisEvent interface: attribute utterance
    200200PASS SpeechSynthesisEvent interface: attribute charIndex
    201 FAIL SpeechSynthesisEvent interface: attribute charLength assert_true: The prototype object must have a property "charLength" expected true got false
     201PASS SpeechSynthesisEvent interface: attribute charLength
    202202PASS SpeechSynthesisEvent interface: attribute elapsedTime
    203203PASS SpeechSynthesisEvent interface: attribute name
    204 FAIL SpeechSynthesisErrorEvent interface: existence and properties of interface object assert_own_property: self does not have own property "SpeechSynthesisErrorEvent" expected property "SpeechSynthesisErrorEvent" missing
    205 FAIL SpeechSynthesisErrorEvent interface object length assert_own_property: self does not have own property "SpeechSynthesisErrorEvent" expected property "SpeechSynthesisErrorEvent" missing
    206 FAIL SpeechSynthesisErrorEvent interface object name assert_own_property: self does not have own property "SpeechSynthesisErrorEvent" expected property "SpeechSynthesisErrorEvent" missing
    207 FAIL SpeechSynthesisErrorEvent interface: existence and properties of interface prototype object assert_own_property: self does not have own property "SpeechSynthesisErrorEvent" expected property "SpeechSynthesisErrorEvent" missing
    208 FAIL SpeechSynthesisErrorEvent interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "SpeechSynthesisErrorEvent" expected property "SpeechSynthesisErrorEvent" missing
    209 FAIL SpeechSynthesisErrorEvent interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "SpeechSynthesisErrorEvent" expected property "SpeechSynthesisErrorEvent" missing
    210 FAIL SpeechSynthesisErrorEvent interface: attribute error assert_own_property: self does not have own property "SpeechSynthesisErrorEvent" expected property "SpeechSynthesisErrorEvent" missing
    211 FAIL SpeechSynthesisVoice interface: existence and properties of interface object assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
    212 FAIL SpeechSynthesisVoice interface object length assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
    213 FAIL SpeechSynthesisVoice interface object name assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
    214 FAIL SpeechSynthesisVoice interface: existence and properties of interface prototype object assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
    215 FAIL SpeechSynthesisVoice interface: existence and properties of interface prototype object's "constructor" property assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
    216 FAIL SpeechSynthesisVoice interface: existence and properties of interface prototype object's @@unscopables property assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
    217 FAIL SpeechSynthesisVoice interface: attribute voiceURI assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
    218 FAIL SpeechSynthesisVoice interface: attribute name assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
    219 FAIL SpeechSynthesisVoice interface: attribute lang assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
    220 FAIL SpeechSynthesisVoice interface: attribute localService assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
    221 FAIL SpeechSynthesisVoice interface: attribute default assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
    222 FAIL SpeechSynthesisVoice must be primary interface of voice assert_own_property: self does not have own property "SpeechSynthesisVoice" expected property "SpeechSynthesisVoice" missing
     204PASS SpeechSynthesisErrorEvent interface: existence and properties of interface object
     205PASS SpeechSynthesisErrorEvent interface object length
     206PASS SpeechSynthesisErrorEvent interface object name
     207PASS SpeechSynthesisErrorEvent interface: existence and properties of interface prototype object
     208PASS SpeechSynthesisErrorEvent interface: existence and properties of interface prototype object's "constructor" property
     209PASS SpeechSynthesisErrorEvent interface: existence and properties of interface prototype object's @@unscopables property
     210PASS SpeechSynthesisErrorEvent interface: attribute error
     211PASS SpeechSynthesisVoice interface: existence and properties of interface object
     212PASS SpeechSynthesisVoice interface object length
     213PASS SpeechSynthesisVoice interface object name
     214PASS SpeechSynthesisVoice interface: existence and properties of interface prototype object
     215PASS SpeechSynthesisVoice interface: existence and properties of interface prototype object's "constructor" property
     216PASS SpeechSynthesisVoice interface: existence and properties of interface prototype object's @@unscopables property
     217PASS SpeechSynthesisVoice interface: attribute voiceURI
     218PASS SpeechSynthesisVoice interface: attribute name
     219PASS SpeechSynthesisVoice interface: attribute lang
     220PASS SpeechSynthesisVoice interface: attribute localService
     221PASS SpeechSynthesisVoice interface: attribute default
     222PASS SpeechSynthesisVoice must be primary interface of voice
    223223PASS Stringification of voice
    224224PASS SpeechSynthesisVoice interface: voice must inherit property "voiceURI" with the proper type
  • trunk/Source/WebCore/ChangeLog

    r291123 r291124  
     12022-03-10  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Support updated WebSpeech API
     4        https://bugs.webkit.org/show_bug.cgi?id=237614
     5        <rdar://problem/89981851>
     6
     7        Reviewed by Andres Gonzalez.
     8
     9        Adopt WebSpeech (18 August 2020) changes from
     10        https://wicg.github.io/speech-api/
     11
     12        Tests Fixed:
     13           imported/w3c/web-platform-tests/speech-api/
     14
     15        * DerivedSources-input.xcfilelist:
     16        * DerivedSources-output.xcfilelist:
     17        * DerivedSources.make:
     18        * Modules/speech/DOMWindow+SpeechSynthesis.idl:
     19        * Modules/speech/DOMWindowSpeechSynthesis.cpp:
     20        (WebCore::DOMWindowSpeechSynthesis::speechSynthesis):
     21        * Modules/speech/SpeechSynthesis.cpp:
     22        (WebCore::Ref<SpeechSynthesis>SpeechSynthesis::create):
     23        (WebCore::SpeechSynthesis::SpeechSynthesis):
     24        (WebCore::SpeechSynthesis::voicesDidChange):
     25        (WebCore::SpeechSynthesis::fireEvent const):
     26        (WebCore::SpeechSynthesis::fireErrorEvent const):
     27        (WebCore::SpeechSynthesis::handleSpeakingCompleted):
     28        (WebCore::SpeechSynthesis::boundaryEventOccurred):
     29        (WebCore::SpeechSynthesis::didStartSpeaking):
     30        (WebCore::SpeechSynthesis::didPauseSpeaking):
     31        (WebCore::SpeechSynthesis::didResumeSpeaking):
     32        (WebCore::SpeechSynthesis::create): Deleted.
     33        (WebCore::SpeechSynthesis::fireEvent): Deleted.
     34        * Modules/speech/SpeechSynthesis.h:
     35        * Modules/speech/SpeechSynthesis.idl:
     36        * Modules/speech/SpeechSynthesisErrorCode.h: Added.
     37        * Modules/speech/SpeechSynthesisErrorCode.idl: Copied from Source/WebCore/Modules/speech/DOMWindow+SpeechSynthesis.idl.
     38        * Modules/speech/SpeechSynthesisErrorEvent.cpp: Copied from Source/WebCore/Modules/speech/SpeechSynthesisEvent.cpp.
     39        (WebCore::SpeechSynthesisErrorEvent::create):
     40        (WebCore::SpeechSynthesisErrorEvent::SpeechSynthesisErrorEvent):
     41        * Modules/speech/SpeechSynthesisErrorEvent.h: Copied from Source/WebCore/Modules/speech/SpeechSynthesisEvent.h.
     42        * Modules/speech/SpeechSynthesisErrorEvent.idl: Copied from Source/WebCore/Modules/speech/SpeechSynthesisEvent.idl.
     43        * Modules/speech/SpeechSynthesisErrorEventInit.h: Copied from Source/WebCore/Modules/speech/DOMWindow+SpeechSynthesis.idl.
     44        * Modules/speech/SpeechSynthesisErrorEventInit.idl: Copied from Source/WebCore/Modules/speech/DOMWindow+SpeechSynthesis.idl.
     45        * Modules/speech/SpeechSynthesisEvent.cpp:
     46        (WebCore::SpeechSynthesisEvent::create):
     47        (WebCore::SpeechSynthesisEvent::SpeechSynthesisEvent):
     48        * Modules/speech/SpeechSynthesisEvent.h:
     49        (WebCore::SpeechSynthesisEvent::utterance const):
     50        (WebCore::SpeechSynthesisEvent::charLength const):
     51        (): Deleted.
     52        * Modules/speech/SpeechSynthesisEvent.idl:
     53        * Modules/speech/SpeechSynthesisEventInit.h: Copied from Source/WebCore/Modules/speech/SpeechSynthesisEvent.h.
     54        (WebCore::SpeechSynthesisEventInit::SpeechSynthesisEventInit):
     55        * Modules/speech/SpeechSynthesisEventInit.idl: Copied from Source/WebCore/Modules/speech/DOMWindow+SpeechSynthesis.idl.
     56        * Modules/speech/SpeechSynthesisUtterance.cpp:
     57        (WebCore::SpeechSynthesisUtterance::SpeechSynthesisUtterance):
     58        * Modules/speech/SpeechSynthesisUtterance.h:
     59        * Modules/speech/SpeechSynthesisVoice.idl:
     60        * Sources.txt:
     61        * WebCore.xcodeproj/project.pbxproj:
     62        * dom/EventNames.h:
     63        * dom/EventNames.in:
     64        * dom/EventTargetFactory.in:
     65        * page/SpeechSynthesisClient.h:
     66        * platform/PlatformSpeechSynthesizer.h:
     67        * platform/cocoa/PlatformSpeechSynthesizerCocoa.mm:
     68        (-[WebSpeechSynthesisWrapper speechSynthesizer:willSpeakRangeOfSpeechString:utterance:]):
     69        (WebCore::PlatformSpeechSynthesizer::initializeVoiceList):
     70        * platform/mock/PlatformSpeechSynthesizerMock.cpp:
     71        (WebCore::PlatformSpeechSynthesizerMock::speak):
     72
    1732022-03-10  Chris Dumez  <cdumez@apple.com>
    274
  • trunk/Source/WebCore/DerivedSources-input.xcfilelist

    r289978 r291124  
    609609$(PROJECT_DIR)/Modules/speech/SpeechRecognitionResultList.idl
    610610$(PROJECT_DIR)/Modules/speech/SpeechSynthesis.idl
     611$(PROJECT_DIR)/Modules/speech/SpeechSynthesisErrorCode.idl
     612$(PROJECT_DIR)/Modules/speech/SpeechSynthesisErrorEvent.idl
     613$(PROJECT_DIR)/Modules/speech/SpeechSynthesisErrorEventInit.idl
    611614$(PROJECT_DIR)/Modules/speech/SpeechSynthesisEvent.idl
     615$(PROJECT_DIR)/Modules/speech/SpeechSynthesisEventInit.idl
    612616$(PROJECT_DIR)/Modules/speech/SpeechSynthesisUtterance.idl
    613617$(PROJECT_DIR)/Modules/speech/SpeechSynthesisVoice.idl
  • trunk/Source/WebCore/DerivedSources-output.xcfilelist

    r290129 r291124  
    25172517$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesis.cpp
    25182518$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesis.h
     2519$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisErrorCode.cpp
     2520$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisErrorCode.h
     2521$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisErrorEvent.cpp
     2522$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisErrorEvent.h
     2523$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisErrorEventInit.cpp
     2524$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisErrorEventInit.h
    25192525$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisEvent.cpp
    25202526$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisEvent.h
     2527$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisEventInit.cpp
     2528$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisEventInit.h
    25212529$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisUtterance.cpp
    25222530$(BUILT_PRODUCTS_DIR)/DerivedSources/WebCore/JSSpeechSynthesisUtterance.h
  • trunk/Source/WebCore/DerivedSources.make

    r290129 r291124  
    522522    $(WebCore)/Modules/speech/DOMWindow+SpeechSynthesis.idl \
    523523    $(WebCore)/Modules/speech/SpeechSynthesis.idl \
     524    $(WebCore)/Modules/speech/SpeechSynthesisErrorCode.idl \
     525    $(WebCore)/Modules/speech/SpeechSynthesisErrorEvent.idl \
     526    $(WebCore)/Modules/speech/SpeechSynthesisErrorEventInit.idl \
    524527    $(WebCore)/Modules/speech/SpeechSynthesisEvent.idl \
     528    $(WebCore)/Modules/speech/SpeechSynthesisEventInit.idl \
    525529    $(WebCore)/Modules/speech/SpeechSynthesisUtterance.idl \
    526530    $(WebCore)/Modules/speech/SpeechSynthesisVoice.idl \
  • trunk/Source/WebCore/Modules/credentialmanagement/BasicCredential.h

    r290184 r291124  
    2828#if ENABLE(WEB_AUTHN)
    2929
     30#include "Document.h"
     31#include "IDLTypes.h"
     32#include "JSDOMPromiseDeferred.h"
    3033#include <wtf/RefCounted.h>
    3134#include <wtf/TypeCasts.h>
  • trunk/Source/WebCore/Modules/speech/DOMWindow+SpeechSynthesis.idl

    r267449 r291124  
    2828    ImplementedBy=DOMWindowSpeechSynthesis
    2929] partial interface DOMWindow {
    30     readonly attribute SpeechSynthesis speechSynthesis;
     30    [SameObject] readonly attribute SpeechSynthesis speechSynthesis;
    3131};
  • trunk/Source/WebCore/Modules/speech/DOMWindowSpeechSynthesis.cpp

    r284057 r291124  
    7272{
    7373    if (!m_speechSynthesis && frame() && frame()->document())
    74         m_speechSynthesis = SpeechSynthesis::create(frame()->page()->speechSynthesisClient(), *frame()->document());
     74        m_speechSynthesis = SpeechSynthesis::create(*frame()->document());
    7575    return m_speechSynthesis.get();
    7676}
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp

    r290329 r291124  
    2929#if ENABLE(SPEECH_SYNTHESIS)
    3030
     31#include "Document.h"
    3132#include "EventNames.h"
     33#include "Frame.h"
     34#include "Page.h"
    3235#include "PlatformSpeechSynthesisVoice.h"
    3336#include "PlatformSpeechSynthesizer.h"
     37#include "SpeechSynthesisErrorEvent.h"
    3438#include "SpeechSynthesisEvent.h"
    3539#include "SpeechSynthesisUtterance.h"
    3640#include "UserGestureIndicator.h"
     41#include <wtf/IsoMallocInlines.h>
    3742#include <wtf/NeverDestroyed.h>
    3843
     44namespace WebCore {
     45
     46WTF_MAKE_ISO_ALLOCATED_IMPL(SpeechSynthesis);
     47
     48Ref<SpeechSynthesis>SpeechSynthesis::create(ScriptExecutionContext& context)
     49{
     50    return adoptRef(*new SpeechSynthesis(context));
     51}
     52
     53SpeechSynthesis::SpeechSynthesis(ScriptExecutionContext& context)
     54    : ContextDestructionObserver(&context)
     55    , m_currentSpeechUtterance(nullptr)
     56    , m_isPaused(false)
     57    , m_restrictions(NoRestrictions)
     58    , m_speechSynthesisClient(nullptr)
     59{
     60    if (context.isDocument()) {
    3961#if PLATFORM(IOS_FAMILY)
    40 #include "Document.h"
     62        if (downcast<Document>(context).audioPlaybackRequiresUserGesture())
     63            m_restrictions = RequireUserGestureForSpeechStartRestriction;
    4164#endif
    42 
    43 namespace WebCore {
    44 
    45 Ref<SpeechSynthesis> SpeechSynthesis::create(WeakPtr<SpeechSynthesisClient> client, Document& document)
    46 {
    47     return adoptRef(*new SpeechSynthesis(client, document));
    48 }
    49 
    50 SpeechSynthesis::SpeechSynthesis(WeakPtr<SpeechSynthesisClient> client, Document& document)
    51     : m_currentSpeechUtterance(nullptr)
    52     , m_isPaused(false)
    53 #if PLATFORM(IOS_FAMILY)
    54     , m_restrictions(document.audioPlaybackRequiresUserGesture() ? RequireUserGestureForSpeechStartRestriction : NoRestrictions)
    55 #endif
    56     , m_speechSynthesisClient(client)
    57 {
    58 #if !PLATFORM(IOS_FAMILY)
    59     UNUSED_PARAM(document);
    60 #endif
     65        m_speechSynthesisClient = downcast<Document>(context).frame()->page()->speechSynthesisClient();
     66    }
    6167
    6268    if (m_speechSynthesisClient) {
     
    6571    }
    6672}
     73
     74SpeechSynthesis::~SpeechSynthesis() = default;
    6775
    6876void SpeechSynthesis::setPlatformSynthesizer(std::unique_ptr<PlatformSpeechSynthesizer> synthesizer)
     
    7987{
    8088    m_voiceList.clear();
     89    dispatchEvent(Event::create(eventNames().voiceschangedEvent, Event::CanBubble::No, Event::IsCancelable::No));
    8190}
    8291
     
    188197}
    189198
    190 void SpeechSynthesis::fireEvent(const AtomString& type, SpeechSynthesisUtterance& utterance, unsigned long charIndex, const String& name)
    191 {
    192     utterance.dispatchEvent(SpeechSynthesisEvent::create(type, charIndex, (MonotonicTime::now() - utterance.startTime()).seconds(), name));
     199void SpeechSynthesis::fireEvent(const AtomString& type, SpeechSynthesisUtterance& utterance, unsigned long charIndex, unsigned long charLength, const String& name) const
     200{
     201    utterance.dispatchEvent(SpeechSynthesisEvent::create(type, { &utterance, charIndex, charLength, static_cast<float>((MonotonicTime::now() - utterance.startTime()).seconds()), name }));
     202}
     203
     204void SpeechSynthesis::fireErrorEvent(const AtomString& type, SpeechSynthesisUtterance& utterance, SpeechSynthesisErrorCode errorCode) const
     205{
     206    utterance.dispatchEvent(SpeechSynthesisErrorEvent::create(type, { { &utterance, 0, 0, static_cast<float>((MonotonicTime::now() - utterance.startTime()).seconds()), { } }, errorCode }));
    193207}
    194208
     
    200214    m_currentSpeechUtterance = nullptr;
    201215
    202     fireEvent(errorOccurred ? eventNames().errorEvent : eventNames().endEvent, utterance, 0, String());
    203 
     216    if (errorOccurred)
     217        fireErrorEvent(eventNames().errorEvent, utterance, SpeechSynthesisErrorCode::Canceled);
     218    else
     219        fireEvent(eventNames().endEvent, utterance, 0, 0, String());
     220   
    204221    if (m_utteranceQueue.size()) {
    205222        Ref<SpeechSynthesisUtterance> firstUtterance = m_utteranceQueue.takeFirst();
     
    212229}
    213230
    214 void SpeechSynthesis::boundaryEventOccurred(PlatformSpeechSynthesisUtterance& utterance, SpeechBoundary boundary, unsigned charIndex)
     231void SpeechSynthesis::boundaryEventOccurred(PlatformSpeechSynthesisUtterance& utterance, SpeechBoundary boundary, unsigned charIndex, unsigned charLength)
    215232{
    216233    static NeverDestroyed<const String> wordBoundaryString(MAKE_STATIC_STRING_IMPL("word"));
     
    221238    switch (boundary) {
    222239    case SpeechBoundary::SpeechWordBoundary:
    223         fireEvent(eventNames().boundaryEvent, static_cast<SpeechSynthesisUtterance&>(*utterance.client()), charIndex, wordBoundaryString);
     240        fireEvent(eventNames().boundaryEvent, static_cast<SpeechSynthesisUtterance&>(*utterance.client()), charIndex, charLength, wordBoundaryString);
    224241        break;
    225242    case SpeechBoundary::SpeechSentenceBoundary:
    226         fireEvent(eventNames().boundaryEvent, static_cast<SpeechSynthesisUtterance&>(*utterance.client()), charIndex, sentenceBoundaryString);
     243        fireEvent(eventNames().boundaryEvent, static_cast<SpeechSynthesisUtterance&>(*utterance.client()), charIndex, charLength, sentenceBoundaryString);
    227244        break;
    228245    default:
     
    266283}
    267284
    268 void SpeechSynthesis::boundaryEventOccurred(bool wordBoundary, unsigned charIndex)
    269 {
    270     if (!m_currentSpeechUtterance)
    271         return;
    272     boundaryEventOccurred(*m_currentSpeechUtterance->platformUtterance(), wordBoundary ? SpeechBoundary::SpeechWordBoundary : SpeechBoundary::SpeechSentenceBoundary, charIndex);
     285void SpeechSynthesis::boundaryEventOccurred(bool wordBoundary, unsigned charIndex, unsigned charLength)
     286{
     287    if (!m_currentSpeechUtterance)
     288        return;
     289    boundaryEventOccurred(*m_currentSpeechUtterance->platformUtterance(), wordBoundary ? SpeechBoundary::SpeechWordBoundary : SpeechBoundary::SpeechSentenceBoundary, charIndex, charLength);
    273290}
    274291
     
    281298{
    282299    if (utterance.client())
    283         fireEvent(eventNames().startEvent, static_cast<SpeechSynthesisUtterance&>(*utterance.client()), 0, String());
     300        fireEvent(eventNames().startEvent, static_cast<SpeechSynthesisUtterance&>(*utterance.client()), 0, 0, String());
    284301}
    285302
     
    288305    m_isPaused = true;
    289306    if (utterance.client())
    290         fireEvent(eventNames().pauseEvent, static_cast<SpeechSynthesisUtterance&>(*utterance.client()), 0, String());
     307        fireEvent(eventNames().pauseEvent, static_cast<SpeechSynthesisUtterance&>(*utterance.client()), 0, 0, String());
    291308}
    292309
     
    295312    m_isPaused = false;
    296313    if (utterance.client())
    297         fireEvent(eventNames().resumeEvent, static_cast<SpeechSynthesisUtterance&>(*utterance.client()), 0, String());
     314        fireEvent(eventNames().resumeEvent, static_cast<SpeechSynthesisUtterance&>(*utterance.client()), 0, 0, String());
    298315}
    299316
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesis.h

    r274678 r291124  
    3131#include "PlatformSpeechSynthesizer.h"
    3232#include "SpeechSynthesisClient.h"
     33#include "SpeechSynthesisErrorCode.h"
    3334#include "SpeechSynthesisUtterance.h"
    3435#include "SpeechSynthesisVoice.h"
     
    4243class SpeechSynthesisVoice;
    4344
    44 class SpeechSynthesis : public PlatformSpeechSynthesizerClient, public SpeechSynthesisClientObserver, public RefCounted<SpeechSynthesis> {
     45class SpeechSynthesis : public PlatformSpeechSynthesizerClient, public SpeechSynthesisClientObserver, public RefCounted<SpeechSynthesis>, public ContextDestructionObserver, public EventTargetWithInlineData {
     46    WTF_MAKE_ISO_ALLOCATED(SpeechSynthesis);
    4547public:
    46     static Ref<SpeechSynthesis> create(WeakPtr<SpeechSynthesisClient>, Document&);
     48    static Ref<SpeechSynthesis> create(ScriptExecutionContext&);
     49    virtual ~SpeechSynthesis();
     50
     51    using RefCounted::ref;
     52    using RefCounted::deref;
    4753
    4854    bool pending() const;
     
    6167
    6268private:
    63     SpeechSynthesis(WeakPtr<SpeechSynthesisClient>, Document&);
     69    SpeechSynthesis(ScriptExecutionContext&);
    6470
    6571    // PlatformSpeechSynthesizerClient override methods.
     
    7076    void didFinishSpeaking(PlatformSpeechSynthesisUtterance&) override;
    7177    void speakingErrorOccurred(PlatformSpeechSynthesisUtterance&) override;
    72     void boundaryEventOccurred(PlatformSpeechSynthesisUtterance&, SpeechBoundary, unsigned charIndex) override;
     78    void boundaryEventOccurred(PlatformSpeechSynthesisUtterance&, SpeechBoundary, unsigned charIndex, unsigned charLength) override;
    7379
    7480    // SpeechSynthesisClient override methods
     
    7884    void didResumeSpeaking() override;
    7985    void speakingErrorOccurred() override;
    80     void boundaryEventOccurred(bool wordBoundary, unsigned charIndex) override;
     86    void boundaryEventOccurred(bool wordBoundary, unsigned charIndex, unsigned charLength) override;
    8187    void voicesChanged() override;
    8288   
    8389    void startSpeakingImmediately(SpeechSynthesisUtterance&);
    8490    void handleSpeakingCompleted(SpeechSynthesisUtterance&, bool errorOccurred);
    85     void fireEvent(const AtomString& type, SpeechSynthesisUtterance&, unsigned long charIndex, const String& name);
     91    void fireEvent(const AtomString& type, SpeechSynthesisUtterance&, unsigned long charIndex, unsigned long charLength, const String& name) const;
     92    void fireErrorEvent(const AtomString& type, SpeechSynthesisUtterance&, SpeechSynthesisErrorCode) const;
    8693
    87 #if PLATFORM(IOS_FAMILY)
    8894    // Restrictions to change default behaviors.
    8995    enum BehaviorRestrictionFlags {
     
    95101    bool userGestureRequiredForSpeechStart() const { return m_restrictions & RequireUserGestureForSpeechStartRestriction; }
    96102    void removeBehaviorRestriction(BehaviorRestrictions restriction) { m_restrictions &= ~restriction; }
    97 #endif
     103   
     104    ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); }
     105    EventTargetInterface eventTargetInterface() const final { return SpeechSynthesisEventTargetInterfaceType; }
     106    void refEventTarget() final { ref(); }
     107    void derefEventTarget() final { deref(); }
     108   
    98109    PlatformSpeechSynthesizer& ensurePlatformSpeechSynthesizer();
    99110   
     
    103114    Deque<Ref<SpeechSynthesisUtterance>> m_utteranceQueue;
    104115    bool m_isPaused;
    105 #if PLATFORM(IOS_FAMILY)
    106116    BehaviorRestrictions m_restrictions;
    107 #endif
    108117    WeakPtr<SpeechSynthesisClient> m_speechSynthesisClient;
    109118};
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesis.idl

    r267813 r291124  
    2525
    2626// https://wicg.github.io/speech-api/#speechsynthesis
    27 // FIXME: This is not specified as "LegacyNoInterfaceObject". It should have an interface object and be Exposed=Window.
    2827[
    2928    Conditional=SPEECH_SYNTHESIS,
    30     LegacyNoInterfaceObject,
    31 ] interface SpeechSynthesis  {
     29    Exposed=Window,
     30] interface SpeechSynthesis : EventTarget {
     31
    3232    readonly attribute boolean pending;
    3333    readonly attribute boolean speaking;
    3434    readonly attribute boolean paused;
    3535
     36    attribute EventHandler onvoiceschanged;
     37 
    3638    undefined speak(SpeechSynthesisUtterance utterance);
    3739    undefined cancel();
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisErrorCode.idl

    r291123 r291124  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626[
    27     Conditional=SPEECH_SYNTHESIS,
    28     ImplementedBy=DOMWindowSpeechSynthesis
    29 ] partial interface DOMWindow {
    30     readonly attribute SpeechSynthesis speechSynthesis;
     27    Conditional=SPEECH_SYNTHESIS
     28] enum SpeechSynthesisErrorCode {
     29    "canceled",
     30    "interrupted",
     31    "audio-busy",
     32    "audio-hardware",
     33    "network",
     34    "synthesis-unavailable",
     35    "synthesis-failed",
     36    "language-unavailable",
     37    "voice-unavailable",
     38    "text-too-long",
     39    "invalid-argument",
     40    "not-allowed"
    3141};
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisErrorEvent.cpp

    r291123 r291124  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626#include "config.h"
    27 #include "SpeechSynthesisEvent.h"
     27#include "SpeechSynthesisErrorEvent.h"
    2828
    2929#if ENABLE(SPEECH_SYNTHESIS)
     
    3333namespace WebCore {
    3434
    35 WTF_MAKE_ISO_ALLOCATED_IMPL(SpeechSynthesisEvent);
     35WTF_MAKE_ISO_ALLOCATED_IMPL(SpeechSynthesisErrorEvent);
    3636
    37 Ref<SpeechSynthesisEvent> SpeechSynthesisEvent::create(const AtomString& type, unsigned charIndex, float elapsedTime, const String& name)
     37Ref<SpeechSynthesisErrorEvent> SpeechSynthesisErrorEvent::create(const AtomString& type, const SpeechSynthesisErrorEventInit& initializer)
    3838{
    39     return adoptRef(*new SpeechSynthesisEvent(type, charIndex, elapsedTime, name));
     39    return adoptRef(*new SpeechSynthesisErrorEvent(type, initializer));
    4040}
    4141
    42 SpeechSynthesisEvent::SpeechSynthesisEvent(const AtomString& type, unsigned charIndex, float elapsedTime, const String& name)
    43     : Event(type, CanBubble::No, IsCancelable::No)
    44     , m_charIndex(charIndex)
    45     , m_elapsedTime(elapsedTime)
    46     , m_name(name)
     42SpeechSynthesisErrorEvent::SpeechSynthesisErrorEvent(const AtomString& type, const SpeechSynthesisErrorEventInit& initializer)
     43    : SpeechSynthesisEvent(type, initializer)
     44    , m_error(initializer.error)
    4745{
    4846}
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisErrorEvent.h

    r291123 r291124  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2828#if ENABLE(SPEECH_SYNTHESIS)
    2929
    30 #include "Event.h"
     30#include "SpeechSynthesisErrorCode.h"
     31#include "SpeechSynthesisErrorEventInit.h"
     32#include "SpeechSynthesisEvent.h"
    3133
    3234namespace WebCore {
    3335
    34 class SpeechSynthesisEvent final : public Event {
    35     WTF_MAKE_ISO_ALLOCATED(SpeechSynthesisEvent);
     36class SpeechSynthesisErrorEvent final : public SpeechSynthesisEvent {
     37    WTF_MAKE_ISO_ALLOCATED(SpeechSynthesisErrorEvent);
    3638public:
    37     static Ref<SpeechSynthesisEvent> create(const AtomString& type, unsigned charIndex, float elapsedTime, const String& name);
     39   
     40    static Ref<SpeechSynthesisErrorEvent> create(const AtomString& type, const SpeechSynthesisErrorEventInit&);
    3841
    39     unsigned long charIndex() const { return m_charIndex; }
    40     float elapsedTime() const { return m_elapsedTime; }
    41     const String& name() const { return m_name; }
     42    SpeechSynthesisErrorCode error() const { return m_error; }
    4243
    43     virtual EventInterface eventInterface() const { return SpeechSynthesisEventInterfaceType; }
     44    virtual EventInterface eventInterface() const { return SpeechSynthesisErrorEventInterfaceType; }
    4445
    4546private:
    46     SpeechSynthesisEvent(const AtomString& type, unsigned charIndex, float elapsedTime, const String& name);
     47    SpeechSynthesisErrorEvent(const AtomString& type, const SpeechSynthesisErrorEventInit&);
    4748
    48     unsigned long m_charIndex;
    49     float m_elapsedTime;
    50     String m_name;
     49    SpeechSynthesisErrorCode m_error;
    5150};
    5251
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisErrorEvent.idl

    r291123 r291124  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
    26 // https://wicg.github.io/speech-api/#speechsynthesisevent
     26// https://wicg.github.io/speech-api/#speechsynthesiserrorevent
    2727[
    2828    Conditional=SPEECH_SYNTHESIS,
    2929    Exposed=Window
    30 ] interface SpeechSynthesisEvent : Event {
    31     readonly attribute unsigned long charIndex;
    32     readonly attribute unrestricted float elapsedTime;
    33     readonly attribute DOMString name;
     30] interface SpeechSynthesisErrorEvent : SpeechSynthesisEvent {
     31    constructor(DOMString type, SpeechSynthesisErrorEventInit eventInitDict);
     32
     33    readonly attribute SpeechSynthesisErrorCode error;
    3434};
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisErrorEventInit.h

    r291123 r291124  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
    26 [
    27     Conditional=SPEECH_SYNTHESIS,
    28     ImplementedBy=DOMWindowSpeechSynthesis
    29 ] partial interface DOMWindow {
    30     readonly attribute SpeechSynthesis speechSynthesis;
     26#pragma once
     27
     28#if ENABLE(SPEECH_SYNTHESIS)
     29
     30#include "SpeechSynthesisEventInit.h"
     31
     32namespace WebCore {
     33
     34struct SpeechSynthesisErrorEventInit : SpeechSynthesisEventInit {
     35    SpeechSynthesisErrorCode error;
    3136};
     37
     38} // namespace WebCore
     39
     40#endif // ENABLE(SPEECH_SYNTHESIS)
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisErrorEventInit.idl

    r291123 r291124  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2525
    2626[
    27     Conditional=SPEECH_SYNTHESIS,
    28     ImplementedBy=DOMWindowSpeechSynthesis
    29 ] partial interface DOMWindow {
    30     readonly attribute SpeechSynthesis speechSynthesis;
     27    Conditional=SPEECH_SYNTHESIS
     28] dictionary SpeechSynthesisErrorEventInit : SpeechSynthesisEventInit {
     29    required SpeechSynthesisErrorCode error;
    3130};
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisEvent.cpp

    r250060 r291124  
    3535WTF_MAKE_ISO_ALLOCATED_IMPL(SpeechSynthesisEvent);
    3636
    37 Ref<SpeechSynthesisEvent> SpeechSynthesisEvent::create(const AtomString& type, unsigned charIndex, float elapsedTime, const String& name)
     37Ref<SpeechSynthesisEvent> SpeechSynthesisEvent::create(const AtomString& type, const SpeechSynthesisEventInit& initializer)
    3838{
    39     return adoptRef(*new SpeechSynthesisEvent(type, charIndex, elapsedTime, name));
     39    return adoptRef(*new SpeechSynthesisEvent(type, initializer));
    4040}
    4141
    42 SpeechSynthesisEvent::SpeechSynthesisEvent(const AtomString& type, unsigned charIndex, float elapsedTime, const String& name)
     42SpeechSynthesisEvent::SpeechSynthesisEvent(const AtomString& type, const SpeechSynthesisEventInit& initializer)
    4343    : Event(type, CanBubble::No, IsCancelable::No)
    44     , m_charIndex(charIndex)
    45     , m_elapsedTime(elapsedTime)
    46     , m_name(name)
     44    , m_utterance(initializer.utterance)
     45    , m_charIndex(initializer.charIndex)
     46    , m_charLength(initializer.charLength)
     47    , m_elapsedTime(initializer.elapsedTime)
     48    , m_name(initializer.name)
    4749{
    4850}
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisEvent.h

    r250060 r291124  
    2929
    3030#include "Event.h"
     31#include "SpeechSynthesisEventInit.h"
     32#include "SpeechSynthesisUtterance.h"
    3133
    3234namespace WebCore {
    3335
    34 class SpeechSynthesisEvent final : public Event {
     36class SpeechSynthesisEvent : public Event {
    3537    WTF_MAKE_ISO_ALLOCATED(SpeechSynthesisEvent);
    3638public:
    37     static Ref<SpeechSynthesisEvent> create(const AtomString& type, unsigned charIndex, float elapsedTime, const String& name);
     39   
     40    static Ref<SpeechSynthesisEvent> create(const AtomString& type, const SpeechSynthesisEventInit&);
    3841
     42    const SpeechSynthesisUtterance* utterance() const { return m_utterance.get(); }
    3943    unsigned long charIndex() const { return m_charIndex; }
     44    unsigned long charLength() const { return m_charLength; }
    4045    float elapsedTime() const { return m_elapsedTime; }
    4146    const String& name() const { return m_name; }
     
    4348    virtual EventInterface eventInterface() const { return SpeechSynthesisEventInterfaceType; }
    4449
     50protected:
     51    SpeechSynthesisEvent(const AtomString& type, const SpeechSynthesisEventInit&);
     52
    4553private:
    46     SpeechSynthesisEvent(const AtomString& type, unsigned charIndex, float elapsedTime, const String& name);
    47 
     54    RefPtr<SpeechSynthesisUtterance> m_utterance;
    4855    unsigned long m_charIndex;
     56    unsigned long m_charLength;
    4957    float m_elapsedTime;
    5058    String m_name;
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisEvent.idl

    r267813 r291124  
    2121 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
    2222 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    23  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
     23 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    2424 */
    2525
     
    2929    Exposed=Window
    3030] interface SpeechSynthesisEvent : Event {
     31    constructor(DOMString type, SpeechSynthesisEventInit eventInitDict);
     32
     33    readonly attribute SpeechSynthesisUtterance utterance;
    3134    readonly attribute unsigned long charIndex;
     35    readonly attribute unsigned long charLength;
    3236    readonly attribute unrestricted float elapsedTime;
    3337    readonly attribute DOMString name;
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisEventInit.h

    r291123 r291124  
    2828#if ENABLE(SPEECH_SYNTHESIS)
    2929
    30 #include "Event.h"
     30#include "EventInit.h"
     31#include "SpeechSynthesisUtterance.h"
    3132
    3233namespace WebCore {
    3334
    34 class SpeechSynthesisEvent final : public Event {
    35     WTF_MAKE_ISO_ALLOCATED(SpeechSynthesisEvent);
    36 public:
    37     static Ref<SpeechSynthesisEvent> create(const AtomString& type, unsigned charIndex, float elapsedTime, const String& name);
     35struct SpeechSynthesisEventInit : EventInit {
    3836
    39     unsigned long charIndex() const { return m_charIndex; }
    40     float elapsedTime() const { return m_elapsedTime; }
    41     const String& name() const { return m_name; }
     37    // Generated code expects a default constructor
     38    SpeechSynthesisEventInit()
     39        : EventInit()
     40        , utterance(nullptr)
     41    { }
     42   
     43    SpeechSynthesisEventInit(SpeechSynthesisUtterance* utterance, unsigned long charIndex, unsigned long charLength, float elapsedTime, const String& name)
     44        : EventInit()
     45        , utterance(utterance)
     46        , charIndex(charIndex)
     47        , charLength(charLength)
     48        , elapsedTime(elapsedTime)
     49        , name(name)
     50    { }
    4251
    43     virtual EventInterface eventInterface() const { return SpeechSynthesisEventInterfaceType; }
    44 
    45 private:
    46     SpeechSynthesisEvent(const AtomString& type, unsigned charIndex, float elapsedTime, const String& name);
    47 
    48     unsigned long m_charIndex;
    49     float m_elapsedTime;
    50     String m_name;
     52    RefPtr<SpeechSynthesisUtterance> utterance;
     53    unsigned long charIndex;
     54    unsigned long charLength;
     55    float elapsedTime;
     56    String name;
    5157};
    5258
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisEventInit.idl

    r291123 r291124  
    11/*
    2  * Copyright (C) 2013 Apple Inc. All rights reserved.
     2 * Copyright (C) 2022 Apple Inc. All rights reserved.
    33 *
    44 * Redistribution and use in source and binary forms, with or without
     
    2424 */
    2525
     26// https://wicg.github.io/speech-api/#speechsynthesiseventinit
    2627[
    27     Conditional=SPEECH_SYNTHESIS,
    28     ImplementedBy=DOMWindowSpeechSynthesis
    29 ] partial interface DOMWindow {
    30     readonly attribute SpeechSynthesis speechSynthesis;
     28    Conditional=SPEECH_SYNTHESIS
     29] dictionary SpeechSynthesisEventInit : EventInit {
     30    required SpeechSynthesisUtterance utterance;
     31    unsigned long charIndex = 0;
     32    unsigned long charLength = 0;
     33    float elapsedTime = 0;
     34    DOMString name = "";
    3135};
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.cpp

    r243887 r291124  
    4141
    4242SpeechSynthesisUtterance::SpeechSynthesisUtterance(ScriptExecutionContext& context, const String& text)
    43     : ContextDestructionObserver(&context)
    44     , m_platformUtterance(PlatformSpeechSynthesisUtterance::create(*this))
     43    : m_platformUtterance(PlatformSpeechSynthesisUtterance::create(*this))
     44    , m_scriptExecutionContext(context)
    4545{
    4646    m_platformUtterance->setText(text);
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisUtterance.h

    r243887 r291124  
    3636namespace WebCore {
    3737
    38 class SpeechSynthesisUtterance final : public PlatformSpeechSynthesisUtteranceClient, public RefCounted<SpeechSynthesisUtterance>, public ContextDestructionObserver, public EventTargetWithInlineData {
     38class SpeechSynthesisUtterance final : public PlatformSpeechSynthesisUtteranceClient, public RefCounted<SpeechSynthesisUtterance>, public EventTargetWithInlineData {
    3939    WTF_MAKE_ISO_ALLOCATED(SpeechSynthesisUtterance);
    4040public:
    4141    static Ref<SpeechSynthesisUtterance> create(ScriptExecutionContext&, const String&);
     42   
     43    // Create an empty default constructor so SpeechSynthesisEventInit compiles.
     44    SpeechSynthesisUtterance();
    4245
    4346    virtual ~SpeechSynthesisUtterance();
     
    6972    PlatformSpeechSynthesisUtterance* platformUtterance() const { return m_platformUtterance.get(); }
    7073
     74    SpeechSynthesisUtterance(const SpeechSynthesisUtterance&);
     75   
    7176private:
    7277    SpeechSynthesisUtterance(ScriptExecutionContext&, const String&);
    7378
    74     ScriptExecutionContext* scriptExecutionContext() const final { return ContextDestructionObserver::scriptExecutionContext(); }
     79    ScriptExecutionContext* scriptExecutionContext() const final { return &m_scriptExecutionContext; }
    7580    EventTargetInterface eventTargetInterface() const final { return SpeechSynthesisUtteranceEventTargetInterfaceType; }
    7681    void refEventTarget() final { ref(); }
     
    7984    RefPtr<PlatformSpeechSynthesisUtterance> m_platformUtterance;
    8085    RefPtr<SpeechSynthesisVoice> m_voice;
     86    ScriptExecutionContext& m_scriptExecutionContext;
    8187};
    8288
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesisVoice.idl

    r267813 r291124  
    2525
    2626// https://wicg.github.io/speech-api/#speechsynthesisvoice
    27 // FIXME: This is not specified as "LegacyNoInterfaceObject". It should have an interface object and be Exposed=Window.
    2827[
    29     LegacyNoInterfaceObject,
    30     Conditional=SPEECH_SYNTHESIS
     28    Conditional=SPEECH_SYNTHESIS,
     29    Exposed=Window
    3130] interface SpeechSynthesisVoice {
    3231    readonly attribute DOMString voiceURI;
  • trunk/Source/WebCore/Sources.txt

    r291095 r291124  
    286286Modules/speech/DOMWindowSpeechSynthesis.cpp
    287287Modules/speech/SpeechSynthesis.cpp
     288Modules/speech/SpeechSynthesisErrorEvent.cpp
    288289Modules/speech/SpeechSynthesisEvent.cpp
    289290Modules/speech/SpeechSynthesisUtterance.cpp
  • trunk/Source/WebCore/SourcesCocoa.txt

    r291025 r291124  
    7171JSApplePayShippingMethodUpdate.cpp
    7272JSApplePayValidateMerchantEvent.cpp
     73JSSpeechSynthesisErrorCode.cpp
     74JSSpeechSynthesisErrorEvent.cpp
     75JSSpeechSynthesisErrorEventInit.cpp
     76JSSpeechSynthesisEventInit.cpp
    7377Modules/airplay/WebMediaSessionManager.cpp
    7478Modules/applepay/ApplePayButtonSystemImage.mm
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r291095 r291124  
    79787978                29E04A27BED2F81F98E9022B /* JSBeforeUnloadEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBeforeUnloadEvent.h; sourceTree = "<group>"; };
    79797979                29E4D8DF16B0940F00C84704 /* PlatformSpeechSynthesizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformSpeechSynthesizer.h; sourceTree = "<group>"; };
     7980                29F83EC327D315A200E1F0FD /* SpeechSynthesisErrorEvent.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeechSynthesisErrorEvent.h; sourceTree = "<group>"; };
     7981                29F83EC427D315A200E1F0FD /* SpeechSynthesisErrorEvent.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = SpeechSynthesisErrorEvent.cpp; sourceTree = "<group>"; };
     7982                29F83EC527D315B800E1F0FD /* SpeechSynthesisErrorEvent.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = SpeechSynthesisErrorEvent.idl; sourceTree = "<group>"; };
     7983                29F83EC627D3192600E1F0FD /* SpeechSynthesisErrorCode.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeechSynthesisErrorCode.h; sourceTree = "<group>"; };
     7984                29F83EC927D594E500E1F0FD /* SpeechSynthesisEventInit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeechSynthesisEventInit.h; sourceTree = "<group>"; };
     7985                29F83ECB27D5952600E1F0FD /* SpeechSynthesisEventInit.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = SpeechSynthesisEventInit.idl; sourceTree = "<group>"; };
     7986                29F83ECE27D5FA6300E1F0FD /* SpeechSynthesisErrorCode.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = SpeechSynthesisErrorCode.idl; sourceTree = "<group>"; };
     7987                29F83ECF27D6C72A00E1F0FD /* SpeechSynthesisErrorEventInit.idl */ = {isa = PBXFileReference; lastKnownFileType = text; path = SpeechSynthesisErrorEventInit.idl; sourceTree = "<group>"; };
     7988                29F83ED027D6C88500E1F0FD /* SpeechSynthesisErrorEventInit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeechSynthesisErrorEventInit.h; sourceTree = "<group>"; };
    79807989                29FAF4B5195AB08900A522DC /* TextUndoInsertionMarkupMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUndoInsertionMarkupMac.h; sourceTree = "<group>"; };
    79817990                2A4107A026CB66ED003BF797 /* CSSKeywordValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSKeywordValue.cpp; sourceTree = "<group>"; };
     
    2818128190                                AA2A5AC116A485D500975A25 /* SpeechSynthesisEvent.h */,
    2818228191                                AA2A5AC216A485D500975A25 /* SpeechSynthesisEvent.idl */,
     28192                                29F83EC927D594E500E1F0FD /* SpeechSynthesisEventInit.h */,
     28193                                29F83ECB27D5952600E1F0FD /* SpeechSynthesisEventInit.idl */,
     28194                                29F83EC627D3192600E1F0FD /* SpeechSynthesisErrorCode.h */,
     28195                                29F83ECE27D5FA6300E1F0FD /* SpeechSynthesisErrorCode.idl */,
     28196                                29F83EC427D315A200E1F0FD /* SpeechSynthesisErrorEvent.cpp */,
     28197                                29F83EC327D315A200E1F0FD /* SpeechSynthesisErrorEvent.h */,
     28198                                29F83EC527D315B800E1F0FD /* SpeechSynthesisErrorEvent.idl */,
     28199                                29F83ECF27D6C72A00E1F0FD /* SpeechSynthesisErrorEventInit.idl */,
     28200                                29F83ED027D6C88500E1F0FD /* SpeechSynthesisErrorEventInit.h */,
    2818328201                                AA2A5AC416A485D500975A25 /* SpeechSynthesisUtterance.cpp */,
    2818428202                                AA2A5AC516A485D500975A25 /* SpeechSynthesisUtterance.h */,
  • trunk/Source/WebCore/dom/EventNames.h

    r287787 r291124  
    300300    macro(versionchange) \
    301301    macro(visibilitychange) \
     302    macro(voiceschanged) \
    302303    macro(volumechange) \
    303304    macro(waiting) \
  • trunk/Source/WebCore/dom/EventNames.in

    r289894 r291124  
    7171SpeechRecognitionErrorEvent
    7272SpeechRecognitionEvent
     73SpeechSynthesisErrorEvent conditional=SPEECH_SYNTHESIS
    7374SpeechSynthesisEvent conditional=SPEECH_SYNTHESIS
    7475WebGLContextEvent conditional=WEBGL
  • trunk/Source/WebCore/dom/EventTargetFactory.in

    r289894 r291124  
    5757SourceBufferList conditional=MEDIA_SOURCE
    5858SpeechRecognition
     59SpeechSynthesis conditional=SPEECH_SYNTHESIS
    5960SpeechSynthesisUtterance conditional=SPEECH_SYNTHESIS
    6061TextTrack conditional=VIDEO
  • trunk/Source/WebCore/page/SpeechSynthesisClient.h

    r286259 r291124  
    6161    virtual void didResumeSpeaking() = 0;
    6262    virtual void speakingErrorOccurred() = 0;
    63     virtual void boundaryEventOccurred(bool wordBoundary, unsigned charIndex) = 0;
     63    virtual void boundaryEventOccurred(bool wordBoundary, unsigned charIndex, unsigned charLength) = 0;
    6464    virtual void voicesChanged() = 0;
    6565};
  • trunk/Source/WebCore/platform/PlatformSpeechSynthesizer.h

    r286259 r291124  
    5353    virtual void didResumeSpeaking(PlatformSpeechSynthesisUtterance&) = 0;
    5454    virtual void speakingErrorOccurred(PlatformSpeechSynthesisUtterance&) = 0;
    55     virtual void boundaryEventOccurred(PlatformSpeechSynthesisUtterance&, SpeechBoundary, unsigned charIndex) = 0;
     55    virtual void boundaryEventOccurred(PlatformSpeechSynthesisUtterance&, SpeechBoundary, unsigned charIndex, unsigned charLength) = 0;
    5656    virtual void voicesDidChange() = 0;
    5757protected:
  • trunk/Source/WebCore/platform/cocoa/PlatformSpeechSynthesizerCocoa.mm

    r286259 r291124  
    258258
    259259    // AVSpeechSynthesizer only supports word boundaries.
    260     m_synthesizerObject->client()->boundaryEventOccurred(*m_utterance, WebCore::SpeechBoundary::SpeechWordBoundary, characterRange.location);
     260    m_synthesizerObject->client()->boundaryEventOccurred(*m_utterance, WebCore::SpeechBoundary::SpeechWordBoundary, characterRange.location, characterRange.length);
    261261}
    262262
     
    282282        NSString *voiceURI = [voice identifier];
    283283        NSString *name = [voice name];
    284        
    285284        // Only show built-in voices when requesting through WebKit to reduce fingerprinting surface area.
    286285#if HAVE(AVSPEECHSYNTHESIS_SYSTEMVOICE)
  • trunk/Source/WebCore/platform/mock/PlatformSpeechSynthesizerMock.cpp

    r243002 r291124  
    6262    client()->didStartSpeaking(*m_utterance);
    6363
    64     // Fire a fake word and then sentence boundary event.
    65     client()->boundaryEventOccurred(*m_utterance, SpeechBoundary::SpeechWordBoundary, 0);
    66     client()->boundaryEventOccurred(*m_utterance, SpeechBoundary::SpeechSentenceBoundary, m_utterance->text().length());
     64    // Fire a fake word and then sentence boundary event. Since the entire sentence is the full length, pick arbitrary (3) length for the word.
     65    client()->boundaryEventOccurred(*m_utterance, SpeechBoundary::SpeechWordBoundary, 0, 3);
     66    client()->boundaryEventOccurred(*m_utterance, SpeechBoundary::SpeechSentenceBoundary, 0, m_utterance->text().length());
    6767
    6868    // Give the fake speech job some time so that pause and other functions have time to be called.
  • trunk/Source/WebKit/ChangeLog

    r291123 r291124  
     12022-03-10  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Support updated WebSpeech API
     4        https://bugs.webkit.org/show_bug.cgi?id=237614
     5        <rdar://problem/89981851>
     6
     7        Reviewed by Andres Gonzalez.
     8
     9        * UIProcess/Cocoa/WebPageProxyCocoa.mm:
     10        (WebKit::WebPageProxy::boundaryEventOccurred):
     11        * UIProcess/WebPageProxy.h:
     12        * WebProcess/WebPage/WebPage.cpp:
     13        (WebKit::WebPage::boundaryEventOccurred):
     14        * WebProcess/WebPage/WebPage.h:
     15        * WebProcess/WebPage/WebPage.messages.in:
     16
    1172022-03-10  Chris Dumez  <cdumez@apple.com>
    218
  • trunk/Source/WebKit/UIProcess/Cocoa/WebPageProxyCocoa.mm

    r291023 r291124  
    452452}
    453453
    454 void WebPageProxy::boundaryEventOccurred(WebCore::PlatformSpeechSynthesisUtterance&, WebCore::SpeechBoundary speechBoundary, unsigned charIndex)
    455 {
    456     send(Messages::WebPage::BoundaryEventOccurred(speechBoundary == WebCore::SpeechBoundary::SpeechWordBoundary, charIndex));
     454void WebPageProxy::boundaryEventOccurred(WebCore::PlatformSpeechSynthesisUtterance&, WebCore::SpeechBoundary speechBoundary, unsigned charIndex, unsigned charLength)
     455{
     456    send(Messages::WebPage::BoundaryEventOccurred(speechBoundary == WebCore::SpeechBoundary::SpeechWordBoundary, charIndex, charLength));
    457457}
    458458
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r291023 r291124  
    25862586    void didResumeSpeaking(WebCore::PlatformSpeechSynthesisUtterance&) final;
    25872587    void speakingErrorOccurred(WebCore::PlatformSpeechSynthesisUtterance&) final;
    2588     void boundaryEventOccurred(WebCore::PlatformSpeechSynthesisUtterance&, WebCore::SpeechBoundary, unsigned charIndex) final;
     2588    void boundaryEventOccurred(WebCore::PlatformSpeechSynthesisUtterance&, WebCore::SpeechBoundary, unsigned charIndex, unsigned charLength) final;
    25892589    void voicesDidChange() final;
    25902590
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r291094 r291124  
    73507350}
    73517351
    7352 void WebPage::boundaryEventOccurred(bool wordBoundary, unsigned charIndex)
     7352void WebPage::boundaryEventOccurred(bool wordBoundary, unsigned charIndex, unsigned charLength)
    73537353{
    73547354    if (auto observer = corePage()->speechSynthesisClient()->observer())
    7355         observer->boundaryEventOccurred(wordBoundary, charIndex);
     7355        observer->boundaryEventOccurred(wordBoundary, charIndex, charLength);
    73567356}
    73577357
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.h

    r290985 r291124  
    19291929#if ENABLE(SPEECH_SYNTHESIS)
    19301930    void speakingErrorOccurred();
    1931     void boundaryEventOccurred(bool wordBoundary, unsigned charIndex);
     1931    void boundaryEventOccurred(bool wordBoundary, unsigned charIndex, unsigned charLength);
    19321932    void voicesDidChange();
    19331933#endif
  • trunk/Source/WebKit/WebProcess/WebPage/WebPage.messages.in

    r290985 r291124  
    616616#if ENABLE(SPEECH_SYNTHESIS)
    617617    SpeakingErrorOccurred()
    618     BoundaryEventOccurred(bool wordBoundary, unsigned charIndex)
     618    BoundaryEventOccurred(bool wordBoundary, unsigned charIndex, unsigned charLength)
    619619    VoicesDidChange()
    620620#endif
Note: See TracChangeset for help on using the changeset viewer.