summaryrefslogtreecommitdiff
path: root/dom/base
diff options
context:
space:
mode:
authorMatt A. Tobin <email@mattatobin.com>2020-04-17 06:34:38 -0400
committerMatt A. Tobin <email@mattatobin.com>2020-04-17 06:34:38 -0400
commit5f12940329ba496da5730863cae94cd8c0b145da (patch)
tree7dede8dd472329aac367a5bd1c02494fca44482f /dom/base
parenta72b827325c25c5951b57146e482e49e92e60f32 (diff)
downloaduxp-5f12940329ba496da5730863cae94cd8c0b145da.tar.gz
Bug 1396584 - Remove support for multiple ShadowRoots
Tag #1375
Diffstat (limited to 'dom/base')
-rw-r--r--dom/base/ChildIterator.cpp59
-rw-r--r--dom/base/ChildIterator.h9
-rw-r--r--dom/base/DocumentFragment.cpp4
-rw-r--r--dom/base/DocumentFragment.h13
-rw-r--r--dom/base/Element.cpp22
-rw-r--r--dom/base/FragmentOrElement.cpp25
-rw-r--r--dom/base/ShadowRoot.cpp182
-rw-r--r--dom/base/ShadowRoot.h51
-rw-r--r--dom/base/nsContentUtils.cpp15
-rw-r--r--dom/base/nsGkAtomList.h1
-rw-r--r--dom/base/nsNodeUtils.cpp4
-rw-r--r--dom/base/test/test_mutationobservers.html28
12 files changed, 42 insertions, 371 deletions
diff --git a/dom/base/ChildIterator.cpp b/dom/base/ChildIterator.cpp
index 23b919516b..391b7c326a 100644
--- a/dom/base/ChildIterator.cpp
+++ b/dom/base/ChildIterator.cpp
@@ -8,7 +8,6 @@
#include "nsContentUtils.h"
#include "mozilla/dom/XBLChildrenElement.h"
#include "mozilla/dom/HTMLContentElement.h"
-#include "mozilla/dom/HTMLShadowElement.h"
#include "mozilla/dom/ShadowRoot.h"
#include "nsIAnonymousContentCreator.h"
#include "nsIFrame.h"
@@ -78,17 +77,6 @@ ExplicitChildIterator::GetNextChild()
}
mIndexInInserted = 0;
mChild = mChild->GetNextSibling();
- } else if (mShadowIterator) {
- // If we're inside of a <shadow> element, look through the
- // explicit children of the projected ShadowRoot via
- // the mShadowIterator.
- nsIContent* nextChild = mShadowIterator->GetNextChild();
- if (nextChild) {
- return nextChild;
- }
-
- mShadowIterator = nullptr;
- mChild = mChild->GetNextSibling();
} else if (mDefaultChild) {
// If we're already in default content, check if there are more nodes there
MOZ_ASSERT(mChild);
@@ -110,23 +98,7 @@ ExplicitChildIterator::GetNextChild()
// Iterate until we find a non-insertion point, or an insertion point with
// content.
while (mChild) {
- // If the current child being iterated is a shadow insertion point then
- // the iterator needs to go into the projected ShadowRoot.
- if (ShadowRoot::IsShadowInsertionPoint(mChild)) {
- // Look for the next child in the projected ShadowRoot for the <shadow>
- // element.
- HTMLShadowElement* shadowElem = HTMLShadowElement::FromContent(mChild);
- ShadowRoot* projectedShadow = shadowElem->GetOlderShadowRoot();
- if (projectedShadow) {
- mShadowIterator = new ExplicitChildIterator(projectedShadow);
- nsIContent* nextChild = mShadowIterator->GetNextChild();
- if (nextChild) {
- return nextChild;
- }
- mShadowIterator = nullptr;
- }
- mChild = mChild->GetNextSibling();
- } else if (nsContentUtils::IsContentInsertionPoint(mChild)) {
+ if (nsContentUtils::IsContentInsertionPoint(mChild)) {
// If the current child being iterated is a content insertion point
// then the iterator needs to return the nodes distributed into
// the content insertion point.
@@ -198,11 +170,9 @@ ExplicitChildIterator::Seek(nsIContent* aChildToFind)
!aChildToFind->IsRootOfAnonymousSubtree()) {
// Fast path: just point ourselves to aChildToFind, which is a
// normal DOM child of ours.
- MOZ_ASSERT(!ShadowRoot::IsShadowInsertionPoint(aChildToFind));
MOZ_ASSERT(!nsContentUtils::IsContentInsertionPoint(aChildToFind));
mChild = aChildToFind;
mIndexInInserted = 0;
- mShadowIterator = nullptr;
mDefaultChild = nullptr;
mIsFirst = false;
return true;
@@ -223,9 +193,8 @@ ExplicitChildIterator::Get() const
if (mIndexInInserted) {
MatchedNodes assignedChildren = GetMatchedNodesForPoint(mChild);
return assignedChildren[mIndexInInserted - 1];
- } else if (mShadowIterator) {
- return mShadowIterator->Get();
}
+
return mDefaultChild ? mDefaultChild : mChild;
}
@@ -241,13 +210,6 @@ ExplicitChildIterator::GetPreviousChild()
return assignedChildren[mIndexInInserted - 1];
}
mChild = mChild->GetPreviousSibling();
- } else if (mShadowIterator) {
- nsIContent* previousChild = mShadowIterator->GetPreviousChild();
- if (previousChild) {
- return previousChild;
- }
- mShadowIterator = nullptr;
- mChild = mChild->GetPreviousSibling();
} else if (mDefaultChild) {
// If we're already in default content, check if there are more nodes there
mDefaultChild = mDefaultChild->GetPreviousSibling();
@@ -267,22 +229,7 @@ ExplicitChildIterator::GetPreviousChild()
// Iterate until we find a non-insertion point, or an insertion point with
// content.
while (mChild) {
- if (ShadowRoot::IsShadowInsertionPoint(mChild)) {
- // If the current child being iterated is a shadow insertion point then
- // the iterator needs to go into the projected ShadowRoot.
- HTMLShadowElement* shadowElem = HTMLShadowElement::FromContent(mChild);
- ShadowRoot* projectedShadow = shadowElem->GetOlderShadowRoot();
- if (projectedShadow) {
- // Create a ExplicitChildIterator that begins iterating from the end.
- mShadowIterator = new ExplicitChildIterator(projectedShadow, false);
- nsIContent* previousChild = mShadowIterator->GetPreviousChild();
- if (previousChild) {
- return previousChild;
- }
- mShadowIterator = nullptr;
- }
- mChild = mChild->GetPreviousSibling();
- } else if (nsContentUtils::IsContentInsertionPoint(mChild)) {
+ if (nsContentUtils::IsContentInsertionPoint(mChild)) {
// If the current child being iterated is a content insertion point
// then the iterator needs to return the nodes distributed into
// the content insertion point.
diff --git a/dom/base/ChildIterator.h b/dom/base/ChildIterator.h
index 63425149af..f78ba7ca3d 100644
--- a/dom/base/ChildIterator.h
+++ b/dom/base/ChildIterator.h
@@ -48,15 +48,11 @@ public:
ExplicitChildIterator(const ExplicitChildIterator& aOther)
: mParent(aOther.mParent), mChild(aOther.mChild),
mDefaultChild(aOther.mDefaultChild),
- mShadowIterator(aOther.mShadowIterator ?
- new ExplicitChildIterator(*aOther.mShadowIterator) :
- nullptr),
mIndexInInserted(aOther.mIndexInInserted), mIsFirst(aOther.mIsFirst) {}
ExplicitChildIterator(ExplicitChildIterator&& aOther)
: mParent(aOther.mParent), mChild(aOther.mChild),
mDefaultChild(aOther.mDefaultChild),
- mShadowIterator(Move(aOther.mShadowIterator)),
mIndexInInserted(aOther.mIndexInInserted), mIsFirst(aOther.mIsFirst) {}
nsIContent* GetNextChild();
@@ -114,11 +110,6 @@ protected:
// to null, we continue iterating at mChild's next sibling.
nsIContent* mDefaultChild;
- // If non-null, this points to an iterator of the explicit children of
- // the ShadowRoot projected by the current shadow element that we're
- // iterating.
- nsAutoPtr<ExplicitChildIterator> mShadowIterator;
-
// If not zero, we're iterating inserted children for an insertion point. This
// is an index into mChild's inserted children array (mChild must be an
// nsXBLChildrenElement). The index is one past the "current" child (as
diff --git a/dom/base/DocumentFragment.cpp b/dom/base/DocumentFragment.cpp
index b3d0d9962d..3e1e2c81bf 100644
--- a/dom/base/DocumentFragment.cpp
+++ b/dom/base/DocumentFragment.cpp
@@ -125,9 +125,7 @@ DocumentFragment::Constructor(const GlobalObject& aGlobal,
return window->GetDoc()->CreateDocumentFragment();
}
-NS_IMPL_CYCLE_COLLECTION_INHERITED(DocumentFragment,
- FragmentOrElement,
- mHost)
+NS_IMPL_CYCLE_COLLECTION_INHERITED(DocumentFragment, FragmentOrElement, mHost)
// QueryInterface implementation for DocumentFragment
NS_INTERFACE_MAP_BEGIN(DocumentFragment)
diff --git a/dom/base/DocumentFragment.h b/dom/base/DocumentFragment.h
index 33d8d4d9d5..ccc233ff13 100644
--- a/dom/base/DocumentFragment.h
+++ b/dom/base/DocumentFragment.h
@@ -43,8 +43,7 @@ public:
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
- NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DocumentFragment,
- FragmentOrElement)
+ NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(DocumentFragment, FragmentOrElement)
// interface nsIDOMNode
NS_FORWARD_NSIDOMNODE_TO_NSINODE
@@ -123,15 +122,9 @@ public:
return nullptr;
}
- Element* GetHost() const
- {
- return mHost;
- }
+ Element* GetHost() const { return mHost; }
- void SetHost(Element* aHost)
- {
- mHost = aHost;
- }
+ void SetHost(Element* aHost) { mHost = aHost; }
static already_AddRefed<DocumentFragment>
Constructor(const GlobalObject& aGlobal, ErrorResult& aRv);
diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp
index a2b78092ad..5bbfbee9b4 100644
--- a/dom/base/Element.cpp
+++ b/dom/base/Element.cpp
@@ -1095,6 +1095,11 @@ Element::RemoveFromIdTable()
already_AddRefed<ShadowRoot>
Element::CreateShadowRoot(ErrorResult& aError)
{
+ if (GetShadowRoot()) {
+ aError.Throw(NS_ERROR_DOM_INVALID_STATE_ERR);
+ return nullptr;
+ }
+
nsAutoScriptBlocker scriptBlocker;
RefPtr<mozilla::dom::NodeInfo> nodeInfo;
@@ -1131,24 +1136,7 @@ Element::CreateShadowRoot(ErrorResult& aError)
shadowRoot->SetIsComposedDocParticipant(IsInComposedDoc());
- // Replace the old ShadowRoot with the new one and let the old
- // ShadowRoot know about the younger ShadowRoot because the old
- // ShadowRoot is projected into the younger ShadowRoot's shadow
- // insertion point (if it exists).
- ShadowRoot* olderShadow = GetShadowRoot();
SetShadowRoot(shadowRoot);
- if (olderShadow) {
- olderShadow->SetYoungerShadow(shadowRoot);
-
- // Unbind children of older shadow root because they
- // are no longer in the composed tree.
- for (nsIContent* child = olderShadow->GetFirstChild(); child;
- child = child->GetNextSibling()) {
- child->UnbindFromTree(true, false);
- }
-
- olderShadow->SetIsComposedDocParticipant(false);
- }
// xblBinding takes ownership of docInfo.
RefPtr<nsXBLBinding> xblBinding = new nsXBLBinding(shadowRoot, protoBinding);
diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp
index d7e7a78f49..592f5447d2 100644
--- a/dom/base/FragmentOrElement.cpp
+++ b/dom/base/FragmentOrElement.cpp
@@ -861,23 +861,10 @@ nsIContent::GetEventTargetParent(EventChainPreVisitor& aVisitor)
// for destination insertion points where nodes have been distributed.
nsTArray<nsIContent*>* destPoints = GetExistingDestInsertionPoints();
if (destPoints && !destPoints->IsEmpty()) {
- // Push destination insertion points to aVisitor.mDestInsertionPoints
- // excluding shadow insertion points.
- bool didPushNonShadowInsertionPoint = false;
+ // Push destination insertion points to aVisitor.mDestInsertionPoints.
for (uint32_t i = 0; i < destPoints->Length(); i++) {
nsIContent* point = destPoints->ElementAt(i);
- if (!ShadowRoot::IsShadowInsertionPoint(point)) {
- aVisitor.mDestInsertionPoints.AppendElement(point);
- didPushNonShadowInsertionPoint = true;
- }
- }
-
- // Next node in the event path is the final destination
- // (non-shadow) insertion point that was pushed.
- if (didPushNonShadowInsertionPoint) {
- parent = aVisitor.mDestInsertionPoints.LastElement();
- aVisitor.mDestInsertionPoints.SetLength(
- aVisitor.mDestInsertionPoints.Length() - 1);
+ aVisitor.mDestInsertionPoints.AppendElement(point);
}
}
@@ -901,10 +888,7 @@ nsIContent::GetEventTargetParent(EventChainPreVisitor& aVisitor)
aVisitor.mDestInsertionPoints.SetLength(
aVisitor.mDestInsertionPoints.Length() - 1);
} else {
- // The pool host for the youngest shadow root is shadow DOM host,
- // for older shadow roots, it is the shadow insertion point
- // where the shadow root is projected, nullptr if none exists.
- parent = thisShadowRoot->GetPoolHost();
+ parent = thisShadowRoot->GetHost();
}
}
@@ -2407,9 +2391,8 @@ FragmentOrElement::SetIsElementInStyleScopeFlagOnShadowTree(bool aInStyleScope)
NS_ASSERTION(IsElement(), "calling SetIsElementInStyleScopeFlagOnShadowTree "
"on a non-Element is useless");
ShadowRoot* shadowRoot = GetShadowRoot();
- while (shadowRoot) {
+ if (shadowRoot) {
shadowRoot->SetIsElementInStyleScopeFlagOnSubtree(aInStyleScope);
- shadowRoot = shadowRoot->GetOlderShadowRoot();
}
}
diff --git a/dom/base/ShadowRoot.cpp b/dom/base/ShadowRoot.cpp
index 51223a8937..c9bd58d53a 100644
--- a/dom/base/ShadowRoot.cpp
+++ b/dom/base/ShadowRoot.cpp
@@ -15,7 +15,6 @@
#include "nsIStyleSheetLinkingElement.h"
#include "mozilla/dom/Element.h"
#include "mozilla/dom/HTMLContentElement.h"
-#include "mozilla/dom/HTMLShadowElement.h"
#include "nsXBLPrototypeBinding.h"
#include "mozilla/StyleSheet.h"
#include "mozilla/StyleSheetInlines.h"
@@ -27,10 +26,7 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(ShadowRoot)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ShadowRoot,
DocumentFragment)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mPoolHost)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStyleSheetList)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mOlderShadow)
- NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mYoungerShadow)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAssociatedBinding)
for (auto iter = tmp->mIdentifierMap.ConstIter(); !iter.Done();
iter.Next()) {
@@ -38,18 +34,14 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ShadowRoot,
}
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
-NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(ShadowRoot,
- DocumentFragment)
- if (tmp->mPoolHost) {
- tmp->mPoolHost->RemoveMutationObserver(tmp);
+NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ShadowRoot)
+ if (tmp->GetHost()) {
+ tmp->GetHost()->RemoveMutationObserver(tmp);
}
- NS_IMPL_CYCLE_COLLECTION_UNLINK(mPoolHost)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mStyleSheetList)
- NS_IMPL_CYCLE_COLLECTION_UNLINK(mOlderShadow)
- NS_IMPL_CYCLE_COLLECTION_UNLINK(mYoungerShadow)
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAssociatedBinding)
tmp->mIdentifierMap.Clear();
-NS_IMPL_CYCLE_COLLECTION_UNLINK_END
+NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(DocumentFragment)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(ShadowRoot)
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
@@ -62,9 +54,10 @@ NS_IMPL_RELEASE_INHERITED(ShadowRoot, DocumentFragment)
ShadowRoot::ShadowRoot(Element* aElement,
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
nsXBLPrototypeBinding* aProtoBinding)
- : DocumentFragment(aNodeInfo), mPoolHost(aElement),
- mProtoBinding(aProtoBinding), mShadowElement(nullptr),
- mInsertionPointChanged(false), mIsComposedDocParticipant(false)
+ : DocumentFragment(aNodeInfo)
+ , mProtoBinding(aProtoBinding)
+ , mInsertionPointChanged(false)
+ , mIsComposedDocParticipant(false)
{
SetHost(aElement);
@@ -81,23 +74,21 @@ ShadowRoot::ShadowRoot(Element* aElement,
// Add the ShadowRoot as a mutation observer on the host to watch
// for mutations because the insertion points in this ShadowRoot
// may need to be updated when the host children are modified.
- mPoolHost->AddMutationObserver(this);
+ GetHost()->AddMutationObserver(this);
}
ShadowRoot::~ShadowRoot()
{
- if (mPoolHost) {
+ if (GetHost()) {
// mPoolHost may have been unlinked or a new ShadowRoot may have been
// creating, making this one obsolete.
- mPoolHost->RemoveMutationObserver(this);
+ GetHost()->RemoveMutationObserver(this);
}
UnsetFlags(NODE_IS_IN_SHADOW_TREE);
// nsINode destructor expects mSubtreeRoot == this.
SetSubtreeRootPointer(this);
-
- SetHost(nullptr);
}
JSObject*
@@ -246,15 +237,6 @@ ShadowRoot::RemoveInsertionPoint(HTMLContentElement* aInsertionPoint)
}
void
-ShadowRoot::SetYoungerShadow(ShadowRoot* aYoungerShadow)
-{
- mYoungerShadow = aYoungerShadow;
- mYoungerShadow->mOlderShadow = this;
-
- ChangePoolHost(mYoungerShadow->GetShadowElement());
-}
-
-void
ShadowRoot::RemoveDestInsertionPoint(nsIContent* aInsertionPoint,
nsTArray<nsIContent*>& aDestInsertionPoints)
{
@@ -302,8 +284,7 @@ ShadowRoot::DistributeSingleNode(nsIContent* aContent)
// Find the appropriate position in the matched node list for the
// newly distributed content.
bool isIndexFound = false;
- MOZ_ASSERT(mPoolHost, "Where did the content come from if there is no pool host?");
- ExplicitChildIterator childIterator(mPoolHost);
+ ExplicitChildIterator childIterator(GetHost());
for (uint32_t i = 0; i < matchedNodes.Length(); i++) {
// Seek through the host's explicit children until the inserted content
// is found or when the current matched node is reached.
@@ -323,15 +304,6 @@ ShadowRoot::DistributeSingleNode(nsIContent* aContent)
insertionPoint->AppendMatchedNode(aContent);
}
- // Handle the case where the parent of the insertion point is a ShadowRoot
- // that is projected into the younger ShadowRoot's shadow insertion point.
- // The node distributed into the insertion point must be reprojected
- // to the shadow insertion point.
- if (insertionPoint->GetParent() == this &&
- mYoungerShadow && mYoungerShadow->GetShadowElement()) {
- mYoungerShadow->GetShadowElement()->DistributeSingleNode(aContent);
- }
-
// Handle the case where the parent of the insertion point has a ShadowRoot.
// The node distributed into the insertion point must be reprojected to the
// insertion points of the parent's ShadowRoot.
@@ -339,16 +311,6 @@ ShadowRoot::DistributeSingleNode(nsIContent* aContent)
if (parentShadow) {
parentShadow->DistributeSingleNode(aContent);
}
-
- // Handle the case where the parent of the insertion point is the <shadow>
- // element. The node distributed into the insertion point must be reprojected
- // into the older ShadowRoot's insertion points.
- if (mShadowElement && mShadowElement == insertionPoint->GetParent()) {
- ShadowRoot* olderShadow = mShadowElement->GetOlderShadowRoot();
- if (olderShadow) {
- olderShadow->DistributeSingleNode(aContent);
- }
- }
}
}
@@ -370,15 +332,6 @@ ShadowRoot::RemoveDistributedNode(nsIContent* aContent)
mInsertionPoints[i]->RemoveMatchedNode(aContent);
- // Handle the case where the parent of the insertion point is a ShadowRoot
- // that is projected into the younger ShadowRoot's shadow insertion point.
- // The removed node needs to be removed from the shadow insertion point.
- if (mInsertionPoints[i]->GetParent() == this) {
- if (mYoungerShadow && mYoungerShadow->GetShadowElement()) {
- mYoungerShadow->GetShadowElement()->RemoveDistributedNode(aContent);
- }
- }
-
// Handle the case where the parent of the insertion point has a ShadowRoot.
// The removed node needs to be removed from the insertion points of the
// parent's ShadowRoot.
@@ -387,16 +340,6 @@ ShadowRoot::RemoveDistributedNode(nsIContent* aContent)
parentShadow->RemoveDistributedNode(aContent);
}
- // Handle the case where the parent of the insertion point is the <shadow>
- // element. The removed node must be removed from the older ShadowRoot's
- // insertion points.
- if (mShadowElement && mShadowElement == mInsertionPoints[i]->GetParent()) {
- ShadowRoot* olderShadow = mShadowElement->GetOlderShadowRoot();
- if (olderShadow) {
- olderShadow->RemoveDistributedNode(aContent);
- }
- }
-
break;
}
}
@@ -407,16 +350,10 @@ ShadowRoot::DistributeAllNodes()
{
// Create node pool.
nsTArray<nsIContent*> nodePool;
-
- // Make sure there is a pool host, an older shadow may not have
- // one if the younger shadow does not have a <shadow> element.
- if (mPoolHost) {
- ExplicitChildIterator childIterator(mPoolHost);
- for (nsIContent* content = childIterator.GetNextChild();
- content;
- content = childIterator.GetNextChild()) {
- nodePool.AppendElement(content);
- }
+ ExplicitChildIterator childIterator(GetHost());
+ for (nsIContent* content = childIterator.GetNextChild(); content;
+ content = childIterator.GetNextChild()) {
+ nodePool.AppendElement(content);
}
nsTArray<ShadowRoot*> shadowsToUpdate;
@@ -447,20 +384,6 @@ ShadowRoot::DistributeAllNodes()
}
}
- // If there is a shadow insertion point in this ShadowRoot, the children
- // of the shadow insertion point needs to be distributed into the insertion
- // points of the older ShadowRoot.
- if (mShadowElement && mOlderShadow) {
- mOlderShadow->DistributeAllNodes();
- }
-
- // If there is a younger ShadowRoot with a shadow insertion point,
- // then the children of this ShadowRoot needs to be distributed to
- // the younger ShadowRoot's shadow insertion point.
- if (mYoungerShadow && mYoungerShadow->GetShadowElement()) {
- mYoungerShadow->GetShadowElement()->DistributeAllNodes();
- }
-
for (uint32_t i = 0; i < shadowsToUpdate.Length(); i++) {
shadowsToUpdate[i]->DistributeAllNodes();
}
@@ -517,59 +440,6 @@ ShadowRoot::StyleSheets()
return mStyleSheetList;
}
-void
-ShadowRoot::SetShadowElement(HTMLShadowElement* aShadowElement)
-{
- // If there is already a shadow element point, remove
- // the projected shadow because it is no longer an insertion
- // point.
- if (mShadowElement) {
- mShadowElement->SetProjectedShadow(nullptr);
- }
-
- if (mOlderShadow) {
- // Nodes for distribution will come from the new shadow element.
- mOlderShadow->ChangePoolHost(aShadowElement);
- }
-
- // Set the new shadow element to project the older ShadowRoot because
- // it is the current shadow insertion point.
- mShadowElement = aShadowElement;
- if (mShadowElement) {
- mShadowElement->SetProjectedShadow(mOlderShadow);
- }
-}
-
-void
-ShadowRoot::ChangePoolHost(nsIContent* aNewHost)
-{
- if (mPoolHost) {
- mPoolHost->RemoveMutationObserver(this);
- }
-
- // Clear the nodes matched to content insertion points
- // because it is no longer relevant.
- for (uint32_t i = 0; i < mInsertionPoints.Length(); i++) {
- mInsertionPoints[i]->ClearMatchedNodes();
- }
-
- mPoolHost = aNewHost;
- if (mPoolHost) {
- mPoolHost->AddMutationObserver(this);
- }
-}
-
-bool
-ShadowRoot::IsShadowInsertionPoint(nsIContent* aContent)
-{
- if (!aContent) {
- return false;
- }
-
- HTMLShadowElement* shadowElem = HTMLShadowElement::FromContent(aContent);
- return shadowElem && shadowElem->IsInsertionPoint();
-}
-
/**
* Returns whether the web components pool population algorithm
* on the host would contain |aContent|. This function ignores
@@ -580,8 +450,7 @@ bool
ShadowRoot::IsPooledNode(nsIContent* aContent, nsIContent* aContainer,
nsIContent* aHost)
{
- if (nsContentUtils::IsContentInsertionPoint(aContent) ||
- IsShadowInsertionPoint(aContent)) {
+ if (nsContentUtils::IsContentInsertionPoint(aContent)) {
// Insertion points never end up in the pool.
return false;
}
@@ -614,7 +483,7 @@ ShadowRoot::AttributeChanged(nsIDocument* aDocument,
int32_t aModType,
const nsAttrValue* aOldValue)
{
- if (!IsPooledNode(aElement, aElement->GetParent(), mPoolHost)) {
+ if (!IsPooledNode(aElement, aElement->GetParent(), GetHost())) {
return;
}
@@ -647,7 +516,7 @@ ShadowRoot::ContentAppended(nsIDocument* aDocument,
}
}
- if (IsPooledNode(currentChild, aContainer, mPoolHost)) {
+ if (IsPooledNode(currentChild, aContainer, GetHost())) {
DistributeSingleNode(currentChild);
}
@@ -669,7 +538,7 @@ ShadowRoot::ContentInserted(nsIDocument* aDocument,
// Watch for new nodes added to the pool because the node
// may need to be added to an insertion point.
- if (IsPooledNode(aChild, aContainer, mPoolHost)) {
+ if (IsPooledNode(aChild, aContainer, GetHost())) {
// Add insertion point to destination insertion points of fallback content.
if (nsContentUtils::IsContentInsertionPoint(aContainer)) {
HTMLContentElement* content = HTMLContentElement::FromContent(aContainer);
@@ -706,7 +575,7 @@ ShadowRoot::ContentRemoved(nsIDocument* aDocument,
// Watch for node that is removed from the pool because
// it may need to be removed from an insertion point.
- if (IsPooledNode(aChild, aContainer, mPoolHost)) {
+ if (IsPooledNode(aChild, aContainer, GetHost())) {
RemoveDistributedNode(aChild);
}
}
@@ -718,15 +587,6 @@ ShadowRoot::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const
return NS_ERROR_DOM_DATA_CLONE_ERR;
}
-void
-ShadowRoot::DestroyContent()
-{
- if (mOlderShadow) {
- mOlderShadow->DestroyContent();
- }
- DocumentFragment::DestroyContent();
-}
-
NS_IMPL_CYCLE_COLLECTION_INHERITED(ShadowRootStyleSheetList, StyleSheetList,
mShadowRoot)
diff --git a/dom/base/ShadowRoot.h b/dom/base/ShadowRoot.h
index e76e4ab3f3..04943752be 100644
--- a/dom/base/ShadowRoot.h
+++ b/dom/base/ShadowRoot.h
@@ -25,7 +25,6 @@ namespace dom {
class Element;
class HTMLContentElement;
-class HTMLShadowElement;
class ShadowRootStyleSheetList;
class ShadowRoot final : public DocumentFragment,
@@ -42,7 +41,8 @@ public:
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
- ShadowRoot(Element* aElement, already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
+ ShadowRoot(Element* aElement,
+ already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
nsXBLPrototypeBinding* aProtoBinding);
void AddToIdTable(Element* aElement, nsIAtom* aId);
@@ -52,24 +52,6 @@ public:
bool ApplyAuthorStyles();
void SetApplyAuthorStyles(bool aApplyAuthorStyles);
StyleSheetList* StyleSheets();
- HTMLShadowElement* GetShadowElement() { return mShadowElement; }
-
- /**
- * Sets the current shadow insertion point where the older
- * ShadowRoot will be projected.
- */
- void SetShadowElement(HTMLShadowElement* aShadowElement);
-
- /**
- * Change the node that populates the distribution pool with
- * its children. This is distinct from the ShadowRoot host described
- * in the specifications. The ShadowRoot host is the element
- * which created this ShadowRoot and does not change. The pool host
- * is the same as the ShadowRoot host if this is the youngest
- * ShadowRoot. If this is an older ShadowRoot, the pool host is
- * the <shadow> element in the younger ShadowRoot (if it exists).
- */
- void ChangePoolHost(nsIContent* aNewHost);
/**
* Distributes a single explicit child of the pool host to the content
@@ -92,23 +74,15 @@ public:
void AddInsertionPoint(HTMLContentElement* aInsertionPoint);
void RemoveInsertionPoint(HTMLContentElement* aInsertionPoint);
- void SetYoungerShadow(ShadowRoot* aYoungerShadow);
- ShadowRoot* GetYoungerShadowRoot() { return mYoungerShadow; }
void SetInsertionPointChanged() { mInsertionPointChanged = true; }
void SetAssociatedBinding(nsXBLBinding* aBinding) { mAssociatedBinding = aBinding; }
- nsISupports* GetParentObject() const { return mPoolHost; }
-
- nsIContent* GetPoolHost() { return mPoolHost; }
- nsTArray<HTMLShadowElement*>& ShadowDescendants() { return mShadowDescendants; }
-
JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
static bool IsPooledNode(nsIContent* aChild, nsIContent* aContainer,
nsIContent* aHost);
static ShadowRoot* FromNode(nsINode* aNode);
- static bool IsShadowInsertionPoint(nsIContent* aContent);
static void RemoveDestInsertionPoint(nsIContent* aInsertionPoint,
nsTArray<nsIContent*>& aDestInsertionPoints);
@@ -125,7 +99,6 @@ public:
void GetInnerHTML(nsAString& aInnerHTML);
void SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError);
Element* Host();
- ShadowRoot* GetOlderShadowRoot() { return mOlderShadow; }
void StyleSheetChanged();
bool IsComposedDocParticipant() { return mIsComposedDocParticipant; }
@@ -134,14 +107,9 @@ public:
mIsComposedDocParticipant = aIsComposedDocParticipant;
}
- virtual void DestroyContent() override;
protected:
virtual ~ShadowRoot();
- // The pool host is the parent of the nodes that will be distributed
- // into the insertion points in this ShadowRoot. See |ChangeShadowRoot|.
- nsCOMPtr<nsIContent> mPoolHost;
-
// An array of content insertion points that are a descendant of the ShadowRoot
// sorted in tree order. Insertion points are responsible for notifying
// the ShadowRoot when they are removed or added as a descendant. The insertion
@@ -149,10 +117,6 @@ protected:
// by the array.
nsTArray<HTMLContentElement*> mInsertionPoints;
- // An array of the <shadow> elements that are descendant of the ShadowRoot
- // sorted in tree order. Only the first may be a shadow insertion point.
- nsTArray<HTMLShadowElement*> mShadowDescendants;
-
nsTHashtable<nsIdentifierMapEntry> mIdentifierMap;
nsXBLPrototypeBinding* mProtoBinding;
@@ -163,17 +127,6 @@ protected:
RefPtr<ShadowRootStyleSheetList> mStyleSheetList;
- // The current shadow insertion point of this ShadowRoot.
- HTMLShadowElement* mShadowElement;
-
- // The ShadowRoot that was created by the host element before
- // this ShadowRoot was created.
- RefPtr<ShadowRoot> mOlderShadow;
-
- // The ShadowRoot that was created by the host element after
- // this ShadowRoot was created.
- RefPtr<ShadowRoot> mYoungerShadow;
-
// A boolean that indicates that an insertion point was added or removed
// from this ShadowRoot and that the nodes need to be redistributed into
// the insertion points. After this flag is set, nodes will be distributed
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
index a68f5ef87d..96f9065803 100644
--- a/dom/base/nsContentUtils.cpp
+++ b/dom/base/nsContentUtils.cpp
@@ -46,7 +46,6 @@
#include "mozilla/dom/HTMLMediaElement.h"
#include "mozilla/dom/HTMLTemplateElement.h"
#include "mozilla/dom/HTMLContentElement.h"
-#include "mozilla/dom/HTMLShadowElement.h"
#include "mozilla/dom/ipc/BlobChild.h"
#include "mozilla/dom/ipc/BlobParent.h"
#include "mozilla/dom/Promise.h"
@@ -7056,20 +7055,6 @@ nsContentUtils::HasDistributedChildren(nsIContent* aContent)
return true;
}
- ShadowRoot* shadow = ShadowRoot::FromNode(aContent);
- if (shadow) {
- // Children of a shadow root are distributed to
- // the shadow insertion point of the younger shadow root.
- return shadow->GetYoungerShadowRoot();
- }
-
- HTMLShadowElement* shadowEl = HTMLShadowElement::FromContent(aContent);
- if (shadowEl && shadowEl->IsInsertionPoint()) {
- // Children of a shadow insertion points are distributed
- // to the insertion points in the older shadow root.
- return shadowEl->GetOlderShadowRoot();
- }
-
HTMLContentElement* contentEl = HTMLContentElement::FromContent(aContent);
if (contentEl && contentEl->IsInsertionPoint()) {
// Children of a content insertion point are distributed to the
diff --git a/dom/base/nsGkAtomList.h b/dom/base/nsGkAtomList.h
index 2f0e30387c..0ae35480ff 100644
--- a/dom/base/nsGkAtomList.h
+++ b/dom/base/nsGkAtomList.h
@@ -1560,7 +1560,6 @@ GK_ATOM(saturate, "saturate")
GK_ATOM(saturation, "saturation")
GK_ATOM(set, "set")
GK_ATOM(seed, "seed")
-GK_ATOM(shadow, "shadow")
GK_ATOM(shape_rendering, "shape-rendering")
GK_ATOM(skewX, "skewX")
GK_ATOM(skewY, "skewY")
diff --git a/dom/base/nsNodeUtils.cpp b/dom/base/nsNodeUtils.cpp
index 384e56cde6..5fdd24e439 100644
--- a/dom/base/nsNodeUtils.cpp
+++ b/dom/base/nsNodeUtils.cpp
@@ -65,7 +65,7 @@ using mozilla::AutoJSContext;
} \
ShadowRoot* shadow = ShadowRoot::FromNode(node); \
if (shadow) { \
- node = shadow->GetPoolHost(); \
+ node = shadow->GetHost(); \
} else { \
node = node->GetParentNode(); \
} \
@@ -93,7 +93,7 @@ using mozilla::AutoJSContext;
} \
ShadowRoot* shadow = ShadowRoot::FromNode(node); \
if (shadow) { \
- node = shadow->GetPoolHost(); \
+ node = shadow->GetHost(); \
} else { \
node = node->GetParentNode(); \
} \
diff --git a/dom/base/test/test_mutationobservers.html b/dom/base/test/test_mutationobservers.html
index 7e4c994235..021bedf1c8 100644
--- a/dom/base/test/test_mutationobservers.html
+++ b/dom/base/test/test_mutationobservers.html
@@ -612,7 +612,7 @@ function testOutsideShadowDOM() {
is(records.length, 1);
is(records[0].type, "attributes", "Should have got attributes");
observer.disconnect();
- then(testInsideShadowDOM);
+ then(testMarquee);
});
m.observe(div, {
attributes: true,
@@ -628,32 +628,6 @@ function testOutsideShadowDOM() {
div.setAttribute("foo", "bar");
}
-function testInsideShadowDOM() {
- var m = new M(function(records, observer) {
- is(records.length, 4);
- is(records[0].type, "childList");
- is(records[1].type, "attributes");
- is(records[2].type, "characterData");
- is(records[3].type, "childList");
- observer.disconnect();
- then(testMarquee);
- });
- var sr = div.createShadowRoot();
- m.observe(sr, {
- attributes: true,
- childList: true,
- characterData: true,
- subtree: true
- });
-
- sr.innerHTML = "<div" + ">text</" + "div>";
- sr.firstChild.setAttribute("foo", "bar");
- sr.firstChild.firstChild.data = "text2";
- sr.firstChild.appendChild(document.createElement("div"));
- div.setAttribute("foo", "bar2");
-
-}
-
function testMarquee() {
var m = new M(function(records, observer) {
is(records.length, 1);