Bug 1587457 - Remove Element::GetTokenList. r=bzbarsky

Looks like this used to be more generic, looking at:

https://hg.mozilla.org/mozilla-central/rev/263812990c503f6e238b33b2fd3314284ac1be3e

But now only specific element subclasses use it, and the token lists can just be
members in the relevant subclasses.

Differential Revision: https://phabricator.services.mozilla.com/D48710

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Emilio Cobos Álvarez 2019-10-11 04:09:40 +00:00
Родитель 25a5e75a89
Коммит 135388d85f
6 изменённых файлов: 20 добавлений и 41 удалений

Просмотреть файл

@ -3103,47 +3103,14 @@ nsresult Element::PostHandleEventForLinks(EventChainPostVisitor& aVisitor) {
void Element::GetLinkTarget(nsAString& aTarget) { aTarget.Truncate(); } void Element::GetLinkTarget(nsAString& aTarget) { aTarget.Truncate(); }
static void nsDOMTokenListPropertyDestructor(void* aObject, nsAtom* aProperty,
void* aPropertyValue,
void* aData) {
nsDOMTokenList* list = static_cast<nsDOMTokenList*>(aPropertyValue);
NS_RELEASE(list);
}
static nsStaticAtom* const sPropertiesToTraverseAndUnlink[] = { static nsStaticAtom* const sPropertiesToTraverseAndUnlink[] = {
nsGkAtoms::sandbox, nsGkAtoms::sizes, nsGkAtoms::dirAutoSetBy, nullptr}; nsGkAtoms::dirAutoSetBy, nullptr};
// static // static
nsStaticAtom* const* Element::HTMLSVGPropertiesToTraverseAndUnlink() { nsStaticAtom* const* Element::HTMLSVGPropertiesToTraverseAndUnlink() {
return sPropertiesToTraverseAndUnlink; return sPropertiesToTraverseAndUnlink;
} }
nsDOMTokenList* Element::GetTokenList(
nsAtom* aAtom, const DOMTokenListSupportedTokenArray aSupportedTokens) {
#ifdef DEBUG
const nsStaticAtom* const* props = HTMLSVGPropertiesToTraverseAndUnlink();
bool found = false;
for (uint32_t i = 0; props[i]; ++i) {
if (props[i] == aAtom) {
found = true;
break;
}
}
MOZ_ASSERT(found, "Trying to use an unknown tokenlist!");
#endif
nsDOMTokenList* list = nullptr;
if (HasProperties()) {
list = static_cast<nsDOMTokenList*>(GetProperty(aAtom));
}
if (!list) {
list = new nsDOMTokenList(this, aAtom, aSupportedTokens);
NS_ADDREF(list);
SetProperty(aAtom, list, nsDOMTokenListPropertyDestructor);
}
return list;
}
nsresult Element::CopyInnerTo(Element* aDst, ReparseAttributes aReparse) { nsresult Element::CopyInnerTo(Element* aDst, ReparseAttributes aReparse) {
nsresult rv = aDst->mAttrs.EnsureCapacityToClone(mAttrs); nsresult rv = aDst->mAttrs.EnsureCapacityToClone(mAttrs);
NS_ENSURE_SUCCESS(rv, rv); NS_ENSURE_SUCCESS(rv, rv);

Просмотреть файл

@ -1908,10 +1908,6 @@ class Element : public FragmentOrElement {
*/ */
virtual void GetLinkTarget(nsAString& aTarget); virtual void GetLinkTarget(nsAString& aTarget);
nsDOMTokenList* GetTokenList(
nsAtom* aAtom,
const DOMTokenListSupportedTokenArray aSupportedTokens = nullptr);
enum class ReparseAttributes { No, Yes }; enum class ReparseAttributes { No, Yes };
/** /**
* Copy attributes and state to another element * Copy attributes and state to another element

Просмотреть файл

@ -28,11 +28,13 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLIFrameElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLIFrameElement, NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLIFrameElement,
nsGenericHTMLFrameElement) nsGenericHTMLFrameElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFeaturePolicy) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mFeaturePolicy)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSandbox)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLIFrameElement, NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLIFrameElement,
nsGenericHTMLFrameElement) nsGenericHTMLFrameElement)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mFeaturePolicy) NS_IMPL_CYCLE_COLLECTION_UNLINK(mFeaturePolicy)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSandbox)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_ADDREF_INHERITED(HTMLIFrameElement, nsGenericHTMLFrameElement) NS_IMPL_ADDREF_INHERITED(HTMLIFrameElement, nsGenericHTMLFrameElement)

Просмотреть файл

@ -66,7 +66,11 @@ class HTMLIFrameElement final : public nsGenericHTMLFrameElement {
SetHTMLAttr(nsGkAtoms::name, aName, aError); SetHTMLAttr(nsGkAtoms::name, aName, aError);
} }
nsDOMTokenList* Sandbox() { nsDOMTokenList* Sandbox() {
return GetTokenList(nsGkAtoms::sandbox, sSupportedSandboxTokens); if (!mSandbox) {
mSandbox =
new nsDOMTokenList(this, nsGkAtoms::sandbox, sSupportedSandboxTokens);
}
return mSandbox;
} }
bool AllowFullscreen() const { bool AllowFullscreen() const {
return GetBoolAttr(nsGkAtoms::allowfullscreen); return GetBoolAttr(nsGkAtoms::allowfullscreen);
@ -196,7 +200,8 @@ class HTMLIFrameElement final : public nsGenericHTMLFrameElement {
*/ */
void AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName, bool aNotify); void AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName, bool aNotify);
RefPtr<mozilla::dom::FeaturePolicy> mFeaturePolicy; RefPtr<dom::FeaturePolicy> mFeaturePolicy;
RefPtr<nsDOMTokenList> mSandbox;
}; };
} // namespace dom } // namespace dom

Просмотреть файл

@ -75,12 +75,14 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLLinkElement,
nsGenericHTMLElement) nsGenericHTMLElement)
tmp->nsStyleLinkElement::Traverse(cb); tmp->nsStyleLinkElement::Traverse(cb);
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelList) NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mRelList)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mSizes)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLLinkElement, NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLLinkElement,
nsGenericHTMLElement) nsGenericHTMLElement)
tmp->nsStyleLinkElement::Unlink(); tmp->nsStyleLinkElement::Unlink();
NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelList) NS_IMPL_CYCLE_COLLECTION_UNLINK(mRelList)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mSizes)
NS_IMPL_CYCLE_COLLECTION_UNLINK_END NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLLinkElement, NS_IMPL_ISUPPORTS_CYCLE_COLLECTION_INHERITED(HTMLLinkElement,

Просмотреть файл

@ -11,6 +11,7 @@
#include "mozilla/dom/Link.h" #include "mozilla/dom/Link.h"
#include "nsGenericHTMLElement.h" #include "nsGenericHTMLElement.h"
#include "nsStyleLinkElement.h" #include "nsStyleLinkElement.h"
#include "nsDOMTokenList.h"
namespace mozilla { namespace mozilla {
class EventChainPostVisitor; class EventChainPostVisitor;
@ -124,7 +125,12 @@ class HTMLLinkElement final : public nsGenericHTMLElement,
static void ParseAsValue(const nsAString& aValue, nsAttrValue& aResult); static void ParseAsValue(const nsAString& aValue, nsAttrValue& aResult);
static nsContentPolicyType AsValueToContentPolicy(const nsAttrValue& aValue); static nsContentPolicyType AsValueToContentPolicy(const nsAttrValue& aValue);
nsDOMTokenList* Sizes() { return GetTokenList(nsGkAtoms::sizes); } nsDOMTokenList* Sizes() {
if (!mSizes) {
mSizes = new nsDOMTokenList(this, nsGkAtoms::sizes);
}
return mSizes;
}
void GetType(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::type, aValue); } void GetType(DOMString& aValue) { GetHTMLAttr(nsGkAtoms::type, aValue); }
void SetType(const nsAString& aType, ErrorResult& aRv) { void SetType(const nsAString& aType, ErrorResult& aRv) {
SetHTMLAttr(nsGkAtoms::type, aType, aRv); SetHTMLAttr(nsGkAtoms::type, aType, aRv);
@ -183,6 +189,7 @@ class HTMLLinkElement final : public nsGenericHTMLElement,
Maybe<SheetInfo> GetStyleSheetInfo() final; Maybe<SheetInfo> GetStyleSheetInfo() final;
RefPtr<nsDOMTokenList> mRelList; RefPtr<nsDOMTokenList> mRelList;
RefPtr<nsDOMTokenList> mSizes;
// The "explicitly enabled" flag. This flag is set whenever the `disabled` // The "explicitly enabled" flag. This flag is set whenever the `disabled`
// attribute is explicitly unset, and makes alternate stylesheets not be // attribute is explicitly unset, and makes alternate stylesheets not be