2015-05-03 22:32:37 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2013-12-02 14:26:11 +04:00
|
|
|
/* 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/Preferences.h"
|
|
|
|
#include "mozilla/dom/ShadowRoot.h"
|
|
|
|
#include "mozilla/dom/ShadowRootBinding.h"
|
|
|
|
#include "mozilla/dom/DocumentFragment.h"
|
2013-12-02 14:26:12 +04:00
|
|
|
#include "ChildIterator.h"
|
2013-12-02 14:26:11 +04:00
|
|
|
#include "nsContentUtils.h"
|
|
|
|
#include "nsDOMClassInfoID.h"
|
|
|
|
#include "nsIDOMHTMLElement.h"
|
2013-12-02 14:26:12 +04:00
|
|
|
#include "nsIStyleSheetLinkingElement.h"
|
2013-12-02 14:26:11 +04:00
|
|
|
#include "mozilla/dom/Element.h"
|
2013-12-02 14:26:12 +04:00
|
|
|
#include "mozilla/dom/HTMLContentElement.h"
|
2013-12-02 14:26:11 +04:00
|
|
|
#include "nsXBLPrototypeBinding.h"
|
2016-09-26 15:03:25 +03:00
|
|
|
#include "mozilla/StyleSheet.h"
|
|
|
|
#include "mozilla/StyleSheetInlines.h"
|
2013-12-02 14:26:11 +04:00
|
|
|
|
|
|
|
using namespace mozilla;
|
|
|
|
using namespace mozilla::dom;
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_CLASS(ShadowRoot)
|
|
|
|
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(ShadowRoot,
|
|
|
|
DocumentFragment)
|
2013-12-02 14:26:12 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mStyleSheetList)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE(mAssociatedBinding)
|
2015-07-22 19:42:01 +03:00
|
|
|
for (auto iter = tmp->mIdentifierMap.ConstIter(); !iter.Done();
|
|
|
|
iter.Next()) {
|
|
|
|
iter.Get()->Traverse(&cb);
|
|
|
|
}
|
2013-12-02 14:26:11 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|
|
|
|
2017-09-25 18:09:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(ShadowRoot)
|
|
|
|
if (tmp->GetHost()) {
|
|
|
|
tmp->GetHost()->RemoveMutationObserver(tmp);
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
2013-12-02 14:26:12 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mStyleSheetList)
|
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK(mAssociatedBinding)
|
2013-12-02 14:26:11 +04:00
|
|
|
tmp->mIdentifierMap.Clear();
|
2017-09-25 18:09:26 +03:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_UNLINK_END_INHERITED(DocumentFragment)
|
2013-12-02 14:26:11 +04:00
|
|
|
|
2017-08-30 02:02:48 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ShadowRoot)
|
2013-12-02 14:26:11 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIContent)
|
2013-12-02 14:26:12 +04:00
|
|
|
NS_INTERFACE_MAP_ENTRY(nsIMutationObserver)
|
2013-12-02 14:26:11 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(DocumentFragment)
|
|
|
|
|
|
|
|
NS_IMPL_ADDREF_INHERITED(ShadowRoot, DocumentFragment)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(ShadowRoot, DocumentFragment)
|
|
|
|
|
2017-10-19 09:44:35 +03:00
|
|
|
ShadowRoot::ShadowRoot(Element* aElement, bool aClosed,
|
2014-06-20 06:01:40 +04:00
|
|
|
already_AddRefed<mozilla::dom::NodeInfo>&& aNodeInfo,
|
2013-12-02 14:26:12 +04:00
|
|
|
nsXBLPrototypeBinding* aProtoBinding)
|
2017-09-25 18:09:26 +03:00
|
|
|
: DocumentFragment(aNodeInfo)
|
|
|
|
, mProtoBinding(aProtoBinding)
|
|
|
|
, mInsertionPointChanged(false)
|
|
|
|
, mIsComposedDocParticipant(false)
|
2013-12-02 14:26:11 +04:00
|
|
|
{
|
2017-09-06 11:37:17 +03:00
|
|
|
SetHost(aElement);
|
2017-10-19 09:44:35 +03:00
|
|
|
mMode = aClosed ? ShadowRootMode::Closed : ShadowRootMode::Open;
|
2014-06-07 12:42:53 +04:00
|
|
|
|
|
|
|
// Nodes in a shadow tree should never store a value
|
|
|
|
// in the subtree root pointer, nodes in the shadow tree
|
|
|
|
// track the subtree root using GetContainingShadow().
|
|
|
|
ClearSubtreeRootPointer();
|
|
|
|
|
2013-12-02 14:26:11 +04:00
|
|
|
SetFlags(NODE_IS_IN_SHADOW_TREE);
|
2014-06-07 12:42:53 +04:00
|
|
|
|
2017-09-06 11:37:17 +03:00
|
|
|
ExtendedDOMSlots()->mBindingParent = aElement;
|
2017-07-18 01:25:49 +03:00
|
|
|
ExtendedDOMSlots()->mContainingShadow = this;
|
2013-12-02 14:26:12 +04:00
|
|
|
|
|
|
|
// 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.
|
2017-09-25 18:09:26 +03:00
|
|
|
GetHost()->AddMutationObserver(this);
|
2013-12-02 14:26:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
ShadowRoot::~ShadowRoot()
|
|
|
|
{
|
2017-10-17 19:22:29 +03:00
|
|
|
if (auto* host = GetHost()) {
|
|
|
|
// mHost may have been unlinked or a new ShadowRoot may have been
|
|
|
|
// created, making this one obsolete.
|
|
|
|
host->RemoveMutationObserver(this);
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
|
2014-06-07 12:42:53 +04:00
|
|
|
UnsetFlags(NODE_IS_IN_SHADOW_TREE);
|
|
|
|
|
|
|
|
// nsINode destructor expects mSubtreeRoot == this.
|
|
|
|
SetSubtreeRootPointer(this);
|
2013-12-02 14:26:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
JSObject*
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
ShadowRoot::WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto)
|
2013-12-02 14:26:11 +04:00
|
|
|
{
|
Bug 1117172 part 3. Change the wrappercached WrapObject methods to allow passing in aGivenProto. r=peterv
The only manual changes here are to BindingUtils.h, BindingUtils.cpp,
Codegen.py, Element.cpp, IDBFileRequest.cpp, IDBObjectStore.cpp,
dom/workers/Navigator.cpp, WorkerPrivate.cpp, DeviceStorageRequestChild.cpp,
Notification.cpp, nsGlobalWindow.cpp, MessagePort.cpp, nsJSEnvironment.cpp,
Sandbox.cpp, XPCConvert.cpp, ExportHelpers.cpp, and DataStoreService.cpp. The
rest of this diff was generated by running the following commands:
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObjectInternal\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapNode\((?:aCx|cx|aContext|aCtx|js))\)/\1, aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(WrapObject\(JSContext *\* *(?:aCx|cx|aContext|aCtx|js))\)/\1, JS::Handle<JSObject*> aGivenProto)/g'
find . -name "*.h" -o -name "*.cpp" | xargs perl -pi -e 'BEGIN { $/ = undef } s/(Binding(?:_workers)?::Wrap\((?:aCx|cx|aContext|aCtx|js), [^,)]+)\)/\1, aGivenProto)/g'
2015-03-19 17:13:33 +03:00
|
|
|
return mozilla::dom::ShadowRootBinding::Wrap(aCx, this, aGivenProto);
|
2013-12-02 14:26:11 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
ShadowRoot*
|
|
|
|
ShadowRoot::FromNode(nsINode* aNode)
|
|
|
|
{
|
2014-07-03 21:02:07 +04:00
|
|
|
if (aNode->IsInShadowTree() && !aNode->GetParentNode()) {
|
2013-12-02 14:26:11 +04:00
|
|
|
MOZ_ASSERT(aNode->NodeType() == nsIDOMNode::DOCUMENT_FRAGMENT_NODE,
|
|
|
|
"ShadowRoot is a document fragment.");
|
|
|
|
return static_cast<ShadowRoot*>(aNode);
|
|
|
|
}
|
|
|
|
|
|
|
|
return nullptr;
|
|
|
|
}
|
|
|
|
|
2013-12-02 14:26:12 +04:00
|
|
|
void
|
2014-06-07 12:42:54 +04:00
|
|
|
ShadowRoot::StyleSheetChanged()
|
2013-12-02 14:26:12 +04:00
|
|
|
{
|
|
|
|
mProtoBinding->FlushSkinSheets();
|
|
|
|
|
2017-10-17 19:22:29 +03:00
|
|
|
if (nsIPresShell* shell = OwnerDoc()->GetShell()) {
|
2013-12-02 14:26:12 +04:00
|
|
|
OwnerDoc()->BeginUpdate(UPDATE_STYLE);
|
2014-06-07 12:42:54 +04:00
|
|
|
shell->RecordShadowStyleChange(this);
|
2013-12-02 14:26:12 +04:00
|
|
|
OwnerDoc()->EndUpdate(UPDATE_STYLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-09-26 15:03:25 +03:00
|
|
|
ShadowRoot::InsertSheet(StyleSheet* aSheet,
|
2013-12-02 14:26:12 +04:00
|
|
|
nsIContent* aLinkingContent)
|
|
|
|
{
|
|
|
|
nsCOMPtr<nsIStyleSheetLinkingElement>
|
|
|
|
linkingElement = do_QueryInterface(aLinkingContent);
|
|
|
|
MOZ_ASSERT(linkingElement, "The only styles in a ShadowRoot should come "
|
|
|
|
"from <style>.");
|
|
|
|
|
|
|
|
linkingElement->SetStyleSheet(aSheet); // This sets the ownerNode on the sheet
|
|
|
|
|
|
|
|
// Find the correct position to insert into the style sheet list (must
|
|
|
|
// be in tree order).
|
2014-06-19 11:02:56 +04:00
|
|
|
for (size_t i = 0; i <= mProtoBinding->SheetCount(); i++) {
|
|
|
|
if (i == mProtoBinding->SheetCount()) {
|
|
|
|
mProtoBinding->AppendStyleSheet(aSheet);
|
2013-12-02 14:26:12 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-02-24 10:01:12 +03:00
|
|
|
nsINode* sheetOwningNode = mProtoBinding->StyleSheetAt(i)->GetOwnerNode();
|
|
|
|
if (nsContentUtils::PositionIsBefore(aLinkingContent, sheetOwningNode)) {
|
2014-06-19 11:02:56 +04:00
|
|
|
mProtoBinding->InsertStyleSheetAt(i, aSheet);
|
2013-12-02 14:26:12 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-06-07 12:42:54 +04:00
|
|
|
if (aSheet->IsApplicable()) {
|
|
|
|
StyleSheetChanged();
|
|
|
|
}
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2016-09-26 15:03:25 +03:00
|
|
|
ShadowRoot::RemoveSheet(StyleSheet* aSheet)
|
2013-12-02 14:26:12 +04:00
|
|
|
{
|
2014-06-19 11:02:56 +04:00
|
|
|
mProtoBinding->RemoveStyleSheet(aSheet);
|
2013-12-02 14:26:12 +04:00
|
|
|
|
2014-06-07 12:42:54 +04:00
|
|
|
if (aSheet->IsApplicable()) {
|
|
|
|
StyleSheetChanged();
|
|
|
|
}
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
|
2013-12-02 14:26:11 +04:00
|
|
|
Element*
|
|
|
|
ShadowRoot::GetElementById(const nsAString& aElementId)
|
|
|
|
{
|
|
|
|
nsIdentifierMapEntry *entry = mIdentifierMap.GetEntry(aElementId);
|
|
|
|
return entry ? entry->GetIdElement() : nullptr;
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsContentList>
|
|
|
|
ShadowRoot::GetElementsByTagName(const nsAString& aTagName)
|
|
|
|
{
|
|
|
|
return NS_GetContentList(this, kNameSpaceID_Unknown, aTagName);
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsContentList>
|
|
|
|
ShadowRoot::GetElementsByTagNameNS(const nsAString& aNamespaceURI,
|
|
|
|
const nsAString& aLocalName)
|
|
|
|
{
|
|
|
|
int32_t nameSpaceId = kNameSpaceID_Wildcard;
|
|
|
|
|
|
|
|
if (!aNamespaceURI.EqualsLiteral("*")) {
|
|
|
|
nsresult rv =
|
|
|
|
nsContentUtils::NameSpaceManager()->RegisterNameSpace(aNamespaceURI,
|
|
|
|
nameSpaceId);
|
|
|
|
NS_ENSURE_SUCCESS(rv, nullptr);
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_ASSERTION(nameSpaceId != kNameSpaceID_Unknown, "Unexpected namespace ID!");
|
|
|
|
|
|
|
|
return NS_GetContentList(this, nameSpaceId, aLocalName);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-10-03 01:05:19 +03:00
|
|
|
ShadowRoot::AddToIdTable(Element* aElement, nsAtom* aId)
|
2013-12-02 14:26:11 +04:00
|
|
|
{
|
2017-04-13 22:12:20 +03:00
|
|
|
nsIdentifierMapEntry* entry = mIdentifierMap.PutEntry(aId);
|
2013-12-02 14:26:11 +04:00
|
|
|
if (entry) {
|
|
|
|
entry->AddIdElement(aElement);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
2017-10-03 01:05:19 +03:00
|
|
|
ShadowRoot::RemoveFromIdTable(Element* aElement, nsAtom* aId)
|
2013-12-02 14:26:11 +04:00
|
|
|
{
|
2017-04-13 22:12:20 +03:00
|
|
|
nsIdentifierMapEntry* entry = mIdentifierMap.GetEntry(aId);
|
2013-12-02 14:26:11 +04:00
|
|
|
if (entry) {
|
|
|
|
entry->RemoveIdElement(aElement);
|
|
|
|
if (entry->IsEmpty()) {
|
2016-02-09 05:52:21 +03:00
|
|
|
mIdentifierMap.RemoveEntry(entry);
|
2013-12-02 14:26:11 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
already_AddRefed<nsContentList>
|
|
|
|
ShadowRoot::GetElementsByClassName(const nsAString& aClasses)
|
|
|
|
{
|
|
|
|
return nsContentUtils::GetElementsByClassName(this, aClasses);
|
|
|
|
}
|
|
|
|
|
2013-12-02 14:26:12 +04:00
|
|
|
void
|
|
|
|
ShadowRoot::AddInsertionPoint(HTMLContentElement* aInsertionPoint)
|
|
|
|
{
|
|
|
|
TreeOrderComparator comparator;
|
|
|
|
mInsertionPoints.InsertElementSorted(aInsertionPoint, comparator);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowRoot::RemoveInsertionPoint(HTMLContentElement* aInsertionPoint)
|
|
|
|
{
|
|
|
|
mInsertionPoints.RemoveElement(aInsertionPoint);
|
|
|
|
}
|
|
|
|
|
2014-05-22 10:11:53 +04:00
|
|
|
void
|
|
|
|
ShadowRoot::RemoveDestInsertionPoint(nsIContent* aInsertionPoint,
|
|
|
|
nsTArray<nsIContent*>& aDestInsertionPoints)
|
|
|
|
{
|
|
|
|
// Remove the insertion point from the destination insertion points.
|
2017-10-20 01:19:58 +03:00
|
|
|
//
|
|
|
|
// Note that while it sounds tempting to just remove all the insertion points
|
|
|
|
// after it too, since they're usually after in tree position, it may not be
|
|
|
|
// the case when we're redistributing after new insertion points have been
|
|
|
|
// bound to the tree before aInsertionPoint, see bug 1409088.
|
2014-05-22 10:11:53 +04:00
|
|
|
int32_t index = aDestInsertionPoints.IndexOf(aInsertionPoint);
|
|
|
|
|
|
|
|
// It's possible that we already removed the insertion point while processing
|
Bug 1409088: Fix destination insertion point removal algorithm. r=bz
When an insertion point (a) is added to the document before another insertion
point (b), and that insertion point matches nodes that used to match (b), the
following happens in RedistributeAllNodes:
* Loop through (a), and clear the existing insertion points on nodes
distributed into it (none, since it was just inserted).
* Go through the node pool and add the matched nodes. That makes the node
(which already had (b) in the insertion point array) have [(b), (a)] as the
insertion points.
* Go through (b), and clear the existing insertion points on the nodes
distributed to it. That used to do IndexOf() + SetLength(), but since (b) was
the first node by then in the insertion point array, we'll leave the
insertion point array empty, while (a) would still think that the node is
distributed to it.
This causes the bloom filter code, which loops through the flattened tree
parents, to not insert any (because the node doesn't know about where it's
inserted).
Also, add a debug phase to verify the flat tree before restyling that would've
caught this more clearly (happy to remove it if you don't think it's worth).
We still can't assert that the insertion point is properly referenced due to the
hacky way mInsertionPoints is cleared in
HTMLContentElement::UpdateFallbackDistribution, but we'll still clear the
insertion points either there, or on the rest of insertion point removal code in
ShadowRoot::DistributeAllNodes.
MozReview-Commit-ID: 9k2gnsAKMEe
--HG--
extra : rebase_source : 7e8371199bde8148d77cb69417a8dd8b1ee77078
2017-10-19 15:45:16 +03:00
|
|
|
// other insertion point removals / fallback content redistribution (which
|
|
|
|
// does DestInsertionPoints().Clear()).
|
2014-05-22 10:11:53 +04:00
|
|
|
if (index >= 0) {
|
Bug 1409088: Fix destination insertion point removal algorithm. r=bz
When an insertion point (a) is added to the document before another insertion
point (b), and that insertion point matches nodes that used to match (b), the
following happens in RedistributeAllNodes:
* Loop through (a), and clear the existing insertion points on nodes
distributed into it (none, since it was just inserted).
* Go through the node pool and add the matched nodes. That makes the node
(which already had (b) in the insertion point array) have [(b), (a)] as the
insertion points.
* Go through (b), and clear the existing insertion points on the nodes
distributed to it. That used to do IndexOf() + SetLength(), but since (b) was
the first node by then in the insertion point array, we'll leave the
insertion point array empty, while (a) would still think that the node is
distributed to it.
This causes the bloom filter code, which loops through the flattened tree
parents, to not insert any (because the node doesn't know about where it's
inserted).
Also, add a debug phase to verify the flat tree before restyling that would've
caught this more clearly (happy to remove it if you don't think it's worth).
We still can't assert that the insertion point is properly referenced due to the
hacky way mInsertionPoints is cleared in
HTMLContentElement::UpdateFallbackDistribution, but we'll still clear the
insertion points either there, or on the rest of insertion point removal code in
ShadowRoot::DistributeAllNodes.
MozReview-Commit-ID: 9k2gnsAKMEe
--HG--
extra : rebase_source : 7e8371199bde8148d77cb69417a8dd8b1ee77078
2017-10-19 15:45:16 +03:00
|
|
|
aDestInsertionPoints.RemoveElementAt(index);
|
2014-05-22 10:11:53 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-18 16:24:53 +03:00
|
|
|
void
|
|
|
|
ShadowRoot::DistributionChanged()
|
|
|
|
{
|
|
|
|
// FIXME(emilio): We could be more granular in a bunch of cases.
|
|
|
|
auto* host = GetHost();
|
2017-10-18 17:03:41 +03:00
|
|
|
if (!host || !host->IsInComposedDoc()) {
|
2017-10-18 16:24:53 +03:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
auto* shell = OwnerDoc()->GetShell();
|
|
|
|
if (!shell) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-26 00:12:25 +03:00
|
|
|
shell->DestroyFramesForAndRestyle(host);
|
2017-10-18 16:24:53 +03:00
|
|
|
}
|
|
|
|
|
2017-10-18 17:03:41 +03:00
|
|
|
const HTMLContentElement*
|
2013-12-02 14:26:12 +04:00
|
|
|
ShadowRoot::DistributeSingleNode(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
// Find the insertion point to which the content belongs.
|
2017-10-17 19:22:29 +03:00
|
|
|
HTMLContentElement* foundInsertionPoint = nullptr;
|
|
|
|
for (HTMLContentElement* insertionPoint : mInsertionPoints) {
|
|
|
|
if (insertionPoint->Match(aContent)) {
|
|
|
|
if (insertionPoint->MatchedNodes().Contains(aContent)) {
|
2013-12-21 10:43:58 +04:00
|
|
|
// Node is already matched into the insertion point. We are done.
|
2017-10-18 17:03:41 +03:00
|
|
|
return insertionPoint;
|
2013-12-21 10:43:58 +04:00
|
|
|
}
|
|
|
|
|
2013-12-02 14:26:12 +04:00
|
|
|
// Matching may cause the insertion point to drop fallback content.
|
2017-10-17 19:22:29 +03:00
|
|
|
if (insertionPoint->MatchedNodes().IsEmpty() &&
|
|
|
|
insertionPoint->HasChildren()) {
|
2013-12-02 14:26:12 +04:00
|
|
|
// This match will cause the insertion point to drop all fallback
|
|
|
|
// content and used matched nodes instead. Give up on the optimization
|
|
|
|
// and just distribute all nodes.
|
|
|
|
DistributeAllNodes();
|
2017-10-18 17:03:41 +03:00
|
|
|
MOZ_ASSERT(insertionPoint->MatchedNodes().Contains(aContent));
|
|
|
|
return insertionPoint;
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
2017-10-17 19:22:29 +03:00
|
|
|
foundInsertionPoint = insertionPoint;
|
2013-12-02 14:26:12 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-17 19:22:29 +03:00
|
|
|
if (!foundInsertionPoint) {
|
2017-10-18 17:03:41 +03:00
|
|
|
return nullptr;
|
2017-10-17 19:22:29 +03:00
|
|
|
}
|
|
|
|
|
2013-12-02 14:26:12 +04:00
|
|
|
// Find the index into the insertion point.
|
2017-10-17 19:22:29 +03:00
|
|
|
nsCOMArray<nsIContent>& matchedNodes = foundInsertionPoint->MatchedNodes();
|
|
|
|
// Find the appropriate position in the matched node list for the
|
|
|
|
// newly distributed content.
|
|
|
|
bool isIndexFound = false;
|
|
|
|
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.
|
|
|
|
if (childIterator.Seek(aContent, matchedNodes[i])) {
|
|
|
|
// aContent was found before the current matched node.
|
|
|
|
foundInsertionPoint->InsertMatchedNode(i, aContent);
|
|
|
|
isIndexFound = true;
|
|
|
|
break;
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
2017-10-17 19:22:29 +03:00
|
|
|
}
|
2013-12-02 14:26:12 +04:00
|
|
|
|
2017-10-17 19:22:29 +03:00
|
|
|
if (!isIndexFound) {
|
|
|
|
// We have still not found an index in the insertion point,
|
|
|
|
// thus it must be at the end.
|
|
|
|
MOZ_ASSERT(childIterator.Seek(aContent, nullptr),
|
|
|
|
"Trying to match a node that is not a candidate to be matched");
|
|
|
|
foundInsertionPoint->AppendMatchedNode(aContent);
|
|
|
|
}
|
2013-12-02 14:26:12 +04:00
|
|
|
|
2017-10-18 17:03:41 +03:00
|
|
|
return foundInsertionPoint;
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
|
2017-10-18 17:03:41 +03:00
|
|
|
const HTMLContentElement*
|
2013-12-02 14:26:12 +04:00
|
|
|
ShadowRoot::RemoveDistributedNode(nsIContent* aContent)
|
|
|
|
{
|
|
|
|
// Find insertion point containing the content and remove the node.
|
2017-10-17 19:22:29 +03:00
|
|
|
for (HTMLContentElement* insertionPoint : mInsertionPoints) {
|
|
|
|
if (!insertionPoint->MatchedNodes().Contains(aContent)) {
|
|
|
|
continue;
|
|
|
|
}
|
2013-12-02 14:26:12 +04:00
|
|
|
|
2017-10-17 19:22:29 +03:00
|
|
|
// Removing the matched node may cause the insertion point to use
|
|
|
|
// fallback content.
|
|
|
|
if (insertionPoint->MatchedNodes().Length() == 1 &&
|
|
|
|
insertionPoint->HasChildren()) {
|
|
|
|
// Removing the matched node will cause fallback content to be
|
|
|
|
// used instead. Give up optimization and distribute all nodes.
|
|
|
|
DistributeAllNodes();
|
2017-10-18 17:03:41 +03:00
|
|
|
return insertionPoint;
|
2017-10-17 19:22:29 +03:00
|
|
|
}
|
2013-12-02 14:26:12 +04:00
|
|
|
|
2017-10-17 19:22:29 +03:00
|
|
|
insertionPoint->RemoveMatchedNode(aContent);
|
2017-10-18 17:03:41 +03:00
|
|
|
return insertionPoint;
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
2017-10-18 17:03:41 +03:00
|
|
|
|
|
|
|
return nullptr;
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowRoot::DistributeAllNodes()
|
|
|
|
{
|
|
|
|
// Create node pool.
|
|
|
|
nsTArray<nsIContent*> nodePool;
|
2017-09-25 18:09:26 +03:00
|
|
|
ExplicitChildIterator childIterator(GetHost());
|
|
|
|
for (nsIContent* content = childIterator.GetNextChild(); content;
|
|
|
|
content = childIterator.GetNextChild()) {
|
|
|
|
nodePool.AppendElement(content);
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
|
2013-12-21 10:43:58 +04:00
|
|
|
nsTArray<ShadowRoot*> shadowsToUpdate;
|
|
|
|
|
2017-10-17 19:22:29 +03:00
|
|
|
for (HTMLContentElement* insertionPoint : mInsertionPoints) {
|
|
|
|
insertionPoint->ClearMatchedNodes();
|
2013-12-02 14:26:12 +04:00
|
|
|
// Assign matching nodes from node pool.
|
|
|
|
for (uint32_t j = 0; j < nodePool.Length(); j++) {
|
2017-10-17 19:22:29 +03:00
|
|
|
if (insertionPoint->Match(nodePool[j])) {
|
|
|
|
insertionPoint->AppendMatchedNode(nodePool[j]);
|
2013-12-02 14:26:12 +04:00
|
|
|
nodePool.RemoveElementAt(j--);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-21 10:43:58 +04:00
|
|
|
// Keep track of instances where the content insertion point is distributed
|
|
|
|
// (parent of insertion point has a ShadowRoot).
|
2017-10-17 19:22:29 +03:00
|
|
|
nsIContent* insertionParent = insertionPoint->GetParent();
|
2013-12-02 14:26:12 +04:00
|
|
|
MOZ_ASSERT(insertionParent, "The only way for an insertion point to be in the"
|
|
|
|
"mInsertionPoints array is to be a descendant of a"
|
|
|
|
"ShadowRoot, in which case, it should have a parent");
|
|
|
|
|
2014-05-22 10:11:53 +04:00
|
|
|
// If the parent of the insertion point has a ShadowRoot, the nodes distributed
|
2013-12-02 14:26:12 +04:00
|
|
|
// to the insertion point must be reprojected to the insertion points of the
|
|
|
|
// parent's ShadowRoot.
|
|
|
|
ShadowRoot* parentShadow = insertionParent->GetShadowRoot();
|
2013-12-21 10:43:58 +04:00
|
|
|
if (parentShadow && !shadowsToUpdate.Contains(parentShadow)) {
|
|
|
|
shadowsToUpdate.AppendElement(parentShadow);
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
}
|
2013-12-21 10:43:58 +04:00
|
|
|
|
2017-10-17 19:22:29 +03:00
|
|
|
for (ShadowRoot* shadow : shadowsToUpdate) {
|
|
|
|
shadow->DistributeAllNodes();
|
2013-12-21 10:43:58 +04:00
|
|
|
}
|
2017-10-18 16:24:53 +03:00
|
|
|
|
|
|
|
DistributionChanged();
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
|
2013-12-02 14:26:12 +04:00
|
|
|
void
|
|
|
|
ShadowRoot::GetInnerHTML(nsAString& aInnerHTML)
|
|
|
|
{
|
|
|
|
GetMarkup(false, aInnerHTML);
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowRoot::SetInnerHTML(const nsAString& aInnerHTML, ErrorResult& aError)
|
|
|
|
{
|
|
|
|
SetInnerHTMLInternal(aInnerHTML, aError);
|
|
|
|
}
|
|
|
|
|
2014-10-16 05:25:45 +04:00
|
|
|
Element*
|
|
|
|
ShadowRoot::Host()
|
|
|
|
{
|
|
|
|
nsIContent* host = GetHost();
|
|
|
|
MOZ_ASSERT(host && host->IsElement(),
|
|
|
|
"ShadowRoot host should always be an element, "
|
|
|
|
"how else did we create this ShadowRoot?");
|
|
|
|
return host->AsElement();
|
|
|
|
}
|
|
|
|
|
2013-12-02 14:26:12 +04:00
|
|
|
bool
|
|
|
|
ShadowRoot::ApplyAuthorStyles()
|
|
|
|
{
|
|
|
|
return mProtoBinding->InheritsStyle();
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowRoot::SetApplyAuthorStyles(bool aApplyAuthorStyles)
|
|
|
|
{
|
|
|
|
mProtoBinding->SetInheritsStyle(aApplyAuthorStyles);
|
|
|
|
|
|
|
|
nsIPresShell* shell = OwnerDoc()->GetShell();
|
|
|
|
if (shell) {
|
|
|
|
OwnerDoc()->BeginUpdate(UPDATE_STYLE);
|
2014-06-07 12:42:54 +04:00
|
|
|
shell->RecordShadowStyleChange(this);
|
2013-12-02 14:26:12 +04:00
|
|
|
OwnerDoc()->EndUpdate(UPDATE_STYLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-04-12 12:18:54 +04:00
|
|
|
StyleSheetList*
|
2013-12-02 14:26:12 +04:00
|
|
|
ShadowRoot::StyleSheets()
|
|
|
|
{
|
|
|
|
if (!mStyleSheetList) {
|
|
|
|
mStyleSheetList = new ShadowRootStyleSheetList(this);
|
|
|
|
}
|
|
|
|
|
|
|
|
return mStyleSheetList;
|
|
|
|
}
|
|
|
|
|
2013-12-02 14:26:12 +04:00
|
|
|
/**
|
|
|
|
* Returns whether the web components pool population algorithm
|
|
|
|
* on the host would contain |aContent|. This function ignores
|
|
|
|
* insertion points in the pool, thus should only be used to
|
|
|
|
* test nodes that have not yet been distributed.
|
|
|
|
*/
|
2013-12-21 10:43:58 +04:00
|
|
|
bool
|
2017-10-18 16:02:16 +03:00
|
|
|
ShadowRoot::IsPooledNode(nsIContent* aContent) const
|
2013-12-02 14:26:12 +04:00
|
|
|
{
|
2017-09-25 18:09:26 +03:00
|
|
|
if (nsContentUtils::IsContentInsertionPoint(aContent)) {
|
2013-12-02 14:26:12 +04:00
|
|
|
// Insertion points never end up in the pool.
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2017-10-18 16:02:16 +03:00
|
|
|
auto* host = GetHost();
|
|
|
|
auto* container = aContent->GetParent();
|
|
|
|
if (container == host && !aContent->IsRootOfAnonymousSubtree()) {
|
2015-01-09 00:49:51 +03:00
|
|
|
// Children of the host will end up in the pool. We check to ensure
|
|
|
|
// that the content is in the same anonymous tree as the container
|
|
|
|
// because anonymous content may report its container as the host
|
|
|
|
// but it may not be in the host's child list.
|
2014-05-22 10:11:53 +04:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2017-10-18 16:02:16 +03:00
|
|
|
if (auto* content = HTMLContentElement::FromContentOrNull(container)) {
|
2013-12-02 14:26:12 +04:00
|
|
|
// Fallback content will end up in pool if its parent is a child of the host.
|
2017-10-18 16:02:16 +03:00
|
|
|
return content->IsInsertionPoint() &&
|
2016-11-23 06:41:51 +03:00
|
|
|
content->MatchedNodes().IsEmpty() &&
|
2017-10-18 16:02:16 +03:00
|
|
|
container->GetParentNode() == host;
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowRoot::AttributeChanged(nsIDocument* aDocument,
|
|
|
|
Element* aElement,
|
|
|
|
int32_t aNameSpaceID,
|
2017-10-03 01:05:19 +03:00
|
|
|
nsAtom* aAttribute,
|
2015-07-25 09:01:19 +03:00
|
|
|
int32_t aModType,
|
|
|
|
const nsAttrValue* aOldValue)
|
2013-12-02 14:26:12 +04:00
|
|
|
{
|
2017-10-18 16:02:16 +03:00
|
|
|
if (!IsPooledNode(aElement)) {
|
2013-12-02 14:26:12 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Attributes may change insertion point matching, find its new distribution.
|
2017-10-18 17:03:41 +03:00
|
|
|
if (!RedistributeElement(aElement)) {
|
|
|
|
return;
|
|
|
|
}
|
2013-12-02 14:26:12 +04:00
|
|
|
|
2017-10-18 17:03:41 +03:00
|
|
|
if (!aElement->IsInComposedDoc()) {
|
2013-12-02 14:26:12 +04:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-18 17:03:41 +03:00
|
|
|
auto* shell = OwnerDoc()->GetShell();
|
|
|
|
if (!shell) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-26 00:12:25 +03:00
|
|
|
shell->DestroyFramesForAndRestyle(aElement);
|
2017-10-18 17:03:41 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
ShadowRoot::RedistributeElement(Element* aElement)
|
|
|
|
{
|
|
|
|
auto* oldInsertionPoint = RemoveDistributedNode(aElement);
|
|
|
|
auto* newInsertionPoint = DistributeSingleNode(aElement);
|
|
|
|
|
|
|
|
if (oldInsertionPoint == newInsertionPoint) {
|
|
|
|
if (oldInsertionPoint) {
|
|
|
|
if (auto* shadow = oldInsertionPoint->GetParent()->GetShadowRoot()) {
|
|
|
|
return shadow->RedistributeElement(aElement);
|
2014-05-22 10:11:53 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-18 17:03:41 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (oldInsertionPoint) {
|
|
|
|
// 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.
|
|
|
|
auto* shadow = oldInsertionPoint->GetParent()->GetShadowRoot();
|
|
|
|
if (!shadow) {
|
|
|
|
break;
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
2014-05-22 10:11:53 +04:00
|
|
|
|
2017-10-18 17:03:41 +03:00
|
|
|
oldInsertionPoint = shadow->RemoveDistributedNode(aElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
while (newInsertionPoint) {
|
|
|
|
// 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.
|
|
|
|
auto* shadow = newInsertionPoint->GetParent()->GetShadowRoot();
|
|
|
|
if (!shadow) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
newInsertionPoint = shadow->DistributeSingleNode(aElement);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowRoot::ContentAppended(nsIDocument* aDocument,
|
|
|
|
nsIContent* aContainer,
|
|
|
|
nsIContent* aFirstNewContent)
|
|
|
|
{
|
|
|
|
for (nsIContent* content = aFirstNewContent;
|
|
|
|
content;
|
|
|
|
content = content->GetNextSibling()) {
|
|
|
|
ContentInserted(aDocument, aContainer, aFirstNewContent);
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowRoot::ContentInserted(nsIDocument* aDocument,
|
|
|
|
nsIContent* aContainer,
|
2017-07-27 16:49:52 +03:00
|
|
|
nsIContent* aChild)
|
2013-12-02 14:26:12 +04:00
|
|
|
{
|
|
|
|
if (mInsertionPointChanged) {
|
|
|
|
DistributeAllNodes();
|
|
|
|
mInsertionPointChanged = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2017-10-18 17:03:41 +03:00
|
|
|
// Add insertion point to destination insertion points of fallback content.
|
|
|
|
if (nsContentUtils::IsContentInsertionPoint(aContainer)) {
|
|
|
|
HTMLContentElement* content = HTMLContentElement::FromContent(aContainer);
|
|
|
|
if (content && content->MatchedNodes().IsEmpty()) {
|
|
|
|
aChild->DestInsertionPoints().AppendElement(aContainer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-02 14:26:12 +04:00
|
|
|
// Watch for new nodes added to the pool because the node
|
|
|
|
// may need to be added to an insertion point.
|
2017-10-18 16:02:16 +03:00
|
|
|
if (IsPooledNode(aChild)) {
|
2017-10-18 17:03:41 +03:00
|
|
|
auto* insertionPoint = DistributeSingleNode(aChild);
|
|
|
|
while (insertionPoint) {
|
|
|
|
// 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.
|
|
|
|
auto* parentShadow = insertionPoint->GetParent()->GetShadowRoot();
|
|
|
|
if (!parentShadow) {
|
|
|
|
break;
|
2014-05-22 10:11:53 +04:00
|
|
|
}
|
|
|
|
|
2017-10-18 17:03:41 +03:00
|
|
|
insertionPoint = parentShadow->DistributeSingleNode(aChild);
|
|
|
|
}
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
ShadowRoot::ContentRemoved(nsIDocument* aDocument,
|
|
|
|
nsIContent* aContainer,
|
|
|
|
nsIContent* aChild,
|
|
|
|
nsIContent* aPreviousSibling)
|
|
|
|
{
|
|
|
|
if (mInsertionPointChanged) {
|
|
|
|
DistributeAllNodes();
|
|
|
|
mInsertionPointChanged = false;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2014-05-22 10:11:53 +04:00
|
|
|
// Clear destination insertion points for removed
|
|
|
|
// fallback content.
|
|
|
|
if (nsContentUtils::IsContentInsertionPoint(aContainer)) {
|
2016-11-23 06:41:51 +03:00
|
|
|
HTMLContentElement* content = HTMLContentElement::FromContent(aContainer);
|
2017-10-12 05:19:10 +03:00
|
|
|
if (content && content->MatchedNodes().IsEmpty()) {
|
2014-05-22 10:11:53 +04:00
|
|
|
aChild->DestInsertionPoints().Clear();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-12-02 14:26:12 +04:00
|
|
|
// Watch for node that is removed from the pool because
|
|
|
|
// it may need to be removed from an insertion point.
|
2017-10-18 16:02:16 +03:00
|
|
|
if (IsPooledNode(aChild)) {
|
2017-10-18 17:03:41 +03:00
|
|
|
auto* insertionPoint = RemoveDistributedNode(aChild);
|
|
|
|
while (insertionPoint) {
|
|
|
|
// 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.
|
|
|
|
auto* parentShadow = insertionPoint->GetParent()->GetShadowRoot();
|
|
|
|
if (!parentShadow) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
insertionPoint = parentShadow->RemoveDistributedNode(aChild);
|
|
|
|
}
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-07-07 04:26:29 +03:00
|
|
|
nsresult
|
2017-04-20 22:57:48 +03:00
|
|
|
ShadowRoot::Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult,
|
|
|
|
bool aPreallocateChildren) const
|
2015-07-07 04:26:29 +03:00
|
|
|
{
|
|
|
|
*aResult = nullptr;
|
|
|
|
return NS_ERROR_DOM_DATA_CLONE_ERR;
|
|
|
|
}
|
|
|
|
|
2014-04-25 20:49:00 +04:00
|
|
|
NS_IMPL_CYCLE_COLLECTION_INHERITED(ShadowRootStyleSheetList, StyleSheetList,
|
|
|
|
mShadowRoot)
|
2013-12-02 14:26:12 +04:00
|
|
|
|
2017-08-30 02:02:48 +03:00
|
|
|
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(ShadowRootStyleSheetList)
|
2014-04-12 12:18:54 +04:00
|
|
|
NS_INTERFACE_MAP_END_INHERITING(StyleSheetList)
|
2013-12-02 14:26:12 +04:00
|
|
|
|
2014-04-12 12:18:54 +04:00
|
|
|
NS_IMPL_ADDREF_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
|
|
|
|
NS_IMPL_RELEASE_INHERITED(ShadowRootStyleSheetList, StyleSheetList)
|
2013-12-02 14:26:12 +04:00
|
|
|
|
|
|
|
ShadowRootStyleSheetList::ShadowRootStyleSheetList(ShadowRoot* aShadowRoot)
|
|
|
|
: mShadowRoot(aShadowRoot)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
ShadowRootStyleSheetList::~ShadowRootStyleSheetList()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-10-14 14:25:38 +03:00
|
|
|
StyleSheet*
|
2014-04-12 12:18:54 +04:00
|
|
|
ShadowRootStyleSheetList::IndexedGetter(uint32_t aIndex, bool& aFound)
|
2013-12-02 14:26:12 +04:00
|
|
|
{
|
2014-06-19 11:02:56 +04:00
|
|
|
aFound = aIndex < mShadowRoot->mProtoBinding->SheetCount();
|
|
|
|
if (!aFound) {
|
2014-04-12 12:15:59 +04:00
|
|
|
return nullptr;
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
2016-10-14 14:25:38 +03:00
|
|
|
return mShadowRoot->mProtoBinding->StyleSheetAt(aIndex);
|
2014-04-12 12:15:59 +04:00
|
|
|
}
|
|
|
|
|
2014-04-12 12:18:54 +04:00
|
|
|
uint32_t
|
|
|
|
ShadowRootStyleSheetList::Length()
|
2013-12-02 14:26:12 +04:00
|
|
|
{
|
2014-06-19 11:02:56 +04:00
|
|
|
return mShadowRoot->mProtoBinding->SheetCount();
|
2013-12-02 14:26:12 +04:00
|
|
|
}
|
|
|
|
|