From 5a10462a92197769cc7af04287c6315fa8961dcd Mon Sep 17 00:00:00 2001 From: JustOff Date: Wed, 13 Mar 2019 18:46:01 +0200 Subject: Change the MozMap API and data storage to more what we want record<> to look like --- dom/fetch/InternalHeaders.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'dom/fetch') diff --git a/dom/fetch/InternalHeaders.cpp b/dom/fetch/InternalHeaders.cpp index 11585615e..83a686785 100644 --- a/dom/fetch/InternalHeaders.cpp +++ b/dom/fetch/InternalHeaders.cpp @@ -316,10 +316,11 @@ InternalHeaders::Fill(const Sequence>& aInit, ErrorResult& a void InternalHeaders::Fill(const MozMap& aInit, ErrorResult& aRv) { - nsTArray 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(NS_ConvertUTF16toUTF8(entry.mKey), entry.mValue, aRv); + if (aRv.Failed()) { + return; + } } } -- cgit v1.2.3 From 5890367d30702ff8f2fbb6fc28e6ecdd6d5b2b84 Mon Sep 17 00:00:00 2001 From: JustOff Date: Wed, 13 Mar 2019 19:37:03 +0200 Subject: Rename "MozMap" to "record" in our IDL parser and IDL files --- dom/fetch/Headers.cpp | 14 +++++++------- dom/fetch/Headers.h | 10 +++++----- 2 files changed, 12 insertions(+), 12 deletions(-) (limited to 'dom/fetch') 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::Constructor(const GlobalObject& aGlobal, - const Optional& aInit, + const Optional& aInit, ErrorResult& aRv) { RefPtr 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::Constructor(const GlobalObject& aGlobal, - const OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap& aInit, + const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aInit, ErrorResult& aRv) { nsCOMPtr global = do_QueryInterface(aGlobal.GetAsSupports()); @@ -62,7 +62,7 @@ Headers::Constructor(const GlobalObject& aGlobal, /* static */ already_AddRefed Headers::Create(nsIGlobalObject* aGlobal, - const OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap& aInit, + const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aInit, ErrorResult& aRv) { RefPtr 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..38b0fc68f 100644 --- a/dom/fetch/Headers.h +++ b/dom/fetch/Headers.h @@ -21,8 +21,8 @@ class ErrorResult; namespace dom { template class MozMap; -class HeadersOrByteStringSequenceSequenceOrByteStringMozMap; -class OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap; +class HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord; +class OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord; /** * This Headers class is only used to represent the content facing Headers @@ -57,17 +57,17 @@ public: static already_AddRefed Constructor(const GlobalObject& aGlobal, - const Optional& aInit, + const Optional& aInit, ErrorResult& aRv); static already_AddRefed Constructor(const GlobalObject& aGlobal, - const OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap& aInit, + const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aInit, ErrorResult& aRv); static already_AddRefed Create(nsIGlobalObject* aGlobalObject, - const OwningHeadersOrByteStringSequenceSequenceOrByteStringMozMap& aInit, + const OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord& aInit, ErrorResult& aRv); void Append(const nsACString& aName, const nsACString& aValue, -- cgit v1.2.3 From b586a191ec085d2c6c5c4fdfb1b12102fb5de4c4 Mon Sep 17 00:00:00 2001 From: JustOff Date: Wed, 13 Mar 2019 20:04:13 +0200 Subject: Rename the MozMap C++ type to "record" and give it a template parameter for the key type --- dom/fetch/Headers.h | 2 +- dom/fetch/InternalHeaders.cpp | 2 +- dom/fetch/InternalHeaders.h | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) (limited to 'dom/fetch') diff --git a/dom/fetch/Headers.h b/dom/fetch/Headers.h index 38b0fc68f..1dd92f779 100644 --- a/dom/fetch/Headers.h +++ b/dom/fetch/Headers.h @@ -20,7 +20,7 @@ class ErrorResult; namespace dom { -template class MozMap; +template class Record; class HeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord; class OwningHeadersOrByteStringSequenceSequenceOrByteStringByteStringRecord; diff --git a/dom/fetch/InternalHeaders.cpp b/dom/fetch/InternalHeaders.cpp index 83a686785..7bf5703dc 100644 --- a/dom/fetch/InternalHeaders.cpp +++ b/dom/fetch/InternalHeaders.cpp @@ -314,7 +314,7 @@ InternalHeaders::Fill(const Sequence>& aInit, ErrorResult& a } void -InternalHeaders::Fill(const MozMap& aInit, ErrorResult& aRv) +InternalHeaders::Fill(const Record& aInit, ErrorResult& aRv) { for (auto& entry : aInit.Entries()) { Append(NS_ConvertUTF16toUTF8(entry.mKey), entry.mValue, aRv); 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 class MozMap; +template class Record; class HeadersEntry; class InternalHeaders final @@ -113,7 +113,7 @@ public: void Fill(const InternalHeaders& aInit, ErrorResult& aRv); void Fill(const Sequence>& aInit, ErrorResult& aRv); - void Fill(const MozMap& aInit, ErrorResult& aRv); + void Fill(const Record& aInit, ErrorResult& aRv); bool HasOnlySimpleHeaders() const; -- cgit v1.2.3 From e7c9fa3e1505aeb90385e0a4e90fe5e0b137d4ab Mon Sep 17 00:00:00 2001 From: JustOff Date: Wed, 13 Mar 2019 20:17:36 +0200 Subject: Actually change the key type of a record, and its corresponding conversion behavior, depending on what the IDL says --- dom/fetch/InternalHeaders.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'dom/fetch') diff --git a/dom/fetch/InternalHeaders.cpp b/dom/fetch/InternalHeaders.cpp index 7bf5703dc..f66221d42 100644 --- a/dom/fetch/InternalHeaders.cpp +++ b/dom/fetch/InternalHeaders.cpp @@ -317,7 +317,7 @@ void InternalHeaders::Fill(const Record& aInit, ErrorResult& aRv) { for (auto& entry : aInit.Entries()) { - Append(NS_ConvertUTF16toUTF8(entry.mKey), entry.mValue, aRv); + Append(entry.mKey, entry.mValue, aRv); if (aRv.Failed()) { return; } -- cgit v1.2.3