mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-10-26 09:07:30 +09:00
Issue #2135 - Bug 1455891/Part 1: Improve StyleChildrenIterator
This commit is contained in:
parent
588c2154a5
commit
263b719ef8
2 changed files with 51 additions and 34 deletions
|
|
@ -536,23 +536,5 @@ StyleChildrenIterator::IsNeeded(const Element* aElement)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
nsIContent*
|
|
||||||
StyleChildrenIterator::GetNextChild()
|
|
||||||
{
|
|
||||||
while (nsIContent* child = AllChildrenIterator::GetNextChild()) {
|
|
||||||
if (IsNativeAnonymousImplementationOfPseudoElement(child)) {
|
|
||||||
// Skip any native-anonymous children that are used to implement pseudo-
|
|
||||||
// elements. These match pseudo-element selectors instead of being
|
|
||||||
// considered a child of their host, and thus the style system needs to
|
|
||||||
// handle them separately.
|
|
||||||
} else {
|
|
||||||
return child;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
} // namespace mozilla
|
} // namespace mozilla
|
||||||
|
|
|
||||||
|
|
@ -7,6 +7,8 @@
|
||||||
#define ChildIterator_h
|
#define ChildIterator_h
|
||||||
|
|
||||||
#include "nsIContent.h"
|
#include "nsIContent.h"
|
||||||
|
#include "nsIContentInlines.h"
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Iterates over the children on a node. If a child is an insertion point,
|
* Iterates over the children on a node. If a child is an insertion point,
|
||||||
|
|
@ -17,9 +19,6 @@
|
||||||
* binding's <xbl:content> element.
|
* binding's <xbl:content> element.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <stdint.h>
|
|
||||||
#include "nsAutoPtr.h"
|
|
||||||
|
|
||||||
class nsIContent;
|
class nsIContent;
|
||||||
|
|
||||||
namespace mozilla {
|
namespace mozilla {
|
||||||
|
|
@ -189,20 +188,33 @@ protected:
|
||||||
class AllChildrenIterator : private FlattenedChildIterator
|
class AllChildrenIterator : private FlattenedChildIterator
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
AllChildrenIterator(const nsIContent* aNode, uint32_t aFlags,
|
AllChildrenIterator(const nsIContent* aNode,
|
||||||
bool aStartAtBeginning = true) :
|
uint32_t aFlags,
|
||||||
FlattenedChildIterator(aNode, aFlags, aStartAtBeginning),
|
bool aStartAtBeginning = true)
|
||||||
mAnonKidsIdx(aStartAtBeginning ? UINT32_MAX : 0),
|
: FlattenedChildIterator(aNode, aFlags, aStartAtBeginning)
|
||||||
mFlags(aFlags), mPhase(aStartAtBeginning ? eAtBegin : eAtEnd) { }
|
, mAnonKidsIdx(aStartAtBeginning ? UINT32_MAX : 0)
|
||||||
|
, mFlags(aFlags), mPhase(aStartAtBeginning ? eAtBegin : eAtEnd)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
AllChildrenIterator(AllChildrenIterator&& aOther)
|
AllChildrenIterator(AllChildrenIterator&& aOther)
|
||||||
: FlattenedChildIterator(Move(aOther)),
|
: FlattenedChildIterator(Move(aOther))
|
||||||
mAnonKids(Move(aOther.mAnonKids)), mAnonKidsIdx(aOther.mAnonKidsIdx),
|
, mAnonKids(Move(aOther.mAnonKids))
|
||||||
mFlags(aOther.mFlags), mPhase(aOther.mPhase)
|
, mAnonKidsIdx(aOther.mAnonKidsIdx)
|
||||||
|
, mFlags(aOther.mFlags)
|
||||||
|
, mPhase(aOther.mPhase)
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
, mMutationGuard(aOther.mMutationGuard)
|
, mMutationGuard(aOther.mMutationGuard)
|
||||||
#endif
|
#endif
|
||||||
{}
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
AllChildrenIterator& operator=(AllChildrenIterator&& aOther)
|
||||||
|
{
|
||||||
|
this->~AllChildrenIterator();
|
||||||
|
new (this)AllChildrenIterator(Move(aOther));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
~AllChildrenIterator() { MOZ_ASSERT(!mMutationGuard.Mutated(0)); }
|
~AllChildrenIterator() { MOZ_ASSERT(!mMutationGuard.Mutated(0)); }
|
||||||
|
|
@ -268,20 +280,43 @@ private:
|
||||||
*/
|
*/
|
||||||
class StyleChildrenIterator : private AllChildrenIterator {
|
class StyleChildrenIterator : private AllChildrenIterator {
|
||||||
public:
|
public:
|
||||||
explicit StyleChildrenIterator(const nsIContent* aContent)
|
StyleChildrenIterator(const nsIContent* aContent,
|
||||||
|
bool aStartAtBeginning = true)
|
||||||
: AllChildrenIterator(aContent,
|
: AllChildrenIterator(aContent,
|
||||||
nsIContent::eAllChildren |
|
nsIContent::eAllChildren |
|
||||||
nsIContent::eSkipDocumentLevelNativeAnonymousContent)
|
nsIContent::eSkipDocumentLevelNativeAnonymousContent,
|
||||||
|
aStartAtBeginning)
|
||||||
{
|
{
|
||||||
MOZ_COUNT_CTOR(StyleChildrenIterator);
|
MOZ_COUNT_CTOR(StyleChildrenIterator);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StyleChildrenIterator(StyleChildrenIterator&& aOther)
|
||||||
|
: AllChildrenIterator(Move(aOther))
|
||||||
|
{
|
||||||
|
MOZ_COUNT_CTOR(StyleChildrenIterator);
|
||||||
|
}
|
||||||
|
|
||||||
|
StyleChildrenIterator& operator=(StyleChildrenIterator&& aOther)
|
||||||
|
{
|
||||||
|
AllChildrenIterator::operator=(Move(aOther));
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
~StyleChildrenIterator() { MOZ_COUNT_DTOR(StyleChildrenIterator); }
|
~StyleChildrenIterator() { MOZ_COUNT_DTOR(StyleChildrenIterator); }
|
||||||
|
|
||||||
nsIContent* GetNextChild();
|
static nsIContent* GetParent(const nsIContent& aContent)
|
||||||
|
{
|
||||||
|
nsINode* node = aContent.GetFlattenedTreeParentNodeForStyle();
|
||||||
|
return node && node->IsContent() ? node->AsContent() : nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
// Returns true if we cannot find all the children we need to style by
|
// Returns true if we cannot find all the children we need to style by
|
||||||
// traversing the siblings of the first child.
|
// traversing the siblings of the first child.
|
||||||
static bool IsNeeded(const Element* aParent);
|
static bool IsNeeded(const Element* aParent);
|
||||||
|
|
||||||
|
using AllChildrenIterator::GetNextChild;
|
||||||
|
using AllChildrenIterator::GetPreviousChild;
|
||||||
|
using AllChildrenIterator::Seek;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // namespace dom
|
} // namespace dom
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue