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: */
|
2012-05-21 15:12:37 +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/. */
|
2009-08-12 12:55:14 +04:00
|
|
|
|
|
|
|
/*
|
2013-01-15 12:35:59 +04:00
|
|
|
* Implementation of DOMTokenList specified by HTML5.
|
2009-08-12 12:55:14 +04:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "nsDOMTokenList.h"
|
|
|
|
#include "nsAttrValue.h"
|
2016-04-11 18:01:14 +03:00
|
|
|
#include "nsAttrValueInlines.h"
|
2021-03-10 13:47:47 +03:00
|
|
|
#include "nsTHashMap.h"
|
2012-07-27 18:03:27 +04:00
|
|
|
#include "nsError.h"
|
2016-04-11 18:01:14 +03:00
|
|
|
#include "nsHashKeys.h"
|
2020-11-23 19:21:38 +03:00
|
|
|
#include "mozilla/dom/Document.h"
|
2012-11-15 02:10:08 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2012-06-13 19:18:30 +04:00
|
|
|
#include "mozilla/dom/DOMTokenListBinding.h"
|
2012-09-06 00:49:53 +04:00
|
|
|
#include "mozilla/ErrorResult.h"
|
2009-08-12 12:55:14 +04:00
|
|
|
|
2012-06-27 17:01:55 +04:00
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
2009-08-12 12:55:14 +04:00
|
|
|
|
2017-10-03 01:05:19 +03:00
|
|
|
nsDOMTokenList::nsDOMTokenList(
|
|
|
|
Element* aElement, nsAtom* aAttrAtom,
|
2016-05-05 06:41:24 +03:00
|
|
|
const DOMTokenListSupportedTokenArray aSupportedTokens)
|
2009-08-12 12:55:14 +04:00
|
|
|
: mElement(aElement),
|
2016-05-05 06:41:24 +03:00
|
|
|
mAttrAtom(aAttrAtom),
|
|
|
|
mSupportedTokens(aSupportedTokens) {
|
2009-08-12 12:55:14 +04:00
|
|
|
// We don't add a reference to our element. If it goes away,
|
|
|
|
// we'll be told to drop our reference
|
|
|
|
}
|
|
|
|
|
2020-02-21 13:41:47 +03:00
|
|
|
nsDOMTokenList::~nsDOMTokenList() = default;
|
2009-08-12 12:55:14 +04:00
|
|
|
|
2014-04-29 12:57:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMTokenList, mElement)
|
2011-08-22 13:14:13 +04:00
|
|
|
|
2013-01-18 23:53:52 +04:00
|
|
|
NS_INTERFACE_MAP_BEGIN(nsDOMTokenList)
|
2011-08-22 13:14:13 +04:00
|
|
|
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
2013-01-18 23:53:52 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
|
|
|
NS_INTERFACE_MAP_ENTRIES_CYCLE_COLLECTION(nsDOMTokenList)
|
2009-08-12 12:55:14 +04:00
|
|
|
NS_INTERFACE_MAP_END
|
|
|
|
|
2011-08-22 13:14:13 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMTokenList)
|
|
|
|
NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMTokenList)
|
2009-08-12 12:55:14 +04:00
|
|
|
|
2012-10-16 15:51:00 +04:00
|
|
|
const nsAttrValue* nsDOMTokenList::GetParsedAttr() {
|
|
|
|
if (!mElement) {
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
return mElement->GetAttrInfo(kNameSpaceID_None, mAttrAtom).mValue;
|
|
|
|
}
|
|
|
|
|
2022-04-04 17:23:23 +03:00
|
|
|
static void RemoveDuplicates(const nsAttrValue* aAttr) {
|
2016-04-11 18:01:14 +03:00
|
|
|
if (!aAttr || aAttr->Type() != nsAttrValue::eAtomArray) {
|
|
|
|
return;
|
|
|
|
}
|
2022-04-04 17:23:23 +03:00
|
|
|
aAttr->GetAtomArrayValue()->RemoveDuplicates();
|
2016-04-11 18:01:14 +03:00
|
|
|
}
|
|
|
|
|
2012-09-06 00:49:53 +04:00
|
|
|
uint32_t nsDOMTokenList::Length() {
|
2009-08-12 12:55:14 +04:00
|
|
|
const nsAttrValue* attr = GetParsedAttr();
|
|
|
|
if (!attr) {
|
2012-09-06 00:49:53 +04:00
|
|
|
return 0;
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
|
|
|
|
2016-04-11 18:01:14 +03:00
|
|
|
RemoveDuplicates(attr);
|
2012-09-06 00:49:53 +04:00
|
|
|
return attr->GetAtomCount();
|
|
|
|
}
|
|
|
|
|
|
|
|
void nsDOMTokenList::IndexedGetter(uint32_t aIndex, bool& aFound,
|
|
|
|
nsAString& aResult) {
|
2009-08-12 12:55:14 +04:00
|
|
|
const nsAttrValue* attr = GetParsedAttr();
|
|
|
|
|
2016-04-11 18:01:14 +03:00
|
|
|
if (!attr || aIndex >= static_cast<uint32_t>(attr->GetAtomCount())) {
|
|
|
|
aFound = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
RemoveDuplicates(attr);
|
|
|
|
|
2012-09-06 00:49:53 +04:00
|
|
|
if (attr && aIndex < static_cast<uint32_t>(attr->GetAtomCount())) {
|
|
|
|
aFound = true;
|
|
|
|
attr->AtomAt(aIndex)->ToString(aResult);
|
|
|
|
} else {
|
|
|
|
aFound = false;
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
2012-09-06 00:49:53 +04:00
|
|
|
}
|
2009-08-12 12:55:14 +04:00
|
|
|
|
2019-10-23 07:55:54 +03:00
|
|
|
void nsDOMTokenList::GetValue(nsAString& aResult) {
|
|
|
|
if (!mElement) {
|
|
|
|
aResult.Truncate();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
mElement->GetAttr(kNameSpaceID_None, mAttrAtom, aResult);
|
|
|
|
}
|
|
|
|
|
2016-04-28 12:20:25 +03:00
|
|
|
void nsDOMTokenList::SetValue(const nsAString& aValue, ErrorResult& rv) {
|
2016-02-12 01:50:42 +03:00
|
|
|
if (!mElement) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
rv = mElement->SetAttr(kNameSpaceID_None, mAttrAtom, aValue, true);
|
|
|
|
}
|
|
|
|
|
2022-06-12 20:59:54 +03:00
|
|
|
void nsDOMTokenList::CheckToken(const nsAString& aToken, ErrorResult& aRv) {
|
|
|
|
if (aToken.IsEmpty()) {
|
|
|
|
return aRv.ThrowSyntaxError("The empty string is not a valid token.");
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
nsAString::const_iterator iter, end;
|
2022-06-12 20:59:54 +03:00
|
|
|
aToken.BeginReading(iter);
|
|
|
|
aToken.EndReading(end);
|
2009-08-12 12:55:14 +04:00
|
|
|
|
|
|
|
while (iter != end) {
|
2022-06-12 20:59:54 +03:00
|
|
|
if (nsContentUtils::IsHTMLWhitespace(*iter)) {
|
|
|
|
return aRv.ThrowInvalidCharacterError(
|
|
|
|
"The token can not contain whitespace.");
|
|
|
|
}
|
2009-08-12 12:55:14 +04:00
|
|
|
++iter;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-12 20:59:54 +03:00
|
|
|
void nsDOMTokenList::CheckTokens(const nsTArray<nsString>& aTokens,
|
|
|
|
ErrorResult& aRv) {
|
2013-08-28 11:31:13 +04:00
|
|
|
for (uint32_t i = 0, l = aTokens.Length(); i < l; ++i) {
|
2022-06-12 20:59:54 +03:00
|
|
|
CheckToken(aTokens[i], aRv);
|
|
|
|
if (aRv.Failed()) {
|
|
|
|
return;
|
2013-08-28 11:31:13 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-05 13:07:22 +03:00
|
|
|
bool nsDOMTokenList::Contains(const nsAString& aToken) {
|
2012-09-06 00:49:53 +04:00
|
|
|
const nsAttrValue* attr = GetParsedAttr();
|
|
|
|
return attr && attr->Contains(aToken);
|
|
|
|
}
|
2009-08-12 12:55:14 +04:00
|
|
|
|
|
|
|
void nsDOMTokenList::AddInternal(const nsAttrValue* aAttr,
|
2013-08-28 11:31:13 +04:00
|
|
|
const nsTArray<nsString>& aTokens) {
|
2010-04-15 15:07:30 +04:00
|
|
|
if (!mElement) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2009-08-12 12:55:14 +04:00
|
|
|
nsAutoString resultStr;
|
|
|
|
|
|
|
|
if (aAttr) {
|
2016-04-11 18:01:14 +03:00
|
|
|
RemoveDuplicates(aAttr);
|
|
|
|
for (uint32_t i = 0; i < aAttr->GetAtomCount(); i++) {
|
|
|
|
if (i != 0) {
|
|
|
|
resultStr.AppendLiteral(" ");
|
|
|
|
}
|
|
|
|
resultStr.Append(nsDependentAtomString(aAttr->AtomAt(i)));
|
|
|
|
}
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
|
|
|
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<nsString, 10> addedClasses;
|
2013-08-28 11:31:13 +04:00
|
|
|
|
|
|
|
for (uint32_t i = 0, l = aTokens.Length(); i < l; ++i) {
|
|
|
|
const nsString& aToken = aTokens[i];
|
|
|
|
|
|
|
|
if ((aAttr && aAttr->Contains(aToken)) || addedClasses.Contains(aToken)) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2016-04-11 18:01:14 +03:00
|
|
|
if (!resultStr.IsEmpty()) {
|
2014-05-22 07:48:50 +04:00
|
|
|
resultStr.Append(' ');
|
2013-08-28 11:31:13 +04:00
|
|
|
}
|
2016-04-11 18:01:14 +03:00
|
|
|
resultStr.Append(aToken);
|
2013-08-28 11:31:13 +04:00
|
|
|
|
|
|
|
addedClasses.AppendElement(aToken);
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
2013-08-28 11:31:13 +04:00
|
|
|
|
2011-10-17 18:59:28 +04:00
|
|
|
mElement->SetAttr(kNameSpaceID_None, mAttrAtom, resultStr, true);
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
|
|
|
|
2013-08-28 11:31:13 +04:00
|
|
|
void nsDOMTokenList::Add(const nsTArray<nsString>& aTokens,
|
|
|
|
ErrorResult& aError) {
|
2022-06-12 20:59:54 +03:00
|
|
|
CheckTokens(aTokens, aError);
|
2012-09-06 00:49:53 +04:00
|
|
|
if (aError.Failed()) {
|
|
|
|
return;
|
|
|
|
}
|
2009-08-12 12:55:14 +04:00
|
|
|
|
|
|
|
const nsAttrValue* attr = GetParsedAttr();
|
2013-08-28 11:31:13 +04:00
|
|
|
AddInternal(attr, aTokens);
|
|
|
|
}
|
2009-08-12 12:55:14 +04:00
|
|
|
|
2016-04-28 12:20:25 +03:00
|
|
|
void nsDOMTokenList::Add(const nsAString& aToken, ErrorResult& aError) {
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<nsString, 1> tokens;
|
2013-09-05 00:43:12 +04:00
|
|
|
tokens.AppendElement(aToken);
|
|
|
|
Add(tokens, aError);
|
2012-09-06 00:49:53 +04:00
|
|
|
}
|
2009-08-12 12:55:14 +04:00
|
|
|
|
|
|
|
void nsDOMTokenList::RemoveInternal(const nsAttrValue* aAttr,
|
2013-08-28 11:31:13 +04:00
|
|
|
const nsTArray<nsString>& aTokens) {
|
2015-02-10 01:34:50 +03:00
|
|
|
MOZ_ASSERT(aAttr, "Need an attribute");
|
2009-08-12 12:55:14 +04:00
|
|
|
|
2016-04-11 18:01:14 +03:00
|
|
|
RemoveDuplicates(aAttr);
|
2009-08-12 12:55:14 +04:00
|
|
|
|
2016-04-11 18:01:14 +03:00
|
|
|
nsAutoString resultStr;
|
|
|
|
for (uint32_t i = 0; i < aAttr->GetAtomCount(); i++) {
|
|
|
|
if (aTokens.Contains(nsDependentAtomString(aAttr->AtomAt(i)))) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!resultStr.IsEmpty()) {
|
|
|
|
resultStr.AppendLiteral(" ");
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
2016-04-11 18:01:14 +03:00
|
|
|
resultStr.Append(nsDependentAtomString(aAttr->AtomAt(i)));
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
|
|
|
|
2016-04-11 18:01:14 +03:00
|
|
|
mElement->SetAttr(kNameSpaceID_None, mAttrAtom, resultStr, true);
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
|
|
|
|
2013-08-28 11:31:13 +04:00
|
|
|
void nsDOMTokenList::Remove(const nsTArray<nsString>& aTokens,
|
|
|
|
ErrorResult& aError) {
|
2022-06-12 20:59:54 +03:00
|
|
|
CheckTokens(aTokens, aError);
|
2012-09-06 00:49:53 +04:00
|
|
|
if (aError.Failed()) {
|
|
|
|
return;
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
|
|
|
|
2012-09-06 00:49:53 +04:00
|
|
|
const nsAttrValue* attr = GetParsedAttr();
|
2013-08-28 11:31:13 +04:00
|
|
|
if (!attr) {
|
2012-09-06 00:49:53 +04:00
|
|
|
return;
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
|
|
|
|
2013-08-28 11:31:13 +04:00
|
|
|
RemoveInternal(attr, aTokens);
|
|
|
|
}
|
|
|
|
|
2016-04-28 12:20:25 +03:00
|
|
|
void nsDOMTokenList::Remove(const nsAString& aToken, ErrorResult& aError) {
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<nsString, 1> tokens;
|
2013-09-05 00:43:12 +04:00
|
|
|
tokens.AppendElement(aToken);
|
|
|
|
Remove(tokens, aError);
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
|
|
|
|
2013-06-15 01:22:17 +04:00
|
|
|
bool nsDOMTokenList::Toggle(const nsAString& aToken,
|
|
|
|
const Optional<bool>& aForce, ErrorResult& aError) {
|
2022-06-12 20:59:54 +03:00
|
|
|
CheckToken(aToken, aError);
|
2012-09-06 00:49:53 +04:00
|
|
|
if (aError.Failed()) {
|
|
|
|
return false;
|
|
|
|
}
|
2009-08-12 12:55:14 +04:00
|
|
|
|
|
|
|
const nsAttrValue* attr = GetParsedAttr();
|
2013-06-15 01:22:17 +04:00
|
|
|
const bool forceOn = aForce.WasPassed() && aForce.Value();
|
|
|
|
const bool forceOff = aForce.WasPassed() && !aForce.Value();
|
2009-08-12 12:55:14 +04:00
|
|
|
|
2013-06-15 01:22:17 +04:00
|
|
|
bool isPresent = attr && attr->Contains(aToken);
|
2016-02-02 18:36:30 +03:00
|
|
|
AutoTArray<nsString, 1> tokens;
|
2013-09-05 00:43:12 +04:00
|
|
|
(*tokens.AppendElement()).Rebind(aToken.Data(), aToken.Length());
|
2013-06-15 01:22:17 +04:00
|
|
|
|
2017-04-27 20:50:21 +03:00
|
|
|
if (isPresent) {
|
|
|
|
if (!forceOn) {
|
|
|
|
RemoveInternal(attr, tokens);
|
|
|
|
isPresent = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
if (!forceOff) {
|
|
|
|
AddInternal(attr, tokens);
|
|
|
|
isPresent = true;
|
2013-06-15 01:22:17 +04:00
|
|
|
}
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
|
|
|
|
2013-06-15 01:22:17 +04:00
|
|
|
return isPresent;
|
2009-08-12 12:55:14 +04:00
|
|
|
}
|
|
|
|
|
2016-04-28 12:20:25 +03:00
|
|
|
bool nsDOMTokenList::Replace(const nsAString& aToken,
|
|
|
|
const nsAString& aNewToken, ErrorResult& aError) {
|
|
|
|
// Doing this here instead of using `CheckToken` because if aToken had invalid
|
|
|
|
// characters, and aNewToken is empty, the returned error should be a
|
|
|
|
// SyntaxError, not an InvalidCharacterError.
|
|
|
|
if (aNewToken.IsEmpty()) {
|
2022-06-12 20:59:54 +03:00
|
|
|
aError.ThrowSyntaxError("The empty string is not a valid token.");
|
2018-03-14 23:08:58 +03:00
|
|
|
return false;
|
2016-04-28 12:20:25 +03:00
|
|
|
}
|
|
|
|
|
2022-06-12 20:59:54 +03:00
|
|
|
CheckToken(aToken, aError);
|
2016-04-28 12:20:25 +03:00
|
|
|
if (aError.Failed()) {
|
2018-03-14 23:08:58 +03:00
|
|
|
return false;
|
2016-04-28 12:20:25 +03:00
|
|
|
}
|
|
|
|
|
2022-06-12 20:59:54 +03:00
|
|
|
CheckToken(aNewToken, aError);
|
2016-04-28 12:20:25 +03:00
|
|
|
if (aError.Failed()) {
|
2018-03-14 23:08:58 +03:00
|
|
|
return false;
|
2016-04-28 12:20:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
const nsAttrValue* attr = GetParsedAttr();
|
2016-08-09 08:48:30 +03:00
|
|
|
if (!attr) {
|
2018-03-14 23:08:58 +03:00
|
|
|
return false;
|
2016-04-28 12:20:25 +03:00
|
|
|
}
|
|
|
|
|
2018-03-14 23:08:58 +03:00
|
|
|
return ReplaceInternal(attr, aToken, aNewToken);
|
2016-08-09 08:48:30 +03:00
|
|
|
}
|
2016-04-28 12:20:25 +03:00
|
|
|
|
2016-08-09 08:48:30 +03:00
|
|
|
bool nsDOMTokenList::ReplaceInternal(const nsAttrValue* aAttr,
|
|
|
|
const nsAString& aToken,
|
|
|
|
const nsAString& aNewToken) {
|
2016-04-11 18:01:14 +03:00
|
|
|
RemoveDuplicates(aAttr);
|
2016-08-09 08:48:30 +03:00
|
|
|
|
2018-03-14 23:08:58 +03:00
|
|
|
// Trying to do a single pass here leads to really complicated code. Just do
|
|
|
|
// the simple thing.
|
|
|
|
bool haveOld = false;
|
|
|
|
for (uint32_t i = 0; i < aAttr->GetAtomCount(); ++i) {
|
|
|
|
if (aAttr->AtomAt(i)->Equals(aToken)) {
|
|
|
|
haveOld = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (!haveOld) {
|
|
|
|
// Make sure to not touch the attribute value in this case.
|
2018-03-14 23:08:58 +03:00
|
|
|
return false;
|
2018-03-14 23:08:58 +03:00
|
|
|
}
|
|
|
|
|
2016-08-09 08:48:30 +03:00
|
|
|
bool sawIt = false;
|
2016-04-11 18:01:14 +03:00
|
|
|
nsAutoString resultStr;
|
|
|
|
for (uint32_t i = 0; i < aAttr->GetAtomCount(); i++) {
|
|
|
|
if (aAttr->AtomAt(i)->Equals(aToken) ||
|
|
|
|
aAttr->AtomAt(i)->Equals(aNewToken)) {
|
|
|
|
if (sawIt) {
|
|
|
|
// We keep only the first
|
|
|
|
continue;
|
2016-08-09 08:48:30 +03:00
|
|
|
}
|
2016-04-11 18:01:14 +03:00
|
|
|
sawIt = true;
|
|
|
|
if (!resultStr.IsEmpty()) {
|
|
|
|
resultStr.AppendLiteral(" ");
|
2016-08-09 08:48:30 +03:00
|
|
|
}
|
2016-04-11 18:01:14 +03:00
|
|
|
resultStr.Append(aNewToken);
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (!resultStr.IsEmpty()) {
|
|
|
|
resultStr.AppendLiteral(" ");
|
2016-08-09 08:48:30 +03:00
|
|
|
}
|
2016-04-11 18:01:14 +03:00
|
|
|
resultStr.Append(nsDependentAtomString(aAttr->AtomAt(i)));
|
2016-08-09 08:48:30 +03:00
|
|
|
}
|
2016-04-28 12:20:25 +03:00
|
|
|
|
2018-03-14 23:08:58 +03:00
|
|
|
MOZ_ASSERT(sawIt, "How could we not have found our token this time?");
|
|
|
|
mElement->SetAttr(kNameSpaceID_None, mAttrAtom, resultStr, true);
|
2018-03-14 23:08:58 +03:00
|
|
|
return true;
|
2016-04-28 12:20:25 +03:00
|
|
|
}
|
|
|
|
|
2016-05-05 06:41:25 +03:00
|
|
|
bool nsDOMTokenList::Supports(const nsAString& aToken, ErrorResult& aError) {
|
|
|
|
if (!mSupportedTokens) {
|
|
|
|
aError.ThrowTypeError<MSG_TOKENLIST_NO_SUPPORTED_TOKENS>(
|
2020-03-07 00:08:02 +03:00
|
|
|
NS_ConvertUTF16toUTF8(mElement->LocalName()),
|
|
|
|
NS_ConvertUTF16toUTF8(nsDependentAtomString(mAttrAtom)));
|
2016-05-05 06:41:25 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (DOMTokenListSupportedToken* supportedToken = mSupportedTokens;
|
|
|
|
*supportedToken; ++supportedToken) {
|
|
|
|
if (aToken.LowerCaseEqualsASCII(*supportedToken)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-11-27 11:10:27 +03:00
|
|
|
DocGroup* nsDOMTokenList::GetDocGroup() const {
|
|
|
|
return mElement ? mElement->OwnerDoc()->GetDocGroup() : nullptr;
|
|
|
|
}
|
|
|
|
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
JSObject* nsDOMTokenList::WrapObject(JSContext* cx,
|
|
|
|
JS::Handle<JSObject*> aGivenProto) {
|
2018-06-26 00:20:54 +03:00
|
|
|
return DOMTokenList_Binding::Wrap(cx, this, aGivenProto);
|
2011-08-22 13:14:13 +04:00
|
|
|
}
|