Title: [121235] trunk/Source/WebCore
Revision
121235
Author
tk...@chromium.org
Date
2012-06-26 00:55:18 -0700 (Tue, 26 Jun 2012)

Log Message

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):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (121234 => 121235)


--- trunk/Source/WebCore/ChangeLog	2012-06-26 07:41:32 UTC (rev 121234)
+++ trunk/Source/WebCore/ChangeLog	2012-06-26 07:55:18 UTC (rev 121235)
@@ -1,3 +1,28 @@
+2012-06-26  Kent Tamura  <tk...@chromium.org>
+
+        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  <domin...@chromium.org>
 
         WheelEvent should inherit from MouseEvent

Modified: trunk/Source/WebCore/html/FormController.cpp (121234 => 121235)


--- trunk/Source/WebCore/html/FormController.cpp	2012-06-26 07:41:32 UTC (rev 121234)
+++ trunk/Source/WebCore/html/FormController.cpp	2012-06-26 07:55:18 UTC (rev 121235)
@@ -138,15 +138,12 @@
         m_stateForNewFormElements.clear();
 }
 
-bool FormController::hasStateForNewFormElements() const
+FormControlState FormController::takeStateForFormElement(const HTMLFormControlElementWithState& control)
 {
-    return !m_stateForNewFormElements.isEmpty();
-}
-
-FormControlState FormController::takeStateForFormElement(AtomicStringImpl* name, AtomicStringImpl* type)
-{
+    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());

Modified: trunk/Source/WebCore/html/FormController.h (121234 => 121235)


--- trunk/Source/WebCore/html/FormController.h	2012-06-26 07:41:32 UTC (rev 121234)
+++ trunk/Source/WebCore/html/FormController.h	2012-06-26 07:55:18 UTC (rev 121235)
@@ -125,8 +125,7 @@
     Vector<String> formElementsState() const;
     // This should be callled only by Document::setStateForNewFormElements().
     void setStateForNewFormElements(const Vector<String>&);
-    bool hasStateForNewFormElements() const;
-    FormControlState takeStateForFormElement(AtomicStringImpl* name, AtomicStringImpl* type);
+    FormControlState takeStateForFormElement(const HTMLFormControlElementWithState&);
 
     void registerFormElementWithFormAttribute(FormAssociatedElement*);
     void unregisterFormElementWithFormAttribute(FormAssociatedElement*);

Modified: trunk/Source/WebCore/html/HTMLFormControlElementWithState.cpp (121234 => 121235)


--- trunk/Source/WebCore/html/HTMLFormControlElementWithState.cpp	2012-06-26 07:41:32 UTC (rev 121234)
+++ trunk/Source/WebCore/html/HTMLFormControlElementWithState.cpp	2012-06-26 07:55:18 UTC (rev 121235)
@@ -77,12 +77,9 @@
     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
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to