Title: [221914] trunk/Source
Revision
221914
Author
[email protected]
Date
2017-09-12 07:53:18 -0700 (Tue, 12 Sep 2017)

Log Message

[Cleanup] Follow up cleanup for DOMFormData implementation
https://bugs.webkit.org/show_bug.cgi?id=176740

Patch by Sam Weinig <[email protected]> on 2017-09-12
Reviewed by Alex Christensen.

Source/WebCore:

- Merges FormDataList into DOMFormData.
- Streamline / refactor FormData creation from DOMFormData.

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* html/FormDataList.cpp: Removed.
* html/FormDataList.h: Removed.

    Remove FormDataList.

* html/DOMFormData.cpp:
(WebCore::DOMFormData::DOMFormData):
(WebCore::DOMFormData::createFileEntry):
(WebCore::DOMFormData::append):
(WebCore::DOMFormData::set):
(WebCore::DOMFormData::Iterator::next):
* html/DOMFormData.h:
(WebCore::DOMFormData::items const):
(WebCore::DOMFormData::encoding const):

    Merge FormDataList into DOMFormData. FormDataList's additional
    appendData/appendBlob functions have been removed, and their
    functionality inlined into DOMFormData's append functions.

    Adopted makeKeyValuePair in DOMFormData::Iterator::next().

* platform/network/FormData.cpp:
(WebCore::FormData::create):
(WebCore::FormData::createMultiPart):
(WebCore::normalizeStringData):
(WebCore::FormData::appendMultiPartFileValue):
(WebCore::FormData::appendMultiPartStringValue):
(WebCore::FormData::appendMultiPartKeyValuePairItems):
(WebCore::FormData::appendNonMultiPartKeyValuePairItems):
(WebCore::FormData::appendKeyValuePairItems): Deleted.
* platform/network/FormData.h:

    Split-up appendKeyValuePairItems into separate multipart and non-multipart
    functions, as the two edges of the branch didn't share much in common. Further
    split out multipart file and multipart string appending, since they too did not
    share that much in common and makes the code easier to follow.

    String value normalization has been moved entirely here (previously it was a member
    function of FormDataList) as FormData is the only user.

* xml/XMLHttpRequest.cpp:
(WebCore::XMLHttpRequest::send):
* loader/FormSubmission.cpp:
(WebCore::FormSubmission::create):
* Modules/fetch/FetchBody.cpp:
(WebCore::FetchBody::extract):

    Update for new FormData create functions which don't need the
    encoding passed explicitly, since it is part of the DOMFormData.

* html/BaseButtonInputType.cpp:
* html/BaseButtonInputType.h:
* html/BaseCheckableInputType.cpp:
* html/BaseCheckableInputType.h:
* html/FileInputType.cpp:
* html/FileInputType.h:
* html/FormAssociatedElement.h:
* html/HTMLButtonElement.cpp:
* html/HTMLButtonElement.h:
* html/HTMLFormControlElement.h:
* html/HTMLInputElement.cpp:
* html/HTMLInputElement.h:
* html/HTMLKeygenElement.cpp:
* html/HTMLKeygenElement.h:
* html/HTMLMeterElement.cpp:
* html/HTMLObjectElement.cpp:
* html/HTMLObjectElement.h:
* html/HTMLSelectElement.cpp:
* html/HTMLSelectElement.h:
* html/HTMLTextAreaElement.cpp:
* html/HTMLTextAreaElement.h:
* html/HiddenInputType.cpp:
* html/HiddenInputType.h:
* html/ImageInputType.cpp:
* html/ImageInputType.h:
* html/InputType.cpp:
* html/InputType.h:
* html/SubmitInputType.cpp:
* html/SubmitInputType.h:
* html/TextFieldInputType.cpp:
* html/TextFieldInputType.h:

    Update to use DOMFormData directly, rather than the FormDataList, which
    has been removed.

* page/csp/ContentSecurityPolicy.cpp:

    Remove unnecessary #include of unused (and now removed) FormDataList.h

Source/WTF:

* WTF.xcodeproj/project.pbxproj:
* wtf/HashTraits.h:
(WTF::KeyValuePair::KeyValuePair): Deleted.
* wtf/KeyValuePair.h: Added.
(WTF::KeyValuePair::KeyValuePair):
(WTF::makeKeyValuePair):

    Move KeyValuePair to its own header and add a makeKeyValuePair helper.

Modified Paths

Added Paths

Removed Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (221913 => 221914)


--- trunk/Source/WTF/ChangeLog	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WTF/ChangeLog	2017-09-12 14:53:18 UTC (rev 221914)
@@ -1,3 +1,19 @@
+2017-09-12  Sam Weinig  <[email protected]>
+
+        [Cleanup] Follow up cleanup for DOMFormData implementation
+        https://bugs.webkit.org/show_bug.cgi?id=176740
+
+        Reviewed by Alex Christensen.
+
+        * WTF.xcodeproj/project.pbxproj:
+        * wtf/HashTraits.h:
+        (WTF::KeyValuePair::KeyValuePair): Deleted.
+        * wtf/KeyValuePair.h: Added.
+        (WTF::KeyValuePair::KeyValuePair):
+        (WTF::makeKeyValuePair):
+
+            Move KeyValuePair to its own header and add a makeKeyValuePair helper.
+
 2017-09-11  Ryan Haddad  <[email protected]>
 
         Unreviewed, rolling out r221854.

Modified: trunk/Source/WTF/WTF.xcodeproj/project.pbxproj (221913 => 221914)


--- trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WTF/WTF.xcodeproj/project.pbxproj	2017-09-12 14:53:18 UTC (rev 221914)
@@ -346,6 +346,7 @@
 		7AFEC6AE1EB22AC600DADE36 /* UUID.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UUID.h; sourceTree = "<group>"; };
 		7AFEC6B01EB22B5900DADE36 /* UUID.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UUID.cpp; sourceTree = "<group>"; };
 		7C3F72391D78811900674E26 /* Brigand.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Brigand.h; sourceTree = "<group>"; };
+		7C9692941F66306E00267A9E /* KeyValuePair.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = KeyValuePair.h; sourceTree = "<group>"; };
 		7CBBA07319BB7FDC00BBF025 /* OSObjectPtr.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSObjectPtr.h; sourceTree = "<group>"; };
 		7CD0D5A71D55322A000CC9E1 /* Variant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Variant.h; sourceTree = "<group>"; };
 		7CD4C26F1E2C82B900929470 /* StringConcatenateNumbers.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StringConcatenateNumbers.h; sourceTree = "<group>"; };
@@ -849,6 +850,7 @@
 				5182C22C1F2BC7E60059BA7C /* InstanceCounted.h */,
 				7CDD7FF7186D291E007433CD /* IteratorAdaptors.h */,
 				7CDD7FF9186D2A54007433CD /* IteratorRange.h */,
+				7C9692941F66306E00267A9E /* KeyValuePair.h */,
 				C2BCFC3E1F61D13000C9222C /* Language.cpp */,
 				C2BCFC3F1F61D13000C9222C /* Language.h */,
 				539EB0621D55284200C82EF7 /* LEBDecoder.h */,

Modified: trunk/Source/WTF/wtf/HashTraits.h (221913 => 221914)


--- trunk/Source/WTF/wtf/HashTraits.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WTF/wtf/HashTraits.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -24,6 +24,7 @@
 #include <limits>
 #include <utility>
 #include <wtf/HashFunctions.h>
+#include <wtf/KeyValuePair.h>
 #include <wtf/Optional.h>
 #include <wtf/StdLibExtras.h>
 
@@ -279,32 +280,6 @@
 template<typename... Traits>
 struct HashTraits<std::tuple<Traits...>> : public TupleHashTraits<HashTraits<Traits>...> { };
 
-template<typename KeyTypeArg, typename ValueTypeArg>
-struct KeyValuePair {
-    typedef KeyTypeArg KeyType;
-
-    KeyValuePair()
-    {
-    }
-
-    template<typename K, typename V>
-    KeyValuePair(K&& key, V&& value)
-        : key(std::forward<K>(key))
-        , value(std::forward<V>(value))
-    {
-    }
-
-    template <typename OtherKeyType, typename OtherValueType>
-    KeyValuePair(KeyValuePair<OtherKeyType, OtherValueType>&& other)
-        : key(std::forward<OtherKeyType>(other.key))
-        , value(std::forward<OtherValueType>(other.value))
-    {
-    }
-
-    KeyTypeArg key;
-    ValueTypeArg value { };
-};
-
 template<typename KeyTraitsArg, typename ValueTraitsArg>
 struct KeyValuePairHashTraits : GenericHashTraits<KeyValuePair<typename KeyTraitsArg::TraitType, typename ValueTraitsArg::TraitType>> {
     typedef KeyTraitsArg KeyTraits;

Added: trunk/Source/WTF/wtf/KeyValuePair.h (0 => 221914)


--- trunk/Source/WTF/wtf/KeyValuePair.h	                        (rev 0)
+++ trunk/Source/WTF/wtf/KeyValuePair.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -0,0 +1,67 @@
+/*
+ * Copyright (C) 2017 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#pragma once
+
+#include <type_traits>
+
+namespace WTF {
+
+template<typename KeyTypeArg, typename ValueTypeArg>
+struct KeyValuePair {
+    using KeyType = KeyTypeArg;
+    using ValueType = ValueTypeArg;
+
+    KeyValuePair()
+    {
+    }
+
+    template<typename K, typename V>
+    KeyValuePair(K&& key, V&& value)
+        : key(std::forward<K>(key))
+        , value(std::forward<V>(value))
+    {
+    }
+
+    template <typename K, typename V>
+    KeyValuePair(KeyValuePair<K, V>&& other)
+        : key(std::forward<K>(other.key))
+        , value(std::forward<V>(other.value))
+    {
+    }
+
+    KeyType key;
+    ValueType value { };
+};
+
+template<typename K, typename V>
+inline KeyValuePair<typename std::decay<K>::type, typename std::decay<V>::type> makeKeyValuePair(K&& key, V&& value)
+{
+    return KeyValuePair<typename std::decay<K>::type, typename std::decay<V>::type> { std::forward<K>(key), std::forward<V>(value) };
+}
+
+}
+
+using WTF::KeyValuePair;

Modified: trunk/Source/WebCore/CMakeLists.txt (221913 => 221914)


--- trunk/Source/WebCore/CMakeLists.txt	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/CMakeLists.txt	2017-09-12 14:53:18 UTC (rev 221914)
@@ -1796,7 +1796,6 @@
     html/FileInputType.cpp
     html/FormAssociatedElement.cpp
     html/FormController.cpp
-    html/FormDataList.cpp
     html/GenericCachedHTMLCollection.cpp
     html/HTMLAllCollection.cpp
     html/HTMLAnchorElement.cpp

Modified: trunk/Source/WebCore/ChangeLog (221913 => 221914)


--- trunk/Source/WebCore/ChangeLog	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/ChangeLog	2017-09-12 14:53:18 UTC (rev 221914)
@@ -1,3 +1,104 @@
+2017-09-12  Sam Weinig  <[email protected]>
+
+        [Cleanup] Follow up cleanup for DOMFormData implementation
+        https://bugs.webkit.org/show_bug.cgi?id=176740
+
+        Reviewed by Alex Christensen.
+
+        - Merges FormDataList into DOMFormData.
+        - Streamline / refactor FormData creation from DOMFormData.
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * html/FormDataList.cpp: Removed.
+        * html/FormDataList.h: Removed.
+
+            Remove FormDataList.
+
+        * html/DOMFormData.cpp:
+        (WebCore::DOMFormData::DOMFormData):
+        (WebCore::DOMFormData::createFileEntry):
+        (WebCore::DOMFormData::append):
+        (WebCore::DOMFormData::set):
+        (WebCore::DOMFormData::Iterator::next):
+        * html/DOMFormData.h:
+        (WebCore::DOMFormData::items const):
+        (WebCore::DOMFormData::encoding const):
+
+            Merge FormDataList into DOMFormData. FormDataList's additional
+            appendData/appendBlob functions have been removed, and their
+            functionality inlined into DOMFormData's append functions. 
+
+            Adopted makeKeyValuePair in DOMFormData::Iterator::next().
+
+        * platform/network/FormData.cpp:
+        (WebCore::FormData::create):
+        (WebCore::FormData::createMultiPart):
+        (WebCore::normalizeStringData):
+        (WebCore::FormData::appendMultiPartFileValue):
+        (WebCore::FormData::appendMultiPartStringValue):
+        (WebCore::FormData::appendMultiPartKeyValuePairItems):
+        (WebCore::FormData::appendNonMultiPartKeyValuePairItems):
+        (WebCore::FormData::appendKeyValuePairItems): Deleted.
+        * platform/network/FormData.h:
+
+            Split-up appendKeyValuePairItems into separate multipart and non-multipart
+            functions, as the two edges of the branch didn't share much in common. Further
+            split out multipart file and multipart string appending, since they too did not
+            share that much in common and makes the code easier to follow. 
+
+            String value normalization has been moved entirely here (previously it was a member 
+            function of FormDataList) as FormData is the only user.
+
+        * xml/XMLHttpRequest.cpp:
+        (WebCore::XMLHttpRequest::send):
+        * loader/FormSubmission.cpp:
+        (WebCore::FormSubmission::create):
+        * Modules/fetch/FetchBody.cpp:
+        (WebCore::FetchBody::extract):
+        
+            Update for new FormData create functions which don't need the
+            encoding passed explicitly, since it is part of the DOMFormData.
+        
+        * html/BaseButtonInputType.cpp:
+        * html/BaseButtonInputType.h:
+        * html/BaseCheckableInputType.cpp:
+        * html/BaseCheckableInputType.h:
+        * html/FileInputType.cpp:
+        * html/FileInputType.h:
+        * html/FormAssociatedElement.h:
+        * html/HTMLButtonElement.cpp:
+        * html/HTMLButtonElement.h:
+        * html/HTMLFormControlElement.h:
+        * html/HTMLInputElement.cpp:
+        * html/HTMLInputElement.h:
+        * html/HTMLKeygenElement.cpp:
+        * html/HTMLKeygenElement.h:
+        * html/HTMLMeterElement.cpp:
+        * html/HTMLObjectElement.cpp:
+        * html/HTMLObjectElement.h:
+        * html/HTMLSelectElement.cpp:
+        * html/HTMLSelectElement.h:
+        * html/HTMLTextAreaElement.cpp:
+        * html/HTMLTextAreaElement.h:
+        * html/HiddenInputType.cpp:
+        * html/HiddenInputType.h:
+        * html/ImageInputType.cpp:
+        * html/ImageInputType.h:
+        * html/InputType.cpp:
+        * html/InputType.h:
+        * html/SubmitInputType.cpp:
+        * html/SubmitInputType.h:
+        * html/TextFieldInputType.cpp:
+        * html/TextFieldInputType.h:
+
+            Update to use DOMFormData directly, rather than the FormDataList, which 
+            has been removed.
+
+        * page/csp/ContentSecurityPolicy.cpp:
+
+            Remove unnecessary #include of unused (and now removed) FormDataList.h
+
 2017-09-12  Zan Dobersek  <[email protected]>
 
         [EME] Implement CDMInstanceClearKey::requestLicense()

Modified: trunk/Source/WebCore/Modules/fetch/FetchBody.cpp (221913 => 221914)


--- trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/Modules/fetch/FetchBody.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -48,7 +48,7 @@
         return FetchBody(WTFMove(blob));
     }, [&](RefPtr<DOMFormData>& value) mutable {
         Ref<DOMFormData> domFormData = value.releaseNonNull();
-        auto formData = FormData::createMultiPart(domFormData.get(), domFormData->encoding(), &static_cast<Document&>(context));
+        auto formData = FormData::createMultiPart(domFormData.get(), &static_cast<Document&>(context));
         contentType = makeString("multipart/form-data; boundary=", formData->boundary().data());
         return FetchBody(WTFMove(formData));
     }, [&](RefPtr<URLSearchParams>& value) mutable {

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (221913 => 221914)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2017-09-12 14:53:18 UTC (rev 221914)
@@ -4755,8 +4755,6 @@
 		A81369E3097374F600D74463 /* HTMLLabelElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A81369C7097374F500D74463 /* HTMLLabelElement.cpp */; };
 		A81369E4097374F600D74463 /* HTMLKeygenElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A81369C8097374F500D74463 /* HTMLKeygenElement.h */; };
 		A81369E5097374F600D74463 /* HTMLKeygenElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A81369C9097374F600D74463 /* HTMLKeygenElement.cpp */; };
-		A8136D380973A8E700D74463 /* FormDataList.h in Headers */ = {isa = PBXBuildFile; fileRef = A8136D360973A8E700D74463 /* FormDataList.h */; };
-		A8136D390973A8E700D74463 /* FormDataList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8136D370973A8E700D74463 /* FormDataList.cpp */; };
 		A8185F3909765766005826D9 /* DocumentType.h in Headers */ = {isa = PBXBuildFile; fileRef = A8185F3109765765005826D9 /* DocumentType.h */; settings = {ATTRIBUTES = (Private, ); }; };
 		A8185F3A09765766005826D9 /* DocumentType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A8185F3209765765005826D9 /* DocumentType.cpp */; };
 		A8185F3B09765766005826D9 /* DOMImplementation.h in Headers */ = {isa = PBXBuildFile; fileRef = A8185F3309765765005826D9 /* DOMImplementation.h */; settings = {ATTRIBUTES = (Private, ); }; };
@@ -13214,8 +13212,6 @@
 		A81369C7097374F500D74463 /* HTMLLabelElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLLabelElement.cpp; sourceTree = "<group>"; };
 		A81369C8097374F500D74463 /* HTMLKeygenElement.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = HTMLKeygenElement.h; sourceTree = "<group>"; };
 		A81369C9097374F600D74463 /* HTMLKeygenElement.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLKeygenElement.cpp; sourceTree = "<group>"; };
-		A8136D360973A8E700D74463 /* FormDataList.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = FormDataList.h; sourceTree = "<group>"; };
-		A8136D370973A8E700D74463 /* FormDataList.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = FormDataList.cpp; sourceTree = "<group>"; };
 		A8185F3109765765005826D9 /* DocumentType.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DocumentType.h; sourceTree = "<group>"; };
 		A8185F3209765765005826D9 /* DocumentType.cpp */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentType.cpp; sourceTree = "<group>"; };
 		A8185F3309765765005826D9 /* DOMImplementation.h */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.c.h; path = DOMImplementation.h; sourceTree = "<group>"; };
@@ -20591,8 +20587,6 @@
 				4A0DA2FD129B241900AB61E1 /* FormAssociatedElement.h */,
 				F50664F5157F52DC00AC226F /* FormController.cpp */,
 				F50664F6157F52DC00AC226F /* FormController.h */,
-				A8136D370973A8E700D74463 /* FormDataList.cpp */,
-				A8136D360973A8E700D74463 /* FormDataList.h */,
 				9B50B1DC17CD4C0F0087F63C /* FormNamedItem.h */,
 				97205AAD123928CA00B17380 /* FTPDirectoryDocument.cpp */,
 				97205AAE123928CA00B17380 /* FTPDirectoryDocument.h */,
@@ -27788,7 +27782,6 @@
 				F50664F8157F52DC00AC226F /* FormController.h in Headers */,
 				514C76700CE923A1007EF3CD /* FormData.h in Headers */,
 				085B92BB0EFDE73D00E6123C /* FormDataBuilder.h in Headers */,
-				A8136D380973A8E700D74463 /* FormDataList.h in Headers */,
 				7EE6846712D26E3800E79415 /* FormDataStreamCFNet.h in Headers */,
 				514C764E0CE9234E007EF3CD /* FormDataStreamMac.h in Headers */,
 				9B50B1DE17CD4C0F0087F63C /* FormNamedItem.h in Headers */,
@@ -31828,7 +31821,6 @@
 				F50664F7157F52DC00AC226F /* FormController.cpp in Sources */,
 				514C766F0CE923A1007EF3CD /* FormData.cpp in Sources */,
 				085B92BA0EFDE73D00E6123C /* FormDataBuilder.cpp in Sources */,
-				A8136D390973A8E700D74463 /* FormDataList.cpp in Sources */,
 				7EE6846612D26E3800E79415 /* FormDataStreamCFNet.cpp in Sources */,
 				514C764F0CE9234E007EF3CD /* FormDataStreamMac.mm in Sources */,
 				656D373B0ADBA5DE00A4554D /* FormState.cpp in Sources */,

Modified: trunk/Source/WebCore/html/BaseButtonInputType.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/BaseButtonInputType.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/BaseButtonInputType.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -45,7 +45,7 @@
     return false;
 }
 
-bool BaseButtonInputType::appendFormData(FormDataList&, bool) const
+bool BaseButtonInputType::appendFormData(DOMFormData&, bool) const
 {
     // Buttons except overridden types are never successful.
     return false;

Modified: trunk/Source/WebCore/html/BaseButtonInputType.h (221913 => 221914)


--- trunk/Source/WebCore/html/BaseButtonInputType.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/BaseButtonInputType.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -41,7 +41,7 @@
 
 private:
     bool shouldSaveAndRestoreFormControlState() const override;
-    bool appendFormData(FormDataList&, bool) const override;
+    bool appendFormData(DOMFormData&, bool) const override;
     RenderPtr<RenderElement> createInputRenderer(RenderStyle&&) override;
     bool storesValueSeparateFromAttribute() override;
     void setValue(const String&, bool, TextFieldEventBehavior) override;

Modified: trunk/Source/WebCore/html/BaseCheckableInputType.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/BaseCheckableInputType.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/BaseCheckableInputType.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -32,8 +32,8 @@
 #include "config.h"
 #include "BaseCheckableInputType.h"
 
+#include "DOMFormData.h"
 #include "FormController.h"
-#include "FormDataList.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "KeyboardEvent.h"
@@ -53,11 +53,11 @@
     element().setChecked(state[0] == "on");
 }
 
-bool BaseCheckableInputType::appendFormData(FormDataList& encoding, bool) const
+bool BaseCheckableInputType::appendFormData(DOMFormData& formData, bool) const
 {
     if (!element().checked())
         return false;
-    encoding.appendData(element().name(), element().value());
+    formData.append(element().name(), element().value());
     return true;
 }
 

Modified: trunk/Source/WebCore/html/BaseCheckableInputType.h (221913 => 221914)


--- trunk/Source/WebCore/html/BaseCheckableInputType.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/BaseCheckableInputType.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -43,7 +43,7 @@
 private:
     FormControlState saveFormControlState() const override;
     void restoreFormControlState(const FormControlState&) override;
-    bool appendFormData(FormDataList&, bool) const override;
+    bool appendFormData(DOMFormData&, bool) const override;
     void handleKeypressEvent(KeyboardEvent&) override;
     bool canSetStringValue() const override;
     void accessKeyAction(bool sendMouseEvents) override;

Modified: trunk/Source/WebCore/html/DOMFormData.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/DOMFormData.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/DOMFormData.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -37,12 +37,12 @@
 namespace WebCore {
 
 DOMFormData::DOMFormData(const TextEncoding& encoding)
-    : FormDataList(encoding)
+    : m_encoding(encoding)
 {
 }
 
 DOMFormData::DOMFormData(HTMLFormElement* form)
-    : FormDataList(UTF8Encoding())
+    : m_encoding(UTF8Encoding())
 {
     if (!form)
         return;
@@ -53,14 +53,26 @@
     }
 }
 
+// https://xhr.spec.whatwg.org/#create-an-entry
+auto DOMFormData::createFileEntry(const String& name, Blob& blob, const String& filename) -> Item
+{
+    if (!blob.isFile())
+        return { name, File::create(blob, filename.isNull() ? ASCIILiteral("blob") : filename) };
+    
+    if (!filename.isNull())
+        return { name, File::create(downcast<File>(blob), filename) };
+
+    return { name, RefPtr<File> { &downcast<File>(blob) } };
+}
+
 void DOMFormData::append(const String& name, const String& value)
 {
-    appendData(name, value);
+    m_items.append({ name, value });
 }
 
 void DOMFormData::append(const String& name, Blob& blob, const String& filename)
 {
-    appendBlob(name, blob, filename);
+    m_items.append(createFileEntry(name, blob, filename));
 }
 
 void DOMFormData::remove(const String& name)
@@ -104,20 +116,44 @@
 
 void DOMFormData::set(const String& name, const String& value)
 {
-    setData(name, value);
+    set(name, { name, value });
 }
 
 void DOMFormData::set(const String& name, Blob& blob, const String& filename)
 {
-    setBlob(name, blob, filename);
+    set(name, createFileEntry(name, blob, filename));
 }
 
+void DOMFormData::set(const String& name, Item&& item)
+{
+    std::optional<size_t> initialMatchLocation;
+
+    // Find location of the first item with a matching name.
+    for (size_t i = 0; i < m_items.size(); ++i) {
+        if (name == m_items[i].name) {
+            initialMatchLocation = i;
+            break;
+        }
+    }
+
+    if (initialMatchLocation) {
+        m_items[*initialMatchLocation] = WTFMove(item);
+
+        m_items.removeAllMatching([&name] (const auto& item) {
+            return item.name == name;
+        }, *initialMatchLocation + 1);
+        return;
+    }
+
+    m_items.append(WTFMove(item));
+}
+
 DOMFormData::Iterator::Iterator(DOMFormData& target)
     : m_target(target)
 {
 }
 
-std::optional<WTF::KeyValuePair<String, DOMFormData::FormDataEntryValue>> DOMFormData::Iterator::next()
+std::optional<KeyValuePair<String, DOMFormData::FormDataEntryValue>> DOMFormData::Iterator::next()
 {
     auto& items = m_target->items();
     if (m_index >= items.size())
@@ -124,7 +160,7 @@
         return std::nullopt;
 
     auto& item = items[m_index++];
-    return WTF::KeyValuePair<String, FormDataEntryValue> { item.name, item.data };
+    return makeKeyValuePair(item.name, item.data);
 }
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/DOMFormData.h (221913 => 221914)


--- trunk/Source/WebCore/html/DOMFormData.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/DOMFormData.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -30,24 +30,32 @@
 
 #pragma once
 
-#include "FormDataList.h"
+#include "File.h"
+#include "TextEncoding.h"
 #include <wtf/Forward.h>
 #include <wtf/Optional.h>
 #include <wtf/RefCounted.h>
+#include <wtf/Variant.h>
+#include <wtf/text/WTFString.h>
 
 namespace WebCore {
 
-class Blob;
 class HTMLFormElement;
-class TextEncoding;
 
-// FIXME: Do we need to have separate DOMFormData and FormDataList classes?
-class DOMFormData : public FormDataList, public RefCounted<DOMFormData> {
+class DOMFormData : public RefCounted<DOMFormData> {
 public:
+    using FormDataEntryValue = Variant<RefPtr<File>, String>;
+
+    struct Item {
+        String name;
+        FormDataEntryValue data;
+    };
+
     static Ref<DOMFormData> create(HTMLFormElement* form) { return adoptRef(*new DOMFormData(form)); }
     static Ref<DOMFormData> create(const TextEncoding& encoding) { return adoptRef(*new DOMFormData(encoding)); }
 
-    using FormDataEntryValue = Item::Data;
+    const Vector<Item>& items() const { return m_items; }
+    const TextEncoding& encoding() const { return m_encoding; }
 
     void append(const String& name, const String& value);
     void append(const String& name, Blob&, const String& filename = { });
@@ -61,7 +69,7 @@
     class Iterator {
     public:
         explicit Iterator(DOMFormData&);
-        std::optional<WTF::KeyValuePair<String, FormDataEntryValue>> next();
+        std::optional<KeyValuePair<String, FormDataEntryValue>> next();
 
     private:
         Ref<DOMFormData> m_target;
@@ -72,6 +80,12 @@
 private:
     explicit DOMFormData(const TextEncoding&);
     explicit DOMFormData(HTMLFormElement*);
+
+    Item createFileEntry(const String& name, Blob&, const String& filename);
+    void set(const String& name, Item&&);
+
+    TextEncoding m_encoding;
+    Vector<Item> m_items;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/FileInputType.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/FileInputType.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/FileInputType.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -23,6 +23,7 @@
 #include "FileInputType.h"
 
 #include "Chrome.h"
+#include "DOMFormData.h"
 #include "DragData.h"
 #include "ElementChildIterator.h"
 #include "Event.h"
@@ -31,7 +32,6 @@
 #include "FileListCreator.h"
 #include "FileSystem.h"
 #include "FormController.h"
-#include "FormDataList.h"
 #include "Frame.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
@@ -73,7 +73,7 @@
 
 Ref<UploadButtonElement> UploadButtonElement::create(Document& document)
 {
-    Ref<UploadButtonElement> button = adoptRef(*new UploadButtonElement(document));
+    auto button = adoptRef(*new UploadButtonElement(document));
     button->setValue(fileButtonChooseFileLabel());
     return button;
 }
@@ -80,7 +80,7 @@
 
 Ref<UploadButtonElement> UploadButtonElement::createForMultiple(Document& document)
 {
-    Ref<UploadButtonElement> button = adoptRef(*new UploadButtonElement(document));
+    auto button = adoptRef(*new UploadButtonElement(document));
     button->setValue(fileButtonChooseMultipleFilesLabel());
     return button;
 }
@@ -147,9 +147,11 @@
     filesChosen(filesFromFormControlState(state));
 }
 
-bool FileInputType::appendFormData(FormDataList& encoding, bool multipart) const
+bool FileInputType::appendFormData(DOMFormData& formData, bool multipart) const
 {
-    FileList* fileList = element().files();
+    auto name = element().name();
+
+    auto* fileList = element().files();
     unsigned numFiles = fileList->length();
     if (!multipart) {
         // Send only the basenames.
@@ -160,7 +162,7 @@
         // submission of file inputs, and Firefox doesn't add "name=" query
         // parameter.
         for (unsigned i = 0; i < numFiles; ++i)
-            encoding.appendData(element().name(), fileList->item(i)->name());
+            formData.append(name, fileList->item(i)->name());
         return true;
     }
 
@@ -167,12 +169,12 @@
     // If no filename at all is entered, return successful but empty.
     // Null would be more logical, but Netscape posts an empty file. Argh.
     if (!numFiles) {
-        encoding.appendBlob(element().name(), File::create(emptyString()));
+        formData.append(name, File::create(emptyString()));
         return true;
     }
 
     for (unsigned i = 0; i < numFiles; ++i)
-        encoding.appendBlob(element().name(), *fileList->item(i));
+        formData.append(name, *fileList->item(i));
     return true;
 }
 

Modified: trunk/Source/WebCore/html/FileInputType.h (221913 => 221914)


--- trunk/Source/WebCore/html/FileInputType.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/FileInputType.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -54,7 +54,7 @@
     const AtomicString& formControlType() const final;
     FormControlState saveFormControlState() const final;
     void restoreFormControlState(const FormControlState&) final;
-    bool appendFormData(FormDataList&, bool) const final;
+    bool appendFormData(DOMFormData&, bool) const final;
     bool valueMissing(const String&) const final;
     String valueMissingText() const final;
     void handleDOMActivateEvent(Event&) final;

Modified: trunk/Source/WebCore/html/FormAssociatedElement.h (221913 => 221914)


--- trunk/Source/WebCore/html/FormAssociatedElement.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/FormAssociatedElement.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -29,9 +29,9 @@
 namespace WebCore {
 
 class ContainerNode;
+class DOMFormData;
 class Document;
 class FormAttributeTargetObserver;
-class FormDataList;
 class HTMLElement;
 class HTMLFormElement;
 class Node;
@@ -59,7 +59,7 @@
 
     // Override in derived classes to get the encoded name=value pair for submitting.
     // Return true for a successful control (see HTML4-17.13.2).
-    virtual bool appendFormData(FormDataList&, bool) { return false; }
+    virtual bool appendFormData(DOMFormData&, bool) { return false; }
 
     void formWillBeDestroyed();
 

Deleted: trunk/Source/WebCore/html/FormDataList.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/FormDataList.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/FormDataList.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -1,100 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2008 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.
- *
- */
-
-#include "config.h"
-#include "FormDataList.h"
-
-#include "LineEnding.h"
-#include <wtf/text/CString.h>
-
-namespace WebCore {
-
-FormDataList::FormDataList(const TextEncoding& encoding)
-    : m_encoding(encoding)
-{
-}
-
-CString FormDataList::normalizeString(const String& value) const
-{
-    return normalizeLineEndingsToCRLF(m_encoding.encode(value, EntitiesForUnencodables));
-}
-
-// https://xhr.spec.whatwg.org/#create-an-entry
-auto FormDataList::createFileEntry(const String& name, Ref<Blob>&& blob, const String& filename) -> Item
-{
-    if (!blob->isFile())
-        return { name, File::create(blob.get(), filename.isNull() ? ASCIILiteral("blob") : filename) };
-    
-    if (!filename.isNull())
-        return { name, File::create(downcast<File>(blob.get()), filename) };
-
-    return { name, static_reference_cast<File>(WTFMove(blob)) };
-}
-
-void FormDataList::appendData(const String& name, const String& value)
-{
-    m_items.append({ name, value });
-}
-
-void FormDataList::appendData(const String& name, int value)
-{
-    m_items.append({ name, String::number(value) });
-}
-
-void FormDataList::appendBlob(const String& name, Ref<Blob>&& blob, const String& filename)
-{
-    m_items.append(createFileEntry(name, WTFMove(blob), filename));
-}
-
-void FormDataList::set(const String& name, Item&& item)
-{
-    std::optional<size_t> initialMatchLocation;
-
-    // Find location of the first item with a matching name.
-    for (size_t i = 0; i < m_items.size(); ++i) {
-        if (name == m_items[i].name) {
-            initialMatchLocation = i;
-            break;
-        }
-    }
-
-    if (initialMatchLocation) {
-        m_items[*initialMatchLocation] = WTFMove(item);
-
-        m_items.removeAllMatching([&name] (const auto& item) {
-            return item.name == name;
-        }, *initialMatchLocation + 1);
-        return;
-    }
-
-    m_items.append(WTFMove(item));
-}
-
-void FormDataList::setData(const String& name, const String& value)
-{
-    set(name, { name, value });
-}
-
-void FormDataList::setBlob(const String& name, Ref<Blob>&& blob, const String& filename)
-{
-    set(name, createFileEntry(name, WTFMove(blob), filename));
-}
-
-}

Deleted: trunk/Source/WebCore/html/FormDataList.h (221913 => 221914)


--- trunk/Source/WebCore/html/FormDataList.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/FormDataList.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -1,60 +0,0 @@
-/*
- * Copyright (C) 2005, 2006, 2008 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.
- *
- */
-
-#pragma once
-
-#include "File.h"
-#include "TextEncoding.h"
-#include <wtf/Forward.h>
-#include <wtf/Variant.h>
-
-namespace WebCore {
-
-class FormDataList {
-public:
-    struct Item {
-        using Data = "" String>;
-
-        String name;
-        Data data;
-    };
-
-    void appendData(const String& name, const String& value);
-    void appendData(const String& name, int value);
-    void appendBlob(const String& name, Ref<Blob>&&, const String& filename = { });
-    void setData(const String& name, const String& value);
-    void setBlob(const String& name, Ref<Blob>&&, const String& filename = { });
-
-    const Vector<Item>& items() const { return m_items; }
-    const TextEncoding& encoding() const { return m_encoding; }
-
-    CString normalizeString(const String&) const;
-
-protected:
-    FormDataList(const TextEncoding&);
-
-    Item createFileEntry(const String& name, Ref<Blob>&&, const String& filename);
-    void set(const String& name, Item&&);
-
-    TextEncoding m_encoding;
-    Vector<Item> m_items;
-};
-
-} // namespace WebCore

Modified: trunk/Source/WebCore/html/HTMLButtonElement.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLButtonElement.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLButtonElement.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -26,8 +26,8 @@
 #include "config.h"
 #include "HTMLButtonElement.h"
 
+#include "DOMFormData.h"
 #include "EventNames.h"
-#include "FormDataList.h"
 #include "HTMLFormElement.h"
 #include "HTMLNames.h"
 #include "KeyboardEvent.h"
@@ -184,11 +184,11 @@
     m_isActivatedSubmit = flag;
 }
 
-bool HTMLButtonElement::appendFormData(FormDataList& formData, bool)
+bool HTMLButtonElement::appendFormData(DOMFormData& formData, bool)
 {
     if (m_type != SUBMIT || name().isEmpty() || !m_isActivatedSubmit)
         return false;
-    formData.appendData(name(), value());
+    formData.append(name(), value());
     return true;
 }
 

Modified: trunk/Source/WebCore/html/HTMLButtonElement.h (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLButtonElement.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLButtonElement.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -57,7 +57,7 @@
     bool isPresentationAttribute(const QualifiedName&) const final;
     void defaultEventHandler(Event&) final;
 
-    bool appendFormData(FormDataList&, bool) final;
+    bool appendFormData(DOMFormData&, bool) final;
 
     bool isEnumeratable() const final { return true; }
     bool supportLabels() const final { return true; }

Modified: trunk/Source/WebCore/html/HTMLFormControlElement.h (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLFormControlElement.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLFormControlElement.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -33,7 +33,7 @@
 
 namespace WebCore {
 
-class FormDataList;
+class DOMFormData;
 class HTMLFieldSetElement;
 class HTMLFormElement;
 class HTMLLegendElement;
@@ -85,7 +85,7 @@
 
     // Override in derived classes to get the encoded name=value pair for submitting.
     // Return true for a successful control (see HTML4-17.13.2).
-    bool appendFormData(FormDataList&, bool) override { return false; }
+    bool appendFormData(DOMFormData&, bool) override { return false; }
 
     virtual bool isSuccessfulSubmitButton() const { return false; }
     virtual bool isActivatedSubmit() const { return false; }

Modified: trunk/Source/WebCore/html/HTMLInputElement.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLInputElement.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLInputElement.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -871,9 +871,9 @@
     m_isActivatedSubmit = flag;
 }
 
-bool HTMLInputElement::appendFormData(FormDataList& encoding, bool multipart)
+bool HTMLInputElement::appendFormData(DOMFormData& formData, bool multipart)
 {
-    return m_inputType->isFormDataAppendable() && m_inputType->appendFormData(encoding, multipart);
+    return m_inputType->isFormDataAppendable() && m_inputType->appendFormData(formData, multipart);
 }
 
 void HTMLInputElement::reset()

Modified: trunk/Source/WebCore/html/HTMLInputElement.h (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLInputElement.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLInputElement.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -380,7 +380,7 @@
 
     void copyNonAttributePropertiesFromElement(const Element&) final;
 
-    bool appendFormData(FormDataList&, bool) final;
+    bool appendFormData(DOMFormData&, bool) final;
 
     bool isSuccessfulSubmitButton() const final;
     bool matchesDefaultPseudoClass() const final;

Modified: trunk/Source/WebCore/html/HTMLKeygenElement.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLKeygenElement.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLKeygenElement.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -26,9 +26,9 @@
 #include "HTMLKeygenElement.h"
 
 #include "Attribute.h"
+#include "DOMFormData.h"
 #include "Document.h"
 #include "ElementChildIterator.h"
-#include "FormDataList.h"
 #include "HTMLNames.h"
 #include "HTMLSelectElement.h"
 #include "HTMLOptionElement.h"
@@ -115,15 +115,15 @@
     return isKeytypeRSA() ? ASCIILiteral("rsa") : emptyString();
 }
 
-bool HTMLKeygenElement::appendFormData(FormDataList& encoded_values, bool)
+bool HTMLKeygenElement::appendFormData(DOMFormData& formData, bool)
 {
     // Only RSA is supported at this time.
     if (!isKeytypeRSA())
         return false;
-    String value = signedPublicKeyAndChallengeString(shadowSelect()->selectedIndex(), attributeWithoutSynchronization(challengeAttr), document().baseURL());
+    auto value = signedPublicKeyAndChallengeString(shadowSelect()->selectedIndex(), attributeWithoutSynchronization(challengeAttr), document().baseURL());
     if (value.isNull())
         return false;
-    encoded_values.appendData(name(), value);
+    formData.append(name(), value);
     return true;
 }
 

Modified: trunk/Source/WebCore/html/HTMLKeygenElement.h (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLKeygenElement.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLKeygenElement.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -44,7 +44,7 @@
 
     void parseAttribute(const QualifiedName&, const AtomicString&) final;
 
-    bool appendFormData(FormDataList&, bool) final;
+    bool appendFormData(DOMFormData&, bool) final;
     const AtomicString& formControlType() const final;
     bool isOptionalFormControl() const final { return false; }
 

Modified: trunk/Source/WebCore/html/HTMLMeterElement.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLMeterElement.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLMeterElement.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -25,7 +25,6 @@
 
 #include "Attribute.h"
 #include "ElementIterator.h"
-#include "FormDataList.h"
 #include "HTMLDivElement.h"
 #include "HTMLFormElement.h"
 #include "HTMLNames.h"

Modified: trunk/Source/WebCore/html/HTMLObjectElement.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLObjectElement.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLObjectElement.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -27,8 +27,8 @@
 #include "Attribute.h"
 #include "CSSValueKeywords.h"
 #include "CachedImage.h"
+#include "DOMFormData.h"
 #include "ElementIterator.h"
-#include "FormDataList.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "HTMLDocument.h"
@@ -491,7 +491,7 @@
     HTMLPlugInImageElement::didMoveToNewDocument(oldDocument, newDocument);
 }
 
-bool HTMLObjectElement::appendFormData(FormDataList& encoding, bool)
+bool HTMLObjectElement::appendFormData(DOMFormData& formData, bool)
 {
     if (name().isEmpty())
         return false;
@@ -504,7 +504,7 @@
     String value;
     if (!downcast<PluginViewBase>(*widget).getFormValue(value))
         return false;
-    encoding.appendData(name(), value);
+    formData.append(name(), value);
     return true;
 }
 

Modified: trunk/Source/WebCore/html/HTMLObjectElement.h (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLObjectElement.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLObjectElement.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -97,7 +97,7 @@
     bool isFormControlElement() const final { return false; }
 
     bool isEnumeratable() const final { return true; }
-    bool appendFormData(FormDataList&, bool) final;
+    bool appendFormData(DOMFormData&, bool) final;
 
     bool canContainRangeEndPoint() const final;
 

Modified: trunk/Source/WebCore/html/HTMLSelectElement.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLSelectElement.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLSelectElement.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -29,11 +29,11 @@
 #include "HTMLSelectElement.h"
 
 #include "AXObjectCache.h"
+#include "DOMFormData.h"
 #include "ElementTraversal.h"
 #include "EventHandler.h"
 #include "EventNames.h"
 #include "FormController.h"
-#include "FormDataList.h"
 #include "Frame.h"
 #include "GenericCachedHTMLCollection.h"
 #include "HTMLFormElement.h"
@@ -1031,7 +1031,7 @@
         invalidateStyleAndRenderersForSubtree();
 }
 
-bool HTMLSelectElement::appendFormData(FormDataList& list, bool)
+bool HTMLSelectElement::appendFormData(DOMFormData& formData, bool)
 {
     const AtomicString& name = this->name();
     if (name.isEmpty())
@@ -1040,7 +1040,7 @@
     bool successful = false;
     for (auto& element : listItems()) {
         if (is<HTMLOptionElement>(*element) && downcast<HTMLOptionElement>(*element).selected() && !downcast<HTMLOptionElement>(*element).isDisabledFormControl()) {
-            list.appendData(name, downcast<HTMLOptionElement>(*element).value());
+            formData.append(name, downcast<HTMLOptionElement>(*element).value());
             successful = true;
         }
     }

Modified: trunk/Source/WebCore/html/HTMLSelectElement.h (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLSelectElement.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLSelectElement.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -130,7 +130,7 @@
 
     bool childShouldCreateRenderer(const Node&) const final;
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
-    bool appendFormData(FormDataList&, bool) final;
+    bool appendFormData(DOMFormData&, bool) final;
 
     void reset() final;
 

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -28,6 +28,7 @@
 
 #include "BeforeTextInsertedEvent.h"
 #include "CSSValueKeywords.h"
+#include "DOMFormData.h"
 #include "Document.h"
 #include "Editor.h"
 #include "ElementChildIterator.h"
@@ -34,7 +35,6 @@
 #include "Event.h"
 #include "EventNames.h"
 #include "FormController.h"
-#include "FormDataList.h"
 #include "Frame.h"
 #include "FrameSelection.h"
 #include "HTMLNames.h"
@@ -217,7 +217,7 @@
     return createRenderer<RenderTextControlMultiLine>(*this, WTFMove(style));
 }
 
-bool HTMLTextAreaElement::appendFormData(FormDataList& encoding, bool)
+bool HTMLTextAreaElement::appendFormData(DOMFormData& formData, bool)
 {
     if (name().isEmpty())
         return false;
@@ -224,12 +224,12 @@
 
     document().updateLayout();
 
-    const String& text = (m_wrap == HardWrap) ? valueWithHardLineBreaks() : value();
-    encoding.appendData(name(), text);
+    formData.append(name(), m_wrap == HardWrap ? valueWithHardLineBreaks() : value());
 
-    const AtomicString& dirnameAttrValue = attributeWithoutSynchronization(dirnameAttr);
+    auto& dirnameAttrValue = attributeWithoutSynchronization(dirnameAttr);
     if (!dirnameAttrValue.isNull())
-        encoding.appendData(dirnameAttrValue, directionForFormData());
+        formData.append(dirnameAttrValue, directionForFormData());
+
     return true;    
 }
 

Modified: trunk/Source/WebCore/html/HTMLTextAreaElement.h (221913 => 221914)


--- trunk/Source/WebCore/html/HTMLTextAreaElement.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HTMLTextAreaElement.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -109,7 +109,7 @@
     bool isPresentationAttribute(const QualifiedName&) const final;
     void collectStyleForPresentationAttribute(const QualifiedName&, const AtomicString&, MutableStyleProperties&) final;
     RenderPtr<RenderElement> createElementRenderer(RenderStyle&&, const RenderTreePosition&) final;
-    bool appendFormData(FormDataList&, bool) final;
+    bool appendFormData(DOMFormData&, bool) final;
     void reset() final;
     bool hasCustomFocusLogic() const final;
     bool isMouseFocusable() const final;

Modified: trunk/Source/WebCore/html/HiddenInputType.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/HiddenInputType.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HiddenInputType.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -32,8 +32,8 @@
 #include "config.h"
 #include "HiddenInputType.h"
 
+#include "DOMFormData.h"
 #include "FormController.h"
-#include "FormDataList.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
 #include "InputTypeNames.h"
@@ -97,13 +97,15 @@
     return true;
 }
 
-bool HiddenInputType::appendFormData(FormDataList& encoding, bool isMultipartForm) const
+bool HiddenInputType::appendFormData(DOMFormData& formData, bool isMultipartForm) const
 {
-    if (equalIgnoringASCIICase(element().name(), "_charset_")) {
-        encoding.appendData(element().name(), String(encoding.encoding().name()));
+    auto name = element().name();
+
+    if (equalIgnoringASCIICase(name, "_charset_")) {
+        formData.append(name, String { formData.encoding().name() });
         return true;
     }
-    return InputType::appendFormData(encoding, isMultipartForm);
+    return InputType::appendFormData(formData, isMultipartForm);
 }
 
 bool HiddenInputType::shouldRespectHeightAndWidthAttributes()

Modified: trunk/Source/WebCore/html/HiddenInputType.h (221913 => 221914)


--- trunk/Source/WebCore/html/HiddenInputType.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/HiddenInputType.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -51,7 +51,7 @@
     bool supportLabels() const override { return false; }
     bool shouldRespectHeightAndWidthAttributes() override;
     void setValue(const String&, bool, TextFieldEventBehavior) override;
-    bool appendFormData(FormDataList&, bool) const override;
+    bool appendFormData(DOMFormData&, bool) const override;
 };
 
 } // namespace WebCore

Modified: trunk/Source/WebCore/html/ImageInputType.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/ImageInputType.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/ImageInputType.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -24,7 +24,7 @@
 #include "ImageInputType.h"
 
 #include "CachedImage.h"
-#include "FormDataList.h"
+#include "DOMFormData.h"
 #include "HTMLFormElement.h"
 #include "HTMLImageLoader.h"
 #include "HTMLInputElement.h"
@@ -54,24 +54,25 @@
     return true;
 }
 
-bool ImageInputType::appendFormData(FormDataList& encoding, bool) const
+bool ImageInputType::appendFormData(DOMFormData& formData, bool) const
 {
     if (!element().isActivatedSubmit())
         return false;
-    const AtomicString& name = element().name();
+
+    auto& name = element().name();
     if (name.isEmpty()) {
-        encoding.appendData("x", m_clickLocation.x());
-        encoding.appendData("y", m_clickLocation.y());
+        formData.append(ASCIILiteral("x"), String::number(m_clickLocation.x()));
+        formData.append(ASCIILiteral("y"), String::number(m_clickLocation.y()));
         return true;
     }
 
-    static NeverDestroyed<String> dotXString(MAKE_STATIC_STRING_IMPL(".x"));
-    static NeverDestroyed<String> dotYString(MAKE_STATIC_STRING_IMPL(".y"));
-    encoding.appendData(name + dotXString.get(), m_clickLocation.x());
-    encoding.appendData(name + dotYString.get(), m_clickLocation.y());
+    formData.append(makeString(name, ".x"), String::number(m_clickLocation.x()));
+    formData.append(makeString(name, ".y"), String::number(m_clickLocation.y()));
 
-    if (!element().value().isEmpty())
-        encoding.appendData(name, element().value());
+    auto value = element().value();
+    if (!value.isEmpty())
+        formData.append(name, value);
+
     return true;
 }
 

Modified: trunk/Source/WebCore/html/ImageInputType.h (221913 => 221914)


--- trunk/Source/WebCore/html/ImageInputType.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/ImageInputType.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -44,7 +44,7 @@
 private:
     const AtomicString& formControlType() const override;
     bool isFormDataAppendable() const override;
-    bool appendFormData(FormDataList&, bool) const override;
+    bool appendFormData(DOMFormData&, bool) const override;
     bool supportsValidation() const override;
     RenderPtr<RenderElement> createInputRenderer(RenderStyle&&) override;
     void handleDOMActivateEvent(Event&) override;

Modified: trunk/Source/WebCore/html/InputType.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/InputType.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/InputType.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -33,6 +33,7 @@
 #include "ButtonInputType.h"
 #include "CheckboxInputType.h"
 #include "ColorInputType.h"
+#include "DOMFormData.h"
 #include "DateComponents.h"
 #include "DateInputType.h"
 #include "DateTimeInputType.h"
@@ -42,7 +43,6 @@
 #include "FileInputType.h"
 #include "FileList.h"
 #include "FormController.h"
-#include "FormDataList.h"
 #include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
 #include "HTMLNames.h"
@@ -211,10 +211,10 @@
     return !element().name().isEmpty();
 }
 
-bool InputType::appendFormData(FormDataList& encoding, bool) const
+bool InputType::appendFormData(DOMFormData& formData, bool) const
 {
     // Always successful.
-    encoding.appendData(element().name(), element().value());
+    formData.append(element().name(), element().value());
     return true;
 }
 

Modified: trunk/Source/WebCore/html/InputType.h (221913 => 221914)


--- trunk/Source/WebCore/html/InputType.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/InputType.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -47,11 +47,11 @@
 
 class BeforeTextInsertedEvent;
 class Chrome;
+class DOMFormData;
 class DateComponents;
 class DragData;
 class Event;
 class FileList;
-class FormDataList;
 class HTMLElement;
 class HTMLFormElement;
 class HTMLInputElement;
@@ -60,8 +60,8 @@
 class MouseEvent;
 class Node;
 class RenderStyle;
+class TextControlInnerTextElement;
 class TouchEvent;
-class TextControlInnerTextElement;
 
 struct InputElementClickState;
 
@@ -120,7 +120,7 @@
     virtual FormControlState saveFormControlState() const;
     virtual void restoreFormControlState(const FormControlState&);
     virtual bool isFormDataAppendable() const;
-    virtual bool appendFormData(FormDataList&, bool multipart) const;
+    virtual bool appendFormData(DOMFormData&, bool multipart) const;
 
     // DOM property functions.
 

Modified: trunk/Source/WebCore/html/SubmitInputType.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/SubmitInputType.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/SubmitInputType.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -32,8 +32,8 @@
 #include "config.h"
 #include "SubmitInputType.h"
 
+#include "DOMFormData.h"
 #include "Event.h"
-#include "FormDataList.h"
 #include "HTMLFormElement.h"
 #include "HTMLInputElement.h"
 #include "InputTypeNames.h"
@@ -46,11 +46,11 @@
     return InputTypeNames::submit();
 }
 
-bool SubmitInputType::appendFormData(FormDataList& encoding, bool) const
+bool SubmitInputType::appendFormData(DOMFormData& formData, bool) const
 {
     if (!element().isActivatedSubmit())
         return false;
-    encoding.appendData(element().name(), element().valueWithDefault());
+    formData.append(element().name(), element().valueWithDefault());
     return true;
 }
 

Modified: trunk/Source/WebCore/html/SubmitInputType.h (221913 => 221914)


--- trunk/Source/WebCore/html/SubmitInputType.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/SubmitInputType.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -40,7 +40,7 @@
 
 private:
     const AtomicString& formControlType() const override;
-    bool appendFormData(FormDataList&, bool) const override;
+    bool appendFormData(DOMFormData&, bool) const override;
     bool supportsRequired() const override;
     void handleDOMActivateEvent(Event&) override;
     bool canBeSuccessfulSubmitButton() override;

Modified: trunk/Source/WebCore/html/TextFieldInputType.cpp (221913 => 221914)


--- trunk/Source/WebCore/html/TextFieldInputType.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/TextFieldInputType.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -35,9 +35,9 @@
 #include "BeforeTextInsertedEvent.h"
 #include "Chrome.h"
 #include "ChromeClient.h"
+#include "DOMFormData.h"
 #include "Editor.h"
 #include "EventNames.h"
-#include "FormDataList.h"
 #include "Frame.h"
 #include "FrameSelection.h"
 #include "HTMLInputElement.h"
@@ -511,12 +511,12 @@
     m_placeholder->setInnerText(placeholderText);
 }
 
-bool TextFieldInputType::appendFormData(FormDataList& list, bool multipart) const
+bool TextFieldInputType::appendFormData(DOMFormData& formData, bool multipart) const
 {
-    InputType::appendFormData(list, multipart);
-    const AtomicString& dirnameAttrValue = element().attributeWithoutSynchronization(dirnameAttr);
+    InputType::appendFormData(formData, multipart);
+    auto& dirnameAttrValue = element().attributeWithoutSynchronization(dirnameAttr);
     if (!dirnameAttrValue.isNull())
-        list.appendData(dirnameAttrValue, element().directionForFormData());
+        formData.append(dirnameAttrValue, element().directionForFormData());
     return true;
 }
 

Modified: trunk/Source/WebCore/html/TextFieldInputType.h (221913 => 221914)


--- trunk/Source/WebCore/html/TextFieldInputType.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/html/TextFieldInputType.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -36,7 +36,7 @@
 
 namespace WebCore {
 
-class FormDataList;
+class DOMFormData;
 class TextControlInnerTextElement;
 
 // The class represents types of which UI contain text fields.
@@ -86,7 +86,7 @@
     bool shouldRespectListAttribute() override;
     HTMLElement* placeholderElement() const final;
     void updatePlaceholderText() final;
-    bool appendFormData(FormDataList&, bool multipart) const final;
+    bool appendFormData(DOMFormData&, bool multipart) const final;
     void subtreeHasChanged() final;
     void capsLockStateMayHaveChanged() final;
     void updateAutoFillButton() final;

Modified: trunk/Source/WebCore/loader/FormSubmission.cpp (221913 => 221914)


--- trunk/Source/WebCore/loader/FormSubmission.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/loader/FormSubmission.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -214,10 +214,10 @@
     String boundary;
 
     if (isMultiPartForm) {
-        formData = FormData::createMultiPart(domFormData, domFormData->encoding(), &document);
+        formData = FormData::createMultiPart(domFormData, &document);
         boundary = formData->boundary().data();
     } else {
-        formData = FormData::create(domFormData, domFormData->encoding(), attributes.method() == Method::Get ? FormData::FormURLEncoded : FormData::parseEncodingType(encodingType));
+        formData = FormData::create(domFormData, attributes.method() == Method::Get ? FormData::FormURLEncoded : FormData::parseEncodingType(encodingType));
         if (copiedAttributes.method() == Method::Post && isMailtoForm) {
             // Convert the form data into a string that we put into the URL.
             appendMailtoPostFormDataToURL(actionURL, *formData, encodingType);

Modified: trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp (221913 => 221914)


--- trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/page/csp/ContentSecurityPolicy.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -38,7 +38,6 @@
 #include "DocumentLoader.h"
 #include "EventNames.h"
 #include "FormData.h"
-#include "FormDataList.h"
 #include "Frame.h"
 #include "HTMLParserIdioms.h"
 #include "InspectorInstrumentation.h"

Modified: trunk/Source/WebCore/platform/network/FormData.cpp (221913 => 221914)


--- trunk/Source/WebCore/platform/network/FormData.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/platform/network/FormData.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -26,11 +26,12 @@
 #include "BlobURL.h"
 #include "Chrome.h"
 #include "ChromeClient.h"
+#include "DOMFormData.h"
 #include "Document.h"
 #include "File.h"
 #include "FileSystem.h"
 #include "FormDataBuilder.h"
-#include "FormDataList.h"
+#include "LineEnding.h"
 #include "Page.h"
 #include "TextEncoding.h"
 #include "ThreadableBlobRegistry.h"
@@ -92,17 +93,17 @@
     return result;
 }
 
-Ref<FormData> FormData::create(const FormDataList& list, const TextEncoding& encoding, EncodingType encodingType)
+Ref<FormData> FormData::create(const DOMFormData& formData, EncodingType encodingType)
 {
     auto result = create();
-    result->appendKeyValuePairItems(list, encoding, false, nullptr, encodingType);
+    result->appendNonMultiPartKeyValuePairItems(formData, encodingType);
     return result;
 }
 
-Ref<FormData> FormData::createMultiPart(const FormDataList& list, const TextEncoding& encoding, Document* document)
+Ref<FormData> FormData::createMultiPart(const DOMFormData& formData, Document* document)
 {
     auto result = create();
-    result->appendKeyValuePairItems(list, encoding, true, document);
+    result->appendMultiPartKeyValuePairItems(formData, document);
     return result;
 }
 
@@ -182,75 +183,95 @@
     m_lengthInBytes = std::nullopt;
 }
 
-void FormData::appendKeyValuePairItems(const FormDataList& list, const TextEncoding& encoding, bool isMultiPartForm, Document* document, EncodingType encodingType)
+static CString normalizeStringData(TextEncoding& encoding, const String& value)
 {
-    if (isMultiPartForm)
-        m_boundary = FormDataBuilder::generateUniqueBoundaryString();
+    return normalizeLineEndingsToCRLF(encoding.encode(value, EntitiesForUnencodables));
+}
 
-    Vector<char> encodedData;
-    for (const auto& item : list.items()) {
-        auto normalizedName = list.normalizeString(item.name);
-    
-        if (isMultiPartForm) {
-            Vector<char> header;
-            FormDataBuilder::beginMultiPartHeader(header, m_boundary.data(), normalizedName);
+void FormData::appendMultiPartFileValue(const File& file, Vector<char>& header, TextEncoding& encoding, Document* document)
+{
+    auto name = file.name();
 
-            bool shouldGenerateFile = false;
+    // Let the application specify a filename if it's going to generate a replacement file for the upload.
+    bool shouldGenerateFile = false;
+    auto& path = file.path();
+    if (!path.isEmpty()) {
+        if (Page* page = document->page()) {
+            String generatedFileName;
+            shouldGenerateFile = page->chrome().client().shouldReplaceWithGeneratedFileForUpload(path, generatedFileName);
+            if (shouldGenerateFile)
+                name = generatedFileName;
+        }
+    }
 
-            if (WTF::holds_alternative<RefPtr<File>>(item.data)) {
-                // If the current type is a file, then we also need to include the filename
-                auto& file = *WTF::get<RefPtr<File>>(item.data);
-                auto name = file.name();
+    // We have to include the filename=".." part in the header, even if the filename is empty
+    FormDataBuilder::addFilenameToMultiPartHeader(header, encoding, name);
 
-                // Let the application specify a filename if it's going to generate a replacement file for the upload.
-                const auto& path = file.path();
-                if (!path.isEmpty()) {
-                    if (Page* page = document->page()) {
-                        String generatedFileName;
-                        shouldGenerateFile = page->chrome().client().shouldReplaceWithGeneratedFileForUpload(path, generatedFileName);
-                        if (shouldGenerateFile)
-                            name = generatedFileName;
-                    }
-                }
+    // Add the content type if available, or "application/octet-stream" otherwise (RFC 1867).
+    auto contentType = file.type();
+    if (contentType.isEmpty())
+        contentType = ASCIILiteral("application/octet-stream");
+    ASSERT(Blob::isNormalizedContentType(contentType));
 
-                // We have to include the filename=".." part in the header, even if the filename is empty
-                FormDataBuilder::addFilenameToMultiPartHeader(header, encoding, name);
+    FormDataBuilder::addContentTypeToMultiPartHeader(header, contentType.ascii());
 
-                // Add the content type if available, or "application/octet-stream" otherwise (RFC 1867).
-                auto contentType = file.type();
-                if (contentType.isEmpty())
-                    contentType = "application/octet-stream";
-                ASSERT(Blob::isNormalizedContentType(contentType));
-                FormDataBuilder::addContentTypeToMultiPartHeader(header, contentType.ascii());
-            }
+    FormDataBuilder::finishMultiPartHeader(header);
+    appendData(header.data(), header.size());
 
-            FormDataBuilder::finishMultiPartHeader(header);
+    if (!file.path().isEmpty())
+        appendFile(file.path(), shouldGenerateFile);
+    else
+        appendBlob(file.url());
+}
 
-            appendData(header.data(), header.size());
+void FormData::appendMultiPartStringValue(const String& string, Vector<char>& header, TextEncoding& encoding)
+{
+    FormDataBuilder::finishMultiPartHeader(header);
+    appendData(header.data(), header.size());
 
-            if (WTF::holds_alternative<RefPtr<File>>(item.data)) {
-                auto& file = *WTF::get<RefPtr<File>>(item.data);
-                if (!file.path().isEmpty())
-                    appendFile(file.path(), shouldGenerateFile);
-                else
-                    appendBlob(file.url());
-            } else {
-                auto normalizedStringData = list.normalizeString(WTF::get<String>(item.data));
-                appendData(normalizedStringData.data(), normalizedStringData.length());
-            }
+    auto normalizedStringData = normalizeStringData(encoding, string);
+    appendData(normalizedStringData.data(), normalizedStringData.length());
+}
 
-            appendData("\r\n", 2);
-        } else {
-            ASSERT(WTF::holds_alternative<String>(item.data));
+void FormData::appendMultiPartKeyValuePairItems(const DOMFormData& formData, Document* document)
+{
+    m_boundary = FormDataBuilder::generateUniqueBoundaryString();
 
-            auto normalizedStringData = list.normalizeString(WTF::get<String>(item.data));
-            FormDataBuilder::addKeyValuePairAsFormData(encodedData, normalizedName, normalizedStringData, encodingType);
-        }
+    auto encoding = formData.encoding();
+
+    Vector<char> encodedData;
+    for (auto& item : formData.items()) {
+        auto normalizedName = normalizeStringData(encoding, item.name);
+    
+        Vector<char> header;
+        FormDataBuilder::beginMultiPartHeader(header, m_boundary.data(), normalizedName);
+
+        if (WTF::holds_alternative<RefPtr<File>>(item.data))
+            appendMultiPartFileValue(*WTF::get<RefPtr<File>>(item.data), header, encoding, document);
+        else
+            appendMultiPartStringValue(WTF::get<String>(item.data), header, encoding);
+
+        appendData("\r\n", 2);
     }
+    
+    FormDataBuilder::addBoundaryToMultiPartHeader(encodedData, m_boundary.data(), true);
 
-    if (isMultiPartForm)
-        FormDataBuilder::addBoundaryToMultiPartHeader(encodedData, m_boundary.data(), true);
+    appendData(encodedData.data(), encodedData.size());
+}
 
+void FormData::appendNonMultiPartKeyValuePairItems(const DOMFormData& formData, EncodingType encodingType)
+{
+    auto encoding = formData.encoding();
+
+    Vector<char> encodedData;
+    for (auto& item : formData.items()) {
+        ASSERT(WTF::holds_alternative<String>(item.data));
+
+        auto normalizedName = normalizeStringData(encoding, item.name);
+        auto normalizedStringData = normalizeStringData(encoding, WTF::get<String>(item.data));
+        FormDataBuilder::addKeyValuePairAsFormData(encodedData, normalizedName, normalizedStringData, encodingType);
+    }
+
     appendData(encodedData.data(), encodedData.size());
 }
 

Modified: trunk/Source/WebCore/platform/network/FormData.h (221913 => 221914)


--- trunk/Source/WebCore/platform/network/FormData.h	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/platform/network/FormData.h	2017-09-12 14:53:18 UTC (rev 221914)
@@ -17,8 +17,7 @@
  * Boston, MA 02110-1301, USA.
  */
 
-#ifndef FormData_h
-#define FormData_h
+#pragma once
 
 #include "BlobData.h"
 #include "URL.h"
@@ -29,8 +28,9 @@
 
 namespace WebCore {
 
+class DOMFormData;
 class Document;
-class FormDataList;
+class File;
 class TextEncoding;
 
 class FormDataElement {
@@ -202,8 +202,8 @@
     WEBCORE_EXPORT static Ref<FormData> create(const void*, size_t);
     static Ref<FormData> create(const CString&);
     static Ref<FormData> create(const Vector<char>&);
-    static Ref<FormData> create(const FormDataList&, const TextEncoding&, EncodingType = FormURLEncoded);
-    static Ref<FormData> createMultiPart(const FormDataList&, const TextEncoding&, Document*);
+    static Ref<FormData> create(const DOMFormData&, EncodingType = FormURLEncoded);
+    static Ref<FormData> createMultiPart(const DOMFormData&, Document*);
     WEBCORE_EXPORT ~FormData();
 
     // FIXME: Both these functions perform a deep copy of m_elements, but differ in handling of other data members.
@@ -262,7 +262,10 @@
     FormData();
     FormData(const FormData&);
 
-    void appendKeyValuePairItems(const FormDataList&, const TextEncoding&, bool isMultiPartForm, Document*, EncodingType = FormURLEncoded);
+    void appendMultiPartFileValue(const File&, Vector<char>& header, TextEncoding&, Document*);
+    void appendMultiPartStringValue(const String&, Vector<char>& header, TextEncoding&);
+    void appendMultiPartKeyValuePairItems(const DOMFormData&, Document*);
+    void appendNonMultiPartKeyValuePairItems(const DOMFormData&, EncodingType);
 
     bool hasGeneratedFiles() const;
     bool hasOwnedGeneratedFiles() const;
@@ -317,4 +320,3 @@
 
 } // namespace WebCore
 
-#endif

Modified: trunk/Source/WebCore/xml/XMLHttpRequest.cpp (221913 => 221914)


--- trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2017-09-12 13:23:05 UTC (rev 221913)
+++ trunk/Source/WebCore/xml/XMLHttpRequest.cpp	2017-09-12 14:53:18 UTC (rev 221914)
@@ -648,7 +648,7 @@
         return WTFMove(result.value());
 
     if (m_method != "GET" && m_method != "HEAD" && m_url.protocolIsInHTTPFamily()) {
-        m_requestEntityBody = FormData::createMultiPart(body, body.encoding(), document());
+        m_requestEntityBody = FormData::createMultiPart(body, document());
         m_requestEntityBody->generateFiles(document());
         if (!m_requestHeaders.contains(HTTPHeaderName::ContentType))
             m_requestHeaders.set(HTTPHeaderName::ContentType, makeString("multipart/form-data; boundary=", m_requestEntityBody->boundary().data()));
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to