Title: [222890] trunk/Tools
Revision
222890
Author
[email protected]
Date
2017-10-04 17:02:05 -0700 (Wed, 04 Oct 2017)

Log Message

Break out new touch debugging code into seperate file
https://bugs.webkit.org/show_bug.cgi?id=177796

Reviewed by Simon Fraser.

Encapsulate the new debug touch code into it's own file.
This allows for cleaner code and a better way to show the touches
in a completely separate window, which should also be in screen
coordinates, and not subject to any transforms that get put on the
WebViews.

* TestRunnerShared/spi/UIKitTestSPI.h:
* WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
* WebKitTestRunner/ios/HIDDebugTouchWindow.h: Added.
* WebKitTestRunner/ios/HIDDebugTouchWindow.mm: Added.
(+[HIDDebugTouchWindow sharedHIDDebugTouchWindow]):
(-[HIDDebugTouchWindow init]):
(-[HIDDebugTouchWindow dealloc]):
(-[HIDDebugTouchWindow updateDebugIndicatorForTouch:withPointInWindowCoordinates:isTouching:]):
(-[HIDDebugTouchWindow initDebugViewsIfNeeded]):
* WebKitTestRunner/ios/HIDEventGenerator.h:
* WebKitTestRunner/ios/HIDEventGenerator.mm:
(-[HIDEventGenerator init]):
(-[HIDEventGenerator _createIOHIDEventWithInfo:]):
(-[HIDEventGenerator _createIOHIDEventType:]):
(-[HIDEventGenerator _updateTouchPoints:count:]):
(-[HIDEventGenerator touchDownAtPoints:touchCount:]):
(-[HIDEventGenerator touchDown:touchCount:]):
(-[HIDEventGenerator liftUpAtPoints:touchCount:]):
(-[HIDEventGenerator liftUp:touchCount:]):
(-[HIDEventGenerator moveToPoints:touchCount:duration:]):
(-[HIDEventGenerator initDebugViewsIfNeeded]): Deleted.
(-[HIDEventGenerator updateDebugIndicatorForTouch:withPoint:isTouching:]): Deleted.
* WebKitTestRunner/ios/TestControllerIOS.mm:
(WTR::TestController::updatePlatformSpecificTestOptionsForTest const):

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (222889 => 222890)


--- trunk/Tools/ChangeLog	2017-10-04 23:58:02 UTC (rev 222889)
+++ trunk/Tools/ChangeLog	2017-10-05 00:02:05 UTC (rev 222890)
@@ -1,3 +1,41 @@
+2017-10-04  Megan Gardner  <[email protected]>
+
+        Break out new touch debugging code into seperate file
+        https://bugs.webkit.org/show_bug.cgi?id=177796
+
+        Reviewed by Simon Fraser.
+
+        Encapsulate the new debug touch code into it's own file.
+        This allows for cleaner code and a better way to show the touches
+        in a completely separate window, which should also be in screen
+        coordinates, and not subject to any transforms that get put on the
+        WebViews.
+
+        * TestRunnerShared/spi/UIKitTestSPI.h:
+        * WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj:
+        * WebKitTestRunner/ios/HIDDebugTouchWindow.h: Added.
+        * WebKitTestRunner/ios/HIDDebugTouchWindow.mm: Added.
+        (+[HIDDebugTouchWindow sharedHIDDebugTouchWindow]):
+        (-[HIDDebugTouchWindow init]):
+        (-[HIDDebugTouchWindow dealloc]):
+        (-[HIDDebugTouchWindow updateDebugIndicatorForTouch:withPointInWindowCoordinates:isTouching:]):
+        (-[HIDDebugTouchWindow initDebugViewsIfNeeded]):
+        * WebKitTestRunner/ios/HIDEventGenerator.h:
+        * WebKitTestRunner/ios/HIDEventGenerator.mm:
+        (-[HIDEventGenerator init]):
+        (-[HIDEventGenerator _createIOHIDEventWithInfo:]):
+        (-[HIDEventGenerator _createIOHIDEventType:]):
+        (-[HIDEventGenerator _updateTouchPoints:count:]):
+        (-[HIDEventGenerator touchDownAtPoints:touchCount:]):
+        (-[HIDEventGenerator touchDown:touchCount:]):
+        (-[HIDEventGenerator liftUpAtPoints:touchCount:]):
+        (-[HIDEventGenerator liftUp:touchCount:]):
+        (-[HIDEventGenerator moveToPoints:touchCount:duration:]):
+        (-[HIDEventGenerator initDebugViewsIfNeeded]): Deleted.
+        (-[HIDEventGenerator updateDebugIndicatorForTouch:withPoint:isTouching:]): Deleted.
+        * WebKitTestRunner/ios/TestControllerIOS.mm:
+        (WTR::TestController::updatePlatformSpecificTestOptionsForTest const):
+
 2017-10-04  JF Bastien  <[email protected]>
 
         WTF: Update std::expected to match current proposal

Modified: trunk/Tools/TestRunnerShared/spi/UIKitTestSPI.h (222889 => 222890)


--- trunk/Tools/TestRunnerShared/spi/UIKitTestSPI.h	2017-10-04 23:58:02 UTC (rev 222889)
+++ trunk/Tools/TestRunnerShared/spi/UIKitTestSPI.h	2017-10-05 00:02:05 UTC (rev 222890)
@@ -39,6 +39,7 @@
 #import <UIKit/UIWindow_Private.h>
 #import <UIKit/UIDevice_Private.h>
 #import <UIKit/UIScreen_Private.h>
+#import <UIKit/_UIApplicationRotationFollowing.h>
 
 @interface UIKeyboardPredictionView : UIView
 + (UIKeyboardPredictionView *)activeInstance;
@@ -80,6 +81,15 @@
 @interface UIScreen ()
 - (void)_setScale:(CGFloat)scale;
 @end
+
+@interface UIApplicationRotationFollowingWindow : UIWindow
+@end
+
+@interface UIApplicationRotationFollowingController : UIViewController
+@end
+
+@interface UIApplicationRotationFollowingControllerNoTouches : UIApplicationRotationFollowingController
+@end
  
 #endif // USE(APPLE_INTERNAL_SDK)
 

Modified: trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj (222889 => 222890)


--- trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2017-10-04 23:58:02 UTC (rev 222889)
+++ trunk/Tools/WebKitTestRunner/WebKitTestRunner.xcodeproj/project.pbxproj	2017-10-05 00:02:05 UTC (rev 222890)
@@ -79,6 +79,7 @@
 		2E63EDA61891BDC0002A7AFC /* TestRunner.cpp in Sources */ = {isa = PBXBuildFile; fileRef = BCC9981711D3F51E0017BCA2 /* TestRunner.cpp */; };
 		2E749BF21891EBFA007FC175 /* EventSenderProxyIOS.mm in Sources */ = {isa = PBXBuildFile; fileRef = 2E63ED7A1891ACE9002A7AFC /* EventSenderProxyIOS.mm */; };
 		31DA8A3D1E7205CC00E1DF2F /* IOSLayoutTestCommunication.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 3148A0531E6F85B600D3B316 /* IOSLayoutTestCommunication.cpp */; };
+		4430AE191F82C4FD0099915A /* GeneratedTouchesDebugWindow.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4430AE171F82C4EE0099915A /* GeneratedTouchesDebugWindow.mm */; };
 		51058AD51D678820009A538C /* libWebCoreTestSupport.dylib in Frameworks */ = {isa = PBXBuildFile; fileRef = 41230E16138C78BF00BCCFCA /* libWebCoreTestSupport.dylib */; };
 		51058AD61D678825009A538C /* WebKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 0F5169CA1445222D00E0A9D7 /* WebKit.framework */; };
 		5641E2D014335E95008307E5 /* JSTextInputController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 5641E2CE14335E95008307E5 /* JSTextInputController.cpp */; };
@@ -271,6 +272,8 @@
 		4181731B138AD39D0057AAA4 /* WebCoreTestSupport.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = WebCoreTestSupport.h; path = WebCoreTestSupport/WebCoreTestSupport.h; sourceTree = BUILT_PRODUCTS_DIR; };
 		4429FC5E1627089600F66D8B /* WorkQueueManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WorkQueueManager.cpp; sourceTree = "<group>"; };
 		4429FC611627089600F66D8B /* WorkQueueManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WorkQueueManager.h; sourceTree = "<group>"; };
+		4430AE171F82C4EE0099915A /* GeneratedTouchesDebugWindow.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = GeneratedTouchesDebugWindow.mm; sourceTree = "<group>"; };
+		4430AE181F82C4EF0099915A /* GeneratedTouchesDebugWindow.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedTouchesDebugWindow.h; sourceTree = "<group>"; };
 		5322FB4113FDA0CD0041ABCC /* CyclicRedundancyCheck.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CyclicRedundancyCheck.cpp; sourceTree = "<group>"; };
 		5322FB4213FDA0CD0041ABCC /* CyclicRedundancyCheck.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CyclicRedundancyCheck.h; sourceTree = "<group>"; };
 		5322FB4413FDA0EA0041ABCC /* PixelDumpSupport.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = PixelDumpSupport.cpp; sourceTree = "<group>"; };
@@ -463,10 +466,10 @@
 		0F18E71A1D6BC4BC0027E547 /* TestRunnerShared */ = {
 			isa = PBXGroup;
 			children = (
+				0F18E71B1D6BC4E60027E547 /* Bindings */,
+				0F73B5471BA782FE004B3EF4 /* UIScriptContext */,
 				3148A0531E6F85B600D3B316 /* IOSLayoutTestCommunication.cpp */,
 				3148A0541E6F85B600D3B316 /* IOSLayoutTestCommunication.h */,
-				0F18E71B1D6BC4E60027E547 /* Bindings */,
-				0F73B5471BA782FE004B3EF4 /* UIScriptContext */,
 			);
 			name = TestRunnerShared;
 			sourceTree = "<group>";
@@ -484,10 +487,10 @@
 		0F73B5471BA782FE004B3EF4 /* UIScriptContext */ = {
 			isa = PBXGroup;
 			children = (
-				2DB6187F1D7D598800978D19 /* spi */,
 				0F73B54B1BA78350004B3EF4 /* Bindings */,
+				0F73B54E1BA78954004B3EF4 /* Derived Sources */,
 				2DD4C4971D6E7D3B0007379C /* Event Serialization */,
-				0F73B54E1BA78954004B3EF4 /* Derived Sources */,
+				2DB6187F1D7D598800978D19 /* spi */,
 				0F18E6DD1D6B9AAF0027E547 /* UIScriptContext.cpp */,
 				0F18E6DE1D6B9AAF0027E547 /* UIScriptContext.h */,
 				0F18E6DF1D6B9AAF0027E547 /* UIScriptController.cpp */,
@@ -567,9 +570,9 @@
 		2DB6187F1D7D598800978D19 /* spi */ = {
 			isa = PBXGroup;
 			children = (
-				31268EB91EF06A3B001963E2 /* UIKitTestSPI.h */,
 				2DB6187D1D7D58D400978D19 /* CoreGraphicsTestSPI.h */,
 				0FEBF85B1BB62A370028722D /* IOKitSPI.h */,
+				31268EB91EF06A3B001963E2 /* UIKitTestSPI.h */,
 			);
 			name = spi;
 			sourceTree = "<group>";
@@ -629,6 +632,8 @@
 		2EE52D121890A9FB0010ED21 /* ios */ = {
 			isa = PBXGroup;
 			children = (
+				4430AE181F82C4EF0099915A /* GeneratedTouchesDebugWindow.h */,
+				4430AE171F82C4EE0099915A /* GeneratedTouchesDebugWindow.mm */,
 				0FEBF8581BB61DF20028722D /* HIDEventGenerator.h */,
 				0FEBF8591BB61DF20028722D /* HIDEventGenerator.mm */,
 				2EE52D131890A9FB0010ED21 /* PlatformWebViewIOS.mm */,
@@ -641,9 +646,9 @@
 		65EB859E11EC67CC0034D300 /* mac */ = {
 			isa = PBXGroup;
 			children = (
+				299E2AA41E3DEE140065DC30 /* AccessibilityCommonMac.h */,
 				29210EAB144CACB200835BB6 /* AccessibilityCommonMac.mm */,
 				8034C6611487636400AC32E9 /* AccessibilityControllerMac.mm */,
-				299E2AA41E3DEE140065DC30 /* AccessibilityCommonMac.h */,
 				29A8FCE4145F0464009045A6 /* AccessibilityTextMarkerRangeMac.mm */,
 				29210EAB144CACB200835BB5 /* AccessibilityUIElementMac.mm */,
 				BC8DAD771316D7B900EC96FC /* InjectedBundleMac.mm */,
@@ -806,9 +811,9 @@
 			buildActionMask = 2147483647;
 			files = (
 				2DB6187E1D7D58D400978D19 /* CoreGraphicsTestSPI.h in Headers */,
+				2DD4C49A1D6E7D3B0007379C /* EventSerializerMac.h in Headers */,
 				0F73B5521BA78968004B3EF4 /* JSUIScriptController.h in Headers */,
 				2DFA98481D7F70CF00AFF2C9 /* SharedEventStreamsMac.h in Headers */,
-				2DD4C49A1D6E7D3B0007379C /* EventSerializerMac.h in Headers */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
@@ -982,6 +987,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				2E749BF21891EBFA007FC175 /* EventSenderProxyIOS.mm in Sources */,
+				4430AE191F82C4FD0099915A /* GeneratedTouchesDebugWindow.mm in Sources */,
 				0FEBF85A1BB61DF20028722D /* HIDEventGenerator.mm in Sources */,
 				2E63ED941891ADAD002A7AFC /* mainIOS.mm in Sources */,
 				2E63ED911891ADAD002A7AFC /* PlatformWebViewIOS.mm in Sources */,
@@ -1011,16 +1017,16 @@
 			files = (
 				A185103A1B9AE0DA00744AEB /* CrashReporterInfo.mm in Sources */,
 				A185103E1B9AE12200744AEB /* CyclicRedundancyCheck.cpp in Sources */,
+				2DD4C49B1D6E7D3B0007379C /* EventSerializerMac.mm in Sources */,
 				A185103F1B9AE12900744AEB /* GeolocationProviderMock.cpp in Sources */,
+				31DA8A3D1E7205CC00E1DF2F /* IOSLayoutTestCommunication.cpp in Sources */,
 				0F73B5511BA78968004B3EF4 /* JSUIScriptController.cpp in Sources */,
 				0F18E7181D6BC4560027E547 /* JSWrapper.cpp in Sources */,
 				A185103C1B9AE0FE00744AEB /* Options.cpp in Sources */,
-				2DD4C49B1D6E7D3B0007379C /* EventSerializerMac.mm in Sources */,
 				A18510401B9AE13100744AEB /* PixelDumpSupport.cpp in Sources */,
+				2DFA98491D7F70CF00AFF2C9 /* SharedEventStreamsMac.mm in Sources */,
 				A18510411B9AE13800744AEB /* TestController.cpp in Sources */,
-				2DFA98491D7F70CF00AFF2C9 /* SharedEventStreamsMac.mm in Sources */,
 				A185103B1B9AE0E200744AEB /* TestControllerCocoa.mm in Sources */,
-				31DA8A3D1E7205CC00E1DF2F /* IOSLayoutTestCommunication.cpp in Sources */,
 				A18510421B9AE13E00744AEB /* TestInvocation.cpp in Sources */,
 				A185103D1B9AE10600744AEB /* TestInvocationCG.cpp in Sources */,
 				0F622CE91BBB3A1A00838AD3 /* TestOptions.cpp in Sources */,

Added: trunk/Tools/WebKitTestRunner/ios/GeneratedTouchesDebugWindow.h (0 => 222890)


--- trunk/Tools/WebKitTestRunner/ios/GeneratedTouchesDebugWindow.h	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/ios/GeneratedTouchesDebugWindow.h	2017-10-05 00:02:05 UTC (rev 222890)
@@ -0,0 +1,35 @@
+/*
+ * 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.
+ */
+
+#import <CoreGraphics/CGGeometry.h>
+
+@interface GeneratedTouchesDebugWindow : NSObject
+@property (nonatomic, assign) BOOL shouldShowTouches;
+
++ (GeneratedTouchesDebugWindow *)sharedGeneratedTouchesDebugWindow;
+- (void)updateDebugIndicatorForTouch:(NSUInteger)index withPointInWindowCoordinates:(CGPoint)point isTouching:(BOOL)isTouching;
+@end
+
+

Added: trunk/Tools/WebKitTestRunner/ios/GeneratedTouchesDebugWindow.mm (0 => 222890)


--- trunk/Tools/WebKitTestRunner/ios/GeneratedTouchesDebugWindow.mm	                        (rev 0)
+++ trunk/Tools/WebKitTestRunner/ios/GeneratedTouchesDebugWindow.mm	2017-10-05 00:02:05 UTC (rev 222890)
@@ -0,0 +1,102 @@
+/*
+ * 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.
+ */
+
+#import "config.h"
+#import "GeneratedTouchesDebugWindow.h"
+
+#import "HIDEventGenerator.h"
+#import "UIKitTestSPI.h"
+#import <wtf/RetainPtr.h>
+
+static const CGFloat debugTouchDotRadius = 5;
+static const CGFloat debugTouchDotSize = debugTouchDotRadius * 2;
+
+@interface GeneratedTouchesDebugWindow ()
+@property (nonatomic, strong) NSArray<UIView *> *debugTouchViews;
+@property (nonatomic, strong) UIApplicationRotationFollowingWindow *debugTouchWindow;
+@end
+
+@implementation GeneratedTouchesDebugWindow
+
++ (GeneratedTouchesDebugWindow *)sharedGeneratedTouchesDebugWindow
+{
+    static dispatch_once_t onceToken;
+    static GeneratedTouchesDebugWindow *touchWindow = nil;
+    dispatch_once(&onceToken, ^{
+        touchWindow = [[GeneratedTouchesDebugWindow alloc] init];
+    });
+    return touchWindow;
+}
+
+- (void)dealloc
+{
+    _debugTouchWindow.hidden = YES;
+    [_debugTouchWindow release];
+    [_debugTouchViews release];
+    
+    [super dealloc];
+}
+
+- (void)updateDebugIndicatorForTouch:(NSUInteger)index withPointInWindowCoordinates:(CGPoint)point isTouching:(BOOL)isTouching
+{
+    [self initDebugViewsIfNeeded];
+    
+    if (index < self.debugTouchViews.count) {
+        self.debugTouchViews[index].hidden = !isTouching;
+        self.debugTouchViews[index].center = point;
+    }
+}
+
+- (void)initDebugViewsIfNeeded
+{
+    if (!self.shouldShowTouches)
+        return;
+    
+    static dispatch_once_t _onceToken_ = 0;
+    dispatch_once(&onceToken, ^{
+        auto touchWindow = adoptNS([[UIApplicationRotationFollowingWindow alloc] init]);
+        auto viewController = adoptNS([[UIApplicationRotationFollowingControllerNoTouches alloc] init]);
+        [touchWindow setRootViewController:viewController.get()];
+        [touchWindow setHidden:NO];
+        [touchWindow setBackgroundColor:[UIColor clearColor]];
+        [touchWindow setUserInteractionEnabled:NO];
+        self.debugTouchWindow = touchWindow.get();
+        
+        NSMutableArray *debugViews = [NSMutableArray arrayWithCapacity:HIDMaxTouchCount];
+        
+        for (NSUInteger i = 0; i < HIDMaxTouchCount; ++i) {
+            auto newView = adoptNS([[UIView alloc] initWithFrame:CGRectMake(10, 10, debugTouchDotSize, debugTouchDotSize)]);
+            [newView setUserInteractionEnabled:NO];
+            [newView layer].cornerRadius = debugTouchDotRadius;
+            [newView setBackgroundColor:[UIColor colorWithRed:1.0 - i * .05 green:0.0 blue:1.0 - i * .05 alpha:0.5]];
+            [newView setHidden:YES];
+            debugViews[i] = newView.get();
+            [[touchWindow rootViewController].view addSubview:debugViews[i]];
+        }
+        self.debugTouchViews = [NSArray arrayWithArray:debugViews];
+    });
+}
+
+@end

Modified: trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.h (222889 => 222890)


--- trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.h	2017-10-04 23:58:02 UTC (rev 222889)
+++ trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.h	2017-10-05 00:02:05 UTC (rev 222890)
@@ -64,11 +64,12 @@
 extern NSString* const HIDEventPhaseEnded;
 extern NSString* const HIDEventPhaseCanceled;
 
+// Values for touch counts, etc, to keep debug code in sync
 
+extern NSUInteger const HIDMaxTouchCount;
+
 @interface HIDEventGenerator : NSObject
 
-@property (nonatomic, assign) BOOL shouldShowTouches;
-
 + (HIDEventGenerator *)sharedHIDEventGenerator;
 
 // Touches

Modified: trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm (222889 => 222890)


--- trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm	2017-10-04 23:58:02 UTC (rev 222889)
+++ trunk/Tools/WebKitTestRunner/ios/HIDEventGenerator.mm	2017-10-05 00:02:05 UTC (rev 222890)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "HIDEventGenerator.h"
 
+#import "GeneratedTouchesDebugWindow.h"
 #import "IOKitSPI.h"
 #import "UIKitTestSPI.h"
 #import <mach/mach_time.h>
@@ -77,14 +78,14 @@
 static const NSTimeInterval longPressHoldDelay = 2.0;
 static const IOHIDFloat defaultMajorRadius = 5;
 static const IOHIDFloat defaultPathPressure = 0;
-static const NSUInteger maxTouchCount = 5;
 static const long nanosecondsPerSecond = 1e9;
 
-static const NSUInteger debugTouchDotRadius = 5;
-static const NSUInteger debugTouchDotSize = debugTouchDotRadius * 2;
+NSUInteger const HIDMaxTouchCount = 5;
 
-static int fingerIdentifiers[maxTouchCount] = { 2, 3, 4, 5, 1 };
 
+
+static int fingerIdentifiers[HIDMaxTouchCount] = { 2, 3, 4, 5, 1 };
+
 typedef enum {
     InterpolationTypeLinear,
     InterpolationTypeSimpleCurve,
@@ -157,7 +158,7 @@
 
 @implementation HIDEventGenerator {
     IOHIDEventSystemClientRef _ioSystemClient;
-    SyntheticEventDigitizerInfo _activePoints[maxTouchCount];
+    SyntheticEventDigitizerInfo _activePoints[HIDMaxTouchCount];
     NSUInteger _activePointCount;
 }
 
@@ -182,7 +183,7 @@
     if (!self)
         return nil;
 
-    for (NSUInteger i = 0; i < maxTouchCount; ++i)
+    for (NSUInteger i = 0; i < HIDMaxTouchCount; ++i)
         _activePoints[i].identifier = fingerIdentifiers[i];
 
     _eventCallbacks = [[NSMutableDictionary alloc] init];
@@ -197,24 +198,7 @@
     [super dealloc];
 }
 
-- (void)initDebugViewsIfNeeded
-{
-    if (!self.shouldShowTouches || self.debugTouchViews)
-        return;
 
-    NSMutableArray *debugViews = [NSMutableArray arrayWithCapacity:maxTouchCount];
-    
-    for (NSUInteger i = 0; i < maxTouchCount; ++i) {
-        auto newView = adoptNS([[UIView alloc] initWithFrame:CGRectMake(10, 10, debugTouchDotSize, debugTouchDotSize)]);
-        [newView setUserInteractionEnabled:NO];
-        [newView layer].cornerRadius = debugTouchDotRadius;
-        [newView setBackgroundColor:[UIColor colorWithRed:1.0-i*.05 green:0.0 blue:1.0-i*.05 alpha:0.5]];
-        [newView setHidden:YES];
-        debugViews[i] = newView.get();
-        [[[UIApplication sharedApplication] keyWindow] addSubview:debugViews[i]];
-    }
-    self.debugTouchViews = [NSArray arrayWithArray:debugViews];
-}
 
 - (void)_sendIOHIDKeyboardEvent:(uint64_t)timestamp usage:(uint32_t)usage isKeyDown:(bool)isKeyDown
 {
@@ -303,14 +287,6 @@
     return 0;
 }
 
-- (void)updateDebugIndicatorForTouch:(NSUInteger)index withPoint:(CGPoint)point isTouching:(BOOL)isTouching
-{
-    [self initDebugViewsIfNeeded];
-    
-    self.debugTouchViews[index].hidden = !isTouching;
-    self.debugTouchViews[index].center = point;
-}
-
 // FIXME: callers of _createIOHIDEventType could switch to this.
 - (IOHIDEventRef)_createIOHIDEventWithInfo:(NSDictionary *)info
 {
@@ -341,9 +317,9 @@
 
     NSArray *childEvents = info[HIDEventTouchesKey];
     for (NSDictionary *touchInfo in childEvents) {
-        if (self.shouldShowTouches)
-            [self updateDebugIndicatorForTouch:[touchInfo[HIDEventTouchIDKey] intValue] withPoint:CGPointMake([touchInfo[HIDEventXKey] floatValue], [touchInfo[HIDEventYKey] floatValue]) isTouching:(BOOL)touch];
         
+        [[GeneratedTouchesDebugWindow sharedGeneratedTouchesDebugWindow] updateDebugIndicatorForTouch:[touchInfo[HIDEventTouchIDKey] intValue] withPointInWindowCoordinates:CGPointMake([touchInfo[HIDEventXKey] floatValue], [touchInfo[HIDEventYKey] floatValue]) isTouching:(BOOL)touch];
+        
         IOHIDDigitizerEventMask childEventMask = 0;
 
         UITouchPhase phase = phaseFromString(touchInfo[HIDEventPhaseKey]);
@@ -430,8 +406,8 @@
 
         CGPoint point = pointInfo->point;
         point = CGPointMake(roundf(point.x), roundf(point.y));
-        if (self.shouldShowTouches)
-            [self updateDebugIndicatorForTouch:i withPoint:point isTouching:isTouching];
+        
+        [[GeneratedTouchesDebugWindow sharedGeneratedTouchesDebugWindow] updateDebugIndicatorForTouch:i withPointInWindowCoordinates:point isTouching:isTouching];
 
         RetainPtr<IOHIDEventRef> subEvent;
         if (pointInfo->isStylus) {
@@ -549,8 +525,7 @@
     // Update point locations.
     for (NSUInteger i = 0; i < count; ++i) {
         _activePoints[i].point = points[i];
-        if (self.shouldShowTouches)
-            [self updateDebugIndicatorForTouch:i withPoint:points[i] isTouching:YES];
+        [[GeneratedTouchesDebugWindow sharedGeneratedTouchesDebugWindow] updateDebugIndicatorForTouch:i withPointInWindowCoordinates:points[i] isTouching:YES];
     }
     
     RetainPtr<IOHIDEventRef> eventRef = adoptCF([self _createIOHIDEventType:handEventType]);
@@ -559,7 +534,7 @@
 
 - (void)touchDownAtPoints:(CGPoint*)locations touchCount:(NSUInteger)touchCount
 {
-    touchCount = MIN(touchCount, maxTouchCount);
+    touchCount = std::min(touchCount, HIDMaxTouchCount);
 
     _activePointCount = touchCount;
 
@@ -567,8 +542,7 @@
         _activePoints[index].point = locations[index];
         _activePoints[index].isStylus = NO;
         
-        if (self.shouldShowTouches)
-            [self updateDebugIndicatorForTouch:index withPoint:locations[index] isTouching:YES];
+        [[GeneratedTouchesDebugWindow sharedGeneratedTouchesDebugWindow] updateDebugIndicatorForTouch:index withPointInWindowCoordinates:locations[index] isTouching:YES];
     }
 
     RetainPtr<IOHIDEventRef> eventRef = adoptCF([self _createIOHIDEventType:HandEventTouched]);
@@ -577,7 +551,7 @@
 
 - (void)touchDown:(CGPoint)location touchCount:(NSUInteger)touchCount
 {
-    touchCount = MIN(touchCount, maxTouchCount);
+    touchCount = std::min(touchCount, HIDMaxTouchCount);
 
     CGPoint locations[touchCount];
 
@@ -594,15 +568,15 @@
 
 - (void)liftUpAtPoints:(CGPoint*)locations touchCount:(NSUInteger)touchCount
 {
-    touchCount = MIN(touchCount, maxTouchCount);
-    touchCount = MIN(touchCount, _activePointCount);
+    touchCount = std::min(touchCount, HIDMaxTouchCount);
+    touchCount = std::min(touchCount, _activePointCount);
 
     NSUInteger newPointCount = _activePointCount - touchCount;
 
     for (NSUInteger index = 0; index < touchCount; ++index) {
         _activePoints[newPointCount + index].point = locations[index];
-        if (self.shouldShowTouches)
-            self.debugTouchViews[index].hidden = YES;
+        
+        [[GeneratedTouchesDebugWindow sharedGeneratedTouchesDebugWindow] updateDebugIndicatorForTouch:index withPointInWindowCoordinates:CGPointZero isTouching:NO];
     }
     
     RetainPtr<IOHIDEventRef> eventRef = adoptCF([self _createIOHIDEventType:HandEventLifted]);
@@ -613,7 +587,7 @@
 
 - (void)liftUp:(CGPoint)location touchCount:(NSUInteger)touchCount
 {
-    touchCount = MIN(touchCount, maxTouchCount);
+    touchCount = std::min(touchCount, HIDMaxTouchCount);
 
     CGPoint locations[touchCount];
 
@@ -630,7 +604,7 @@
 
 - (void)moveToPoints:(CGPoint*)newLocations touchCount:(NSUInteger)touchCount duration:(NSTimeInterval)seconds
 {
-    touchCount = MIN(touchCount, maxTouchCount);
+    touchCount = std::min(touchCount, HIDMaxTouchCount);
 
     CGPoint startLocations[touchCount];
     CGPoint nextLocations[touchCount];

Modified: trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm (222889 => 222890)


--- trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2017-10-04 23:58:02 UTC (rev 222889)
+++ trunk/Tools/WebKitTestRunner/ios/TestControllerIOS.mm	2017-10-05 00:02:05 UTC (rev 222890)
@@ -26,6 +26,7 @@
 #import "config.h"
 #import "TestController.h"
 
+#import "GeneratedTouchesDebugWindow.h"
 #import "HIDEventGenerator.h"
 #import "IOSLayoutTestCommunication.h"
 #import "PlatformWebView.h"
@@ -129,9 +130,8 @@
 
 void TestController::updatePlatformSpecificTestOptionsForTest(TestOptions& options, const std::string&) const
 {
-    
     options.shouldShowTouches = shouldShowTouches();
-    [[HIDEventGenerator sharedHIDEventGenerator] setShouldShowTouches:options.shouldShowTouches];
+    [[GeneratedTouchesDebugWindow sharedGeneratedTouchesDebugWindow] setShouldShowTouches:options.shouldShowTouches];
 }
 
 void TestController::platformInitializeContext()
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to