Title: [227855] trunk
Revision
227855
Author
[email protected]
Date
2018-01-30 14:16:08 -0800 (Tue, 30 Jan 2018)

Log Message

Make preserve and restore focus more likely to be symmetrical
https://bugs.webkit.org/show_bug.cgi?id=182264
Source/WebKit:

<rdar://problem/36948473>
        
Reviewed by Tim Horton.

Keep a stack of if we actually increment the focusState, so that
changes to the web content do not result in asymmetric decrements to the focus state. 
To work around problems associated with <rdar://problem/37000122>.

* UIProcess/ios/WKContentViewInteraction.h:
* UIProcess/ios/WKContentViewInteraction.mm:
(-[WKContentView _restoreFocusWithToken:]):
(-[WKContentView _preserveFocusWithToken:destructively:]):

LayoutTests:


Reviewed by Tim Horton.

Added new test to verify that opening a selection form twice works.

* fast/forms/ios/ipad/select-form-run-twice-expected.txt: Added.
* fast/forms/ios/ipad/select-form-run-twice.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (227854 => 227855)


--- trunk/LayoutTests/ChangeLog	2018-01-30 22:14:14 UTC (rev 227854)
+++ trunk/LayoutTests/ChangeLog	2018-01-30 22:16:08 UTC (rev 227855)
@@ -1,3 +1,15 @@
+2018-01-30  Megan Gardner  <[email protected]>
+
+        Make preserve and restore focus more likely to be symmetrical
+        https://bugs.webkit.org/show_bug.cgi?id=182264
+
+        Reviewed by Tim Horton.
+
+        Added new test to verify that opening a selection form twice works.
+
+        * fast/forms/ios/ipad/select-form-run-twice-expected.txt: Added.
+        * fast/forms/ios/ipad/select-form-run-twice.html: Added.
+
 2018-01-30  Dean Jackson  <[email protected]>
 
         CrashTracer: com.apple.WebKit.WebContent at WebCore: WebCore::Document::updateStyleIfNeeded

Added: trunk/LayoutTests/fast/forms/ios/ipad/select-form-run-twice-expected.txt (0 => 227855)


--- trunk/LayoutTests/fast/forms/ios/ipad/select-form-run-twice-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/ipad/select-form-run-twice-expected.txt	2018-01-30 22:16:08 UTC (rev 227855)
@@ -0,0 +1,7 @@
+This is the top
+
+First Click
+Final Click
+March June
+PASS: hit testing found #nextButton after first select interaction
+PASS: hit testing found #finalTarget after select interaction

Added: trunk/LayoutTests/fast/forms/ios/ipad/select-form-run-twice.html (0 => 227855)


--- trunk/LayoutTests/fast/forms/ios/ipad/select-form-run-twice.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/ipad/select-form-run-twice.html	2018-01-30 22:16:08 UTC (rev 227855)
@@ -0,0 +1,140 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+
+<html>
+<head>
+    <meta name="viewport" content="initial-scale=1.0, user-scalable=no">
+    <style>
+        body {
+            height: 1500px;
+        }
+        #container {
+            position: fixed;
+            top: 10px;
+            left: 10px;
+            bottom: 30px;
+            right: 10px;
+            background-color: rgba(0, 0, 0, 0.5);
+            padding: 10px;
+            box-sizing: border-box;
+            border: 5px solid black;
+        }
+        
+        select {
+            display: block;
+            margin: 500px 200px 20px 20px;
+        }
+        
+        button {
+            display: block;
+        }
+        
+    </style>
+    <script src=""
+    <script src=""
+    <script>
+        if (window.testRunner)
+            testRunner.waitUntilDone();
+
+        function getScrollDownUIScript(x, y)
+        {
+            return `
+                (function() {
+                    uiController.didEndScrollingCallback = function() {
+                        uiController.uiScriptComplete();
+                    };
+
+                    uiController.scrollToOffset(${x}, ${y});
+                })();`
+        }
+
+        function getTapOnSelectUIScript(x, y, row)
+        {
+            return `
+                (function() {
+                    uiController.didStartFormControlInteractionCallback = function() {
+                        uiController.selectFormAccessoryPickerRow(${row});
+                    };
+
+                    uiController.didEndFormControlInteractionCallback = function() {
+                        uiController.uiScriptComplete();
+                    };
+
+                    uiController.singleTapAtPoint(${x}, ${y}, function() {
+                    });
+                })();`
+        }
+
+        function firstButtonClicked()
+        {
+            document.getElementById('nextStep').textContent = 'PASS: hit testing found #nextButton after first select interaction';
+            var selectElement = document.getElementsByTagName('select')[0];
+            var point = getPointInsideElement(selectElement, 10, 10);
+            testRunner.runUIScript(getTapOnSelectUIScript(point.x, point.y, 5), function() {
+                document.getElementById('select-value2').textContent = selectElement.value;
+                    tryTapOnButton('finalTarget');
+            });
+        }
+    
+        function finalButtonClicked()
+        {
+            document.getElementById('result').textContent = 'PASS: hit testing found #finalTarget after select interaction';
+            if (window.testRunner)
+                testRunner.notifyDone();
+        }
+
+        async function tryTapOnButton(target)
+        {
+            var point = getPointInsideElement(document.getElementById(target), 10, 10);
+            await tapAtPoint(point.x, point.y);
+            
+            // We have to keep retrying, because the dimming view behind the popover animates out,
+            // and we currently have no callback when that animation completes.
+            window.setTimeout(tryTapOnButton.bind(this, target), 100);
+        }
+
+        function doTest()
+        {
+            if (!window.testRunner)
+                return;
+
+            testRunner.waitUntilDone();
+            testRunner.dumpAsText();
+
+            testRunner.runUIScript(getScrollDownUIScript(0, 500), function() {
+                var selectElement = document.getElementsByTagName('select')[0];
+                var point = getPointInsideElement(selectElement, 10, 10);
+                testRunner.runUIScript(getTapOnSelectUIScript(point.x, point.y, 2), function() {
+                    document.getElementById('select-value').textContent = selectElement.value;
+                    tryTapOnButton('firstTarget');
+                });
+            });
+        }
+        
+        window.addEventListener('load', doTest, false);
+    </script>
+</head>
+<body>
+    <p>This is the top</p>
+    <div id="container">
+        <button id="firstTarget" _onclick_="firstButtonClicked()">First Click</button>
+        <button id="finalTarget" _onclick_="finalButtonClicked()">Final Click</button>
+        <select>
+            <option>January</option>
+            <option>February</option>
+            <option>March</option>
+            <option>April</option>
+            <option>May</option>
+            <option>June</option>
+            <option>July</option>
+            <option>August</option>
+            <option>September</option>
+        </select>
+        <span id="select-value">Value goes here</span>
+        <span id="select-value2">2nd Value goes here</span>
+        <div id="nextStep">FAIL: should have hit-tested and found #target element</div>
+        <div id="result">FAIL: should have hit-tested and found #target element</div>
+    </div>
+    
+</div>
+</body>
+</html>

Modified: trunk/Source/WebKit/ChangeLog (227854 => 227855)


--- trunk/Source/WebKit/ChangeLog	2018-01-30 22:14:14 UTC (rev 227854)
+++ trunk/Source/WebKit/ChangeLog	2018-01-30 22:16:08 UTC (rev 227855)
@@ -1,3 +1,20 @@
+2018-01-30  Megan Gardner  <[email protected]>
+
+        Make preserve and restore focus more likely to be symmetrical
+        https://bugs.webkit.org/show_bug.cgi?id=182264
+        <rdar://problem/36948473>
+        
+        Reviewed by Tim Horton.
+
+        Keep a stack of if we actually increment the focusState, so that
+        changes to the web content do not result in asymmetric decrements to the focus state. 
+        To work around problems associated with <rdar://problem/37000122>.
+
+        * UIProcess/ios/WKContentViewInteraction.h:
+        * UIProcess/ios/WKContentViewInteraction.mm:
+        (-[WKContentView _restoreFocusWithToken:]):
+        (-[WKContentView _preserveFocusWithToken:destructively:]):
+
 2018-01-30  Brent Fulgham  <[email protected]>
 
         Add telemetry to track storage access API adoption

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h (227854 => 227855)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2018-01-30 22:14:14 UTC (rev 227854)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.h	2018-01-30 22:16:08 UTC (rev 227855)
@@ -171,6 +171,7 @@
     RetainPtr<WKFileUploadPanel> _fileUploadPanel;
     RetainPtr<UIGestureRecognizer> _previewGestureRecognizer;
     RetainPtr<UIGestureRecognizer> _previewSecondaryGestureRecognizer;
+    Vector<bool> _focusStateStack;
 #if HAVE(LINK_PREVIEW)
     RetainPtr<UIPreviewItemController> _previewItemController;
 #endif

Modified: trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm (227854 => 227855)


--- trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-01-30 22:14:14 UTC (rev 227854)
+++ trunk/Source/WebKit/UIProcess/ios/WKContentViewInteraction.mm	2018-01-30 22:16:08 UTC (rev 227855)
@@ -4169,14 +4169,21 @@
 
 - (void)_restoreFocusWithToken:(id <NSCopying, NSSecureCoding>)token
 {
-    if (!_inputPeripheral)
+    ASSERT(!_focusStateStack.isEmpty());
+    
+    if (_focusStateStack.takeLast()) {
+        ASSERT(_webView->_activeFocusedStateRetainCount);
         --_webView->_activeFocusedStateRetainCount;
+    }
 }
 
 - (void)_preserveFocusWithToken:(id <NSCopying, NSSecureCoding>)token destructively:(BOOL)destructively
 {
-    if (!_inputPeripheral)
+    if (!_inputPeripheral) {
         ++_webView->_activeFocusedStateRetainCount;
+        _focusStateStack.append(true);
+    } else
+        _focusStateStack.append(false);
 }
 
 #pragma mark - Implementation of UIWebTouchEventsGestureRecognizerDelegate.
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to