Title: [136915] trunk
Revision
136915
Author
commit-qu...@webkit.org
Date
2012-12-06 18:18:01 -0800 (Thu, 06 Dec 2012)

Log Message

Disabled file input box stops a certain other div from being rendered
https://bugs.webkit.org/show_bug.cgi?id=104226

Patch by Kunihiko Sakamoto <ksakam...@chromium.org> on 2012-12-06
Reviewed by Dimitri Glazkov.

Source/WebCore:

The bug was caused by setNeedsStyleRecalc() call during style recalculation,
which resulted in inconsistent ChildNeedsStyleRecalc flags in DOM tree.

When reattach of file input happens during style recalculation,
RenderFileUploadControl::updateFromElement() is called from attach().
It may change the disabled state of the upload button in its shadow tree,
but it triggers style recalculation.

This patch solves this issue by setting disabled state of the upload button in
FileInputType::disabledAttributeChanged instead of RenderFileUploadControl.

Test: fast/forms/file/sibling-of-disabled-file-input.html

* html/FileInputType.cpp:
(WebCore::FileInputType::disabledAttributeChanged): Added.
* html/FileInputType.h:
(FileInputType): Declare disabledAttributeChanged.
* rendering/RenderFileUploadControl.cpp:
(WebCore::RenderFileUploadControl::updateFromElement): Remove call to button->setDisabled().

LayoutTests:

Add a test to ensure that sibling of disabled file input is correctly rendered.

* fast/forms/file/sibling-of-disabled-file-input-expected.txt: Added.
* fast/forms/file/sibling-of-disabled-file-input.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (136914 => 136915)


--- trunk/LayoutTests/ChangeLog	2012-12-07 02:17:14 UTC (rev 136914)
+++ trunk/LayoutTests/ChangeLog	2012-12-07 02:18:01 UTC (rev 136915)
@@ -1,3 +1,15 @@
+2012-12-06  Kunihiko Sakamoto  <ksakam...@chromium.org>
+
+        Disabled file input box stops a certain other div from being rendered
+        https://bugs.webkit.org/show_bug.cgi?id=104226
+
+        Reviewed by Dimitri Glazkov.
+
+        Add a test to ensure that sibling of disabled file input is correctly rendered.
+
+        * fast/forms/file/sibling-of-disabled-file-input-expected.txt: Added.
+        * fast/forms/file/sibling-of-disabled-file-input.html: Added.
+
 2012-12-06  Dominic Cooney  <domin...@chromium.org>
 
         Element.pseudo property should be prefixed

Added: trunk/LayoutTests/fast/forms/file/sibling-of-disabled-file-input-expected.txt (0 => 136915)


--- trunk/LayoutTests/fast/forms/file/sibling-of-disabled-file-input-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/sibling-of-disabled-file-input-expected.txt	2012-12-07 02:18:01 UTC (rev 136915)
@@ -0,0 +1,4 @@
+Test for https://bugs.webkit.org/show_bug.cgi?id=104226 Disabled file input box stops a certain other div from being rendered.
+
+
+PASS if this text is visible.

Added: trunk/LayoutTests/fast/forms/file/sibling-of-disabled-file-input.html (0 => 136915)


--- trunk/LayoutTests/fast/forms/file/sibling-of-disabled-file-input.html	                        (rev 0)
+++ trunk/LayoutTests/fast/forms/file/sibling-of-disabled-file-input.html	2012-12-07 02:18:01 UTC (rev 136915)
@@ -0,0 +1,37 @@
+<!doctype html>
+<html>
+<head>
+<script>
+if (window.testRunner) {
+    testRunner.dumpAsText();
+    testRunner.waitUntilDone();
+}
+function onLoad() {
+    div1 = document.createElement('div');
+    document.body.appendChild(div1);
+
+    div2 = document.createElement('div');
+    div1.appendChild(div2);
+
+    fileInput = document.createElement('input');
+    fileInput.type = 'file';
+    fileInput.disabled = true;
+    div2.appendChild(fileInput);
+
+    divTxt = document.createElement('div');
+    div2.appendChild(divTxt);
+
+    setTimeout(function() {
+        divTxt.appendChild(document.createTextNode('PASS if this text is visible.'));
+        if (window.testRunner)
+            testRunner.notifyDone();
+    }, 1);
+}
+</script>
+</head>
+<body _onload_="onLoad();">
+<p>Test for <a href=""
+Disabled file input box stops a certain other div from being rendered.
+</p>
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (136914 => 136915)


--- trunk/Source/WebCore/ChangeLog	2012-12-07 02:17:14 UTC (rev 136914)
+++ trunk/Source/WebCore/ChangeLog	2012-12-07 02:18:01 UTC (rev 136915)
@@ -1,3 +1,30 @@
+2012-12-06  Kunihiko Sakamoto  <ksakam...@chromium.org>
+
+        Disabled file input box stops a certain other div from being rendered
+        https://bugs.webkit.org/show_bug.cgi?id=104226
+
+        Reviewed by Dimitri Glazkov.
+
+        The bug was caused by setNeedsStyleRecalc() call during style recalculation,
+        which resulted in inconsistent ChildNeedsStyleRecalc flags in DOM tree.
+
+        When reattach of file input happens during style recalculation,
+        RenderFileUploadControl::updateFromElement() is called from attach().
+        It may change the disabled state of the upload button in its shadow tree,
+        but it triggers style recalculation.
+
+        This patch solves this issue by setting disabled state of the upload button in
+        FileInputType::disabledAttributeChanged instead of RenderFileUploadControl.
+
+        Test: fast/forms/file/sibling-of-disabled-file-input.html
+
+        * html/FileInputType.cpp:
+        (WebCore::FileInputType::disabledAttributeChanged): Added.
+        * html/FileInputType.h:
+        (FileInputType): Declare disabledAttributeChanged.
+        * rendering/RenderFileUploadControl.cpp:
+        (WebCore::RenderFileUploadControl::updateFromElement): Remove call to button->setDisabled().
+
 2012-12-06  Dominic Cooney  <domin...@chromium.org>
 
         Element.pseudo property should be prefixed

Modified: trunk/Source/WebCore/html/FileInputType.cpp (136914 => 136915)


--- trunk/Source/WebCore/html/FileInputType.cpp	2012-12-07 02:17:14 UTC (rev 136914)
+++ trunk/Source/WebCore/html/FileInputType.cpp	2012-12-07 02:18:01 UTC (rev 136915)
@@ -306,6 +306,14 @@
     element()->userAgentShadowRoot()->appendChild(element()->multiple() ? UploadButtonElement::createForMultiple(element()->document()): UploadButtonElement::create(element()->document()), ec);
 }
 
+void FileInputType::disabledAttributeChanged()
+{
+    ASSERT(element()->shadow());
+    UploadButtonElement* button = static_cast<UploadButtonElement*>(element()->userAgentShadowRoot()->firstChild());
+    if (button)
+        button->setDisabled(element()->disabled());
+}
+
 void FileInputType::multipleAttributeChanged()
 {
     ASSERT(element()->shadow());

Modified: trunk/Source/WebCore/html/FileInputType.h (136914 => 136915)


--- trunk/Source/WebCore/html/FileInputType.h	2012-12-07 02:17:14 UTC (rev 136914)
+++ trunk/Source/WebCore/html/FileInputType.h	2012-12-07 02:18:01 UTC (rev 136915)
@@ -71,6 +71,7 @@
     virtual Icon* icon() const OVERRIDE;
     virtual bool isFileUpload() const OVERRIDE;
     virtual void createShadowSubtree() OVERRIDE;
+    virtual void disabledAttributeChanged() OVERRIDE;
     virtual void multipleAttributeChanged() OVERRIDE;
     virtual String defaultToolTip() const OVERRIDE;
 

Modified: trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp (136914 => 136915)


--- trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp	2012-12-07 02:17:14 UTC (rev 136914)
+++ trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp	2012-12-07 02:18:01 UTC (rev 136915)
@@ -72,14 +72,6 @@
     ASSERT(input->isFileUpload());
 
     if (HTMLInputElement* button = uploadButton()) {
-        bool newDisabled = !theme()->isEnabled(this);
-        // We should avoid to call HTMLFormControlElement::setDisabled() as
-        // possible because setAttribute() in setDisabled() can cause style
-        // recalculation, and HTMLFormControlElement::recalcStyle() calls
-        // updateFromElement() eventually.
-        if (button->disabled() != newDisabled)
-            button->setDisabled(newDisabled);
-
         bool newCanReceiveDroppedFilesState = input->canReceiveDroppedFiles();
         if (m_canReceiveDroppedFiles != newCanReceiveDroppedFilesState) {
             m_canReceiveDroppedFiles = newCanReceiveDroppedFilesState;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to