mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-31 11:37:30 +09:00
moebius#140: Fix: Fetch - headers should sort and combine
https://github.com/MoonchildProductions/moebius/pull/140
This commit is contained in:
parent
a3fc13a8fc
commit
f70e3223fb
4 changed files with 86 additions and 27 deletions
|
|
@ -45,14 +45,23 @@ private:
|
|||
HeadersGuardEnum mGuard;
|
||||
nsTArray<Entry> mList;
|
||||
|
||||
nsTArray<Entry> mSortedList;
|
||||
|
||||
// This boolean is set to true at any writing operation to mList. It's set to
|
||||
// false when mSortedList is regenerated. This happens when the header is
|
||||
// iterated.
|
||||
bool mListDirty;
|
||||
|
||||
public:
|
||||
explicit InternalHeaders(HeadersGuardEnum aGuard = HeadersGuardEnum::None)
|
||||
: mGuard(aGuard)
|
||||
, mListDirty(false)
|
||||
{
|
||||
}
|
||||
|
||||
explicit InternalHeaders(const InternalHeaders& aOther)
|
||||
: mGuard(HeadersGuardEnum::None)
|
||||
, mListDirty(true)
|
||||
{
|
||||
ErrorResult result;
|
||||
Fill(aOther, result);
|
||||
|
|
@ -79,19 +88,22 @@ public:
|
|||
bool Has(const nsACString& aName, ErrorResult& aRv) const;
|
||||
void Set(const nsACString& aName, const nsACString& aValue, ErrorResult& aRv);
|
||||
|
||||
uint32_t GetIterableLength() const
|
||||
uint32_t GetIterableLength()
|
||||
{
|
||||
return mList.Length();
|
||||
MaybeSortList();
|
||||
return mSortedList.Length();
|
||||
}
|
||||
const NS_ConvertASCIItoUTF16 GetKeyAtIndex(unsigned aIndex) const
|
||||
const NS_ConvertASCIItoUTF16 GetKeyAtIndex(unsigned aIndex)
|
||||
{
|
||||
MOZ_ASSERT(aIndex < mList.Length());
|
||||
return NS_ConvertASCIItoUTF16(mList[aIndex].mName);
|
||||
MaybeSortList();
|
||||
MOZ_ASSERT(aIndex < mSortedList.Length());
|
||||
return NS_ConvertASCIItoUTF16(mSortedList[aIndex].mName);
|
||||
}
|
||||
const NS_ConvertASCIItoUTF16 GetValueAtIndex(unsigned aIndex) const
|
||||
const NS_ConvertASCIItoUTF16 GetValueAtIndex(unsigned aIndex)
|
||||
{
|
||||
MOZ_ASSERT(aIndex < mList.Length());
|
||||
return NS_ConvertASCIItoUTF16(mList[aIndex].mValue);
|
||||
MaybeSortList();
|
||||
MOZ_ASSERT(aIndex < mSortedList.Length());
|
||||
return NS_ConvertASCIItoUTF16(mSortedList[aIndex].mValue);
|
||||
}
|
||||
|
||||
void Clear();
|
||||
|
|
@ -152,6 +164,9 @@ private:
|
|||
const nsACString& aValue);
|
||||
|
||||
static bool IsRevalidationHeader(const nsACString& aName);
|
||||
|
||||
void MaybeSortList();
|
||||
void SetListDirty();
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue