From 92bad1a113023270b150a61b58e344a75e46e33d Mon Sep 17 00:00:00 2001 From: "tkent@chromium.org" Date: Tue, 26 Jun 2012 07:55:18 +0000 Subject: [PATCH] Refactoring: Simplify FormController interface https://bugs.webkit.org/show_bug.cgi?id=89951 Reviewed by Kentaro Hara. - Remove FormController::hasStateForNewFormElements() takeStateForFormElement() can check the emptiness, and return an empty FormControlState. - Change the argument of takeStateForFormElement() Passing just one HTMLFormControlElementWithState object instead of two AtomicStringImpl. This is a preparation to use HTMLFormControlElementWithState::form() in FormController. No new tests. Just a refactoring. * html/FormController.cpp: (WebCore::FormController::takeStateForFormElement): * html/FormController.h: (FormController): * html/HTMLFormControlElementWithState.cpp: (WebCore::HTMLFormControlElementWithState::finishParsingChildren): git-svn-id: http://svn.webkit.org/repository/webkit/trunk@121235 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- Source/WebCore/ChangeLog | 25 ++++++++++++++++++++++ Source/WebCore/html/FormController.cpp | 11 ++++------ Source/WebCore/html/FormController.h | 3 +-- .../html/HTMLFormControlElementWithState.cpp | 9 +++----- 4 files changed, 33 insertions(+), 15 deletions(-) diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index c105be5..46df104 100755 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,28 @@ +2012-06-26 Kent Tamura + + Refactoring: Simplify FormController interface + https://bugs.webkit.org/show_bug.cgi?id=89951 + + Reviewed by Kentaro Hara. + + - Remove FormController::hasStateForNewFormElements() + takeStateForFormElement() can check the emptiness, and return an empty + FormControlState. + + - Change the argument of takeStateForFormElement() + Passing just one HTMLFormControlElementWithState object instead of two + AtomicStringImpl. This is a preparation to use + HTMLFormControlElementWithState::form() in FormController. + + No new tests. Just a refactoring. + + * html/FormController.cpp: + (WebCore::FormController::takeStateForFormElement): + * html/FormController.h: + (FormController): + * html/HTMLFormControlElementWithState.cpp: + (WebCore::HTMLFormControlElementWithState::finishParsingChildren): + 2012-06-26 Dominic Cooney WheelEvent should inherit from MouseEvent diff --git a/Source/WebCore/html/FormController.cpp b/Source/WebCore/html/FormController.cpp index 31c7763..8719443 100644 --- a/Source/WebCore/html/FormController.cpp +++ b/Source/WebCore/html/FormController.cpp @@ -138,15 +138,12 @@ void FormController::setStateForNewFormElements(const Vector& stateVecto m_stateForNewFormElements.clear(); } -bool FormController::hasStateForNewFormElements() const -{ - return !m_stateForNewFormElements.isEmpty(); -} - -FormControlState FormController::takeStateForFormElement(AtomicStringImpl* name, AtomicStringImpl* type) +FormControlState FormController::takeStateForFormElement(const HTMLFormControlElementWithState& control) { + if (m_stateForNewFormElements.isEmpty()) + return FormControlState(); typedef FormElementStateMap::iterator Iterator; - Iterator it = m_stateForNewFormElements.find(FormElementKey(name, type)); + Iterator it = m_stateForNewFormElements.find(FormElementKey(control.name().impl(), control.type().impl())); if (it == m_stateForNewFormElements.end()) return FormControlState(); ASSERT(it->second.size()); diff --git a/Source/WebCore/html/FormController.h b/Source/WebCore/html/FormController.h index fa5463b..8415695 100644 --- a/Source/WebCore/html/FormController.h +++ b/Source/WebCore/html/FormController.h @@ -125,8 +125,7 @@ public: Vector formElementsState() const; // This should be callled only by Document::setStateForNewFormElements(). void setStateForNewFormElements(const Vector&); - bool hasStateForNewFormElements() const; - FormControlState takeStateForFormElement(AtomicStringImpl* name, AtomicStringImpl* type); + FormControlState takeStateForFormElement(const HTMLFormControlElementWithState&); void registerFormElementWithFormAttribute(FormAssociatedElement*); void unregisterFormElementWithFormAttribute(FormAssociatedElement*); diff --git a/Source/WebCore/html/HTMLFormControlElementWithState.cpp b/Source/WebCore/html/HTMLFormControlElementWithState.cpp index a884ee1..22940e0 100644 --- a/Source/WebCore/html/HTMLFormControlElementWithState.cpp +++ b/Source/WebCore/html/HTMLFormControlElementWithState.cpp @@ -77,12 +77,9 @@ void HTMLFormControlElementWithState::finishParsingChildren() if (!shouldSaveAndRestoreFormControlState()) return; - Document* doc = document(); - if (doc->formController()->hasStateForNewFormElements()) { - FormControlState state = doc->formController()->takeStateForFormElement(name().impl(), type().impl()); - if (state.valueSize() > 0) - restoreFormControlState(state); - } + FormControlState state = document()->formController()->takeStateForFormElement(*this); + if (state.valueSize() > 0) + restoreFormControlState(state); } } // namespace Webcore -- 2.7.4