зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1552313) for WPT failures in custom-elements/CustomElementRegistry.html. CLOSED TREE
Backed out changeset 27a01989152a (bug 1552313) Backed out changeset 5f8c6c9f2d36 (bug 1552313) Backed out changeset f26d61e06a9d (bug 1552313)
This commit is contained in:
Родитель
27d65da3d8
Коммит
cbf2994b14
|
@ -174,12 +174,6 @@ void CustomElementData::SetCustomElementDefinition(
|
|||
mCustomElementDefinition = aDefinition;
|
||||
}
|
||||
|
||||
void CustomElementData::AttachedInternals() {
|
||||
MOZ_ASSERT(!mIsAttachedInternals);
|
||||
|
||||
mIsAttachedInternals = true;
|
||||
}
|
||||
|
||||
CustomElementDefinition* CustomElementData::GetCustomElementDefinition() {
|
||||
MOZ_ASSERT(mCustomElementDefinition ? mState == State::eCustom
|
||||
: mState != State::eCustom);
|
||||
|
@ -642,61 +636,6 @@ int32_t CustomElementRegistry::InferNamespace(
|
|||
return kNameSpaceID_XHTML;
|
||||
}
|
||||
|
||||
bool CustomElementRegistry::JSObjectToAtomArray(
|
||||
JSContext* aCx, JS::Handle<JSObject*> aConstructor, const char16_t* aName,
|
||||
nsTArray<RefPtr<nsAtom>>& aArray, ErrorResult& aRv) {
|
||||
JS::RootedValue iterable(aCx, JS::UndefinedValue());
|
||||
if (!JS_GetUCProperty(aCx, aConstructor, aName,
|
||||
std::char_traits<char16_t>::length(aName), &iterable)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!iterable.isUndefined()) {
|
||||
if (!iterable.isObject()) {
|
||||
aRv.ThrowTypeError<MSG_NOT_SEQUENCE>(nsDependentString(aName));
|
||||
return false;
|
||||
}
|
||||
|
||||
JS::ForOfIterator iter(aCx);
|
||||
if (!iter.init(iterable, JS::ForOfIterator::AllowNonIterable)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!iter.valueIsIterable()) {
|
||||
aRv.ThrowTypeError<MSG_NOT_SEQUENCE>(nsDependentString(aName));
|
||||
return false;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> attribute(aCx);
|
||||
while (true) {
|
||||
bool done;
|
||||
if (!iter.next(&attribute, &done)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return false;
|
||||
}
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsAutoString attrStr;
|
||||
if (!ConvertJSValueToString(aCx, attribute, eStringify, eStringify,
|
||||
attrStr)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!aArray.AppendElement(NS_Atomize(attrStr))) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/scripting.html#element-definition
|
||||
void CustomElementRegistry::Define(
|
||||
JSContext* aCx, const nsAString& aName,
|
||||
|
@ -843,9 +782,6 @@ void CustomElementRegistry::Define(
|
|||
|
||||
auto callbacksHolder = MakeUnique<LifecycleCallbacks>();
|
||||
nsTArray<RefPtr<nsAtom>> observedAttributes;
|
||||
AutoTArray<RefPtr<nsAtom>, 2> disabledFeatures;
|
||||
bool disableInternals = false;
|
||||
bool disableShadow = false;
|
||||
{ // Set mIsCustomDefinitionRunning.
|
||||
/**
|
||||
* 9. Set this CustomElementRegistry's element definition is running flag.
|
||||
|
@ -905,36 +841,58 @@ void CustomElementRegistry::Define(
|
|||
* any exceptions from the conversion.
|
||||
*/
|
||||
if (callbacksHolder->mAttributeChangedCallback.WasPassed()) {
|
||||
if (!JSObjectToAtomArray(aCx, constructor, u"observedAttributes",
|
||||
observedAttributes, aRv)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
JS::Rooted<JS::Value> observedAttributesIterable(aCx);
|
||||
|
||||
/**
|
||||
* 14.6. Let disabledFeatures be an empty sequence<DOMString>.
|
||||
* 14.7. Let disabledFeaturesIterable be Get(constructor,
|
||||
* "disabledFeatures"). Rethrow any exceptions.
|
||||
* 14.8. If disabledFeaturesIterable is not undefined, then set
|
||||
* disabledFeatures to the result of converting
|
||||
* disabledFeaturesIterable to a sequence<DOMString>.
|
||||
* Rethrow any exceptions from the conversion.
|
||||
*/
|
||||
if (StaticPrefs::dom_webcomponents_elementInternals_enabled()) {
|
||||
if (!JSObjectToAtomArray(aCx, constructor, u"disabledFeatures",
|
||||
disabledFeatures, aRv)) {
|
||||
if (!JS_GetProperty(aCx, constructor, "observedAttributes",
|
||||
&observedAttributesIterable)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
|
||||
// 14.9. Set disableInternals to true if disabledFeaturesSequence contains
|
||||
// "internals".
|
||||
disableInternals = disabledFeatures.Contains(
|
||||
static_cast<nsStaticAtom*>(nsGkAtoms::internals));
|
||||
if (!observedAttributesIterable.isUndefined()) {
|
||||
if (!observedAttributesIterable.isObject()) {
|
||||
aRv.ThrowTypeError<MSG_NOT_SEQUENCE>(
|
||||
NS_LITERAL_STRING("observedAttributes"));
|
||||
return;
|
||||
}
|
||||
|
||||
// 14.10. Set disableShadow to true if disabledFeaturesSequence contains
|
||||
// "shadow".
|
||||
disableShadow = disabledFeatures.Contains(
|
||||
static_cast<nsStaticAtom*>(nsGkAtoms::shadow));
|
||||
JS::ForOfIterator iter(aCx);
|
||||
if (!iter.init(observedAttributesIterable,
|
||||
JS::ForOfIterator::AllowNonIterable)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!iter.valueIsIterable()) {
|
||||
aRv.ThrowTypeError<MSG_NOT_SEQUENCE>(
|
||||
NS_LITERAL_STRING("observedAttributes"));
|
||||
return;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> attribute(aCx);
|
||||
while (true) {
|
||||
bool done;
|
||||
if (!iter.next(&attribute, &done)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
if (done) {
|
||||
break;
|
||||
}
|
||||
|
||||
nsAutoString attrStr;
|
||||
if (!ConvertJSValueToString(aCx, attribute, eStringify, eStringify,
|
||||
attrStr)) {
|
||||
aRv.NoteJSContextException(aCx);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!observedAttributes.AppendElement(NS_Atomize(attrStr))) {
|
||||
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} // Unset mIsCustomDefinitionRunning
|
||||
|
||||
|
@ -957,8 +915,7 @@ void CustomElementRegistry::Define(
|
|||
|
||||
RefPtr<CustomElementDefinition> definition = new CustomElementDefinition(
|
||||
nameAtom, localNameAtom, nameSpaceID, &aFunctionConstructor,
|
||||
std::move(observedAttributes), std::move(callbacksHolder),
|
||||
disableInternals, disableShadow);
|
||||
std::move(observedAttributes), std::move(callbacksHolder));
|
||||
|
||||
CustomElementDefinition* def = definition.get();
|
||||
mCustomDefinitions.Put(nameAtom, definition.forget());
|
||||
|
@ -1095,19 +1052,8 @@ already_AddRefed<Promise> CustomElementRegistry::WhenDefined(
|
|||
namespace {
|
||||
|
||||
MOZ_CAN_RUN_SCRIPT
|
||||
static void DoUpgrade(Element* aElement, CustomElementDefinition* aDefinition,
|
||||
CustomElementConstructor* aConstructor,
|
||||
static void DoUpgrade(Element* aElement, CustomElementConstructor* aConstructor,
|
||||
ErrorResult& aRv) {
|
||||
if (aDefinition->mDisableShadow && aElement->GetShadowRoot()) {
|
||||
aRv.ThrowDOMException(
|
||||
NS_ERROR_DOM_NOT_SUPPORTED_ERR,
|
||||
nsPrintfCString(
|
||||
"Custom element upgrade to '%s' is disabled due to shadow root "
|
||||
"already exists",
|
||||
NS_ConvertUTF16toUTF8(aDefinition->mType->GetUTF16String()).get()));
|
||||
return;
|
||||
}
|
||||
|
||||
JS::Rooted<JS::Value> constructResult(RootingCx());
|
||||
// Rethrow the exception since it might actually throw the exception from the
|
||||
// upgrade steps back out to the caller of document.createElement.
|
||||
|
@ -1178,8 +1124,7 @@ void CustomElementRegistry::Upgrade(Element* aElement,
|
|||
AutoConstructionStackEntry acs(aDefinition->mConstructionStack, aElement);
|
||||
|
||||
// Step 6 and step 7.
|
||||
DoUpgrade(aElement, aDefinition, MOZ_KnownLive(aDefinition->mConstructor),
|
||||
aRv);
|
||||
DoUpgrade(aElement, MOZ_KnownLive(aDefinition->mConstructor), aRv);
|
||||
if (aRv.Failed()) {
|
||||
data->mState = CustomElementData::State::eFailed;
|
||||
// Empty element's custom element reaction queue.
|
||||
|
@ -1460,16 +1405,13 @@ CustomElementDefinition::CustomElementDefinition(
|
|||
nsAtom* aType, nsAtom* aLocalName, int32_t aNamespaceID,
|
||||
CustomElementConstructor* aConstructor,
|
||||
nsTArray<RefPtr<nsAtom>>&& aObservedAttributes,
|
||||
UniquePtr<LifecycleCallbacks>&& aCallbacks, bool aDisableInternals,
|
||||
bool aDisableShadow)
|
||||
UniquePtr<LifecycleCallbacks>&& aCallbacks)
|
||||
: mType(aType),
|
||||
mLocalName(aLocalName),
|
||||
mNamespaceID(aNamespaceID),
|
||||
mConstructor(aConstructor),
|
||||
mObservedAttributes(std::move(aObservedAttributes)),
|
||||
mCallbacks(std::move(aCallbacks)),
|
||||
mDisableInternals(aDisableInternals),
|
||||
mDisableShadow(aDisableShadow) {}
|
||||
mCallbacks(std::move(aCallbacks)) {}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -105,8 +105,6 @@ struct CustomElementData {
|
|||
void SetCustomElementDefinition(CustomElementDefinition* aDefinition);
|
||||
CustomElementDefinition* GetCustomElementDefinition();
|
||||
nsAtom* GetCustomElementType() const { return mType; }
|
||||
void AttachedInternals();
|
||||
bool HasAttachedInternals() const { return mIsAttachedInternals; }
|
||||
|
||||
void Traverse(nsCycleCollectionTraversalCallback& aCb) const;
|
||||
void Unlink();
|
||||
|
@ -125,7 +123,6 @@ struct CustomElementData {
|
|||
// this would be x-button.
|
||||
RefPtr<nsAtom> mType;
|
||||
RefPtr<CustomElementDefinition> mCustomElementDefinition;
|
||||
bool mIsAttachedInternals = false;
|
||||
};
|
||||
|
||||
#define ALREADY_CONSTRUCTED_MARKER nullptr
|
||||
|
@ -140,8 +137,7 @@ struct CustomElementDefinition {
|
|||
int32_t aNamespaceID,
|
||||
CustomElementConstructor* aConstructor,
|
||||
nsTArray<RefPtr<nsAtom>>&& aObservedAttributes,
|
||||
UniquePtr<LifecycleCallbacks>&& aCallbacks,
|
||||
bool aDisableInternals, bool aDisableShadow);
|
||||
UniquePtr<LifecycleCallbacks>&& aCallbacks);
|
||||
|
||||
// The type (name) for this custom element, for <button is="x-foo"> or <x-foo>
|
||||
// this would be x-foo.
|
||||
|
@ -162,12 +158,6 @@ struct CustomElementDefinition {
|
|||
// The lifecycle callbacks to call for this custom element.
|
||||
UniquePtr<LifecycleCallbacks> mCallbacks;
|
||||
|
||||
// Determine whether to allow to attachInternals() for this custom element.
|
||||
bool mDisableInternals = false;
|
||||
|
||||
// Determine whether to allow to attachShadow() for this custom element.
|
||||
bool mDisableShadow = false;
|
||||
|
||||
// A construction stack. Use nullptr to represent an "already constructed
|
||||
// marker".
|
||||
nsTArray<RefPtr<Element>> mConstructionStack;
|
||||
|
@ -468,10 +458,6 @@ class CustomElementRegistry final : public nsISupports, public nsWrapperCache {
|
|||
private:
|
||||
~CustomElementRegistry();
|
||||
|
||||
bool JSObjectToAtomArray(JSContext* aCx, JS::Handle<JSObject*> aConstructor,
|
||||
const char16_t* aName,
|
||||
nsTArray<RefPtr<nsAtom>>& aArray, ErrorResult& aRv);
|
||||
|
||||
static UniquePtr<CustomElementCallback> CreateCustomElementCallback(
|
||||
Document::ElementCallbackType aType, Element* aCustomElement,
|
||||
LifecycleCallbackArgs* aArgs,
|
||||
|
|
|
@ -977,8 +977,8 @@ bool Element::CanAttachShadowDOM() const {
|
|||
* return false.
|
||||
*/
|
||||
nsAtom* nameAtom = NodeInfo()->NameAtom();
|
||||
uint32_t namespaceID = NodeInfo()->NamespaceID();
|
||||
if (!(nsContentUtils::IsCustomElementName(nameAtom, namespaceID) ||
|
||||
if (!(nsContentUtils::IsCustomElementName(nameAtom,
|
||||
NodeInfo()->NamespaceID()) ||
|
||||
nameAtom == nsGkAtoms::article || nameAtom == nsGkAtoms::aside ||
|
||||
nameAtom == nsGkAtoms::blockquote || nameAtom == nsGkAtoms::body ||
|
||||
nameAtom == nsGkAtoms::div || nameAtom == nsGkAtoms::footer ||
|
||||
|
@ -991,30 +991,6 @@ bool Element::CanAttachShadowDOM() const {
|
|||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 3. If context object’s local name is a valid custom element name, or
|
||||
* context object’s is value is not null, then:
|
||||
* If definition is not null and definition’s disable shadow is true, then
|
||||
* return false.
|
||||
*/
|
||||
// It will always have CustomElementData when the element is a valid custom
|
||||
// element or has is value.
|
||||
CustomElementData* ceData = GetCustomElementData();
|
||||
if (StaticPrefs::dom_webcomponents_elementInternals_enabled() && ceData) {
|
||||
CustomElementDefinition* definition = ceData->GetCustomElementDefinition();
|
||||
// If the definition is null, the element possible hasn't yet upgraded.
|
||||
// Fallback to use LookupCustomElementDefinition to find its definition.
|
||||
if (!definition) {
|
||||
definition = nsContentUtils::LookupCustomElementDefinition(
|
||||
NodeInfo()->GetDocument(), nameAtom, namespaceID,
|
||||
ceData->GetCustomElementType());
|
||||
}
|
||||
|
||||
if (definition && definition->mDisableShadow) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -1033,11 +1009,11 @@ already_AddRefed<ShadowRoot> Element::AttachShadow(const ShadowRootInit& aInit,
|
|||
}
|
||||
|
||||
/**
|
||||
* 4. If context object is a shadow host, then throw
|
||||
* an "NotSupportedError" DOMException.
|
||||
* 3. If context object is a shadow host, then throw
|
||||
* an "InvalidStateError" DOMException.
|
||||
*/
|
||||
if (GetShadowRoot()) {
|
||||
aError.Throw(NS_ERROR_DOM_NOT_SUPPORTED_ERR);
|
||||
aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,33 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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 "mozilla/dom/ElementInternals.h"
|
||||
#include "mozilla/dom/ElementInternalsBinding.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(ElementInternals, mTarget)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(ElementInternals)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(ElementInternals)
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ElementInternals)
|
||||
NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
ElementInternals::ElementInternals(nsGenericHTMLElement* aTarget)
|
||||
: mTarget(aTarget) {}
|
||||
|
||||
nsISupports* ElementInternals::GetParentObject() { return ToSupports(mTarget); }
|
||||
|
||||
JSObject* ElementInternals::WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) {
|
||||
return ElementInternals_Binding::Wrap(aCx, this, aGivenProto);
|
||||
}
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
|
@ -1,40 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim:set ts=2 sw=2 sts=2 et cindent: */
|
||||
/* 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/. */
|
||||
|
||||
#ifndef mozilla_dom_ElementInternals_h
|
||||
#define mozilla_dom_ElementInternals_h
|
||||
|
||||
#include "js/TypeDecls.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsGenericHTMLElement.h"
|
||||
#include "nsWrapperCache.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class ElementInternals final : public nsISupports, public nsWrapperCache {
|
||||
public:
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ElementInternals)
|
||||
|
||||
explicit ElementInternals(nsGenericHTMLElement* aTarget);
|
||||
|
||||
nsISupports* GetParentObject();
|
||||
|
||||
virtual JSObject* WrapObject(JSContext* aCx,
|
||||
JS::Handle<JSObject*> aGivenProto) override;
|
||||
|
||||
private:
|
||||
~ElementInternals() = default;
|
||||
|
||||
// It's a target element which is a custom element.
|
||||
RefPtr<nsGenericHTMLElement> mTarget;
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_ElementInternals_h
|
|
@ -49,7 +49,6 @@ EXPORTS.mozilla += [
|
|||
]
|
||||
|
||||
EXPORTS.mozilla.dom += [
|
||||
'ElementInternals.h',
|
||||
'HTMLAllCollection.h',
|
||||
'HTMLAnchorElement.h',
|
||||
'HTMLAreaElement.h',
|
||||
|
@ -130,7 +129,6 @@ EXPORTS.mozilla.dom += [
|
|||
]
|
||||
|
||||
UNIFIED_SOURCES += [
|
||||
'ElementInternals.cpp',
|
||||
'HTMLAllCollection.cpp',
|
||||
'HTMLAnchorElement.cpp',
|
||||
'HTMLAreaElement.cpp',
|
||||
|
|
|
@ -102,8 +102,6 @@
|
|||
#include "nsComputedDOMStyle.h"
|
||||
#include "mozilla/dom/HTMLLabelElement.h"
|
||||
#include "mozilla/dom/HTMLInputElement.h"
|
||||
#include "mozilla/dom/CustomElementRegistry.h"
|
||||
#include "mozilla/dom/ElementInternals.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
@ -2798,77 +2796,3 @@ void nsGenericHTMLElement::SetInnerText(const nsAString& aValue) {
|
|||
|
||||
mb.NodesAdded();
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/commit-snapshots/b48bb2238269d90ea4f455a52cdf29505aff3df0/#dom-attachinternals
|
||||
already_AddRefed<ElementInternals> nsGenericHTMLElement::AttachInternals(
|
||||
ErrorResult& aRv) {
|
||||
CustomElementData* ceData = GetCustomElementData();
|
||||
|
||||
// 1. If element's is value is not null, then throw a "NotSupportedError"
|
||||
// DOMException.
|
||||
nsAtom* isAtom = ceData ? ceData->GetIs(this) : nullptr;
|
||||
nsAtom* nameAtom = NodeInfo()->NameAtom();
|
||||
if (isAtom) {
|
||||
aRv.ThrowDOMException(
|
||||
NS_ERROR_DOM_NOT_SUPPORTED_ERR,
|
||||
nsPrintfCString(
|
||||
"Cannot attach ElementInternals to a customized built-in element "
|
||||
"'%s'",
|
||||
NS_ConvertUTF16toUTF8(isAtom->GetUTF16String()).get()));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 2. Let definition be the result of looking up a custom element definition
|
||||
// given element's node document, its namespace, its local name, and null
|
||||
// as is value.
|
||||
CustomElementDefinition* definition = nullptr;
|
||||
if (ceData) {
|
||||
definition = ceData->GetCustomElementDefinition();
|
||||
|
||||
// If the definition is null, the element possible hasn't yet upgraded.
|
||||
// Fallback to use LookupCustomElementDefinition to find its definition.
|
||||
if (!definition) {
|
||||
definition = nsContentUtils::LookupCustomElementDefinition(
|
||||
NodeInfo()->GetDocument(), nameAtom,
|
||||
NodeInfo()->NamespaceID(), ceData->GetCustomElementType());
|
||||
}
|
||||
}
|
||||
|
||||
// 3. If definition is null, then throw an "NotSupportedError" DOMException.
|
||||
if (!definition) {
|
||||
aRv.ThrowDOMException(
|
||||
NS_ERROR_DOM_NOT_SUPPORTED_ERR,
|
||||
nsPrintfCString(
|
||||
"Cannot attach ElementInternals to a non-custom element '%s'",
|
||||
NS_ConvertUTF16toUTF8(nameAtom->GetUTF16String()).get()));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 4. If definition's disable internals is true, then throw a
|
||||
// "NotSupportedError" DOMException.
|
||||
if (definition->mDisableInternals) {
|
||||
aRv.ThrowDOMException(
|
||||
NS_ERROR_DOM_NOT_SUPPORTED_ERR,
|
||||
nsPrintfCString(
|
||||
"AttachInternal() to '%s' is disabled by disabledFeatures",
|
||||
NS_ConvertUTF16toUTF8(nameAtom->GetUTF16String()).get()));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 5. If element's attached internals is true, then throw an
|
||||
// "NotSupportedError" DOMException.
|
||||
if (ceData->HasAttachedInternals()) {
|
||||
aRv.ThrowDOMException(
|
||||
NS_ERROR_DOM_NOT_SUPPORTED_ERR,
|
||||
nsPrintfCString(
|
||||
"AttachInternals() has already been called from '%s'",
|
||||
NS_ConvertUTF16toUTF8(nameAtom->GetUTF16String()).get()));
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
// 6. Set element's attached internals to true.
|
||||
ceData->AttachedInternals();
|
||||
|
||||
// 7. Create a new ElementInternals instance targeting element, and return it.
|
||||
return MakeAndAddRef<ElementInternals>(this);
|
||||
}
|
|
@ -15,9 +15,9 @@
|
|||
#include "nsContentCreatorFunctions.h"
|
||||
#include "mozilla/ErrorResult.h"
|
||||
#include "mozilla/dom/BindingDeclarations.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
#include "mozilla/dom/DOMRect.h"
|
||||
#include "mozilla/dom/ValidityState.h"
|
||||
#include "mozilla/dom/Element.h"
|
||||
|
||||
class nsDOMTokenList;
|
||||
class nsIFormControlFrame;
|
||||
|
@ -35,7 +35,6 @@ class EventStates;
|
|||
class TextEditor;
|
||||
class PresState;
|
||||
namespace dom {
|
||||
class ElementInternals;
|
||||
class HTMLFormElement;
|
||||
class HTMLMenuElement;
|
||||
} // namespace dom
|
||||
|
@ -227,10 +226,6 @@ class nsGenericHTMLElement : public nsGenericHTMLElementBase {
|
|||
return IsNodeInternal(aFirst, aArgs...);
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-attachinternals
|
||||
already_AddRefed<mozilla::dom::ElementInternals> AttachInternals(
|
||||
ErrorResult& aRv);
|
||||
|
||||
protected:
|
||||
virtual ~nsGenericHTMLElement() {}
|
||||
|
||||
|
|
|
@ -350,8 +350,6 @@ var interfaceNamesInGlobalScope = [
|
|||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "Element", insecureContext: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "ElementInternals", insecureContext: true, nightly: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "ErrorEvent", insecureContext: true },
|
||||
// IMPORTANT: Do not change this list without review from a DOM peer!
|
||||
{ name: "Event", insecureContext: true },
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* 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/.
|
||||
*
|
||||
* The origin of this IDL file is
|
||||
* https://html.spec.whatwg.org/#elementinternals
|
||||
*/
|
||||
|
||||
[Pref="dom.webcomponents.elementInternals.enabled", Exposed=Window]
|
||||
interface ElementInternals {
|
||||
};
|
||||
|
|
@ -58,10 +58,6 @@ interface HTMLElement : Element {
|
|||
//readonly attribute boolean? commandHidden;
|
||||
//readonly attribute boolean? commandDisabled;
|
||||
//readonly attribute boolean? commandChecked;
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/custom-elements.html#dom-attachinternals
|
||||
[Pref="dom.webcomponents.elementInternals.enabled", Throws]
|
||||
ElementInternals attachInternals();
|
||||
};
|
||||
|
||||
// http://dev.w3.org/csswg/cssom-view/#extensions-to-the-htmlelement-interface
|
||||
|
|
|
@ -484,7 +484,6 @@ WEBIDL_FILES = [
|
|||
'DragEvent.webidl',
|
||||
'DynamicsCompressorNode.webidl',
|
||||
'Element.webidl',
|
||||
'ElementInternals.webidl',
|
||||
'Event.webidl',
|
||||
'EventHandler.webidl',
|
||||
'EventListener.webidl',
|
||||
|
|
|
@ -2620,12 +2620,6 @@
|
|||
value: false
|
||||
mirror: always
|
||||
|
||||
# Is support for elementInternals enabled?
|
||||
- name: dom.webcomponents.elementInternals.enabled
|
||||
type: bool
|
||||
value: @IS_NIGHTLY_BUILD@
|
||||
mirror: always
|
||||
|
||||
# Is support for the Web GPU API enabled?
|
||||
- name: dom.webgpu.enable
|
||||
type: RelaxedAtomicBool
|
||||
|
|
|
@ -17,11 +17,18 @@
|
|||
[customElements.define must rethrow an exception thrown while getting additional formAssociated callbacks on the constructor prototype]
|
||||
expected: FAIL
|
||||
|
||||
[customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on disabledFeatures]
|
||||
expected: FAIL
|
||||
|
||||
[customElements.define must get four additional callbacks on the prototype if formAssociated is converted to true]
|
||||
expected: FAIL
|
||||
|
||||
[customElements.define must not throw when defining another custom element in a different global object during Get(constructor, "prototype")]
|
||||
[customElements.define must rethrow an exception thrown while getting disabledFeatures on the constructor prototype]
|
||||
expected: FAIL
|
||||
|
||||
[customElements.define must rethrow an exception thrown while iterating over disabledFeatures to sequence<DOMString>]
|
||||
expected: FAIL
|
||||
|
||||
[customElements.define must rethrow an exception thrown while converting the value of disabledFeatures to sequence<DOMString>]
|
||||
expected: FAIL
|
||||
|
||||
[customElements.define must get "prototype" property of the constructor ]
|
||||
expected: FAIL
|
|
@ -0,0 +1,13 @@
|
|||
[HTMLElement-attachInternals.html]
|
||||
[Successful attachInternals() and the second call.]
|
||||
expected: FAIL
|
||||
|
||||
[attachInternals() throws a NotSupportedError if it is called for a customized built-in element]
|
||||
expected: FAIL
|
||||
|
||||
[If a custom element definition for the local name of the element has disable internals flag, throw a NotSupportedError]
|
||||
expected: FAIL
|
||||
|
||||
[If a custom element definition for the local name of the element doesn't exist, throw an NotSupportedError]
|
||||
expected: FAIL
|
||||
|
|
@ -1 +0,0 @@
|
|||
prefs: [dom.webcomponents.elementInternals.enabled:true]
|
|
@ -1,136 +1,4 @@
|
|||
[ElementInternals-accessibility.html]
|
||||
[role is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaActiveDescendant is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaAtomic is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaAutoComplete is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaBusy is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaChecked is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaColCount is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaColIndex is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaColSpan is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaControls is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaCurrent is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaDescribedBy is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaDetails is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaDisabled is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaErrorMessage is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaExpanded is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaFlowTo is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaHasPopup is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaHidden is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaKeyShortcuts is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaLabel is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaLabelledBy is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaLevel is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaLive is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaModal is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaMultiLine is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaMultiSelectable is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaOrientation is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaOwns is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaPlaceholder is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaPosInSet is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaPressed is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaReadOnly is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaRelevant is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaRequired is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaRoleDescription is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaRowCount is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaRowIndex is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaRowSpan is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaSelected is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaSort is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaValueMax is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaValueMin is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaValueNow is defined in ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[ariaValueText is defined in ElementInternals]
|
||||
[ElementInternals-accessibility]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
[ElementInternals-labels.html]
|
||||
expected: ERROR
|
||||
[LABEL click]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
[ElementInternals-setFormValue.html]
|
||||
expected: ERROR
|
||||
[Single value - Non-empty name exists]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
[ElementInternals-validation.html]
|
||||
expected: ERROR
|
||||
[validity and setValidity()]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -1,12 +1,4 @@
|
|||
[form-associated-callback.html]
|
||||
[Associate by parser, customized at element creation]
|
||||
[formAssociatedCallback, and form IDL attribute of ElementInternals]
|
||||
expected: FAIL
|
||||
|
||||
[Parsed, connected, then upgraded]
|
||||
expected: FAIL
|
||||
|
||||
[Disassociation]
|
||||
expected: FAIL
|
||||
|
||||
[Updating "form" content attribute]
|
||||
expected: FAIL
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
[upgrading.html]
|
||||
max-asserts: 4
|
||||
[If definition's disable shadow is true and element's shadow root is non-null, then throw a "NotSupportedError" DOMException.]
|
||||
expected: FAIL
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.header.enabled:true, dom.security.featurePolicy.webidl.enabled:true, dom.webcomponents.elementInternals.enabled:true]
|
||||
prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.header.enabled:true, dom.security.featurePolicy.webidl.enabled:true]
|
||||
[idlharness.https.html?exclude=(Document|Window|HTML.*)]
|
||||
[ElementInternals interface: operation setValidity(ValidityStateFlags, DOMString, HTMLElement)]
|
||||
expected: FAIL
|
||||
|
@ -27,6 +27,9 @@ prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.head
|
|||
[OffscreenCanvasRenderingContext2D interface: operation measureText(DOMString)]
|
||||
expected: FAIL
|
||||
|
||||
[ElementInternals interface: existence and properties of interface object]
|
||||
expected: FAIL
|
||||
|
||||
[CanvasRenderingContext2D interface: document.createElement("canvas").getContext("2d") must inherit property "imageSmoothingQuality" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -111,6 +114,9 @@ prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.head
|
|||
[OffscreenCanvasRenderingContext2D interface: operation beginPath()]
|
||||
expected: FAIL
|
||||
|
||||
[ElementInternals interface object length]
|
||||
expected: FAIL
|
||||
|
||||
[OffscreenCanvasRenderingContext2D interface: operation bezierCurveTo(unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double, unrestricted double)]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -381,6 +387,9 @@ prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.head
|
|||
[OffscreenCanvasRenderingContext2D interface object name]
|
||||
expected: FAIL
|
||||
|
||||
[ElementInternals interface object name]
|
||||
expected: FAIL
|
||||
|
||||
[ElementInternals interface: attribute labels]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -408,6 +417,9 @@ prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.head
|
|||
[ApplicationCache interface: attribute oncached]
|
||||
expected: FAIL
|
||||
|
||||
[ElementInternals interface: existence and properties of interface prototype object]
|
||||
expected: FAIL
|
||||
|
||||
[OffscreenCanvasRenderingContext2D interface: operation commit()]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -471,9 +483,15 @@ prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.head
|
|||
[OffscreenCanvasRenderingContext2D interface: operation putImageData(ImageData, long, long, long, long, long, long)]
|
||||
expected: FAIL
|
||||
|
||||
[ElementInternals interface: existence and properties of interface prototype object's @@unscopables property]
|
||||
expected: FAIL
|
||||
|
||||
[AudioTrack interface object name]
|
||||
expected: FAIL
|
||||
|
||||
[ElementInternals interface: existence and properties of interface prototype object's "constructor" property]
|
||||
expected: FAIL
|
||||
|
||||
[AudioTrack interface: attribute kind]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -843,6 +861,9 @@ prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.head
|
|||
[HTMLInputElement interface: attribute dirName]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLElement interface: operation attachInternals()]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLVideoElement interface: attribute playsInline]
|
||||
expected: FAIL
|
||||
|
||||
|
@ -1005,6 +1026,9 @@ prefs: [dom.security.featurePolicy.enabled:true, dom.security.featurePolicy.head
|
|||
[HTMLElement interface: document.createElement("noscript") must inherit property "enterKeyHint" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLElement interface: document.createElement("noscript") must inherit property "attachInternals()" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
[HTMLFormElement interface: document.createElement("form") must inherit property "requestSubmit(HTMLElement)" with the proper type]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
[Element-interface-attachShadow-custom-element.html]
|
||||
[Element.attachShadow for an autonomous custom element with disabledFeatures=["shadow"\] should throw a NotSupportedError]
|
||||
expected: FAIL
|
||||
|
||||
[Element.attachShadow for a customized built-in element with disabledFeatures=["shadow"\] should throw a NotSupportedError]
|
||||
expected: FAIL
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
[Element-interface-attachShadow.html]
|
||||
[Element.attachShadow must throw a NotSupportedError if the context object already hosts a shadow tree]
|
||||
expected: FAIL
|
||||
|
|
@ -1 +0,0 @@
|
|||
prefs: [dom.webcomponents.elementInternals.enabled:true]
|
|
@ -77,7 +77,7 @@ test(() => {
|
|||
|
||||
test(() => {
|
||||
class CapitalShadowDisabledElement extends HTMLElement {
|
||||
static get disabledFeatures() { return ['SHADOW']; }
|
||||
static get disabledFeatures() { return ['shadow']; }
|
||||
}
|
||||
|
||||
customElements.define('capital-shadow-disabled-element', CapitalShadowDisabledElement);
|
||||
|
|
|
@ -537,7 +537,6 @@ STATIC_ATOMS = [
|
|||
Atom("insertion", "insertion"),
|
||||
Atom("integer", "integer"),
|
||||
Atom("integrity", "integrity"),
|
||||
Atom("internals", "internals"),
|
||||
Atom("intersection", "intersection"),
|
||||
Atom("intersectionobserverlist", "intersectionobserverlist"),
|
||||
Atom("is", "is"),
|
||||
|
@ -1088,7 +1087,6 @@ STATIC_ATOMS = [
|
|||
Atom("seltype", "seltype"),
|
||||
Atom("setcookie", "set-cookie"),
|
||||
Atom("setter", "setter"),
|
||||
Atom("shadow", "shadow"),
|
||||
Atom("shape", "shape"),
|
||||
Atom("show", "show"),
|
||||
Atom("showcaret", "showcaret"),
|
||||
|
|
Загрузка…
Ссылка в новой задаче