summaryrefslogtreecommitdiff
path: root/layout
diff options
context:
space:
mode:
authorFranklinDM <mrmineshafter17@gmail.com>2023-02-19 21:16:07 +0800
committerFranklinDM <mrmineshafter17@gmail.com>2023-02-21 22:46:04 +0800
commitae59eb00e5d6a7019f6542288de75474e3773f19 (patch)
tree1f9f9fa2032048beb21aaf779d25f5b4d98ab43e /layout
parent9d9d93381e03157413f0a18fc544afafad4fff70 (diff)
downloaduxp-ae59eb00e5d6a7019f6542288de75474e3773f19.tar.gz
Issue #1823 - Ensure :host() and :host-context() are given proper weights
Diffstat (limited to 'layout')
-rw-r--r--layout/style/StyleRule.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp
index 6b514e5beb..815c6f96cc 100644
--- a/layout/style/StyleRule.cpp
+++ b/layout/style/StyleRule.cpp
@@ -533,22 +533,28 @@ int32_t nsCSSSelector::CalcWeightWithoutNegations() const
while (nullptr != plist) {
int pseudoClassWeight = 0x000100;
// XXX(franklindm): Check for correctness.
- // The specificity of the :where() pseudo-class is always zero.
- if (plist->mType == CSSPseudoClassType::where) {
- pseudoClassWeight = 0;
- } else if (nsCSSPseudoClasses::HasForgivingSelectorListArg(plist->mType)) {
- // The specificity of the :is() pseudo-class is replaced by the
- // specificity of its most specific argument.
- pseudoClassWeight = 0;
- nsCSSSelectorList* slist = plist->u.mSelectorList;
- while (slist) {
- int currentWeight = slist->mSelectors ?
- slist->mWeight :
- 0;
- if (currentWeight > pseudoClassWeight) {
- pseudoClassWeight = currentWeight;
+ if (nsCSSPseudoClasses::HasSelectorListArg(plist->mType) &&
+ plist->mType != CSSPseudoClassType::mozAny) {
+ // The specificity of :host() and :host-context is that of a
+ // pseudo-class, plus the specificity of its argument.
+ if (plist->mType != CSSPseudoClassType::host &&
+ plist->mType != CSSPseudoClassType::hostContext) {
+ pseudoClassWeight = 0;
+ }
+ // The specificity of the :where() pseudo-class is always zero.
+ if (plist->mType != CSSPseudoClassType::where) {
+ // The specificity of the :is() pseudo-class is replaced by the
+ // specificity of its most specific argument.
+ nsCSSSelectorList* slist = plist->u.mSelectorList;
+ while (slist) {
+ int currentWeight = slist->mSelectors ?
+ slist->mWeight :
+ 0;
+ if (currentWeight > pseudoClassWeight) {
+ pseudoClassWeight = currentWeight;
+ }
+ slist = slist->mNext;
}
- slist = slist->mNext;
}
}
weight += pseudoClassWeight;