mirror of
https://github.com/classilla/tenfourfox.git
synced 2024-06-01 17:41:34 +00:00
closes #488: M1257849 M1244328 finish DOMTokenList transition, bustage fixes
This commit is contained in:
parent
9470d4fb94
commit
d4f4b43538
31
dom/base/DOMTokenListSupportedTokens.h
Normal file
31
dom/base/DOMTokenListSupportedTokens.h
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Definitions of supported tokens data types for nsDOMTokenList. This is in a
|
||||||
|
* separate header so Element.h can include it too.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef mozilla_dom_DOMTokenListSupportedTokens_h
|
||||||
|
#define mozilla_dom_DOMTokenListSupportedTokens_h
|
||||||
|
|
||||||
|
namespace mozilla {
|
||||||
|
namespace dom {
|
||||||
|
|
||||||
|
// A single supported token.
|
||||||
|
typedef const char* const DOMTokenListSupportedToken;
|
||||||
|
|
||||||
|
// An array of supported tokens. This should end with a null
|
||||||
|
// DOMTokenListSupportedToken to indicate array termination. A null value for
|
||||||
|
// the DOMTokenListSupportedTokenArray means there is no definition of supported
|
||||||
|
// tokens for the given DOMTokenList. This should generally be a static table,
|
||||||
|
// or at least outlive the DOMTokenList whose constructor it's passed to.
|
||||||
|
typedef DOMTokenListSupportedToken* DOMTokenListSupportedTokenArray;
|
||||||
|
|
||||||
|
} // namespace dom
|
||||||
|
} // namespace mozilla
|
||||||
|
|
||||||
|
#endif // mozilla_dom_DOMTokenListSupportedTokens_h
|
|
@ -44,7 +44,6 @@
|
||||||
#include "nsNameSpaceManager.h"
|
#include "nsNameSpaceManager.h"
|
||||||
#include "nsContentList.h"
|
#include "nsContentList.h"
|
||||||
#include "nsVariant.h"
|
#include "nsVariant.h"
|
||||||
#include "nsDOMSettableTokenList.h"
|
|
||||||
#include "nsDOMTokenList.h"
|
#include "nsDOMTokenList.h"
|
||||||
#include "nsXBLPrototypeBinding.h"
|
#include "nsXBLPrototypeBinding.h"
|
||||||
#include "nsError.h"
|
#include "nsError.h"
|
||||||
|
@ -3086,11 +3085,11 @@ Element::GetLinkTarget(nsAString& aTarget)
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
nsDOMSettableTokenListPropertyDestructor(void *aObject, nsIAtom *aProperty,
|
nsDOMTokenListPropertyDestructor(void *aObject, nsIAtom *aProperty,
|
||||||
void *aPropertyValue, void *aData)
|
void *aPropertyValue, void *aData)
|
||||||
{
|
{
|
||||||
nsDOMSettableTokenList* list =
|
nsDOMTokenList* list =
|
||||||
static_cast<nsDOMSettableTokenList*>(aPropertyValue);
|
static_cast<nsDOMTokenList*>(aPropertyValue);
|
||||||
NS_RELEASE(list);
|
NS_RELEASE(list);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3113,8 +3112,9 @@ Element::HTMLSVGPropertiesToTraverseAndUnlink()
|
||||||
return sPropertiesToTraverseAndUnlink;
|
return sPropertiesToTraverseAndUnlink;
|
||||||
}
|
}
|
||||||
|
|
||||||
nsDOMSettableTokenList*
|
nsDOMTokenList*
|
||||||
Element::GetTokenList(nsIAtom* aAtom)
|
Element::GetTokenList(nsIAtom* aAtom,
|
||||||
|
const DOMTokenListSupportedTokenArray aSupportedTokens)
|
||||||
{
|
{
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
nsIAtom*** props =
|
nsIAtom*** props =
|
||||||
|
@ -3129,14 +3129,14 @@ Element::GetTokenList(nsIAtom* aAtom)
|
||||||
MOZ_ASSERT(found, "Trying to use an unknown tokenlist!");
|
MOZ_ASSERT(found, "Trying to use an unknown tokenlist!");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
nsDOMSettableTokenList* list = nullptr;
|
nsDOMTokenList* list = nullptr;
|
||||||
if (HasProperties()) {
|
if (HasProperties()) {
|
||||||
list = static_cast<nsDOMSettableTokenList*>(GetProperty(aAtom));
|
list = static_cast<nsDOMTokenList*>(GetProperty(aAtom));
|
||||||
}
|
}
|
||||||
if (!list) {
|
if (!list) {
|
||||||
list = new nsDOMSettableTokenList(this, aAtom);
|
list = new nsDOMTokenList(this, aAtom, aSupportedTokens);
|
||||||
NS_ADDREF(list);
|
NS_ADDREF(list);
|
||||||
SetProperty(aAtom, list, nsDOMSettableTokenListPropertyDestructor);
|
SetProperty(aAtom, list, nsDOMTokenListPropertyDestructor);
|
||||||
}
|
}
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
@ -3153,7 +3153,7 @@ Element::GetTokenList(nsIAtom* aAtom, nsIVariant** aResult)
|
||||||
nsresult
|
nsresult
|
||||||
Element::SetTokenList(nsIAtom* aAtom, nsIVariant* aValue)
|
Element::SetTokenList(nsIAtom* aAtom, nsIVariant* aValue)
|
||||||
{
|
{
|
||||||
nsDOMSettableTokenList* itemType = GetTokenList(aAtom);
|
nsDOMTokenList* itemType = GetTokenList(aAtom);
|
||||||
nsAutoString string;
|
nsAutoString string;
|
||||||
aValue->GetAsAString(string);
|
aValue->GetAsAString(string);
|
||||||
ErrorResult rv;
|
ErrorResult rv;
|
||||||
|
|
|
@ -34,6 +34,7 @@
|
||||||
#include "nsAttrValue.h"
|
#include "nsAttrValue.h"
|
||||||
#include "mozilla/EventForwards.h"
|
#include "mozilla/EventForwards.h"
|
||||||
#include "mozilla/dom/BindingDeclarations.h"
|
#include "mozilla/dom/BindingDeclarations.h"
|
||||||
|
#include "mozilla/dom/DOMTokenListSupportedTokens.h"
|
||||||
#include "mozilla/dom/WindowBinding.h"
|
#include "mozilla/dom/WindowBinding.h"
|
||||||
#include "mozilla/dom/ElementBinding.h"
|
#include "mozilla/dom/ElementBinding.h"
|
||||||
#include "Units.h"
|
#include "Units.h"
|
||||||
|
@ -44,7 +45,6 @@ class nsIURI;
|
||||||
class nsIScrollableFrame;
|
class nsIScrollableFrame;
|
||||||
class nsAttrValueOrString;
|
class nsAttrValueOrString;
|
||||||
class nsContentList;
|
class nsContentList;
|
||||||
class nsDOMSettableTokenList;
|
|
||||||
class nsDOMTokenList;
|
class nsDOMTokenList;
|
||||||
struct nsRect;
|
struct nsRect;
|
||||||
class nsFocusManager;
|
class nsFocusManager;
|
||||||
|
@ -1342,7 +1342,8 @@ protected:
|
||||||
*/
|
*/
|
||||||
virtual void GetLinkTarget(nsAString& aTarget);
|
virtual void GetLinkTarget(nsAString& aTarget);
|
||||||
|
|
||||||
nsDOMSettableTokenList* GetTokenList(nsIAtom* aAtom);
|
nsDOMTokenList* GetTokenList(nsIAtom* aAtom,
|
||||||
|
const DOMTokenListSupportedTokenArray aSupportedTokens = nullptr);
|
||||||
void GetTokenList(nsIAtom* aAtom, nsIVariant** aResult);
|
void GetTokenList(nsIAtom* aAtom, nsIVariant** aResult);
|
||||||
nsresult SetTokenList(nsIAtom* aAtom, nsIVariant* aValue);
|
nsresult SetTokenList(nsIAtom* aAtom, nsIVariant* aValue);
|
||||||
|
|
||||||
|
|
|
@ -25,11 +25,11 @@
|
||||||
class ContentUnbinder;
|
class ContentUnbinder;
|
||||||
class nsContentList;
|
class nsContentList;
|
||||||
class nsDOMAttributeMap;
|
class nsDOMAttributeMap;
|
||||||
class nsDOMTokenList;
|
|
||||||
class nsIControllers;
|
class nsIControllers;
|
||||||
class nsICSSDeclaration;
|
class nsICSSDeclaration;
|
||||||
class nsIDocument;
|
class nsIDocument;
|
||||||
class nsDOMStringMap;
|
class nsDOMStringMap;
|
||||||
|
class nsDOMTokenList;
|
||||||
class nsIURI;
|
class nsIURI;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
24
dom/base/IframeSandboxKeywordList.h
Normal file
24
dom/base/IframeSandboxKeywordList.h
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||||
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||||
|
/* 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/. */
|
||||||
|
|
||||||
|
/* NOTE: no include guard; this file is meant to maybe be included multiple
|
||||||
|
times. It has a list of the sandbox keywords we support, with their
|
||||||
|
corresponding sandbox flags. */
|
||||||
|
|
||||||
|
#include "nsSandboxFlags.h"
|
||||||
|
|
||||||
|
// Each entry has the sandbox keyword as a string, the corresponding nsGkAtoms
|
||||||
|
// atom name, and the corresponding sandbox flags.
|
||||||
|
SANDBOX_KEYWORD("allow-same-origin", allowsameorigin, SANDBOXED_ORIGIN)
|
||||||
|
SANDBOX_KEYWORD("allow-forms", allowforms, SANDBOXED_FORMS)
|
||||||
|
SANDBOX_KEYWORD("allow-scripts", allowscripts,
|
||||||
|
SANDBOXED_SCRIPTS | SANDBOXED_AUTOMATIC_FEATURES)
|
||||||
|
SANDBOX_KEYWORD("allow-top-navigation", allowtopnavigation,
|
||||||
|
SANDBOXED_TOPLEVEL_NAVIGATION)
|
||||||
|
SANDBOX_KEYWORD("allow-pointer-lock", allowpointerlock, SANDBOXED_POINTER_LOCK)
|
||||||
|
SANDBOX_KEYWORD("allow-orientation-lock", alloworientationlock,
|
||||||
|
SANDBOXED_ORIENTATION_LOCK)
|
||||||
|
SANDBOX_KEYWORD("allow-popups", allowpopups, SANDBOXED_AUXILIARY_NAVIGATION)
|
|
@ -45,6 +45,7 @@ EXPORTS += [
|
||||||
'AutocompleteFieldList.h',
|
'AutocompleteFieldList.h',
|
||||||
'Crypto.h',
|
'Crypto.h',
|
||||||
'HTMLSplitOnSpacesTokenizer.h',
|
'HTMLSplitOnSpacesTokenizer.h',
|
||||||
|
'IframeSandboxKeywordList.h',
|
||||||
'mozAutoDocUpdate.h',
|
'mozAutoDocUpdate.h',
|
||||||
'mozFlushType.h',
|
'mozFlushType.h',
|
||||||
'nsAtomListUtils.h',
|
'nsAtomListUtils.h',
|
||||||
|
@ -74,6 +75,7 @@ EXPORTS += [
|
||||||
'nsDOMJSUtils.h',
|
'nsDOMJSUtils.h',
|
||||||
'nsDOMNavigationTiming.h',
|
'nsDOMNavigationTiming.h',
|
||||||
'nsDOMString.h',
|
'nsDOMString.h',
|
||||||
|
'nsDOMTokenList.h',
|
||||||
'nsFocusManager.h',
|
'nsFocusManager.h',
|
||||||
'nsFormData.h',
|
'nsFormData.h',
|
||||||
'nsFrameMessageManager.h',
|
'nsFrameMessageManager.h',
|
||||||
|
@ -174,6 +176,7 @@ EXPORTS.mozilla.dom += [
|
||||||
'DOMRect.h',
|
'DOMRect.h',
|
||||||
'DOMRequest.h',
|
'DOMRequest.h',
|
||||||
'DOMStringList.h',
|
'DOMStringList.h',
|
||||||
|
'DOMTokenListSupportedTokens.h',
|
||||||
'Element.h',
|
'Element.h',
|
||||||
'ElementInlines.h',
|
'ElementInlines.h',
|
||||||
'EventSource.h',
|
'EventSource.h',
|
||||||
|
@ -278,7 +281,6 @@ UNIFIED_SOURCES += [
|
||||||
'nsDOMNavigationTiming.cpp',
|
'nsDOMNavigationTiming.cpp',
|
||||||
'nsDOMScriptObjectFactory.cpp',
|
'nsDOMScriptObjectFactory.cpp',
|
||||||
'nsDOMSerializer.cpp',
|
'nsDOMSerializer.cpp',
|
||||||
'nsDOMSettableTokenList.cpp',
|
|
||||||
'nsDOMTokenList.cpp',
|
'nsDOMTokenList.cpp',
|
||||||
'nsDOMWindowList.cpp',
|
'nsDOMWindowList.cpp',
|
||||||
'nsFocusManager.cpp',
|
'nsFocusManager.cpp',
|
||||||
|
|
|
@ -1362,19 +1362,13 @@ nsContentUtils::ParseSandboxAttributeToFlags(const nsAttrValue* sandboxAttr)
|
||||||
| SANDBOXED_DOMAIN;
|
| SANDBOXED_DOMAIN;
|
||||||
|
|
||||||
// Macro for updating the flag according to the keywords
|
// Macro for updating the flag according to the keywords
|
||||||
#define IF_KEYWORD(atom, flags) \
|
#define SANDBOX_KEYWORD(string, atom, flags) \
|
||||||
if (sandboxAttr->Contains(nsGkAtoms::atom, eIgnoreCase)) { out &= ~(flags); }
|
if (sandboxAttr->Contains(nsGkAtoms::atom, eIgnoreCase)) { out &= ~(flags); }
|
||||||
|
|
||||||
IF_KEYWORD(allowsameorigin, SANDBOXED_ORIGIN)
|
#include "IframeSandboxKeywordList.h"
|
||||||
IF_KEYWORD(allowforms, SANDBOXED_FORMS)
|
|
||||||
IF_KEYWORD(allowscripts, SANDBOXED_SCRIPTS | SANDBOXED_AUTOMATIC_FEATURES)
|
|
||||||
IF_KEYWORD(allowtopnavigation, SANDBOXED_TOPLEVEL_NAVIGATION)
|
|
||||||
IF_KEYWORD(allowpointerlock, SANDBOXED_POINTER_LOCK)
|
|
||||||
IF_KEYWORD(alloworientationlock, SANDBOXED_ORIENTATION_LOCK)
|
|
||||||
IF_KEYWORD(allowpopups, SANDBOXED_AUXILIARY_NAVIGATION)
|
|
||||||
|
|
||||||
return out;
|
return out;
|
||||||
#undef IF_KEYWORD
|
#undef SANDBOX_KEYWORD
|
||||||
}
|
}
|
||||||
|
|
||||||
nsIBidiKeyboard*
|
nsIBidiKeyboard*
|
||||||
|
|
|
@ -9,20 +9,25 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include "nsDOMTokenList.h"
|
#include "nsDOMTokenList.h"
|
||||||
|
#include "nsAttrValueInlines.h"
|
||||||
|
#include "nsDataHashtable.h"
|
||||||
#include "nsAttrValue.h"
|
#include "nsAttrValue.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsError.h"
|
#include "nsError.h"
|
||||||
|
#include "nsHashKeys.h"
|
||||||
#include "mozilla/dom/Element.h"
|
#include "mozilla/dom/Element.h"
|
||||||
#include "mozilla/dom/DOMTokenListBinding.h"
|
#include "mozilla/dom/DOMTokenListBinding.h"
|
||||||
|
#include "mozilla/BloomFilter.h"
|
||||||
#include "mozilla/ErrorResult.h"
|
#include "mozilla/ErrorResult.h"
|
||||||
|
|
||||||
using namespace mozilla;
|
using namespace mozilla;
|
||||||
using namespace mozilla::dom;
|
using namespace mozilla::dom;
|
||||||
|
|
||||||
nsDOMTokenList::nsDOMTokenList(Element* aElement, nsIAtom* aAttrAtom)
|
nsDOMTokenList::nsDOMTokenList(Element* aElement, nsIAtom* aAttrAtom,
|
||||||
|
const DOMTokenListSupportedTokenArray aSupportedTokens)
|
||||||
: mElement(aElement),
|
: mElement(aElement),
|
||||||
mAttrAtom(aAttrAtom)
|
mAttrAtom(aAttrAtom),
|
||||||
|
mSupportedTokens(aSupportedTokens)
|
||||||
{
|
{
|
||||||
// We don't add a reference to our element. If it goes away,
|
// We don't add a reference to our element. If it goes away,
|
||||||
// we'll be told to drop our reference
|
// we'll be told to drop our reference
|
||||||
|
@ -50,6 +55,45 @@ nsDOMTokenList::GetParsedAttr()
|
||||||
return mElement->GetAttrInfo(kNameSpaceID_None, mAttrAtom).mValue;
|
return mElement->GetAttrInfo(kNameSpaceID_None, mAttrAtom).mValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsDOMTokenList::RemoveDuplicates(const nsAttrValue* aAttr)
|
||||||
|
{
|
||||||
|
if (!aAttr || aAttr->Type() != nsAttrValue::eAtomArray) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BloomFilter<8, nsIAtom> filter;
|
||||||
|
nsAttrValue::AtomArray* array = aAttr->GetAtomArrayValue();
|
||||||
|
for (uint32_t i = 0; i < array->Length(); i++) {
|
||||||
|
nsIAtom* atom = array->ElementAt(i);
|
||||||
|
if (filter.mightContain(atom)) {
|
||||||
|
// Start again, with a hashtable
|
||||||
|
RemoveDuplicatesInternal(array, i);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
filter.add(atom);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsDOMTokenList::RemoveDuplicatesInternal(nsAttrValue::AtomArray* aArray,
|
||||||
|
uint32_t aStart)
|
||||||
|
{
|
||||||
|
nsDataHashtable<nsPtrHashKey<nsIAtom>, bool> tokens;
|
||||||
|
|
||||||
|
for (uint32_t i = 0; i < aArray->Length(); i++) {
|
||||||
|
nsIAtom* atom = aArray->ElementAt(i);
|
||||||
|
// No need to check the hashtable below aStart
|
||||||
|
if (i >= aStart && tokens.Get(atom)) {
|
||||||
|
aArray->RemoveElementAt(i);
|
||||||
|
i--;
|
||||||
|
} else {
|
||||||
|
tokens.Put(atom, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t
|
uint32_t
|
||||||
nsDOMTokenList::Length()
|
nsDOMTokenList::Length()
|
||||||
{
|
{
|
||||||
|
@ -58,6 +102,7 @@ nsDOMTokenList::Length()
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RemoveDuplicates(attr);
|
||||||
return attr->GetAtomCount();
|
return attr->GetAtomCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -66,6 +111,13 @@ nsDOMTokenList::IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aResult)
|
||||||
{
|
{
|
||||||
const nsAttrValue* attr = GetParsedAttr();
|
const nsAttrValue* attr = GetParsedAttr();
|
||||||
|
|
||||||
|
if (!attr || aIndex >= static_cast<uint32_t>(attr->GetAtomCount())) {
|
||||||
|
aFound = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
RemoveDuplicates(attr);
|
||||||
|
|
||||||
if (attr && aIndex < static_cast<uint32_t>(attr->GetAtomCount())) {
|
if (attr && aIndex < static_cast<uint32_t>(attr->GetAtomCount())) {
|
||||||
aFound = true;
|
aFound = true;
|
||||||
attr->AtomAt(aIndex)->ToString(aResult);
|
attr->AtomAt(aIndex)->ToString(aResult);
|
||||||
|
@ -74,6 +126,16 @@ nsDOMTokenList::IndexedGetter(uint32_t aIndex, bool& aFound, nsAString& aResult)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsDOMTokenList::SetValue(const nsAString& aValue, ErrorResult& rv)
|
||||||
|
{
|
||||||
|
if (!mElement) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rv = mElement->SetAttr(kNameSpaceID_None, mAttrAtom, aValue, true);
|
||||||
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
nsDOMTokenList::CheckToken(const nsAString& aStr)
|
nsDOMTokenList::CheckToken(const nsAString& aStr)
|
||||||
{
|
{
|
||||||
|
@ -130,10 +192,15 @@ nsDOMTokenList::AddInternal(const nsAttrValue* aAttr,
|
||||||
nsAutoString resultStr;
|
nsAutoString resultStr;
|
||||||
|
|
||||||
if (aAttr) {
|
if (aAttr) {
|
||||||
aAttr->ToString(resultStr);
|
RemoveDuplicates(aAttr);
|
||||||
|
for (uint32_t i = 0; i < aAttr->GetAtomCount(); i++) {
|
||||||
|
if (i != 0) {
|
||||||
|
resultStr.AppendLiteral(" ");
|
||||||
|
}
|
||||||
|
resultStr.Append(nsDependentAtomString(aAttr->AtomAt(i)));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool oneWasAdded = false;
|
|
||||||
nsAutoTArray<nsString, 10> addedClasses;
|
nsAutoTArray<nsString, 10> addedClasses;
|
||||||
|
|
||||||
for (uint32_t i = 0, l = aTokens.Length(); i < l; ++i) {
|
for (uint32_t i = 0, l = aTokens.Length(); i < l; ++i) {
|
||||||
|
@ -144,16 +211,11 @@ nsDOMTokenList::AddInternal(const nsAttrValue* aAttr,
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (oneWasAdded ||
|
if (!resultStr.IsEmpty()) {
|
||||||
(!resultStr.IsEmpty() &&
|
|
||||||
!nsContentUtils::IsHTMLWhitespace(resultStr.Last()))) {
|
|
||||||
resultStr.Append(' ');
|
resultStr.Append(' ');
|
||||||
resultStr.Append(aToken);
|
|
||||||
} else {
|
|
||||||
resultStr.Append(aToken);
|
|
||||||
}
|
}
|
||||||
|
resultStr.Append(aToken);
|
||||||
|
|
||||||
oneWasAdded = true;
|
|
||||||
addedClasses.AppendElement(aToken);
|
addedClasses.AppendElement(aToken);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -186,60 +248,20 @@ nsDOMTokenList::RemoveInternal(const nsAttrValue* aAttr,
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(aAttr, "Need an attribute");
|
MOZ_ASSERT(aAttr, "Need an attribute");
|
||||||
|
|
||||||
nsAutoString input;
|
RemoveDuplicates(aAttr);
|
||||||
aAttr->ToString(input);
|
|
||||||
|
|
||||||
nsAString::const_iterator copyStart, tokenStart, iter, end;
|
nsAutoString resultStr;
|
||||||
input.BeginReading(iter);
|
for (uint32_t i = 0; i < aAttr->GetAtomCount(); i++) {
|
||||||
input.EndReading(end);
|
if (aTokens.Contains(nsDependentAtomString(aAttr->AtomAt(i)))) {
|
||||||
copyStart = iter;
|
continue;
|
||||||
|
|
||||||
nsAutoString output;
|
|
||||||
bool lastTokenRemoved = false;
|
|
||||||
|
|
||||||
while (iter != end) {
|
|
||||||
// skip whitespace.
|
|
||||||
while (iter != end && nsContentUtils::IsHTMLWhitespace(*iter)) {
|
|
||||||
++iter;
|
|
||||||
}
|
}
|
||||||
|
if (!resultStr.IsEmpty()) {
|
||||||
if (iter == end) {
|
resultStr.AppendLiteral(" ");
|
||||||
// At this point we're sure the last seen token (if any) wasn't to be
|
|
||||||
// removed. So the trailing spaces will need to be kept.
|
|
||||||
MOZ_ASSERT(!lastTokenRemoved, "How did this happen?");
|
|
||||||
|
|
||||||
output.Append(Substring(copyStart, end));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
tokenStart = iter;
|
|
||||||
do {
|
|
||||||
++iter;
|
|
||||||
} while (iter != end && !nsContentUtils::IsHTMLWhitespace(*iter));
|
|
||||||
|
|
||||||
if (aTokens.Contains(Substring(tokenStart, iter))) {
|
|
||||||
|
|
||||||
// Skip whitespace after the token, it will be collapsed.
|
|
||||||
while (iter != end && nsContentUtils::IsHTMLWhitespace(*iter)) {
|
|
||||||
++iter;
|
|
||||||
}
|
|
||||||
copyStart = iter;
|
|
||||||
lastTokenRemoved = true;
|
|
||||||
|
|
||||||
} else {
|
|
||||||
|
|
||||||
if (lastTokenRemoved && !output.IsEmpty()) {
|
|
||||||
MOZ_ASSERT(!nsContentUtils::IsHTMLWhitespace(output.Last()),
|
|
||||||
"Invalid last output token");
|
|
||||||
output.Append(char16_t(' '));
|
|
||||||
}
|
|
||||||
lastTokenRemoved = false;
|
|
||||||
output.Append(Substring(copyStart, iter));
|
|
||||||
copyStart = iter;
|
|
||||||
}
|
}
|
||||||
|
resultStr.Append(nsDependentAtomString(aAttr->AtomAt(i)));
|
||||||
}
|
}
|
||||||
|
|
||||||
mElement->SetAttr(kNameSpaceID_None, mAttrAtom, output, true);
|
mElement->SetAttr(kNameSpaceID_None, mAttrAtom, resultStr, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
|
@ -299,6 +321,93 @@ nsDOMTokenList::Toggle(const nsAString& aToken,
|
||||||
return isPresent;
|
return isPresent;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
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()) {
|
||||||
|
aError.Throw(NS_ERROR_DOM_SYNTAX_ERR);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
aError = CheckToken(aToken);
|
||||||
|
if (aError.Failed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
aError = CheckToken(aNewToken);
|
||||||
|
if (aError.Failed()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const nsAttrValue* attr = GetParsedAttr();
|
||||||
|
if (!attr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReplaceInternal(attr, aToken, aNewToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
void
|
||||||
|
nsDOMTokenList::ReplaceInternal(const nsAttrValue* aAttr,
|
||||||
|
const nsAString& aToken,
|
||||||
|
const nsAString& aNewToken)
|
||||||
|
{
|
||||||
|
RemoveDuplicates(aAttr);
|
||||||
|
|
||||||
|
bool sawIt = false;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
sawIt = true;
|
||||||
|
if (!resultStr.IsEmpty()) {
|
||||||
|
resultStr.AppendLiteral(" ");
|
||||||
|
}
|
||||||
|
resultStr.Append(aNewToken);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!resultStr.IsEmpty()) {
|
||||||
|
resultStr.AppendLiteral(" ");
|
||||||
|
}
|
||||||
|
resultStr.Append(nsDependentAtomString(aAttr->AtomAt(i)));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sawIt) {
|
||||||
|
mElement->SetAttr(kNameSpaceID_None, mAttrAtom, resultStr, true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
nsDOMTokenList::Supports(const nsAString& aToken,
|
||||||
|
ErrorResult& aError)
|
||||||
|
{
|
||||||
|
if (!mSupportedTokens) {
|
||||||
|
aError.ThrowTypeError<MSG_TOKENLIST_NO_SUPPORTED_TOKENS>(
|
||||||
|
mElement->LocalName(),
|
||||||
|
nsDependentAtomString(mAttrAtom));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (DOMTokenListSupportedToken* supportedToken = mSupportedTokens;
|
||||||
|
*supportedToken;
|
||||||
|
++supportedToken) {
|
||||||
|
if (aToken.LowerCaseEqualsASCII(*supportedToken)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
nsDOMTokenList::Stringify(nsAString& aResult)
|
nsDOMTokenList::Stringify(nsAString& aResult)
|
||||||
{
|
{
|
||||||
|
|
|
@ -13,9 +13,11 @@
|
||||||
|
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsDOMString.h"
|
#include "nsDOMString.h"
|
||||||
|
#include "nsDOMString.h"
|
||||||
#include "nsWrapperCache.h"
|
#include "nsWrapperCache.h"
|
||||||
#include "mozilla/dom/Element.h"
|
#include "mozilla/dom/Element.h"
|
||||||
#include "mozilla/dom/BindingDeclarations.h"
|
#include "mozilla/dom/BindingDeclarations.h"
|
||||||
|
#include "mozilla/dom/DOMTokenListSupportedTokens.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
class ErrorResult;
|
class ErrorResult;
|
||||||
|
@ -26,7 +28,7 @@ class nsAttrValue;
|
||||||
class nsIAtom;
|
class nsIAtom;
|
||||||
|
|
||||||
// nsISupports must be on the primary inheritance chain
|
// nsISupports must be on the primary inheritance chain
|
||||||
// because nsDOMSettableTokenList is traversed by Element.
|
|
||||||
class nsDOMTokenList : public nsISupports,
|
class nsDOMTokenList : public nsISupports,
|
||||||
public nsWrapperCache
|
public nsWrapperCache
|
||||||
{
|
{
|
||||||
|
@ -37,7 +39,8 @@ public:
|
||||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMTokenList)
|
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(nsDOMTokenList)
|
||||||
|
|
||||||
nsDOMTokenList(Element* aElement, nsIAtom* aAttrAtom);
|
nsDOMTokenList(Element* aElement, nsIAtom* aAttrAtom,
|
||||||
|
const mozilla::dom::DOMTokenListSupportedTokenArray = nullptr);
|
||||||
|
|
||||||
virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
|
virtual JSObject* WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
|
||||||
|
|
||||||
|
@ -46,6 +49,7 @@ public:
|
||||||
return mElement;
|
return mElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void RemoveDuplicates(const nsAttrValue* aAttr);
|
||||||
uint32_t Length();
|
uint32_t Length();
|
||||||
void Item(uint32_t aIndex, nsAString& aResult)
|
void Item(uint32_t aIndex, nsAString& aResult)
|
||||||
{
|
{
|
||||||
|
@ -63,9 +67,17 @@ public:
|
||||||
void Remove(const nsAString& aToken, mozilla::ErrorResult& aError);
|
void Remove(const nsAString& aToken, mozilla::ErrorResult& aError);
|
||||||
void Remove(const nsTArray<nsString>& aTokens,
|
void Remove(const nsTArray<nsString>& aTokens,
|
||||||
mozilla::ErrorResult& aError);
|
mozilla::ErrorResult& aError);
|
||||||
|
void Replace(const nsAString& aToken,
|
||||||
|
const nsAString& aNewToken,
|
||||||
|
mozilla::ErrorResult& aError);
|
||||||
bool Toggle(const nsAString& aToken,
|
bool Toggle(const nsAString& aToken,
|
||||||
const mozilla::dom::Optional<bool>& force,
|
const mozilla::dom::Optional<bool>& force,
|
||||||
mozilla::ErrorResult& aError);
|
mozilla::ErrorResult& aError);
|
||||||
|
bool Supports(const nsAString& aToken,
|
||||||
|
mozilla::ErrorResult& aError);
|
||||||
|
|
||||||
|
void GetValue(nsAString& aResult) { Stringify(aResult); }
|
||||||
|
void SetValue(const nsAString& aValue, mozilla::ErrorResult& rv);
|
||||||
void Stringify(nsAString& aResult);
|
void Stringify(nsAString& aResult);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -73,14 +85,20 @@ protected:
|
||||||
|
|
||||||
nsresult CheckToken(const nsAString& aStr);
|
nsresult CheckToken(const nsAString& aStr);
|
||||||
nsresult CheckTokens(const nsTArray<nsString>& aStr);
|
nsresult CheckTokens(const nsTArray<nsString>& aStr);
|
||||||
|
void RemoveDuplicatesInternal(nsTArray<nsCOMPtr<nsIAtom>>* aArray,
|
||||||
|
uint32_t aStart);
|
||||||
void AddInternal(const nsAttrValue* aAttr,
|
void AddInternal(const nsAttrValue* aAttr,
|
||||||
const nsTArray<nsString>& aTokens);
|
const nsTArray<nsString>& aTokens);
|
||||||
void RemoveInternal(const nsAttrValue* aAttr,
|
void RemoveInternal(const nsAttrValue* aAttr,
|
||||||
const nsTArray<nsString>& aTokens);
|
const nsTArray<nsString>& aTokens);
|
||||||
|
void ReplaceInternal(const nsAttrValue* aAttr,
|
||||||
|
const nsAString& aToken,
|
||||||
|
const nsAString& aNewToken);
|
||||||
inline const nsAttrValue* GetParsedAttr();
|
inline const nsAttrValue* GetParsedAttr();
|
||||||
|
|
||||||
nsCOMPtr<Element> mElement;
|
nsCOMPtr<Element> mElement;
|
||||||
nsCOMPtr<nsIAtom> mAttrAtom;
|
nsCOMPtr<nsIAtom> mAttrAtom;
|
||||||
|
const mozilla::dom::DOMTokenListSupportedTokenArray mSupportedTokens;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // nsDOMTokenList_h___
|
#endif // nsDOMTokenList_h___
|
||||||
|
|
|
@ -149,7 +149,9 @@ nsStyleLinkElement::IsImportEnabled()
|
||||||
}
|
}
|
||||||
|
|
||||||
static uint32_t ToLinkMask(const nsAString& aLink, nsIPrincipal* aPrincipal)
|
static uint32_t ToLinkMask(const nsAString& aLink, nsIPrincipal* aPrincipal)
|
||||||
{
|
{
|
||||||
|
// Keep this in sync with sRelValues in HTMLLinkElement.cpp
|
||||||
|
// XXX: "icon" and "search" are supported, but not listed here.
|
||||||
if (aLink.EqualsLiteral("prefetch"))
|
if (aLink.EqualsLiteral("prefetch"))
|
||||||
return nsStyleLinkElement::ePREFETCH;
|
return nsStyleLinkElement::ePREFETCH;
|
||||||
else if (aLink.EqualsLiteral("dns-prefetch"))
|
else if (aLink.EqualsLiteral("dns-prefetch"))
|
||||||
|
|
|
@ -441,10 +441,6 @@ DOMInterfaces = {
|
||||||
'implicitJSContext': [ 'then' ],
|
'implicitJSContext': [ 'then' ],
|
||||||
},
|
},
|
||||||
|
|
||||||
'DOMSettableTokenList': {
|
|
||||||
'nativeType': 'nsDOMSettableTokenList',
|
|
||||||
},
|
|
||||||
|
|
||||||
'DOMStringMap': {
|
'DOMStringMap': {
|
||||||
'nativeType': 'nsDOMStringMap'
|
'nativeType': 'nsDOMStringMap'
|
||||||
},
|
},
|
||||||
|
|
|
@ -92,3 +92,4 @@ MSG_DEF(MSG_IS_NOT_PROMISE, 1, JSEXN_TYPEERR, "{0} is not a Promise")
|
||||||
MSG_DEF(MSG_SW_INSTALL_ERROR, 2, JSEXN_TYPEERR, "ServiceWorker script at {0} for scope {1} encountered an error during installation.")
|
MSG_DEF(MSG_SW_INSTALL_ERROR, 2, JSEXN_TYPEERR, "ServiceWorker script at {0} for scope {1} encountered an error during installation.")
|
||||||
MSG_DEF(MSG_SW_SCRIPT_THREW, 2, JSEXN_TYPEERR, "ServiceWorker script at {0} for scope {1} threw an exception during script evaluation.")
|
MSG_DEF(MSG_SW_SCRIPT_THREW, 2, JSEXN_TYPEERR, "ServiceWorker script at {0} for scope {1} threw an exception during script evaluation.")
|
||||||
MSG_DEF(MSG_TYPEDARRAY_IS_SHARED, 1, JSEXN_TYPEERR, "{0} can't be a typed array on SharedArrayBuffer")
|
MSG_DEF(MSG_TYPEDARRAY_IS_SHARED, 1, JSEXN_TYPEERR, "{0} can't be a typed array on SharedArrayBuffer")
|
||||||
|
MSG_DEF(MSG_TOKENLIST_NO_SUPPORTED_TOKENS, 2, JSEXN_TYPEERR, "{0} attribute of <{1}> does not define any supported tokens")
|
||||||
|
|
|
@ -55,17 +55,22 @@ TestInterfaceIterableSingle::GetParentObject() const
|
||||||
return mParent;
|
return mParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t
|
uint32_t
|
||||||
TestInterfaceIterableSingle::GetIterableLength() const
|
TestInterfaceIterableSingle::Length() const
|
||||||
{
|
{
|
||||||
return mValues.Length();
|
return mValues.Length();
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t
|
int32_t
|
||||||
TestInterfaceIterableSingle::GetValueAtIndex(uint32_t index) const
|
TestInterfaceIterableSingle::IndexedGetter(uint32_t aIndex, bool& aFound) const
|
||||||
{
|
{
|
||||||
MOZ_ASSERT(index < mValues.Length());
|
if (aIndex >= mValues.Length()) {
|
||||||
return mValues.ElementAt(index);
|
aFound = false;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
aFound = true;
|
||||||
|
return mValues[aIndex];
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
|
@ -36,12 +36,13 @@ public:
|
||||||
static already_AddRefed<TestInterfaceIterableSingle>
|
static already_AddRefed<TestInterfaceIterableSingle>
|
||||||
Constructor(const GlobalObject& aGlobal, ErrorResult& rv);
|
Constructor(const GlobalObject& aGlobal, ErrorResult& rv);
|
||||||
|
|
||||||
size_t GetIterableLength() const;
|
uint32_t Length() const;
|
||||||
uint32_t GetValueAtIndex(uint32_t aIndex) const;
|
int32_t IndexedGetter(uint32_t aIndex, bool& aFound) const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
virtual ~TestInterfaceIterableSingle() {}
|
virtual ~TestInterfaceIterableSingle() {}
|
||||||
nsCOMPtr<nsPIDOMWindow> mParent;
|
nsCOMPtr<nsPIDOMWindow> mParent;
|
||||||
nsTArray<uint32_t> mValues;
|
nsTArray<int32_t> mValues;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
|
@ -39,6 +39,12 @@ ASSERT_NODE_FLAGS_SPACE(ELEMENT_TYPE_SPECIFIC_BITS_OFFSET + 2);
|
||||||
|
|
||||||
#undef ANCHOR_ELEMENT_FLAG_BIT
|
#undef ANCHOR_ELEMENT_FLAG_BIT
|
||||||
|
|
||||||
|
// static
|
||||||
|
const DOMTokenListSupportedToken HTMLAnchorElement::sSupportedRelValues[] = {
|
||||||
|
"noreferrer",
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
|
||||||
HTMLAnchorElement::~HTMLAnchorElement()
|
HTMLAnchorElement::~HTMLAnchorElement()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
@ -302,7 +308,7 @@ nsDOMTokenList*
|
||||||
HTMLAnchorElement::RelList()
|
HTMLAnchorElement::RelList()
|
||||||
{
|
{
|
||||||
if (!mRelList) {
|
if (!mRelList) {
|
||||||
mRelList = new nsDOMTokenList(this, nsGkAtoms::rel);
|
mRelList = new nsDOMTokenList(this, nsGkAtoms::rel, sSupportedRelValues);
|
||||||
}
|
}
|
||||||
return mRelList;
|
return mRelList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -227,6 +227,8 @@ public:
|
||||||
GetHref(aResult);
|
GetHref(aResult);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static DOMTokenListSupportedToken sSupportedRelValues[];
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual ~HTMLAnchorElement();
|
virtual ~HTMLAnchorElement();
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@
|
||||||
#include "mozilla/dom/HTMLAreaElement.h"
|
#include "mozilla/dom/HTMLAreaElement.h"
|
||||||
|
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
|
#include "mozilla/dom/HTMLAnchorElement.h"
|
||||||
#include "mozilla/dom/HTMLAreaElementBinding.h"
|
#include "mozilla/dom/HTMLAreaElementBinding.h"
|
||||||
#include "mozilla/EventDispatcher.h"
|
#include "mozilla/EventDispatcher.h"
|
||||||
#include "mozilla/EventStates.h"
|
#include "mozilla/EventStates.h"
|
||||||
|
@ -122,7 +123,8 @@ nsDOMTokenList*
|
||||||
HTMLAreaElement::RelList()
|
HTMLAreaElement::RelList()
|
||||||
{
|
{
|
||||||
if (!mRelList) {
|
if (!mRelList) {
|
||||||
mRelList = new nsDOMTokenList(this, nsGkAtoms::rel);
|
mRelList = new nsDOMTokenList(this, nsGkAtoms::rel,
|
||||||
|
HTMLAnchorElement::sSupportedRelValues);
|
||||||
}
|
}
|
||||||
return mRelList;
|
return mRelList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -18,6 +18,15 @@ NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(IFrame)
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
|
// static
|
||||||
|
const DOMTokenListSupportedToken HTMLIFrameElement::sSupportedSandboxTokens[] =
|
||||||
|
{
|
||||||
|
#define SANDBOX_KEYWORD(string, atom, flags) string,
|
||||||
|
#include "IframeSandboxKeywordList.h"
|
||||||
|
#undef SANDBOX_KEYWORD
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
|
||||||
HTMLIFrameElement::HTMLIFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
HTMLIFrameElement::HTMLIFrameElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo,
|
||||||
FromParser aFromParser)
|
FromParser aFromParser)
|
||||||
: nsGenericHTMLFrameElement(aNodeInfo, aFromParser)
|
: nsGenericHTMLFrameElement(aNodeInfo, aFromParser)
|
||||||
|
|
|
@ -10,7 +10,7 @@
|
||||||
#include "mozilla/Attributes.h"
|
#include "mozilla/Attributes.h"
|
||||||
#include "nsGenericHTMLFrameElement.h"
|
#include "nsGenericHTMLFrameElement.h"
|
||||||
#include "nsIDOMHTMLIFrameElement.h"
|
#include "nsIDOMHTMLIFrameElement.h"
|
||||||
#include "nsDOMSettableTokenList.h"
|
#include "nsDOMTokenList.h"
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
@ -84,9 +84,9 @@ public:
|
||||||
{
|
{
|
||||||
SetHTMLAttr(nsGkAtoms::name, aName, aError);
|
SetHTMLAttr(nsGkAtoms::name, aName, aError);
|
||||||
}
|
}
|
||||||
nsDOMSettableTokenList* Sandbox()
|
nsDOMTokenList* Sandbox()
|
||||||
{
|
{
|
||||||
return GetTokenList(nsGkAtoms::sandbox);
|
return GetTokenList(nsGkAtoms::sandbox, sSupportedSandboxTokens);
|
||||||
}
|
}
|
||||||
bool AllowFullscreen() const
|
bool AllowFullscreen() const
|
||||||
{
|
{
|
||||||
|
@ -202,6 +202,8 @@ protected:
|
||||||
private:
|
private:
|
||||||
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
static void MapAttributesIntoRule(const nsMappedAttributes* aAttributes,
|
||||||
nsRuleData* aData);
|
nsRuleData* aData);
|
||||||
|
|
||||||
|
static const DOMTokenListSupportedToken sSupportedSandboxTokens[];
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#include "nsPIDOMWindow.h"
|
#include "nsPIDOMWindow.h"
|
||||||
#include "nsReadableUtils.h"
|
#include "nsReadableUtils.h"
|
||||||
#include "nsStyleConsts.h"
|
#include "nsStyleConsts.h"
|
||||||
|
#include "nsStyleLinkElement.h"
|
||||||
#include "nsUnicharUtils.h"
|
#include "nsUnicharUtils.h"
|
||||||
|
|
||||||
#define LINK_ELEMENT_FLAG_BIT(n_) \
|
#define LINK_ELEMENT_FLAG_BIT(n_) \
|
||||||
|
@ -499,11 +500,30 @@ HTMLLinkElement::GetLinkTarget(nsAString& aTarget)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static const DOMTokenListSupportedToken sSupportedRelValues[] = {
|
||||||
|
// Keep this in sync with ToLinkMask in nsStyleLinkElement.cpp.
|
||||||
|
// "import" must come first because it's conditional.
|
||||||
|
"import"
|
||||||
|
"prefetch",
|
||||||
|
"dns-prefetch",
|
||||||
|
"stylesheet",
|
||||||
|
"next",
|
||||||
|
"alternate",
|
||||||
|
"preconnect",
|
||||||
|
"icon",
|
||||||
|
"search",
|
||||||
|
nullptr
|
||||||
|
};
|
||||||
|
|
||||||
nsDOMTokenList*
|
nsDOMTokenList*
|
||||||
HTMLLinkElement::RelList()
|
HTMLLinkElement::RelList()
|
||||||
{
|
{
|
||||||
if (!mRelList) {
|
if (!mRelList) {
|
||||||
mRelList = new nsDOMTokenList(this, nsGkAtoms::rel);
|
const DOMTokenListSupportedTokenArray relValues =
|
||||||
|
nsStyleLinkElement::IsImportEnabled() ?
|
||||||
|
sSupportedRelValues : &sSupportedRelValues[1];
|
||||||
|
|
||||||
|
mRelList = new nsDOMTokenList(this, nsGkAtoms::rel, relValues);
|
||||||
}
|
}
|
||||||
return mRelList;
|
return mRelList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -119,7 +119,7 @@ public:
|
||||||
{
|
{
|
||||||
SetHTMLAttr(nsGkAtoms::hreflang, aHreflang, aRv);
|
SetHTMLAttr(nsGkAtoms::hreflang, aHreflang, aRv);
|
||||||
}
|
}
|
||||||
nsDOMSettableTokenList* Sizes()
|
nsDOMTokenList* Sizes()
|
||||||
{
|
{
|
||||||
return GetTokenList(nsGkAtoms::sizes);
|
return GetTokenList(nsGkAtoms::sizes);
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
#include "mozilla/dom/HTMLMenuItemElementBinding.h"
|
#include "mozilla/dom/HTMLMenuItemElementBinding.h"
|
||||||
#include "nsAttrValueInlines.h"
|
#include "nsAttrValueInlines.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
|
#include "nsDOMTokenList.h"
|
||||||
|
|
||||||
|
|
||||||
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(MenuItem)
|
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(MenuItem)
|
||||||
|
|
|
@ -11,7 +11,6 @@
|
||||||
#include "mozilla/dom/HTMLFormElement.h"
|
#include "mozilla/dom/HTMLFormElement.h"
|
||||||
#include "mozilla/dom/HTMLOutputElementBinding.h"
|
#include "mozilla/dom/HTMLOutputElementBinding.h"
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsDOMSettableTokenList.h"
|
|
||||||
#include "nsFormSubmission.h"
|
#include "nsFormSubmission.h"
|
||||||
|
|
||||||
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Output)
|
NS_IMPL_NS_NEW_HTML_ELEMENT_CHECK_PARSER(Output)
|
||||||
|
@ -166,11 +165,11 @@ HTMLOutputElement::SetDefaultValue(const nsAString& aDefaultValue, ErrorResult&
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nsDOMSettableTokenList*
|
nsDOMTokenList*
|
||||||
HTMLOutputElement::HtmlFor()
|
HTMLOutputElement::HtmlFor()
|
||||||
{
|
{
|
||||||
if (!mTokenList) {
|
if (!mTokenList) {
|
||||||
mTokenList = new nsDOMSettableTokenList(this, nsGkAtoms::_for);
|
mTokenList = new nsDOMTokenList(this, nsGkAtoms::_for);
|
||||||
}
|
}
|
||||||
return mTokenList;
|
return mTokenList;
|
||||||
}
|
}
|
||||||
|
|
|
@ -64,7 +64,7 @@ public:
|
||||||
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
virtual JSObject* WrapNode(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
|
||||||
|
|
||||||
// WebIDL
|
// WebIDL
|
||||||
nsDOMSettableTokenList* HtmlFor();
|
nsDOMTokenList* HtmlFor();
|
||||||
// nsGenericHTMLFormElement::GetForm is fine.
|
// nsGenericHTMLFormElement::GetForm is fine.
|
||||||
void GetName(nsAString& aName)
|
void GetName(nsAString& aName)
|
||||||
{
|
{
|
||||||
|
@ -108,7 +108,7 @@ protected:
|
||||||
ValueModeFlag mValueModeFlag;
|
ValueModeFlag mValueModeFlag;
|
||||||
bool mIsDoneAddingChildren;
|
bool mIsDoneAddingChildren;
|
||||||
nsString mDefaultValue;
|
nsString mDefaultValue;
|
||||||
RefPtr<nsDOMSettableTokenList> mTokenList;
|
RefPtr<nsDOMTokenList> mTokenList;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
|
@ -9,7 +9,7 @@
|
||||||
#include "nsContentUtils.h"
|
#include "nsContentUtils.h"
|
||||||
#include "nsGenericHTMLElement.h"
|
#include "nsGenericHTMLElement.h"
|
||||||
#include "nsVariant.h"
|
#include "nsVariant.h"
|
||||||
#include "nsDOMSettableTokenList.h"
|
#include "nsDOMTokenList.h"
|
||||||
#include "nsAttrValue.h"
|
#include "nsAttrValue.h"
|
||||||
#include "nsWrapperCacheInlines.h"
|
#include "nsWrapperCacheInlines.h"
|
||||||
#include "mozilla/dom/HTMLPropertiesCollectionBinding.h"
|
#include "mozilla/dom/HTMLPropertiesCollectionBinding.h"
|
||||||
|
|
|
@ -47,7 +47,7 @@ public:
|
||||||
{
|
{
|
||||||
SetUnsignedIntAttr(nsGkAtoms::rowspan, aRowSpan, aError);
|
SetUnsignedIntAttr(nsGkAtoms::rowspan, aRowSpan, aError);
|
||||||
}
|
}
|
||||||
//already_AddRefed<nsDOMSettableTokenList> Headers() const;
|
//already_AddRefed<nsDOMTokenList> Headers() const;
|
||||||
void GetHeaders(DOMString& aHeaders)
|
void GetHeaders(DOMString& aHeaders)
|
||||||
{
|
{
|
||||||
GetHTMLAttr(nsGkAtoms::headers, aHeaders);
|
GetHTMLAttr(nsGkAtoms::headers, aHeaders);
|
||||||
|
|
|
@ -96,7 +96,7 @@
|
||||||
|
|
||||||
#include "HTMLPropertiesCollection.h"
|
#include "HTMLPropertiesCollection.h"
|
||||||
#include "nsVariant.h"
|
#include "nsVariant.h"
|
||||||
#include "nsDOMSettableTokenList.h"
|
#include "nsDOMTokenList.h"
|
||||||
#include "nsThreadUtils.h"
|
#include "nsThreadUtils.h"
|
||||||
#include "nsTextFragment.h"
|
#include "nsTextFragment.h"
|
||||||
#include "mozilla/dom/BindingUtils.h"
|
#include "mozilla/dom/BindingUtils.h"
|
||||||
|
|
|
@ -20,7 +20,7 @@
|
||||||
#include "mozilla/dom/ValidityState.h"
|
#include "mozilla/dom/ValidityState.h"
|
||||||
#include "mozilla/dom/ElementInlines.h"
|
#include "mozilla/dom/ElementInlines.h"
|
||||||
|
|
||||||
class nsDOMSettableTokenList;
|
class nsDOMTokenList;
|
||||||
class nsIDOMHTMLMenuElement;
|
class nsIDOMHTMLMenuElement;
|
||||||
class nsIEditor;
|
class nsIEditor;
|
||||||
class nsIFormControlFrame;
|
class nsIFormControlFrame;
|
||||||
|
@ -104,7 +104,7 @@ public:
|
||||||
{
|
{
|
||||||
SetHTMLBoolAttr(nsGkAtoms::itemscope, aItemScope, aError);
|
SetHTMLBoolAttr(nsGkAtoms::itemscope, aItemScope, aError);
|
||||||
}
|
}
|
||||||
nsDOMSettableTokenList* ItemType()
|
nsDOMTokenList* ItemType()
|
||||||
{
|
{
|
||||||
return GetTokenList(nsGkAtoms::itemtype);
|
return GetTokenList(nsGkAtoms::itemtype);
|
||||||
}
|
}
|
||||||
|
@ -116,11 +116,11 @@ public:
|
||||||
{
|
{
|
||||||
SetHTMLAttr(nsGkAtoms::itemid, aItemID, aError);
|
SetHTMLAttr(nsGkAtoms::itemid, aItemID, aError);
|
||||||
}
|
}
|
||||||
nsDOMSettableTokenList* ItemRef()
|
nsDOMTokenList* ItemRef()
|
||||||
{
|
{
|
||||||
return GetTokenList(nsGkAtoms::itemref);
|
return GetTokenList(nsGkAtoms::itemref);
|
||||||
}
|
}
|
||||||
nsDOMSettableTokenList* ItemProp()
|
nsDOMTokenList* ItemProp()
|
||||||
{
|
{
|
||||||
return GetTokenList(nsGkAtoms::itemprop);
|
return GetTokenList(nsGkAtoms::itemprop);
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,7 +32,7 @@ interface nsIDOMHTMLElement : nsIDOMElement
|
||||||
attribute nsIVariant itemType;
|
attribute nsIVariant itemType;
|
||||||
attribute DOMString itemId;
|
attribute DOMString itemId;
|
||||||
readonly attribute nsISupports properties;
|
readonly attribute nsISupports properties;
|
||||||
// The following attributes are really nsDOMSettableTokenList, which has
|
// The following attributes are really nsDOMTokenList, which has
|
||||||
// PutForwards, so we express them as nsIVariants to deal with this.
|
// PutForwards, so we express them as nsIVariants to deal with this.
|
||||||
attribute nsIVariant itemValue;
|
attribute nsIVariant itemValue;
|
||||||
attribute nsIVariant itemProp;
|
attribute nsIVariant itemProp;
|
||||||
|
|
|
@ -20,7 +20,13 @@ interface DOMTokenList {
|
||||||
[Throws]
|
[Throws]
|
||||||
void remove(DOMString... tokens);
|
void remove(DOMString... tokens);
|
||||||
[Throws]
|
[Throws]
|
||||||
|
void replace(DOMString token, DOMString newToken);
|
||||||
|
[Throws]
|
||||||
boolean toggle(DOMString token, optional boolean force);
|
boolean toggle(DOMString token, optional boolean force);
|
||||||
|
[Throws]
|
||||||
|
boolean supports(DOMString token);
|
||||||
|
[SetterThrows]
|
||||||
|
attribute DOMString value;
|
||||||
stringifier DOMString ();
|
stringifier DOMString ();
|
||||||
iterable<DOMString?>;
|
iterable<DOMString?>;
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,7 +30,7 @@ interface Element : Node {
|
||||||
attribute DOMString id;
|
attribute DOMString id;
|
||||||
[Pure]
|
[Pure]
|
||||||
attribute DOMString className;
|
attribute DOMString className;
|
||||||
[Constant]
|
[Constant, PutForwards=value]
|
||||||
readonly attribute DOMTokenList classList;
|
readonly attribute DOMTokenList classList;
|
||||||
|
|
||||||
[SameObject]
|
[SameObject]
|
||||||
|
|
|
@ -23,6 +23,7 @@ interface HTMLAnchorElement : HTMLElement {
|
||||||
attribute DOMString rel;
|
attribute DOMString rel;
|
||||||
[SetterThrows, Pref="network.http.enablePerElementReferrer"]
|
[SetterThrows, Pref="network.http.enablePerElementReferrer"]
|
||||||
attribute DOMString referrerPolicy;
|
attribute DOMString referrerPolicy;
|
||||||
|
[PutForwards=value]
|
||||||
readonly attribute DOMTokenList relList;
|
readonly attribute DOMTokenList relList;
|
||||||
[SetterThrows]
|
[SetterThrows]
|
||||||
attribute DOMString hreflang;
|
attribute DOMString hreflang;
|
||||||
|
|
|
@ -30,6 +30,7 @@ interface HTMLAreaElement : HTMLElement {
|
||||||
attribute DOMString rel;
|
attribute DOMString rel;
|
||||||
[SetterThrows, Pref="network.http.enablePerElementReferrer"]
|
[SetterThrows, Pref="network.http.enablePerElementReferrer"]
|
||||||
attribute DOMString referrerPolicy;
|
attribute DOMString referrerPolicy;
|
||||||
|
[PutForwards=value]
|
||||||
readonly attribute DOMTokenList relList;
|
readonly attribute DOMTokenList relList;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -28,11 +28,11 @@ interface HTMLElement : Element {
|
||||||
// microdata
|
// microdata
|
||||||
[SetterThrows, Pure]
|
[SetterThrows, Pure]
|
||||||
attribute boolean itemScope;
|
attribute boolean itemScope;
|
||||||
[PutForwards=value,Constant] readonly attribute DOMSettableTokenList itemType;
|
[PutForwards=value,Constant] readonly attribute DOMTokenList itemType;
|
||||||
[SetterThrows, Pure]
|
[SetterThrows, Pure]
|
||||||
attribute DOMString itemId;
|
attribute DOMString itemId;
|
||||||
[PutForwards=value,Constant] readonly attribute DOMSettableTokenList itemRef;
|
[PutForwards=value,Constant] readonly attribute DOMTokenList itemRef;
|
||||||
[PutForwards=value,Constant] readonly attribute DOMSettableTokenList itemProp;
|
[PutForwards=value,Constant] readonly attribute DOMTokenList itemProp;
|
||||||
[Constant]
|
[Constant]
|
||||||
readonly attribute HTMLPropertiesCollection properties;
|
readonly attribute HTMLPropertiesCollection properties;
|
||||||
[Throws]
|
[Throws]
|
||||||
|
@ -54,7 +54,7 @@ interface HTMLElement : Element {
|
||||||
readonly attribute DOMString accessKeyLabel;
|
readonly attribute DOMString accessKeyLabel;
|
||||||
[SetterThrows, Pure]
|
[SetterThrows, Pure]
|
||||||
attribute boolean draggable;
|
attribute boolean draggable;
|
||||||
//[PutForwards=value] readonly attribute DOMSettableTokenList dropzone;
|
//[PutForwards=value] readonly attribute DOMTokenList dropzone;
|
||||||
[SetterThrows, Pure]
|
[SetterThrows, Pure]
|
||||||
attribute DOMString contentEditable;
|
attribute DOMString contentEditable;
|
||||||
[Pure]
|
[Pure]
|
||||||
|
|
|
@ -18,7 +18,7 @@ interface HTMLIFrameElement : HTMLElement {
|
||||||
attribute DOMString srcdoc;
|
attribute DOMString srcdoc;
|
||||||
[SetterThrows, Pure]
|
[SetterThrows, Pure]
|
||||||
attribute DOMString name;
|
attribute DOMString name;
|
||||||
[PutForwards=value] readonly attribute DOMSettableTokenList sandbox;
|
[PutForwards=value] readonly attribute DOMTokenList sandbox;
|
||||||
// attribute boolean seamless;
|
// attribute boolean seamless;
|
||||||
[SetterThrows, Pure]
|
[SetterThrows, Pure]
|
||||||
attribute boolean allowFullscreen;
|
attribute boolean allowFullscreen;
|
||||||
|
|
|
@ -21,6 +21,7 @@ interface HTMLLinkElement : HTMLElement {
|
||||||
attribute DOMString? crossOrigin;
|
attribute DOMString? crossOrigin;
|
||||||
[SetterThrows, Pure]
|
[SetterThrows, Pure]
|
||||||
attribute DOMString rel;
|
attribute DOMString rel;
|
||||||
|
[PutForwards=value]
|
||||||
readonly attribute DOMTokenList relList;
|
readonly attribute DOMTokenList relList;
|
||||||
[SetterThrows, Pure]
|
[SetterThrows, Pure]
|
||||||
attribute DOMString media;
|
attribute DOMString media;
|
||||||
|
@ -28,7 +29,7 @@ interface HTMLLinkElement : HTMLElement {
|
||||||
attribute DOMString hreflang;
|
attribute DOMString hreflang;
|
||||||
[SetterThrows, Pure]
|
[SetterThrows, Pure]
|
||||||
attribute DOMString type;
|
attribute DOMString type;
|
||||||
[PutForwards=value] readonly attribute DOMSettableTokenList sizes;
|
[PutForwards=value] readonly attribute DOMTokenList sizes;
|
||||||
};
|
};
|
||||||
HTMLLinkElement implements LinkStyle;
|
HTMLLinkElement implements LinkStyle;
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
// http://www.whatwg.org/specs/web-apps/current-work/#the-output-element
|
// http://www.whatwg.org/specs/web-apps/current-work/#the-output-element
|
||||||
interface HTMLOutputElement : HTMLElement {
|
interface HTMLOutputElement : HTMLElement {
|
||||||
[PutForwards=value, Constant]
|
[PutForwards=value, Constant]
|
||||||
readonly attribute DOMSettableTokenList htmlFor;
|
readonly attribute DOMTokenList htmlFor;
|
||||||
readonly attribute HTMLFormElement? form;
|
readonly attribute HTMLFormElement? form;
|
||||||
[SetterThrows, Pure]
|
[SetterThrows, Pure]
|
||||||
attribute DOMString name;
|
attribute DOMString name;
|
||||||
|
|
|
@ -16,7 +16,7 @@ interface HTMLTableCellElement : HTMLElement {
|
||||||
attribute unsigned long colSpan;
|
attribute unsigned long colSpan;
|
||||||
[SetterThrows]
|
[SetterThrows]
|
||||||
attribute unsigned long rowSpan;
|
attribute unsigned long rowSpan;
|
||||||
//[PutForwards=value] readonly attribute DOMSettableTokenList headers;
|
//[PutForwards=value] readonly attribute DOMTokenList headers;
|
||||||
[SetterThrows]
|
[SetterThrows]
|
||||||
attribute DOMString headers;
|
attribute DOMString headers;
|
||||||
readonly attribute long cellIndex;
|
readonly attribute long cellIndex;
|
||||||
|
|
|
@ -50,6 +50,8 @@ interface TestInterfaceSetlikeNode {
|
||||||
Pref="dom.expose_test_interfaces"]
|
Pref="dom.expose_test_interfaces"]
|
||||||
interface TestInterfaceIterableSingle {
|
interface TestInterfaceIterableSingle {
|
||||||
iterable<long>;
|
iterable<long>;
|
||||||
|
getter long(unsigned long index);
|
||||||
|
readonly attribute unsigned long length;
|
||||||
};
|
};
|
||||||
|
|
||||||
[Constructor(),
|
[Constructor(),
|
||||||
|
|
|
@ -132,7 +132,6 @@ WEBIDL_FILES = [
|
||||||
'DOMRect.webidl',
|
'DOMRect.webidl',
|
||||||
'DOMRectList.webidl',
|
'DOMRectList.webidl',
|
||||||
'DOMRequest.webidl',
|
'DOMRequest.webidl',
|
||||||
'DOMSettableTokenList.webidl',
|
|
||||||
'DOMStringList.webidl',
|
'DOMStringList.webidl',
|
||||||
'DOMStringMap.webidl',
|
'DOMStringMap.webidl',
|
||||||
'DOMTokenList.webidl',
|
'DOMTokenList.webidl',
|
||||||
|
|
Loading…
Reference in New Issue
Block a user