Move HTMLFormControlElementWithState class in its own header file.
authoralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jan 2012 05:36:37 +0000 (05:36 +0000)
committeralexis.menard@openbossa.org <alexis.menard@openbossa.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 6 Jan 2012 05:36:37 +0000 (05:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=75482

Reviewed by Kent Tamura.

Move HTMLFormControlElementWithState class which was mixed in HTMLFormControlElement
files into its own header file and its own implementation file.

No new tests : the existing ones should cover the refactoring.

* CMakeLists.txt:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.vcproj/WebCore.vcproj:
* WebCore.xcodeproj/project.pbxproj:
* html/HTMLElementsAllInOne.cpp:
* html/HTMLFormControlElement.cpp:
* html/HTMLFormControlElement.h:
* html/HTMLKeygenElement.h:
* html/HTMLSelectElement.h:
* html/HTMLTextFormControlElement.h:

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@104268 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/Target.pri
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/html/HTMLElementsAllInOne.cpp
Source/WebCore/html/HTMLFormControlElement.cpp
Source/WebCore/html/HTMLFormControlElement.h
Source/WebCore/html/HTMLFormControlElementWithState.cpp [new file with mode: 0644]
Source/WebCore/html/HTMLFormControlElementWithState.h [new file with mode: 0644]
Source/WebCore/html/HTMLKeygenElement.h
Source/WebCore/html/HTMLSelectElement.h
Source/WebCore/html/HTMLTextFormControlElement.h

index 90856a8..2ac44ce 100644 (file)
@@ -740,6 +740,7 @@ SET(WebCore_SOURCES
     html/HTMLFontElement.cpp
     html/HTMLFormCollection.cpp
     html/HTMLFormControlElement.cpp
+    html/HTMLFormControlElementWithState.cpp
     html/HTMLFormElement.cpp
     html/HTMLFrameElement.cpp
     html/HTMLFrameElementBase.cpp
index 335ba03..cfacd2f 100644 (file)
@@ -1,3 +1,28 @@
+2012-01-05  Alexis Menard  <alexis.menard@openbossa.org>
+
+        Move HTMLFormControlElementWithState class in its own header file.
+        https://bugs.webkit.org/show_bug.cgi?id=75482
+
+        Reviewed by Kent Tamura.
+
+        Move HTMLFormControlElementWithState class which was mixed in HTMLFormControlElement
+        files into its own header file and its own implementation file.
+
+        No new tests : the existing ones should cover the refactoring.
+
+        * CMakeLists.txt:
+        * GNUmakefile.list.am:
+        * Target.pri:
+        * WebCore.gypi:
+        * WebCore.vcproj/WebCore.vcproj:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/HTMLElementsAllInOne.cpp:
+        * html/HTMLFormControlElement.cpp:
+        * html/HTMLFormControlElement.h:
+        * html/HTMLKeygenElement.h:
+        * html/HTMLSelectElement.h:
+        * html/HTMLTextFormControlElement.h:
+
 2012-01-05  Wei James  <james.wei@intel.com>
 
         Optimize with memcpy instead of copying frame by frame in Realtimeanalyser::doFFTAnalysis
index 73bb8fa..8fe0fb5 100644 (file)
@@ -2020,6 +2020,8 @@ webcore_sources += \
        Source/WebCore/html/HTMLFormCollection.h \
        Source/WebCore/html/HTMLFormControlElement.cpp \
        Source/WebCore/html/HTMLFormControlElement.h \
+       Source/WebCore/html/HTMLFormControlElementWithState.cpp \
+       Source/WebCore/html/HTMLFormControlElementWithState.h \
        Source/WebCore/html/HTMLFormElement.cpp \
        Source/WebCore/html/HTMLFormElement.h \
        Source/WebCore/html/HTMLFrameElementBase.cpp \
index fa0cffa..b6f566e 100644 (file)
@@ -725,6 +725,7 @@ SOURCES += \
     html/HTMLFontElement.cpp \
     html/HTMLFormCollection.cpp \
     html/HTMLFormControlElement.cpp \
+    html/HTMLFormControlElementWithState.cpp \
     html/HTMLFormElement.cpp \
     html/HTMLFrameElement.cpp \
     html/HTMLFrameElementBase.cpp \
@@ -1795,6 +1796,7 @@ HEADERS += \
     html/HTMLFontElement.h \
     html/HTMLFormCollection.h \
     html/HTMLFormControlElement.h \
+    html/HTMLFormControlElementWithState.h \
     html/HTMLFormElement.h \
     html/HTMLFrameElementBase.h \
     html/HTMLFrameElement.h \
index 4111af4..df970b7 100644 (file)
             'html/HTMLDocument.h',
             'html/HTMLElement.h',
             'html/HTMLFormControlElement.h',
+            'html/HTMLFormControlElementWithState.h',
             'html/HTMLFormElement.h',
             'html/HTMLFrameElement.h',
             'html/HTMLFrameElementBase.h',
             'html/HTMLFormCollection.cpp',
             'html/HTMLFormCollection.h',
             'html/HTMLFormControlElement.cpp',
+            'html/HTMLFormControlElementWithState.cpp',
             'html/HTMLFormElement.cpp',
             'html/HTMLFrameElement.cpp',
             'html/HTMLFrameElementBase.cpp',
index 3e26b26..12556e0 100755 (executable)
                                RelativePath="..\html\HTMLFormControlElement.h"
                                >
                        </File>
+                        <File
+                                RelativePath="..\html\HTMLFormControlElementWithState.cpp"
+                                >
+                                <FileConfiguration
+                                        Name="Debug|Win32"
+                                        ExcludedFromBuild="true"
+                                        >
+                                        <Tool
+                                                Name="VCCLCompilerTool"
+                                        />
+                                </FileConfiguration>
+                                <FileConfiguration
+                                        Name="Release|Win32"
+                                        ExcludedFromBuild="true"
+                                        >
+                                        <Tool
+                                                Name="VCCLCompilerTool"
+                                        />
+                                </FileConfiguration>
+                                <FileConfiguration
+                                        Name="Debug_Cairo_CFLite|Win32"
+                                        ExcludedFromBuild="true"
+                                        >
+                                        <Tool
+                                                Name="VCCLCompilerTool"
+                                        />
+                                </FileConfiguration>
+                                <FileConfiguration
+                                        Name="Release_Cairo_CFLite|Win32"
+                                        ExcludedFromBuild="true"
+                                        >
+                                        <Tool
+                                                Name="VCCLCompilerTool"
+                                        />
+                                </FileConfiguration>
+                                <FileConfiguration
+                                        Name="Debug_All|Win32"
+                                        ExcludedFromBuild="true"
+                                        >
+                                        <Tool
+                                                Name="VCCLCompilerTool"
+                                        />
+                                </FileConfiguration>
+                                <FileConfiguration
+                                        Name="Production|Win32"
+                                        ExcludedFromBuild="true"
+                                        >
+                                        <Tool
+                                                Name="VCCLCompilerTool"
+                                        />
+                                </FileConfiguration>
+                        </File>
+                        <File
+                                RelativePath="..\html\HTMLFormControlElementWithState.h"
+                                >
+                        </File>
                        <File
                                RelativePath="..\html\HTMLFormElement.cpp"
                                >
index aaf27f6..a49c0af 100644 (file)
                E12EDBEA0B308E0B002704B6 /* EventTarget.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E12EDBE90B308E0B002704B6 /* EventTarget.cpp */; };
                E134F5AB12EE343F004EC58D /* IntRectHash.h in Headers */ = {isa = PBXBuildFile; fileRef = E134F5AA12EE343F004EC58D /* IntRectHash.h */; settings = {ATTRIBUTES = (Private, ); }; };
                E13F01F11270E19000DFBA71 /* CookieStorageMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = E13F01F01270E19000DFBA71 /* CookieStorageMac.mm */; };
+               E14F1C4414B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E14F1C4214B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp */; };
+               E14F1C4514B5DAC600EA9009 /* HTMLFormControlElementWithState.h in Headers */ = {isa = PBXBuildFile; fileRef = E14F1C4314B5DAC600EA9009 /* HTMLFormControlElementWithState.h */; };
                E15A36D71104572000B7B639 /* XMLNSNames.h in Headers */ = {isa = PBXBuildFile; fileRef = E15A36D61104572000B7B639 /* XMLNSNames.h */; };
                E15A36D91104572700B7B639 /* XMLNSNames.cpp in Sources */ = {isa = PBXBuildFile; fileRef = E15A36D81104572700B7B639 /* XMLNSNames.cpp */; };
                E169803D1133542D00894115 /* CRuntimeObject.h in Headers */ = {isa = PBXBuildFile; fileRef = E169803C1133542D00894115 /* CRuntimeObject.h */; };
                E134F5AA12EE343F004EC58D /* IntRectHash.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IntRectHash.h; sourceTree = "<group>"; };
                E13F01EA1270E10D00DFBA71 /* CookieStorage.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CookieStorage.h; sourceTree = "<group>"; };
                E13F01F01270E19000DFBA71 /* CookieStorageMac.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CookieStorageMac.mm; sourceTree = "<group>"; };
+               E14F1C4214B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLFormControlElementWithState.cpp; sourceTree = "<group>"; };
+               E14F1C4314B5DAC600EA9009 /* HTMLFormControlElementWithState.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLFormControlElementWithState.h; sourceTree = "<group>"; };
                E15A36D61104572000B7B639 /* XMLNSNames.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = XMLNSNames.h; sourceTree = "<group>"; };
                E15A36D81104572700B7B639 /* XMLNSNames.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = XMLNSNames.cpp; sourceTree = "<group>"; };
                E169803C1133542D00894115 /* CRuntimeObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CRuntimeObject.h; sourceTree = "<group>"; };
                                A8DF3FC6097FA0FB0052981B /* HTMLFormCollection.h */,
                                A81369B3097374F500D74463 /* HTMLFormControlElement.cpp */,
                                A81369B2097374F500D74463 /* HTMLFormControlElement.h */,
+                               E14F1C4214B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp */,
+                               E14F1C4314B5DAC600EA9009 /* HTMLFormControlElementWithState.h */,
                                A81369B5097374F500D74463 /* HTMLFormElement.cpp */,
                                A81369B4097374F500D74463 /* HTMLFormElement.h */,
                                A8D064EF0A23BFEA005E7203 /* HTMLFormElement.idl */,
                                977B386F122883E900B81FF8 /* HTMLFormattingElementList.h in Headers */,
                                A8DF3FCE097FA0FC0052981B /* HTMLFormCollection.h in Headers */,
                                A81369CE097374F600D74463 /* HTMLFormControlElement.h in Headers */,
+                               E14F1C4514B5DAC600EA9009 /* HTMLFormControlElementWithState.h in Headers */,
                                A81369D0097374F600D74463 /* HTMLFormElement.h in Headers */,
                                A871DE2B0A152AC800B12A68 /* HTMLFrameElement.h in Headers */,
                                14FFE31D0AE1963300136BF5 /* HTMLFrameElementBase.h in Headers */,
                                977B386E122883E900B81FF8 /* HTMLFormattingElementList.cpp in Sources */,
                                A8DF3FCF097FA0FC0052981B /* HTMLFormCollection.cpp in Sources */,
                                A81369CF097374F600D74463 /* HTMLFormControlElement.cpp in Sources */,
+                               E14F1C4414B5DAC600EA9009 /* HTMLFormControlElementWithState.cpp in Sources */,
                                A81369D1097374F600D74463 /* HTMLFormElement.cpp in Sources */,
                                A871DE230A152AC800B12A68 /* HTMLFrameElement.cpp in Sources */,
                                14FFE31E0AE1963300136BF5 /* HTMLFrameElementBase.cpp in Sources */,
index 5d9942f..b624e62 100644 (file)
@@ -51,6 +51,7 @@
 #include "HTMLFieldSetElement.cpp"
 #include "HTMLFontElement.cpp"
 #include "HTMLFormControlElement.cpp"
+#include "HTMLFormControlElementWithState.cpp"
 #include "HTMLFormElement.cpp"
 #include "HTMLFrameElement.cpp"
 #include "HTMLFrameElementBase.cpp"
index 8fe4504..71a4484 100644 (file)
@@ -500,54 +500,4 @@ PassRefPtr<NodeList> HTMLFormControlElement::labels()
     return list.release();
 }
 
-HTMLFormControlElementWithState::HTMLFormControlElementWithState(const QualifiedName& tagName, Document* doc, HTMLFormElement* f)
-    : HTMLFormControlElement(tagName, doc, f)
-{
-    document()->registerFormElementWithState(this);
-}
-
-HTMLFormControlElementWithState::~HTMLFormControlElementWithState()
-{
-    document()->unregisterFormElementWithState(this);
-}
-
-void HTMLFormControlElementWithState::didMoveToNewDocument(Document* oldDocument)
-{
-    if (oldDocument)
-        oldDocument->unregisterFormElementWithState(this);
-    document()->registerFormElementWithState(this);
-    HTMLFormControlElement::didMoveToNewDocument(oldDocument);
-}
-
-bool HTMLFormControlElementWithState::shouldAutocomplete() const
-{
-    if (!form())
-        return true;
-    return form()->shouldAutocomplete();
-}
-
-bool HTMLFormControlElementWithState::shouldSaveAndRestoreFormControlState() const
-{
-    // We don't save/restore control state in a form with autocomplete=off.
-    return attached() && shouldAutocomplete();
-}
-
-void HTMLFormControlElementWithState::finishParsingChildren()
-{
-    HTMLFormControlElement::finishParsingChildren();
-
-    // We don't save state of a control with shouldSaveAndRestoreFormControlState()=false.
-    // But we need to skip restoring process too because a control in another
-    // form might have the same pair of name and type and saved its state.
-    if (!shouldSaveAndRestoreFormControlState())
-        return;
-
-    Document* doc = document();
-    if (doc->hasStateForNewFormElements()) {
-        String state;
-        if (doc->takeStateForFormElement(name().impl(), type().impl(), state))
-            restoreFormControlState(state);
-    }
-}
-
 } // namespace Webcore
index df7a2d1..f500b6d 100644 (file)
@@ -169,25 +169,6 @@ private:
     bool m_hasAutofocused : 1;
 };
 
-// FIXME: Give this class its own header file.
-class HTMLFormControlElementWithState : public HTMLFormControlElement {
-public:
-    virtual ~HTMLFormControlElementWithState();
-
-    virtual bool canContainRangeEndPoint() const { return false; }
-
-    bool shouldSaveAndRestoreFormControlState() const;
-    virtual bool saveFormControlState(String&) const { return false; }
-    virtual void restoreFormControlState(const String&) { }
-
-protected:
-    HTMLFormControlElementWithState(const QualifiedName& tagName, Document*, HTMLFormElement*);
-
-    virtual bool shouldAutocomplete() const;
-    virtual void finishParsingChildren();
-    virtual void didMoveToNewDocument(Document* oldDocument) OVERRIDE;
-};
-
 } // namespace
 
 #endif
diff --git a/Source/WebCore/html/HTMLFormControlElementWithState.cpp b/Source/WebCore/html/HTMLFormControlElementWithState.cpp
new file mode 100644 (file)
index 0000000..bf94c54
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ *           (C) 2001 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved.
+ *           (C) 2006 Alexey Proskuryakov (ap@nypop.com)
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include "config.h"
+#include "HTMLFormControlElementWithState.h"
+
+#include "HTMLFormElement.h"
+
+namespace WebCore {
+
+HTMLFormControlElementWithState::HTMLFormControlElementWithState(const QualifiedName& tagName, Document* doc, HTMLFormElement* f)
+    : HTMLFormControlElement(tagName, doc, f)
+{
+    document()->registerFormElementWithState(this);
+}
+
+HTMLFormControlElementWithState::~HTMLFormControlElementWithState()
+{
+    document()->unregisterFormElementWithState(this);
+}
+
+void HTMLFormControlElementWithState::didMoveToNewDocument(Document* oldDocument)
+{
+    if (oldDocument)
+        oldDocument->unregisterFormElementWithState(this);
+    document()->registerFormElementWithState(this);
+    HTMLFormControlElement::didMoveToNewDocument(oldDocument);
+}
+
+bool HTMLFormControlElementWithState::shouldAutocomplete() const
+{
+    if (!form())
+        return true;
+    return form()->shouldAutocomplete();
+}
+
+bool HTMLFormControlElementWithState::shouldSaveAndRestoreFormControlState() const
+{
+    // We don't save/restore control state in a form with autocomplete=off.
+    return attached() && shouldAutocomplete();
+}
+
+void HTMLFormControlElementWithState::finishParsingChildren()
+{
+    HTMLFormControlElement::finishParsingChildren();
+
+    // We don't save state of a control with shouldSaveAndRestoreFormControlState()=false.
+    // But we need to skip restoring process too because a control in another
+    // form might have the same pair of name and type and saved its state.
+    if (!shouldSaveAndRestoreFormControlState())
+        return;
+
+    Document* doc = document();
+    if (doc->hasStateForNewFormElements()) {
+        String state;
+        if (doc->takeStateForFormElement(name().impl(), type().impl(), state))
+            restoreFormControlState(state);
+    }
+}
+
+} // namespace Webcore
diff --git a/Source/WebCore/html/HTMLFormControlElementWithState.h b/Source/WebCore/html/HTMLFormControlElementWithState.h
new file mode 100644 (file)
index 0000000..73de326
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
+ *           (C) 1999 Antti Koivisto (koivisto@kde.org)
+ *           (C) 2000 Dirk Mueller (mueller@kde.org)
+ * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserved.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#ifndef HTMLFormControlElementWithState_h
+#define HTMLFormControlElementWithState_h
+
+#include "HTMLFormControlElement.h"
+
+namespace WebCore {
+
+class HTMLFormControlElementWithState : public HTMLFormControlElement {
+public:
+    virtual ~HTMLFormControlElementWithState();
+
+    virtual bool canContainRangeEndPoint() const { return false; }
+
+    bool shouldSaveAndRestoreFormControlState() const;
+    virtual bool saveFormControlState(String&) const { return false; }
+    virtual void restoreFormControlState(const String&) { }
+
+protected:
+    HTMLFormControlElementWithState(const QualifiedName& tagName, Document*, HTMLFormElement*);
+
+    virtual bool shouldAutocomplete() const;
+    virtual void finishParsingChildren();
+    virtual void didMoveToNewDocument(Document* oldDocument) OVERRIDE;
+};
+
+} // namespace
+
+#endif
index 7761993..cc477d6 100644 (file)
@@ -24,7 +24,7 @@
 #ifndef HTMLKeygenElement_h
 #define HTMLKeygenElement_h
 
-#include "HTMLFormControlElement.h"
+#include "HTMLFormControlElementWithState.h"
 
 namespace WebCore {
 
index 9c09383..5363cc7 100644 (file)
@@ -27,7 +27,7 @@
 #define HTMLSelectElement_h
 
 #include "Event.h"
-#include "HTMLFormControlElement.h"
+#include "HTMLFormControlElementWithState.h"
 #include <wtf/Vector.h>
 
 namespace WebCore {
index ca21232..c13440c 100644 (file)
@@ -25,7 +25,7 @@
 #ifndef HTMLTextFormControlElement_h
 #define HTMLTextFormControlElement_h
 
-#include "HTMLFormControlElement.h"
+#include "HTMLFormControlElementWithState.h"
 
 namespace WebCore {