зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 3 changesets (bug 1326028) for wpt bustage in custom-elements/CustomElementRegistry.html on a CLOSED TREE
Backed out changeset 38057b774238 (bug 1326028) Backed out changeset ab4ee52d5a81 (bug 1326028) Backed out changeset 414efc66b026 (bug 1326028)
This commit is contained in:
Родитель
92ae27a927
Коммит
9b1570bb80
|
@ -455,94 +455,6 @@ CustomElementRegistry::EnqueueLifecycleCallback(nsIDocument::ElementCallbackType
|
|||
reactionsStack->EnqueueCallbackReaction(aCustomElement, Move(callback));
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
class CandidateFinder
|
||||
{
|
||||
public:
|
||||
CandidateFinder(nsTArray<nsWeakPtr>&& aCandidates, nsIDocument* aDoc);
|
||||
nsTArray<nsCOMPtr<Element>> OrderedCandidates();
|
||||
|
||||
private:
|
||||
bool Traverse(Element* aRoot, nsTArray<nsCOMPtr<Element>>& aOrderedElements);
|
||||
|
||||
nsCOMPtr<nsIDocument> mDoc;
|
||||
nsInterfaceHashtable<nsPtrHashKey<Element>, Element> mCandidates;
|
||||
};
|
||||
|
||||
CandidateFinder::CandidateFinder(nsTArray<nsWeakPtr>&& aCandidates,
|
||||
nsIDocument* aDoc)
|
||||
: mDoc(aDoc)
|
||||
, mCandidates(aCandidates.Length())
|
||||
{
|
||||
MOZ_ASSERT(mDoc);
|
||||
for (auto& candidate : aCandidates) {
|
||||
nsCOMPtr<Element> elem = do_QueryReferent(candidate);
|
||||
if (!elem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Element* key = elem.get();
|
||||
mCandidates.Put(key, elem.forget());
|
||||
}
|
||||
}
|
||||
|
||||
nsTArray<nsCOMPtr<Element>>
|
||||
CandidateFinder::OrderedCandidates()
|
||||
{
|
||||
if (mCandidates.Count() == 1) {
|
||||
// Fast path for one candidate.
|
||||
for (auto iter = mCandidates.Iter(); !iter.Done(); iter.Next()) {
|
||||
nsTArray<nsCOMPtr<Element>> rval({ Move(iter.Data()) });
|
||||
iter.Remove();
|
||||
return rval;
|
||||
}
|
||||
}
|
||||
|
||||
nsTArray<nsCOMPtr<Element>> orderedElements(mCandidates.Count());
|
||||
for (Element* child = mDoc->GetFirstElementChild(); child; child = child->GetNextElementSibling()) {
|
||||
if (!Traverse(child->AsElement(), orderedElements)) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return orderedElements;
|
||||
}
|
||||
|
||||
bool
|
||||
CandidateFinder::Traverse(Element* aRoot, nsTArray<nsCOMPtr<Element>>& aOrderedElements)
|
||||
{
|
||||
nsCOMPtr<Element> elem;
|
||||
if (mCandidates.Remove(aRoot, getter_AddRefs(elem))) {
|
||||
aOrderedElements.AppendElement(Move(elem));
|
||||
if (mCandidates.Count() == 0) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (ShadowRoot* root = aRoot->GetShadowRoot()) {
|
||||
// First iterate the children of the shadow root if aRoot is a shadow host.
|
||||
for (Element* child = root->GetFirstElementChild(); child;
|
||||
child = child->GetNextElementSibling()) {
|
||||
if (!Traverse(child, aOrderedElements)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate the explicit children of aRoot.
|
||||
for (Element* child = aRoot->GetFirstElementChild(); child;
|
||||
child = child->GetNextElementSibling()) {
|
||||
if (!Traverse(child, aOrderedElements)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void
|
||||
CustomElementRegistry::UpgradeCandidates(nsAtom* aKey,
|
||||
CustomElementDefinition* aDefinition,
|
||||
|
@ -554,14 +466,18 @@ CustomElementRegistry::UpgradeCandidates(nsAtom* aKey,
|
|||
return;
|
||||
}
|
||||
|
||||
// TODO: Bug 1326028 - Upgrade custom element in shadow-including tree order
|
||||
nsAutoPtr<nsTArray<nsWeakPtr>> candidates;
|
||||
if (mCandidatesMap.Remove(aKey, &candidates)) {
|
||||
MOZ_ASSERT(candidates);
|
||||
CustomElementReactionsStack* reactionsStack =
|
||||
docGroup->CustomElementReactionsStack();
|
||||
for (size_t i = 0; i < candidates->Length(); ++i) {
|
||||
nsCOMPtr<Element> elem = do_QueryReferent(candidates->ElementAt(i));
|
||||
if (!elem) {
|
||||
continue;
|
||||
}
|
||||
|
||||
CandidateFinder finder(Move(*candidates), mWindow->GetExtantDoc());
|
||||
for (auto& elem : finder.OrderedCandidates()) {
|
||||
reactionsStack->EnqueueUpgradeReaction(elem, aDefinition);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,7 +1,10 @@
|
|||
[CustomElementRegistry.html]
|
||||
prefs: [dom.webcomponents.shadowdom.enabled:true]
|
||||
[customElements.define must get callbacks of the constructor prototype]
|
||||
expected: FAIL
|
||||
|
||||
[customElements.define must get "observedAttributes" property on the constructor prototype when "attributeChangedCallback" is present]
|
||||
expected: FAIL
|
||||
|
||||
[customElements.define must upgrade elements in the shadow-including tree order]
|
||||
expected: FAIL
|
||||
|
||||
|
|
|
@ -54,21 +54,6 @@ public:
|
|||
*/
|
||||
Interface* GetWeak(KeyType aKey, bool* aFound = nullptr) const;
|
||||
|
||||
/**
|
||||
* Allows inserting a value into the hashtable, moving its owning reference
|
||||
* count into the hashtable, avoiding an AddRef.
|
||||
*/
|
||||
void Put(KeyType aKey, already_AddRefed<Interface>&& aData)
|
||||
{
|
||||
if (!Put(aKey, mozilla::Move(aData), mozilla::fallible)) {
|
||||
NS_ABORT_OOM(this->mTable.EntrySize() * this->mTable.EntryCount());
|
||||
}
|
||||
}
|
||||
|
||||
MOZ_MUST_USE bool Put(KeyType aKey, already_AddRefed<Interface>&& aData,
|
||||
const mozilla::fallible_t&);
|
||||
using base_type::Put;
|
||||
|
||||
/**
|
||||
* Remove the entry associated with aKey (if any), optionally _moving_ its
|
||||
* current value into *aData, thereby avoiding calls to AddRef and Release.
|
||||
|
@ -165,21 +150,6 @@ nsInterfaceHashtable<KeyClass, Interface>::GetWeak(KeyType aKey,
|
|||
return nullptr;
|
||||
}
|
||||
|
||||
template<class KeyClass, class Interface>
|
||||
bool
|
||||
nsInterfaceHashtable<KeyClass, Interface>::Put(KeyType aKey,
|
||||
already_AddRefed<Interface>&& aValue,
|
||||
const mozilla::fallible_t&)
|
||||
{
|
||||
typename base_type::EntryType* ent = this->PutEntry(aKey);
|
||||
if (!ent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
ent->mData = aValue;
|
||||
return true;
|
||||
}
|
||||
|
||||
template<class KeyClass, class Interface>
|
||||
bool
|
||||
nsInterfaceHashtable<KeyClass, Interface>::Remove(KeyType aKey,
|
||||
|
|
Загрузка…
Ссылка в новой задаче