Bug 1237674 - Rename nsFormData to mozilla::dom::FormData, r=smaug

This commit is contained in:
Andrea Marchesini 2016-01-07 19:30:36 +00:00
parent f25ca3b068
commit 496a5cfe38
15 changed files with 130 additions and 126 deletions

View File

@ -4,7 +4,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#include "nsFormData.h" #include "FormData.h"
#include "nsIVariant.h" #include "nsIVariant.h"
#include "nsIInputStream.h" #include "nsIInputStream.h"
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
@ -15,7 +15,7 @@
using namespace mozilla; using namespace mozilla;
using namespace mozilla::dom; using namespace mozilla::dom;
nsFormData::nsFormData(nsISupports* aOwner) FormData::FormData(nsISupports* aOwner)
: nsFormSubmission(NS_LITERAL_CSTRING("UTF-8"), nullptr) : nsFormSubmission(NS_LITERAL_CSTRING("UTF-8"), nullptr)
, mOwner(aOwner) , mOwner(aOwner)
{ {
@ -61,9 +61,9 @@ CreateNewFileInstance(Blob& aBlob, const Optional<nsAString>& aFilename,
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// nsISupports // nsISupports
NS_IMPL_CYCLE_COLLECTION_CLASS(nsFormData) NS_IMPL_CYCLE_COLLECTION_CLASS(FormData)
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsFormData) NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(FormData)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner) NS_IMPL_CYCLE_COLLECTION_UNLINK(mOwner)
for (uint32_t i = 0, len = tmp->mFormData.Length(); i < len; ++i) { for (uint32_t i = 0, len = tmp->mFormData.Length(); i < len; ++i) {
@ -73,7 +73,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsFormData)
NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER NS_IMPL_CYCLE_COLLECTION_UNLINK_PRESERVED_WRAPPER
NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsFormData) NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(FormData)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOwner)
for (uint32_t i = 0, len = tmp->mFormData.Length(); i < len; ++i) { for (uint32_t i = 0, len = tmp->mFormData.Length(); i < len; ++i) {
@ -84,12 +84,12 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsFormData)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(nsFormData) NS_IMPL_CYCLE_COLLECTION_TRACE_WRAPPERCACHE(FormData)
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsFormData) NS_IMPL_CYCLE_COLLECTING_ADDREF(FormData)
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsFormData) NS_IMPL_CYCLE_COLLECTING_RELEASE(FormData)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsFormData) NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(FormData)
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
NS_INTERFACE_MAP_ENTRY(nsIDOMFormData) NS_INTERFACE_MAP_ENTRY(nsIDOMFormData)
NS_INTERFACE_MAP_ENTRY(nsIXHRSendable) NS_INTERFACE_MAP_ENTRY(nsIXHRSendable)
@ -99,23 +99,23 @@ NS_INTERFACE_MAP_END
// ------------------------------------------------------------------------- // -------------------------------------------------------------------------
// nsFormSubmission // nsFormSubmission
nsresult nsresult
nsFormData::GetEncodedSubmission(nsIURI* aURI, FormData::GetEncodedSubmission(nsIURI* aURI,
nsIInputStream** aPostDataStream) nsIInputStream** aPostDataStream)
{ {
NS_NOTREACHED("Shouldn't call nsFormData::GetEncodedSubmission"); NS_NOTREACHED("Shouldn't call FormData::GetEncodedSubmission");
return NS_OK; return NS_OK;
} }
void void
nsFormData::Append(const nsAString& aName, const nsAString& aValue, FormData::Append(const nsAString& aName, const nsAString& aValue,
ErrorResult& aRv) ErrorResult& aRv)
{ {
AddNameValuePair(aName, aValue); AddNameValuePair(aName, aValue);
} }
void void
nsFormData::Append(const nsAString& aName, Blob& aBlob, FormData::Append(const nsAString& aName, Blob& aBlob,
const Optional<nsAString>& aFilename, const Optional<nsAString>& aFilename,
ErrorResult& aRv) ErrorResult& aRv)
{ {
RefPtr<File> file = CreateNewFileInstance(aBlob, aFilename, aRv); RefPtr<File> file = CreateNewFileInstance(aBlob, aFilename, aRv);
@ -127,7 +127,7 @@ nsFormData::Append(const nsAString& aName, Blob& aBlob,
} }
void void
nsFormData::Delete(const nsAString& aName) FormData::Delete(const nsAString& aName)
{ {
// We have to use this slightly awkward for loop since uint32_t >= 0 is an // We have to use this slightly awkward for loop since uint32_t >= 0 is an
// error for being always true. // error for being always true.
@ -139,8 +139,8 @@ nsFormData::Delete(const nsAString& aName)
} }
void void
nsFormData::Get(const nsAString& aName, FormData::Get(const nsAString& aName,
Nullable<OwningFileOrUSVString>& aOutValue) Nullable<OwningFileOrUSVString>& aOutValue)
{ {
for (uint32_t i = 0; i < mFormData.Length(); ++i) { for (uint32_t i = 0; i < mFormData.Length(); ++i) {
if (aName.Equals(mFormData[i].name)) { if (aName.Equals(mFormData[i].name)) {
@ -153,8 +153,8 @@ nsFormData::Get(const nsAString& aName,
} }
void void
nsFormData::GetAll(const nsAString& aName, FormData::GetAll(const nsAString& aName,
nsTArray<OwningFileOrUSVString>& aValues) nsTArray<OwningFileOrUSVString>& aValues)
{ {
for (uint32_t i = 0; i < mFormData.Length(); ++i) { for (uint32_t i = 0; i < mFormData.Length(); ++i) {
if (aName.Equals(mFormData[i].name)) { if (aName.Equals(mFormData[i].name)) {
@ -165,7 +165,7 @@ nsFormData::GetAll(const nsAString& aName,
} }
bool bool
nsFormData::Has(const nsAString& aName) FormData::Has(const nsAString& aName)
{ {
for (uint32_t i = 0; i < mFormData.Length(); ++i) { for (uint32_t i = 0; i < mFormData.Length(); ++i) {
if (aName.Equals(mFormData[i].name)) { if (aName.Equals(mFormData[i].name)) {
@ -177,15 +177,15 @@ nsFormData::Has(const nsAString& aName)
} }
nsresult nsresult
nsFormData::AddNameFilePair(const nsAString& aName, File* aFile) FormData::AddNameFilePair(const nsAString& aName, File* aFile)
{ {
FormDataTuple* data = mFormData.AppendElement(); FormDataTuple* data = mFormData.AppendElement();
SetNameFilePair(data, aName, aFile); SetNameFilePair(data, aName, aFile);
return NS_OK; return NS_OK;
} }
nsFormData::FormDataTuple* FormData::FormDataTuple*
nsFormData::RemoveAllOthersAndGetFirstFormDataTuple(const nsAString& aName) FormData::RemoveAllOthersAndGetFirstFormDataTuple(const nsAString& aName)
{ {
FormDataTuple* lastFoundTuple = nullptr; FormDataTuple* lastFoundTuple = nullptr;
uint32_t lastFoundIndex = mFormData.Length(); uint32_t lastFoundIndex = mFormData.Length();
@ -207,9 +207,9 @@ nsFormData::RemoveAllOthersAndGetFirstFormDataTuple(const nsAString& aName)
} }
void void
nsFormData::Set(const nsAString& aName, Blob& aBlob, FormData::Set(const nsAString& aName, Blob& aBlob,
const Optional<nsAString>& aFilename, const Optional<nsAString>& aFilename,
ErrorResult& aRv) ErrorResult& aRv)
{ {
FormDataTuple* tuple = RemoveAllOthersAndGetFirstFormDataTuple(aName); FormDataTuple* tuple = RemoveAllOthersAndGetFirstFormDataTuple(aName);
if (tuple) { if (tuple) {
@ -225,8 +225,8 @@ nsFormData::Set(const nsAString& aName, Blob& aBlob,
} }
void void
nsFormData::Set(const nsAString& aName, const nsAString& aValue, FormData::Set(const nsAString& aName, const nsAString& aValue,
ErrorResult& aRv) ErrorResult& aRv)
{ {
FormDataTuple* tuple = RemoveAllOthersAndGetFirstFormDataTuple(aName); FormDataTuple* tuple = RemoveAllOthersAndGetFirstFormDataTuple(aName);
if (tuple) { if (tuple) {
@ -237,29 +237,29 @@ nsFormData::Set(const nsAString& aName, const nsAString& aValue,
} }
uint32_t uint32_t
nsFormData::GetIterableLength() const FormData::GetIterableLength() const
{ {
return mFormData.Length(); return mFormData.Length();
} }
const nsAString& const nsAString&
nsFormData::GetKeyAtIndex(uint32_t aIndex) const FormData::GetKeyAtIndex(uint32_t aIndex) const
{ {
MOZ_ASSERT(aIndex < mFormData.Length()); MOZ_ASSERT(aIndex < mFormData.Length());
return mFormData[aIndex].name; return mFormData[aIndex].name;
} }
const OwningFileOrUSVString& const OwningFileOrUSVString&
nsFormData::GetValueAtIndex(uint32_t aIndex) const FormData::GetValueAtIndex(uint32_t aIndex) const
{ {
MOZ_ASSERT(aIndex < mFormData.Length()); MOZ_ASSERT(aIndex < mFormData.Length());
return mFormData[aIndex].value; return mFormData[aIndex].value;
} }
void void
nsFormData::SetNameValuePair(FormDataTuple* aData, FormData::SetNameValuePair(FormDataTuple* aData,
const nsAString& aName, const nsAString& aName,
const nsAString& aValue) const nsAString& aValue)
{ {
MOZ_ASSERT(aData); MOZ_ASSERT(aData);
aData->name = aName; aData->name = aName;
@ -267,9 +267,9 @@ nsFormData::SetNameValuePair(FormDataTuple* aData,
} }
void void
nsFormData::SetNameFilePair(FormDataTuple* aData, FormData::SetNameFilePair(FormDataTuple* aData,
const nsAString& aName, const nsAString& aName,
File* aFile) File* aFile)
{ {
MOZ_ASSERT(aData); MOZ_ASSERT(aData);
aData->name = aName; aData->name = aName;
@ -284,7 +284,7 @@ nsFormData::SetNameFilePair(FormDataTuple* aData,
// nsIDOMFormData // nsIDOMFormData
NS_IMETHODIMP NS_IMETHODIMP
nsFormData::Append(const nsAString& aName, nsIVariant* aValue) FormData::Append(const nsAString& aName, nsIVariant* aValue)
{ {
uint16_t dataType; uint16_t dataType;
nsresult rv = aValue->GetDataType(&dataType); nsresult rv = aValue->GetDataType(&dataType);
@ -331,17 +331,17 @@ nsFormData::Append(const nsAString& aName, nsIVariant* aValue)
} }
/* virtual */ JSObject* /* virtual */ JSObject*
nsFormData::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) FormData::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
{ {
return FormDataBinding::Wrap(aCx, this, aGivenProto); return FormDataBinding::Wrap(aCx, this, aGivenProto);
} }
/* static */ already_AddRefed<nsFormData> /* static */ already_AddRefed<FormData>
nsFormData::Constructor(const GlobalObject& aGlobal, FormData::Constructor(const GlobalObject& aGlobal,
const Optional<NonNull<HTMLFormElement> >& aFormElement, const Optional<NonNull<HTMLFormElement> >& aFormElement,
ErrorResult& aRv) ErrorResult& aRv)
{ {
RefPtr<nsFormData> formData = new nsFormData(aGlobal.GetAsSupports()); RefPtr<FormData> formData = new FormData(aGlobal.GetAsSupports());
if (aFormElement.WasPassed()) { if (aFormElement.WasPassed()) {
aRv = aFormElement.Value().WalkFormElements(formData); aRv = aFormElement.Value().WalkFormElements(formData);
} }
@ -352,8 +352,8 @@ nsFormData::Constructor(const GlobalObject& aGlobal,
// nsIXHRSendable // nsIXHRSendable
NS_IMETHODIMP NS_IMETHODIMP
nsFormData::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength, FormData::GetSendInfo(nsIInputStream** aBody, uint64_t* aContentLength,
nsACString& aContentType, nsACString& aCharset) nsACString& aContentType, nsACString& aCharset)
{ {
nsFSMultipartFormData fs(NS_LITERAL_CSTRING("UTF-8"), nullptr); nsFSMultipartFormData fs(NS_LITERAL_CSTRING("UTF-8"), nullptr);

View File

@ -4,40 +4,33 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this * License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
#ifndef nsFormData_h__ #ifndef mozilla_dom_FormData_h
#define nsFormData_h__ #define mozilla_dom_FormData_h
#include "mozilla/Attributes.h" #include "mozilla/Attributes.h"
#include "nsIDOMFormData.h"
#include "nsIXMLHttpRequest.h"
#include "nsFormSubmission.h"
#include "nsWrapperCache.h"
#include "nsTArray.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "mozilla/dom/BindingDeclarations.h" #include "mozilla/dom/BindingDeclarations.h"
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
#include "mozilla/dom/FormDataBinding.h" #include "mozilla/dom/FormDataBinding.h"
#include "nsIDOMFormData.h"
#include "nsIXMLHttpRequest.h"
#include "nsFormSubmission.h"
#include "nsTArray.h"
#include "nsWrapperCache.h"
namespace mozilla { namespace mozilla {
class ErrorResult;
namespace dom { namespace dom {
class HTMLFormElement; class HTMLFormElement;
class GlobalObject; class GlobalObject;
} // namespace dom
} // namespace mozilla
class nsFormData final : public nsIDOMFormData, class FormData final : public nsIDOMFormData,
public nsIXHRSendable, public nsIXHRSendable,
public nsFormSubmission, public nsFormSubmission,
public nsWrapperCache public nsWrapperCache
{ {
private: private:
~nsFormData() {} ~FormData() {}
typedef mozilla::dom::Blob Blob;
typedef mozilla::dom::File File;
typedef mozilla::dom::OwningFileOrUSVString OwningFileOrUSVString;
struct FormDataTuple struct FormDataTuple
{ {
@ -59,10 +52,10 @@ private:
File* aFile); File* aFile);
public: public:
explicit nsFormData(nsISupports* aOwner = nullptr); explicit FormData(nsISupports* aOwner = nullptr);
NS_DECL_CYCLE_COLLECTING_ISUPPORTS NS_DECL_CYCLE_COLLECTING_ISUPPORTS
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsFormData, NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(FormData,
nsIDOMFormData) nsIDOMFormData)
NS_DECL_NSIDOMFORMDATA NS_DECL_NSIDOMFORMDATA
@ -77,32 +70,42 @@ public:
{ {
return mOwner; return mOwner;
} }
static already_AddRefed<nsFormData>
Constructor(const mozilla::dom::GlobalObject& aGlobal, static already_AddRefed<FormData>
const mozilla::dom::Optional<mozilla::dom::NonNull<mozilla::dom::HTMLFormElement> >& aFormElement, Constructor(const GlobalObject& aGlobal,
mozilla::ErrorResult& aRv); const Optional<NonNull<HTMLFormElement> >& aFormElement,
ErrorResult& aRv);
void Append(const nsAString& aName, const nsAString& aValue, void Append(const nsAString& aName, const nsAString& aValue,
mozilla::ErrorResult& aRv); ErrorResult& aRv);
void Append(const nsAString& aName, Blob& aBlob, void Append(const nsAString& aName, Blob& aBlob,
const mozilla::dom::Optional<nsAString>& aFilename, const Optional<nsAString>& aFilename,
mozilla::ErrorResult& aRv); ErrorResult& aRv);
void Delete(const nsAString& aName); void Delete(const nsAString& aName);
void Get(const nsAString& aName, mozilla::dom::Nullable<OwningFileOrUSVString>& aOutValue);
void Get(const nsAString& aName, Nullable<OwningFileOrUSVString>& aOutValue);
void GetAll(const nsAString& aName, nsTArray<OwningFileOrUSVString>& aValues); void GetAll(const nsAString& aName, nsTArray<OwningFileOrUSVString>& aValues);
bool Has(const nsAString& aName); bool Has(const nsAString& aName);
void Set(const nsAString& aName, Blob& aBlob, void Set(const nsAString& aName, Blob& aBlob,
const mozilla::dom::Optional<nsAString>& aFilename, const Optional<nsAString>& aFilename,
mozilla::ErrorResult& aRv); ErrorResult& aRv);
void Set(const nsAString& aName, const nsAString& aValue, void Set(const nsAString& aName, const nsAString& aValue,
mozilla::ErrorResult& aRv); ErrorResult& aRv);
uint32_t GetIterableLength() const; uint32_t GetIterableLength() const;
const nsAString& GetKeyAtIndex(uint32_t aIndex) const; const nsAString& GetKeyAtIndex(uint32_t aIndex) const;
const OwningFileOrUSVString& GetValueAtIndex(uint32_t aIndex) const; const OwningFileOrUSVString& GetValueAtIndex(uint32_t aIndex) const;
// nsFormSubmission // nsFormSubmission
virtual nsresult GetEncodedSubmission(nsIURI* aURI, virtual nsresult
nsIInputStream** aPostDataStream) override; GetEncodedSubmission(nsIURI* aURI, nsIInputStream** aPostDataStream) override;
virtual nsresult AddNameValuePair(const nsAString& aName, virtual nsresult AddNameValuePair(const nsAString& aName,
const nsAString& aValue) override const nsAString& aValue) override
{ {
@ -110,6 +113,7 @@ public:
SetNameValuePair(data, aName, aValue); SetNameValuePair(data, aName, aValue);
return NS_OK; return NS_OK;
} }
virtual nsresult AddNameFilePair(const nsAString& aName, virtual nsresult AddNameFilePair(const nsAString& aName,
File* aFile) override; File* aFile) override;
@ -144,4 +148,7 @@ private:
nsTArray<FormDataTuple> mFormData; nsTArray<FormDataTuple> mFormData;
}; };
#endif // nsFormData_h__ } // dom namespace
} // mozilla namepsace
#endif // mozilla_dom_FormData_h

View File

@ -106,7 +106,7 @@
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
#include "nsIUploadChannel2.h" #include "nsIUploadChannel2.h"
#include "nsFormData.h" #include "mozilla/dom/FormData.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "WorkerPrivate.h" #include "WorkerPrivate.h"
@ -1292,7 +1292,7 @@ Navigator::SendBeacon(const nsAString& aUrl,
mimeType = NS_ConvertUTF16toUTF8(type); mimeType = NS_ConvertUTF16toUTF8(type);
} else if (aData.Value().IsFormData()) { } else if (aData.Value().IsFormData()) {
nsFormData& form = aData.Value().GetAsFormData(); FormData& form = aData.Value().GetAsFormData();
uint64_t len; uint64_t len;
nsAutoCString charset; nsAutoCString charset;
form.GetSendInfo(getter_AddRefs(in), form.GetSendInfo(getter_AddRefs(in),

View File

@ -13,6 +13,7 @@
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
#include "mozilla/dom/FileList.h" #include "mozilla/dom/FileList.h"
#include "mozilla/dom/FileListBinding.h" #include "mozilla/dom/FileListBinding.h"
#include "mozilla/dom/FormData.h"
#include "mozilla/dom/ImageBitmap.h" #include "mozilla/dom/ImageBitmap.h"
#include "mozilla/dom/ImageBitmapBinding.h" #include "mozilla/dom/ImageBitmapBinding.h"
#include "mozilla/dom/ImageData.h" #include "mozilla/dom/ImageData.h"
@ -33,7 +34,6 @@
#include "mozilla/ipc/BackgroundUtils.h" #include "mozilla/ipc/BackgroundUtils.h"
#include "mozilla/ipc/PBackgroundSharedTypes.h" #include "mozilla/ipc/PBackgroundSharedTypes.h"
#include "MultipartBlobImpl.h" #include "MultipartBlobImpl.h"
#include "nsFormData.h"
#include "nsIRemoteBlob.h" #include "nsIRemoteBlob.h"
#include "nsQueryObject.h" #include "nsQueryObject.h"
@ -816,8 +816,8 @@ ReadFormData(JSContext* aCx,
// See the serialization of the FormData for the format. // See the serialization of the FormData for the format.
JS::Rooted<JS::Value> val(aCx); JS::Rooted<JS::Value> val(aCx);
{ {
RefPtr<nsFormData> formData = RefPtr<FormData> formData =
new nsFormData(aHolder->ParentDuringRead()); new FormData(aHolder->ParentDuringRead());
Optional<nsAString> thirdArg; Optional<nsAString> thirdArg;
for (uint32_t i = 0; i < aCount; ++i) { for (uint32_t i = 0; i < aCount; ++i) {
@ -887,7 +887,7 @@ ReadFormData(JSContext* aCx,
// - value string // - value string
bool bool
WriteFormData(JSStructuredCloneWriter* aWriter, WriteFormData(JSStructuredCloneWriter* aWriter,
nsFormData* aFormData, FormData* aFormData,
StructuredCloneHolder* aHolder) StructuredCloneHolder* aHolder)
{ {
MOZ_ASSERT(aWriter); MOZ_ASSERT(aWriter);
@ -1010,7 +1010,7 @@ StructuredCloneHolder::CustomWriteHandler(JSContext* aCx,
// See if this is a FormData object. // See if this is a FormData object.
{ {
nsFormData* formData = nullptr; FormData* formData = nullptr;
if (NS_SUCCEEDED(UNWRAP_OBJECT(FormData, aObj, formData))) { if (NS_SUCCEEDED(UNWRAP_OBJECT(FormData, aObj, formData))) {
return WriteFormData(aWriter, formData, this); return WriteFormData(aWriter, formData, this);
} }

View File

@ -75,7 +75,6 @@ EXPORTS += [
'nsDOMNavigationTiming.h', 'nsDOMNavigationTiming.h',
'nsDOMString.h', 'nsDOMString.h',
'nsFocusManager.h', 'nsFocusManager.h',
'nsFormData.h',
'nsFrameMessageManager.h', 'nsFrameMessageManager.h',
'nsGenericDOMDataNode.h', 'nsGenericDOMDataNode.h',
'nsGkAtomList.h', 'nsGkAtomList.h',
@ -180,6 +179,7 @@ EXPORTS.mozilla.dom += [
'File.h', 'File.h',
'FileList.h', 'FileList.h',
'FileReader.h', 'FileReader.h',
'FormData.h',
'FragmentOrElement.h', 'FragmentOrElement.h',
'FromParser.h', 'FromParser.h',
'ImageEncoder.h', 'ImageEncoder.h',
@ -246,6 +246,7 @@ UNIFIED_SOURCES += [
'File.cpp', 'File.cpp',
'FileList.cpp', 'FileList.cpp',
'FileReader.cpp', 'FileReader.cpp',
'FormData.cpp',
'FragmentOrElement.cpp', 'FragmentOrElement.cpp',
'ImageEncoder.cpp', 'ImageEncoder.cpp',
'ImportManager.cpp', 'ImportManager.cpp',
@ -280,7 +281,6 @@ UNIFIED_SOURCES += [
'nsDOMTokenList.cpp', 'nsDOMTokenList.cpp',
'nsDOMWindowList.cpp', 'nsDOMWindowList.cpp',
'nsFocusManager.cpp', 'nsFocusManager.cpp',
'nsFormData.cpp',
'nsFrameLoader.cpp', 'nsFrameLoader.cpp',
'nsGenConImageContent.cpp', 'nsGenConImageContent.cpp',
'nsGenericDOMDataNode.cpp', 'nsGenericDOMDataNode.cpp',

View File

@ -14,6 +14,7 @@
#include "mozilla/dom/BlobSet.h" #include "mozilla/dom/BlobSet.h"
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
#include "mozilla/dom/FetchUtil.h" #include "mozilla/dom/FetchUtil.h"
#include "mozilla/dom/FormData.h"
#include "mozilla/dom/XMLHttpRequestUploadBinding.h" #include "mozilla/dom/XMLHttpRequestUploadBinding.h"
#include "mozilla/EventDispatcher.h" #include "mozilla/EventDispatcher.h"
#include "mozilla/EventListenerManager.h" #include "mozilla/EventListenerManager.h"
@ -73,7 +74,6 @@
#include "nsIHttpChannelInternal.h" #include "nsIHttpChannelInternal.h"
#include "nsIClassOfService.h" #include "nsIClassOfService.h"
#include "nsCharSeparatedTokenizer.h" #include "nsCharSeparatedTokenizer.h"
#include "nsFormData.h"
#include "nsStreamListenerWrapper.h" #include "nsStreamListenerWrapper.h"
#include "xpcjsid.h" #include "xpcjsid.h"
#include "nsITimedChannel.h" #include "nsITimedChannel.h"

View File

@ -41,7 +41,6 @@
#undef Status #undef Status
#endif #endif
class nsFormData;
class nsIJARChannel; class nsIJARChannel;
class nsILoadGroup; class nsILoadGroup;
class nsIUnicodeDecoder; class nsIUnicodeDecoder;
@ -52,6 +51,7 @@ namespace mozilla {
namespace dom { namespace dom {
class Blob; class Blob;
class BlobSet; class BlobSet;
class FormData;
} // namespace dom } // namespace dom
// A helper for building up an ArrayBuffer object's data // A helper for building up an ArrayBuffer object's data
@ -363,7 +363,7 @@ private:
{ {
mValue.mString = &aString; mValue.mString = &aString;
} }
explicit RequestBody(nsFormData& aFormData) : mType(FormData) explicit RequestBody(mozilla::dom::FormData& aFormData) : mType(FormData)
{ {
mValue.mFormData = &aFormData; mValue.mFormData = &aFormData;
} }
@ -388,7 +388,7 @@ private:
mozilla::dom::Blob* mBlob; mozilla::dom::Blob* mBlob;
nsIDocument* mDocument; nsIDocument* mDocument;
const nsAString* mString; const nsAString* mString;
nsFormData* mFormData; mozilla::dom::FormData* mFormData;
nsIInputStream* mStream; nsIInputStream* mStream;
}; };
@ -467,7 +467,8 @@ public:
aRv = Send(RequestBody(aString)); aRv = Send(RequestBody(aString));
} }
} }
void Send(JSContext* /*aCx*/, nsFormData& aFormData, ErrorResult& aRv) void Send(JSContext* /*aCx*/, mozilla::dom::FormData& aFormData,
ErrorResult& aRv)
{ {
aRv = Send(RequestBody(aFormData)); aRv = Send(RequestBody(aFormData));
} }

View File

@ -529,10 +529,6 @@ DOMInterfaces = {
'wrapperCache': False, 'wrapperCache': False,
}, },
'FormData': {
'nativeType': 'nsFormData'
},
'Geolocation': { 'Geolocation': {
'headerFile': 'nsGeolocation.h' 'headerFile': 'nsGeolocation.h'
}, },

View File

@ -25,6 +25,7 @@
#include "mozilla/dom/Exceptions.h" #include "mozilla/dom/Exceptions.h"
#include "mozilla/dom/FetchDriver.h" #include "mozilla/dom/FetchDriver.h"
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
#include "mozilla/dom/FormData.h"
#include "mozilla/dom/Headers.h" #include "mozilla/dom/Headers.h"
#include "mozilla/dom/Promise.h" #include "mozilla/dom/Promise.h"
#include "mozilla/dom/PromiseWorkerProxy.h" #include "mozilla/dom/PromiseWorkerProxy.h"
@ -37,7 +38,6 @@
#include "InternalRequest.h" #include "InternalRequest.h"
#include "InternalResponse.h" #include "InternalResponse.h"
#include "nsFormData.h"
#include "WorkerPrivate.h" #include "WorkerPrivate.h"
#include "WorkerRunnable.h" #include "WorkerRunnable.h"
#include "WorkerScope.h" #include "WorkerScope.h"
@ -393,7 +393,7 @@ ExtractFromBlob(const Blob& aBlob, nsIInputStream** aStream,
} }
nsresult nsresult
ExtractFromFormData(nsFormData& aFormData, nsIInputStream** aStream, ExtractFromFormData(FormData& aFormData, nsIInputStream** aStream,
nsCString& aContentType) nsCString& aContentType)
{ {
uint64_t unusedContentLength; uint64_t unusedContentLength;
@ -468,7 +468,7 @@ ExtractByteStreamFromBody(const OwningArrayBufferOrArrayBufferViewOrBlobOrFormDa
const Blob& blob = aBodyInit.GetAsBlob(); const Blob& blob = aBodyInit.GetAsBlob();
return ExtractFromBlob(blob, aStream, aContentType); return ExtractFromBlob(blob, aStream, aContentType);
} else if (aBodyInit.IsFormData()) { } else if (aBodyInit.IsFormData()) {
nsFormData& form = aBodyInit.GetAsFormData(); FormData& form = aBodyInit.GetAsFormData();
return ExtractFromFormData(form, aStream, aContentType); return ExtractFromFormData(form, aStream, aContentType);
} else if (aBodyInit.IsUSVString()) { } else if (aBodyInit.IsUSVString()) {
nsAutoString str; nsAutoString str;
@ -500,7 +500,7 @@ ExtractByteStreamFromBody(const ArrayBufferOrArrayBufferViewOrBlobOrFormDataOrUS
const Blob& blob = aBodyInit.GetAsBlob(); const Blob& blob = aBodyInit.GetAsBlob();
return ExtractFromBlob(blob, aStream, aContentType); return ExtractFromBlob(blob, aStream, aContentType);
} else if (aBodyInit.IsFormData()) { } else if (aBodyInit.IsFormData()) {
nsFormData& form = aBodyInit.GetAsFormData(); FormData& form = aBodyInit.GetAsFormData();
return ExtractFromFormData(form, aStream, aContentType); return ExtractFromFormData(form, aStream, aContentType);
} else if (aBodyInit.IsUSVString()) { } else if (aBodyInit.IsUSVString()) {
nsAutoString str; nsAutoString str;
@ -1039,7 +1039,7 @@ FetchBody<Derived>::ContinueConsumeBody(nsresult aStatus, uint32_t aResultLength
data.Adopt(reinterpret_cast<char*>(aResult), aResultLength); data.Adopt(reinterpret_cast<char*>(aResult), aResultLength);
autoFree.Reset(); autoFree.Reset();
RefPtr<nsFormData> fd = FetchUtil::ConsumeFormData( RefPtr<dom::FormData> fd = FetchUtil::ConsumeFormData(
DerivedClass()->GetParentObject(), DerivedClass()->GetParentObject(),
mMimeType, data, error); mMimeType, data, error);
if (!error.Failed()) { if (!error.Failed()) {

View File

@ -194,7 +194,7 @@ class MOZ_STACK_CLASS FillFormIterator final
: public URLSearchParams::ForEachIterator : public URLSearchParams::ForEachIterator
{ {
public: public:
explicit FillFormIterator(nsFormData* aFormData) explicit FillFormIterator(FormData* aFormData)
: mFormData(aFormData) : mFormData(aFormData)
{ {
MOZ_ASSERT(aFormData); MOZ_ASSERT(aFormData);
@ -210,7 +210,7 @@ public:
} }
private: private:
nsFormData* mFormData; FormData* mFormData;
}; };
/** /**
@ -224,7 +224,7 @@ private:
* never return a partially filled FormData. * never return a partially filled FormData.
* The content-disposition header is used to figure out the name and filename * The content-disposition header is used to figure out the name and filename
* entries. The inclusion of the filename parameter decides if the entry is * entries. The inclusion of the filename parameter decides if the entry is
* inserted into the nsFormData as a string or a File. * inserted into the FormData as a string or a File.
* *
* File blobs are copies of the underlying data string since we cannot adopt * File blobs are copies of the underlying data string since we cannot adopt
* char* chunks embedded within the larger body without significant effort. * char* chunks embedded within the larger body without significant effort.
@ -235,7 +235,7 @@ private:
class MOZ_STACK_CLASS FormDataParser class MOZ_STACK_CLASS FormDataParser
{ {
private: private:
RefPtr<nsFormData> mFormData; RefPtr<FormData> mFormData;
nsCString mMimeType; nsCString mMimeType;
nsCString mData; nsCString mData;
@ -388,7 +388,7 @@ private:
aStart.advance(2); aStart.advance(2);
if (!mFormData) { if (!mFormData) {
mFormData = new nsFormData(); mFormData = new FormData();
} }
NS_ConvertUTF8toUTF16 name(mName); NS_ConvertUTF8toUTF16 name(mName);
@ -488,7 +488,7 @@ public:
if (start != end && *start == '-') { if (start != end && *start == '-') {
// End of data. // End of data.
if (!mFormData) { if (!mFormData) {
mFormData = new nsFormData(); mFormData = new FormData();
} }
return true; return true;
} }
@ -535,7 +535,7 @@ public:
return false; return false;
} }
already_AddRefed<nsFormData> FormData() already_AddRefed<FormData> GetFormData()
{ {
return mFormData.forget(); return mFormData.forget();
} }
@ -543,7 +543,7 @@ public:
} }
// static // static
already_AddRefed<nsFormData> already_AddRefed<FormData>
FetchUtil::ConsumeFormData(nsIGlobalObject* aParent, const nsCString& aMimeType, FetchUtil::ConsumeFormData(nsIGlobalObject* aParent, const nsCString& aMimeType,
const nsCString& aStr, ErrorResult& aRv) const nsCString& aStr, ErrorResult& aRv)
{ {
@ -564,7 +564,7 @@ FetchUtil::ConsumeFormData(nsIGlobalObject* aParent, const nsCString& aMimeType,
return nullptr; return nullptr;
} }
RefPtr<nsFormData> fd = parser.FormData(); RefPtr<FormData> fd = parser.GetFormData();
MOZ_ASSERT(fd); MOZ_ASSERT(fd);
return fd.forget(); return fd.forget();
} }
@ -580,7 +580,7 @@ FetchUtil::ConsumeFormData(nsIGlobalObject* aParent, const nsCString& aMimeType,
URLParams params; URLParams params;
params.ParseInput(aStr); params.ParseInput(aStr);
RefPtr<nsFormData> fd = new nsFormData(aParent); RefPtr<FormData> fd = new FormData(aParent);
FillFormIterator iterator(fd); FillFormIterator iterator(fd);
DebugOnly<bool> status = params.ForEach(iterator); DebugOnly<bool> status = params.ForEach(iterator);
MOZ_ASSERT(status); MOZ_ASSERT(status);

View File

@ -3,10 +3,10 @@
#include "nsString.h" #include "nsString.h"
#include "nsError.h" #include "nsError.h"
#include "nsFormData.h"
#include "mozilla/ErrorResult.h" #include "mozilla/ErrorResult.h"
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
#include "mozilla/dom/FormData.h"
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -47,7 +47,7 @@ public:
* Creates a form data object from a UTF-8 encoded |aStr|. Returns |nullptr| * Creates a form data object from a UTF-8 encoded |aStr|. Returns |nullptr|
* and sets |aRv| to MSG_BAD_FORMDATA if |aStr| contains invalid data. * and sets |aRv| to MSG_BAD_FORMDATA if |aStr| contains invalid data.
*/ */
static already_AddRefed<nsFormData> static already_AddRefed<FormData>
ConsumeFormData(nsIGlobalObject* aParent, const nsCString& aMimeType, ConsumeFormData(nsIGlobalObject* aParent, const nsCString& aMimeType,
const nsCString& aStr, ErrorResult& aRv); const nsCString& aStr, ErrorResult& aRv);

View File

@ -36,6 +36,7 @@
#include "nsQueryObject.h" #include "nsQueryObject.h"
// form submission // form submission
#include "mozilla/dom/FormData.h"
#include "mozilla/Telemetry.h" #include "mozilla/Telemetry.h"
#include "nsIFormSubmitObserver.h" #include "nsIFormSubmitObserver.h"
#include "nsIObserverService.h" #include "nsIObserverService.h"
@ -49,7 +50,6 @@
#include "nsIInterfaceRequestorUtils.h" #include "nsIInterfaceRequestorUtils.h"
#include "nsIWebProgress.h" #include "nsIWebProgress.h"
#include "nsIDocShell.h" #include "nsIDocShell.h"
#include "nsFormData.h"
#include "nsFormSubmissionConstants.h" #include "nsFormSubmissionConstants.h"
#include "nsIPrompt.h" #include "nsIPrompt.h"
#include "nsISecurityUITelemetry.h" #include "nsISecurityUITelemetry.h"

View File

@ -16,11 +16,11 @@
#include "mozilla/ArrayUtils.h" #include "mozilla/ArrayUtils.h"
#include "mozilla/dom/Exceptions.h" #include "mozilla/dom/Exceptions.h"
#include "mozilla/dom/File.h" #include "mozilla/dom/File.h"
#include "mozilla/dom/FormData.h"
#include "mozilla/dom/ProgressEvent.h" #include "mozilla/dom/ProgressEvent.h"
#include "mozilla/dom/StructuredCloneHolder.h" #include "mozilla/dom/StructuredCloneHolder.h"
#include "nsComponentManagerUtils.h" #include "nsComponentManagerUtils.h"
#include "nsContentUtils.h" #include "nsContentUtils.h"
#include "nsFormData.h"
#include "nsJSUtils.h" #include "nsJSUtils.h"
#include "nsThreadUtils.h" #include "nsThreadUtils.h"
#include "nsVariant.h" #include "nsVariant.h"
@ -2203,7 +2203,7 @@ XMLHttpRequest::Send(Blob& aBody, ErrorResult& aRv)
} }
void void
XMLHttpRequest::Send(nsFormData& aBody, ErrorResult& aRv) XMLHttpRequest::Send(FormData& aBody, ErrorResult& aRv)
{ {
mWorkerPrivate->AssertIsOnWorkerThread(); mWorkerPrivate->AssertIsOnWorkerThread();
JSContext* cx = mWorkerPrivate->GetJSContext(); JSContext* cx = mWorkerPrivate->GetJSContext();

View File

@ -174,7 +174,7 @@ public:
Send(Blob& aBody, ErrorResult& aRv); Send(Blob& aBody, ErrorResult& aRv);
void void
Send(nsFormData& aBody, ErrorResult& aRv); Send(FormData& aBody, ErrorResult& aRv);
void void
Send(const ArrayBuffer& aBody, ErrorResult& aRv); Send(const ArrayBuffer& aBody, ErrorResult& aRv);

View File

@ -67,7 +67,7 @@
// view stuff // view stuff
#include "nsContentCreatorFunctions.h" #include "nsContentCreatorFunctions.h"
#include "nsFormData.h" #include "mozilla/dom/FormData.h"
#include "nsHostObjectProtocolHandler.h" #include "nsHostObjectProtocolHandler.h"
#include "nsHostObjectURI.h" #include "nsHostObjectURI.h"
#include "nsGlobalWindowCommands.h" #include "nsGlobalWindowCommands.h"
@ -299,7 +299,7 @@ NS_GENERIC_FACTORY_CONSTRUCTOR(XPathEvaluator)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(txNodeSetAdaptor, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(txNodeSetAdaptor, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMSerializer) NS_GENERIC_FACTORY_CONSTRUCTOR(nsDOMSerializer)
NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsXMLHttpRequest, Init) NS_GENERIC_FACTORY_CONSTRUCTOR_INIT(nsXMLHttpRequest, Init)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsFormData) NS_GENERIC_FACTORY_CONSTRUCTOR(FormData)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlobProtocolHandler) NS_GENERIC_FACTORY_CONSTRUCTOR(nsBlobProtocolHandler)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMediaStreamProtocolHandler) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMediaStreamProtocolHandler)
NS_GENERIC_FACTORY_CONSTRUCTOR(nsMediaSourceProtocolHandler) NS_GENERIC_FACTORY_CONSTRUCTOR(nsMediaSourceProtocolHandler)
@ -1054,7 +1054,7 @@ static const mozilla::Module::CIDEntry kLayoutCIDs[] = {
{ &kTRANSFORMIIX_XPATH_EVALUATOR_CID, false, nullptr, XPathEvaluatorConstructor }, { &kTRANSFORMIIX_XPATH_EVALUATOR_CID, false, nullptr, XPathEvaluatorConstructor },
{ &kTRANSFORMIIX_NODESET_CID, false, nullptr, txNodeSetAdaptorConstructor }, { &kTRANSFORMIIX_NODESET_CID, false, nullptr, txNodeSetAdaptorConstructor },
{ &kNS_XMLSERIALIZER_CID, false, nullptr, nsDOMSerializerConstructor }, { &kNS_XMLSERIALIZER_CID, false, nullptr, nsDOMSerializerConstructor },
{ &kNS_FORMDATA_CID, false, nullptr, nsFormDataConstructor }, { &kNS_FORMDATA_CID, false, nullptr, FormDataConstructor },
{ &kNS_BLOBPROTOCOLHANDLER_CID, false, nullptr, nsBlobProtocolHandlerConstructor }, { &kNS_BLOBPROTOCOLHANDLER_CID, false, nullptr, nsBlobProtocolHandlerConstructor },
{ &kNS_MEDIASTREAMPROTOCOLHANDLER_CID, false, nullptr, nsMediaStreamProtocolHandlerConstructor }, { &kNS_MEDIASTREAMPROTOCOLHANDLER_CID, false, nullptr, nsMediaStreamProtocolHandlerConstructor },
{ &kNS_MEDIASOURCEPROTOCOLHANDLER_CID, false, nullptr, nsMediaSourceProtocolHandlerConstructor }, { &kNS_MEDIASOURCEPROTOCOLHANDLER_CID, false, nullptr, nsMediaSourceProtocolHandlerConstructor },