diff options
author | Moonchild <mcwerewolf@wolfbeast.com> | 2019-03-14 15:21:42 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-03-14 15:21:42 +0100 |
commit | 91cbd86a5e0e851904015fc98f3b4bb4422e584b (patch) | |
tree | 603ad2d101065a622db1d02c0f0603a0fdfcea51 /dom/fetch | |
parent | d791dfed61bbc963351e5965657a3b13d4e6dceb (diff) | |
parent | 0ff4dbff80ddea637b0fb02c885e222ddcfa171a (diff) | |
download | UXP-91cbd86a5e0e851904015fc98f3b4bb4422e584b.tar UXP-91cbd86a5e0e851904015fc98f3b4bb4422e584b.tar.gz UXP-91cbd86a5e0e851904015fc98f3b4bb4422e584b.tar.lz UXP-91cbd86a5e0e851904015fc98f3b4bb4422e584b.tar.xz UXP-91cbd86a5e0e851904015fc98f3b4bb4422e584b.zip |
Merge pull request #1002 from JustOff/PR_URLSearchParams
Align URLSearchParams with the spec
Diffstat (limited to 'dom/fetch')
-rw-r--r-- | dom/fetch/Headers.cpp | 14 | ||||
-rw-r--r-- | dom/fetch/Headers.h | 12 | ||||
-rw-r--r-- | dom/fetch/InternalHeaders.cpp | 11 | ||||
-rw-r--r-- | dom/fetch/InternalHeaders.h | 4 |
4 files changed, 21 insertions, 20 deletions
diff --git a/dom/fetch/Headers.cpp b/dom/fetch/Headers.cpp index 1e1a46c62..ca5aa57a6 100644 --- a/dom/fetch/Headers.cpp +++ b/dom/fetch/Headers.cpp @@ -25,7 +25,7 @@ NS_INTERFACE_MAP_END // static already_AddRefed<Headers> Headers::Constructor(const GlobalObject& aGlobal, - const Optional<HeadersOrByteStringSequenceSequenceOrByteStringMozMap>& aInit, + const Optional<HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord>& aInit, ErrorResult& aRv) { RefPtr<InternalHeaders> ih = new InternalHeaders(); @@ -39,8 +39,8 @@ Headers::Constructor(const GlobalObject& aGlobal, ih->Fill(*aInit.Value().GetAsHeaders().mInternalHeaders, aRv); } else if (aInit.Value().IsByteStringSequenceSequence()) { ih->Fill(aInit.Value().GetAsByteStringSequenceSequence(), aRv); - } else if (aInit.Value().IsByteStringMozMap()) { - ih->Fill(aInit.Value().GetAsByteStringMozMap(), aRv); + } else if (aInit.Value().IsByteStringByteStringRecord()) { + ih->Fill(aInit.Value().GetAsByteStringByteStringRecord(), aRv); } if (aRv.Failed()) { @@ -53,7 +53,7 @@ Headers::Constructor(const GlobalObject& aGlobal, // static already_AddRefed<Headers> Headers::Constructor(const GlobalObject& aGlobal, - const OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap& aInit, + const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aInit, ErrorResult& aRv) { nsCOMPtr<nsIGlobalObject> global = do_QueryInterface(aGlobal.GetAsSupports()); @@ -62,7 +62,7 @@ Headers::Constructor(const GlobalObject& aGlobal, /* static */ already_AddRefed<Headers> Headers::Create(nsIGlobalObject* aGlobal, - const OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap& aInit, + const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aInit, ErrorResult& aRv) { RefPtr<InternalHeaders> ih = new InternalHeaders(); @@ -72,8 +72,8 @@ Headers::Create(nsIGlobalObject* aGlobal, ih->Fill(*(aInit.GetAsHeaders().get()->mInternalHeaders), aRv); } else if (aInit.IsByteStringSequenceSequence()) { ih->Fill(aInit.GetAsByteStringSequenceSequence(), aRv); - } else if (aInit.IsByteStringMozMap()) { - ih->Fill(aInit.GetAsByteStringMozMap(), aRv); + } else if (aInit.IsByteStringByteStringRecord()) { + ih->Fill(aInit.GetAsByteStringByteStringRecord(), aRv); } if (NS_WARN_IF(aRv.Failed())) { diff --git a/dom/fetch/Headers.h b/dom/fetch/Headers.h index b603dc836..1dd92f779 100644 --- a/dom/fetch/Headers.h +++ b/dom/fetch/Headers.h @@ -20,9 +20,9 @@ class ErrorResult; namespace dom { -template<typename T> class MozMap; -class HeadersOrByteStringSequenceSequenceOrByteStringMozMap; -class OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap; +template<typename K, typename V> class Record; +class HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord; +class OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord; /** * This Headers class is only used to represent the content facing Headers @@ -57,17 +57,17 @@ public: static already_AddRefed<Headers> Constructor(const GlobalObject& aGlobal, - const Optional<HeadersOrByteStringSequenceSequenceOrByteStringMozMap>& aInit, + const Optional<HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord>& aInit, ErrorResult& aRv); static already_AddRefed<Headers> Constructor(const GlobalObject& aGlobal, - const OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap& aInit, + const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aInit, ErrorResult& aRv); static already_AddRefed<Headers> Create(nsIGlobalObject* aGlobalObject, - const OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap& aInit, + const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aInit, ErrorResult& aRv); void Append(const nsACString& aName, const nsACString& aValue, diff --git a/dom/fetch/InternalHeaders.cpp b/dom/fetch/InternalHeaders.cpp index 11585615e..f66221d42 100644 --- a/dom/fetch/InternalHeaders.cpp +++ b/dom/fetch/InternalHeaders.cpp @@ -314,12 +314,13 @@ InternalHeaders::Fill(const Sequence<Sequence<nsCString>>& aInit, ErrorResult& a } void -InternalHeaders::Fill(const MozMap<nsCString>& aInit, ErrorResult& aRv) +InternalHeaders::Fill(const Record<nsCString, nsCString>& aInit, ErrorResult& aRv) { - nsTArray<nsString> keys; - aInit.GetKeys(keys); - for (uint32_t i = 0; i < keys.Length() && !aRv.Failed(); ++i) { - Append(NS_ConvertUTF16toUTF8(keys[i]), aInit.Get(keys[i]), aRv); + for (auto& entry : aInit.Entries()) { + Append(entry.mKey, entry.mValue, aRv); + if (aRv.Failed()) { + return; + } } } diff --git a/dom/fetch/InternalHeaders.h b/dom/fetch/InternalHeaders.h index 9a6d6dae7..98046f0ef 100644 --- a/dom/fetch/InternalHeaders.h +++ b/dom/fetch/InternalHeaders.h @@ -20,7 +20,7 @@ class ErrorResult; namespace dom { -template<typename T> class MozMap; +template<typename K, typename V> class Record; class HeadersEntry; class InternalHeaders final @@ -113,7 +113,7 @@ public: void Fill(const InternalHeaders& aInit, ErrorResult& aRv); void Fill(const Sequence<Sequence<nsCString>>& aInit, ErrorResult& aRv); - void Fill(const MozMap<nsCString>& aInit, ErrorResult& aRv); + void Fill(const Record<nsCString, nsCString>& aInit, ErrorResult& aRv); bool HasOnlySimpleHeaders() const; |