LayoutTests:
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jul 2007 17:48:32 +0000 (17:48 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 17 Jul 2007 17:48:32 +0000 (17:48 +0000)
commit87c727a3a480ed9cd05296568e0ba89a8ecb7a64
treeec57b70ddf747427876d37649fc5d726d78d4bb9
parentb4691ed1b135ae45f206144c1086d0ad7a893f1a
LayoutTests:

        Reviewed by Maciej.
        Landed by Darin.

        - test for http://bugs.webkit.org/show_bug.cgi?id=14569
          Repro crash due to saved state not being cleared when select and textarea elements are adopted by another document
          and for http://bugs.webkit.org/show_bug.cgi?id=13701
          REGRESSION (r21431): Reproducible crash resulting from calling adoptNode on a password field

        * fast/forms/saved-state-adoptNode-crash-expected.txt: Added.
        * fast/forms/saved-state-adoptNode-crash.html: Added.

WebCore:

        Reviewed by Mitz.

        - fix http://bugs.webkit.org/show_bug.cgi?id=14569
          Repro crash due to saved state not being cleared when select and textarea elements
          are adopted by another document

        Test: fast/forms/saved-state-adoptNode-crash.html

        * dom/Document.h:
        (WebCore::Document::registerFormElementWithState): Updated parameter type to be
        HTMLFormControlElementWithState.
        (WebCore::Document::unregisterFormElementWithState): Ditto.
        Also removed isFormElementRegistered function and changed the type of the
        m_formElementsWithState ListHashSet.
        * dom/Document.cpp: (WebCore::Document::formElementsState): Updated to use new type,
        for set contents and to use new saveState() function and only save state for elements
        that return true.

        * html/HTMLGenericFormElement.h: Added HTMLFormControlElementWithState class,
        derived from HTMLGenericFormElement, and moved down all the behavior related to
        saving form control element state. Also removed the unnecessary default parameter
        to the HTMLGenericFormElement constructor.
        * html/HTMLGenericFormElement.cpp:
        (WebCore::HTMLFormControlElementWithState::HTMLFormControlElementWithState): Added.
        Calls registerFormElementWithState.
        (WebCore::HTMLFormControlElementWithState::~HTMLFormControlElementWithState): Added.
        Calls unregisterFormElementWithState.
        (WebCore::HTMLFormControlElementWithState::willMoveToNewOwnerDocument): Added.
        Calls unregisterFormElementWithState.
        (WebCore::HTMLFormControlElementWithState::didMoveToNewOwnerDocument): Added.
        Calls registerFormElementWithState.
        (WebCore::HTMLFormControlElementWithState::closeRenderer): Moved to this class from
        the base class.

        * html/HTMLInputElement.h: Updated the base class name and overrode saveState instead
        of stateValue.
        * html/HTMLInputElement.cpp: Updated the base class name.
        (WebCore::HTMLInputElement::init): Removed the call to registerFormElementWithState.
        (WebCore::HTMLInputElement::~HTMLInputElement): Removed the call to
        unregisterFormElementWithState. Also changed the code to only call the
        unregisterForDidRestoreFromCacheCallback function for type PASSWORD (consistency
        and efficiency).
        (WebCore::HTMLInputElement::setInputType): Removed calls to registerFormElementWithState
        and unregisterFormElementWithState; we now let the element stay registered and simply
        don't save or restore state for password fields.
        (WebCore::HTMLInputElement::saveState): Updated function name and signature to replace
        the old stateValue function. Returns false for password fields.
        (WebCore::HTMLInputElement::willMoveToNewOwnerDocument): Removed the call to
        unregisterFormElementWithState.
        (WebCore::HTMLInputElement::didMoveToNewOwnerDocument): Removed the call to
        registerFormElementWithState.

        * html/HTMLSelectElement.h: Updated the base class name and overrode saveState instead
        of stateValue.
        * html/HTMLSelectElement.cpp: Updated the base class name.
        (WebCore::HTMLSelectElement::HTMLSelectElement): Removed the call to
        registerFormElementWithState.
        (WebCore::HTMLSelectElement::~HTMLSelectElement): Removed the call to
        unregisterFormElementWithState.
        (WebCore::HTMLSelectElement::saveState): Updated function name and signature to
        replace the old stateValue function.
        (WebCore::HTMLSelectElement::setLength): Updated to use document() instead of
        ownerDocument(); the latter is just a slower virtual-function way of doing the
        same thing in all cases except for Document and XPathNamespace.

        * html/HTMLTextAreaElement.h: Update the base class name, overrode saveState instead
        of stateValue, and removed the now-unnecessary explicit destructor.
        * html/HTMLTextAreaElement.cpp: Updated the base class name.
        (WebCore::HTMLTextAreaElement::HTMLTextAreaElement): Removed the call to
        registerFormElementWithState.
        (WebCore::HTMLTextAreaElement::saveState): Updated function name and signature to replace
        the old stateValue function.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@24363 268f45cc-cd09-0410-ab3c-d52691b4dbfc
14 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/forms/saved-state-adoptNode-crash-expected.txt [new file with mode: 0644]
LayoutTests/fast/forms/saved-state-adoptNode-crash.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Document.cpp
WebCore/dom/Document.h
WebCore/html/HTMLGenericFormElement.cpp
WebCore/html/HTMLGenericFormElement.h
WebCore/html/HTMLInputElement.cpp
WebCore/html/HTMLInputElement.h
WebCore/html/HTMLSelectElement.cpp
WebCore/html/HTMLSelectElement.h
WebCore/html/HTMLTextAreaElement.cpp
WebCore/html/HTMLTextAreaElement.h