Title: [265271] trunk/Tools
Revision
265271
Author
wenson_hs...@apple.com
Date
2020-08-04 18:27:12 -0700 (Tue, 04 Aug 2020)

Log Message

Move poseAsClass() into the TestRunnerShared directory
https://bugs.webkit.org/show_bug.cgi?id=215147

Reviewed by Tim Horton.

Move the duplicated implementations of `poseAsClass()` out of WebKitTestRunner and DumpRenderTree,
and into helper files in TestRunnerShared instead.

No change in behavior.

* DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
* DumpRenderTree/mac/DumpRenderTree.mm:
(poseAsClass): Deleted.
(setPersistentUserStyleSheetLocation): Deleted.
* TestRunnerShared/cocoa/PoseAsClass.h: Renamed from Tools/WebKitTestRunner/mac/PoseAsClass.h.
* TestRunnerShared/cocoa/PoseAsClass.mm: Renamed from Tools/WebKitTestRunner/mac/PoseAsClass.mm.
(swizzleAllMethods):
(poseAsClass):
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Tools/ChangeLog (265270 => 265271)


--- trunk/Tools/ChangeLog	2020-08-05 00:43:32 UTC (rev 265270)
+++ trunk/Tools/ChangeLog	2020-08-05 01:27:12 UTC (rev 265271)
@@ -1,3 +1,25 @@
+2020-08-04  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        Move poseAsClass() into the TestRunnerShared directory
+        https://bugs.webkit.org/show_bug.cgi?id=215147
+
+        Reviewed by Tim Horton.
+
+        Move the duplicated implementations of `poseAsClass()` out of WebKitTestRunner and DumpRenderTree,
+        and into helper files in TestRunnerShared instead.
+
+        No change in behavior.
+
+        * DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj:
+        * DumpRenderTree/mac/DumpRenderTree.mm:
+        (poseAsClass): Deleted.
+        (setPersistentUserStyleSheetLocation): Deleted.
+        * TestRunnerShared/cocoa/PoseAsClass.h: Renamed from Tools/WebKitTestRunner/mac/PoseAsClass.h.
+        * TestRunnerShared/cocoa/PoseAsClass.mm: Renamed from Tools/WebKitTestRunner/mac/PoseAsClass.mm.
+        (swizzleAllMethods):
+        (poseAsClass):
+        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+
 2020-08-04  Per Arne Vollan  <pvol...@apple.com>
 
         [iOS] Check that Accessibility is enabled when receiving the enable Accessibility notification

Modified: trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj (265270 => 265271)


--- trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2020-08-05 00:43:32 UTC (rev 265270)
+++ trunk/Tools/DumpRenderTree/DumpRenderTree.xcodeproj/project.pbxproj	2020-08-05 01:27:12 UTC (rev 265271)
@@ -156,6 +156,7 @@
 		C23EA2081BC9F05100C980B7 /* FontWithFeatures.otf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = C23EA2061BC9EABA00C980B7 /* FontWithFeatures.otf */; };
 		C23EA2091BC9F05100C980B7 /* FontWithFeatures.ttf in Copy Font Files */ = {isa = PBXBuildFile; fileRef = C23EA2071BC9EABA00C980B7 /* FontWithFeatures.ttf */; };
 		E1B7816511AF31B7007E1BC2 /* MockGeolocationProvider.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1B7808711AF1669007E1BC2 /* MockGeolocationProvider.mm */; };
+		F4010B7B24DA201F00A876E2 /* PoseAsClass.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4010B7924DA200E00A876E2 /* PoseAsClass.mm */; };
 		F445C68624B2789D00790440 /* UIScriptControllerShared.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F445C68524B2788F00790440 /* UIScriptControllerShared.cpp */; };
 		F445C68924B278EC00790440 /* UIScriptController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F445C68824B278EC00790440 /* UIScriptController.cpp */; };
 		F44A531D21B89A4D00DBB99C /* ClassMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44A531A21B89A4400DBB99C /* ClassMethodSwizzler.mm */; };
@@ -428,6 +429,8 @@
 		C23EA2071BC9EABA00C980B7 /* FontWithFeatures.ttf */ = {isa = PBXFileReference; lastKnownFileType = file; name = FontWithFeatures.ttf; path = fonts/FontWithFeatures.ttf; sourceTree = "<group>"; };
 		E1B7808511AF1643007E1BC2 /* MockGeolocationProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = MockGeolocationProvider.h; path = mac/MockGeolocationProvider.h; sourceTree = "<group>"; };
 		E1B7808711AF1669007E1BC2 /* MockGeolocationProvider.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = MockGeolocationProvider.mm; path = mac/MockGeolocationProvider.mm; sourceTree = "<group>"; };
+		F4010B7924DA200E00A876E2 /* PoseAsClass.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PoseAsClass.mm; sourceTree = "<group>"; };
+		F4010B7A24DA200E00A876E2 /* PoseAsClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PoseAsClass.h; sourceTree = "<group>"; };
 		F445C68524B2788F00790440 /* UIScriptControllerShared.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = UIScriptControllerShared.cpp; path = ../TestRunnerShared/UIScriptContext/UIScriptControllerShared.cpp; sourceTree = "<group>"; };
 		F445C68824B278EC00790440 /* UIScriptController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UIScriptController.cpp; sourceTree = "<group>"; };
 		F44A531921B89A4400DBB99C /* InstanceMethodSwizzler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InstanceMethodSwizzler.h; sourceTree = "<group>"; };
@@ -877,6 +880,8 @@
 				F44A531C21B89A4500DBB99C /* InstanceMethodSwizzler.mm */,
 				F4C3578920E8442700FA0748 /* LayoutTestSpellChecker.h */,
 				F4C3578820E8442700FA0748 /* LayoutTestSpellChecker.mm */,
+				F4010B7A24DA200E00A876E2 /* PoseAsClass.h */,
+				F4010B7924DA200E00A876E2 /* PoseAsClass.mm */,
 			);
 			path = cocoa;
 			sourceTree = "<group>";
@@ -1225,6 +1230,7 @@
 				A1158D59189274360088C17B /* PixelDumpSupportIOS.mm in Sources */,
 				BCB284D60CFA83D1007E533E /* PixelDumpSupportMac.mm in Sources */,
 				BCA18B660C9B08C200114369 /* PolicyDelegate.mm in Sources */,
+				F4010B7B24DA201F00A876E2 /* PoseAsClass.mm in Sources */,
 				BCA18B680C9B08C200114369 /* ResourceLoadDelegate.mm in Sources */,
 				A30A21F82051D8C40008FF42 /* TestOptions.cpp in Sources */,
 				BC0131DA0C9772010087317D /* TestRunner.cpp in Sources */,

Modified: trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm (265270 => 265271)


--- trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2020-08-05 00:43:32 UTC (rev 265270)
+++ trunk/Tools/DumpRenderTree/mac/DumpRenderTree.mm	2020-08-05 01:27:12 UTC (rev 265271)
@@ -48,6 +48,7 @@
 #import "ObjCPluginFunction.h"
 #import "PixelDumpSupport.h"
 #import "PolicyDelegate.h"
+#import "PoseAsClass.h"
 #import "ResourceLoadDelegate.h"
 #import "TestOptions.h"
 #import "TestRunner.h"
@@ -239,56 +240,6 @@
 DumpRenderTreeWindow *gDrtWindow = nil;
 #endif
 
-#ifdef __OBJC2__
-static void swizzleAllMethods(Class imposter, Class original)
-{
-    unsigned int imposterMethodCount;
-    Method* imposterMethods = class_copyMethodList(imposter, &imposterMethodCount);
-
-    unsigned int originalMethodCount;
-    Method* originalMethods = class_copyMethodList(original, &originalMethodCount);
-
-    for (unsigned int i = 0; i < imposterMethodCount; i++) {
-        SEL imposterMethodName = method_getName(imposterMethods[i]);
-
-        // Attempt to add the method to the original class.  If it fails, the method already exists and we should
-        // instead exchange the implementations.
-        if (class_addMethod(original, imposterMethodName, method_getImplementation(imposterMethods[i]), method_getTypeEncoding(imposterMethods[i])))
-            continue;
-
-        unsigned int j = 0;
-        for (; j < originalMethodCount; j++) {
-            SEL originalMethodName = method_getName(originalMethods[j]);
-            if (sel_isEqual(imposterMethodName, originalMethodName))
-                break;
-        }
-
-        // If class_addMethod failed above then the method must exist on the original class.
-        ASSERT(j < originalMethodCount);
-        method_exchangeImplementations(imposterMethods[i], originalMethods[j]);
-    }
-
-    free(imposterMethods);
-    free(originalMethods);
-}
-#endif
-
-static void poseAsClass(const char* imposter, const char* original)
-{
-    Class imposterClass = objc_getClass(imposter);
-    Class originalClass = objc_getClass(original);
-
-#ifndef __OBJC2__
-    class_poseAs(imposterClass, originalClass);
-#else
-
-    // Swizzle instance methods
-    swizzleAllMethods(imposterClass, originalClass);
-    // and then class methods
-    swizzleAllMethods(object_getClass(imposterClass), object_getClass(originalClass));
-#endif
-}
-
 void setPersistentUserStyleSheetLocation(CFStringRef url)
 {
     persistentUserStyleSheetLocation = url;

Copied: trunk/Tools/TestRunnerShared/cocoa/PoseAsClass.h (from rev 265270, trunk/Tools/WebKitTestRunner/mac/PoseAsClass.h) (0 => 265271)


--- trunk/Tools/TestRunnerShared/cocoa/PoseAsClass.h	                        (rev 0)
+++ trunk/Tools/TestRunnerShared/cocoa/PoseAsClass.h	2020-08-05 01:27:12 UTC (rev 265271)
@@ -0,0 +1,28 @@
+/*
+ * Copyright (C) 2013-2020 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
+
+void poseAsClass(const char* imposter, const char* original);

Copied: trunk/Tools/TestRunnerShared/cocoa/PoseAsClass.mm (from rev 265270, trunk/Tools/WebKitTestRunner/mac/PoseAsClass.mm) (0 => 265271)


--- trunk/Tools/TestRunnerShared/cocoa/PoseAsClass.mm	                        (rev 0)
+++ trunk/Tools/TestRunnerShared/cocoa/PoseAsClass.mm	2020-08-05 01:27:12 UTC (rev 265271)
@@ -0,0 +1,73 @@
+/*
+ * Copyright (C) 2013-2020 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.
+ */
+
+#import "config.h"
+#import "PoseAsClass.h"
+
+#import <objc/runtime.h>
+#import <wtf/Assertions.h>
+
+static void swizzleAllMethods(Class imposter, Class original)
+{
+    unsigned imposterMethodCount;
+    Method* imposterMethods = class_copyMethodList(imposter, &imposterMethodCount);
+
+    unsigned originalMethodCount;
+    Method* originalMethods = class_copyMethodList(original, &originalMethodCount);
+
+    for (unsigned i = 0; i < imposterMethodCount; i++) {
+        SEL imposterMethodName = method_getName(imposterMethods[i]);
+
+        // Attempt to add the method to the original class. If it fails, the method already exists and we should
+        // instead exchange the implementations.
+        if (class_addMethod(original, imposterMethodName, method_getImplementation(imposterMethods[i]), method_getTypeEncoding(imposterMethods[i])))
+            continue;
+
+        unsigned j = 0;
+        for (; j < originalMethodCount; j++) {
+            SEL originalMethodName = method_getName(originalMethods[j]);
+            if (sel_isEqual(imposterMethodName, originalMethodName))
+                break;
+        }
+
+        // If class_addMethod failed above then the method must exist on the original class.
+        ASSERT(j < originalMethodCount);
+        method_exchangeImplementations(imposterMethods[i], originalMethods[j]);
+    }
+
+    free(imposterMethods);
+    free(originalMethods);
+}
+
+void poseAsClass(const char* imposter, const char* original)
+{
+    Class imposterClass = objc_getClass(imposter);
+    Class originalClass = objc_getClass(original);
+
+    // Swizzle instance methods
+    swizzleAllMethods(imposterClass, originalClass);
+    // and then class methods
+    swizzleAllMethods(object_getClass(imposterClass), object_getClass(originalClass));
+}

Modified: trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj (265270 => 265271)


--- trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2020-08-05 00:43:32 UTC (rev 265270)
+++ trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2020-08-05 01:27:12 UTC (rev 265271)
@@ -150,8 +150,8 @@
 		C0CE720B1247C93300BC0EC4 /* TestRunnerMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = C0CE720A1247C93300BC0EC4 /* TestRunnerMac.mm */; };
 		E132AA3A17CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.mm in Sources */ = {isa = PBXBuildFile; fileRef = E132AA3817CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.mm */; };
 		E132AA3D17CE776F00611DF0 /* WebKitTestRunnerEvent.mm in Sources */ = {isa = PBXBuildFile; fileRef = E132AA3B17CE776F00611DF0 /* WebKitTestRunnerEvent.mm */; };
-		E1C642C317CBCC7300D66A3C /* PoseAsClass.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */; };
 		E1C642C617CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = E1C642C417CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm */; };
+		F4010B7E24DA205300A876E2 /* PoseAsClass.mm in Sources */ = {isa = PBXBuildFile; fileRef = F4010B7C24DA204800A876E2 /* PoseAsClass.mm */; };
 		F445C68A24B27ACC00790440 /* UIScriptController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = F445C68324B277E300790440 /* UIScriptController.cpp */; };
 		F44A531721B899E200DBB99C /* ClassMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44A531421B899DA00DBB99C /* ClassMethodSwizzler.mm */; };
 		F44A531821B899E500DBB99C /* InstanceMethodSwizzler.mm in Sources */ = {isa = PBXBuildFile; fileRef = F44A531621B899DA00DBB99C /* InstanceMethodSwizzler.mm */; };
@@ -407,10 +407,10 @@
 		E132AA3B17CE776F00611DF0 /* WebKitTestRunnerEvent.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitTestRunnerEvent.mm; sourceTree = "<group>"; };
 		E132AA3C17CE776F00611DF0 /* WebKitTestRunnerEvent.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitTestRunnerEvent.h; sourceTree = "<group>"; };
 		E1BA671D1742DA5A00C20251 /* Carbon.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Carbon.framework; path = System/Library/Frameworks/Carbon.framework; sourceTree = SDKROOT; };
-		E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PoseAsClass.mm; sourceTree = "<group>"; };
-		E1C642C217CBCC7300D66A3C /* PoseAsClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = PoseAsClass.h; sourceTree = "<group>"; };
 		E1C642C417CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebKitTestRunnerPasteboard.mm; sourceTree = "<group>"; };
 		E1C642C517CBCD4C00D66A3C /* WebKitTestRunnerPasteboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebKitTestRunnerPasteboard.h; sourceTree = "<group>"; };
+		F4010B7C24DA204800A876E2 /* PoseAsClass.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = PoseAsClass.mm; path = ../TestRunnerShared/cocoa/PoseAsClass.mm; sourceTree = "<group>"; };
+		F4010B7D24DA204800A876E2 /* PoseAsClass.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PoseAsClass.h; path = ../TestRunnerShared/cocoa/PoseAsClass.h; sourceTree = "<group>"; };
 		F445C68324B277E300790440 /* UIScriptController.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = UIScriptController.cpp; sourceTree = "<group>"; };
 		F44A531321B899DA00DBB99C /* InstanceMethodSwizzler.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = InstanceMethodSwizzler.h; path = ../TestRunnerShared/cocoa/InstanceMethodSwizzler.h; sourceTree = "<group>"; };
 		F44A531421B899DA00DBB99C /* ClassMethodSwizzler.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = ClassMethodSwizzler.mm; path = ../TestRunnerShared/cocoa/ClassMethodSwizzler.mm; sourceTree = "<group>"; };
@@ -796,8 +796,6 @@
 				5670B8271386FCA5002EB355 /* EventSenderProxy.mm */,
 				BC7933FF118F7C84005EA8E2 /* main.mm */,
 				BC7934E711906846005EA8E2 /* PlatformWebViewMac.mm */,
-				E1C642C217CBCC7300D66A3C /* PoseAsClass.h */,
-				E1C642C117CBCC7300D66A3C /* PoseAsClass.mm */,
 				BC8C795B11D2785D004535A1 /* TestControllerMac.mm */,
 				2D058E0A22E2EF6D00E4C145 /* UIScriptControllerMac.h */,
 				0F87B6111BACAD6F004EC572 /* UIScriptControllerMac.mm */,
@@ -900,6 +898,8 @@
 				F4C3578A20E8444000FA0748 /* LayoutTestSpellChecker.mm */,
 				2E2A765B2370C8A0008F9FFE /* PlatformViewHelpers.h */,
 				2E2A765C2370C8A0008F9FFE /* PlatformViewHelpers.mm */,
+				F4010B7D24DA204800A876E2 /* PoseAsClass.h */,
+				F4010B7C24DA204800A876E2 /* PoseAsClass.mm */,
 			);
 			name = cocoa;
 			sourceTree = "<group>";
@@ -1166,7 +1166,6 @@
 				BC793400118F7C84005EA8E2 /* main.mm in Sources */,
 				F4FED324235823A3003C139C /* NSPasteboardAdditions.mm in Sources */,
 				BC7934E811906846005EA8E2 /* PlatformWebViewMac.mm in Sources */,
-				E1C642C317CBCC7300D66A3C /* PoseAsClass.mm in Sources */,
 				BC8C795C11D2785D004535A1 /* TestControllerMac.mm in Sources */,
 				0F87B6131BACAD82004EC572 /* UIScriptControllerMac.mm in Sources */,
 				E132AA3A17CD5F1000611DF0 /* WebKitTestRunnerDraggingInfo.mm in Sources */,
@@ -1193,6 +1192,7 @@
 				A185103C1B9AE0FE00744AEB /* Options.cpp in Sources */,
 				A18510401B9AE13100744AEB /* PixelDumpSupport.cpp in Sources */,
 				2E2A765D2370C8D1008F9FFE /* PlatformViewHelpers.mm in Sources */,
+				F4010B7E24DA205300A876E2 /* PoseAsClass.mm in Sources */,
 				2DFA98491D7F70CF00AFF2C9 /* SharedEventStreamsMac.mm in Sources */,
 				A18510411B9AE13800744AEB /* TestController.cpp in Sources */,
 				A185103B1B9AE0E200744AEB /* TestControllerCocoa.mm in Sources */,

Deleted: trunk/Tools/WebKitTestRunner/mac/PoseAsClass.h (265270 => 265271)


--- trunk/Tools/WebKitTestRunner/mac/PoseAsClass.h	2020-08-05 00:43:32 UTC (rev 265270)
+++ trunk/Tools/WebKitTestRunner/mac/PoseAsClass.h	2020-08-05 01:27:12 UTC (rev 265271)
@@ -1,31 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#ifndef PoseAsClass_h
-#define PoseAsClass_h
-
-void poseAsClass(const char* imposter, const char* original);
-
-#endif // PoseAsClass_h

Deleted: trunk/Tools/WebKitTestRunner/mac/PoseAsClass.mm (265270 => 265271)


--- trunk/Tools/WebKitTestRunner/mac/PoseAsClass.mm	2020-08-05 00:43:32 UTC (rev 265270)
+++ trunk/Tools/WebKitTestRunner/mac/PoseAsClass.mm	2020-08-05 01:27:12 UTC (rev 265271)
@@ -1,73 +0,0 @@
-/*
- * Copyright (C) 2013 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.
- */
-
-#import "config.h"
-#import "PoseAsClass.h"
-
-#import <objc/runtime.h>
-#import <wtf/Assertions.h>
-
-static void swizzleAllMethods(Class imposter, Class original)
-{
-    unsigned int imposterMethodCount;
-    Method* imposterMethods = class_copyMethodList(imposter, &imposterMethodCount);
-
-    unsigned int originalMethodCount;
-    Method* originalMethods = class_copyMethodList(original, &originalMethodCount);
-
-    for (unsigned int i = 0; i < imposterMethodCount; i++) {
-        SEL imposterMethodName = method_getName(imposterMethods[i]);
-
-        // Attempt to add the method to the original class.  If it fails, the method already exists and we should
-        // instead exchange the implementations.
-        if (class_addMethod(original, imposterMethodName, method_getImplementation(imposterMethods[i]), method_getTypeEncoding(imposterMethods[i])))
-            continue;
-
-        unsigned int j = 0;
-        for (; j < originalMethodCount; j++) {
-            SEL originalMethodName = method_getName(originalMethods[j]);
-            if (sel_isEqual(imposterMethodName, originalMethodName))
-                break;
-        }
-
-        // If class_addMethod failed above then the method must exist on the original class.
-        ASSERT(j < originalMethodCount);
-        method_exchangeImplementations(imposterMethods[i], originalMethods[j]);
-    }
-
-    free(imposterMethods);
-    free(originalMethods);
-}
-
-void poseAsClass(const char* imposter, const char* original)
-{
-    Class imposterClass = objc_getClass(imposter);
-    Class originalClass = objc_getClass(original);
-
-    // Swizzle instance methods
-    swizzleAllMethods(imposterClass, originalClass);
-    // and then class methods
-    swizzleAllMethods(object_getClass(imposterClass), object_getClass(originalClass));
-}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to