mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-07 15:57:31 +09:00
parent
af22b5cba5
commit
d9112daf48
7 changed files with 27 additions and 116 deletions
|
|
@ -17,48 +17,6 @@
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
namespace dom {
|
namespace dom {
|
||||||
|
|
||||||
class MatchedNodes {
|
|
||||||
public:
|
|
||||||
explicit MatchedNodes()
|
|
||||||
: mIsContentElement(false), mChildrenElement(nullptr) {}
|
|
||||||
explicit MatchedNodes(XBLChildrenElement* aInsertionPoint)
|
|
||||||
: mIsContentElement(false), mChildrenElement(aInsertionPoint) {}
|
|
||||||
|
|
||||||
uint32_t Length() const
|
|
||||||
{
|
|
||||||
return mChildrenElement ? mChildrenElement->InsertedChildrenLength() : 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
nsIContent* operator[](int32_t aIndex) const
|
|
||||||
{
|
|
||||||
return mChildrenElement ? mChildrenElement->InsertedChild(aIndex) : nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool IsEmpty() const
|
|
||||||
{
|
|
||||||
return mChildrenElement && !mChildrenElement->HasInsertedChildren();
|
|
||||||
}
|
|
||||||
protected:
|
|
||||||
// Leftover from Shadow DOM v0.
|
|
||||||
bool mIsContentElement;
|
|
||||||
union {
|
|
||||||
XBLChildrenElement* mChildrenElement;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
static inline MatchedNodes
|
|
||||||
GetMatchedNodesForPoint(nsIContent* aContent)
|
|
||||||
{
|
|
||||||
if (aContent->NodeInfo()->Equals(nsGkAtoms::children, kNameSpaceID_XBL)) {
|
|
||||||
// XBL case
|
|
||||||
return MatchedNodes(static_cast<XBLChildrenElement*>(aContent));
|
|
||||||
}
|
|
||||||
|
|
||||||
return MatchedNodes();
|
|
||||||
// Web components case
|
|
||||||
// XXX handle <slot> element?
|
|
||||||
}
|
|
||||||
|
|
||||||
ExplicitChildIterator::ExplicitChildIterator(const nsIContent* aParent,
|
ExplicitChildIterator::ExplicitChildIterator(const nsIContent* aParent,
|
||||||
bool aStartAtBeginning)
|
bool aStartAtBeginning)
|
||||||
: mParent(aParent),
|
: mParent(aParent),
|
||||||
|
|
@ -88,16 +46,18 @@ ExplicitChildIterator::GetNextChild()
|
||||||
return mChild;
|
return mChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
MatchedNodes assignedChildren = GetMatchedNodesForPoint(mChild);
|
MOZ_ASSERT(mChild->IsActiveChildrenElement());
|
||||||
if (mIndexInInserted < assignedChildren.Length()) {
|
auto* childrenElement =
|
||||||
return assignedChildren[mIndexInInserted++];
|
static_cast<XBLChildrenElement*>(mChild);
|
||||||
|
if (mIndexInInserted < childrenElement->InsertedChildrenLength()) {
|
||||||
|
return childrenElement->InsertedChild(mIndexInInserted++);
|
||||||
}
|
}
|
||||||
mIndexInInserted = 0;
|
mIndexInInserted = 0;
|
||||||
mChild = mChild->GetNextSibling();
|
mChild = mChild->GetNextSibling();
|
||||||
} else if (mDefaultChild) {
|
} else if (mDefaultChild) {
|
||||||
// If we're already in default content, check if there are more nodes there
|
// If we're already in default content, check if there are more nodes there
|
||||||
MOZ_ASSERT(mChild);
|
MOZ_ASSERT(mChild);
|
||||||
MOZ_ASSERT(nsContentUtils::IsContentInsertionPoint(mChild));
|
MOZ_ASSERT(mChild->IsActiveChildrenElement());
|
||||||
|
|
||||||
mDefaultChild = mDefaultChild->GetNextSibling();
|
mDefaultChild = mDefaultChild->GetNextSibling();
|
||||||
if (mDefaultChild) {
|
if (mDefaultChild) {
|
||||||
|
|
@ -128,15 +88,16 @@ ExplicitChildIterator::GetNextChild()
|
||||||
// Iterate until we find a non-insertion point, or an insertion point with
|
// Iterate until we find a non-insertion point, or an insertion point with
|
||||||
// content.
|
// content.
|
||||||
while (mChild) {
|
while (mChild) {
|
||||||
if (nsContentUtils::IsContentInsertionPoint(mChild)) {
|
if (mChild->IsActiveChildrenElement()) {
|
||||||
// If the current child being iterated is a content insertion point
|
// If the current child being iterated is a content insertion point
|
||||||
// then the iterator needs to return the nodes distributed into
|
// then the iterator needs to return the nodes distributed into
|
||||||
// the content insertion point.
|
// the content insertion point.
|
||||||
MatchedNodes assignedChildren = GetMatchedNodesForPoint(mChild);
|
auto* childrenElement =
|
||||||
if (!assignedChildren.IsEmpty()) {
|
static_cast<XBLChildrenElement*>(mChild);
|
||||||
|
if (childrenElement->HasInsertedChildren()) {
|
||||||
// Iterate through elements projected on insertion point.
|
// Iterate through elements projected on insertion point.
|
||||||
mIndexInInserted = 1;
|
mIndexInInserted = 1;
|
||||||
return assignedChildren[0];
|
return childrenElement->InsertedChild(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Insertion points inside fallback/default content
|
// Insertion points inside fallback/default content
|
||||||
|
|
@ -204,7 +165,7 @@ ExplicitChildIterator::Seek(const nsIContent* aChildToFind)
|
||||||
mIndexInInserted = 0;
|
mIndexInInserted = 0;
|
||||||
mDefaultChild = nullptr;
|
mDefaultChild = nullptr;
|
||||||
mIsFirst = false;
|
mIsFirst = false;
|
||||||
MOZ_ASSERT(!nsContentUtils::IsContentInsertionPoint(mChild));
|
MOZ_ASSERT(!mChild->IsActiveChildrenElement());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -227,8 +188,9 @@ ExplicitChildIterator::Get() const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mIndexInInserted) {
|
if (mIndexInInserted) {
|
||||||
MatchedNodes assignedChildren = GetMatchedNodesForPoint(mChild);
|
MOZ_ASSERT(mChild->IsActiveChildrenElement());
|
||||||
return assignedChildren[mIndexInInserted - 1];
|
auto* childrenElement = static_cast<XBLChildrenElement*>(mChild);
|
||||||
|
return childrenElement->InsertedChild(mIndexInInserted - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
return mDefaultChild ? mDefaultChild : mChild;
|
return mDefaultChild ? mDefaultChild : mChild;
|
||||||
|
|
@ -255,9 +217,10 @@ ExplicitChildIterator::GetPreviousChild()
|
||||||
|
|
||||||
// NB: mIndexInInserted points one past the last returned child so we need
|
// NB: mIndexInInserted points one past the last returned child so we need
|
||||||
// to look *two* indices back in order to return the previous child.
|
// to look *two* indices back in order to return the previous child.
|
||||||
MatchedNodes assignedChildren = GetMatchedNodesForPoint(mChild);
|
MOZ_ASSERT(mChild->IsActiveChildrenElement());
|
||||||
|
auto* childrenElement = static_cast<XBLChildrenElement*>(mChild);
|
||||||
if (--mIndexInInserted) {
|
if (--mIndexInInserted) {
|
||||||
return assignedChildren[mIndexInInserted - 1];
|
return childrenElement->InsertedChild(mIndexInInserted - 1);
|
||||||
}
|
}
|
||||||
mChild = mChild->GetPreviousSibling();
|
mChild = mChild->GetPreviousSibling();
|
||||||
} else if (mDefaultChild) {
|
} else if (mDefaultChild) {
|
||||||
|
|
@ -291,14 +254,14 @@ ExplicitChildIterator::GetPreviousChild()
|
||||||
// Iterate until we find a non-insertion point, or an insertion point with
|
// Iterate until we find a non-insertion point, or an insertion point with
|
||||||
// content.
|
// content.
|
||||||
while (mChild) {
|
while (mChild) {
|
||||||
if (nsContentUtils::IsContentInsertionPoint(mChild)) {
|
if (mChild->IsActiveChildrenElement()) {
|
||||||
// If the current child being iterated is a content insertion point
|
// If the current child being iterated is a content insertion point
|
||||||
// then the iterator needs to return the nodes distributed into
|
// then the iterator needs to return the nodes distributed into
|
||||||
// the content insertion point.
|
// the content insertion point.
|
||||||
MatchedNodes assignedChildren = GetMatchedNodesForPoint(mChild);
|
auto* childrenElement = static_cast<XBLChildrenElement*>(mChild);
|
||||||
if (!assignedChildren.IsEmpty()) {
|
if (childrenElement->HasInsertedChildren()) {
|
||||||
mIndexInInserted = assignedChildren.Length();
|
mIndexInInserted = childrenElement->InsertedChildrenLength();
|
||||||
return assignedChildren[mIndexInInserted - 1];
|
return childrenElement->InsertedChild(mIndexInInserted - 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
mDefaultChild = mChild->GetLastChild();
|
mDefaultChild = mChild->GetLastChild();
|
||||||
|
|
|
||||||
|
|
@ -533,33 +533,6 @@ ShadowRoot::StyleSheets()
|
||||||
return mStyleSheetList;
|
return mStyleSheetList;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 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.
|
|
||||||
*/
|
|
||||||
bool
|
|
||||||
ShadowRoot::IsPooledNode(nsIContent* aContent) const
|
|
||||||
{
|
|
||||||
if (nsContentUtils::IsContentInsertionPoint(aContent)) {
|
|
||||||
// Insertion points never end up in the pool.
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
auto* host = GetHost();
|
|
||||||
auto* container = aContent->GetParent();
|
|
||||||
if (container == host && !aContent->IsRootOfAnonymousSubtree()) {
|
|
||||||
// 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.
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void
|
void
|
||||||
ShadowRoot::AttributeChanged(nsIDocument* aDocument,
|
ShadowRoot::AttributeChanged(nsIDocument* aDocument,
|
||||||
Element* aElement,
|
Element* aElement,
|
||||||
|
|
|
||||||
|
|
@ -7017,19 +7017,6 @@ nsContentUtils::GetHTMLEditor(nsPresContext* aPresContext)
|
||||||
return editor;
|
return editor;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
|
||||||
nsContentUtils::IsContentInsertionPoint(nsIContent* aContent)
|
|
||||||
{
|
|
||||||
// Check if the content is a XBL insertion point.
|
|
||||||
if (aContent->IsActiveChildrenElement()) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Check if the content is a web components content insertion point.
|
|
||||||
// XXX handle <slot>?
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
// static
|
// static
|
||||||
bool
|
bool
|
||||||
nsContentUtils::HasDistributedChildren(nsIContent* aContent)
|
nsContentUtils::HasDistributedChildren(nsIContent* aContent)
|
||||||
|
|
|
||||||
|
|
@ -2414,18 +2414,6 @@ public:
|
||||||
*/
|
*/
|
||||||
static mozilla::LogModule* DOMDumpLog();
|
static mozilla::LogModule* DOMDumpLog();
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns whether a content is an insertion point for XBL
|
|
||||||
* bindings or web components ShadowRoot. In web components,
|
|
||||||
* this corresponds to a <content> element that participates
|
|
||||||
* in node distribution. In XBL this corresponds to an
|
|
||||||
* <xbl:children> element in anonymous content.
|
|
||||||
*
|
|
||||||
* @param aContent The content to test for being an insertion point.
|
|
||||||
*/
|
|
||||||
static bool IsContentInsertionPoint(nsIContent* aContent);
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns whether the children of the provided content are
|
* Returns whether the children of the provided content are
|
||||||
* nodes that are distributed to Shadow DOM insertion points.
|
* nodes that are distributed to Shadow DOM insertion points.
|
||||||
|
|
|
||||||
|
|
@ -3489,7 +3489,7 @@ ElementRestyler::RestyleUndisplayedNodes(nsRestyleHint aChildRestyleHint,
|
||||||
// not have a frame and would not otherwise be pushed as an ancestor.
|
// not have a frame and would not otherwise be pushed as an ancestor.
|
||||||
nsIContent* parent = undisplayed->mContent->GetParent();
|
nsIContent* parent = undisplayed->mContent->GetParent();
|
||||||
TreeMatchContext::AutoAncestorPusher insertionPointPusher(mTreeMatchContext);
|
TreeMatchContext::AutoAncestorPusher insertionPointPusher(mTreeMatchContext);
|
||||||
if (parent && nsContentUtils::IsContentInsertionPoint(parent)) {
|
if (parent && parent->IsActiveChildrenElement()) {
|
||||||
insertionPointPusher.PushAncestorAndStyleScope(parent);
|
insertionPointPusher.PushAncestorAndStyleScope(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -3715,7 +3715,7 @@ ElementRestyler::RestyleContentChildren(nsIFrame* aParent,
|
||||||
// nsPageFrame that does not have a content.
|
// nsPageFrame that does not have a content.
|
||||||
nsIContent* parent = child->GetContent() ? child->GetContent()->GetParent() : nullptr;
|
nsIContent* parent = child->GetContent() ? child->GetContent()->GetParent() : nullptr;
|
||||||
TreeMatchContext::AutoAncestorPusher insertionPointPusher(mTreeMatchContext);
|
TreeMatchContext::AutoAncestorPusher insertionPointPusher(mTreeMatchContext);
|
||||||
if (parent && nsContentUtils::IsContentInsertionPoint(parent)) {
|
if (parent && parent->IsActiveChildrenElement()) {
|
||||||
insertionPointPusher.PushAncestorAndStyleScope(parent);
|
insertionPointPusher.PushAncestorAndStyleScope(parent);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3821,7 +3821,7 @@ nsCSSFrameConstructor::ConstructFrameFromItemInternal(FrameConstructionItem& aIt
|
||||||
// AutoDisplayContentsAncestorPusher above.)
|
// AutoDisplayContentsAncestorPusher above.)
|
||||||
TreeMatchContext::AutoAncestorPusher
|
TreeMatchContext::AutoAncestorPusher
|
||||||
insertionPointPusher(aState.mTreeMatchContext);
|
insertionPointPusher(aState.mTreeMatchContext);
|
||||||
if (adcp.IsEmpty() && parent && nsContentUtils::IsContentInsertionPoint(parent)) {
|
if (adcp.IsEmpty() && parent && parent->IsActiveChildrenElement()) {
|
||||||
if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
|
if (aState.mTreeMatchContext.mAncestorFilter.HasFilter()) {
|
||||||
insertionPointPusher.PushAncestorAndStyleScope(parent);
|
insertionPointPusher.PushAncestorAndStyleScope(parent);
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
|
|
@ -611,7 +611,7 @@ nsFrameManagerBase::UndisplayedMap::GetApplicableParent(nsIContent* aParent)
|
||||||
// be a <xbl:children> element) but the parent in the frame tree would be the
|
// be a <xbl:children> element) but the parent in the frame tree would be the
|
||||||
// insertion parent (parent of the <xbl:children> element). Here the children
|
// insertion parent (parent of the <xbl:children> element). Here the children
|
||||||
// elements are normalized to the insertion parent to correct for the mismatch.
|
// elements are normalized to the insertion parent to correct for the mismatch.
|
||||||
if (aParent && nsContentUtils::IsContentInsertionPoint(aParent)) {
|
if (aParent && aParent->IsActiveChildrenElement()) {
|
||||||
return aParent->GetParent();
|
return aParent->GetParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue