2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-12-12 23:30:10 +04:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* 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/. */
|
|
|
|
|
|
|
|
#include "URLSearchParams.h"
|
|
|
|
#include "mozilla/dom/URLSearchParamsBinding.h"
|
2014-08-08 04:45:14 +04:00
|
|
|
#include "mozilla/dom/EncodingUtils.h"
|
2014-10-07 12:06:00 +04:00
|
|
|
#include "nsDOMString.h"
|
2013-12-12 23:30:10 +04:00
|
|
|
|
|
|
|
namespace mozilla {
|
|
|
|
namespace dom {
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
bool
|
|
|
|
URLParams::Has(const nsAString& aName)
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
for (uint32_t i = 0, len = mParams.Length(); i < len; ++i) {
|
|
|
|
if (mParams[i].mKey.Equals(aName)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
return false;
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
void
|
|
|
|
URLParams::Get(const nsAString& aName, nsString& aRetval)
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
SetDOMStringToNull(aRetval);
|
|
|
|
|
|
|
|
for (uint32_t i = 0, len = mParams.Length(); i < len; ++i) {
|
|
|
|
if (mParams[i].mKey.Equals(aName)) {
|
|
|
|
aRetval.Assign(mParams[i].mValue);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
void
|
|
|
|
URLParams::GetAll(const nsAString& aName, nsTArray<nsString>& aRetval)
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
aRetval.Clear();
|
|
|
|
|
|
|
|
for (uint32_t i = 0, len = mParams.Length(); i < len; ++i) {
|
|
|
|
if (mParams[i].mKey.Equals(aName)) {
|
|
|
|
aRetval.AppendElement(mParams[i].mValue);
|
|
|
|
}
|
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
void
|
|
|
|
URLParams::Append(const nsAString& aName, const nsAString& aValue)
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
Param* param = mParams.AppendElement();
|
|
|
|
param->mKey = aName;
|
|
|
|
param->mValue = aValue;
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-04 23:45:24 +03:00
|
|
|
URLParams::Set(const nsAString& aName, const nsAString& aValue)
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
Param* param = nullptr;
|
|
|
|
for (uint32_t i = 0, len = mParams.Length(); i < len;) {
|
|
|
|
if (!mParams[i].mKey.Equals(aName)) {
|
|
|
|
++i;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!param) {
|
|
|
|
param = &mParams[i];
|
|
|
|
++i;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
// Remove duplicates.
|
|
|
|
mParams.RemoveElementAt(i);
|
|
|
|
--len;
|
|
|
|
}
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
if (!param) {
|
|
|
|
param = mParams.AppendElement();
|
|
|
|
param->mKey = aName;
|
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
param->mValue = aValue;
|
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
bool
|
|
|
|
URLParams::Delete(const nsAString& aName)
|
|
|
|
{
|
|
|
|
bool found = false;
|
|
|
|
for (uint32_t i = 0; i < mParams.Length();) {
|
|
|
|
if (mParams[i].mKey.Equals(aName)) {
|
|
|
|
mParams.RemoveElementAt(i);
|
|
|
|
found = true;
|
2013-12-12 23:30:10 +04:00
|
|
|
} else {
|
2015-06-04 23:45:24 +03:00
|
|
|
++i;
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
2015-06-04 23:45:24 +03:00
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
return found;
|
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
void
|
|
|
|
URLParams::ConvertString(const nsACString& aInput, nsAString& aOutput)
|
|
|
|
{
|
|
|
|
aOutput.Truncate();
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
if (!mDecoder) {
|
|
|
|
mDecoder = EncodingUtils::DecoderForEncoding("UTF-8");
|
|
|
|
if (!mDecoder) {
|
|
|
|
MOZ_ASSERT(mDecoder, "Failed to create a decoder.");
|
|
|
|
return;
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
2015-06-04 23:45:24 +03:00
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
int32_t inputLength = aInput.Length();
|
|
|
|
int32_t outputLength = 0;
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
nsresult rv = mDecoder->GetMaxLength(aInput.BeginReading(), inputLength,
|
|
|
|
&outputLength);
|
|
|
|
if (NS_WARN_IF(NS_FAILED(rv))) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!aOutput.SetLength(outputLength, fallible)) {
|
|
|
|
return;
|
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
int32_t newOutputLength = outputLength;
|
|
|
|
rv = mDecoder->Convert(aInput.BeginReading(), &inputLength,
|
|
|
|
aOutput.BeginWriting(), &newOutputLength);
|
|
|
|
if (NS_FAILED(rv)) {
|
|
|
|
aOutput.Truncate();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
if (newOutputLength < outputLength) {
|
|
|
|
aOutput.Truncate(newOutputLength);
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-04 23:45:24 +03:00
|
|
|
URLParams::DecodeString(const nsACString& aInput, nsAString& aOutput)
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2013-12-12 23:30:27 +04:00
|
|
|
nsACString::const_iterator start, end;
|
2013-12-12 23:30:10 +04:00
|
|
|
aInput.BeginReading(start);
|
|
|
|
aInput.EndReading(end);
|
|
|
|
|
2014-08-08 04:45:14 +04:00
|
|
|
nsCString unescaped;
|
|
|
|
|
2013-12-12 23:30:10 +04:00
|
|
|
while (start != end) {
|
|
|
|
// replace '+' with U+0020
|
|
|
|
if (*start == '+') {
|
2014-08-08 04:45:14 +04:00
|
|
|
unescaped.Append(' ');
|
2013-12-12 23:30:10 +04:00
|
|
|
++start;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Percent decode algorithm
|
|
|
|
if (*start == '%') {
|
2013-12-12 23:30:27 +04:00
|
|
|
nsACString::const_iterator first(start);
|
2013-12-12 23:30:10 +04:00
|
|
|
++first;
|
|
|
|
|
2013-12-12 23:30:27 +04:00
|
|
|
nsACString::const_iterator second(first);
|
2013-12-12 23:30:10 +04:00
|
|
|
++second;
|
|
|
|
|
|
|
|
#define ASCII_HEX_DIGIT( x ) \
|
|
|
|
((x >= 0x41 && x <= 0x46) || \
|
|
|
|
(x >= 0x61 && x <= 0x66) || \
|
|
|
|
(x >= 0x30 && x <= 0x39))
|
|
|
|
|
|
|
|
#define HEX_DIGIT( x ) \
|
|
|
|
(*x >= 0x30 && *x <= 0x39 \
|
|
|
|
? *x - 0x30 \
|
|
|
|
: (*x >= 0x41 && *x <= 0x46 \
|
|
|
|
? *x - 0x37 \
|
|
|
|
: *x - 0x57))
|
|
|
|
|
|
|
|
if (first != end && second != end &&
|
|
|
|
ASCII_HEX_DIGIT(*first) && ASCII_HEX_DIGIT(*second)) {
|
2014-08-08 04:45:14 +04:00
|
|
|
unescaped.Append(HEX_DIGIT(first) * 16 + HEX_DIGIT(second));
|
2013-12-12 23:30:10 +04:00
|
|
|
start = ++second;
|
|
|
|
continue;
|
|
|
|
|
|
|
|
} else {
|
2014-08-08 04:45:14 +04:00
|
|
|
unescaped.Append('%');
|
2013-12-12 23:30:10 +04:00
|
|
|
++start;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-08-08 04:45:14 +04:00
|
|
|
unescaped.Append(*start);
|
2013-12-12 23:30:10 +04:00
|
|
|
++start;
|
|
|
|
}
|
2014-08-08 04:45:14 +04:00
|
|
|
|
|
|
|
ConvertString(unescaped, aOutput);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-04 23:45:24 +03:00
|
|
|
URLParams::ParseInput(const nsACString& aInput)
|
2014-08-08 04:45:14 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
// Remove all the existing data before parsing a new input.
|
|
|
|
DeleteAll();
|
2014-08-08 04:45:14 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
nsACString::const_iterator start, end;
|
|
|
|
aInput.BeginReading(start);
|
|
|
|
aInput.EndReading(end);
|
|
|
|
nsACString::const_iterator iter(start);
|
|
|
|
|
|
|
|
while (start != end) {
|
|
|
|
nsAutoCString string;
|
|
|
|
|
|
|
|
if (FindCharInReadable('&', iter, end)) {
|
|
|
|
string.Assign(Substring(start, iter));
|
|
|
|
start = ++iter;
|
|
|
|
} else {
|
|
|
|
string.Assign(Substring(start, end));
|
|
|
|
start = end;
|
2014-08-08 04:45:14 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
if (string.IsEmpty()) {
|
|
|
|
continue;
|
|
|
|
}
|
2014-08-08 04:45:14 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
nsACString::const_iterator eqStart, eqEnd;
|
|
|
|
string.BeginReading(eqStart);
|
|
|
|
string.EndReading(eqEnd);
|
|
|
|
nsACString::const_iterator eqIter(eqStart);
|
2014-08-08 04:45:14 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
nsAutoCString name;
|
|
|
|
nsAutoCString value;
|
2014-08-08 04:45:14 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
if (FindCharInReadable('=', eqIter, eqEnd)) {
|
|
|
|
name.Assign(Substring(eqStart, eqIter));
|
2014-08-09 01:41:00 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
++eqIter;
|
|
|
|
value.Assign(Substring(eqIter, eqEnd));
|
|
|
|
} else {
|
|
|
|
name.Assign(string);
|
|
|
|
}
|
|
|
|
|
|
|
|
nsAutoString decodedName;
|
|
|
|
DecodeString(name, decodedName);
|
|
|
|
|
|
|
|
nsAutoString decodedValue;
|
|
|
|
DecodeString(value, decodedValue);
|
|
|
|
|
|
|
|
Append(decodedName, decodedValue);
|
2014-08-08 04:45:14 +04:00
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
namespace {
|
|
|
|
|
|
|
|
void SerializeString(const nsCString& aInput, nsAString& aValue)
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
const unsigned char* p = (const unsigned char*) aInput.get();
|
2015-11-16 21:29:55 +03:00
|
|
|
const unsigned char* end = p + aInput.Length();
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-11-16 21:29:55 +03:00
|
|
|
while (p != end) {
|
2015-06-04 23:45:24 +03:00
|
|
|
// ' ' to '+'
|
|
|
|
if (*p == 0x20) {
|
|
|
|
aValue.Append(0x2B);
|
|
|
|
// Percent Encode algorithm
|
|
|
|
} else if (*p == 0x2A || *p == 0x2D || *p == 0x2E ||
|
|
|
|
(*p >= 0x30 && *p <= 0x39) ||
|
|
|
|
(*p >= 0x41 && *p <= 0x5A) || *p == 0x5F ||
|
|
|
|
(*p >= 0x61 && *p <= 0x7A)) {
|
|
|
|
aValue.Append(*p);
|
|
|
|
} else {
|
|
|
|
aValue.AppendPrintf("%%%.2X", *p);
|
2014-10-01 17:55:33 +04:00
|
|
|
}
|
2015-06-04 23:45:24 +03:00
|
|
|
|
|
|
|
++p;
|
2014-10-01 17:55:33 +04:00
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
|
2015-07-13 18:25:42 +03:00
|
|
|
} // namespace
|
2015-06-04 23:45:24 +03:00
|
|
|
|
2013-12-12 23:30:10 +04:00
|
|
|
void
|
2015-06-04 23:45:24 +03:00
|
|
|
URLParams::Serialize(nsAString& aValue) const
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
aValue.Truncate();
|
|
|
|
bool first = true;
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
for (uint32_t i = 0, len = mParams.Length(); i < len; ++i) {
|
|
|
|
if (first) {
|
|
|
|
first = false;
|
|
|
|
} else {
|
|
|
|
aValue.Append('&');
|
2014-10-01 17:55:33 +04:00
|
|
|
}
|
2015-06-04 23:45:24 +03:00
|
|
|
|
|
|
|
SerializeString(NS_ConvertUTF16toUTF8(mParams[i].mKey), aValue);
|
|
|
|
aValue.Append('=');
|
|
|
|
SerializeString(NS_ConvertUTF16toUTF8(mParams[i].mValue), aValue);
|
2014-10-01 17:55:33 +04:00
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
|
2015-06-29 19:02:53 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(URLSearchParams, mParent, mObserver)
|
2015-06-04 23:45:24 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(URLSearchParams)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(URLSearchParams)
|
2014-10-01 17:55:33 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(URLSearchParams)
|
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_END
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2015-06-29 19:02:53 +03:00
|
|
|
URLSearchParams::URLSearchParams(nsISupports* aParent,
|
|
|
|
URLSearchParamsObserver* aObserver)
|
|
|
|
: mParams(new URLParams())
|
|
|
|
, mParent(aParent)
|
|
|
|
, mObserver(aObserver)
|
2015-06-04 23:45:24 +03:00
|
|
|
{
|
|
|
|
}
|
2014-10-01 17:55:33 +04:00
|
|
|
|
2015-06-29 19:02:53 +03:00
|
|
|
URLSearchParams::URLSearchParams(nsISupports* aParent,
|
|
|
|
const URLSearchParams& aOther)
|
|
|
|
: mParams(new URLParams(*aOther.mParams.get()))
|
|
|
|
, mParent(aParent)
|
2015-11-16 21:29:57 +03:00
|
|
|
, mObserver(nullptr)
|
2015-06-04 23:45:24 +03:00
|
|
|
{
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
URLSearchParams::~URLSearchParams()
|
2013-12-12 23:30:27 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
DeleteAll();
|
2013-12-12 23:30:27 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
JSObject*
|
|
|
|
URLSearchParams::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
return URLSearchParamsBinding::Wrap(aCx, this, aGivenProto);
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
/* static */ already_AddRefed<URLSearchParams>
|
|
|
|
URLSearchParams::Constructor(const GlobalObject& aGlobal,
|
|
|
|
const nsAString& aInit,
|
|
|
|
ErrorResult& aRv)
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<URLSearchParams> sp =
|
2015-06-29 19:02:53 +03:00
|
|
|
new URLSearchParams(aGlobal.GetAsSupports(), nullptr);
|
2015-06-04 23:45:24 +03:00
|
|
|
sp->ParseInput(NS_ConvertUTF16toUTF8(aInit));
|
2015-06-29 19:02:53 +03:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
return sp.forget();
|
|
|
|
}
|
2014-10-01 17:55:33 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
/* static */ already_AddRefed<URLSearchParams>
|
|
|
|
URLSearchParams::Constructor(const GlobalObject& aGlobal,
|
|
|
|
URLSearchParams& aInit,
|
|
|
|
ErrorResult& aRv)
|
|
|
|
{
|
2015-10-18 08:24:48 +03:00
|
|
|
RefPtr<URLSearchParams> sp =
|
2015-06-29 19:02:53 +03:00
|
|
|
new URLSearchParams(aGlobal.GetAsSupports(), aInit);
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
return sp.forget();
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-04 23:45:24 +03:00
|
|
|
URLSearchParams::ParseInput(const nsACString& aInput)
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
mParams->ParseInput(aInput);
|
|
|
|
}
|
2013-12-12 23:30:10 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
void
|
|
|
|
URLSearchParams::Get(const nsAString& aName, nsString& aRetval)
|
|
|
|
{
|
|
|
|
return mParams->Get(aName, aRetval);
|
2013-12-12 23:30:27 +04:00
|
|
|
}
|
|
|
|
|
2013-12-12 23:30:10 +04:00
|
|
|
void
|
2015-06-04 23:45:24 +03:00
|
|
|
URLSearchParams::GetAll(const nsAString& aName, nsTArray<nsString>& aRetval)
|
2013-12-12 23:30:10 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
return mParams->GetAll(aName, aRetval);
|
2013-12-12 23:30:10 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
void
|
|
|
|
URLSearchParams::Set(const nsAString& aName, const nsAString& aValue)
|
|
|
|
{
|
|
|
|
mParams->Set(aName, aValue);
|
|
|
|
NotifyObserver();
|
|
|
|
}
|
2013-12-12 23:30:27 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
void
|
|
|
|
URLSearchParams::Append(const nsAString& aName, const nsAString& aValue)
|
2014-10-01 17:55:33 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
mParams->Append(aName, aValue);
|
|
|
|
NotifyObserver();
|
|
|
|
}
|
2014-10-01 17:55:33 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
bool
|
|
|
|
URLSearchParams::Has(const nsAString& aName)
|
|
|
|
{
|
|
|
|
return mParams->Has(aName);
|
|
|
|
}
|
2014-10-01 17:55:33 +04:00
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
void
|
|
|
|
URLSearchParams::Delete(const nsAString& aName)
|
|
|
|
{
|
|
|
|
if (mParams->Delete(aName)) {
|
|
|
|
NotifyObserver();
|
2013-12-12 23:30:27 +04:00
|
|
|
}
|
2014-10-01 17:55:33 +04:00
|
|
|
}
|
|
|
|
|
2015-06-04 23:45:24 +03:00
|
|
|
void
|
|
|
|
URLSearchParams::DeleteAll()
|
|
|
|
{
|
|
|
|
mParams->DeleteAll();
|
|
|
|
}
|
2013-12-12 23:30:27 +04:00
|
|
|
|
|
|
|
void
|
2014-01-15 18:50:18 +04:00
|
|
|
URLSearchParams::Serialize(nsAString& aValue) const
|
2013-12-12 23:30:27 +04:00
|
|
|
{
|
2015-06-04 23:45:24 +03:00
|
|
|
mParams->Serialize(aValue);
|
2013-12-12 23:30:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2015-06-24 22:15:59 +03:00
|
|
|
URLSearchParams::NotifyObserver()
|
2013-12-12 23:30:27 +04:00
|
|
|
{
|
2015-06-24 22:15:59 +03:00
|
|
|
if (mObserver) {
|
|
|
|
mObserver->URLSearchParamsUpdated(this);
|
2013-12-12 23:30:27 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-10-19 18:07:40 +03:00
|
|
|
uint32_t
|
|
|
|
URLSearchParams::GetIterableLength() const
|
|
|
|
{
|
|
|
|
return mParams->Length();
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsAString&
|
|
|
|
URLSearchParams::GetKeyAtIndex(uint32_t aIndex) const
|
|
|
|
{
|
|
|
|
return mParams->GetKeyAtIndex(aIndex);
|
|
|
|
}
|
|
|
|
|
|
|
|
const nsAString&
|
|
|
|
URLSearchParams::GetValueAtIndex(uint32_t aIndex) const
|
|
|
|
{
|
|
|
|
return mParams->GetValueAtIndex(aIndex);
|
|
|
|
}
|
|
|
|
|
2013-12-12 23:30:10 +04:00
|
|
|
} // namespace dom
|
|
|
|
} // namespace mozilla
|