Skip to content
  • tkent@chromium.org's avatar
    Radio button group state is not restored correctly · eae496df
    tkent@chromium.org authored
    https://bugs.webkit.org/show_bug.cgi?id=50442
    
    Reviewed by Dimitri Glazkov.
    
    Source/WebCore:
    
    Fixes a bug that radio button states are not restored correctly in
    a case that non-first radio button in a group is checked.
    
    If "checked" attribute is present, the radio button is checked and
    other radio buttons in the group are unchecked. This behavior
    disturbs form state restoring. This patch changes this behavior so
    that the "checked" attribute handling is delayed after form state
    restoring.
    
    Test: fast/forms/state-restore-radio-group.html
    
    * html/HTMLFormControlElement.h:
     Make finishParsingChildren() protected so that HTMLInpuElement can call it.
    * html/HTMLInputElement.cpp:
    (WebCore::HTMLInputElement::HTMLInputElement):
     - Add createdByParser parameter.
     - Initialize m_stateRestored and m_parsingInProgress.
    (WebCore::HTMLInputElement::create): Sync with the constructor.
    (WebCore::HTMLInputElement::restoreFormControlState):
     Set m_stateRestored in order to refer it in finishParsingChildren().
    (WebCore::HTMLInputElement::parseMappedAttribute):
     Don't call setChecked() during parsing. Move setNeedsValidityCheck()
     to setChecked().
    (WebCore::HTMLInputElement::finishParsingChildren):
     Call setChecked() if form state is not restored.
    (WebCore::HTMLInputElement::setChecked):
     Move setNeedsValidityCheck() from parseMappedAttribute() because
     finishParsingChildren() also needs to call setNeedsValidityCheck().
    * html/HTMLInputElement.h:
     - Remove the default value of HTMLFormElement* of the HTMLInputElement
       constructor, and add createdByParser parameter.
     - Introduce m_parsingInProgress and m_stateRestored.
    * html/HTMLIsIndexElement.cpp:
    (WebCore::HTMLIsIndexElement::HTMLIsIndexElement):
     Sync with the HTMLInputElement constructor change.
    * html/HTMLTagNames.in: Add constructorNeedsCreatedByParser flag.
    * rendering/MediaControlElements.cpp:
    (WebCore::MediaControlInputElement::MediaControlInputElement):
     Sync with the HTMLInputElement constructor change.
    * rendering/ShadowElement.cpp:
    (WebCore::ShadowInputElement::ShadowInputElement): ditto.
    * rendering/ShadowElement.h:
    (WebCore::ShadowElement::ShadowElement): ditto.
    
    LayoutTests:
    
    * fast/forms/state-restore-radio-group-expected.txt: Added.
    * fast/forms/state-restore-radio-group.html: Added.
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@76664 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    eae496df