Title: [222053] trunk/Source
Revision
222053
Author
aes...@apple.com
Date
2017-09-14 14:23:57 -0700 (Thu, 14 Sep 2017)

Log Message

[Mac] Upstream SpeechSynthesis-related WebKitSystemInterface functions
https://bugs.webkit.org/show_bug.cgi?id=176931

Reviewed by Joseph Pecoraro.

Source/WebCore:

* platform/mac/PlatformSpeechSynthesizerMac.mm:
(WebCore::speechSynthesisGetVoiceIdentifiers):
(WebCore::speechSynthesisGetDefaultVoiceIdentifierForLocale):
(WebCore::PlatformSpeechSynthesizer::initializeVoiceList):
* platform/mac/WebCoreSystemInterface.h:
* platform/mac/WebCoreSystemInterface.mm:

Source/WebCore/PAL:

* PAL.xcodeproj/project.pbxproj:
* pal/spi/mac/SpeechSynthesisSPI.h: Added.

Source/WebKit:

* WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

Source/WebKitLegacy/mac:

* WebCoreSupport/WebSystemInterface.mm:
(InitWebCoreSystemInterface):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (222052 => 222053)


--- trunk/Source/WebCore/ChangeLog	2017-09-14 21:09:15 UTC (rev 222052)
+++ trunk/Source/WebCore/ChangeLog	2017-09-14 21:23:57 UTC (rev 222053)
@@ -1,3 +1,17 @@
+2017-09-14  Andy Estes  <aes...@apple.com>
+
+        [Mac] Upstream SpeechSynthesis-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176931
+
+        Reviewed by Joseph Pecoraro.
+
+        * platform/mac/PlatformSpeechSynthesizerMac.mm:
+        (WebCore::speechSynthesisGetVoiceIdentifiers):
+        (WebCore::speechSynthesisGetDefaultVoiceIdentifierForLocale):
+        (WebCore::PlatformSpeechSynthesizer::initializeVoiceList):
+        * platform/mac/WebCoreSystemInterface.h:
+        * platform/mac/WebCoreSystemInterface.mm:
+
 2017-09-14  Youenn Fablet  <you...@apple.com>
 
         RTCDataChannel connectivity issues in Safari 11

Modified: trunk/Source/WebCore/PAL/ChangeLog (222052 => 222053)


--- trunk/Source/WebCore/PAL/ChangeLog	2017-09-14 21:09:15 UTC (rev 222052)
+++ trunk/Source/WebCore/PAL/ChangeLog	2017-09-14 21:23:57 UTC (rev 222053)
@@ -1,3 +1,13 @@
+2017-09-14  Andy Estes  <aes...@apple.com>
+
+        [Mac] Upstream SpeechSynthesis-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176931
+
+        Reviewed by Joseph Pecoraro.
+
+        * PAL.xcodeproj/project.pbxproj:
+        * pal/spi/mac/SpeechSynthesisSPI.h: Added.
+
 2017-09-13  Andy Estes  <aes...@apple.com>
 
         [CF] Upstream CFNetwork-related WebKitSystemInterface functions

Modified: trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj (222052 => 222053)


--- trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2017-09-14 21:09:15 UTC (rev 222052)
+++ trunk/Source/WebCore/PAL/PAL.xcodeproj/project.pbxproj	2017-09-14 21:23:57 UTC (rev 222053)
@@ -106,6 +106,7 @@
 		A10826F91F576292004772AC /* WebPanel.h in Headers */ = {isa = PBXBuildFile; fileRef = A10826F71F576292004772AC /* WebPanel.h */; };
 		A10826FA1F576292004772AC /* WebPanel.mm in Sources */ = {isa = PBXBuildFile; fileRef = A10826F81F576292004772AC /* WebPanel.mm */; };
 		A10826FE1F58A433004772AC /* NSGraphicsSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A10826FD1F58A433004772AC /* NSGraphicsSPI.h */; };
+		A1175B491F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A1175B481F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h */; };
 		A1F55DCF1F5528EC00EDB75F /* MetadataSPI.h in Headers */ = {isa = PBXBuildFile; fileRef = A1F55DCE1F5528EC00EDB75F /* MetadataSPI.h */; };
 		A30D41211F0DD0EA00B71954 /* KillRing.h in Headers */ = {isa = PBXBuildFile; fileRef = A30D411E1F0DD0EA00B71954 /* KillRing.h */; };
 		A30D41221F0DD0EA00B71954 /* KillRing.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A30D411F1F0DD0EA00B71954 /* KillRing.cpp */; };
@@ -227,6 +228,7 @@
 		A10826F71F576292004772AC /* WebPanel.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = WebPanel.h; sourceTree = "<group>"; };
 		A10826F81F576292004772AC /* WebPanel.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = WebPanel.mm; sourceTree = "<group>"; };
 		A10826FD1F58A433004772AC /* NSGraphicsSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = NSGraphicsSPI.h; sourceTree = "<group>"; };
+		A1175B481F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SpeechSynthesisSPI.h; sourceTree = "<group>"; };
 		A1F55DCE1F5528EC00EDB75F /* MetadataSPI.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = MetadataSPI.h; sourceTree = "<group>"; };
 		A30D411E1F0DD0EA00B71954 /* KillRing.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KillRing.h; sourceTree = "<group>"; };
 		A30D411F1F0DD0EA00B71954 /* KillRing.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = KillRing.cpp; sourceTree = "<group>"; };
@@ -378,6 +380,7 @@
 				0C7785861F45130F00F4EBB6 /* QTKitSPI.h */,
 				A102658A1F56748C00B4C844 /* QuickDrawSPI.h */,
 				0C7785871F45130F00F4EBB6 /* QuickLookMacSPI.h */,
+				A1175B481F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h */,
 				0C7785881F45130F00F4EBB6 /* TUCallSPI.h */,
 			);
 			path = mac;
@@ -535,12 +538,12 @@
 				0C2DA1431F3BEB4900DBC317 /* IOPSLibSPI.h in Headers */,
 				0C2DA1441F3BEB4900DBC317 /* IOReturnSPI.h in Headers */,
 				0C2DA1451F3BEB4900DBC317 /* IOSurfaceSPI.h in Headers */,
-				07377ADC1F5777D90027F16D /* LoggerHelper.h in Headers */,
 				0C2DA1461F3BEB4900DBC317 /* IOTypesSPI.h in Headers */,
 				A30D41211F0DD0EA00B71954 /* KillRing.h in Headers */,
 				0C5AF91C1F43A4C7002EAC02 /* LaunchServicesSPI.h in Headers */,
 				0C2DA1471F3BEB4900DBC317 /* LinkPresentationSPI.h in Headers */,
 				0708AC331F4C874B001F788F /* Logger.h in Headers */,
+				07377ADC1F5777D90027F16D /* LoggerHelper.h in Headers */,
 				0C77858B1F45130F00F4EBB6 /* LookupSPI.h in Headers */,
 				0C2DA1481F3BEB4900DBC317 /* MachVMSPI.h in Headers */,
 				0C5AF91D1F43A4C7002EAC02 /* MediaPlayerSPI.h in Headers */,
@@ -592,6 +595,7 @@
 				A3AB6E561F3D1DDB009C14B1 /* SleepDisabler.h in Headers */,
 				A3AB6E611F3D1E39009C14B1 /* SleepDisablerCocoa.h in Headers */,
 				A3788E981F05B6CE00679425 /* Sound.h in Headers */,
+				A1175B491F6AFF8E00C4B9F0 /* SpeechSynthesisSPI.h in Headers */,
 				0C5AF9211F43A4C7002EAC02 /* SQLite3SPI.h in Headers */,
 				A3AB6E581F3D1DDB009C14B1 /* SystemSleepListener.h in Headers */,
 				A3AB6E641F3D217F009C14B1 /* SystemSleepListenerMac.h in Headers */,

Copied: trunk/Source/WebCore/PAL/pal/spi/mac/SpeechSynthesisSPI.h (from rev 222052, trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm) (0 => 222053)


--- trunk/Source/WebCore/PAL/pal/spi/mac/SpeechSynthesisSPI.h	                        (rev 0)
+++ trunk/Source/WebCore/PAL/pal/spi/mac/SpeechSynthesisSPI.h	2017-09-14 21:23:57 UTC (rev 222053)
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#if USE(APPLE_INTERNAL_SDK)
+
+#include <SpeechSynthesis/SpeechSynthesisPriv.h>
+
+#endif
+
+WTF_EXTERN_C_BEGIN
+
+CFArrayRef CopySpeechSynthesisVoicesForMode(CFTypeRef mode);
+CFStringRef GetIdentifierStringForPreferredVoiceInListWithLocale(CFArrayRef voices, CFLocaleRef);
+
+WTF_EXTERN_C_END

Modified: trunk/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm (222052 => 222053)


--- trunk/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm	2017-09-14 21:09:15 UTC (rev 222052)
+++ trunk/Source/WebCore/platform/mac/PlatformSpeechSynthesizerMac.mm	2017-09-14 21:23:57 UTC (rev 222053)
@@ -30,6 +30,7 @@
 #include "PlatformSpeechSynthesisVoice.h"
 #include "WebCoreSystemInterface.h"
 #include <AppKit/NSSpeechSynthesizer.h>
+#include <pal/spi/mac/SpeechSynthesisSPI.h>
 #include <wtf/RetainPtr.h>
 
 #if ENABLE(SPEECH_SYNTHESIS)
@@ -214,9 +215,25 @@
     [m_platformSpeechWrapper.get() invalidate];
 }
 
+static NSArray *speechSynthesisGetVoiceIdentifiers()
+{
+    // Get all the voices offered by TTS.
+    // By default speech only returns "premium" voices, which does not include all the
+    // international voices. This allows us to offer speech synthesis for all supported languages.
+    return [(NSArray *)CopySpeechSynthesisVoicesForMode((CFArrayRef)@[ @"VoiceGroupDefault", @"VoiceGroupCompact" ]) autorelease];
+}
+
+static NSString *speechSynthesisGetDefaultVoiceIdentifierForLocale(NSLocale *userLocale)
+{
+    if (!userLocale)
+        return nil;
+
+    return (NSString *)GetIdentifierStringForPreferredVoiceInListWithLocale((CFArrayRef)speechSynthesisGetVoiceIdentifiers(), (CFLocaleRef)userLocale);
+}
+
 void PlatformSpeechSynthesizer::initializeVoiceList()
 {
-    NSArray *availableVoices = wkSpeechSynthesisGetVoiceIdentifiers();
+    NSArray *availableVoices = speechSynthesisGetVoiceIdentifiers();
     NSUInteger count = [availableVoices count];
     for (NSUInteger k = 0; k < count; k++) {
         NSString *voiceName = [availableVoices objectAtIndex:k];
@@ -226,7 +243,7 @@
         NSString *name = [attributes objectForKey:NSVoiceName];
         NSString *language = [attributes objectForKey:NSVoiceLocaleIdentifier];
         NSLocale *locale = [[NSLocale alloc] initWithLocaleIdentifier:language];
-        NSString *defaultVoiceURI = wkSpeechSynthesisGetDefaultVoiceIdentifierForLocale(locale);
+        NSString *defaultVoiceURI = speechSynthesisGetDefaultVoiceIdentifierForLocale(locale);
         [locale release];
 
         // Change to BCP-47 format as defined by spec.

Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h (222052 => 222053)


--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h	2017-09-14 21:09:15 UTC (rev 222052)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.h	2017-09-14 21:23:57 UTC (rev 222053)
@@ -143,11 +143,6 @@
 
 extern NSCursor *(*wkCursor)(const char*);
 #endif // !PLATFORM(IOS)
-    
-#if !PLATFORM(IOS)
-extern NSArray *(*wkSpeechSynthesisGetVoiceIdentifiers)(void);
-extern NSString *(*wkSpeechSynthesisGetDefaultVoiceIdentifierForLocale)(NSLocale *);
-#endif // !PLATFORM(IOS)
 
 #if PLATFORM(IOS)
 extern void (*wkSetLayerContentsScale)(CALayer *);

Modified: trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm (222052 => 222053)


--- trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm	2017-09-14 21:09:15 UTC (rev 222052)
+++ trunk/Source/WebCore/platform/mac/WebCoreSystemInterface.mm	2017-09-14 21:23:57 UTC (rev 222053)
@@ -48,10 +48,6 @@
 
 NSCursor *(*wkCursor)(const char*);
 
-NSArray *(*wkSpeechSynthesisGetVoiceIdentifiers)(void);
-NSString *(*wkSpeechSynthesisGetDefaultVoiceIdentifierForLocale)(NSLocale *);
-
-
 #if !PLATFORM(IOS)
 CGFloat (*wkNSElasticDeltaForTimeDelta)(CGFloat initialPosition, CGFloat initialVelocity, CGFloat elapsedTime);
 CGFloat (*wkNSElasticDeltaForReboundDelta)(CGFloat delta);

Modified: trunk/Source/WebKit/ChangeLog (222052 => 222053)


--- trunk/Source/WebKit/ChangeLog	2017-09-14 21:09:15 UTC (rev 222052)
+++ trunk/Source/WebKit/ChangeLog	2017-09-14 21:23:57 UTC (rev 222053)
@@ -1,3 +1,13 @@
+2017-09-14  Andy Estes  <aes...@apple.com>
+
+        [Mac] Upstream SpeechSynthesis-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176931
+
+        Reviewed by Joseph Pecoraro.
+
+        * WebProcess/WebCoreSupport/mac/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2017-09-14  Ryan Haddad  <ryanhad...@apple.com>
 
         Unreviewed, rolling out r222033.

Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm (222052 => 222053)


--- trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm	2017-09-14 21:09:15 UTC (rev 222052)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebSystemInterface.mm	2017-09-14 21:23:57 UTC (rev 222053)
@@ -45,8 +45,6 @@
         INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard);
         INIT(CopyDefaultSearchProviderDisplayName);
         INIT(Cursor);
-        INIT(SpeechSynthesisGetVoiceIdentifiers);
-        INIT(SpeechSynthesisGetDefaultVoiceIdentifierForLocale);
         INIT(NSElasticDeltaForTimeDelta);
         INIT(NSElasticDeltaForReboundDelta);
         INIT(NSReboundDeltaForElasticDelta);

Modified: trunk/Source/WebKitLegacy/mac/ChangeLog (222052 => 222053)


--- trunk/Source/WebKitLegacy/mac/ChangeLog	2017-09-14 21:09:15 UTC (rev 222052)
+++ trunk/Source/WebKitLegacy/mac/ChangeLog	2017-09-14 21:23:57 UTC (rev 222053)
@@ -1,3 +1,13 @@
+2017-09-14  Andy Estes  <aes...@apple.com>
+
+        [Mac] Upstream SpeechSynthesis-related WebKitSystemInterface functions
+        https://bugs.webkit.org/show_bug.cgi?id=176931
+
+        Reviewed by Joseph Pecoraro.
+
+        * WebCoreSupport/WebSystemInterface.mm:
+        (InitWebCoreSystemInterface):
+
 2017-09-14  Yusuke Suzuki  <utatane....@gmail.com>
 
         [JSC] Add PrivateSymbolMode::{Include,Exclude} for PropertyNameArray

Modified: trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm (222052 => 222053)


--- trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm	2017-09-14 21:09:15 UTC (rev 222052)
+++ trunk/Source/WebKitLegacy/mac/WebCoreSupport/WebSystemInterface.mm	2017-09-14 21:23:57 UTC (rev 222053)
@@ -54,8 +54,6 @@
     INIT(ExecutableWasLinkedOnOrBeforeSnowLeopard);
     INIT(CopyDefaultSearchProviderDisplayName);
     INIT(Cursor);
-    INIT(SpeechSynthesisGetVoiceIdentifiers);
-    INIT(SpeechSynthesisGetDefaultVoiceIdentifierForLocale);
 #endif
 
 #if !PLATFORM(IOS)
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to