Fix the WebKit build after <rdar://problem/64288191>
https://bugs.webkit.org/show_bug.cgi?id=213832

Reviewed by Tim Horton.

Source/WebCore:

Upcoming changes to <UIKit/UIWebDocumentView.h> will cause the WebKit build to break, due to conflicting
declarations of WKObject in both WebCore (WAK) code and the WebKit API. Avoid this by renaming the WAK version
to WAKObject, rather than WKObject.

Additionally, fix some minor style issues along the way.

* platform/ios/wak/WKTypes.h:
* platform/ios/wak/WKUtilities.c:
(WKRetain):
(WKRelease):
(_WAKObjectDealloc):
(WKGetClassInfo):
(_WKObjectDealloc): Deleted.
* platform/ios/wak/WKUtilities.h:
* platform/ios/wak/WKView.h:
* platform/ios/wak/WKView.mm:
(_WKViewDealloc):

Tools:

Additionally, fix a naming conflict that will result from `WebArchivePboardType` being declared in both
`<WebKitLegacy/WebArchive.h>` and DumpRenderTree, by making the latter a local variable instead.

* DumpRenderTree/mac/TestRunnerMac.mm:
(TestRunner::imageCountInGeneralPasteboard const):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@263814 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index 0e44ce2..8f91c32 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,28 @@
+2020-07-01  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Fix the WebKit build after <rdar://problem/64288191>
+        https://bugs.webkit.org/show_bug.cgi?id=213832
+
+        Reviewed by Tim Horton.
+
+        Upcoming changes to <UIKit/UIWebDocumentView.h> will cause the WebKit build to break, due to conflicting
+        declarations of WKObject in both WebCore (WAK) code and the WebKit API. Avoid this by renaming the WAK version
+        to WAKObject, rather than WKObject.
+
+        Additionally, fix some minor style issues along the way.
+
+        * platform/ios/wak/WKTypes.h:
+        * platform/ios/wak/WKUtilities.c:
+        (WKRetain):
+        (WKRelease):
+        (_WAKObjectDealloc):
+        (WKGetClassInfo):
+        (_WKObjectDealloc): Deleted.
+        * platform/ios/wak/WKUtilities.h:
+        * platform/ios/wak/WKView.h:
+        * platform/ios/wak/WKView.mm:
+        (_WKViewDealloc):
+
 2020-07-01  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][TFC] Add support for non-baseline aligned cell height
diff --git a/Source/WebCore/platform/ios/wak/WKTypes.h b/Source/WebCore/platform/ios/wak/WKTypes.h
index cd9374c..701b8bc 100644
--- a/Source/WebCore/platform/ios/wak/WKTypes.h
+++ b/Source/WebCore/platform/ios/wak/WKTypes.h
@@ -32,8 +32,9 @@
 extern "C" {
 #endif
 
-typedef struct _WKObject WKObject;
-typedef struct _WKObject *WKObjectRef;
+// This is named WAKObject to avoid a name conflict with WebKit's WKObject.
+typedef struct _WAKObject WAKObject;
+typedef struct _WAKObject *WAKObjectRef;
 typedef struct WKControl* WKControlRef;
 typedef struct _WKView* WKViewRef;
 
diff --git a/Source/WebCore/platform/ios/wak/WKUtilities.c b/Source/WebCore/platform/ios/wak/WKUtilities.c
index 2de3c12..a9244db 100644
--- a/Source/WebCore/platform/ios/wak/WKUtilities.c
+++ b/Source/WebCore/platform/ios/wak/WKUtilities.c
@@ -41,7 +41,7 @@
 
 const void *WKRetain(const void *o)
 {
-    WKObjectRef object = (WKObjectRef)(uintptr_t)o;
+    WAKObjectRef object = (WAKObjectRef)(uintptr_t)o;
     
     object->referenceCount++;
     
@@ -56,7 +56,7 @@
 
 void WKRelease(const void *o)
 {
-    WKObjectRef object = (WKObjectRef)(uintptr_t)o;
+    WAKObjectRef object = (WAKObjectRef)(uintptr_t)o;
 
     if (object->referenceCount == 0) {
         WKError ("attempt to release invalid object");
@@ -75,16 +75,16 @@
     }
 }
 
-static void _WKObjectDealloc (WKObjectRef v)
+static void WAKObjectDealloc(WAKObjectRef v)
 {
     free (v);
 }
 
-WKClassInfo WKObjectClass = { 0, "WKObject", _WKObjectDealloc };
+WKClassInfo WAKObjectClass = { 0, "WAKObject", WAKObjectDealloc };
 
 const void *WKCreateObjectWithSize (size_t size, WKClassInfo *info)
 {
-    WKObjectRef object = (WKObjectRef)calloc (size, 1);
+    WAKObjectRef object = (WAKObjectRef)calloc(size, 1);
     if (!object)
         return 0;
 
@@ -121,7 +121,7 @@
     return index;
 }
 
-WKClassInfo *WKGetClassInfo (WKObjectRef object)
+WKClassInfo *WKGetClassInfo(WAKObjectRef object)
 {
     return object->classInfo;
 }
diff --git a/Source/WebCore/platform/ios/wak/WKUtilities.h b/Source/WebCore/platform/ios/wak/WKUtilities.h
index 02053f2..515499f 100644
--- a/Source/WebCore/platform/ios/wak/WKUtilities.h
+++ b/Source/WebCore/platform/ios/wak/WKUtilities.h
@@ -39,7 +39,7 @@
 extern const CFSetCallBacks WKCollectionSetCallBacks;
 
 
-typedef void(*WKDeallocCallback)(WKObjectRef object);
+typedef void(*WKDeallocCallback)(WAKObjectRef object);
 
 typedef struct _WKClassInfo WKClassInfo;
 
@@ -50,9 +50,9 @@
     WKDeallocCallback dealloc;
 };
 
-extern WKClassInfo WKObjectClass;
+extern WKClassInfo WAKObjectClass;
 
-struct _WKObject
+struct _WAKObject
 {
     unsigned referenceCount;
     WKClassInfo *classInfo;
@@ -70,7 +70,7 @@
 
 CFIndex WKArrayIndexOfValue (CFArrayRef array, const void *value);
 
-WKClassInfo *WKGetClassInfo (WKObjectRef object);
+WKClassInfo *WKGetClassInfo(WAKObjectRef);
 
 #ifdef __cplusplus
 }
diff --git a/Source/WebCore/platform/ios/wak/WKView.h b/Source/WebCore/platform/ios/wak/WKView.h
index 270e970..472a176 100644
--- a/Source/WebCore/platform/ios/wak/WKView.h
+++ b/Source/WebCore/platform/ios/wak/WKView.h
@@ -65,7 +65,7 @@
 } WKViewContext;
 
 struct _WKView {
-    WKObject isa;
+    WAKObject isa;
     
     WKViewContext *context;
     
diff --git a/Source/WebCore/platform/ios/wak/WKView.mm b/Source/WebCore/platform/ios/wak/WKView.mm
index 66e4b0a..ea5a58e 100644
--- a/Source/WebCore/platform/ios/wak/WKView.mm
+++ b/Source/WebCore/platform/ios/wak/WKView.mm
@@ -76,7 +76,7 @@
     _WKViewSetSuperview(static_cast<WKViewRef>(const_cast<void*>(value)), 0);
 }
 
-static void _WKViewDealloc (WKObjectRef v)
+static void _WKViewDealloc(WAKObjectRef v)
 {
     WKViewRef view = (WKViewRef)v;
     
@@ -101,7 +101,7 @@
     view->scale = 1.0f;
 }
 
-WKClassInfo WKViewClassInfo = { &WKObjectClass, "WKView", _WKViewDealloc };
+WKClassInfo WKViewClassInfo = { &WAKObjectClass, "WKView", _WKViewDealloc };
 
 WKViewRef WKViewCreateWithFrame (CGRect frame, WKViewContext *context)
 {
diff --git a/Tools/ChangeLog b/Tools/ChangeLog
index 0bd744e..8100359 100644
--- a/Tools/ChangeLog
+++ b/Tools/ChangeLog
@@ -1,3 +1,16 @@
+2020-07-01  Wenson Hsieh  <wenson_hsieh@apple.com>
+
+        Fix the WebKit build after <rdar://problem/64288191>
+        https://bugs.webkit.org/show_bug.cgi?id=213832
+
+        Reviewed by Tim Horton.
+
+        Additionally, fix a naming conflict that will result from `WebArchivePboardType` being declared in both
+        `<WebKitLegacy/WebArchive.h>` and DumpRenderTree, by making the latter a local variable instead.
+
+        * DumpRenderTree/mac/TestRunnerMac.mm:
+        (TestRunner::imageCountInGeneralPasteboard const):
+
 2020-07-01  Daniel Bates  <dabates@apple.com>
 
         [iOS] Implement support for UIWKDocumentRequestSpatialAndCurrentSelection
diff --git a/Tools/DumpRenderTree/mac/TestRunnerMac.mm b/Tools/DumpRenderTree/mac/TestRunnerMac.mm
index bf7ae9e..2faa378 100644
--- a/Tools/DumpRenderTree/mac/TestRunnerMac.mm
+++ b/Tools/DumpRenderTree/mac/TestRunnerMac.mm
@@ -1257,16 +1257,16 @@
 {
 }
 
-static NSString * const WebArchivePboardType = @"Apple Web Archive pasteboard type";
 static NSString * const WebSubresourcesKey = @"WebSubresources";
 static NSString * const WebSubframeArchivesKey = @"WebResourceMIMEType like 'image*'";
 
 unsigned TestRunner::imageCountInGeneralPasteboard() const
 {
+    NSString *webArchivePboardType = @"Apple Web Archive pasteboard type";
 #if PLATFORM(MAC)
-    NSData *data = [[NSPasteboard generalPasteboard] dataForType:WebArchivePboardType];
+    NSData *data = [[NSPasteboard generalPasteboard] dataForType:webArchivePboardType];
 #elif PLATFORM(IOS_FAMILY)
-    NSData *data = [[UIPasteboard generalPasteboard] valueForPasteboardType:WebArchivePboardType];
+    NSData *data = [[UIPasteboard generalPasteboard] valueForPasteboardType:webArchivePboardType];
 #endif
     if (!data)
         return 0;