[Cocoa] Build with UChar as char16_t even in builds that use Apple's internal SDK
authordarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Apr 2020 04:34:31 +0000 (04:34 +0000)
committerdarin@apple.com <darin@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 23 Apr 2020 04:34:31 +0000 (04:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=210845

Reviewed by Anders Carlsson.

.:

* Source/cmake/OptionsCommon.cmake: Move ICU-configuring macros to Platform.h.
* Source/cmake/OptionsJSCOnly.cmake: Ditto.
* Source/cmake/OptionsMac.cmake: Ditto.

Source/JavaScriptCore:

* Configurations/Base.xcconfig: Move ICU-configuring macros to Platform.h.

Source/WebCore:

* Configurations/WebCore.xcconfig: Move ICU-configuring macros to Platform.h.

* Modules/websockets/WebSocket.cpp:
(WebCore::WebSocket::connect): Get rid of an obsolete cast to unsigned to work
around uint16_t not being treated as a number by makeString.

* rendering/svg/SVGTextLayoutEngineBaseline.cpp:
(WebCore::SVGTextLayoutEngineBaseline::calculateGlyphOrientationAngle const):
Remove deprecated U_EA_COUNT.

Source/WebKit:

* Configurations/BaseTarget.xcconfig: Move ICU-configuring macros to Platform.h.

* Platform/unix/EnvironmentUtilities.h: Removed unneeded includes.
This sidesteps a problem with Apple's internal InstallAPI tool that happens
if StringView.h is included and Platform.h is not included first.

* UIProcess/API/cpp/WKRetainPtr.h: Removed unneeded includes, and used
#pragma once.

* UIProcess/Cocoa/PreferenceObserver.h: Moved most things out of the header,
since they don't need to be there.
* UIProcess/Cocoa/PreferenceObserver.mm: Moved them here including using a
class extension for the data member of WKPreferenceObserver.

* UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.h:
Removed unneeded WTF prefix.

Source/WebKitLegacy/mac:

* Configurations/WebKitLegacy.xcconfig: Move ICU-configuring macros to Platform.h.

Source/WTF:

* Configurations/Base.xcconfig: Move ICU-configuring macros to Platform.h.

* wtf/Platform.h: Set macros here. The file says not to put things like this in it,
but in practice this is the right place to put something that we need set consistently
for all the WebKit projects.
- U_HIDE_DEPRECATED_API, to make sure we don't use it by accident.
- U_SHOW_CPLUSPLUS_API=0, to make sure we don't use it by accident.
- UCHAR_TYPE=char16_t when compiling C++, which is the default on most platforms,
  but not the default in Apple's internal SDK.
- U_DISABLE_RENAMING when building on Apple platforms, important so we can link
  to an older version of ICU and still load with a newer version.

* wtf/URL.cpp:
(WTF::URL::hostAndPort const): Get rid of an obsolete cast to unsigned to work
around uint16_t not being treated as a number by makeString.

* wtf/URLHelpers.cpp: Rework to not use deprecated USCRIPT_CODE_LIMIT.
(WTF::URLHelpers::whiteListIDNScript): Added overloads.
(WTF::URLHelpers::initializeDefaultIDNScriptWhiteList): Use an array of
UScriptCode instead of an array of strings.
(WTF::URLHelpers::allCharactersInIDNScriptWhiteList): Updated for the above.

* wtf/cocoa/NSURLExtras.mm:
(WTF::decodePercentEscapes): Use createCFString instead of converting to NString
and then typecasting.
(WTF::URLByTruncatingOneCharacterBeforeComponent): Updated to use a constexpr
instead of a macro.
(WTF::dataForURLComponentType): Ditto.
(WTF::URLByRemovingComponentAndSubsequentCharacter): Ditto.
(WTF::originalURLData): Ditto.

Tools:

* TestWebKitAPI/Tests/WTF/StringConcatenate.cpp:
(TestWebKitAPI::TEST): Get rid of an obsolete cast to unsigned to work
around uint16_t not being treated as a number by makeString.
* TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm:
(TestWebKitAPI::TEST): Ditto.
* TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm:
(TestWebKitAPI::TEST): Ditto.
* TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
(TestWebKitAPI::TEST): Ditto.

* TestWebKitAPI/Tests/WebKit/EnvironmentUtilitiesTest.cpp:
Add an include needed since EvironmentUtilities.h now includes less.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@260554 268f45cc-cd09-0410-ab3c-d52691b4dbfc

31 files changed:
ChangeLog
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/Configurations/Base.xcconfig
Source/WTF/ChangeLog
Source/WTF/Configurations/Base.xcconfig
Source/WTF/wtf/Platform.h
Source/WTF/wtf/URL.cpp
Source/WTF/wtf/URLHelpers.cpp
Source/WTF/wtf/cocoa/NSURLExtras.mm
Source/WebCore/ChangeLog
Source/WebCore/Configurations/WebCore.xcconfig
Source/WebCore/Modules/websockets/WebSocket.cpp
Source/WebCore/rendering/svg/SVGTextLayoutEngineBaseline.cpp
Source/WebKit/ChangeLog
Source/WebKit/Configurations/BaseTarget.xcconfig
Source/WebKit/Platform/unix/EnvironmentUtilities.h
Source/WebKit/UIProcess/API/cpp/WKRetainPtr.h
Source/WebKit/UIProcess/Cocoa/PreferenceObserver.h
Source/WebKit/UIProcess/Cocoa/PreferenceObserver.mm
Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.h
Source/WebKitLegacy/mac/ChangeLog
Source/WebKitLegacy/mac/Configurations/WebKitLegacy.xcconfig
Source/cmake/OptionsCommon.cmake
Source/cmake/OptionsJSCOnly.cmake
Source/cmake/OptionsMac.cmake
Tools/ChangeLog
Tools/TestWebKitAPI/Tests/WTF/StringConcatenate.cpp
Tools/TestWebKitAPI/Tests/WebKit/EnvironmentUtilitiesTest.cpp
Tools/TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm
Tools/TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm

index ce9d0a1..2da0144 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2020-04-22  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Build with UChar as char16_t even in builds that use Apple's internal SDK
+        https://bugs.webkit.org/show_bug.cgi?id=210845
+
+        Reviewed by Anders Carlsson.
+
+        * Source/cmake/OptionsCommon.cmake: Move ICU-configuring macros to Platform.h.
+        * Source/cmake/OptionsJSCOnly.cmake: Ditto.
+        * Source/cmake/OptionsMac.cmake: Ditto.
+
 2020-04-22  Don Olmstead  <don.olmstead@sony.com>
 
         [CMake] Use WEBKIT_EXECUTABLE in WebKitTestRunner
index ce0e3f8..af9261a 100644 (file)
@@ -1,3 +1,12 @@
+2020-04-22  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Build with UChar as char16_t even in builds that use Apple's internal SDK
+        https://bugs.webkit.org/show_bug.cgi?id=210845
+
+        Reviewed by Anders Carlsson.
+
+        * Configurations/Base.xcconfig: Move ICU-configuring macros to Platform.h.
+
 2020-04-22  Yusuke Suzuki  <ysuzuki@apple.com>
 
         [JSC] branchIfBigInt32 can use BigInt32Mask and remove branchIfNumber filter
index 5aeba7f..769cc41 100644 (file)
@@ -68,7 +68,7 @@ GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
 GCC_NO_COMMON_BLOCKS = YES;
 GCC_OBJC_CALL_CXX_CDTORS = YES;
 GCC_PRECOMPILE_PREFIX_HEADER = YES;
-GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) U_HIDE_DEPRECATED_API U_DISABLE_RENAMING=1 U_SHOW_CPLUSPLUS_API=0 $(inherited);
+GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) $(inherited);
 GCC_STRICT_ALIASING = YES;
 GCC_THREADSAFE_STATICS = NO;
 GCC_TREAT_WARNINGS_AS_ERRORS = YES;
index 8bc82f1..bc7d03f 100644 (file)
@@ -1,3 +1,41 @@
+2020-04-22  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Build with UChar as char16_t even in builds that use Apple's internal SDK
+        https://bugs.webkit.org/show_bug.cgi?id=210845
+
+        Reviewed by Anders Carlsson.
+
+        * Configurations/Base.xcconfig: Move ICU-configuring macros to Platform.h.
+
+        * wtf/Platform.h: Set macros here. The file says not to put things like this in it,
+        but in practice this is the right place to put something that we need set consistently
+        for all the WebKit projects.
+        - U_HIDE_DEPRECATED_API, to make sure we don't use it by accident.
+        - U_SHOW_CPLUSPLUS_API=0, to make sure we don't use it by accident.
+        - UCHAR_TYPE=char16_t when compiling C++, which is the default on most platforms,
+          but not the default in Apple's internal SDK.
+        - U_DISABLE_RENAMING when building on Apple platforms, important so we can link
+          to an older version of ICU and still load with a newer version.
+
+        * wtf/URL.cpp:
+        (WTF::URL::hostAndPort const): Get rid of an obsolete cast to unsigned to work
+        around uint16_t not being treated as a number by makeString.
+
+        * wtf/URLHelpers.cpp: Rework to not use deprecated USCRIPT_CODE_LIMIT.
+        (WTF::URLHelpers::whiteListIDNScript): Added overloads.
+        (WTF::URLHelpers::initializeDefaultIDNScriptWhiteList): Use an array of
+        UScriptCode instead of an array of strings.
+        (WTF::URLHelpers::allCharactersInIDNScriptWhiteList): Updated for the above.
+
+        * wtf/cocoa/NSURLExtras.mm:
+        (WTF::decodePercentEscapes): Use createCFString instead of converting to NString
+        and then typecasting.
+        (WTF::URLByTruncatingOneCharacterBeforeComponent): Updated to use a constexpr
+        instead of a macro.
+        (WTF::dataForURLComponentType): Ditto.
+        (WTF::URLByRemovingComponentAndSubsequentCharacter): Ditto.
+        (WTF::originalURLData): Ditto.
+
 2020-04-22  Claudio Saavedra  <csaavedra@igalia.com>
 
         [GTK4] Several fixes to GdkEvent APIs for GTK4
index f0a6f19..6ce7330 100644 (file)
@@ -69,7 +69,7 @@ GCC_INLINES_ARE_PRIVATE_EXTERN = YES;
 GCC_NO_COMMON_BLOCKS = YES;
 GCC_OBJC_CALL_CXX_CDTORS = YES;
 GCC_PRECOMPILE_PREFIX_HEADER = YES;
-GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) U_DISABLE_RENAMING=1 U_SHOW_CPLUSPLUS_API=0 $(inherited);
+GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(inherited);
 GCC_STRICT_ALIASING = YES;
 GCC_THREADSAFE_STATICS = NO;
 GCC_TREAT_WARNINGS_AS_ERRORS = YES;
index 0ed821e..f7a4cb5 100644 (file)
 #define __ASSERT_MACROS_DEFINE_VERSIONS_WITHOUT_UNDERSCORES 0
 #endif
 
+/* FIXME: This does not belong in Platform.h and should instead be included in another mechanism (compiler option, prefix header, config.h, etc) */
+/* ICU configuration. Some of these match ICU defaults on some platforms, but we would like them consistently set everywhere we build WebKit. */
+#define U_HIDE_DEPRECATED_API 1
+#define U_SHOW_CPLUSPLUS_API 0
+#ifdef __cplusplus
+#define UCHAR_TYPE char16_t
+#endif
+#if PLATFORM(COCOA)
+#define U_DISABLE_RENAMING 1
+#endif
+
 #if COMPILER(MSVC)
 #undef __STDC_FORMAT_MACROS
 #define __STDC_FORMAT_MACROS
index 2c504bc..610d1c4 100644 (file)
@@ -149,7 +149,7 @@ Optional<uint16_t> URL::port() const
 String URL::hostAndPort() const
 {
     if (auto port = this->port())
-        return makeString(host(), ':', static_cast<unsigned>(port.value()));
+        return makeString(host(), ':', port.value());
     return host().toString();
 }
 
index 5e0ff10..36f8089 100644 (file)
@@ -42,15 +42,23 @@ namespace URLHelpers {
 
 // Needs to be big enough to hold an IDN-encoded name.
 // For host names bigger than this, we won't do IDN encoding, which is almost certainly OK.
-const unsigned hostNameBufferLength = 2048;
-const unsigned urlBytesBufferLength = 2048;
+constexpr unsigned hostNameBufferLength = 2048;
+constexpr unsigned urlBytesBufferLength = 2048;
 
-static uint32_t IDNScriptWhiteList[(USCRIPT_CODE_LIMIT + 31) / 32];
+// This needs to be higher than the UScriptCode for any of the scripts on the IDN whitelist.
+// At one point we used USCRIPT_CODE_LIMIT from ICU, but there are two reasons not to use it.
+// 1) ICU considers it deprecated, so by setting U_HIDE_DEPRECATED we can't see it.
+// 2) No good reason to limit ourselves to scripts that existed in the ICU headers when
+//    WebKit was compiled.
+// This is only really important for platforms that load an external ICU whitelist.
+// Not important for the compiled-in one.
+constexpr auto scriptCodeLimit = static_cast<UScriptCode>(256);
+
+static uint32_t IDNScriptWhiteList[(scriptCodeLimit + 31) / 32];
 
 #if !PLATFORM(COCOA)
 
-// Cocoa has an implementation that uses a whitelist in /Library or ~/Library,
-// if it exists.
+// Cocoa has an implementation that uses a whitelist in /Library or ~/Library, if it exists.
 void loadIDNScriptWhiteList()
 {
     static std::once_flag flag;
@@ -256,42 +264,51 @@ static bool isLookalikeCharacter(const Optional<UChar32>& previousCodePoint, UCh
     }
 }
 
-void whiteListIDNScript(const char* scriptName)
+static void whiteListIDNScript(int32_t script)
 {
-    int32_t script = u_getPropertyValueEnum(UCHAR_SCRIPT, scriptName);
-    if (script >= 0 && script < USCRIPT_CODE_LIMIT) {
+    if (script >= 0 && script < scriptCodeLimit) {
         size_t index = script / 32;
         uint32_t mask = 1 << (script % 32);
         IDNScriptWhiteList[index] |= mask;
     }
 }
 
+static void whiteListIDNScript(UScriptCode script)
+{
+    whiteListIDNScript(static_cast<int32_t>(script));
+}
+
+void whiteListIDNScript(const char* scriptName)
+{
+    whiteListIDNScript(u_getPropertyValueEnum(UCHAR_SCRIPT, scriptName));
+}
+
 void initializeDefaultIDNScriptWhiteList()
 {
-    const char* defaultIDNScriptWhiteList[20] = {
-        "Common",
-        "Inherited",
-        "Arabic",
-        "Armenian",
-        "Bopomofo",
-        "Canadian_Aboriginal",
-        "Devanagari",
-        "Deseret",
-        "Gujarati",
-        "Gurmukhi",
-        "Hangul",
-        "Han",
-        "Hebrew",
-        "Hiragana",
-        "Katakana_Or_Hiragana",
-        "Katakana",
-        "Latin",
-        "Tamil",
-        "Thai",
-        "Yi",
+    constexpr UScriptCode defaultIDNScriptWhiteList[] = {
+        USCRIPT_COMMON,
+        USCRIPT_INHERITED,
+        USCRIPT_ARABIC,
+        USCRIPT_ARMENIAN,
+        USCRIPT_BOPOMOFO,
+        USCRIPT_CANADIAN_ABORIGINAL,
+        USCRIPT_DEVANAGARI,
+        USCRIPT_DESERET,
+        USCRIPT_GUJARATI,
+        USCRIPT_GURMUKHI,
+        USCRIPT_HANGUL,
+        USCRIPT_HAN,
+        USCRIPT_HEBREW,
+        USCRIPT_HIRAGANA,
+        USCRIPT_KATAKANA_OR_HIRAGANA,
+        USCRIPT_KATAKANA,
+        USCRIPT_LATIN,
+        USCRIPT_TAMIL,
+        USCRIPT_THAI,
+        USCRIPT_YI,
     };
-    for (const char* scriptName : defaultIDNScriptWhiteList)
-        whiteListIDNScript(scriptName);
+    for (auto script : defaultIDNScriptWhiteList)
+        whiteListIDNScript(script);
 }
 
 static bool allCharactersInIDNScriptWhiteList(const UChar* buffer, int32_t length)
@@ -312,7 +329,7 @@ static bool allCharactersInIDNScriptWhiteList(const UChar* buffer, int32_t lengt
             LOG_ERROR("got negative number for script code from ICU: %d", script);
             return false;
         }
-        if (script >= USCRIPT_CODE_LIMIT)
+        if (script >= scriptCodeLimit)
             return false;
 
         size_t index = script / 32;
index 47dee62..4631f27 100644 (file)
 #import <wtf/Vector.h>
 #import <wtf/cf/CFURLExtras.h>
 
-#define URL_BYTES_BUFFER_LENGTH 2048
-
 namespace WTF {
 
 using namespace URLHelpers;
 
+constexpr unsigned urlBytesBufferLength = 2048;
+
 static BOOL readIDNScriptWhiteListFile(NSString *filename)
 {
     if (!filename)
@@ -94,13 +94,10 @@ void loadIDNScriptWhiteList()
     
 static String decodePercentEscapes(const String& string)
 {
-    NSString *substring = (NSString *)string;
-    substring = CFBridgingRelease(CFURLCreateStringByReplacingPercentEscapes(nullptr, (CFStringRef)substring, CFSTR("")));
-
+    NSString *substring = CFBridgingRelease(CFURLCreateStringByReplacingPercentEscapes(nullptr, string.createCFString().get(), CFSTR("")));
     if (!substring)
         return string;
-
-    return (String)substring;
+    return substring;
 }
 
 NSString *decodeHostName(NSString *string)
@@ -135,7 +132,7 @@ NSURL *URLByTruncatingOneCharacterBeforeComponent(NSURL *URL, CFURLComponentType
     if (fragRg.location == kCFNotFound)
         return URL;
 
-    Vector<UInt8, URL_BYTES_BUFFER_LENGTH> urlBytes(URL_BYTES_BUFFER_LENGTH);
+    Vector<UInt8, urlBytesBufferLength> urlBytes(urlBytesBufferLength);
     CFIndex numBytes = CFURLGetBytes((__bridge CFURLRef)URL, urlBytes.data(), urlBytes.size());
     if (numBytes == -1) {
         numBytes = CFURLGetBytes((__bridge CFURLRef)URL, nullptr, 0);
@@ -269,7 +266,7 @@ static BOOL hasQuestionMarkOnlyQueryString(NSURL *URL)
 
 NSData *dataForURLComponentType(NSURL *URL, CFURLComponentType componentType)
 {
-    Vector<UInt8, URL_BYTES_BUFFER_LENGTH> allBytesBuffer(URL_BYTES_BUFFER_LENGTH);
+    Vector<UInt8, urlBytesBufferLength> allBytesBuffer(urlBytesBufferLength);
     CFIndex bytesFilled = CFURLGetBytes((__bridge CFURLRef)URL, allBytesBuffer.data(), allBytesBuffer.size());
     if (bytesFilled == -1) {
         CFIndex bytesToAllocate = CFURLGetBytes((__bridge CFURLRef)URL, nullptr, 0);
@@ -325,7 +322,7 @@ static NSURL *URLByRemovingComponentAndSubsequentCharacter(NSURL *URL, CFURLComp
     // Remove one subsequent character.
     range.length++;
 
-    Vector<UInt8, URL_BYTES_BUFFER_LENGTH> buffer(URL_BYTES_BUFFER_LENGTH);
+    Vector<UInt8, urlBytesBufferLength> buffer(urlBytesBufferLength);
     CFIndex numBytes = CFURLGetBytes((__bridge CFURLRef)URL, buffer.data(), buffer.size());
     if (numBytes == -1) {
         numBytes = CFURLGetBytes((__bridge CFURLRef)URL, nullptr, 0);
@@ -355,8 +352,8 @@ NSURL *URLByRemovingUserInfo(NSURL *URL)
 
 NSData *originalURLData(NSURL *URL)
 {
-    UInt8 *buffer = (UInt8 *)malloc(URL_BYTES_BUFFER_LENGTH);
-    CFIndex bytesFilled = CFURLGetBytes((__bridge CFURLRef)URL, buffer, URL_BYTES_BUFFER_LENGTH);
+    UInt8 *buffer = (UInt8 *)malloc(urlBytesBufferLength);
+    CFIndex bytesFilled = CFURLGetBytes((__bridge CFURLRef)URL, buffer, urlBytesBufferLength);
     if (bytesFilled == -1) {
         CFIndex bytesToAllocate = CFURLGetBytes((__bridge CFURLRef)URL, nullptr, 0);
         buffer = (UInt8 *)realloc(buffer, bytesToAllocate);
index eeb2a56..df7a295 100644 (file)
@@ -1,3 +1,20 @@
+2020-04-22  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Build with UChar as char16_t even in builds that use Apple's internal SDK
+        https://bugs.webkit.org/show_bug.cgi?id=210845
+
+        Reviewed by Anders Carlsson.
+
+        * Configurations/WebCore.xcconfig: Move ICU-configuring macros to Platform.h.
+
+        * Modules/websockets/WebSocket.cpp:
+        (WebCore::WebSocket::connect): Get rid of an obsolete cast to unsigned to work
+        around uint16_t not being treated as a number by makeString.
+
+        * rendering/svg/SVGTextLayoutEngineBaseline.cpp:
+        (WebCore::SVGTextLayoutEngineBaseline::calculateGlyphOrientationAngle const):
+        Remove deprecated U_EA_COUNT.
+
 2020-04-22  Andres Gonzalez  <andresg_22@apple.com>
 
         Add logging to core accessibility.
index a0add2a..6cf3c41 100644 (file)
@@ -27,7 +27,7 @@
 #include "WebKitTargetConditionals.xcconfig"
 
 GCC_PREFIX_HEADER = WebCorePrefix.h;
-GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) BUILDING_WEBKIT U_DISABLE_RENAMING=1 U_SHOW_CPLUSPLUS_API=0 GL_SILENCE_DEPRECATION=1 GLES_SILENCE_DEPRECATION=1 $(inherited);
+GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) BUILDING_WEBKIT GL_SILENCE_DEPRECATION=1 GLES_SILENCE_DEPRECATION=1 $(inherited);
 
 WK_PRIVATE_FRAMEWORKS_DIR = $(WK_PRIVATE_FRAMEWORKS_DIR_$(USE_INTERNAL_SDK));
 WK_PRIVATE_FRAMEWORKS_DIR_[sdk=iphone*] = $(PROJECT_DIR)/../../WebKitLibraries/WebKitPrivateFrameworkStubs/iOS/$(WK_TARGET_IOS_VERSION_MAJOR);
index be6d945..89f3d84 100644 (file)
@@ -257,7 +257,7 @@ ExceptionOr<void> WebSocket::connect(const String& url, const Vector<String>& pr
     if (!portAllowed(m_url)) {
         String message;
         if (m_url.port())
-            message = makeString("WebSocket port ", static_cast<unsigned>(m_url.port().value()), " blocked");
+            message = makeString("WebSocket port ", m_url.port().value(), " blocked");
         else
             message = "WebSocket without port blocked"_s;
         context.addConsoleMessage(MessageSource::JS, MessageLevel::Error, message);
index ed57eab..7be20d8 100644 (file)
@@ -162,9 +162,6 @@ float SVGTextLayoutEngineBaseline::calculateGlyphOrientationAngle(bool isVertica
         case U_EA_FULLWIDTH:
         case U_EA_WIDE:
             return 0;
-        case U_EA_COUNT:
-            ASSERT_NOT_REACHED();
-            break;
         }
         ASSERT_NOT_REACHED();
         break;
index 0b0d728..a2bcad2 100644 (file)
@@ -1,3 +1,27 @@
+2020-04-22  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Build with UChar as char16_t even in builds that use Apple's internal SDK
+        https://bugs.webkit.org/show_bug.cgi?id=210845
+
+        Reviewed by Anders Carlsson.
+
+        * Configurations/BaseTarget.xcconfig: Move ICU-configuring macros to Platform.h.
+
+        * Platform/unix/EnvironmentUtilities.h: Removed unneeded includes.
+        This sidesteps a problem with Apple's internal InstallAPI tool that happens
+        if StringView.h is included and Platform.h is not included first.
+
+        * UIProcess/API/cpp/WKRetainPtr.h: Removed unneeded includes, and used
+        #pragma once.
+
+        * UIProcess/Cocoa/PreferenceObserver.h: Moved most things out of the header,
+        since they don't need to be there.
+        * UIProcess/Cocoa/PreferenceObserver.mm: Moved them here including using a
+        class extension for the data member of WKPreferenceObserver.
+
+        * UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.h:
+        Removed unneeded WTF prefix.
+
 2020-04-22  Nikos Mouchtaris  <nmouchtaris@apple.com>
 
         Soft link QuickLookThumbnailing framework
index 6f28f77..331abaf 100644 (file)
@@ -36,7 +36,7 @@ FRAMEWORK_SEARCH_PATHS[sdk=iphone*] = $(FRAMEWORK_SEARCH_PATHS_base) $(WK_PRIVAT
 SYSTEM_FRAMEWORK_SEARCH_PATHS = $(inherited) $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Frameworks;
 
 GCC_PREFIX_HEADER = WebKit2Prefix.h;
-GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) $(WK_CORE_PREDICTION_DEFINES) U_HIDE_DEPRECATED_API U_DISABLE_RENAMING=1 U_SHOW_CPLUSPLUS_API=0 FRAMEWORK_NAME=WebKit;
+GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) $(WK_CORE_PREDICTION_DEFINES) FRAMEWORK_NAME=WebKit;
 WEBKITADDITIONS_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions $(SDKROOT)/usr/local/include/WebKitAdditions;
 LIBWEBRTC_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/webrtc $(SDKROOT)/usr/local/include/webrtc;
 
index e828d74..1c0d3a5 100644 (file)
@@ -27,8 +27,7 @@
 #pragma once
 
 #include "WKDeclarationSpecifiers.h"
-#include <wtf/text/StringView.h>
-#include <wtf/text/WTFString.h>
+#include <wtf/Forward.h>
 
 namespace WebKit {
 
index 863ed96..bcc7fdf 100644 (file)
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WKRetainPtr_h
-#define WKRetainPtr_h
+#pragma once
 
 #include <WebKit/WKType.h>
 #include <algorithm>
-#include <wtf/GetPtr.h>
-#include <wtf/HashFunctions.h>
 #include <wtf/HashTraits.h>
-#include <wtf/RefPtr.h>
 
 namespace WebKit {
 
@@ -263,7 +259,10 @@ using WebKit::retainWK;
 
 namespace WTF {
 
-template <typename T> struct IsSmartPtr<WKRetainPtr<T>> {
+template<typename> struct IsSmartPtr;
+template<typename> struct DefaultHash;
+
+template<typename T> struct IsSmartPtr<WKRetainPtr<T>> {
     WTF_INTERNAL static const bool value = true;
 };
 
@@ -280,5 +279,3 @@ template<typename P> struct HashTraits<WKRetainPtr<P>> : SimpleClassHashTraits<W
 };
 
 } // namespace WTF
-
-#endif // WKRetainPtr_h
index 2c3e91e..4f4472a 100644 (file)
 * THE POSSIBILITY OF SUCH DAMAGE.
 */
 
-#import <wtf/RetainPtr.h>
-#import <wtf/Vector.h>
-
-@class WKPreferenceObserver;
-
-__attribute__((visibility("default")))
-@interface WKUserDefaults : NSUserDefaults {
-@private
-    NSString *m_suiteName;
-@public
-    WKPreferenceObserver *m_observer;
-}
-@end
-
 __attribute__((visibility("default")))
-@interface WKPreferenceObserver : NSObject {
-@private
-    Vector<RetainPtr<WKUserDefaults>> m_userDefaults;
-}
+@interface WKPreferenceObserver : NSObject
 + (id)sharedInstance;
 - (void)preferenceDidChange:(NSString *)domain key:(NSString *)key encodedValue:(NSString *)encodedValue;
 @end
index 5f15ad8..316b2f3 100644 (file)
 #import "WebProcessPool.h"
 #import <pal/spi/cocoa/NSUserDefaultsSPI.h>
 
+@interface WKUserDefaults : NSUserDefaults {
+@private
+    NSString *m_suiteName;
+@public
+    WKPreferenceObserver *m_observer;
+}
+@end
+
+@interface WKPreferenceObserver () {
+@private
+    Vector<RetainPtr<WKUserDefaults>> m_userDefaults;
+}
+@end
+
 @implementation WKUserDefaults
 
 - (void)_notifyObserversOfChangeFromValuesForKeys:(NSDictionary<NSString *, id> *)oldValues toValuesForKeys:(NSDictionary<NSString *, id> *)newValues
index ebea319..2734698 100644 (file)
@@ -31,8 +31,8 @@
 namespace WebKit {
 
 struct FullscreenTouchSecheuristicParameters {
-    WTF::Seconds rampUpSpeed;
-    WTF::Seconds rampDownSpeed;
+    Seconds rampUpSpeed;
+    Seconds rampDownSpeed;
     double xWeight;
     double yWeight;
     double gamma;
index 81089df..4a3afde 100644 (file)
@@ -1,5 +1,14 @@
 2020-04-22  Darin Adler  <darin@apple.com>
 
+        [Cocoa] Build with UChar as char16_t even in builds that use Apple's internal SDK
+        https://bugs.webkit.org/show_bug.cgi?id=210845
+
+        Reviewed by Anders Carlsson.
+
+        * Configurations/WebKitLegacy.xcconfig: Move ICU-configuring macros to Platform.h.
+
+2020-04-22  Darin Adler  <darin@apple.com>
+
         [Cocoa] REGRESSION (r260485): Crash in Legacy WebKit createMenu item function (reproducible under Asan)
         https://bugs.webkit.org/show_bug.cgi?id=210888
 
index be8f48d..8a49162 100644 (file)
@@ -49,7 +49,7 @@ OTHER_CFLAGS_COCOA_TOUCH_NO = -iframework $(SDKROOT)$(SYSTEM_LIBRARY_DIR)/Framew
 OTHER_CPLUSPLUSFLAGS = $(inherited) $(OTHER_CFLAGS_COCOA_TOUCH);
 
 GCC_PREFIX_HEADER = mac/WebKitPrefix.h;
-GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) BUILDING_WEBKIT U_HIDE_DEPRECATED_API U_DISABLE_RENAMING=1 U_SHOW_CPLUSPLUS_API=0 FRAMEWORK_NAME=WebKitLegacy $(inherited);
+GCC_PREPROCESSOR_DEFINITIONS = $(DEBUG_DEFINES) $(FEATURE_DEFINES) BUILDING_WEBKIT FRAMEWORK_NAME=WebKitLegacy $(inherited);
 
 WEBKITADDITIONS_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/WebKitAdditions $(SDKROOT)/usr/local/include/WebKitAdditions;
 LIBWEBRTC_HEADER_SEARCH_PATHS = $(BUILT_PRODUCTS_DIR)/usr/local/include/webrtc $(SDKROOT)/usr/local/include/webrtc;
index 93fbe20..ea13624 100644 (file)
@@ -180,5 +180,3 @@ check_type_size("__int128_t" INT128_VALUE)
 if (HAVE_INT128_VALUE)
   SET_AND_EXPOSE_TO_BUILD(HAVE_INT128_T INT128_VALUE)
 endif ()
-
-add_definitions(-DU_SHOW_CPLUSPLUS_API=0)
index 05b858d..23446d7 100644 (file)
@@ -95,7 +95,4 @@ else ()
     SET_AND_EXPOSE_TO_BUILD(WTF_DEFAULT_EVENT_LOOP 0)
 endif ()
 
-if (APPLE)
-    add_definitions(-DU_DISABLE_RENAMING=1)
-endif ()
 find_package(ICU 60.2 REQUIRED COMPONENTS data i18n uc)
index c1d95d6..1f0b490 100644 (file)
@@ -119,5 +119,4 @@ set(JavaScriptCore_LIBRARY_TYPE SHARED)
 set(WebCore_LIBRARY_TYPE SHARED)
 set(WebCoreTestSupport_LIBRARY_TYPE SHARED)
 
-add_definitions(-DU_DISABLE_RENAMING=1)
 find_package(ICU 60.2 REQUIRED COMPONENTS data i18n uc)
index 1d452e3..3909aca 100644 (file)
@@ -1,3 +1,23 @@
+2020-04-22  Darin Adler  <darin@apple.com>
+
+        [Cocoa] Build with UChar as char16_t even in builds that use Apple's internal SDK
+        https://bugs.webkit.org/show_bug.cgi?id=210845
+
+        Reviewed by Anders Carlsson.
+
+        * TestWebKitAPI/Tests/WTF/StringConcatenate.cpp:
+        (TestWebKitAPI::TEST): Get rid of an obsolete cast to unsigned to work
+        around uint16_t not being treated as a number by makeString.
+        * TestWebKitAPI/Tests/WebKitCocoa/TLSDeprecation.mm:
+        (TestWebKitAPI::TEST): Ditto.
+        * TestWebKitAPI/Tests/WebKitCocoa/TestSOAuthorization.mm:
+        (TestWebKitAPI::TEST): Ditto.
+        * TestWebKitAPI/Tests/WebKitCocoa/_WKWebAuthenticationPanel.mm:
+        (TestWebKitAPI::TEST): Ditto.
+
+        * TestWebKitAPI/Tests/WebKit/EnvironmentUtilitiesTest.cpp:
+        Add an include needed since EvironmentUtilities.h now includes less.
+
 2020-04-22  Saam Barati  <sbarati@apple.com>
 
         DumpRenderTree should have the JIT entitlement on Mac
index da08f4f..739158e 100644 (file)
@@ -83,11 +83,7 @@ TEST(WTF, StringConcatenate_Unsigned)
     EXPECT_STREQ("hello 0 world", makeString("hello ", 0u , " world").utf8().data());
 
     EXPECT_STREQ("hello 42 world", makeString("hello ", static_cast<unsigned char>(42) , " world").utf8().data());
-    // FIXME: Remove this if statement once we have UChar as char16_t in all configurations.
-    if constexpr (std::is_same_v<UChar, uint16_t>)
-        EXPECT_STREQ("hello * world", makeString("hello ", static_cast<unsigned short>(42) , " world").utf8().data());
-    else
-        EXPECT_STREQ("hello 42 world", makeString("hello ", static_cast<unsigned short>(42) , " world").utf8().data());
+    EXPECT_STREQ("hello 42 world", makeString("hello ", static_cast<unsigned short>(42) , " world").utf8().data());
     EXPECT_STREQ("hello 4 world", makeString("hello ", sizeof(int) , " world").utf8().data()); // size_t
     EXPECT_STREQ("hello 4 world", makeString("hello ", offsetof(S, i) , " world").utf8().data()); // size_t
     EXPECT_STREQ("hello 3235839742 world", makeString("hello ", static_cast<size_t>(0xc0defefe), " world").utf8().data());
index 34f51f9..3fd283a 100644 (file)
@@ -28,6 +28,7 @@
 #include "Test.h"
 
 #include <WebKit/EnvironmentUtilities.h>
+#include <wtf/text/WTFString.h>
 
 namespace TestWebKitAPI {
 
index 940ef95..ee2052f 100644 (file)
@@ -310,7 +310,7 @@ TEST(TLSVersion, BackForwardNegotiatedLegacyTLS)
         { "/", { "hello" } }
     }, HTTPServer::Protocol::HttpsWithLegacyTLS);
     HTTPServer mixedContentServer({
-        { "/", { {{ "Content-Type", "text/html" }}, makeString("<img src='https://127.0.0.1:", static_cast<unsigned>(insecureServer.port()), "/'></img>") } },
+        { "/", { {{ "Content-Type", "text/html" }}, makeString("<img src='https://127.0.0.1:", insecureServer.port(), "/'></img>") } },
     }, HTTPServer::Protocol::Https);
 
     auto [webView, delegate] = webViewWithNavigationDelegate();
@@ -344,7 +344,7 @@ TEST(TLSVersion, Subresource)
     }, HTTPServer::Protocol::HttpsWithLegacyTLS);
 
     HTTPServer modernTLSServer({
-        { "/", { makeString("<script>fetch('https://127.0.0.1:", static_cast<unsigned>(legacyTLSServer.port()), "/',{mode:'no-cors'})</script>") } },
+        { "/", { makeString("<script>fetch('https://127.0.0.1:", legacyTLSServer.port(), "/',{mode:'no-cors'})</script>") } },
         { "/pageWithoutSubresource", { "hello" }}
     }, HTTPServer::Protocol::Https);
     
@@ -378,7 +378,7 @@ TEST(TLSVersion, BackForwardHasOnlySecureContent)
         { "/", { "hello" } }
     });
     HTTPServer mixedContentServer({
-        { "/", { {{ "Content-Type", "text/html" }}, makeString("<img src='http://127.0.0.1:", static_cast<unsigned>(insecureServer.port()), "/'></img>") } },
+        { "/", { {{ "Content-Type", "text/html" }}, makeString("<img src='http://127.0.0.1:", insecureServer.port(), "/'></img>") } },
     }, HTTPServer::Protocol::Https);
 
     auto [webView, delegate] = webViewWithNavigationDelegate();
index 9a9b466..86dd11e 100644 (file)
@@ -2551,7 +2551,7 @@ TEST(SOAuthorizationSubFrame, InterceptionErrorWithReferrer)
     auto delegate = adoptNS([[TestSOAuthorizationDelegate alloc] init]);
     configureSOAuthorizationWebView(webView.get(), delegate.get());
 
-    auto origin = makeString("http://127.0.0.1:", static_cast<unsigned>(server.port()));
+    auto origin = makeString("http://127.0.0.1:", server.port());
     [webView _loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:(id)origin]] shouldOpenExternalURLs:NO];
     [webView waitForMessage:(id)origin];
     [webView waitForMessage:@"SOAuthorizationDidStart"];
index 3714d1f..6b82dba 100644 (file)
@@ -688,7 +688,7 @@ TEST(WebAuthenticationPanel, SubFrameDestructionHidCancel)
     auto delegate = adoptNS([[TestWebAuthenticationPanelUIDelegate alloc] init]);
     [webView setUIDelegate:delegate.get()];
 
-    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:(id)makeString("http://localhost:", static_cast<unsigned>(server.port()))]]];
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:(id)makeString("http://localhost:", server.port())]]];
     Util::run(&webAuthenticationPanelRan);
     [webView evaluateJavaScript:@"theFrame.parentNode.removeChild(theFrame)" completionHandler:nil];
     Util::run(&webAuthenticationPanelFailed);