Changeset 136915 in webkit


Ignore:
Timestamp:
Dec 6, 2012, 6:18:01 PM (12 years ago)
Author:
commit-queue@webkit.org
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 <ksakamoto@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.
Location:
trunk
Files:
2 added
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r136913 r136915  
     12012-12-06  Kunihiko Sakamoto  <ksakamoto@chromium.org>
     2
     3        Disabled file input box stops a certain other div from being rendered
     4        https://bugs.webkit.org/show_bug.cgi?id=104226
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        Add a test to ensure that sibling of disabled file input is correctly rendered.
     9
     10        * fast/forms/file/sibling-of-disabled-file-input-expected.txt: Added.
     11        * fast/forms/file/sibling-of-disabled-file-input.html: Added.
     12
    1132012-12-06  Dominic Cooney  <dominicc@chromium.org>
    214
  • trunk/Source/WebCore/ChangeLog

    r136913 r136915  
     12012-12-06  Kunihiko Sakamoto  <ksakamoto@chromium.org>
     2
     3        Disabled file input box stops a certain other div from being rendered
     4        https://bugs.webkit.org/show_bug.cgi?id=104226
     5
     6        Reviewed by Dimitri Glazkov.
     7
     8        The bug was caused by setNeedsStyleRecalc() call during style recalculation,
     9        which resulted in inconsistent ChildNeedsStyleRecalc flags in DOM tree.
     10
     11        When reattach of file input happens during style recalculation,
     12        RenderFileUploadControl::updateFromElement() is called from attach().
     13        It may change the disabled state of the upload button in its shadow tree,
     14        but it triggers style recalculation.
     15
     16        This patch solves this issue by setting disabled state of the upload button in
     17        FileInputType::disabledAttributeChanged instead of RenderFileUploadControl.
     18
     19        Test: fast/forms/file/sibling-of-disabled-file-input.html
     20
     21        * html/FileInputType.cpp:
     22        (WebCore::FileInputType::disabledAttributeChanged): Added.
     23        * html/FileInputType.h:
     24        (FileInputType): Declare disabledAttributeChanged.
     25        * rendering/RenderFileUploadControl.cpp:
     26        (WebCore::RenderFileUploadControl::updateFromElement): Remove call to button->setDisabled().
     27
    1282012-12-06  Dominic Cooney  <dominicc@chromium.org>
    229
  • trunk/Source/WebCore/html/FileInputType.cpp

    r133976 r136915  
    307307}
    308308
     309void FileInputType::disabledAttributeChanged()
     310{
     311    ASSERT(element()->shadow());
     312    UploadButtonElement* button = static_cast<UploadButtonElement*>(element()->userAgentShadowRoot()->firstChild());
     313    if (button)
     314        button->setDisabled(element()->disabled());
     315}
     316
    309317void FileInputType::multipleAttributeChanged()
    310318{
  • trunk/Source/WebCore/html/FileInputType.h

    r125759 r136915  
    7272    virtual bool isFileUpload() const OVERRIDE;
    7373    virtual void createShadowSubtree() OVERRIDE;
     74    virtual void disabledAttributeChanged() OVERRIDE;
    7475    virtual void multipleAttributeChanged() OVERRIDE;
    7576    virtual String defaultToolTip() const OVERRIDE;
  • trunk/Source/WebCore/rendering/RenderFileUploadControl.cpp

    r128130 r136915  
    7373
    7474    if (HTMLInputElement* button = uploadButton()) {
    75         bool newDisabled = !theme()->isEnabled(this);
    76         // We should avoid to call HTMLFormControlElement::setDisabled() as
    77         // possible because setAttribute() in setDisabled() can cause style
    78         // recalculation, and HTMLFormControlElement::recalcStyle() calls
    79         // updateFromElement() eventually.
    80         if (button->disabled() != newDisabled)
    81             button->setDisabled(newDisabled);
    82 
    8375        bool newCanReceiveDroppedFilesState = input->canReceiveDroppedFiles();
    8476        if (m_canReceiveDroppedFiles != newCanReceiveDroppedFilesState) {
Note: See TracChangeset for help on using the changeset viewer.