Title: [248302] trunk
Revision
248302
Author
jer.no...@apple.com
Date
2019-08-06 10:34:27 -0700 (Tue, 06 Aug 2019)

Log Message

Add test for behavior introduced in r248174
https://bugs.webkit.org/show_bug.cgi?id=200446

Reviewed by Eric Carlson.

Source/WebKit:

Add a new helper struct, FullscreenTouchSecheuristicParameters, and static getter,
iosParameters(), to allow the settings used by WKFullScreenViewController to be tested
in TestWebKitAPI. Make both of the Secheuristic classes privately exported as well.

* UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.cpp:
(WebKit::FullscreenTouchSecheuristic::scoreOfNextTouch):
(WebKit::FullscreenTouchSecheuristic::reset):
(WebKit::FullscreenTouchSecheuristic::distanceScore):
(WebKit::FullscreenTouchSecheuristic::attenuationFactor):
* UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h:
(WebKit::FullscreenTouchSecheuristic::setParameters):
(WebKit::FullscreenTouchSecheuristic::requiredScore const):
(WebKit::FullscreenTouchSecheuristic::setRampUpSpeed):
(WebKit::FullscreenTouchSecheuristic::setRampDownSpeed):
(WebKit::FullscreenTouchSecheuristic::setXWeight):
(WebKit::FullscreenTouchSecheuristic::setYWeight):
(WebKit::FullscreenTouchSecheuristic::setGamma):
(WebKit::FullscreenTouchSecheuristic::setGammaCutoff):
* UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.cpp: Copied from Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h.
(WebKit::FullscreenTouchSecheuristicParameters::iosParameters):
* UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.h: Copied from Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h.
* UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
(-[WKFullScreenViewController initWithWebView:]):
(-[WKFullScreenViewController _touchDetected:]):
* WebKit.xcodeproj/project.pbxproj:

Tools:

* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/ios/FullscreenTouchSecheuristicTests.cpp: Added.
(WebKit::configureSecheuristic):
(WebKit::TEST):

Modified Paths

Added Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (248301 => 248302)


--- trunk/Source/WebKit/ChangeLog	2019-08-06 17:05:13 UTC (rev 248301)
+++ trunk/Source/WebKit/ChangeLog	2019-08-06 17:34:27 UTC (rev 248302)
@@ -1,3 +1,36 @@
+2019-08-06  Jer Noble  <jer.no...@apple.com>
+
+        Add test for behavior introduced in r248174
+        https://bugs.webkit.org/show_bug.cgi?id=200446
+
+        Reviewed by Eric Carlson.
+
+        Add a new helper struct, FullscreenTouchSecheuristicParameters, and static getter,
+        iosParameters(), to allow the settings used by WKFullScreenViewController to be tested
+        in TestWebKitAPI. Make both of the Secheuristic classes privately exported as well.
+
+        * UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.cpp:
+        (WebKit::FullscreenTouchSecheuristic::scoreOfNextTouch):
+        (WebKit::FullscreenTouchSecheuristic::reset):
+        (WebKit::FullscreenTouchSecheuristic::distanceScore):
+        (WebKit::FullscreenTouchSecheuristic::attenuationFactor):
+        * UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h:
+        (WebKit::FullscreenTouchSecheuristic::setParameters):
+        (WebKit::FullscreenTouchSecheuristic::requiredScore const):
+        (WebKit::FullscreenTouchSecheuristic::setRampUpSpeed):
+        (WebKit::FullscreenTouchSecheuristic::setRampDownSpeed):
+        (WebKit::FullscreenTouchSecheuristic::setXWeight):
+        (WebKit::FullscreenTouchSecheuristic::setYWeight):
+        (WebKit::FullscreenTouchSecheuristic::setGamma):
+        (WebKit::FullscreenTouchSecheuristic::setGammaCutoff):
+        * UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.cpp: Copied from Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h.
+        (WebKit::FullscreenTouchSecheuristicParameters::iosParameters):
+        * UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.h: Copied from Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h.
+        * UIProcess/ios/fullscreen/WKFullScreenViewController.mm:
+        (-[WKFullScreenViewController initWithWebView:]):
+        (-[WKFullScreenViewController _touchDetected:]):
+        * WebKit.xcodeproj/project.pbxproj:
+
 2019-08-06  Claudio Saavedra  <csaave...@igalia.com>
 
         [GLIB] Fix documentation typo

Modified: trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.cpp (248301 => 248302)


--- trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.cpp	2019-08-06 17:05:13 UTC (rev 248301)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.cpp	2019-08-06 17:34:27 UTC (rev 248302)
@@ -26,8 +26,6 @@
 #include "config.h"
 #include "FullscreenTouchSecheuristic.h"
 
-#if ENABLE(FULLSCREEN_API) && PLATFORM(IOS_FAMILY)
-
 #include <wtf/MonotonicTime.h>
 
 namespace WebKit {
@@ -38,16 +36,24 @@
 
     if (!m_lastTouchTime) {
         m_lastTouchTime = WTFMove(now);
-        m_lastTouchLocation = WTFMove(location);
         return 0;
     }
 
     Seconds deltaTime = now - m_lastTouchTime;
+    m_lastTouchTime = now;
 
+    return scoreOfNextTouch(location, deltaTime);
+}
+
+double FullscreenTouchSecheuristic::scoreOfNextTouch(CGPoint location, const Seconds& deltaTime)
+{
+    if (m_lastTouchLocation.x == -1 && m_lastTouchLocation.y ==  -1) {
+        m_lastTouchLocation = WTFMove(location);
+        return 0;
+    }
+
     double coefficient = attenuationFactor(deltaTime);
     m_lastScore = coefficient * distanceScore(location, m_lastTouchLocation, deltaTime) + (1 - coefficient) * m_lastScore;
-
-    m_lastTouchTime = now;
     m_lastTouchLocation = location;
     return m_lastScore;
 }
@@ -55,7 +61,7 @@
 void FullscreenTouchSecheuristic::reset()
 {
     m_lastTouchTime = 0_s;
-    m_lastTouchLocation = { };
+    m_lastTouchLocation = { -1, -1 };
     m_lastScore = 0;
 }
 
@@ -62,25 +68,23 @@
 double FullscreenTouchSecheuristic::distanceScore(const CGPoint& nextLocation, const CGPoint& lastLocation, const Seconds& deltaTime)
 {
     double distance = sqrt(
-        m_xWeight * pow(nextLocation.x - lastLocation.x, 2) +
-        m_yWeight * pow(nextLocation.y - lastLocation.y, 2));
+        m_parameters.xWeight * pow(nextLocation.x - lastLocation.x, 2) +
+        m_parameters.yWeight * pow(nextLocation.y - lastLocation.y, 2));
     double sizeFactor = sqrt(
-        m_xWeight * pow(m_size.width, 2) +
-        m_yWeight * pow(m_size.height, 2));
+        m_parameters.xWeight * pow(m_size.width, 2) +
+        m_parameters.yWeight * pow(m_size.height, 2));
     double scaledDistance = distance / sizeFactor;
-    if (scaledDistance <= m_cutoff)
-        return scaledDistance * (m_rampUpSpeed / deltaTime);
+    if (scaledDistance <= m_parameters.gammaCutoff)
+        return scaledDistance * (m_parameters.rampUpSpeed / deltaTime);
 
-    double exponentialDistance = m_cutoff + pow((scaledDistance - m_cutoff) / (1 - m_cutoff), m_gamma);
-    return exponentialDistance * (m_rampUpSpeed / deltaTime);
+    double exponentialDistance = m_parameters.gammaCutoff + pow((scaledDistance - m_parameters.gammaCutoff) / (1 - m_parameters.gammaCutoff), m_parameters.gamma);
+    return exponentialDistance * (m_parameters.rampUpSpeed / deltaTime);
 }
 
 double FullscreenTouchSecheuristic::attenuationFactor(Seconds delta)
 {
-    double normalizedTimeDelta = delta / m_rampDownSpeed;
+    double normalizedTimeDelta = delta / m_parameters.rampDownSpeed;
     return std::max(std::min(normalizedTimeDelta * m_weight, 1.0), 0.0);
 }
 
 }
-
-#endif // ENABLE(FULLSCREEN_API) && PLATFORM(IOS_FAMILY)

Modified: trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h (248301 => 248302)


--- trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h	2019-08-06 17:05:13 UTC (rev 248301)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h	2019-08-06 17:34:27 UTC (rev 248302)
@@ -25,42 +25,37 @@
 
 #pragma once
 
-#if ENABLE(FULLSCREEN_API) && PLATFORM(IOS_FAMILY)
+#include "FullscreenTouchSecheuristicParameters.h"
 
-#include <wtf/Seconds.h>
-
 namespace WebKit {
 
 class FullscreenTouchSecheuristic {
 public:
-    double scoreOfNextTouch(CGPoint location);
-    void reset();
+    WK_EXPORT double scoreOfNextTouch(CGPoint location);
+    WK_EXPORT double scoreOfNextTouch(CGPoint location, const Seconds& deltaTime);
+    WK_EXPORT void reset();
 
-    void setRampUpSpeed(Seconds speed) { m_rampUpSpeed = speed; }
-    void setRampDownSpeed(Seconds speed) { m_rampDownSpeed = speed; }
-    void setXWeight(double weight) { m_xWeight = weight; }
-    void setYWeight(double weight) { m_yWeight = weight; }
+    void setParameters(const FullscreenTouchSecheuristicParameters& parameters) { m_parameters = parameters; }
+    double requiredScore() const { return m_parameters.requiredScore; }
+
+    void setRampUpSpeed(Seconds speed) { m_parameters.rampUpSpeed = speed; }
+    void setRampDownSpeed(Seconds speed) { m_parameters.rampDownSpeed = speed; }
+    void setXWeight(double weight) { m_parameters.xWeight = weight; }
+    void setYWeight(double weight) { m_parameters.yWeight = weight; }
     void setSize(CGSize size) { m_size = size; }
-    void setGamma(double gamma) { m_gamma = gamma; }
-    void setGammaCutoff(double cutoff) { m_cutoff = cutoff; }
+    void setGamma(double gamma) { m_parameters.gamma = gamma; }
+    void setGammaCutoff(double cutoff) { m_parameters.gammaCutoff = cutoff; }
 
 private:
-    double distanceScore(const CGPoint& nextLocation, const CGPoint& lastLocation, const Seconds& deltaTime);
-    double attenuationFactor(Seconds delta);
+    WK_EXPORT double distanceScore(const CGPoint& nextLocation, const CGPoint& lastLocation, const Seconds& deltaTime);
+    WK_EXPORT double attenuationFactor(Seconds delta);
 
     double m_weight { 0.1 };
-    Seconds m_rampUpSpeed { 1 };
-    Seconds m_rampDownSpeed { 1 };
-    double m_xWeight { 1 };
-    double m_yWeight { 1 };
-    double m_gamma { 1 };
-    double m_cutoff { 1 };
+    FullscreenTouchSecheuristicParameters m_parameters;
     CGSize m_size { };
     Seconds m_lastTouchTime { 0 };
-    CGPoint m_lastTouchLocation { };
+    CGPoint m_lastTouchLocation { -1, -1 };
     double m_lastScore { 0 };
 };
 
 }
-
-#endif // ENABLE(FULLSCREEN_API) && PLATFORM(IOS_FAMILY)

Copied: trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.cpp (from rev 248301, trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h) (0 => 248302)


--- trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.cpp	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.cpp	2019-08-06 17:34:27 UTC (rev 248302)
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include "config.h"
+#include "FullscreenTouchSecheuristicParameters.h"
+
+namespace WebKit {
+
+FullscreenTouchSecheuristicParameters FullscreenTouchSecheuristicParameters::iosParameters()
+{
+    return {
+        .rampUpSpeed = 0.25_s,
+        .rampDownSpeed = 1_s,
+        .xWeight = 0,
+        .yWeight = 1,
+        .gamma = 0.1,
+        .gammaCutoff = 0.08,
+        .requiredScore = 0.1,
+    };
+}
+
+}

Copied: trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.h (from rev 248301, trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristic.h) (0 => 248302)


--- trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.h	                        (rev 0)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/FullscreenTouchSecheuristicParameters.h	2019-08-06 17:34:27 UTC (rev 248302)
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2019 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
+
+#include "WKDeclarationSpecifiers.h"
+#include <wtf/Seconds.h>
+
+namespace WebKit {
+
+struct FullscreenTouchSecheuristicParameters {
+    WTF::Seconds rampUpSpeed;
+    WTF::Seconds rampDownSpeed;
+    double xWeight;
+    double yWeight;
+    double gamma;
+    double gammaCutoff;
+    double requiredScore;
+
+    WK_EXPORT static FullscreenTouchSecheuristicParameters iosParameters();
+};
+
+}

Modified: trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm (248301 => 248302)


--- trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm	2019-08-06 17:05:13 UTC (rev 248301)
+++ trunk/Source/WebKit/UIProcess/ios/fullscreen/WKFullScreenViewController.mm	2019-08-06 17:34:27 UTC (rev 248302)
@@ -43,7 +43,6 @@
 static const NSTimeInterval showHideAnimationDuration = 0.1;
 static const NSTimeInterval pipHideAnimationDuration = 0.2;
 static const NSTimeInterval autoHideDelay = 4.0;
-static const double requiredScore = 0.1;
 
 @class WKFullscreenStackView;
 
@@ -183,11 +182,7 @@
     _nonZeroStatusBarHeight = UIApplication.sharedApplication.statusBarFrame.size.height;
     [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(_statusBarFrameDidChange:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil];
 ALLOW_DEPRECATED_DECLARATIONS_END
-    _secheuristic.setRampUpSpeed(Seconds(0.25));
-    _secheuristic.setRampDownSpeed(Seconds(1.));
-    _secheuristic.setXWeight(0);
-    _secheuristic.setGamma(0.1);
-    _secheuristic.setGammaCutoff(0.08);
+    _secheuristic.setParameters(WebKit::FullscreenTouchSecheuristicParameters::iosParameters());
 
     self._webView = webView;
 
@@ -531,7 +526,7 @@
 {
     if ([_touchGestureRecognizer state] == UIGestureRecognizerStateEnded) {
         double score = _secheuristic.scoreOfNextTouch([_touchGestureRecognizer locationInView:self.view]);
-        if (score > requiredScore)
+        if (score > _secheuristic.requiredScore())
             [self _showPhishingAlert];
     }
     if (!self.animating)

Modified: trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj (248301 => 248302)


--- trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-08-06 17:05:13 UTC (rev 248301)
+++ trunk/Source/WebKit/WebKit.xcodeproj/project.pbxproj	2019-08-06 17:34:27 UTC (rev 248302)
@@ -1593,7 +1593,7 @@
 		CD003A5319D49B5D005ABCE0 /* WebMediaKeyStorageManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CD003A5119D49B5D005ABCE0 /* WebMediaKeyStorageManager.h */; };
 		CD0C6831201FD10100A59409 /* WKFullScreenViewController.h in Headers */ = {isa = PBXBuildFile; fileRef = CD0C682F201FD10100A59409 /* WKFullScreenViewController.h */; };
 		CD19A26E1A13E834008D650E /* WebDiagnosticLoggingClient.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19A26A1A13E821008D650E /* WebDiagnosticLoggingClient.h */; };
-		CD19D2EA2046406F0017074A /* FullscreenTouchSecheuristic.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19D2E82046406F0017074A /* FullscreenTouchSecheuristic.h */; };
+		CD19D2EA2046406F0017074A /* FullscreenTouchSecheuristic.h in Headers */ = {isa = PBXBuildFile; fileRef = CD19D2E82046406F0017074A /* FullscreenTouchSecheuristic.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		CD2865EE2255562000606AC7 /* ProcessTaskStateObserver.h in Headers */ = {isa = PBXBuildFile; fileRef = CD2865EC2255562000606AC7 /* ProcessTaskStateObserver.h */; };
 		CD2865EF2255562000606AC7 /* ProcessTaskStateObserver.mm in Sources */ = {isa = PBXBuildFile; fileRef = CD2865ED2255562000606AC7 /* ProcessTaskStateObserver.mm */; };
 		CD491B081E70D05F00009066 /* UserMediaCaptureManager.h in Headers */ = {isa = PBXBuildFile; fileRef = CD491B061E70D05F00009066 /* UserMediaCaptureManager.h */; };
@@ -1616,6 +1616,8 @@
 		CDA29A291CBEB67A00901CCF /* PlaybackSessionManagerMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A251CBEB67A00901CCF /* PlaybackSessionManagerMessages.h */; };
 		CDA29A2A1CBEB67A00901CCF /* PlaybackSessionManagerProxyMessageReceiver.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA29A261CBEB67A00901CCF /* PlaybackSessionManagerProxyMessageReceiver.cpp */; };
 		CDA29A2B1CBEB67A00901CCF /* PlaybackSessionManagerProxyMessages.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA29A271CBEB67A00901CCF /* PlaybackSessionManagerProxyMessages.h */; };
+		CDA93DB022F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.h in Headers */ = {isa = PBXBuildFile; fileRef = CDA93DAE22F8BCF300490A69 /* FullscreenTouchSecheuristicParameters.h */; settings = {ATTRIBUTES = (Private, ); }; };
+		CDA93DB122F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA93DAF22F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.cpp */; };
 		CDC2831D201BD79D00E6E745 /* WKFullscreenStackView.h in Headers */ = {isa = PBXBuildFile; fileRef = CDC2831B201BD79D00E6E745 /* WKFullscreenStackView.h */; };
 		CDCA85C9132ABA4E00E961DF /* WKFullScreenWindowController.h in Headers */ = {isa = PBXBuildFile; fileRef = CDCA85C7132ABA4E00E961DF /* WKFullScreenWindowController.h */; };
 		CE11AD521CBC482F00681EE5 /* CodeSigning.h in Headers */ = {isa = PBXBuildFile; fileRef = CE11AD511CBC482F00681EE5 /* CodeSigning.h */; };
@@ -4560,6 +4562,8 @@
 		CDA29A251CBEB67A00901CCF /* PlaybackSessionManagerMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlaybackSessionManagerMessages.h; path = DerivedSources/WebKit2/PlaybackSessionManagerMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
 		CDA29A261CBEB67A00901CCF /* PlaybackSessionManagerProxyMessageReceiver.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; name = PlaybackSessionManagerProxyMessageReceiver.cpp; path = DerivedSources/WebKit2/PlaybackSessionManagerProxyMessageReceiver.cpp; sourceTree = BUILT_PRODUCTS_DIR; };
 		CDA29A271CBEB67A00901CCF /* PlaybackSessionManagerProxyMessages.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = PlaybackSessionManagerProxyMessages.h; path = DerivedSources/WebKit2/PlaybackSessionManagerProxyMessages.h; sourceTree = BUILT_PRODUCTS_DIR; };
+		CDA93DAE22F8BCF300490A69 /* FullscreenTouchSecheuristicParameters.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = FullscreenTouchSecheuristicParameters.h; path = ios/fullscreen/FullscreenTouchSecheuristicParameters.h; sourceTree = "<group>"; };
+		CDA93DAF22F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; name = FullscreenTouchSecheuristicParameters.cpp; path = ios/fullscreen/FullscreenTouchSecheuristicParameters.cpp; sourceTree = "<group>"; };
 		CDC2831B201BD79D00E6E745 /* WKFullscreenStackView.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = WKFullscreenStackView.h; path = ios/fullscreen/WKFullscreenStackView.h; sourceTree = "<group>"; };
 		CDC2831C201BD79D00E6E745 /* WKFullscreenStackView.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; name = WKFullscreenStackView.mm; path = ios/fullscreen/WKFullscreenStackView.mm; sourceTree = "<group>"; };
 		CDC382F717211506008A2FC3 /* CFNetwork.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CFNetwork.framework; path = /System/Library/Frameworks/CFNetwork.framework; sourceTree = "<absolute>"; };
@@ -8943,6 +8947,8 @@
 			children = (
 				CD19D2E92046406F0017074A /* FullscreenTouchSecheuristic.cpp */,
 				CD19D2E82046406F0017074A /* FullscreenTouchSecheuristic.h */,
+				CDA93DAE22F8BCF300490A69 /* FullscreenTouchSecheuristicParameters.h */,
+				CDA93DAF22F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.cpp */,
 				CDC2831B201BD79D00E6E745 /* WKFullscreenStackView.h */,
 				CDC2831C201BD79D00E6E745 /* WKFullscreenStackView.mm */,
 				CD0C682F201FD10100A59409 /* WKFullScreenViewController.h */,
@@ -10000,6 +10006,7 @@
 				1A445BA5184D5FDA004B3414 /* WKContextConnectionClient.h in Headers */,
 				1A445BA3184D5FCF004B3414 /* WKContextDownloadClient.h in Headers */,
 				1A445BA1184D5FC1004B3414 /* WKContextHistoryClient.h in Headers */,
+				CDA93DB022F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.h in Headers */,
 				1A445B9F184D5FB5004B3414 /* WKContextInjectedBundleClient.h in Headers */,
 				5C795D70229F373F003FF1C4 /* WKContextMenuElementInfo.h in Headers */,
 				5C795D71229F3757003FF1C4 /* WKContextMenuElementInfoPrivate.h in Headers */,
@@ -11146,6 +11153,7 @@
 				BC82844D16B5081C00A278FE /* PluginServiceEntryPoint.mm in Sources */,
 				2D91344D212CF9F000128AFD /* PluginView.cpp in Sources */,
 				2D54C31B212F4DA60049C174 /* ProcessLauncher.cpp in Sources */,
+				CDA93DB122F8BCF400490A69 /* FullscreenTouchSecheuristicParameters.cpp in Sources */,
 				CD2865EF2255562000606AC7 /* ProcessTaskStateObserver.mm in Sources */,
 				2D72A1FA212BF46E00517A20 /* RemoteLayerTreeDrawingArea.mm in Sources */,
 				0FF24A2D1879E4BC003ABF0C /* RemoteLayerTreeDrawingAreaProxyMessageReceiver.cpp in Sources */,

Modified: trunk/Tools/ChangeLog (248301 => 248302)


--- trunk/Tools/ChangeLog	2019-08-06 17:05:13 UTC (rev 248301)
+++ trunk/Tools/ChangeLog	2019-08-06 17:34:27 UTC (rev 248302)
@@ -1,3 +1,15 @@
+2019-08-06  Jer Noble  <jer.no...@apple.com>
+
+        Add test for behavior introduced in r248174
+        https://bugs.webkit.org/show_bug.cgi?id=200446
+
+        Reviewed by Eric Carlson.
+
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/ios/FullscreenTouchSecheuristicTests.cpp: Added.
+        (WebKit::configureSecheuristic):
+        (WebKit::TEST):
+
 2019-08-05  Fujii Hironori  <hironori.fu...@sony.com>
 
         [MiniBrowser][WK2] Unhandled key events should be bubbled up to the parent window

Modified: trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj (248301 => 248302)


--- trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-08-06 17:05:13 UTC (rev 248301)
+++ trunk/Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj	2019-08-06 17:34:27 UTC (rev 248302)
@@ -870,6 +870,7 @@
 		CDA3159A1ED548F1009F60D3 /* MediaPlaybackSleepAssertion.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDA315991ED540A5009F60D3 /* MediaPlaybackSleepAssertion.html */; };
 		CDA3159D1ED5643F009F60D3 /* IOKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = CDA3159C1ED5643F009F60D3 /* IOKit.framework */; };
 		CDA4438E21F7A47700379489 /* ProcessSuspendMediaBuffering.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDA4438D21F7A47700379489 /* ProcessSuspendMediaBuffering.mm */; };
+		CDA93DAD22F4F11E00490A69 /* FullscreenTouchSecheuristicTests.cpp in Sources */ = {isa = PBXBuildFile; fileRef = CDA93DAC22F4EC2200490A69 /* FullscreenTouchSecheuristicTests.cpp */; };
 		CDB4115A1E0B00DB00EAD352 /* video-with-muted-audio.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDB411591E09DA8E00EAD352 /* video-with-muted-audio.html */; };
 		CDB5DFFF213610FA00D3E189 /* now-playing.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = CDB5DFFE21360ED800D3E189 /* now-playing.html */; };
 		CDBFCC451A9FF45300A7B691 /* FullscreenZoomInitialFrame.mm in Sources */ = {isa = PBXBuildFile; fileRef = CDBFCC431A9FF44800A7B691 /* FullscreenZoomInitialFrame.mm */; };
@@ -2297,6 +2298,7 @@
 		CDA315991ED540A5009F60D3 /* MediaPlaybackSleepAssertion.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = MediaPlaybackSleepAssertion.html; sourceTree = "<group>"; };
 		CDA3159C1ED5643F009F60D3 /* IOKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = IOKit.framework; path = System/Library/Frameworks/IOKit.framework; sourceTree = SDKROOT; };
 		CDA4438D21F7A47700379489 /* ProcessSuspendMediaBuffering.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = ProcessSuspendMediaBuffering.mm; sourceTree = "<group>"; };
+		CDA93DAC22F4EC2200490A69 /* FullscreenTouchSecheuristicTests.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = FullscreenTouchSecheuristicTests.cpp; sourceTree = "<group>"; };
 		CDB411591E09DA8E00EAD352 /* video-with-muted-audio.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "video-with-muted-audio.html"; sourceTree = "<group>"; };
 		CDB5DFFE21360ED800D3E189 /* now-playing.html */ = {isa = PBXFileReference; lastKnownFileType = text.html; path = "now-playing.html"; sourceTree = "<group>"; };
 		CDBFCC421A9FF44800A7B691 /* FullscreenZoomInitialFrame.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = FullscreenZoomInitialFrame.html; sourceTree = "<group>"; };
@@ -3015,6 +3017,7 @@
 				F42D634322A1729F00D2FB3A /* AutocorrectionTestsIOS.mm */,
 				F4D4F3B71E4E36E400BB2767 /* DragAndDropTestsIOS.mm */,
 				F4BC0B132146C849002A0478 /* FocusPreservationTests.mm */,
+				CDA93DAC22F4EC2200490A69 /* FullscreenTouchSecheuristicTests.cpp */,
 				F45E15722112CE2900307E82 /* KeyboardInputTestsIOS.mm */,
 				7560917719259C59009EF06E /* MemoryCacheAddImageToCacheIOS.mm */,
 				F464AF9120BB66EA007F9B18 /* RenderingProgressTests.mm */,
@@ -4792,6 +4795,7 @@
 			buildActionMask = 2147483647;
 			files = (
 				9BD4239A1E04BD9800200395 /* AttributedSubstringForProposedRangeWithImage.mm in Sources */,
+				CDA93DAD22F4F11E00490A69 /* FullscreenTouchSecheuristicTests.cpp in Sources */,
 				5C9D923122D7E0EB008E9266 /* ClassMethodSwizzler.mm in Sources */,
 				2E7765CD16C4D80A00BA2BB1 /* mainIOS.mm in Sources */,
 				2E7765CF16C4D81100BA2BB1 /* mainMac.mm in Sources */,

Added: trunk/Tools/TestWebKitAPI/Tests/ios/FullscreenTouchSecheuristicTests.cpp (0 => 248302)


--- trunk/Tools/TestWebKitAPI/Tests/ios/FullscreenTouchSecheuristicTests.cpp	                        (rev 0)
+++ trunk/Tools/TestWebKitAPI/Tests/ios/FullscreenTouchSecheuristicTests.cpp	2019-08-06 17:34:27 UTC (rev 248302)
@@ -0,0 +1,146 @@
+/*
+ * Copyright (C) 2019 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.
+ */
+
+#include "config.h"
+
+#include "Test.h"
+#include <CoreGraphics/CGGeometry.h>
+#include <WebKit/FullscreenTouchSecheuristic.h>
+
+namespace WebKit {
+
+static void configureSecheuristic(FullscreenTouchSecheuristic& secheuristic)
+{
+    secheuristic.setRampUpSpeed(0.25_s);
+    secheuristic.setRampDownSpeed(1_s);
+    secheuristic.setGamma(0.1);
+    secheuristic.setGammaCutoff(0.08);
+    secheuristic.setSize(CGSizeMake(100, 100));
+    secheuristic.reset();
+}
+
+TEST(FullscreenTouchSecheuristic, Basic)
+{
+    using namespace WebKit;
+    FullscreenTouchSecheuristic secheuristic;
+    configureSecheuristic(secheuristic);
+
+    ASSERT_EQ(secheuristic.scoreOfNextTouch({0, 0}, 0_s), 0);
+    ASSERT_EQ(secheuristic.scoreOfNextTouch({0, 0}, .25_s), 0);
+    ASSERT_GT(secheuristic.scoreOfNextTouch({50, 50}, .25_s), 0);
+
+    secheuristic.reset();
+    secheuristic.setXWeight(0);
+    secheuristic.setYWeight(1);
+    ASSERT_EQ(secheuristic.scoreOfNextTouch({0, 0}, 0_s), 0);
+    ASSERT_EQ(secheuristic.scoreOfNextTouch({50, 0}, .25_s), 0);
+    ASSERT_GT(secheuristic.scoreOfNextTouch({0, 50}, .25_s), 0);
+
+    secheuristic.reset();
+    secheuristic.setXWeight(1);
+    secheuristic.setYWeight(0);
+    ASSERT_EQ(secheuristic.scoreOfNextTouch({0, 0}, 0_s), 0);
+    ASSERT_EQ(secheuristic.scoreOfNextTouch({0, 50}, .25_s), 0);
+    ASSERT_GT(secheuristic.scoreOfNextTouch({50, 0}, .25_s), 0);
+}
+
+TEST(FullscreenTouchSecheuristic, TapOnceVsTapTwice)
+{
+    using namespace WebKit;
+    FullscreenTouchSecheuristic twice;
+    configureSecheuristic(twice);
+
+    static const auto tapDelta = 0.25_s;
+    static const auto tapDuration = 0.1_s;
+    static const CGPoint location1 {0, 0};
+    static const CGPoint location2 {50, 50};
+
+    auto twiceScore = twice.scoreOfNextTouch(location1, 0_s);
+    twiceScore = twice.scoreOfNextTouch(location1, tapDuration);
+
+    ASSERT_EQ(twiceScore, 0);
+
+    FullscreenTouchSecheuristic once;
+    configureSecheuristic(once);
+
+    auto _onceScore_ = once.scoreOfNextTouch(location1, tapDuration);
+    ASSERT_EQ(onceScore, 0);
+
+    for (auto i = 0; i < 20; ++i) {
+        twiceScore = twice.scoreOfNextTouch(location2, tapDelta);
+        twiceScore = twice.scoreOfNextTouch(location2, tapDuration);
+
+        twiceScore = twice.scoreOfNextTouch(location1, tapDelta);
+        twiceScore = twice.scoreOfNextTouch(location1, tapDuration);
+    }
+
+    for (auto i = 0; i < 20; ++i) {
+        _onceScore_ = once.scoreOfNextTouch(location2, tapDelta + tapDuration);
+        _onceScore_ = once.scoreOfNextTouch(location1, tapDelta + tapDuration);
+    }
+
+    ASSERT_LT(abs(twiceScore - onceScore), 0.01);
+}
+
+TEST(FullscreenTouchSecheuristic, WKFullScreenViewControllerParameters)
+{
+    using namespace WebKit;
+
+    static const auto tapDelta = 0.25_s;
+    static const auto tapDuration = 0.1_s;
+    static const CGPoint locations[] = {
+        {1556, 1604},
+        {1883, 1427},
+        {1460, 1786},
+        {1930, 1602},
+        {760,  1430},
+        {760,  1430},
+        {200,  1780},
+        {470,  1280},
+        {430,  1610},
+        {2080, 1430},
+        {2080, 1430},
+        {1930, 1600},
+        {760,  1430},
+        {2570, 1620},
+    };
+
+    FullscreenTouchSecheuristic secheuristic;
+    secheuristic.setParameters(FullscreenTouchSecheuristicParameters::iosParameters());
+    secheuristic.setSize(CGSizeMake(2732, 2048));
+    secheuristic.reset();
+
+    size_t successfulTaps = 0;
+    for (auto& location : locations) {
+        auto score = secheuristic.scoreOfNextTouch(location, tapDelta + tapDuration);
+        if (score > secheuristic.requiredScore())
+            break;
+        ++successfulTaps;
+    }
+
+    ASSERT_LT(successfulTaps, std::size(locations));
+}
+
+}
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to