Title: [91566] trunk
Revision
91566
Author
[email protected]
Date
2011-07-22 06:40:59 -0700 (Fri, 22 Jul 2011)

Log Message

REGRESSION(r89535): Form reset does not repaint a file upload control.
https://bugs.webkit.org/show_bug.cgi?id=65008

Patch by Kentaro Hara <[email protected]> on 2011-07-22
Reviewed by Kent Tamura.

Source/WebCore:

This patch fixes the code so that the file upload control is repainted
in updateFromElement() if no files are selected.

Tests: fast/forms/file-input-reset.html

* rendering/RenderFileUploadControl.cpp:
(WebCore::RenderFileUploadControl::updateFromElement): Calls repaint() if no files are selected.

LayoutTests:

This patch fixes the code so that the file upload control is repainted
in updateFromElement() if no files are selected. The added test checks
if the label next to the file chooser button becomes "No file chosen"
when we press the reset button.

* fast/forms/file-input-reset-expected.html: Added.
* fast/forms/file-input-reset.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (91565 => 91566)


--- trunk/LayoutTests/ChangeLog	2011-07-22 13:38:02 UTC (rev 91565)
+++ trunk/LayoutTests/ChangeLog	2011-07-22 13:40:59 UTC (rev 91566)
@@ -1,3 +1,18 @@
+2011-07-22  Kentaro Hara  <[email protected]>
+
+        REGRESSION(r89535): Form reset does not repaint a file upload control.
+        https://bugs.webkit.org/show_bug.cgi?id=65008
+
+        Reviewed by Kent Tamura.
+
+        This patch fixes the code so that the file upload control is repainted
+        in updateFromElement() if no files are selected. The added test checks
+        if the label next to the file chooser button becomes "No file chosen"
+        when we press the reset button.
+
+        * fast/forms/file-input-reset-expected.html: Added.
+        * fast/forms/file-input-reset.html: Added.
+
 2011-07-22  John Knottenbelt  <[email protected]>
 
         [Chromium] Adjust test expectations.

Added: trunk/LayoutTests/fast/forms/file-input-reset-expected.html (0 => 91566)


--- trunk/LayoutTests/fast/forms/file-input-reset-expected.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file-input-reset-expected.html	2011-07-22 13:40:59 UTC (rev 91566)
@@ -0,0 +1,18 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<form id="form">
+<input id="file" type="file" />
+<input id="reset" type="reset" />
+</form>
+<div id="console">C:\fakepath\foo.txt is selected.</div>
+<p>
+This tests whether the label next to the file chooser button becomes "No file chosen"
+when we press the reset button.
+To run this test manually, choose a file and then click the reset button.
+If the label next to the file chooser button changes to "No file chosen", the test passes.
+</p>
+</body>
+</html>

Added: trunk/LayoutTests/fast/forms/file-input-reset.html (0 => 91566)


--- trunk/LayoutTests/fast/forms/file-input-reset.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file-input-reset.html	2011-07-22 13:40:59 UTC (rev 91566)
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+<html>
+<head>
+</head>
+<body>
+<form id="form">
+<input id="file" type="file" />
+<input id="reset" type="reset" />
+</form>
+<div id="console"></div>
+<p>
+This tests whether the label next to the file chooser button becomes "No file chosen"
+when we press the reset button.
+To run this test manually, choose a file and then click the reset button.
+If the label next to the file chooser button changes to "No file chosen", the test passes.
+</p>
+<script>
+if (layoutTestController && eventSender) {
+    var file = document.getElementById("file");
+    var reset = document.getElementById("reset");
+    dragFilesOntoElement(file, ["foo.txt"]);
+    document.getElementById("console").innerHTML = file.value + " is selected.";
+    click(reset.offsetLeft + reset.offsetWidth / 2, reset.offsetTop + reset.offsetHeight / 2);
+    click(reset.offsetLeft + reset.offsetWidth + 10, reset.offsetTop + reset.offsetHeight + 10); // Move a cursor out of the reset button.
+}
+
+function click(x, y) {
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseDown();
+    eventSender.mouseMoveTo(x, y);
+    eventSender.mouseUp();
+}
+
+function dragFilesOntoElement(element, files) {
+    eventSender.beginDragWithFiles(files);
+    var centerX = element.offsetLeft + element.offsetWidth / 2;
+    var centerY = element.offsetTop + element.offsetHeight / 2;
+    eventSender.mouseMoveTo(centerX, centerY);
+    eventSender.mouseUp();
+}
+
+var successfullyParsed = true;
+</script>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (91565 => 91566)


--- trunk/Source/WebCore/ChangeLog	2011-07-22 13:38:02 UTC (rev 91565)
+++ trunk/Source/WebCore/ChangeLog	2011-07-22 13:40:59 UTC (rev 91566)
@@ -1,3 +1,18 @@
+2011-07-22  Kentaro Hara  <[email protected]>
+
+        REGRESSION(r89535): Form reset does not repaint a file upload control.
+        https://bugs.webkit.org/show_bug.cgi?id=65008
+
+        Reviewed by Kent Tamura.
+
+        This patch fixes the code so that the file upload control is repainted
+        in updateFromElement() if no files are selected.
+
+        Tests: fast/forms/file-input-reset.html
+
+        * rendering/RenderFileUploadControl.cpp:
+        (WebCore::RenderFileUploadControl::updateFromElement): Calls repaint() if no files are selected.
+
 2011-07-22  Ilya Tikhonovsky  <[email protected]>
 
         Web Inspector: the max depth of the Timeline events' stack trace should be customizable.

Modified: trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp (91565 => 91566)


--- trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp	2011-07-22 13:38:02 UTC (rev 91565)
+++ trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp	2011-07-22 13:40:59 UTC (rev 91566)
@@ -60,8 +60,18 @@
 
 void RenderFileUploadControl::updateFromElement()
 {
+    HTMLInputElement* input = static_cast<HTMLInputElement*>(node());
+    ASSERT(input->isFileUpload());
+
     if (HTMLInputElement* button = uploadButton())
         button->setDisabled(!theme()->isEnabled(this));
+
+    // This only supports clearing out the files, but that's OK because for
+    // security reasons that's the only change the DOM is allowed to make.
+    FileList* files = input->files();
+    ASSERT(files);
+    if (files && files->isEmpty())
+        repaint();
 }
 
 static int nodeWidth(Node* node)
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to