Title: [230055] trunk
Revision
230055
Author
wenson_hs...@apple.com
Date
2018-03-28 15:03:04 -0700 (Wed, 28 Mar 2018)

Log Message

[iOS] Multiple select appearance doesn't update when selecting or deselecting rows in the picker view
https://bugs.webkit.org/show_bug.cgi?id=184110
<rdar://problem/38796648>

Reviewed by Tim Horton.

Source/WebCore:

HTMLSelectElement::optionSelectedByUser is invoked upon user interaction with a select menu. This currently
takes two separate codepaths, depending on whether or not the menu list appearance is being used to render the
select. If a menu list appearance is used, we call selectOption(), which updates validity, updates the element
renderer, and then dispatches a `change` event if needed.

However, if updateSelectedState() is used, we only update form validity and then dispatch the `change` event
without updating the renderer, leaving it stale.

Test: fast/forms/ios/ipad/multiple-select-updates-renderer.html

* html/HTMLSelectElement.cpp:
(WebCore::HTMLSelectElement::optionSelectedByUser):

Update the renderer after updating the DOM to reflect the selected option.

LayoutTests:

Adds a new layout test to verify that after tapping on a multiple select and choosing an option, the select's
renderer is updated to reflect its new state.

* fast/forms/ios/ipad/multiple-select-updates-renderer-expected.txt: Added.
* fast/forms/ios/ipad/multiple-select-updates-renderer.html: Added.
* resources/basic-gestures.js:

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (230054 => 230055)


--- trunk/LayoutTests/ChangeLog	2018-03-28 21:45:40 UTC (rev 230054)
+++ trunk/LayoutTests/ChangeLog	2018-03-28 22:03:04 UTC (rev 230055)
@@ -1,3 +1,18 @@
+2018-03-28  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] Multiple select appearance doesn't update when selecting or deselecting rows in the picker view
+        https://bugs.webkit.org/show_bug.cgi?id=184110
+        <rdar://problem/38796648>
+
+        Reviewed by Tim Horton.
+
+        Adds a new layout test to verify that after tapping on a multiple select and choosing an option, the select's
+        renderer is updated to reflect its new state.
+
+        * fast/forms/ios/ipad/multiple-select-updates-renderer-expected.txt: Added.
+        * fast/forms/ios/ipad/multiple-select-updates-renderer.html: Added.
+        * resources/basic-gestures.js:
+
 2018-03-28  Per Arne Vollan  <pvol...@apple.com>
 
         Mark http/tests/preload/download_resources.html as a flaky crash on Windows.

Added: trunk/LayoutTests/fast/forms/ios/ipad/multiple-select-updates-renderer-expected.txt (0 => 230055)


--- trunk/LayoutTests/fast/forms/ios/ipad/multiple-select-updates-renderer-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/ipad/multiple-select-updates-renderer-expected.txt	2018-03-28 22:03:04 UTC (rev 230055)
@@ -0,0 +1,2 @@
+
+PASS

Added: trunk/LayoutTests/fast/forms/ios/ipad/multiple-select-updates-renderer.html (0 => 230055)


--- trunk/LayoutTests/fast/forms/ios/ipad/multiple-select-updates-renderer.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/ios/ipad/multiple-select-updates-renderer.html	2018-03-28 22:03:04 UTC (rev 230055)
@@ -0,0 +1,61 @@
+<!DOCTYPE html> <!-- webkit-test-runner [ useFlexibleViewport=true ] -->
+<html>
+<head>
+<meta name="viewport" content="initial-scale=1.0, user-scalable=no">
+<style>
+    body, html {
+        width: 100%;
+        height: 100%;
+        margin: 0;
+    }
+    select {
+        width: 200px;
+        height: 200px;
+    }
+</style>
+<script src=""
+<script>
+    async function run()
+    {
+        if (!window.testRunner)
+            return;
+
+        await tapAtPoint(100, 100);
+        await selectFormAccessoryPickerRow(0);
+        doneEvaluatingUIScript = true;
+        checkDone();
+    }
+
+    function checkDone()
+    {
+        if (window.doneEvaluatingUIScript && window.valueChanged && window.testRunner)
+            testRunner.notifyDone();
+    }
+</script>
+</head>
+<body _onload_="run()">
+    <select multiple id="select"><option>This is an option.</option></select>
+    <pre id="output"></pre>
+</body>
+<script>
+    select.addEventListener("change", () => {
+        if (window.internals) {
+            const renderTreeAsText = internals.elementRenderTreeAsText(document.documentElement);
+            const expectedOptionValue = "This is an option.";
+            if (renderTreeAsText.indexOf(expectedOptionValue) != -1)
+                output.textContent = "PASS";
+            else
+                output.textContent = `FAIL: expected '${expectedOptionValue}' in render tree dump:\n${renderTreeAsText}`;
+        }
+
+        select.blur();
+        valueChanged = true;
+        checkDone();
+    });
+
+    if (window.testRunner) {
+        testRunner.waitUntilDone();
+        testRunner.dumpAsText();
+    }
+</script>
+</html>

Modified: trunk/LayoutTests/resources/basic-gestures.js (230054 => 230055)


--- trunk/LayoutTests/resources/basic-gestures.js	2018-03-28 21:45:40 UTC (rev 230054)
+++ trunk/LayoutTests/resources/basic-gestures.js	2018-03-28 22:03:04 UTC (rev 230055)
@@ -140,6 +140,12 @@
     });
 }
 
+function selectFormAccessoryPickerRow(rowIndex)
+{
+    const selectRowScript = `(() => uiController.selectFormAccessoryPickerRow(${rowIndex}))()`;
+    return new Promise(resolve => testRunner.runUIScript(selectRowScript, resolve));
+}
+
 function holdAtPoint(x, y)
 {
     return new Promise(resolve => {

Modified: trunk/Source/WebCore/ChangeLog (230054 => 230055)


--- trunk/Source/WebCore/ChangeLog	2018-03-28 21:45:40 UTC (rev 230054)
+++ trunk/Source/WebCore/ChangeLog	2018-03-28 22:03:04 UTC (rev 230055)
@@ -1,3 +1,26 @@
+2018-03-28  Wenson Hsieh  <wenson_hs...@apple.com>
+
+        [iOS] Multiple select appearance doesn't update when selecting or deselecting rows in the picker view
+        https://bugs.webkit.org/show_bug.cgi?id=184110
+        <rdar://problem/38796648>
+
+        Reviewed by Tim Horton.
+
+        HTMLSelectElement::optionSelectedByUser is invoked upon user interaction with a select menu. This currently
+        takes two separate codepaths, depending on whether or not the menu list appearance is being used to render the
+        select. If a menu list appearance is used, we call selectOption(), which updates validity, updates the element
+        renderer, and then dispatches a `change` event if needed.
+
+        However, if updateSelectedState() is used, we only update form validity and then dispatch the `change` event
+        without updating the renderer, leaving it stale.
+
+        Test: fast/forms/ios/ipad/multiple-select-updates-renderer.html
+
+        * html/HTMLSelectElement.cpp:
+        (WebCore::HTMLSelectElement::optionSelectedByUser):
+
+        Update the renderer after updating the DOM to reflect the selected option.
+
 2018-03-28  Daniel Bates  <daba...@apple.com>
 
         Substitute "strong password confirmation auto fill" for "strong confirmation password auto fill"

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (230054 => 230055)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2018-03-28 21:45:40 UTC (rev 230054)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2018-03-28 22:03:04 UTC (rev 230055)
@@ -117,6 +117,8 @@
     if (!usesMenuList()) {
         updateSelectedState(optionToListIndex(optionIndex), allowMultipleSelection, false);
         updateValidity();
+        if (auto* renderer = this->renderer())
+            renderer->updateFromElement();
         if (fireOnChangeNow)
             listBoxOnChange();
         return;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to