⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 286259 in webkit


Ignore:
Timestamp:
Nov 29, 2021, 12:48:59 PM (5 years ago)
Author:
Chris Fleizach
Message:

AX: Unify speech synthesizer platform usage for Mac/iOS
https://bugs.webkit.org/show_bug.cgi?id=231895
<rdar://problem/84372479>

Reviewed by Andres Gonzalez.

LayoutTests/imported/w3c:

Update expectations now that the test passes.

  • web-platform-tests/speech-api/SpeechSynthesis-speak-events-expected.txt:

Source/WebCore:

AVSpeechSynthesizer has been fully supported on macOS for a number of years. This allows us to unify platform usage.
Fix a number of tests that had been marked failing/flaky related to speech synthesis.

  • Modules/speech/SpeechSynthesis.cpp:

(WebCore::SpeechSynthesis::SpeechSynthesis):
(WebCore::SpeechSynthesis::startSpeakingImmediately):
(WebCore::SpeechSynthesis::speak):

  • SourcesCocoa.txt:
  • WebCore.xcodeproj/project.pbxproj:
  • page/SpeechSynthesisClient.h:
  • platform/PlatformSpeechSynthesizer.h:
  • platform/graphics/cocoa/FontCacheCoreText.cpp:

(WebCore::variationAxes):

  • platform/ios/PlatformSpeechSynthesizerIOS.mm: Removed.
  • platform/mac/PlatformSpeechSynthesizerMac.mm: Removed.
  • Source/WebCore/platform/cocoa/PlatformSpeechSynthesizerCocoa.mm: Added.

Source/WebCore/PAL:

  • PAL.xcodeproj/project.pbxproj:
  • pal/cocoa/AVFoundationSoftLink.h:
  • pal/cocoa/AVFoundationSoftLink.mm:
  • pal/spi/cocoa/AXSpeechManagerSPI.h:
  • pal/spi/mac/SpeechSynthesisSPI.h: Removed.

Source/WebKit:

Create a new message for resetting speech synthesis state when the DOMWindow changes
but the Page (and its referenced speech synthesis) stays the same.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::speechSynthesisResetState):

  • UIProcess/WebPageProxy.h:
  • UIProcess/WebPageProxy.messages.in:
  • WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp:

(WebKit::WebSpeechSynthesisClient::resetState):

  • WebProcess/WebCoreSupport/WebSpeechSynthesisClient.h:

Source/WTF:

  • wtf/PlatformHave.h:

LayoutTests:

  • fast/speechsynthesis/speech-synthesis-speak-empty-string-expected.txt:
  • platform/mac-catalina-wk1/TestExpectations: Added.
  • platform/mac-wk1/TestExpectations:
  • platform/mac-wk2/TestExpectations:
  • platform/mac/TestExpectations:
Location:
trunk
Files:
1 added
2 deleted
26 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r286254 r286259  
     12021-11-29  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Unify speech synthesizer platform usage for Mac/iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=231895
     5        <rdar://problem/84372479>
     6
     7        Reviewed by Andres Gonzalez.
     8
     9        * fast/speechsynthesis/speech-synthesis-speak-empty-string-expected.txt:
     10        * platform/mac-catalina-wk1/TestExpectations: Added.
     11        * platform/mac-wk1/TestExpectations:
     12        * platform/mac-wk2/TestExpectations:
     13        * platform/mac/TestExpectations:
     14
    1152021-11-29  Myles C. Maxfield  <mmaxfield@apple.com>
    216
  • trunk/LayoutTests/fast/speechsynthesis/speech-synthesis-speak-empty-string-expected.txt

    r173000 r286259  
    66PASS speechSynthesis.speaking is false
    77PASS event.elapsedTime > 0 is true
     8PASS speechSynthesis.speaking is true
     9PASS event.elapsedTime > 0 is true
    810PASS speechSynthesis.speaking is false
    911PASS successfullyParsed is true
  • trunk/LayoutTests/imported/w3c/ChangeLog

    r286226 r286259  
     12021-11-29  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Unify speech synthesizer platform usage for Mac/iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=231895
     5        <rdar://problem/84372479>
     6
     7        Reviewed by Andres Gonzalez.
     8
     9        Update expectations now that the test passes.
     10
     11        * web-platform-tests/speech-api/SpeechSynthesis-speak-events-expected.txt:
     12
    1132021-11-29  Antti Koivisto  <antti@apple.com>
    214
  • trunk/LayoutTests/imported/w3c/web-platform-tests/speech-api/SpeechSynthesis-speak-events-expected.txt

    r279400 r286259  
    11
    2 FAIL speechSynthesis.speak() fires start and end events with empty utterance assert_true: Not expecting event, but got end event expected true got false
     2PASS speechSynthesis.speak() fires start and end events with empty utterance
    33PASS speechSynthesis.speak() fires start and end events
    44
  • trunk/LayoutTests/platform/mac-wk1/TestExpectations

    r286116 r286259  
    7373fast/speechrecognition/start-recognition-after-gum.html [ Skip ]
    7474fast/speechrecognition/start-recognition-after-denied-gum.html [ Skip ]
    75 imported/w3c/web-platform-tests/speech-api/SpeechSynthesis-pause-resume.tentative.html [ Skip ]
    7675
    7776# Datalist is unsupported in WK1
  • trunk/LayoutTests/platform/mac-wk2/TestExpectations

    r285993 r286259  
    12091209[ BigSur+ ] imported/w3c/web-platform-tests/css/css-font-loading/idlharness.https.html [ Pass Failure Timeout ]
    12101210
    1211 # rdar://66701815 (REGRESSION (20A2321a-20A2348b): fast/speechsynthesis/speech-synthesis-speak-empty-string.html is a flaky failure)
    1212 [ BigSur+ ] fast/speechsynthesis/speech-synthesis-speak-empty-string.html [ Pass Failure ]
    1213 
    12141211# rdar://66703773 (REGRESSION (20A2316-20A2348b): http/tests/security/contentSecurityPolicy/plugin-blocked-in-about-blank-window.html is a constant failure)
    12151212[ arm64 ] http/tests/security/contentSecurityPolicy/plugin-blocked-in-about-blank-window.html [ Skip ]
  • trunk/LayoutTests/platform/mac/TestExpectations

    r286165 r286259  
    20322032webkit.org/b/217620 inspector/audit/basic-async.html [ Pass Timeout ]
    20332033
    2034 imported/w3c/web-platform-tests/speech-api/SpeechSynthesis-speak-twice.html [ Skip ]
    2035 imported/w3c/web-platform-tests/speech-api/SpeechSynthesis-speak-without-activation-fails.tentative.html [ Skip ]
    2036 webkit.org/b/227501 [ Debug ] imported/w3c/web-platform-tests/speech-api/SpeechSynthesis-speak-events.html [ Skip ]
    2037 
    20382034webkit.org/b/217669 http/wpt/service-workers/service-worker-spinning-message.https.html [ Pass Failure ]
    20392035
     
    23012297
    23022298#rdar://82146367 ([Mac, iOS Release] imported/w3c/web-platform-tests/worklets/layout-worklet-csp.https.html is a flaky failure) imported/w3c/web-platform-tests/worklets/layout-worklet-csp.https.html [ Pass Failure ]
    2303 
    2304 webkit.org/b/228396 fast/speechsynthesis/speech-synthesis-speak-empty-string.html [ Pass Failure ]
    23052299
    23062300webkit.org/b/228176 [ Mojave Catalina BigSur ] fast/text/variable-system-font.html [ ImageOnlyFailure ]
  • trunk/Source/WTF/ChangeLog

    r286251 r286259  
     12021-11-29  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Unify speech synthesizer platform usage for Mac/iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=231895
     5        <rdar://problem/84372479>
     6
     7        Reviewed by Andres Gonzalez.
     8
     9        * wtf/PlatformHave.h:
     10
    1112021-11-29  Yusuke Suzuki  <ysuzuki@apple.com>
    212
  • trunk/Source/WTF/wtf/PlatformHave.h

    r286227 r286259  
    758758#endif
    759759
    760 #if (PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 140300
     760#if ((PLATFORM(IOS) || PLATFORM(MACCATALYST)) && __IPHONE_OS_VERSION_MAX_ALLOWED >= 140300) || (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED > 120000)
    761761#if !defined(HAVE_AVSPEECHSYNTHESIS_SYSTEMVOICE)
    762762#define HAVE_AVSPEECHSYNTHESIS_SYSTEMVOICE 1
     
    767767#if !defined(HAVE_TCC_IOS_14_BIG_SUR_SPI)
    768768#define HAVE_TCC_IOS_14_BIG_SUR_SPI 1
    769 #endif
    770 #endif
    771 
    772 #if PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 120000
    773 #if !defined(HAVE_SPEECHSYNTHESIS_MONTEREY_SPI)
    774 #define HAVE_SPEECHSYNTHESIS_MONTEREY_SPI 1
    775769#endif
    776770#endif
     
    11111105#define HAVE_SCENEKIT 1
    11121106#endif
     1107
     1108#if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 130000)
     1109#define HAVE_UNIFIED_SPEECHSYNTHESIS_FIX_FOR_81465164 1
     1110#endif
  • trunk/Source/WebCore/ChangeLog

    r286254 r286259  
     12021-11-29  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Unify speech synthesizer platform usage for Mac/iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=231895
     5        <rdar://problem/84372479>
     6
     7        Reviewed by Andres Gonzalez.
     8
     9        AVSpeechSynthesizer has been fully supported on macOS for a number of years. This allows us to unify platform usage.
     10        Fix a number of tests that had been marked failing/flaky related to speech synthesis.
     11
     12        * Modules/speech/SpeechSynthesis.cpp:
     13        (WebCore::SpeechSynthesis::SpeechSynthesis):
     14        (WebCore::SpeechSynthesis::startSpeakingImmediately):
     15        (WebCore::SpeechSynthesis::speak):
     16        * SourcesCocoa.txt:
     17        * WebCore.xcodeproj/project.pbxproj:
     18        * page/SpeechSynthesisClient.h:
     19        * platform/PlatformSpeechSynthesizer.h:
     20        * platform/graphics/cocoa/FontCacheCoreText.cpp:
     21        (WebCore::variationAxes):
     22        * platform/ios/PlatformSpeechSynthesizerIOS.mm: Removed.
     23        * platform/mac/PlatformSpeechSynthesizerMac.mm: Removed.
     24        * Source/WebCore/platform/cocoa/PlatformSpeechSynthesizerCocoa.mm: Added.
     25
    1262021-11-29  Myles C. Maxfield  <mmaxfield@apple.com>
    227
  • trunk/Source/WebCore/Modules/speech/SpeechSynthesis.cpp

    r284057 r286259  
    6060#endif
    6161
    62     if (m_speechSynthesisClient)
     62    if (m_speechSynthesisClient) {
    6363        m_speechSynthesisClient->setObserver(*this);
     64        m_speechSynthesisClient->resetState();
     65    }
    6466}
    6567
     
    123125    m_isPaused = false;
    124126
    125     // Zero lengthed strings should immediately notify that the event is complete.
    126     if (utterance.text().isEmpty()) {
    127         handleSpeakingCompleted(utterance, false);
    128         return;
    129     }
    130 
    131127    if (m_speechSynthesisClient)
    132128        m_speechSynthesisClient->speak(utterance.platformUtterance());
     
    146142
    147143    m_utteranceQueue.append(utterance);
    148 
    149144    // If the queue was empty, speak this immediately and add it to the queue.
    150145    if (m_utteranceQueue.size() == 1)
  • trunk/Source/WebCore/PAL/ChangeLog

    r286252 r286259  
     12021-11-29  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Unify speech synthesizer platform usage for Mac/iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=231895
     5        <rdar://problem/84372479>
     6
     7        Reviewed by Andres Gonzalez.
     8
     9        * PAL.xcodeproj/project.pbxproj:
     10        * pal/cocoa/AVFoundationSoftLink.h:
     11        * pal/cocoa/AVFoundationSoftLink.mm:
     12        * pal/spi/cocoa/AXSpeechManagerSPI.h:
     13        * pal/spi/mac/SpeechSynthesisSPI.h: Removed.
     14
    1152021-11-29  Myles C. Maxfield  <mmaxfield@apple.com>
    216
  • trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj

    r285846 r286259  
    324324                A10826FA1F576292004772AC /* WebPanel.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10826F81F576292004772AC /* WebPanel.mm */; };
    325325                A10826FE1F58A433004772AC /* NSGraphicsSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10826FD1F58A433004772AC /* NSGraphicsSPI.h */; };
    326                 A1175B491F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A1175B481F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h */; };
    327326                A1175B4B1F6B2D7E00C4B9F0 /* NSCellSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A1175B4A1F6B2D7E00C4B9F0 /* NSCellSPI.h */; };
    328327                A1175B4E1F6B337300C4B9F0 /* PopupMenu.h in Headers */ = {isa = PBXBuildFile; fileRef = A1175B4C1F6B337300C4B9F0 /* PopupMenu.h */; };
     
    729728                A10826F81F576292004772AC /* WebPanel.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPanel.mm; sourceTree = "<group>"; };
    730729                A10826FD1F58A433004772AC /* NSGraphicsSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSGraphicsSPI.h; sourceTree = "<group>"; };
    731                 A1175B481F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeechSynthesisSPI.h; sourceTree = "<group>"; };
    732730                A1175B4A1F6B2D7E00C4B9F0 /* NSCellSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSCellSPI.h; sourceTree = "<group>"; };
    733731                A1175B4C1F6B337300C4B9F0 /* PopupMenu.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PopupMenu.h; sourceTree = "<group>"; };
     
    979977                                0C7785851F45130F00F4EBB6 /* PIPSPI.h */,
    980978                                0C7785871F45130F00F4EBB6 /* QuickLookMacSPI.h */,
    981                                 A1175B481F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h */,
    982979                                71B1141F26823ACD004D6701 /* SystemPreviewSPI.h */,
    983980                                0C7785881F45130F00F4EBB6 /* TelephonyUtilitiesSPI.h */,
     
    15501547                                93B38EBE25821CB600198E63 /* SpeechSoftLink.h in Headers */,
    15511548                                93B38EC225821D2200198E63 /* SpeechSPI.h in Headers */,
    1552                                 A1175B491F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h in Headers */,
    15531549                                0C5AF9211F43A4C7002EAC02 /* SQLite3SPI.h in Headers */,
    15541550                                71B1142026823ACD004D6701 /* SystemPreviewSPI.h in Headers */,
  • trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.h

    r284822 r286259  
    7777SOFT_LINK_CLASS_FOR_HEADER(PAL, AVAudioSession)
    7878SOFT_LINK_CLASS_FOR_HEADER(PAL, AVPersistableContentKeyRequest)
     79#endif
     80
     81#if PLATFORM(COCOA)
    7982SOFT_LINK_CLASS_FOR_HEADER(PAL, AVSpeechSynthesisVoice)
    8083SOFT_LINK_CLASS_FOR_HEADER(PAL, AVSpeechSynthesizer)
  • trunk/Source/WebCore/PAL/pal/cocoa/AVFoundationSoftLink.mm

    r284822 r286259  
    103103SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVAudioSession, PAL_EXPORT)
    104104SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVPersistableContentKeyRequest, PAL_EXPORT)
     105#endif
     106
     107#if PLATFORM(COCOA)
    105108SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVSpeechSynthesisVoice, PAL_EXPORT)
    106109SOFT_LINK_CLASS_FOR_SOURCE_WITH_EXPORT(PAL, AVFoundation, AVSpeechSynthesizer, PAL_EXPORT)
  • trunk/Source/WebCore/PAL/pal/spi/cocoa/AXSpeechManagerSPI.h

    r284822 r286259  
    2626#pragma once
    2727
    28 #if PLATFORM(IOS_FAMILY)
     28#if PLATFORM(COCOA)
    2929
    3030// FIXME: Undo when isSystemVoice is available in all SDKs.
     
    4343#endif // USE(APPLE_INTERNAL_SDK)
    4444
    45 #endif // PLATFORM(IOS_FAMILY)
     45#endif // PLATFORM(COCOA)
    4646
  • trunk/Source/WebCore/SourcesCocoa.txt

    r286193 r286259  
    260260platform/cocoa/PasteboardCustomDataCocoa.mm
    261261platform/cocoa/PlatformPasteboardCocoa.mm
     262platform/cocoa/PlatformSpeechSynthesizerCocoa.mm @no-unify
    262263platform/cocoa/PlaybackSessionModelMediaElement.mm
    263264platform/cocoa/PowerSourceNotifier.mm
     
    445446platform/ios/PlatformPasteboardIOS.mm
    446447platform/ios/PlatformScreenIOS.mm
    447 platform/ios/PlatformSpeechSynthesizerIOS.mm @no-unify
    448448platform/ios/PlaybackSessionInterfaceAVKit.mm @no-unify
    449449platform/ios/PreviewConverterIOS.mm
     
    492492platform/mac/PlatformPasteboardMac.mm
    493493platform/mac/PlatformScreenMac.mm
    494 platform/mac/PlatformSpeechSynthesizerMac.mm
    495494platform/mac/PlaybackSessionInterfaceMac.mm @no-unify
    496495platform/mac/PluginBlocklist.mm
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r286209 r286259  
    37063706                A9D248070D757E7D00FDF959 /* JSDOMMimeType.h in Headers */ = {isa = PBXBuildFile; fileRef = A9D248030D757E7D00FDF959 /* JSDOMMimeType.h */; };
    37073707                A9D248090D757E7D00FDF959 /* JSDOMMimeTypeArray.h in Headers */ = {isa = PBXBuildFile; fileRef = A9D248050D757E7D00FDF959 /* JSDOMMimeTypeArray.h */; };
    3708                 AA12DF491743DF83004DAFDF /* PlatformSpeechSynthesizerIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = AAE3755D17429BCC006200C2 /* PlatformSpeechSynthesizerIOS.mm */; };
     3708                AA12DF491743DF83004DAFDF /* PlatformSpeechSynthesizerCocoa.mm in Sources */ = {isa = PBXBuildFile; fileRef = AAE3755D17429BCC006200C2 /* PlatformSpeechSynthesizerCocoa.mm */; };
    37093709                AA21ECCD0ABF0FC6002B834C /* CSSCursorImageValue.h in Headers */ = {isa = PBXBuildFile; fileRef = AA0978EE0ABAA6E100874480 /* CSSCursorImageValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
    37103710                AA2A5ACE16A485FD00975A25 /* SpeechSynthesisVoice.h in Headers */ = {isa = PBXBuildFile; fileRef = AA2A5AC716A485D500975A25 /* SpeechSynthesisVoice.h */; };
     
    78477847                29E04A27BED2F81F98E9022B /* JSBeforeUnloadEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSBeforeUnloadEvent.h; sourceTree = "<group>"; };
    78487848                29E4D8DF16B0940F00C84704 /* PlatformSpeechSynthesizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = PlatformSpeechSynthesizer.h; sourceTree = "<group>"; };
    7849                 29E4D8E016B0959800C84704 /* PlatformSpeechSynthesizerMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformSpeechSynthesizerMac.mm; sourceTree = "<group>"; };
    78507849                29FAF4B5195AB08900A522DC /* TextUndoInsertionMarkupMac.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextUndoInsertionMarkupMac.h; sourceTree = "<group>"; };
    78517850                2A4107A026CB66ED003BF797 /* CSSKeywordValue.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = CSSKeywordValue.cpp; sourceTree = "<group>"; };
     
    1425014249                AAE27B7416CBFC0D00623043 /* PlatformSpeechSynthesizerMock.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PlatformSpeechSynthesizerMock.cpp; sourceTree = "<group>"; };
    1425114250                AAE27B7516CBFC0D00623043 /* PlatformSpeechSynthesizerMock.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PlatformSpeechSynthesizerMock.h; sourceTree = "<group>"; };
    14252                 AAE3755D17429BCC006200C2 /* PlatformSpeechSynthesizerIOS.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformSpeechSynthesizerIOS.mm; sourceTree = "<group>"; };
     14251                AAE3755D17429BCC006200C2 /* PlatformSpeechSynthesizerCocoa.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PlatformSpeechSynthesizerCocoa.mm; sourceTree = "<group>"; };
    1425314252                AAF5B7B11524B4BD0004CB49 /* WebSocketFrame.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WebSocketFrame.cpp; sourceTree = "<group>"; };
    1425414253                AB23A32509BBA7D00067CC53 /* BeforeTextInsertedEvent.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = BeforeTextInsertedEvent.cpp; sourceTree = "<group>"; };
     
    2359623595                                C5F765BA14E1ECF4006C899B /* PlatformPasteboardMac.mm */,
    2359723596                                BC94D1070C274F88006BC617 /* PlatformScreenMac.mm */,
    23598                                 29E4D8E016B0959800C84704 /* PlatformSpeechSynthesizerMac.mm */,
    2359923597                                CDA29A151CBDA56C00901CCF /* PlaybackSessionInterfaceMac.h */,
    2360023598                                CDA29A141CBDA56C00901CCF /* PlaybackSessionInterfaceMac.mm */,
     
    2633426332                                C5278B0B17F212EA003A2998 /* PlatformPasteboardIOS.mm */,
    2633526333                                E45390320EAFD637003695C8 /* PlatformScreenIOS.mm */,
    26336                                 AAE3755D17429BCC006200C2 /* PlatformSpeechSynthesizerIOS.mm */,
    2633726334                                CDA29A2E1CBF73FC00901CCF /* PlaybackSessionInterfaceAVKit.h */,
    2633826335                                CDA29A2F1CBF73FC00901CCF /* PlaybackSessionInterfaceAVKit.mm */,
     
    2649326490                                F4FB35002350C96200F0094A /* PasteboardCustomDataCocoa.mm */,
    2649426491                                F4628A9E234D3BBF00BC884C /* PlatformPasteboardCocoa.mm */,
     26492                                AAE3755D17429BCC006200C2 /* PlatformSpeechSynthesizerCocoa.mm */,
    2649526493                                52B0D4BD1C57FD1E0077CE53 /* PlatformView.h */,
    2649626494                                95BA4FAB26D981AA002A0E62 /* PlatformViewController.h */,
     
    3822438222                                E16982601134636A00894115 /* ObjCRuntimeObject.mm in Sources */,
    3822538223                                CEA284662141E84900E407E8 /* PlatformEventFactoryIOS.mm in Sources */,
    38226                                 AA12DF491743DF83004DAFDF /* PlatformSpeechSynthesizerIOS.mm in Sources */,
     38224                                AA12DF491743DF83004DAFDF /* PlatformSpeechSynthesizerCocoa.mm in Sources */,
    3822738225                                CDA29A301CBF74D400901CCF /* PlaybackSessionInterfaceAVKit.mm in Sources */,
    3822838226                                CDA29A161CBDA56C00901CCF /* PlaybackSessionInterfaceMac.mm in Sources */,
  • trunk/Source/WebCore/page/SpeechSynthesisClient.h

    r243002 r286259  
    4848    virtual void pause() = 0;
    4949    virtual void resume() = 0;
     50    virtual void resetState() = 0;
    5051
    5152};
  • trunk/Source/WebCore/platform/PlatformSpeechSynthesizer.h

    r247755 r286259  
    7373    virtual void resume();
    7474    virtual void cancel();
     75    virtual void resetState();
    7576
    76     void resetState();
    7777    PlatformSpeechSynthesizerClient* client() const { return m_speechSynthesizerClient; }
    7878
  • trunk/Source/WebCore/platform/cocoa/PlatformSpeechSynthesizerCocoa.mm

    r286258 r286259  
    2626#import "PlatformSpeechSynthesizer.h"
    2727
    28 #if ENABLE(SPEECH_SYNTHESIS) && PLATFORM(IOS_FAMILY)
     28#if ENABLE(SPEECH_SYNTHESIS) && PLATFORM(COCOA)
    2929
    3030#import "PlatformSpeechSynthesisUtterance.h"
    3131#import "PlatformSpeechSynthesisVoice.h"
    32 #import <AVFoundation/AVSpeechSynthesis.h>
     32
     33#if __has_include(<AVFAudio/AVSpeechSynthesis.h>)
     34#import <AVFAudio/AVSpeechSynthesis.h>
     35#else
     36#import <AVFoundation/AVFoundation.h>
     37#endif
     38
    3339#import <pal/spi/cocoa/AXSpeechManagerSPI.h>
    3440#import <wtf/BlockObjCExceptions.h>
     
    6470#define AVSpeechUtteranceMaximumSpeechRate getAVSpeechUtteranceMaximumSpeechRate()
    6571
    66 @interface WebSpeechSynthesisWrapper : NSObject<AVSpeechSynthesizerDelegate>
    67 {
     72@interface WebSpeechSynthesisWrapper : NSObject<AVSpeechSynthesizerDelegate> {
    6873    WebCore::PlatformSpeechSynthesizer* m_synthesizerObject;
    6974    // Hold a Ref to the utterance so that it won't disappear until the synth is done with it.
     
    106111    ASSERT(!m_utterance);
    107112    ASSERT(utterance);
    108 
    109113    if (!utterance)
    110114        return;
    111 
     115   
    112116    BEGIN_BLOCK_OBJC_EXCEPTIONS
    113117    if (!m_synthesizer) {
     
    115119        [m_synthesizer setDelegate:self];
    116120    }
    117 
     121   
    118122    // Choose the best voice, by first looking at the utterance voice, then the utterance language,
    119123    // then choose the default language.
     
    140144    m_utterance = WTFMove(utterance);
    141145
     146    // macOS won't send a did start speaking callback for empty strings.
     147#if !HAVE(UNIFIED_SPEECHSYNTHESIS_FIX_FOR_81465164)
     148    if (!m_utterance->text().length())
     149        m_synthesizerObject->client()->didStartSpeaking(*m_utterance);
     150#endif
     151
    142152    [m_synthesizer speakUtterance:avUtterance];
    143153    END_BLOCK_OBJC_EXCEPTIONS
     
    164174}
    165175
     176- (void)resetState
     177{
     178    // On a reset, cancel utterance and set to nil immediately so the next speech job continues without waiting for a callback
     179    [self cancel];
     180    m_utterance = nil;
     181}
     182
    166183- (void)cancel
    167184{
     
    192209
    193210    // Clear the m_utterance variable in case finish speaking kicks off a new speaking job immediately.
    194     RefPtr<WebCore::PlatformSpeechSynthesisUtterance> platformUtterance = m_utterance;
     211    RefPtr<WebCore::PlatformSpeechSynthesisUtterance> protectedUtterance = m_utterance;
    195212    m_utterance = nullptr;
    196213
    197     m_synthesizerObject->client()->didFinishSpeaking(*platformUtterance);
     214    m_synthesizerObject->client()->didFinishSpeaking(*protectedUtterance);
    198215}
    199216
     
    226243
    227244    // Clear the m_utterance variable in case finish speaking kicks off a new speaking job immediately.
    228     RefPtr<WebCore::PlatformSpeechSynthesisUtterance> platformUtterance = m_utterance;
     245    RefPtr<WebCore::PlatformSpeechSynthesisUtterance> protectedUtterance = m_utterance;
    229246    m_utterance = nullptr;
    230247
    231     m_synthesizerObject->client()->didFinishSpeaking(*platformUtterance);
     248    m_synthesizerObject->client()->didFinishSpeaking(*protectedUtterance);
    232249}
    233250
     
    240257        return;
    241258
    242     // iOS only supports word boundaries.
     259    // AVSpeechSynthesizer only supports word boundaries.
    243260    m_synthesizerObject->client()->boundaryEventOccurred(*m_utterance, WebCore::SpeechBoundary::SpeechWordBoundary, characterRange.location);
    244261}
     
    276293        if (includeVoice)
    277294#else
    278         if (voice.quality == AVSpeechSynthesisVoiceQualityDefault)
     295        // AVSpeechSynthesis on macOS does not support quality property correctly.
     296        if (voice.quality == AVSpeechSynthesisVoiceQualityDefault
     297            || (TARGET_OS_OSX && ![voiceURI hasSuffix:@"premium"]))
    279298#endif
    280299            m_voiceList.append(PlatformSpeechSynthesisVoice::create(voiceURI, name, language, true, isDefault));
     
    308327void PlatformSpeechSynthesizer::resetState()
    309328{
    310     [m_platformSpeechWrapper cancel];
     329    [m_platformSpeechWrapper resetState];
    311330}
    312331
    313332} // namespace WebCore
    314333
    315 #endif // ENABLE(SPEECH_SYNTHESIS) && PLATFORM(IOS_FAMILY)
     334#endif // ENABLE(SPEECH_SYNTHESIS) && PLATFORM(COCOA)
  • trunk/Source/WebKit/ChangeLog

    r286258 r286259  
     12021-11-29  Chris Fleizach  <cfleizach@apple.com>
     2
     3        AX: Unify speech synthesizer platform usage for Mac/iOS
     4        https://bugs.webkit.org/show_bug.cgi?id=231895
     5        <rdar://problem/84372479>
     6
     7        Reviewed by Andres Gonzalez.
     8
     9        Create a new message for resetting speech synthesis state when the DOMWindow changes
     10        but the Page (and its referenced speech synthesis) stays the same.
     11
     12        * UIProcess/WebPageProxy.cpp:
     13        (WebKit::WebPageProxy::speechSynthesisResetState):
     14        * UIProcess/WebPageProxy.h:
     15        * UIProcess/WebPageProxy.messages.in:
     16        * WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp:
     17        (WebKit::WebSpeechSynthesisClient::resetState):
     18        * WebProcess/WebCoreSupport/WebSpeechSynthesisClient.h:
     19
    1202021-11-29  Brent Fulgham  <bfulgham@apple.com>
    221
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r286227 r286259  
    1051610516}
    1051710517
     10518void WebPageProxy::speechSynthesisResetState()
     10519{
     10520    speechSynthesisData().synthesizer->resetState();
     10521}
     10522
    1051810523void WebPageProxy::speechSynthesisPause(CompletionHandler<void()>&& completionHandler)
    1051910524{
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r286227 r286259  
    18191819    void speechSynthesisPause(CompletionHandler<void()>&&);
    18201820    void speechSynthesisResume(CompletionHandler<void()>&&);
     1821    void speechSynthesisResetState();
    18211822#endif
    18221823
  • trunk/Source/WebKit/UIProcess/WebPageProxy.messages.in

    r286227 r286259  
    545545    SpeechSynthesisPause() -> () Async
    546546    SpeechSynthesisResume() -> () Async
     547    SpeechSynthesisResetState()
    547548#endif
    548549
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebSpeechSynthesisClient.cpp

    r284009 r286259  
    5454        return m_page.corePage()->speechSynthesisClient()->observer().get();
    5555    return nullptr;
     56}
     57
     58void WebSpeechSynthesisClient::resetState()
     59{
     60    m_page.send(Messages::WebPageProxy::SpeechSynthesisResetState());
    5661}
    5762
  • trunk/Source/WebKit/WebProcess/WebCoreSupport/WebSpeechSynthesisClient.h

    r248762 r286259  
    5454    void setObserver(WeakPtr<WebCore::SpeechSynthesisClientObserver> observer) override { m_observer = observer; }
    5555    WeakPtr<WebCore::SpeechSynthesisClientObserver> observer() const override { return m_observer; }
     56    void resetState() override;
    5657
    5758    WebCore::SpeechSynthesisClientObserver* corePageObserver() const;
Note: See TracChangeset for help on using the changeset viewer.