Title: [152705] trunk
Revision
152705
Author
[email protected]
Date
2013-07-15 22:19:36 -0700 (Mon, 15 Jul 2013)

Log Message

Input element that becomes visible during a simulated click event from an associated label element doesn't get focused
https://bugs.webkit.org/show_bug.cgi?id=118700

Reviewed by Kent Tamura.

Source/WebCore:

Inspired by https://chromium.googlesource.com/chromium/blink/+/6435f70d53403b250e261a914f30d55142f81476.

The bug was caused by isMouseFocusable() check in HTMLLabelElement::defaultEventHandler not updating the layout even
though the call to dispatchSimulatedClick may have dirtied the render tree.

Explicitly update the layout so that we have up-to-date render tree.

Test: fast/forms/label/label-becomes-visible-while-clicking-on-label.html

* html/HTMLLabelElement.cpp:
(WebCore::HTMLLabelElement::defaultEventHandler):

LayoutTests:

Add a regression test.

* fast/forms/label/label-becomes-visible-while-clicking-on-label-expected.txt: Added.
* fast/forms/label/label-becomes-visible-while-clicking-on-label.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (152704 => 152705)


--- trunk/LayoutTests/ChangeLog	2013-07-16 05:01:15 UTC (rev 152704)
+++ trunk/LayoutTests/ChangeLog	2013-07-16 05:19:36 UTC (rev 152705)
@@ -1,3 +1,15 @@
+2013-07-15  Ryosuke Niwa  <[email protected]>
+
+        Input element that becomes visible during a simulated click event from an associated label element doesn't get focused
+        https://bugs.webkit.org/show_bug.cgi?id=118700
+
+        Reviewed by Kent Tamura.
+
+        Add a regression test.
+
+        * fast/forms/label/label-becomes-visible-while-clicking-on-label-expected.txt: Added.
+        * fast/forms/label/label-becomes-visible-while-clicking-on-label.html: Added.
+
 2013-07-15  Tim Horton  <[email protected]>
 
         Unreviewed rebaselines after r152701.

Added: trunk/LayoutTests/fast/forms/label/label-becomes-visible-while-clicking-on-label-expected.txt (0 => 152705)


--- trunk/LayoutTests/fast/forms/label/label-becomes-visible-while-clicking-on-label-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/label/label-becomes-visible-while-clicking-on-label-expected.txt	2013-07-16 05:19:36 UTC (rev 152705)
@@ -0,0 +1,12 @@
+This tests making an input element visible while the associated label element is clicked.To manually test, "click me" below. The input element that becomes visible must be focused.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+focused = false; clickElement(document.querySelector("label"));
+PASS focused is true
+PASS document.activeElement is document.querySelector("input")
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/forms/label/label-becomes-visible-while-clicking-on-label.html (0 => 152705)


--- trunk/LayoutTests/fast/forms/label/label-becomes-visible-while-clicking-on-label.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/label/label-becomes-visible-while-clicking-on-label.html	2013-07-16 05:19:36 UTC (rev 152705)
@@ -0,0 +1,29 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src=""
+<script src=""
+
+<div>
+<input id="input-element" style="visibility: hidden;" _onfocus_="focused = true" _onblur_="focused = false" _onclick_="this.style.visibility = 'visible';">
+<label for="" me</label>
+</div>
+
+<script>
+
+description('This tests making an input element visible while the associated label element is clicked.'
+ + 'To manually test, "click me" below. The input element that becomes visible must be focused.');
+
+if (window.eventSender) {
+    evalAndLog('focused = false; clickElement(document.querySelector("label"));');
+    shouldBeTrue('focused');
+    shouldBe('document.activeElement', 'document.querySelector("input")');
+
+    document.querySelector('input').parentNode.style.display = 'none';
+}
+
+</script>
+
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (152704 => 152705)


--- trunk/Source/WebCore/ChangeLog	2013-07-16 05:01:15 UTC (rev 152704)
+++ trunk/Source/WebCore/ChangeLog	2013-07-16 05:19:36 UTC (rev 152705)
@@ -1,3 +1,22 @@
+2013-07-15  Ryosuke Niwa  <[email protected]>
+
+        Input element that becomes visible during a simulated click event from an associated label element doesn't get focused
+        https://bugs.webkit.org/show_bug.cgi?id=118700
+
+        Reviewed by Kent Tamura.
+
+        Inspired by https://chromium.googlesource.com/chromium/blink/+/6435f70d53403b250e261a914f30d55142f81476.
+
+        The bug was caused by isMouseFocusable() check in HTMLLabelElement::defaultEventHandler not updating the layout even
+        though the call to dispatchSimulatedClick may have dirtied the render tree.
+
+        Explicitly update the layout so that we have up-to-date render tree.
+
+        Test: fast/forms/label/label-becomes-visible-while-clicking-on-label.html
+
+        * html/HTMLLabelElement.cpp:
+        (WebCore::HTMLLabelElement::defaultEventHandler):
+
 2013-07-15  Kangil Han  <[email protected]>
 
         Introduce toHTMLIFrameElement

Modified: trunk/Source/WebCore/html/HTMLLabelElement.cpp (152704 => 152705)


--- trunk/Source/WebCore/html/HTMLLabelElement.cpp	2013-07-16 05:01:15 UTC (rev 152704)
+++ trunk/Source/WebCore/html/HTMLLabelElement.cpp	2013-07-16 05:19:36 UTC (rev 152705)
@@ -136,6 +136,7 @@
         // Click the corresponding control.
         element->dispatchSimulatedClick(evt);
 
+        document()->updateLayoutIgnorePendingStylesheets();
         if (element->isMouseFocusable())
             element->focus();
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to