mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-03 14:28:39 +09:00
Support CSS shadow parts
This commit is contained in:
parent
667a753448
commit
a852c0a86a
10 changed files with 1882 additions and 29 deletions
|
|
@ -404,6 +404,22 @@ RuleHash::AppendUniversalRule(const RuleSelectorPair& aRuleInfo)
|
|||
RuleValue(aRuleInfo, mRuleCount++, mQuirksMode));
|
||||
}
|
||||
|
||||
static bool
|
||||
SelectorContainsPseudoClass(nsCSSSelector* aSelector, CSSPseudoClassType aType)
|
||||
{
|
||||
for (nsCSSSelector* selector = aSelector; selector; selector = selector->mNext) {
|
||||
for (nsPseudoClassList* pseudoClass = selector->mPseudoClassList;
|
||||
pseudoClass;
|
||||
pseudoClass = pseudoClass->mNext) {
|
||||
if (pseudoClass->mType == aType) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo)
|
||||
{
|
||||
|
|
@ -411,7 +427,10 @@ RuleHash::AppendRule(const RuleSelectorPair& aRuleInfo)
|
|||
if (selector->IsPseudoElement()) {
|
||||
selector = selector->mNext;
|
||||
}
|
||||
if (nullptr != selector->mIDList) {
|
||||
if (SelectorContainsPseudoClass(selector, CSSPseudoClassType::part)) {
|
||||
AppendUniversalRule(aRuleInfo);
|
||||
RULE_HASH_STAT_INCREMENT(mUniversalSelectors);
|
||||
} else if (nullptr != selector->mIDList) {
|
||||
AppendRuleToTable(&mIdTable, selector->mIDList->mAtom, aRuleInfo);
|
||||
RULE_HASH_STAT_INCREMENT(mIdSelectors);
|
||||
} else if (nullptr != selector->mClassList) {
|
||||
|
|
@ -452,6 +471,10 @@ LookForTargetPseudo(nsCSSSelector* aSelector,
|
|||
nsRestyleHint* possibleChange)
|
||||
{
|
||||
if (aMatchContext->mOnlyMatchHostPseudo) {
|
||||
if (SelectorContainsPseudoClass(aSelector, CSSPseudoClassType::part)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
while (aSelector && aSelector->mNext != nullptr) {
|
||||
aSelector = aSelector->mNext;
|
||||
}
|
||||
|
|
@ -502,7 +525,8 @@ ContentEnumFunc(const RuleValue& value,
|
|||
data->mTreeMatchContext.SetHaveRelevantLink();
|
||||
}
|
||||
// XXX: Ignore the ancestor filter if we're testing the assigned slot.
|
||||
bool useAncestorFilter = !(data->mTreeMatchContext.mForAssignedSlot);
|
||||
bool useAncestorFilter = !(data->mTreeMatchContext.mForAssignedSlot ||
|
||||
data->mTreeMatchContext.mOnlyMatchHostPseudo);
|
||||
if (useAncestorFilter && ancestorFilter &&
|
||||
!ancestorFilter->MightHaveMatchingAncestor<RuleValue::eMaxAncestorHashes>(
|
||||
value.mAncestorSelectorHashes)) {
|
||||
|
|
@ -556,9 +580,18 @@ ContentEnumFunc(const RuleValue& value,
|
|||
nodeContext,
|
||||
data->mTreeMatchContext,
|
||||
selectorFlags)) {
|
||||
Element* treeMatchStart = data->mElement;
|
||||
if (SelectorContainsPseudoClass(selector, CSSPseudoClassType::part)) {
|
||||
nsIContent* partHost = data->mElement->GetContainingShadowHost();
|
||||
if (!partHost || !partHost->IsElement()) {
|
||||
return;
|
||||
}
|
||||
treeMatchStart = partHost->AsElement();
|
||||
}
|
||||
|
||||
nsCSSSelector* next = selector->mNext;
|
||||
if (!next || nsCSSRuleUtils::SelectorMatchesTree(
|
||||
data->mElement,
|
||||
treeMatchStart,
|
||||
next,
|
||||
data->mTreeMatchContext,
|
||||
nodeContext.mIsRelevantLink ? SelectorMatchesTreeFlags(0)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue