AutoFill button should not be shown in read-only or disabled field
authordbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Jun 2015 20:44:56 +0000 (20:44 +0000)
committerdbates@webkit.org <dbates@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 3 Jun 2015 20:44:56 +0000 (20:44 +0000)
https://bugs.webkit.org/show_bug.cgi?id=145579
<rdar://problem/21212494>

Reviewed by Darin Adler.

Source/WebCore:

Fixes an issue where the AutoFill button is shown in a read-only or disabled
field. We should not show the AutoFill button in such cases.

Tests: fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled.html
       fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly.html
       fast/forms/auto-fill-button/input-auto-fill-button.html
       fast/forms/auto-fill-button/input-disabled-auto-fill-button.html
       fast/forms/auto-fill-button/input-readonly-auto-fill-button.html
       fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button.html

* html/TextFieldInputType.cpp:
(WebCore::TextFieldInputType::disabledAttributeChanged): Update AutoFill button state.
(WebCore::TextFieldInputType::readonlyAttributeChanged): Ditto.
(WebCore::TextFieldInputType::shouldDrawAutoFillButton): Do not draw AutoFill button
when the field is disabled or read-only.

LayoutTests:

Add tests to ensure that we do no show the AutoFill button in a read-only or disabled field.

Additionally, create directory LayoutTests/fast/forms/auto-fill-button and move existing test
LayoutTests/fast/forms/input-auto-fill-button.html and associated test results into this directory
or the platform-specific variant of this directory.

* fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled-expected.html: Added.
* fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled.html: Added.
* fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly-expected.html: Added.
* fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly.html: Added.
* fast/forms/auto-fill-button/input-auto-fill-button-expected.txt: Renamed from LayoutTests/fast/forms/input-auto-fill-button-expected.txt.
* fast/forms/auto-fill-button/input-auto-fill-button.html: Renamed from LayoutTests/fast/forms/input-auto-fill-button.html.
* fast/forms/auto-fill-button/input-disabled-auto-fill-button-expected.html: Added.
* fast/forms/auto-fill-button/input-disabled-auto-fill-button.html: Added.
* fast/forms/auto-fill-button/input-readonly-auto-fill-button-expected.html: Added.
* fast/forms/auto-fill-button/input-readonly-auto-fill-button.html: Added.
* fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button-expected.html: Added.
* fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button.html: Added.
* platform/ios-simulator/fast/forms/auto-fill-button/input-auto-fill-button-expected.png: Renamed from LayoutTests/platform/ios-simulator/fast/forms/input-auto-fill-button-expected.png.
* platform/ios-simulator/fast/forms/auto-fill-button/input-auto-fill-button-expected.txt: Renamed from LayoutTests/platform/ios-simulator/fast/forms/input-auto-fill-button-expected.txt.
* platform/mac-mavericks/fast/forms/auto-fill-button/input-auto-fill-button-expected.txt: Renamed from LayoutTests/platform/mac-mavericks/fast/forms/input-auto-fill-button-expected.txt.
* platform/win/fast/forms/auto-fill-button/input-auto-fill-button-expected.txt: Renamed from LayoutTests/platform/win/fast/forms/input-auto-fill-button-expected.txt.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@185166 268f45cc-cd09-0410-ab3c-d52691b4dbfc

19 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled-expected.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly-expected.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/input-auto-fill-button-expected.txt [moved from LayoutTests/fast/forms/input-auto-fill-button-expected.txt with 100% similarity]
LayoutTests/fast/forms/auto-fill-button/input-auto-fill-button.html [moved from LayoutTests/fast/forms/input-auto-fill-button.html with 100% similarity]
LayoutTests/fast/forms/auto-fill-button/input-disabled-auto-fill-button-expected.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/input-disabled-auto-fill-button.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/input-readonly-auto-fill-button-expected.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/input-readonly-auto-fill-button.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button-expected.html [new file with mode: 0644]
LayoutTests/fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button.html [new file with mode: 0644]
LayoutTests/platform/ios-simulator/fast/forms/auto-fill-button/input-auto-fill-button-expected.png [moved from LayoutTests/platform/ios-simulator/fast/forms/input-auto-fill-button-expected.png with 100% similarity]
LayoutTests/platform/ios-simulator/fast/forms/auto-fill-button/input-auto-fill-button-expected.txt [moved from LayoutTests/platform/ios-simulator/fast/forms/input-auto-fill-button-expected.txt with 100% similarity]
LayoutTests/platform/mac-mavericks/fast/forms/auto-fill-button/input-auto-fill-button-expected.txt [moved from LayoutTests/platform/mac-mavericks/fast/forms/input-auto-fill-button-expected.txt with 100% similarity]
LayoutTests/platform/win/fast/forms/auto-fill-button/input-auto-fill-button-expected.txt [moved from LayoutTests/platform/win/fast/forms/input-auto-fill-button-expected.txt with 66% similarity]
Source/WebCore/ChangeLog
Source/WebCore/html/TextFieldInputType.cpp

index adb941c..0f99540 100644 (file)
@@ -1,3 +1,34 @@
+2015-06-03  Daniel Bates  <dabates@apple.com>
+
+        AutoFill button should not be shown in read-only or disabled field
+        https://bugs.webkit.org/show_bug.cgi?id=145579
+        <rdar://problem/21212494>
+
+        Reviewed by Darin Adler.
+
+        Add tests to ensure that we do no show the AutoFill button in a read-only or disabled field.
+
+        Additionally, create directory LayoutTests/fast/forms/auto-fill-button and move existing test
+        LayoutTests/fast/forms/input-auto-fill-button.html and associated test results into this directory
+        or the platform-specific variant of this directory.
+
+        * fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled-expected.html: Added.
+        * fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled.html: Added.
+        * fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly-expected.html: Added.
+        * fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly.html: Added.
+        * fast/forms/auto-fill-button/input-auto-fill-button-expected.txt: Renamed from LayoutTests/fast/forms/input-auto-fill-button-expected.txt.
+        * fast/forms/auto-fill-button/input-auto-fill-button.html: Renamed from LayoutTests/fast/forms/input-auto-fill-button.html.
+        * fast/forms/auto-fill-button/input-disabled-auto-fill-button-expected.html: Added.
+        * fast/forms/auto-fill-button/input-disabled-auto-fill-button.html: Added.
+        * fast/forms/auto-fill-button/input-readonly-auto-fill-button-expected.html: Added.
+        * fast/forms/auto-fill-button/input-readonly-auto-fill-button.html: Added.
+        * fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button-expected.html: Added.
+        * fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button.html: Added.
+        * platform/ios-simulator/fast/forms/auto-fill-button/input-auto-fill-button-expected.png: Renamed from LayoutTests/platform/ios-simulator/fast/forms/input-auto-fill-button-expected.png.
+        * platform/ios-simulator/fast/forms/auto-fill-button/input-auto-fill-button-expected.txt: Renamed from LayoutTests/platform/ios-simulator/fast/forms/input-auto-fill-button-expected.txt.
+        * platform/mac-mavericks/fast/forms/auto-fill-button/input-auto-fill-button-expected.txt: Renamed from LayoutTests/platform/mac-mavericks/fast/forms/input-auto-fill-button-expected.txt.
+        * platform/win/fast/forms/auto-fill-button/input-auto-fill-button-expected.txt: Renamed from LayoutTests/platform/win/fast/forms/input-auto-fill-button-expected.txt.
+
 2015-06-02  Filip Pizlo  <fpizlo@apple.com>
 
         GetById and PutById profiling should be more precise about it takes slow path
diff --git a/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled-expected.html b/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled-expected.html
new file mode 100644 (file)
index 0000000..f83aa9c
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that the AutoFill button does not render when the field becomes disabled.</p>
+<input type="password" id="password" disabled>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled.html b/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled.html
new file mode 100644 (file)
index 0000000..8942a56
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that the AutoFill button does not render when the field becomes disabled.</p>
+<input type="password" id="password">
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+var password = document.getElementById("password");
+
+if (window.internals)
+    internals.setShowAutoFillButton(password, true);
+
+function makeFieldDisabledAndNotifyDone()
+{
+    password.disabled = true;
+    if (window.internals)
+        internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+window.setTimeout(makeFieldDisabledAndNotifyDone, 0);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly-expected.html b/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly-expected.html
new file mode 100644 (file)
index 0000000..78851dc
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that the AutoFill button does not render when the field becomes read only.</p>
+<input type="password" id="password" readonly>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly.html b/LayoutTests/fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly.html
new file mode 100644 (file)
index 0000000..1e7b86a
--- /dev/null
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that the AutoFill button does not render when the field becomes read only.</p>
+<input type="password" id="password">
+<script>
+if (window.testRunner)
+    testRunner.waitUntilDone();
+
+var password = document.getElementById("password");
+
+if (window.internals)
+    internals.setShowAutoFillButton(password, true);
+
+function makeFieldReadOnlyAndNotifyDone()
+{
+    password.readOnly = true;
+    if (window.internals)
+        internals.updateLayoutIgnorePendingStylesheetsAndRunPostLayoutTasks();
+    if (window.testRunner)
+        testRunner.notifyDone();
+}
+
+window.setTimeout(makeFieldReadOnlyAndNotifyDone, 0);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/input-disabled-auto-fill-button-expected.html b/LayoutTests/fast/forms/auto-fill-button/input-disabled-auto-fill-button-expected.html
new file mode 100644 (file)
index 0000000..a770070
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that the AutoFill button does not render in a disabled field. It can only be tested in the test tool.</p>
+<input type="password" placeholder="disabled" disabled>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/input-disabled-auto-fill-button.html b/LayoutTests/fast/forms/auto-fill-button/input-disabled-auto-fill-button.html
new file mode 100644 (file)
index 0000000..22353ef
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that the AutoFill button does not render in a disabled field. It can only be tested in the test tool.</p>
+<input type="password" id="password" placeholder="disabled" disabled autofocus>
+<script>
+if (window.internals)
+    internals.setShowAutoFillButton(document.getElementById("password"), true);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/input-readonly-auto-fill-button-expected.html b/LayoutTests/fast/forms/auto-fill-button/input-readonly-auto-fill-button-expected.html
new file mode 100644 (file)
index 0000000..cca346e
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that the AutoFill button does not render in a read only field. It can only be tested in the test tool.</p>
+<input type="password" placeholder="read only" readonly>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/input-readonly-auto-fill-button.html b/LayoutTests/fast/forms/auto-fill-button/input-readonly-auto-fill-button.html
new file mode 100644 (file)
index 0000000..59b633f
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that the AutoFill button does not render in a read only field. It can only be tested in the test tool.</p>
+<input type="password" id="password" placeholder="read only" readonly autofocus>
+<script>
+if (window.internals)
+    internals.setShowAutoFillButton(document.getElementById("password"), true);
+</script>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button-expected.html b/LayoutTests/fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button-expected.html
new file mode 100644 (file)
index 0000000..5a38f78
--- /dev/null
@@ -0,0 +1,7 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that the AutoFill button does not render in a non-empty read only field. It can only be tested in the test tool.</p>
+<input type="password" value="read only" readonly autofocus>
+</body>
+</html>
diff --git a/LayoutTests/fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button.html b/LayoutTests/fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button.html
new file mode 100644 (file)
index 0000000..e393d1c
--- /dev/null
@@ -0,0 +1,11 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p>This tests that the AutoFill button does not render in a non-empty read only field. It can only be tested in the test tool.</p>
+<input type="password" id="password" value="read only" readonly autofocus>
+<script>
+if (window.internals)
+    internals.setShowAutoFillButton(document.getElementById("password"), true);
+</script>
+</body>
+</html>
@@ -9,29 +9,29 @@ layer at (0,0) size 800x600
       RenderBlock {DIV} at (0,34) size 784x25
         RenderTextControl {INPUT} at (2,2) size 149x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
           RenderFlexibleBox {DIV} at (2,3) size 145x15
-            RenderBlock {DIV} at (0,0) size 125x15
+            RenderBlock {DIV} at (0,0) size 129x15
         RenderText {#text} at (153,3) size 4x18
           text run at (153,3) width 4: " "
         RenderTextControl {INPUT} at (159,2) size 149x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
           RenderFlexibleBox {DIV} at (2,3) size 145x15
-            RenderBlock {DIV} at (0,0) size 125x15
+            RenderBlock {DIV} at (0,0) size 129x15
         RenderText {#text} at (310,3) size 4x18
           text run at (310,3) width 4: " "
         RenderTextControl {INPUT} at (316,2) size 149x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
           RenderFlexibleBox {DIV} at (2,3) size 145x15
-            RenderBlock {DIV} at (0,0) size 125x15
+            RenderBlock {DIV} at (0,0) size 129x15
         RenderTextControl {INPUT} at (469,2) size 149x21 [bgcolor=#FFFFFF] [border: (2px inset #000000)]
-layer at (12,47) size 125x15
-  RenderBlock {DIV} at (0,0) size 125x15
-layer at (169,47) size 125x15
-  RenderBlock {DIV} at (0,0) size 125x15
-layer at (326,47) size 125x15
-  RenderBlock {DIV} at (0,0) size 125x15
+layer at (12,47) size 129x15
+  RenderBlock {DIV} at (0,0) size 129x15
+layer at (169,47) size 129x15
+  RenderBlock {DIV} at (0,0) size 129x15
+layer at (326,47) size 129x15
+  RenderBlock {DIV} at (0,0) size 129x15
 layer at (479,47) size 145x15
   RenderBlock {DIV} at (2,3) size 145x15
-layer at (140,49) size 15x12
-  RenderBlock {DIV} at (128,1) size 15x13 [bgcolor=#000000]
-layer at (297,49) size 15x12
-  RenderBlock {DIV} at (128,1) size 15x13 [bgcolor=#000000]
-layer at (454,49) size 15x12
-  RenderBlock {DIV} at (128,1) size 15x13 [bgcolor=#000000]
+layer at (141,47) size 16x15
+  RenderImage {DIV} at (129,0) size 16x15
+layer at (298,47) size 16x15
+  RenderImage {DIV} at (129,0) size 16x15
+layer at (455,47) size 16x15
+  RenderImage {DIV} at (129,0) size 16x15
index 6c317a7..c5fc1b6 100644 (file)
@@ -1,3 +1,27 @@
+2015-06-03  Daniel Bates  <dabates@apple.com>
+
+        AutoFill button should not be shown in read-only or disabled field
+        https://bugs.webkit.org/show_bug.cgi?id=145579
+        <rdar://problem/21212494>
+
+        Reviewed by Darin Adler.
+
+        Fixes an issue where the AutoFill button is shown in a read-only or disabled
+        field. We should not show the AutoFill button in such cases.
+
+        Tests: fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-disabled.html
+               fast/forms/auto-fill-button/hide-auto-fill-button-when-input-becomes-readonly.html
+               fast/forms/auto-fill-button/input-auto-fill-button.html
+               fast/forms/auto-fill-button/input-disabled-auto-fill-button.html
+               fast/forms/auto-fill-button/input-readonly-auto-fill-button.html
+               fast/forms/auto-fill-button/input-readonly-non-empty-auto-fill-button.html
+
+        * html/TextFieldInputType.cpp:
+        (WebCore::TextFieldInputType::disabledAttributeChanged): Update AutoFill button state.
+        (WebCore::TextFieldInputType::readonlyAttributeChanged): Ditto.
+        (WebCore::TextFieldInputType::shouldDrawAutoFillButton): Do not draw AutoFill button
+        when the field is disabled or read-only.
+
 2015-06-03  Brent Fulgham  <bfulgham@apple.com>
 
         REGRESSION: (r181879): Scrolling in select/option region in iFrame scrolls both select and iframe
index 945ad28..e7ecf6f 100644 (file)
@@ -358,12 +358,14 @@ void TextFieldInputType::disabledAttributeChanged()
 {
     if (m_innerSpinButton)
         m_innerSpinButton->releaseCapture();
+    updateAutoFillButton();
 }
 
 void TextFieldInputType::readonlyAttributeChanged()
 {
     if (m_innerSpinButton)
         m_innerSpinButton->releaseCapture();
+    updateAutoFillButton();
 }
 
 bool TextFieldInputType::supportsReadOnly() const
@@ -570,7 +572,7 @@ void TextFieldInputType::capsLockStateMayHaveChanged()
 
 bool TextFieldInputType::shouldDrawAutoFillButton() const
 {
-    return element().showAutoFillButton();
+    return !element().isDisabledOrReadOnly() && element().showAutoFillButton();
 }
 
 void TextFieldInputType::autoFillButtonElementWasClicked()