Title: [175369] trunk/Source/WebCore
Revision
175369
Author
[email protected]
Date
2014-10-30 01:02:20 -0700 (Thu, 30 Oct 2014)

Log Message

FormDataBuilder should not use Document
https://bugs.webkit.org/show_bug.cgi?id=138172

Reviewed by Alexey Proskuryakov.

It's only used by encodingFromAcceptCharset() to fallback to
document input encoding. That method is only used by
FormSubmission::create(), so it could be moved as a static
function to FormSubmission.cpp.

* loader/FormSubmission.cpp:
(WebCore::encodingFromAcceptCharset):
(WebCore::FormSubmission::create):
* platform/network/FormDataBuilder.cpp:
(WebCore::FormDataBuilder::encodingFromAcceptCharset): Deleted.
* platform/network/FormDataBuilder.h:

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (175368 => 175369)


--- trunk/Source/WebCore/ChangeLog	2014-10-30 07:37:16 UTC (rev 175368)
+++ trunk/Source/WebCore/ChangeLog	2014-10-30 08:02:20 UTC (rev 175369)
@@ -1,3 +1,22 @@
+2014-10-30  Carlos Garcia Campos  <[email protected]>
+
+        FormDataBuilder should not use Document
+        https://bugs.webkit.org/show_bug.cgi?id=138172
+
+        Reviewed by Alexey Proskuryakov.
+
+        It's only used by encodingFromAcceptCharset() to fallback to
+        document input encoding. That method is only used by
+        FormSubmission::create(), so it could be moved as a static
+        function to FormSubmission.cpp.
+
+        * loader/FormSubmission.cpp:
+        (WebCore::encodingFromAcceptCharset):
+        (WebCore::FormSubmission::create):
+        * platform/network/FormDataBuilder.cpp:
+        (WebCore::FormDataBuilder::encodingFromAcceptCharset): Deleted.
+        * platform/network/FormDataBuilder.h:
+
 2014-10-29  Said Abou-Hallawa  <[email protected]>
 
         ASSERTION NOT REACHED because RenderStyle::setWordSpacing() does not handle a Length value of type 'Calculated'.

Modified: trunk/Source/WebCore/loader/FormSubmission.cpp (175368 => 175369)


--- trunk/Source/WebCore/loader/FormSubmission.cpp	2014-10-30 07:37:16 UTC (rev 175368)
+++ trunk/Source/WebCore/loader/FormSubmission.cpp	2014-10-30 08:02:20 UTC (rev 175369)
@@ -137,6 +137,23 @@
 {
 }
 
+static TextEncoding encodingFromAcceptCharset(const String& acceptCharset, Document& document)
+{
+    String normalizedAcceptCharset = acceptCharset;
+    normalizedAcceptCharset.replace(',', ' ');
+
+    Vector<String> charsets;
+    normalizedAcceptCharset.split(' ', charsets);
+
+    for (auto& charset : charsets) {
+        TextEncoding encoding(charset);
+        if (encoding.isValid())
+            return encoding;
+    }
+
+    return document.inputEncoding();
+}
+
 PassRefPtr<FormSubmission> FormSubmission::create(HTMLFormElement* form, const Attributes& attributes, PassRefPtr<Event> event, LockHistory lockHistory, FormSubmissionTrigger trigger)
 {
     ASSERT(form);
@@ -179,7 +196,7 @@
         }
     }
 
-    TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : FormDataBuilder::encodingFromAcceptCharset(copiedAttributes.acceptCharset(), document);
+    TextEncoding dataEncoding = isMailtoForm ? UTF8Encoding() : encodingFromAcceptCharset(copiedAttributes.acceptCharset(), document);
     RefPtr<DOMFormData> domFormData = DOMFormData::create(dataEncoding.encodingForFormSubmission());
     Vector<std::pair<String, String>> formValues;
 

Modified: trunk/Source/WebCore/platform/network/FormDataBuilder.cpp (175368 => 175369)


--- trunk/Source/WebCore/platform/network/FormDataBuilder.cpp	2014-10-30 07:37:16 UTC (rev 175368)
+++ trunk/Source/WebCore/platform/network/FormDataBuilder.cpp	2014-10-30 08:02:20 UTC (rev 175369)
@@ -26,7 +26,6 @@
 #include "FormDataBuilder.h"
 
 #include "Blob.h"
-#include "Document.h"
 #include "TextEncoding.h"
 #include <limits>
 #include <wtf/Assertions.h>
@@ -77,23 +76,6 @@
     }
 }
 
-TextEncoding FormDataBuilder::encodingFromAcceptCharset(const String& acceptCharset, Document& document)
-{
-    String normalizedAcceptCharset = acceptCharset;
-    normalizedAcceptCharset.replace(',', ' ');
-
-    Vector<String> charsets;
-    normalizedAcceptCharset.split(' ', charsets);
-
-    for (auto& charset : charsets) {
-        TextEncoding encoding(charset);
-        if (encoding.isValid())
-            return encoding;
-    }
-
-    return document.inputEncoding();
-}
-
 Vector<char> FormDataBuilder::generateUniqueBoundaryString()
 {
     Vector<char> boundary;

Modified: trunk/Source/WebCore/platform/network/FormDataBuilder.h (175368 => 175369)


--- trunk/Source/WebCore/platform/network/FormDataBuilder.h	2014-10-30 07:37:16 UTC (rev 175368)
+++ trunk/Source/WebCore/platform/network/FormDataBuilder.h	2014-10-30 08:02:20 UTC (rev 175369)
@@ -26,14 +26,11 @@
 
 namespace WebCore {
 
-class Document;
 class TextEncoding;
 
 class FormDataBuilder {
     WTF_MAKE_NONCOPYABLE(FormDataBuilder);
 public:
-    static TextEncoding encodingFromAcceptCharset(const String& acceptCharset, Document&);
-
     // Helper functions used by HTMLFormElement for multi-part form data
     static Vector<char> generateUniqueBoundaryString();
     static void beginMultiPartHeader(Vector<char>&, const CString& boundary, const CString& name);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to