mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-20 15:27:32 +09:00
Simplify class selector result collection
This commit is contained in:
parent
77cfca739d
commit
b08f544172
1 changed files with 3 additions and 11 deletions
|
|
@ -2927,12 +2927,11 @@ FindMatchingElementsWithId(const nsAString& aId, nsINode* aRoot,
|
||||||
// Actually find elements matching aSelectorList (which must not be
|
// Actually find elements matching aSelectorList (which must not be
|
||||||
// null) and which are descendants of aRoot and put them in aList. If
|
// null) and which are descendants of aRoot and put them in aList. If
|
||||||
// onlyFirstMatch, then stop once the first one is found.
|
// onlyFirstMatch, then stop once the first one is found.
|
||||||
template<bool onlyFirstMatch, class Collector, class T>
|
template<bool onlyFirstMatch, class T>
|
||||||
static void
|
static void
|
||||||
FindMatchingElementsWithClass(nsINode* aRoot, nsIAtom* aClass,
|
FindMatchingElementsWithClass(nsINode* aRoot, nsIAtom* aClass,
|
||||||
nsCaseTreatment aCaseTreatment, T& aList)
|
nsCaseTreatment aCaseTreatment, T& aList)
|
||||||
{
|
{
|
||||||
Collector results;
|
|
||||||
for (nsIContent* cur = aRoot->GetFirstChild(); cur;
|
for (nsIContent* cur = aRoot->GetFirstChild(); cur;
|
||||||
cur = cur->GetNextNode(aRoot)) {
|
cur = cur->GetNextNode(aRoot)) {
|
||||||
if (!cur->IsElement()) {
|
if (!cur->IsElement()) {
|
||||||
|
|
@ -2944,14 +2943,7 @@ FindMatchingElementsWithClass(nsINode* aRoot, nsIAtom* aClass,
|
||||||
aList.AppendElement(cur->AsElement());
|
aList.AppendElement(cur->AsElement());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
results.AppendElement(cur->AsElement());
|
aList.AppendElement(cur->AsElement());
|
||||||
}
|
|
||||||
}
|
|
||||||
const uint32_t len = results.Length();
|
|
||||||
if (len) {
|
|
||||||
aList.SetCapacity(len);
|
|
||||||
for (uint32_t i = 0; i < len; ++i) {
|
|
||||||
aList.AppendElement(results.ElementAt(i));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -2975,7 +2967,7 @@ FindMatchingElements(nsINode* aRoot, nsCSSSelectorList* aSelectorList, T &aList,
|
||||||
nsCaseTreatment caseTreatment =
|
nsCaseTreatment caseTreatment =
|
||||||
doc->GetCompatibilityMode() == eCompatibility_NavQuirks
|
doc->GetCompatibilityMode() == eCompatibility_NavQuirks
|
||||||
? eIgnoreCase : eCaseMatters;
|
? eIgnoreCase : eCaseMatters;
|
||||||
FindMatchingElementsWithClass<onlyFirstMatch, Collector>(
|
FindMatchingElementsWithClass<onlyFirstMatch>(
|
||||||
aRoot, selector->mClassList->mAtom, caseTreatment, aList);
|
aRoot, selector->mClassList->mAtom, caseTreatment, aList);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue