Changeset 57012 in webkit


Ignore:
Timestamp:
Apr 2, 2010 11:31:24 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-04-02 Kent Tamura <tkent@chromium.org>

Reviewed by Darin Adler.

Forms with autocomplete=off should not consume saved state
https://bugs.webkit.org/show_bug.cgi?id=36762

  • fast/forms/state-restore-to-non-autocomplete-form-expected.txt: Added.
  • fast/forms/state-restore-to-non-autocomplete-form.html: Added.

2010-04-02 Kent Tamura <tkent@chromium.org>

Reviewed by Darin Adler.

Forms with autocomplete=off should not consume saved state
https://bugs.webkit.org/show_bug.cgi?id=36762

Introduce Element::shouldSaveAndRestoreFormControlState() to check
if we should save and restore control state.

Test: fast/forms/state-restore-to-non-autocomplete-form.html

  • dom/Document.cpp: (WebCore::Document::formElementsState): Check shouldSaveAndRestoreFormControlState().
  • dom/Element.h: (WebCore::Element::shouldSaveAndRestoreFormControlState): Added. It just returns true.
  • html/HTMLFormControlElement.cpp: (WebCore::HTMLFormControlElementWithState::autoComplete): Added. It return autocomplete state of the form. (WebCore::HTMLFormControlElementWithState::shouldSaveAndRestoreFormControlState): Added. It returns the result of autoComplete(). (WebCore::HTMLFormControlElementWithState::finishParsingChildren): Do not restore state if shouldSaveAndRestoreFormControlState() is false.
  • html/HTMLFormControlElement.h: Declare autoComplete() and overriding methods.
  • html/HTMLInputElement.cpp: (WebCore::HTMLInputElement::autoComplete): Reduce code by using autoComplete() of the parent class. (WebCore::HTMLInputElement::saveFormControlState): Remove the autoComplete() check. Document::formElementsState() does equivalent check.
Location:
trunk
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r57007 r57012  
     12010-04-02  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Forms with autocomplete=off should not consume saved state
     6        https://bugs.webkit.org/show_bug.cgi?id=36762
     7
     8        * fast/forms/state-restore-to-non-autocomplete-form-expected.txt: Added.
     9        * fast/forms/state-restore-to-non-autocomplete-form.html: Added.
     10
    1112010-04-02  Dirk Schulze  <krit@webkit.org>
    212
  • trunk/WebCore/ChangeLog

    r57009 r57012  
     12010-04-02  Kent Tamura  <tkent@chromium.org>
     2
     3        Reviewed by Darin Adler.
     4
     5        Forms with autocomplete=off should not consume saved state
     6        https://bugs.webkit.org/show_bug.cgi?id=36762
     7       
     8        Introduce Element::shouldSaveAndRestoreFormControlState() to check
     9        if we should save and restore control state.
     10
     11        Test: fast/forms/state-restore-to-non-autocomplete-form.html
     12
     13        * dom/Document.cpp:
     14        (WebCore::Document::formElementsState): Check shouldSaveAndRestoreFormControlState().
     15        * dom/Element.h:
     16        (WebCore::Element::shouldSaveAndRestoreFormControlState): Added. It just returns true.
     17        * html/HTMLFormControlElement.cpp:
     18        (WebCore::HTMLFormControlElementWithState::autoComplete):
     19          Added. It return autocomplete state of the form.
     20        (WebCore::HTMLFormControlElementWithState::shouldSaveAndRestoreFormControlState):
     21          Added. It returns the result of autoComplete().
     22        (WebCore::HTMLFormControlElementWithState::finishParsingChildren):
     23          Do not restore state if shouldSaveAndRestoreFormControlState() is false.
     24        * html/HTMLFormControlElement.h: Declare autoComplete() and overriding methods.
     25        * html/HTMLInputElement.cpp:
     26        (WebCore::HTMLInputElement::autoComplete):
     27          Reduce code by using autoComplete() of the parent class.
     28        (WebCore::HTMLInputElement::saveFormControlState):
     29          Remove the autoComplete() check. Document::formElementsState() does equivalent check.
     30
    1312010-04-02  Simon Fraser  <simon.fraser@apple.com>
    232
  • trunk/WebCore/dom/Document.cpp

    r56895 r57012  
    42114211    Iterator end = m_formElementsWithState.end();
    42124212    for (Iterator it = m_formElementsWithState.begin(); it != end; ++it) {
    4213         Element* e = *it;
     4213        Element* elementWithState = *it;
    42144214        String value;
    4215         if (e->saveFormControlState(value)) {
    4216             stateVector.append(e->formControlName().string());
    4217             stateVector.append(e->formControlType().string());
    4218             stateVector.append(value);
    4219         }
     4215        if (!elementWithState->shouldSaveAndRestoreFormControlState())
     4216            continue;
     4217        if (!elementWithState->saveFormControlState(value))
     4218            continue;
     4219        stateVector.append(elementWithState->formControlName().string());
     4220        stateVector.append(elementWithState->formControlType().string());
     4221        stateVector.append(value);
    42204222    }
    42214223    return stateVector;
  • trunk/WebCore/dom/Element.h

    r55167 r57012  
    266266    virtual const AtomicString& formControlType() const { return nullAtom; }
    267267
     268    virtual bool shouldSaveAndRestoreFormControlState() const { return true; }
    268269    virtual bool saveFormControlState(String&) const { return false; }
    269270    virtual void restoreFormControlState(const String&) { }
  • trunk/WebCore/html/HTMLFormControlElement.cpp

    r56463 r57012  
    423423}
    424424
     425bool HTMLFormControlElementWithState::autoComplete() const
     426{
     427    if (!form())
     428        return true;
     429    return form()->autoComplete();
     430}
     431
     432bool HTMLFormControlElementWithState::shouldSaveAndRestoreFormControlState() const
     433{
     434    // We don't save/restore control state in a form with autocomplete=off.
     435    return autoComplete();
     436}
     437
    425438void HTMLFormControlElementWithState::finishParsingChildren()
    426439{
    427440    HTMLFormControlElement::finishParsingChildren();
     441
     442    // We don't save state of a control with shouldSaveAndRestoreFormControlState()=false.
     443    // But we need to skip restoring process too because a control in another
     444    // form might have the same pair of name and type and saved its state.
     445    if (!shouldSaveAndRestoreFormControlState())
     446        return;
     447
    428448    Document* doc = document();
    429449    if (doc->hasStateForNewFormElements()) {
  • trunk/WebCore/html/HTMLFormControlElement.h

    r56385 r57012  
    151151    virtual ~HTMLFormControlElementWithState();
    152152
     153    virtual bool autoComplete() const;
     154    virtual bool shouldSaveAndRestoreFormControlState() const;
    153155    virtual void finishParsingChildren();
    154156
  • trunk/WebCore/html/HTMLInputElement.cpp

    r56933 r57012  
    156156    if (m_autocomplete != Uninitialized)
    157157        return m_autocomplete == On;
    158    
    159     // Assuming we're still in a Form, respect the Form's setting
    160     if (HTMLFormElement* form = this->form())
    161         return form->autoComplete();
    162    
    163     // The default is true
    164     return true;
     158    return HTMLTextFormControlElement::autoComplete();
    165159}
    166160
     
    912906bool HTMLInputElement::saveFormControlState(String& result) const
    913907{
    914     if (!autoComplete())
    915         return false;
    916 
    917908    switch (inputType()) {
    918909        case BUTTON:
Note: See TracChangeset for help on using the changeset viewer.