Bug 1396584 - Remove support for multiple ShadowRoots, r=mrbkap

--HG--
extra : rebase_source : 2bb600ed1ffd35c195617a7eb70d0ba847a46898
This commit is contained in:
Olli Pettay 2017-09-25 18:09:26 +03:00
Родитель b73bb761aa
Коммит c80e124562
46 изменённых файлов: 1376 добавлений и 2966 удалений

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

@ -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.
@ -196,11 +168,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;
@ -221,9 +191,8 @@ ExplicitChildIterator::Get() const
if (mIndexInInserted) {
MatchedNodes assignedChildren = GetMatchedNodesForPoint(mChild);
return assignedChildren[mIndexInInserted - 1];
} else if (mShadowIterator) {
return mShadowIterator->Get();
}
return mDefaultChild ? mDefaultChild : mChild;
}
@ -239,13 +208,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();
@ -265,22 +227,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.

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

@ -48,16 +48,12 @@ public:
ExplicitChildIterator(const ExplicitChildIterator& aOther)
: mParent(aOther.mParent), mChild(aOther.mChild),
mDefaultChild(aOther.mDefaultChild),
mShadowIterator(aOther.mShadowIterator ?
new ExplicitChildIterator(*aOther.mShadowIterator) :
nullptr),
mIsFirst(aOther.mIsFirst),
mIndexInInserted(aOther.mIndexInInserted) {}
ExplicitChildIterator(ExplicitChildIterator&& aOther)
: mParent(aOther.mParent), mChild(aOther.mChild),
mDefaultChild(aOther.mDefaultChild),
mShadowIterator(Move(aOther.mShadowIterator)),
mIsFirst(aOther.mIsFirst),
mIndexInInserted(aOther.mIndexInInserted) {}
@ -116,11 +112,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;
// A flag to let us know that we haven't started iterating yet.
bool mIsFirst;

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

@ -111,9 +111,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)

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

@ -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
@ -122,15 +121,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);

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

@ -1106,6 +1106,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;
@ -1142,24 +1147,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);

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

@ -1047,23 +1047,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);
}
}
@ -1087,10 +1074,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();
}
}
@ -2619,8 +2603,7 @@ 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();
}
}

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

@ -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(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*
@ -243,15 +234,6 @@ ShadowRoot::RemoveInsertionPoint(HTMLContentElement* aInsertionPoint)
mInsertionPoints.RemoveElement(aInsertionPoint);
}
void
ShadowRoot::SetYoungerShadow(ShadowRoot* aYoungerShadow)
{
mYoungerShadow = aYoungerShadow;
mYoungerShadow->mOlderShadow = this;
ChangePoolHost(mYoungerShadow->GetShadowElement());
}
void
ShadowRoot::RemoveDestInsertionPoint(nsIContent* aInsertionPoint,
nsTArray<nsIContent*>& aDestInsertionPoints)
@ -300,8 +282,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.
@ -321,15 +302,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.
@ -337,16 +309,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);
}
}
}
}
@ -368,15 +330,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.
@ -385,16 +338,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;
}
}
@ -405,16 +348,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;
@ -445,20 +382,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();
}
@ -515,59 +438,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
@ -578,8 +448,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;
}
@ -612,7 +481,7 @@ ShadowRoot::AttributeChanged(nsIDocument* aDocument,
int32_t aModType,
const nsAttrValue* aOldValue)
{
if (!IsPooledNode(aElement, aElement->GetParent(), mPoolHost)) {
if (!IsPooledNode(aElement, aElement->GetParent(), GetHost())) {
return;
}
@ -645,7 +514,7 @@ ShadowRoot::ContentAppended(nsIDocument* aDocument,
}
}
if (IsPooledNode(currentChild, aContainer, mPoolHost)) {
if (IsPooledNode(currentChild, aContainer, GetHost())) {
DistributeSingleNode(currentChild);
}
@ -667,7 +536,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);
@ -704,7 +573,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);
}
}
@ -717,15 +586,6 @@ ShadowRoot::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
return NS_ERROR_DOM_DATA_CLONE_ERR;
}
void
ShadowRoot::DestroyContent()
{
if (mOlderShadow) {
mOlderShadow->DestroyContent();
}
DocumentFragment::DestroyContent();
}
NS_IMPL_CYCLE_COLLECTION_INHERITED(ShadowRootStyleSheetList, StyleSheetList,
mShadowRoot)

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

@ -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

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

@ -50,7 +50,6 @@
#include "mozilla/dom/HTMLInputElement.h"
#include "mozilla/dom/HTMLTemplateElement.h"
#include "mozilla/dom/HTMLContentElement.h"
#include "mozilla/dom/HTMLShadowElement.h"
#include "mozilla/dom/IPCBlobUtils.h"
#include "mozilla/dom/Promise.h"
#include "mozilla/dom/ScriptSettings.h"
@ -7567,20 +7566,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

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

@ -1660,7 +1660,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")

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

@ -66,7 +66,7 @@ using mozilla::AutoJSContext;
} \
ShadowRoot* shadow = ShadowRoot::FromNode(node); \
if (shadow) { \
node = shadow->GetPoolHost(); \
node = shadow->GetHost(); \
} else { \
node = node->GetParentNode(); \
} \
@ -94,7 +94,7 @@ using mozilla::AutoJSContext;
} \
ShadowRoot* shadow = ShadowRoot::FromNode(node); \
if (shadow) { \
node = shadow->GetPoolHost(); \
node = shadow->GetHost(); \
} else { \
node = node->GetParentNode(); \
} \

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

@ -587,7 +587,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,
@ -603,32 +603,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);

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

@ -1,373 +0,0 @@
/* -*- 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/. */
#include "mozilla/dom/ShadowRoot.h"
#include "ChildIterator.h"
#include "nsContentUtils.h"
#include "nsDocument.h"
#include "mozilla/dom/HTMLShadowElement.h"
#include "mozilla/dom/HTMLUnknownElement.h"
#include "mozilla/dom/HTMLShadowElementBinding.h"
// Expand NS_IMPL_NS_NEW_HTML_ELEMENT(Shadow) to add check for web components
// being enabled.
nsGenericHTMLElement*
NS_NewHTMLShadowElement(already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
mozilla::dom::FromParser aFromParser)
{
// When this check is removed, remove the nsDocument.h and
// HTMLUnknownElement.h includes. Also remove nsINode::IsHTMLShadowElement.
//
// We have to jump through some hoops to be able to produce both NodeInfo* and
// already_AddRefed<NodeInfo>& for our callees.
RefPtr<mozilla::dom::NodeInfo> nodeInfo(aNodeInfo);
if (!nsDocument::IsWebComponentsEnabled(nodeInfo)) {
already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
return new mozilla::dom::HTMLUnknownElement(nodeInfoArg);
}
already_AddRefed<mozilla::dom::NodeInfo> nodeInfoArg(nodeInfo.forget());
return new mozilla::dom::HTMLShadowElement(nodeInfoArg);
}
using namespace mozilla::dom;
HTMLShadowElement::HTMLShadowElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo)
: nsGenericHTMLElement(aNodeInfo), mIsInsertionPoint(false)
{
}
HTMLShadowElement::~HTMLShadowElement()
{
if (mProjectedShadow) {
mProjectedShadow->RemoveMutationObserver(this);
}
}
NS_IMPL_CYCLE_COLLECTION_CLASS(HTMLShadowElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(HTMLShadowElement,
nsGenericHTMLElement)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mProjectedShadow)
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(HTMLShadowElement,
nsGenericHTMLElement)
if (tmp->mProjectedShadow) {
tmp->mProjectedShadow->RemoveMutationObserver(tmp);
tmp->mProjectedShadow = nullptr;
}
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
NS_IMPL_ADDREF_INHERITED(HTMLShadowElement, Element)
NS_IMPL_RELEASE_INHERITED(HTMLShadowElement, Element)
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(HTMLShadowElement)
NS_INTERFACE_MAP_END_INHERITING(nsGenericHTMLElement)
NS_IMPL_ELEMENT_CLONE(HTMLShadowElement)
JSObject*
HTMLShadowElement::WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
{
return HTMLShadowElementBinding::Wrap(aCx, this, aGivenProto);
}
void
HTMLShadowElement::SetProjectedShadow(ShadowRoot* aProjectedShadow)
{
if (mProjectedShadow) {
mProjectedShadow->RemoveMutationObserver(this);
// The currently projected ShadowRoot is going away,
// thus the destination insertion points need to be updated.
ExplicitChildIterator childIterator(mProjectedShadow);
for (nsIContent* content = childIterator.GetNextChild();
content;
content = childIterator.GetNextChild()) {
ShadowRoot::RemoveDestInsertionPoint(this, content->DestInsertionPoints());
}
}
mProjectedShadow = aProjectedShadow;
if (mProjectedShadow) {
// A new ShadowRoot is being projected, thus its explcit
// children will be distributed to this shadow insertion point.
ExplicitChildIterator childIterator(mProjectedShadow);
for (nsIContent* content = childIterator.GetNextChild();
content;
content = childIterator.GetNextChild()) {
content->DestInsertionPoints().AppendElement(this);
}
// Watch for mutations on the projected shadow because
// it affects the nodes that are distributed to this shadow
// insertion point.
mProjectedShadow->AddMutationObserver(this);
}
}
static bool
IsInFallbackContent(nsIContent* aContent)
{
nsINode* parentNode = aContent->GetParentNode();
while (parentNode) {
if (parentNode->IsHTMLElement(nsGkAtoms::content)) {
return true;
}
parentNode = parentNode->GetParentNode();
}
return false;
}
nsresult
HTMLShadowElement::BindToTree(nsIDocument* aDocument,
nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers)
{
RefPtr<ShadowRoot> oldContainingShadow = GetContainingShadow();
nsresult rv = nsGenericHTMLElement::BindToTree(aDocument, aParent,
aBindingParent,
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
ShadowRoot* containingShadow = GetContainingShadow();
if (containingShadow && !oldContainingShadow) {
// Keep track of all descendant <shadow> elements in tree order so
// that when the current shadow insertion point is removed, the next
// one can be found quickly.
TreeOrderComparator comparator;
containingShadow->ShadowDescendants().InsertElementSorted(this, comparator);
if (containingShadow->ShadowDescendants()[0] != this) {
// Only the first <shadow> (in tree order) of a ShadowRoot can be an insertion point.
return NS_OK;
}
if (IsInFallbackContent(this)) {
// If the first shadow element in tree order is invalid (in fallback content),
// the containing ShadowRoot will not have a shadow insertion point.
containingShadow->SetShadowElement(nullptr);
} else {
mIsInsertionPoint = true;
containingShadow->SetShadowElement(this);
}
containingShadow->SetInsertionPointChanged();
}
if (mIsInsertionPoint && containingShadow) {
// Propagate BindToTree calls to projected shadow root children.
ShadowRoot* projectedShadow = containingShadow->GetOlderShadowRoot();
if (projectedShadow) {
projectedShadow->SetIsComposedDocParticipant(IsInComposedDoc());
for (nsIContent* child = projectedShadow->GetFirstChild(); child;
child = child->GetNextSibling()) {
rv = child->BindToTree(nullptr, projectedShadow,
projectedShadow->GetBindingParent(),
aCompileEventHandlers);
NS_ENSURE_SUCCESS(rv, rv);
}
}
}
return NS_OK;
}
void
HTMLShadowElement::UnbindFromTree(bool aDeep, bool aNullParent)
{
RefPtr<ShadowRoot> oldContainingShadow = GetContainingShadow();
if (mIsInsertionPoint && oldContainingShadow) {
// Propagate UnbindFromTree call to previous projected shadow
// root children.
ShadowRoot* projectedShadow = oldContainingShadow->GetOlderShadowRoot();
if (projectedShadow) {
for (nsIContent* child = projectedShadow->GetFirstChild(); child;
child = child->GetNextSibling()) {
child->UnbindFromTree(true, false);
}
projectedShadow->SetIsComposedDocParticipant(false);
}
}
nsGenericHTMLElement::UnbindFromTree(aDeep, aNullParent);
if (oldContainingShadow && !GetContainingShadow() && mIsInsertionPoint) {
nsTArray<HTMLShadowElement*>& shadowDescendants =
oldContainingShadow->ShadowDescendants();
shadowDescendants.RemoveElement(this);
oldContainingShadow->SetShadowElement(nullptr);
// Find the next shadow insertion point.
if (shadowDescendants.Length() > 0 &&
!IsInFallbackContent(shadowDescendants[0])) {
oldContainingShadow->SetShadowElement(shadowDescendants[0]);
}
oldContainingShadow->SetInsertionPointChanged();
mIsInsertionPoint = false;
}
}
void
HTMLShadowElement::DistributeSingleNode(nsIContent* aContent)
{
if (aContent->DestInsertionPoints().Contains(this)) {
// Node has already been distrbuted this this node,
// we are done.
return;
}
aContent->DestInsertionPoints().AppendElement(this);
// Handle the case where the shadow element is a child of
// a node with a ShadowRoot. The nodes that have been distributed to
// this shadow insertion point will need to be reprojected into the
// insertion points of the parent's ShadowRoot.
ShadowRoot* parentShadowRoot = GetParent()->GetShadowRoot();
if (parentShadowRoot) {
parentShadowRoot->DistributeSingleNode(aContent);
return;
}
// Handle the case where the parent of this shadow element is a ShadowRoot
// that is projected into a shadow insertion point in the younger ShadowRoot.
ShadowRoot* containingShadow = GetContainingShadow();
ShadowRoot* youngerShadow = containingShadow->GetYoungerShadowRoot();
if (youngerShadow && GetParent() == containingShadow) {
HTMLShadowElement* youngerShadowElement = youngerShadow->GetShadowElement();
if (youngerShadowElement) {
youngerShadowElement->DistributeSingleNode(aContent);
}
}
}
void
HTMLShadowElement::RemoveDistributedNode(nsIContent* aContent)
{
ShadowRoot::RemoveDestInsertionPoint(this, aContent->DestInsertionPoints());
// Handle the case where the shadow element is a child of
// a node with a ShadowRoot. The nodes that have been distributed to
// this shadow insertion point will need to be removed from the
// insertion points of the parent's ShadowRoot.
ShadowRoot* parentShadowRoot = GetParent()->GetShadowRoot();
if (parentShadowRoot) {
parentShadowRoot->RemoveDistributedNode(aContent);
return;
}
// Handle the case where the parent of this shadow element is a ShadowRoot
// that is projected into a shadow insertion point in the younger ShadowRoot.
ShadowRoot* containingShadow = GetContainingShadow();
ShadowRoot* youngerShadow = containingShadow->GetYoungerShadowRoot();
if (youngerShadow && GetParent() == containingShadow) {
HTMLShadowElement* youngerShadowElement = youngerShadow->GetShadowElement();
if (youngerShadowElement) {
youngerShadowElement->RemoveDistributedNode(aContent);
}
}
}
void
HTMLShadowElement::DistributeAllNodes()
{
// All the explicit children of the projected ShadowRoot are distributed
// into this shadow insertion point so update the destination insertion
// points.
ShadowRoot* containingShadow = GetContainingShadow();
ShadowRoot* olderShadow = containingShadow->GetOlderShadowRoot();
if (olderShadow) {
ExplicitChildIterator childIterator(olderShadow);
for (nsIContent* content = childIterator.GetNextChild();
content;
content = childIterator.GetNextChild()) {
ShadowRoot::RemoveDestInsertionPoint(this, content->DestInsertionPoints());
content->DestInsertionPoints().AppendElement(this);
}
}
// Handle the case where the shadow element is a child of
// a node with a ShadowRoot. The nodes that have been distributed to
// this shadow insertion point will need to be reprojected into the
// insertion points of the parent's ShadowRoot.
ShadowRoot* parentShadowRoot = GetParent()->GetShadowRoot();
if (parentShadowRoot) {
parentShadowRoot->DistributeAllNodes();
return;
}
// Handle the case where the parent of this shadow element is a ShadowRoot
// that is projected into a shadow insertion point in the younger ShadowRoot.
ShadowRoot* youngerShadow = containingShadow->GetYoungerShadowRoot();
if (youngerShadow && GetParent() == containingShadow) {
HTMLShadowElement* youngerShadowElement = youngerShadow->GetShadowElement();
if (youngerShadowElement) {
youngerShadowElement->DistributeAllNodes();
}
}
}
void
HTMLShadowElement::ContentAppended(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aFirstNewContent,
int32_t aNewIndexInContainer)
{
// Watch for content appended to the projected shadow (the ShadowRoot that
// will be rendered in place of this shadow insertion point) because the
// nodes may need to be distributed into other insertion points.
nsIContent* currentChild = aFirstNewContent;
while (currentChild) {
if (ShadowRoot::IsPooledNode(currentChild, aContainer, mProjectedShadow)) {
DistributeSingleNode(currentChild);
}
currentChild = currentChild->GetNextSibling();
}
}
void
HTMLShadowElement::ContentInserted(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
int32_t aIndexInContainer)
{
// Watch for content appended to the projected shadow (the ShadowRoot that
// will be rendered in place of this shadow insertion point) because the
// nodes may need to be distributed into other insertion points.
if (!ShadowRoot::IsPooledNode(aChild, aContainer, mProjectedShadow)) {
return;
}
DistributeSingleNode(aChild);
}
void
HTMLShadowElement::ContentRemoved(nsIDocument* aDocument,
nsIContent* aContainer,
nsIContent* aChild,
int32_t aIndexInContainer,
nsIContent* aPreviousSibling)
{
// Watch for content removed from the projected shadow (the ShadowRoot that
// will be rendered in place of this shadow insertion point) because the
// nodes may need to be removed from other insertion points.
if (!ShadowRoot::IsPooledNode(aChild, aContainer, mProjectedShadow)) {
return;
}
RemoveDistributedNode(aChild);
}

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

@ -1,97 +0,0 @@
/* -*- 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/. */
#ifndef mozilla_dom_HTMLShadowElement_h__
#define mozilla_dom_HTMLShadowElement_h__
#include "nsGenericHTMLElement.h"
namespace mozilla {
namespace dom {
class HTMLShadowElement final : public nsGenericHTMLElement,
public nsStubMutationObserver
{
public:
explicit HTMLShadowElement(already_AddRefed<mozilla::dom::NodeInfo>& aNodeInfo);
// nsISupports
NS_DECL_ISUPPORTS_INHERITED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTAPPENDED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTINSERTED
NS_DECL_NSIMUTATIONOBSERVER_CONTENTREMOVED
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLShadowElement,
nsGenericHTMLElement)
static HTMLShadowElement* FromContent(nsIContent* aContent)
{
if (aContent->IsHTMLShadowElement()) {
return static_cast<HTMLShadowElement*>(aContent);
}
return nullptr;
}
virtual bool IsHTMLShadowElement() const override { return true; }
virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
bool aPreallocateChildren) const override;
virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent,
nsIContent* aBindingParent,
bool aCompileEventHandlers) override;
virtual void UnbindFromTree(bool aDeep = true,
bool aNullParent = true) override;
bool IsInsertionPoint() { return mIsInsertionPoint; }
/**
* Sets the ShadowRoot that will be rendered in place of
* this shadow insertion point.
*/
void SetProjectedShadow(ShadowRoot* aProjectedShadow);
/**
* Distributes a single explicit child of the projected ShadowRoot
* to relevant insertion points.
*/
void DistributeSingleNode(nsIContent* aContent);
/**
* Removes a single explicit child of the projected ShadowRoot
* from relevant insertion points.
*/
void RemoveDistributedNode(nsIContent* aContent);
/**
* Distributes all the explicit children of the projected ShadowRoot
* to the shadow insertion point in the younger ShadowRoot and
* the content insertion point of the parent node's ShadowRoot.
*/
void DistributeAllNodes();
// WebIDL methods.
ShadowRoot* GetOlderShadowRoot() { return mProjectedShadow; }
protected:
virtual ~HTMLShadowElement();
virtual JSObject* WrapNode(JSContext *aCx, JS::Handle<JSObject*> aGivenProto) override;
// The ShadowRoot that will be rendered in place of this shadow insertion point.
RefPtr<ShadowRoot> mProjectedShadow;
bool mIsInsertionPoint;
};
} // namespace dom
} // namespace mozilla
#endif // mozilla_dom_HTMLShadowElement_h__

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

@ -95,7 +95,6 @@ EXPORTS.mozilla.dom += [
'HTMLProgressElement.h',
'HTMLScriptElement.h',
'HTMLSelectElement.h',
'HTMLShadowElement.h',
'HTMLSharedElement.h',
'HTMLSharedListElement.h',
'HTMLSourceElement.h',
@ -175,7 +174,6 @@ UNIFIED_SOURCES += [
'HTMLProgressElement.cpp',
'HTMLScriptElement.cpp',
'HTMLSelectElement.cpp',
'HTMLShadowElement.cpp',
'HTMLSharedElement.cpp',
'HTMLSharedListElement.cpp',
'HTMLSourceElement.cpp',

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

@ -1581,7 +1581,6 @@ NS_DECLARE_NS_NEW_HTML_ELEMENT(Pre)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Progress)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Script)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Select)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Shadow)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Source)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Span)
NS_DECLARE_NS_NEW_HTML_ELEMENT(Style)

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

@ -24,6 +24,7 @@
#include "nsServiceManagerUtils.h"
#include "nsSubDocumentFrame.h"
#include "nsXULElement.h"
#include "nsAttrValueOrString.h"
using namespace mozilla;
using namespace mozilla::dom;

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

@ -30,6 +30,7 @@
#include "mozilla/Logging.h"
#include "nsNodeUtils.h"
#include "nsIContent.h"
#include "mozilla/dom/CustomElementRegistry.h"
#include "mozilla/dom/Element.h"
#include "mozilla/Preferences.h"

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

@ -513,8 +513,6 @@ var interfaceNamesInGlobalScope =
"HTMLScriptElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLSelectElement",
// IMPORTANT: Do not change this list without review from a DOM peer!
{name: "HTMLShadowElement", stylo: false},
// IMPORTANT: Do not change this list without review from a DOM peer!
"HTMLSourceElement",
// IMPORTANT: Do not change this list without review from a DOM peer!

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

@ -33,8 +33,6 @@ support-files =
skip-if = stylo # bug 1293844
[test_dest_insertion_points.html]
skip-if = stylo # bug 1293844
[test_dest_insertion_points_shadow.html]
skip-if = stylo # bug 1293844
[test_fallback_dest_insertion_points.html]
skip-if = stylo # bug 1293844
[test_detached_style.html]
@ -53,8 +51,6 @@ skip-if = true # disabled - See bug 1390396
[test_document_register_stack.html]
skip-if = true # disabled - See bug 1390396
[test_document_shared_registry.html]
[test_event_dispatch.html]
skip-if = stylo # bug 1293844
[test_event_retarget.html]
skip-if = stylo # bug 1293844
[test_event_stopping.html]
@ -66,16 +62,10 @@ skip-if = stylo # bug 1293844
skip-if = stylo # bug 1293844
[test_shadowroot_inert_element.html]
skip-if = stylo # bug 1293844
[test_shadowroot_host.html]
skip-if = stylo # bug 1293844
[test_shadowroot_style.html]
skip-if = stylo # bug 1293844
[test_shadowroot_style_multiple_shadow.html]
skip-if = stylo # bug 1293844
[test_shadowroot_style_order.html]
skip-if = stylo # bug 1293844
[test_shadowroot_youngershadowroot.html]
skip-if = stylo # bug 1293844
[test_style_fallback_content.html]
skip-if = stylo # bug 1293844
[test_unresolved_pseudo_class.html]

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

@ -1,68 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=999999
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 999999</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=999999">Mozilla Bug 999999</a>
<p id="display"></p>
<div id="content">
<div id="shadowhost"></div>
</div>
<pre id="test">
</pre>
<script type="application/javascript">
/** Test for Bug 999999 **/
var host = document.getElementById("shadowhost");
// Test destination insertion points of node distributed to shadow element.
var olderShadowRoot = host.createShadowRoot();
var youngerShadowRoot = host.createShadowRoot();
var shadowElem = document.createElement("shadow");
youngerShadowRoot.appendChild(shadowElem);
var span = document.createElement("span");
olderShadowRoot.appendChild(span);
is(span.getDestinationInsertionPoints().length, 1, "Child of ShadowRoot should be distributed to shadow insertion point.");
is(span.getDestinationInsertionPoints()[0], shadowElem, "Shadow element should be in destination insertion point list.");
// Test destination insertion points of node removed from tree.
olderShadowRoot.removeChild(span);
is(span.getDestinationInsertionPoints().length, 0, "Node removed from tree should no longer be distributed.");
// Test destination insertion points of fallback content being reprojected into a shadow element.
var content = document.createElement("content");
var fallback = document.createElement("span");
content.appendChild(fallback);
olderShadowRoot.appendChild(content);
is(fallback.getDestinationInsertionPoints().length, 2, "The fallback content should have 2 destination insertion points, the parent content and the shadow element to which it is reprojected.");
is(fallback.getDestinationInsertionPoints()[0], content, "First destination of the fallback content should be the parent content element.");
is(fallback.getDestinationInsertionPoints()[1], shadowElem, "Second destination of the fallback content should be the shadow element to which the element is reprojected.");
// Test destination insertion points of fallback content being removed from tree.
content.removeChild(fallback);
is(fallback.getDestinationInsertionPoints().length, 0, "The content should no longer be distributed to any nodes because it is no longer fallback content.");
// Test destination insertion points of distributed content after removing shadow insertion point.
var div = document.createElement("div");
olderShadowRoot.appendChild(div);
is(div.getDestinationInsertionPoints().length, 1, "Children in older shadow root should be distributed to shadow insertion point.");
is(div.getDestinationInsertionPoints()[0], shadowElem, "Destination insertion point should include shadow element.");
youngerShadowRoot.removeChild(shadowElem);
is(div.getDestinationInsertionPoints().length, 0, "Destination insertion points should be empty after removing shadow element.");
</script>
</body>
</html>

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

@ -1,458 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=887541
-->
<head>
<title>Test for event model in web components</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=887541">Bug 887541</a>
<script>
var els = SpecialPowers.Cc["@mozilla.org/eventlistenerservice;1"]
.getService(SpecialPowers.Ci.nsIEventListenerService);
function eventListener(e) {
eventChain.push(this);
}
function isEventChain(actual, expected, msg) {
is(actual.length, expected.length, msg);
for (var i = 0; i < expected.length; i++) {
is(actual[i], expected[i], msg + " at " + i);
}
// Check to make sure the event chain matches what we get back from nsIEventListenerService.getEventTargetChainFor
if (0 < actual.length) {
var chain = els.getEventTargetChainFor(actual[0], true); // Events should be dispatched on actual[0].
for (var i = 0; i < expected.length; i++) {
ok(SpecialPowers.compare(chain[i], expected[i]), msg + " at " + i + " for nsIEventListenerService");
}
}
}
/*
* Test 1: Test of event dispatch through a basic ShadowRoot with content a insertion point.
*
* <div elemOne> ------ <shadow-root shadowOne>
* | |
* <div elemTwo> <span elemThree>
* |
* <content elemFour>
*/
var elemOne = document.createElement("div");
elemOne.addEventListener("custom", eventListener);
var elemTwo = document.createElement("div");
elemTwo.addEventListener("custom", eventListener);
var elemThree = document.createElement("span");
elemThree.addEventListener("custom", eventListener);
var elemFour = document.createElement("content");
elemFour.addEventListener("custom", eventListener);
var shadowOne = elemOne.createShadowRoot();
shadowOne.addEventListener("custom", eventListener);
elemThree.appendChild(elemFour);
shadowOne.appendChild(elemThree);
elemOne.appendChild(elemTwo);
var eventChain = [];
var customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemTwo.dispatchEvent(customEvent);
isEventChain(eventChain, [elemTwo, elemFour, elemThree, shadowOne, elemOne], "Event path for test 1 for event dispatched on elemTwo.");
/*
* Test 2: Test of event dispatch through a nested ShadowRoots with content insertion points.
*
* <div elemFive> --- <shadow-root shadowTwo>
* | |
* <div elemOne> <div elemFour> ----- <shadow-root shadowOne>
* | |
* <content elemTwo> <p elemSix>
* |
* <content elemThree>
*/
elemOne = document.createElement("div");
elemOne.addEventListener("custom", eventListener);
elemTwo = document.createElement("content");
elemTwo.addEventListener("custom", eventListener);
elemThree = document.createElement("content");
elemThree.addEventListener("custom", eventListener);
var elemFour = document.createElement("div");
elemFour.addEventListener("custom", eventListener);
var elemFive = document.createElement("div");
elemFive.addEventListener("custom", eventListener);
var elemSix = document.createElement("p");
elemSix.addEventListener("custom", eventListener);
var shadowOne = elemFour.createShadowRoot();
shadowOne.addEventListener("custom", eventListener);
var shadowTwo = elemFive.createShadowRoot();
shadowTwo.addEventListener("custom", eventListener);
elemFive.appendChild(elemOne);
shadowTwo.appendChild(elemFour);
elemFour.appendChild(elemTwo);
shadowOne.appendChild(elemSix);
elemSix.appendChild(elemThree);
eventChain = [];
customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemOne.dispatchEvent(customEvent);
is(elemOne.getDestinationInsertionPoints().length, 2, "yes");
isEventChain(eventChain, [elemOne, elemThree, elemSix, shadowOne, elemTwo, elemFour, shadowTwo, elemFive], "Event path for test 2 for event dispatched on elemOne.");
/*
* Test 3: Test of event dispatch through nested ShadowRoot with content insertion points.
*
* <div elemOne> ------- <shadow-root shadowOne>
* | |
* <span elemTwo> <span elemThree> ------------ <shadow-root shadowTwo>
* | |
* <span elemFour> <content elemSix>
* |
* <content elemFive>
*/
elemOne = document.createElement("div");
elemOne.addEventListener("custom", eventListener);
elemTwo = document.createElement("span");
elemTwo.addEventListener("custom", eventListener);
elemThree = document.createElement("span");
elemThree.addEventListener("custom", eventListener);
elemFour = document.createElement("span");
elemFour.addEventListener("custom", eventListener);
elemFive = document.createElement("content");
elemFive.addEventListener("custom", eventListener);
elemSix = document.createElement("content");
elemSix.addEventListener("custom", eventListener);
shadowOne = elemOne.createShadowRoot();
shadowOne.addEventListener("custom", eventListener);
shadowTwo = elemThree.createShadowRoot();
shadowTwo.addEventListener("custom", eventListener);
elemOne.appendChild(elemTwo);
shadowOne.appendChild(elemThree);
elemThree.appendChild(elemFour);
elemFour.appendChild(elemFive);
shadowTwo.appendChild(elemSix);
eventChain = [];
customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemTwo.dispatchEvent(customEvent);
isEventChain(eventChain, [elemTwo, elemFive, elemFour, elemSix, shadowTwo, elemThree, shadowOne, elemOne], "Event path for test 3 for event dispatched on elemTwo.");
/*
* Test 4: Test of event dispatch through host with multiple ShadowRoots with shadow insertion point.
*
* <div elemSeven> --- <shadow-root shadowTwo> (younger ShadowRoot)
* | | |
* <div elemOne> | <div elemSix> -------- <shadow-root shadowOne>
* | | |
* | <shadow elemFour> <content elemFive>
* | |
* | <content elemTwo>
* |
* --- <shadow-root shadowThree> (older ShadowRoot)
* | |
* | <content elemThree>
* |
* <div elemEight>
*/
elemOne = document.createElement("div");
elemOne.addEventListener("custom", eventListener);
elemTwo = document.createElement("content");
elemTwo.addEventListener("custom", eventListener);
elemThree = document.createElement("content");
elemThree.addEventListener("custom", eventListener);
elemFour = document.createElement("shadow");
elemFour.addEventListener("custom", eventListener);
elemFive = document.createElement("content");
elemFive.addEventListener("custom", eventListener);
elemSix = document.createElement("div");
elemSix.addEventListener("custom", eventListener);
var elemSeven = document.createElement("div");
elemSeven.addEventListener("custom", eventListener);
var elemEight = document.createElement("div");
elemEight.addEventListener("custom", eventListener);
var shadowThree = elemSeven.createShadowRoot();
shadowThree.addEventListener("custom", eventListener);
shadowTwo = elemSeven.createShadowRoot();
shadowTwo.addEventListener("custom", eventListener);
shadowOne = elemSix.createShadowRoot();
shadowOne.addEventListener("custom", eventListener);
elemSeven.appendChild(elemOne);
shadowTwo.appendChild(elemSix);
elemSix.appendChild(elemFour);
elemFour.appendChild(elemTwo);
shadowThree.appendChild(elemEight);
shadowThree.appendChild(elemThree);
shadowOne.appendChild(elemFive);
eventChain = [];
customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemOne.dispatchEvent(customEvent);
isEventChain(eventChain, [elemOne, elemFive, shadowOne, elemThree, shadowThree, elemTwo, elemFour, elemSix, shadowTwo, elemSeven], "Event path for test 4 for event dispatched on elemOne.");
eventChain = [];
customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemEight.dispatchEvent(customEvent);
isEventChain(eventChain, [elemEight, elemFive, shadowOne, elemSix, shadowTwo, elemSeven], "Event path for test 4 for event dispatched on elemEight.");
/*
* Test 5: Test of event dispatch through nested shadowroot with insertion points that match specific tags.
*
* <div elemOne> --------- <shadow-root shadowOne>
* | | |
* | <p elemThree> <span elemFour> ------------------------ <shadow-root shadowTwo>
* | | | |
* <span elemTwo> | <content select="p" elemFive> <content elemSeven>
* |
* <content select="span" elemSix>
*/
elemOne = document.createElement("div");
elemOne.addEventListener("custom", eventListener);
elemTwo = document.createElement("span");
elemTwo.addEventListener("custom", eventListener);
elemThree = document.createElement("p");
elemThree.addEventListener("custom", eventListener);
elemFour = document.createElement("span");
elemFour.addEventListener("custom", eventListener);
elemFive = document.createElement("content");
elemFive.select = "p";
elemFive.addEventListener("custom", eventListener);
elemSix = document.createElement("content");
elemSix.select = "span";
elemSix.addEventListener("custom", eventListener);
elemSeven = document.createElement("content");
elemSeven.addEventListener("custom", eventListener);
shadowTwo = elemFour.createShadowRoot();
shadowTwo.addEventListener("custom", eventListener);
shadowOne = elemOne.createShadowRoot();
shadowOne.addEventListener("custom", eventListener);
elemOne.appendChild(elemTwo);
elemOne.appendChild(elemThree);
shadowOne.appendChild(elemFour);
elemFour.appendChild(elemSix);
elemFour.appendChild(elemFive);
shadowTwo.appendChild(elemSeven);
eventChain = [];
customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemTwo.dispatchEvent(customEvent);
isEventChain(eventChain, [elemTwo, elemSeven, shadowTwo, elemSix, elemFour, shadowOne, elemOne], "Event path for test 5 for event dispatched on elemTwo.");
eventChain = [];
customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemThree.dispatchEvent(customEvent);
isEventChain(eventChain, [elemThree, elemSeven, shadowTwo, elemFive, elemFour, shadowOne, elemOne], "Event path for test 5 for event dispatched on elemThree.");
/*
* Test 6: Test of event dispatch through nested shadowroot with insertion points that match specific tags.
*
* <div elemOne> --------- <shadow-root shadowOne>;
* | | |
* | <p elemThree> <span elemFour> ------ <shadow-root shadowTwo>
* | | | |
* <span elemTwo> <content elemFive> | <content select="p" elemSeven>
* |
* <content select="span" elemSix>
*/
elemOne = document.createElement("div");
elemOne.addEventListener("custom", eventListener);
elemTwo = document.createElement("span");
elemTwo.addEventListener("custom", eventListener);
elemThree = document.createElement("p");
elemThree.addEventListener("custom", eventListener);
elemFour = document.createElement("span");
elemFour.addEventListener("custom", eventListener);
elemFive = document.createElement("content");
elemFive.addEventListener("custom", eventListener);
elemSix = document.createElement("content");
elemSix.select = "span";
elemSix.addEventListener("custom", eventListener);
elemSeven = document.createElement("content");
elemSeven.select = "p";
elemSeven.addEventListener("custom", eventListener);
shadowTwo = elemFour.createShadowRoot();
shadowTwo.addEventListener("custom", eventListener);
shadowOne = elemOne.createShadowRoot();
shadowOne.addEventListener("custom", eventListener);
elemOne.appendChild(elemTwo);
elemOne.appendChild(elemThree);
shadowOne.appendChild(elemFour);
elemFour.appendChild(elemFive);
shadowTwo.appendChild(elemSix);
shadowTwo.appendChild(elemSeven);
eventChain = [];
customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemTwo.dispatchEvent(customEvent);
isEventChain(eventChain, [elemTwo, elemSix, shadowTwo, elemFive, elemFour, shadowOne, elemOne], "Event path for test 6 for event dispatched on elemTwo.");
eventChain = [];
customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemThree.dispatchEvent(customEvent);
isEventChain(eventChain, [elemThree, elemSeven, shadowTwo, elemFive, elemFour, shadowOne, elemOne], "Event path for test 6 for event dispatched on elemThree.");
/*
* Test 7: Test of event dispatch through nested shadowroot with insertion points that match specific tags.
*
* <div elemOne> --------- <shadow-root shadowOne>
* | | |
* | <p elemThree> <span elemFour> ------ <shadow-root shadowTwo>
* | | |
* <span elemTwo> <content elemFive> <span elemEight>
* | |
* | <content select="p" elemSeven>
* |
* <content select="span" elemSix>
*/
elemOne = document.createElement("div");
elemOne.addEventListener("custom", eventListener);
elemTwo = document.createElement("span");
elemTwo.addEventListener("custom", eventListener);
elemThree = document.createElement("p");
elemThree.addEventListener("custom", eventListener);
elemFour = document.createElement("span");
elemFour.addEventListener("custom", eventListener);
elemFive = document.createElement("content");
elemFive.addEventListener("custom", eventListener);
elemSix = document.createElement("content");
elemSix.select = "span";
elemSix.addEventListener("custom", eventListener);
elemSeven = document.createElement("content");
elemSeven.select = "p";
elemSeven.addEventListener("custom", eventListener);
elemEight = document.createElement("span");
elemEight.addEventListener("custom", eventListener);
shadowTwo = elemFour.createShadowRoot();
shadowTwo.addEventListener("custom", eventListener);
shadowOne = elemOne.createShadowRoot();
shadowOne.addEventListener("custom", eventListener);
elemOne.appendChild(elemTwo);
elemOne.appendChild(elemThree);
shadowOne.appendChild(elemFour);
elemFour.appendChild(elemFive);
shadowTwo.appendChild(elemEight);
elemEight.appendChild(elemSix);
elemEight.appendChild(elemSeven);
eventChain = [];
customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemTwo.dispatchEvent(customEvent);
isEventChain(eventChain, [elemTwo, elemSix, elemEight, shadowTwo, elemFive, elemFour, shadowOne, elemOne], "Event path for test 7 for event dispatched on elemTwo.");
eventChain = [];
customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemThree.dispatchEvent(customEvent);
isEventChain(eventChain, [elemThree, elemSeven, elemEight, shadowTwo, elemFive, elemFour, shadowOne, elemOne], "Event path for test 7 for event dispatched on elemThree.");
/*
* Test 8: Test of event dispatch through host with multiple ShadowRoots with shadow insertion point.
*
* <div elemOne> --- <shadow-root shadowOne> (younger ShadowRoot)
* | |
* | <div elemFour>
* | |
* | <shadow elemTwo>
* |
* --- <shadow-root shadowTwo> (older ShadowRoot)
* |
* <div elemThree>
*/
elemOne = document.createElement("div");
elemOne.addEventListener("custom", eventListener);
elemTwo = document.createElement("shadow");
elemTwo.addEventListener("custom", eventListener);
elemThree = document.createElement("div");
elemThree.addEventListener("custom", eventListener);
elemFour = document.createElement("div");
elemFour.addEventListener("custom", eventListener);
shadowTwo = elemOne.createShadowRoot();
shadowTwo.addEventListener("custom", eventListener);
shadowOne = elemOne.createShadowRoot();
shadowOne.addEventListener("custom", eventListener);
shadowOne.appendChild(elemFour);
elemFour.appendChild(elemTwo);
shadowTwo.appendChild(elemThree);
eventChain = [];
customEvent = new CustomEvent("custom", { "bubbles" : true, "composed" : true });
elemThree.dispatchEvent(customEvent);
isEventChain(eventChain, [elemThree, shadowTwo, elemTwo, elemFour, shadowOne, elemOne], "Event path for test 8 for event dispatched on elemThree.");
</script>
</body>
</html>

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

@ -1,41 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1083587
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1083587</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1083587">Mozilla Bug 1083587</a>
<p id="display"></p>
<div id="content" style="display: none">
<div id="host"></div>
</div>
<pre id="test">
</pre>
<script type="application/javascript">
/** Test for Bug 1083587 **/
var hostInDoc = document.getElementById("host");
var shadowOne = hostInDoc.createShadowRoot();
is(shadowOne.host, hostInDoc);
var shadowTwo = hostInDoc.createShadowRoot();
is(shadowOne.host, hostInDoc);
is(shadowTwo.host, hostInDoc);
var hostNotInDoc = document.createElement("div");
var shadowThree = hostNotInDoc.createShadowRoot();
is(shadowThree.host, hostNotInDoc);
var shadowFour = hostNotInDoc.createShadowRoot();
is(shadowThree.host, hostNotInDoc);
is(shadowFour.host, hostNotInDoc);
</script>
</body>
</html>

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

@ -1,57 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=806506
-->
<head>
<title>Test for ShadowRoot styles with multiple ShadowRoot on host.</title>
<script type="text/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" />
</head>
<body>
<div class="tall" id="bodydiv"></div>
<div id="container"></div>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=806506">Bug 806506</a>
<script>
// Create ShadowRoot.
var container = document.getElementById("container");
var elem = document.createElement("div");
container.appendChild(elem); // Put ShadowRoot host in document.
var firstRoot = elem.createShadowRoot();
var secondRoot = elem.createShadowRoot();
var thirdRoot = elem.createShadowRoot();
// A style element that will be appended into the ShadowRoot.
var firstStyle = document.createElement("style");
firstRoot.appendChild(firstStyle);
is(firstRoot.styleSheets.length, 1, "firstStyle should be the only style in firstRoot.");
is(firstRoot.styleSheets[0].ownerNode, firstStyle, "firstStyle should in the ShadowRoot styleSheets.");
var secondStyle = document.createElement("style");
secondRoot.appendChild(secondStyle);
is(secondRoot.styleSheets.length, 1, "secondStyle should be the only style in secondRoot.");
is(secondRoot.styleSheets[0].ownerNode, secondStyle, "secondStyle should in the ShadowRoot styleSheets.");
var thirdStyle = document.createElement("style");
thirdRoot.appendChild(thirdStyle);
is(thirdRoot.styleSheets.length, 1, "thirdStyle should be the only style in thirdRoot.");
is(thirdRoot.styleSheets[0].ownerNode, thirdStyle, "thirdStyle should in the ShadowRoot styleSheets.");
// Check the stylesheet counts again to make sure that none of the style sheets leaked into the older ShadowRoots.
is(firstRoot.styleSheets.length, 1, "Adding a stylesheet to a younger ShadowRoot should not affect stylesheets in the older ShadowRoot.");
is(secondRoot.styleSheets.length, 1, "Adding a stylesheet to a younger ShadowRoot should not affect stylesheets in the older ShadowRoot.");
// Remove styles and make sure they are removed from the correct ShadowRoot.
firstRoot.removeChild(firstStyle);
is(firstRoot.styleSheets.length, 0, "firstRoot should no longer have any styles.");
thirdRoot.removeChild(thirdStyle);
is(thirdRoot.styleSheets.length, 0, "thirdRoot should no longer have any styles.");
secondRoot.removeChild(secondStyle);
is(secondRoot.styleSheets.length, 0, "secondRoot should no longer have any styles.");
</script>
</body>
</html>

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

@ -1,41 +0,0 @@
<!DOCTYPE HTML>
<html>
<!--
https://bugzilla.mozilla.org/show_bug.cgi?id=1083587
-->
<head>
<meta charset="utf-8">
<title>Test for Bug 1083587</title>
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
</head>
<body>
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1083587">Mozilla Bug 1083587</a>
<p id="display"></p>
<div id="content" style="display: none">
<div id="host"></div>
</div>
<pre id="test">
</pre>
<script type="application/javascript">
/** Test for Bug 1083587 **/
var hostInDoc = document.getElementById("host");
var shadowOne = hostInDoc.createShadowRoot();
is(shadowOne.olderShadowRoot, null);
var shadowTwo = hostInDoc.createShadowRoot();
is(shadowOne.olderShadowRoot, null);
is(shadowTwo.olderShadowRoot, shadowOne);
var hostNotInDoc = document.createElement("div");
var shadowThree = hostNotInDoc.createShadowRoot();
is(shadowThree.olderShadowRoot, null);
var shadowFour = hostNotInDoc.createShadowRoot();
is(shadowThree.olderShadowRoot, null);
is(shadowFour.olderShadowRoot, shadowThree);
</script>
</body>
</html>

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

@ -1,19 +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://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html
*
* © Copyright 2004-2011 Apple Computer, Inc., Mozilla Foundation, and
* Opera Software ASA. You are granted a license to use, reproduce
* and create derivative works of this document.
*/
[Func="nsDocument::IsWebComponentsEnabled"]
interface HTMLShadowElement : HTMLElement
{
readonly attribute ShadowRoot? olderShadowRoot;
};

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

@ -20,7 +20,6 @@ interface ShadowRoot : DocumentFragment
[CEReactions, SetterThrows, TreatNullAs=EmptyString]
attribute DOMString innerHTML;
readonly attribute Element host;
readonly attribute ShadowRoot? olderShadowRoot;
attribute boolean applyAuthorStyles;
readonly attribute StyleSheetList styleSheets;
};

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

@ -616,7 +616,6 @@ WEBIDL_FILES = [
'HTMLQuoteElement.webidl',
'HTMLScriptElement.webidl',
'HTMLSelectElement.webidl',
'HTMLShadowElement.webidl',
'HTMLSourceElement.webidl',
'HTMLSpanElement.webidl',
'HTMLStyleElement.webidl',

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

@ -720,7 +720,6 @@ static const ElementInfo kElements[eHTMLTag_userdefined] = {
GROUP_LEAF),
ELEM(section, true, true, GROUP_BLOCK, GROUP_FLOW_ELEMENT),
ELEM(select, true, false, GROUP_FORMCONTROL, GROUP_SELECT_CONTENT),
ELEM(shadow, true, false, GROUP_NONE, GROUP_INLINE_ELEMENT),
ELEM(small, true, true, GROUP_FONTSTYLE, GROUP_INLINE_ELEMENT),
ELEM(source, false, false, GROUP_PICTURE_CONTENT, GROUP_NONE),
ELEM(span, true, true, GROUP_SPECIAL, GROUP_INLINE_ELEMENT),

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

@ -45,8 +45,6 @@ span { color:blue; }
<span style="color:green">R</span>
<div></div>
<b style="color:green">V</b>
<b style="color:green">W</b>
<b style="color:green">X</b>
<!-- <b style="color:green">Y</b> -->
</body>
</html>

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

@ -51,8 +51,6 @@ div.after::after {content: " Y";}
<div id="hostT" class="c">T</div>
<div id="hostU"><span class="c">U</span></div>
<div id="hostV" class="c" style="color:red"><b class="c" style="color:inherit">V</b></div>
<div id="hostW" class="c" style="color:red"><b class="c" style="color:inherit">W</b></div>
<span id="hostX" style="color:red"><b class="c" style="color:inherit">X</b></span>
<!-- TODO(bug 1021572?) <div id="hostY" class="c" style="color:red"><b>Y</b></div> -->
<script>
@ -106,8 +104,6 @@ div.after::after {content: " Y";}
shadow("hostP").innerHTML = '<content select="b"></content><content select="i"></content>';
shadow("hostQ").innerHTML = '<content select="b"></content><content select="i"></content>';
shadow("hostR").innerHTML = '<content select="span"></content>';
shadow("hostW").innerHTML = '<z style="color:red"><content select="b"></content></z>';
shadow("hostX").innerHTML = '<z style="color:red"><content select="b"></content></z>';
// TODO(bug 1021572?) shadow("hostY").innerHTML = '<content select="b"><style scoped>:scope{color:green}</style></content>';
}
@ -224,8 +220,6 @@ div.after::after {content: " Y";}
shadow("hostT");
shadow("hostU");
shadow("hostV").innerHTML = '<z style="color:green"><content select="b"></content></z>';
shadow("hostW").innerHTML = '<z style="color:green"><content select="b"></content></z>';
shadow("hostX").innerHTML = '<z style="color:green"><content select="b"></content></z>';
document.body.offsetHeight;
document.documentElement.removeAttribute("class");

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

@ -1,6 +0,0 @@
<!DOCTYPE HTML>
<html>
<body>
<div><span>Hello</span><span>World</span></div>
</body>
</html>

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

@ -1,17 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<script>
function tweak() {
var oldShadowRoot = document.getElementById('outer').createShadowRoot();
oldShadowRoot.innerHTML = 'World';
var youngShadowRoot = document.getElementById('outer').createShadowRoot();
youngShadowRoot.innerHTML = 'Hello<content></content><shadow></shadow>';
}
</script>
</head>
<body onload="tweak()">
<div id="outer"></div>
</body>
</html>

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

@ -1,6 +0,0 @@
<!DOCTYPE HTML>
<html>
<body>
<div><span>Hello</span><span>World</span></div>
</body>
</html>

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

@ -1,17 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<script>
function tweak() {
var oldShadowRoot = document.getElementById('outer').createShadowRoot();
oldShadowRoot.innerHTML = 'Hello';
var youngShadowRoot = document.getElementById('outer').createShadowRoot();
youngShadowRoot.innerHTML = '<shadow></shadow><content></content>World';
}
</script>
</head>
<body onload="tweak()">
<div id="outer"></div>
</body>
</html>

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

@ -1,10 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div>
<div style="width:100px; height:100px; background-color:green"></div><div style="width:100px; height:100px; background-color:orange">Hello World</div>
</div>
</body>
</html>

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

@ -1,19 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<script>
function tweak() {
var olderShadow = document.getElementById('outer').createShadowRoot();
olderShadow.innerHTML = '<div style="width:100px; height:100px; background-color: orange"><content></content></div>';
var youngerShadow = document.getElementById('outer').createShadowRoot();
youngerShadow.innerHTML = '<div style="width:100px; height:100px; background-color: green"></div><shadow>Hello World</shadow>';
}
</script>
</head>
<body onload="tweak()">
<div id="outer">
<div style="width:300px; height:100px; background-color:red;"></div>
</div>
</body>
</html>

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

@ -1,10 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
</head>
<body>
<div>
<div style="background-color: green"><span>Hello</span><span> </span><span>World</span></div>
</div>
</body>
</html>

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

@ -1,29 +0,0 @@
<!DOCTYPE HTML>
<html>
<head>
<script>
function tweak() {
var olderShadow = document.getElementById('outer').createShadowRoot();
olderShadow.innerHTML = '<content></content><span>World</span>';
var youngerShadow = document.getElementById('outer').createShadowRoot();
youngerShadow.innerHTML = '<div id="shadowparent"><shadow id="youngshadow"><span>Hello</span></shadow></div>';
var shadowParent = youngerShadow.getElementById("shadowparent");
var nestedShadow = shadowParent.createShadowRoot();
nestedShadow.innerHTML = '<div style="background-color: green"><content></content></div>';
// Dynamically append a span to the shadow element in the younger ShadowRoot to make sure
// it is projected into the nested shadow.
var appendedSpan = document.createElement("span");
appendedSpan.textContent = ' ';
youngerShadow.getElementById("youngshadow").appendChild(appendedSpan);
}
</script>
</head>
<body onload="tweak()">
<div id="outer">
<div style="width:300px; height:100px; background-color:red;"></div>
</div>
</body>
</html>

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

@ -5,13 +5,9 @@ pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == basic-shad
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == basic-shadow-4.html basic-shadow-4-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == basic-insertion-point-1.html basic-insertion-point-1-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == basic-insertion-point-2.html basic-insertion-point-2-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == adjacent-insertion-points-1.html adjacent-insertion-points-1-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == adjacent-insertion-points-2.html adjacent-insertion-points-2-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == fallback-content-1.html fallback-content-1-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == remove-insertion-point-1.html remove-insertion-point-1-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == nested-insertion-point-1.html nested-insertion-point-1-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == basic-shadow-element-1.html basic-shadow-element-1-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == nested-shadow-element-1.html nested-shadow-element-1-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == update-dist-node-descendants-1.html update-dist-node-descendants-1-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) fuzzy-if(Android,2,7) == input-transition-1.html input-transition-1-ref.html
pref(dom.webcomponents.enabled,true) fails-if(stylo||styloVsGecko) == dynamic-insertion-point-distribution-1.html dynamic-insertion-point-distribution-1-ref.html

Разница между файлами не показана из-за своего большого размера Загрузить разницу

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

@ -284,7 +284,6 @@ nsHtml5ElementName* nsHtml5ElementName::ELT_TFOOT = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_TEXT = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_MENU = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_FEDROPSHADOW = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_SHADOW = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_VIEW = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_FECOLORMATRIX = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_FECONVOLVEMATRIX = nullptr;
@ -295,27 +294,27 @@ nsHtml5ElementName* nsHtml5ElementName::ELT_SUMMARY = nullptr;
nsHtml5ElementName* nsHtml5ElementName::ELT_TBODY = nullptr;
nsHtml5ElementName** nsHtml5ElementName::ELEMENT_NAMES = 0;
static int32_t const ELEMENT_HASHES_DATA[] = {
1902641154, 1749395095, 2001349720, 893386754, 1803876550, 1971938532,
2007781534, 59821379, 1732381397, 1756600614, 1870135298, 1939219752,
1990037800, 2005324101, 2060065124, 55104723, 62450211, 1686489160,
1902641154, 1749395095, 2001349704, 893386754, 1803876550, 1971465813,
2007601444, 59821379, 1732381397, 1756600614, 1870135298, 1939219752,
1988763672, 2004635806, 2060065124, 55104723, 62450211, 1686489160,
1747048757, 1749932347, 1782357526, 1818755074, 1881669634, 1907959605,
1967760215, 1983533124, 1999917383, 2001392798, 2006329158, 2008994116,
1967760215, 1982935782, 1999397992, 2001392796, 2006028454, 2008851557,
2085266636, 52485715, 57733651, 60354131, 67633153, 960495618,
1703936002, 1736200310, 1747838298, 1749723735, 1753362711, 1757157700,
1786534215, 1805647874, 1854245076, 1874102998, 1898223949, 1906087319,
1932928296, 1965115924, 1968053806, 1982173479, 1986527234, 1998724870,
2001309869, 2001392795, 2003183333, 2005925890, 2006974466, 2008340774,
2051837468, 2068523856, 2092255447, 51438659, 52488851, 56151587,
1932928296, 1965115924, 1968053806, 1973420034, 1983633431, 1998585858,
2000525512, 2001349736, 2001495140, 2005719336, 2006896969, 2008125638,
2021937364, 2068523856, 2092255447, 51438659, 52488851, 56151587,
59244545, 60347747, 61925907, 63438849, 69730305, 926941186,
1681770564, 1689922072, 1730150402, 1733076167, 1738539010, 1747306711,
1748225318, 1749673195, 1749813541, 1751386406, 1755148615, 1757137429,
1763839627, 1783388497, 1797585096, 1803929861, 1807599880, 1854228692,
1864368130, 1873281026, 1881498736, 1887579800, 1899272519, 1904412884,
1907435316, 1919418370, 1935549734, 1941221172, 1966223078, 1967795910,
1971461414, 1973420034, 1982935782, 1983633431, 1988763672, 1998585858,
1999397992, 2000525512, 2001349704, 2001349736, 2001392796, 2001495140,
2004635806, 2005719336, 2006028454, 2006896969, 2007601444, 2008125638,
2008851557, 2021937364, 2058653206, 2068523853, 2083120164, 2091479332,
1971461414, 1971938532, 1982173479, 1983533124, 1986527234, 1990037800,
1998724870, 1999917383, 2001309869, 2001349720, 2001392795, 2001392798,
2003183333, 2005324101, 2005925890, 2006329158, 2006974466, 2007781534,
2008340774, 2008994116, 2051837468, 2068523853, 2083120164, 2091479332,
2092557349, 51434643, 51961587, 52486755, 52490899, 55110883,
57206291, 58773795, 59768833, 60345171, 60352339, 61395251,
62390273, 62973651, 67108865, 68681729, 876609538, 910163970,
@ -329,7 +328,7 @@ static int32_t const ELEMENT_HASHES_DATA[] = {
1881613047, 1884120164, 1889085973, 1898753862, 1900845386, 1903302038,
1905563974, 1906135367, 1907661127, 1914900309, 1925844629, 1934172497,
1938817026, 1941178676, 1963982850, 1965334268, 1967128578, 1967788867,
1967795958, 1968836118, 1971465813
1967795958, 1968836118
};
staticJArray<int32_t,int32_t> nsHtml5ElementName::ELEMENT_HASHES = { ELEMENT_HASHES_DATA, MOZ_ARRAY_LENGTH(ELEMENT_HASHES_DATA) };
void
@ -1458,11 +1457,6 @@ nsHtml5ElementName::initializeStatics()
NS_NewHTMLUnknownElement,
NS_NewSVGFEDropShadowElement,
nsHtml5TreeBuilder::OTHER);
ELT_SHADOW = new nsHtml5ElementName(nsGkAtoms::shadow,
nsGkAtoms::shadow,
NS_NewHTMLShadowElement,
NS_NewSVGUnknownElement,
nsHtml5TreeBuilder::OTHER);
ELT_VIEW = new nsHtml5ElementName(nsGkAtoms::view,
nsGkAtoms::view,
NS_NewHTMLUnknownElement,
@ -1511,21 +1505,21 @@ nsHtml5ElementName::initializeStatics()
NS_NewSVGUnknownElement,
nsHtml5TreeBuilder::TBODY_OR_THEAD_OR_TFOOT |
SPECIAL | FOSTER_PARENTING | OPTIONAL_END_TAG);
ELEMENT_NAMES = new nsHtml5ElementName*[207];
ELEMENT_NAMES = new nsHtml5ElementName*[206];
ELEMENT_NAMES[0] = ELT_MN;
ELEMENT_NAMES[1] = ELT_ELLIPSE;
ELEMENT_NAMES[2] = ELT_FRAMESET;
ELEMENT_NAMES[2] = ELT_FIELDSET;
ELEMENT_NAMES[3] = ELT_H2;
ELEMENT_NAMES[4] = ELT_MGLYPH;
ELEMENT_NAMES[5] = ELT_NOBR;
ELEMENT_NAMES[6] = ELT_RADIALGRADIENT;
ELEMENT_NAMES[5] = ELT_METER;
ELEMENT_NAMES[6] = ELT_RECT;
ELEMENT_NAMES[7] = ELT_RTC;
ELEMENT_NAMES[8] = ELT_EMBED;
ELEMENT_NAMES[9] = ELT_STRIKE;
ELEMENT_NAMES[10] = ELT_OL;
ELEMENT_NAMES[11] = ELT_OPTGROUP;
ELEMENT_NAMES[12] = ELT_PROGRESS;
ELEMENT_NAMES[13] = ELT_MTEXT;
ELEMENT_NAMES[12] = ELT_NOFRAMES;
ELEMENT_NAMES[13] = ELT_LINEARGRADIENT;
ELEMENT_NAMES[14] = ELT_VIEW;
ELEMENT_NAMES[15] = ELT_IMG;
ELEMENT_NAMES[16] = ELT_WBR;
@ -1537,11 +1531,11 @@ nsHtml5ElementName::initializeStatics()
ELEMENT_NAMES[22] = ELT_EM;
ELEMENT_NAMES[23] = ELT_TSPAN;
ELEMENT_NAMES[24] = ELT_FEFUNCR;
ELEMENT_NAMES[25] = ELT_DEFS;
ELEMENT_NAMES[26] = ELT_CONTENT;
ELEMENT_NAMES[27] = ELT_FEDISTANTLIGHT;
ELEMENT_NAMES[28] = ELT_OUTPUT;
ELEMENT_NAMES[29] = ELT_TEXT;
ELEMENT_NAMES[25] = ELT_CANVAS;
ELEMENT_NAMES[26] = ELT_BASEFONT;
ELEMENT_NAMES[27] = ELT_FEPOINTLIGHT;
ELEMENT_NAMES[28] = ELT_OBJECT;
ELEMENT_NAMES[29] = ELT_TFOOT;
ELEMENT_NAMES[30] = ELT_FEMORPHOLOGY;
ELEMENT_NAMES[31] = ELT_DEL;
ELEMENT_NAMES[32] = ELT_NAV;
@ -1563,16 +1557,16 @@ nsHtml5ElementName::initializeStatics()
ELEMENT_NAMES[48] = ELT_COLGROUP;
ELEMENT_NAMES[49] = ELT_ABBR;
ELEMENT_NAMES[50] = ELT_FEGAUSSIANBLUR;
ELEMENT_NAMES[51] = ELT_ADDRESS;
ELEMENT_NAMES[52] = ELT_MS;
ELEMENT_NAMES[53] = ELT_APPLET;
ELEMENT_NAMES[54] = ELT_FOREIGNOBJECT;
ELEMENT_NAMES[55] = ELT_FESPOTLIGHT;
ELEMENT_NAMES[56] = ELT_INPUT;
ELEMENT_NAMES[57] = ELT_RT;
ELEMENT_NAMES[58] = ELT_TT;
ELEMENT_NAMES[59] = ELT_SCRIPT;
ELEMENT_NAMES[60] = ELT_FEDROPSHADOW;
ELEMENT_NAMES[51] = ELT_TR;
ELEMENT_NAMES[52] = ELT_DETAILS;
ELEMENT_NAMES[53] = ELT_DT;
ELEMENT_NAMES[54] = ELT_DATALIST;
ELEMENT_NAMES[55] = ELT_FEOFFSET;
ELEMENT_NAMES[56] = ELT_FONT;
ELEMENT_NAMES[57] = ELT_NOSCRIPT;
ELEMENT_NAMES[58] = ELT_PLAINTEXT;
ELEMENT_NAMES[59] = ELT_SELECT;
ELEMENT_NAMES[60] = ELT_MENU;
ELEMENT_NAMES[61] = ELT_FECONVOLVEMATRIX;
ELEMENT_NAMES[62] = ELT_SUMMARY;
ELEMENT_NAMES[63] = ELT_BDO;
@ -1615,26 +1609,26 @@ nsHtml5ElementName::initializeStatics()
ELEMENT_NAMES[100] = ELT_CENTER;
ELEMENT_NAMES[101] = ELT_FILTER;
ELEMENT_NAMES[102] = ELT_MARKER;
ELEMENT_NAMES[103] = ELT_TR;
ELEMENT_NAMES[104] = ELT_CANVAS;
ELEMENT_NAMES[105] = ELT_DETAILS;
ELEMENT_NAMES[106] = ELT_NOFRAMES;
ELEMENT_NAMES[107] = ELT_DT;
ELEMENT_NAMES[108] = ELT_BASEFONT;
ELEMENT_NAMES[109] = ELT_DATALIST;
ELEMENT_NAMES[110] = ELT_FIELDSET;
ELEMENT_NAMES[111] = ELT_FEOFFSET;
ELEMENT_NAMES[112] = ELT_FEPOINTLIGHT;
ELEMENT_NAMES[113] = ELT_FONT;
ELEMENT_NAMES[114] = ELT_LINEARGRADIENT;
ELEMENT_NAMES[115] = ELT_NOSCRIPT;
ELEMENT_NAMES[116] = ELT_OBJECT;
ELEMENT_NAMES[117] = ELT_PLAINTEXT;
ELEMENT_NAMES[118] = ELT_RECT;
ELEMENT_NAMES[119] = ELT_SELECT;
ELEMENT_NAMES[120] = ELT_TFOOT;
ELEMENT_NAMES[121] = ELT_MENU;
ELEMENT_NAMES[122] = ELT_SHADOW;
ELEMENT_NAMES[103] = ELT_NOBR;
ELEMENT_NAMES[104] = ELT_ADDRESS;
ELEMENT_NAMES[105] = ELT_DEFS;
ELEMENT_NAMES[106] = ELT_MS;
ELEMENT_NAMES[107] = ELT_PROGRESS;
ELEMENT_NAMES[108] = ELT_APPLET;
ELEMENT_NAMES[109] = ELT_CONTENT;
ELEMENT_NAMES[110] = ELT_FOREIGNOBJECT;
ELEMENT_NAMES[111] = ELT_FRAMESET;
ELEMENT_NAMES[112] = ELT_FESPOTLIGHT;
ELEMENT_NAMES[113] = ELT_FEDISTANTLIGHT;
ELEMENT_NAMES[114] = ELT_INPUT;
ELEMENT_NAMES[115] = ELT_MTEXT;
ELEMENT_NAMES[116] = ELT_RT;
ELEMENT_NAMES[117] = ELT_OUTPUT;
ELEMENT_NAMES[118] = ELT_TT;
ELEMENT_NAMES[119] = ELT_RADIALGRADIENT;
ELEMENT_NAMES[120] = ELT_SCRIPT;
ELEMENT_NAMES[121] = ELT_TEXT;
ELEMENT_NAMES[122] = ELT_FEDROPSHADOW;
ELEMENT_NAMES[123] = ELT_FECOLORMATRIX;
ELEMENT_NAMES[124] = ELT_BODY;
ELEMENT_NAMES[125] = ELT_RUBY;
@ -1718,7 +1712,6 @@ nsHtml5ElementName::initializeStatics()
ELEMENT_NAMES[203] = ELT_FECOMPONENTTRANSFER;
ELEMENT_NAMES[204] = ELT_FOOTER;
ELEMENT_NAMES[205] = ELT_HEADER;
ELEMENT_NAMES[206] = ELT_METER;
}
void
@ -1923,7 +1916,6 @@ nsHtml5ElementName::releaseStatics()
delete ELT_TEXT;
delete ELT_MENU;
delete ELT_FEDROPSHADOW;
delete ELT_SHADOW;
delete ELT_VIEW;
delete ELT_FECOLORMATRIX;
delete ELT_FECONVOLVEMATRIX;

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

@ -105,48 +105,48 @@ public:
inline bool isInterned()
{
return !(flags & nsHtml5ElementName::NOT_INTERNED);
}
}
inline static int32_t levelOrderBinarySearch(jArray<int32_t, int32_t> data,
int32_t key)
{
int32_t n = data.length;
int32_t i = 0;
while (i < n) {
int32_t val = data[i];
if (val < key) {
i = 2 * i + 2;
} else if (val > key) {
i = 2 * i + 1;
} else {
return i;
}
}
return -1;
}
inline static nsHtml5ElementName* elementNameByBuffer(
char16_t* buf,
int32_t offset,
int32_t length,
nsHtml5AtomTable* interner)
{
uint32_t hash = nsHtml5ElementName::bufToHash(buf, length);
jArray<int32_t, int32_t> hashes;
hashes = nsHtml5ElementName::ELEMENT_HASHES;
int32_t index = levelOrderBinarySearch(hashes, hash);
if (index < 0) {
return nullptr;
inline static int32_t levelOrderBinarySearch(jArray<int32_t, int32_t> data,
int32_t key)
{
int32_t n = data.length;
int32_t i = 0;
while (i < n) {
int32_t val = data[i];
if (val < key) {
i = 2 * i + 2;
} else if (val > key) {
i = 2 * i + 1;
} else {
nsHtml5ElementName* elementName =
nsHtml5ElementName::ELEMENT_NAMES[index];
nsIAtom* name = elementName->name;
if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) {
return nullptr;
}
return elementName;
return i;
}
}
return -1;
}
inline static nsHtml5ElementName* elementNameByBuffer(
char16_t* buf,
int32_t offset,
int32_t length,
nsHtml5AtomTable* interner)
{
uint32_t hash = nsHtml5ElementName::bufToHash(buf, length);
jArray<int32_t, int32_t> hashes;
hashes = nsHtml5ElementName::ELEMENT_HASHES;
int32_t index = levelOrderBinarySearch(hashes, hash);
if (index < 0) {
return nullptr;
} else {
nsHtml5ElementName* elementName =
nsHtml5ElementName::ELEMENT_NAMES[index];
nsIAtom* name = elementName->name;
if (!nsHtml5Portability::localEqualsBuffer(name, buf, offset, length)) {
return nullptr;
}
return elementName;
}
}
private:
inline static uint32_t bufToHash(char16_t* buf, int32_t length)
@ -401,7 +401,6 @@ public:
static nsHtml5ElementName* ELT_TEXT;
static nsHtml5ElementName* ELT_MENU;
static nsHtml5ElementName* ELT_FEDROPSHADOW;
static nsHtml5ElementName* ELT_SHADOW;
static nsHtml5ElementName* ELT_VIEW;
static nsHtml5ElementName* ELT_FECOLORMATRIX;
static nsHtml5ElementName* ELT_FECONVOLVEMATRIX;

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

@ -70,7 +70,6 @@ class nsHtml5StackNode
private:
int32_t refcount;
mozilla::dom::HTMLContentCreatorFunction htmlCreator;
public:
inline int32_t getFlags()
{

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

@ -143,7 +143,6 @@ static const HTMLElement gHTMLElements[] = {
ELEM(script, ____, true)
ELEM(section, true, true)
ELEM(select, ____, true)
ELEM(shadow, ____, true)
ELEM(small, ____, true)
ELEM(source, ____, ____)
ELEM(span, ____, true)

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

@ -154,7 +154,6 @@ HTML_HTMLELEMENT_TAG(samp)
HTML_TAG(script, Script, Script)
HTML_HTMLELEMENT_TAG(section)
HTML_TAG(select, Select, Select)
HTML_TAG(shadow, Shadow, Shadow)
HTML_HTMLELEMENT_TAG(small)
HTML_TAG(source, Source, Source)
HTML_TAG(span, Span, Span)