Title: [142054] trunk
Revision
142054
Author
o...@chromium.org
Date
2013-02-06 16:41:07 -0800 (Wed, 06 Feb 2013)

Log Message

display:none file upload button crashes
https://bugs.webkit.org/show_bug.cgi?id=109102

Reviewed by Levi Weintraub.

Source/WebCore:

Test: fast/forms/file/display-none-upload-button.html

* rendering/RenderFileUploadControl.cpp:
(WebCore::nodeWidth):
(WebCore::RenderFileUploadControl::paintObject):
Having an upload button doesn't mean we have a rendered upload button.
Null check the renderer before trying to access it.

LayoutTests:

* fast/forms/file/display-none-upload-button-expected.txt: Added.
* fast/forms/file/display-none-upload-button.html: Added.
Tests that we don't crash. Also exposes a bug that the baseline and height of
the input don't include the height of the filename text.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (142053 => 142054)


--- trunk/LayoutTests/ChangeLog	2013-02-07 00:32:46 UTC (rev 142053)
+++ trunk/LayoutTests/ChangeLog	2013-02-07 00:41:07 UTC (rev 142054)
@@ -1,3 +1,15 @@
+2013-02-06  Ojan Vafai  <o...@chromium.org>
+
+        display:none file upload button crashes
+        https://bugs.webkit.org/show_bug.cgi?id=109102
+
+        Reviewed by Levi Weintraub.
+
+        * fast/forms/file/display-none-upload-button-expected.txt: Added.
+        * fast/forms/file/display-none-upload-button.html: Added.
+        Tests that we don't crash. Also exposes a bug that the baseline and height of
+        the input don't include the height of the filename text.
+
 2013-02-06  Stephen Chenney  <schen...@chromium.org>
 
         [Chromium] Test expectations update for Skia change.

Added: trunk/LayoutTests/fast/forms/file/display-none-upload-button-expected.txt (0 => 142054)


--- trunk/LayoutTests/fast/forms/file/display-none-upload-button-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/display-none-upload-button-expected.txt	2013-02-07 00:41:07 UTC (rev 142054)
@@ -0,0 +1,5 @@
+FAIL document.querySelector('input').offsetHeight > 10 should be true. Was false.
+PASS successfullyParsed is true
+
+TEST COMPLETE
+Tests that a display:none upload button works. 

Added: trunk/LayoutTests/fast/forms/file/display-none-upload-button.html (0 => 142054)


--- trunk/LayoutTests/fast/forms/file/display-none-upload-button.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/display-none-upload-button.html	2013-02-07 00:41:07 UTC (rev 142054)
@@ -0,0 +1,19 @@
+<!DOCTYPE HTML>
+<style>
+input {
+    border: 5px solid salmon;
+}
+input::-webkit-file-upload-button {
+    display: none;
+}
+</style>
+Tests that a display:none upload button works.
+<input type="file">
+<script src=""
+<script>
+// FIXME: The text inside the file input should give the input a contentHeight
+// even when there's no upload button.
+// https://bugs.webkit.org/show_bug.cgi?id=109104
+shouldBeTrue("document.querySelector('input').offsetHeight > 10");
+</script>
+<script src=""
\ No newline at end of file

Modified: trunk/Source/WebCore/ChangeLog (142053 => 142054)


--- trunk/Source/WebCore/ChangeLog	2013-02-07 00:32:46 UTC (rev 142053)
+++ trunk/Source/WebCore/ChangeLog	2013-02-07 00:41:07 UTC (rev 142054)
@@ -1,3 +1,18 @@
+2013-02-06  Ojan Vafai  <o...@chromium.org>
+
+        display:none file upload button crashes
+        https://bugs.webkit.org/show_bug.cgi?id=109102
+
+        Reviewed by Levi Weintraub.
+
+        Test: fast/forms/file/display-none-upload-button.html
+
+        * rendering/RenderFileUploadControl.cpp:
+        (WebCore::nodeWidth):
+        (WebCore::RenderFileUploadControl::paintObject):
+        Having an upload button doesn't mean we have a rendered upload button.
+        Null check the renderer before trying to access it.
+
 2013-02-06  Dirk Schulze  <dschu...@adobe.com>
 
         Context's currentPath should check for passed type

Modified: trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp (142053 => 142054)


--- trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp	2013-02-07 00:32:46 UTC (rev 142053)
+++ trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp	2013-02-07 00:41:07 UTC (rev 142054)
@@ -89,7 +89,7 @@
 
 static int nodeWidth(Node* node)
 {
-    return node ? node->renderBox()->pixelSnappedWidth() : 0;
+    return (node && node->renderBox()) ? node->renderBox()->pixelSnappedWidth() : 0;
 }
 
 int RenderFileUploadControl::maxFilenameWidth() const
@@ -136,10 +136,14 @@
             textX = contentLeft + buttonAndIconWidth;
         else
             textX = contentLeft + contentWidth() - buttonAndIconWidth - font.width(textRun);
+
+        LayoutUnit textY = 0;
         // We want to match the button's baseline
-        RenderButton* buttonRenderer = toRenderButton(button->renderer());
         // FIXME: Make this work with transforms.
-        LayoutUnit textY = paintOffset.y() + buttonRenderer->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine);
+        if (RenderButton* buttonRenderer = toRenderButton(button->renderer()))
+            textY = paintOffset.y() + buttonRenderer->baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine);
+        else
+            textY = baselinePosition(AlphabeticBaseline, true, HorizontalLine, PositionOnContainingLine);
 
         paintInfo.context->setFillColor(style()->visitedDependentColor(CSSPropertyColor), style()->colorSpace());
         
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to