diff --git a/dom/base/ShadowRoot.h b/dom/base/ShadowRoot.h index 63535c9a06..775eaae957 100644 --- a/dom/base/ShadowRoot.h +++ b/dom/base/ShadowRoot.h @@ -108,7 +108,6 @@ public: void SetInsertionPointChanged() { mInsertionPointChanged = true; } - nsXBLBinding* GetAssociatedBinding() { return mAssociatedBinding; } void SetAssociatedBinding(nsXBLBinding* aBinding) { mAssociatedBinding = aBinding; } JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; diff --git a/dom/xbl/nsBindingManager.cpp b/dom/xbl/nsBindingManager.cpp index 8f18f112af..a2c18bcb99 100644 --- a/dom/xbl/nsBindingManager.cpp +++ b/dom/xbl/nsBindingManager.cpp @@ -30,7 +30,6 @@ #include "nsXBLPrototypeBinding.h" #include "nsXBLDocumentInfo.h" #include "mozilla/dom/XBLChildrenElement.h" -#include "mozilla/dom/ShadowRoot.h" #include "nsIStyleRuleProcessor.h" #include "nsRuleProcessorData.h" @@ -664,32 +663,13 @@ nsBindingManager::WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc, NS_ASSERTION(aData->mElement, "How did that happen?"); - // Walk the rules in shadow root for :host pseudo-class rules. - aData->mTreeMatchContext.mOnlyMatchHostPseudo = true; - aData->mElementIsFeatureless = true; - - ShadowRoot* currentShadow = aData->mElement->GetShadowRoot(); - - if (currentShadow) { - nsXBLBinding* associatedBinding = currentShadow->GetAssociatedBinding(); - if (associatedBinding) { - aData->mTreeMatchContext.mScopedRoot = aData->mElement; - associatedBinding->WalkRules(aFunc, aData); - } - } - - aData->mElementIsFeatureless = false; - aData->mTreeMatchContext.mOnlyMatchHostPseudo = false; - // Walk the binding scope chain, starting with the binding attached to our // content, up till we run out of scopes or we get cut off. nsIContent *content = aData->mElement; do { nsXBLBinding *binding = content->GetXBLBinding(); - if (binding && - // Unlike XBL, styles in the shadow root are not applied to the host. - !(content == aData->mElement && binding->IsShadowRootBinding())) { + if (binding) { aData->mTreeMatchContext.mScopedRoot = content; binding->WalkRules(aFunc, aData); // If we're not looking at our original content, allow the binding to cut @@ -722,26 +702,14 @@ nsBindingManager::WalkRules(nsIStyleRuleProcessor::EnumFunc aFunc, typedef nsTHashtable > RuleProcessorSet; static RuleProcessorSet* -GetContentSetRuleProcessors(nsTHashtable>* aContentSet, bool aOnlyWalkShadowRootRules) +GetContentSetRuleProcessors(nsTHashtable>* aContentSet) { RuleProcessorSet* set = nullptr; for (auto iter = aContentSet->Iter(); !iter.Done(); iter.Next()) { nsIContent* boundContent = iter.Get()->GetKey(); - - // If we are only walking rules for shadow root hosts, skip other types - // of bound content. - ShadowRoot *shadowRoot = boundContent->GetShadowRoot(); - if (aOnlyWalkShadowRootRules && !shadowRoot) { - return set; - } - - // Bound content may have multiple rule processors, potentially one - // for its immediate binding, and one more for each binding in the - // inheritance chain. Additionally, a bound content may host multiple - // shadow roots, each with its own rule processor. - for (nsXBLBinding *binding = boundContent->GetXBLBinding(); binding; - binding = binding->GetBaseBinding()) { + for (nsXBLBinding* binding = boundContent->GetXBLBinding(); binding; + binding = binding->GetBaseBinding()) { nsIStyleRuleProcessor* ruleProc = binding->PrototypeBinding()->GetRuleProcessor(); if (ruleProc) { @@ -750,27 +718,22 @@ GetContentSetRuleProcessors(nsTHashtable>* aContentS } set->PutEntry(ruleProc); } - - if (shadowRoot) { - binding = shadowRoot->GetAssociatedBinding(); - } - } } + } return set; } void nsBindingManager::WalkAllRules(nsIStyleRuleProcessor::EnumFunc aFunc, - ElementDependentRuleProcessorData* aData, - bool aOnlyWalkShadowRootRules) + ElementDependentRuleProcessorData* aData) { if (!mBoundContentSet) { return; } nsAutoPtr set; - set = GetContentSetRuleProcessors(mBoundContentSet, aOnlyWalkShadowRootRules); + set = GetContentSetRuleProcessors(mBoundContentSet); if (!set) { return; } @@ -781,17 +744,6 @@ nsBindingManager::WalkAllRules(nsIStyleRuleProcessor::EnumFunc aFunc, } } -// The approach in WalkAllShadowRootHostRules seems reasonable on the surface and reminds me of what is done with mScopedRoot elsewhere. But something important is missing, either here or in the code that would normally use it. - -void -nsBindingManager::WalkAllShadowRootHostRules(nsIStyleRuleProcessor::EnumFunc aFunc, - ElementDependentRuleProcessorData* aData) - { - aData->mTreeMatchContext.mOnlyMatchHostPseudo = true; - WalkAllRules(aFunc, aData, true); - aData->mTreeMatchContext.mOnlyMatchHostPseudo = false; - } - nsresult nsBindingManager::MediumFeaturesChanged(nsPresContext* aPresContext, bool* aRulesChanged) @@ -802,7 +754,7 @@ nsBindingManager::MediumFeaturesChanged(nsPresContext* aPresContext, } nsAutoPtr set; - set = GetContentSetRuleProcessors(mBoundContentSet, false); + set = GetContentSetRuleProcessors(mBoundContentSet); if (!set) { return NS_OK; } diff --git a/dom/xbl/nsBindingManager.h b/dom/xbl/nsBindingManager.h index 35d31b387a..cb15aa57f6 100644 --- a/dom/xbl/nsBindingManager.h +++ b/dom/xbl/nsBindingManager.h @@ -128,11 +128,7 @@ public: bool* aCutOffInheritance); void WalkAllRules(nsIStyleRuleProcessor::EnumFunc aFunc, - ElementDependentRuleProcessorData* aData, - bool aOnlyWalkShadowRootRules = false); - - void WalkAllShadowRootHostRules(nsIStyleRuleProcessor::EnumFunc aFunc, - ElementDependentRuleProcessorData* aData); + ElementDependentRuleProcessorData* aData); /** * Do any processing that needs to happen as a result of a change in * the characteristics of the medium, and return whether this rule diff --git a/dom/xbl/nsXBLBinding.h b/dom/xbl/nsXBLBinding.h index a61866aed4..5eb743398a 100644 --- a/dom/xbl/nsXBLBinding.h +++ b/dom/xbl/nsXBLBinding.h @@ -138,11 +138,6 @@ public: mozilla::dom::XBLChildrenElement* FindInsertionPointFor(nsIContent* aChild); - bool IsShadowRootBinding() - { - return mIsShadowRootBinding; - } - bool HasFilteredInsertionPoints() { return !mInsertionPoints.IsEmpty(); diff --git a/layout/style/StyleRule.cpp b/layout/style/StyleRule.cpp index bf5eefa156..8fde725349 100644 --- a/layout/style/StyleRule.cpp +++ b/layout/style/StyleRule.cpp @@ -148,8 +148,7 @@ nsPseudoClassList::nsPseudoClassList(CSSPseudoClassType aType, : mType(aType), mNext(nullptr) { - NS_ASSERTION(nsCSSPseudoClasses::HasSelectorListArg(aType) || - nsCSSPseudoClasses::HasOptionalSelectorListArg(aType), + NS_ASSERTION(nsCSSPseudoClasses::HasSelectorListArg(aType), "unexpected pseudo-class"); NS_ASSERTION(aSelectorList, "selector list expected"); MOZ_COUNT_CTOR(nsPseudoClassList); @@ -314,7 +313,6 @@ nsCSSSelector::nsCSSSelector(void) mPseudoClassList(nullptr), mAttrList(nullptr), mNegations(nullptr), - mExplicitUniversal(false), mNext(nullptr), mNameSpace(kNameSpaceID_Unknown), mOperator(0), @@ -384,17 +382,6 @@ void nsCSSSelector::Reset(void) mOperator = char16_t(0); } -bool nsCSSSelector::HasFeatureSelectors() -{ - return mExplicitUniversal || mLowercaseTag || mCasedTag || - mIDList || mClassList || mAttrList; -} - -void nsCSSSelector::SetHasExplicitUniversal() -{ - mExplicitUniversal = true; -} - void nsCSSSelector::SetNameSpace(int32_t aNameSpace) { mNameSpace = aNameSpace; @@ -763,9 +750,9 @@ nsCSSSelector::AppendToStringWithoutCombinatorsOrNegations // Universal selector: avoid writing the universal selector when we // can avoid it, especially since we're required to avoid it for the // inside of :not() - if (wroteNamespace || mExplicitUniversal || + if (wroteNamespace || (!mIDList && !mClassList && !mPseudoClassList && !mAttrList && - aIsNegated)) { + (aIsNegated || !mNegations))) { aString.Append(char16_t('*')); } } else { @@ -773,7 +760,9 @@ nsCSSSelector::AppendToStringWithoutCombinatorsOrNegations nsAutoString tag; (isPseudoElement ? mLowercaseTag : mCasedTag)->ToString(tag); if (isPseudoElement) { - if (mExplicitUniversal) { + if (!mNext) { + // Lone pseudo-element selector -- toss in a wildcard type selector + // XXXldb Why? aString.Append(char16_t('*')); } // While our atoms use one colon, most pseudo-elements require two diff --git a/layout/style/StyleRule.h b/layout/style/StyleRule.h index dbf4e08406..907e55448a 100644 --- a/layout/style/StyleRule.h +++ b/layout/style/StyleRule.h @@ -151,8 +151,6 @@ public: nsCSSSelector* Clone() const { return Clone(true, true); } void Reset(void); - bool HasFeatureSelectors(); - void SetHasExplicitUniversal(); void SetNameSpace(int32_t aNameSpace); void SetTag(const nsString& aTag); void AddID(const nsString& aID); @@ -233,10 +231,9 @@ public: // the argument to functional pseudos nsAttrSelector* mAttrList; nsCSSSelector* mNegations; - bool mExplicitUniversal; // True if universal selector explicitly - nsCSSSelector* mNext; // appears in the selector + nsCSSSelector* mNext; int32_t mNameSpace; - char mOperator; + char16_t mOperator; private: // The underlying type of CSSPseudoElementType is uint8_t and // it packs well with mOperator. (char16_t + uint8_t is less than 32bits.) diff --git a/layout/style/nsCSSParser.cpp b/layout/style/nsCSSParser.cpp index bfdf6ee6e5..12d4ff8505 100644 --- a/layout/style/nsCSSParser.cpp +++ b/layout/style/nsCSSParser.cpp @@ -5641,7 +5641,6 @@ CSSParserImpl::ParseTypeOrUniversalSelector(int32_t& aDataMask, aSelector.SetTag(mToken.mIdent); } else if (mToken.IsSymbol('*')) { // universal selector - aSelector.SetHasExplicitUniversal(); aDataMask |= SEL_MASK_ELEM; // don't set tag } @@ -5653,7 +5652,6 @@ CSSParserImpl::ParseTypeOrUniversalSelector(int32_t& aDataMask, } else { // was universal element selector SetDefaultNamespaceOnSelector(aSelector); - aSelector.SetHasExplicitUniversal(); aDataMask |= SEL_MASK_ELEM; // don't set any tag in the selector } @@ -6099,8 +6097,7 @@ CSSParserImpl::ParsePseudoSelector(int32_t& aDataMask, CSSPseudoClassType::negation == pseudoClassType || nsCSSPseudoClasses::HasStringArg(pseudoClassType) || nsCSSPseudoClasses::HasNthPairArg(pseudoClassType) || - nsCSSPseudoClasses::HasSelectorListArg(pseudoClassType)) && - !nsCSSPseudoClasses::HasOptionalSelectorListArg(pseudoClassType)) { + nsCSSPseudoClasses::HasSelectorListArg(pseudoClassType))) { // There are no other function pseudos REPORT_UNEXPECTED_TOKEN(PEPseudoSelNonFunc); UngetToken(); diff --git a/layout/style/nsCSSPseudoClassList.h b/layout/style/nsCSSPseudoClassList.h index c57c28bc0b..7f620ec32f 100644 --- a/layout/style/nsCSSPseudoClassList.h +++ b/layout/style/nsCSSPseudoClassList.h @@ -133,12 +133,6 @@ CSS_PSEUDO_CLASS(scope, ":scope", 0, "layout.css.scope-pseudo.enabled") // it doesn't actually get directly matched on in SelectorMatches. CSS_PSEUDO_CLASS(negation, ":not", 0, "") -// http://drafts.csswg.org/css-scoping/#selectordef-host-context -CSS_PSEUDO_CLASS(hostContext, ":host-context", 0, "dom.webcomponents.enabled") - -// http://drafts.csswg.org/css-scoping/#selectordef-host-context -CSS_PSEUDO_CLASS(host, ":host", 0, "dom.webcomponents.enabled") - // :dir(ltr) and :dir(rtl) match elements whose resolved // directionality in the markup language is ltr or rtl respectively. CSS_STATE_DEPENDENT_PSEUDO_CLASS(dir, ":dir", 0, "", diff --git a/layout/style/nsCSSPseudoClasses.h b/layout/style/nsCSSPseudoClasses.h index 05f67b05cd..55e5bf9d2e 100644 --- a/layout/style/nsCSSPseudoClasses.h +++ b/layout/style/nsCSSPseudoClasses.h @@ -59,12 +59,7 @@ public: static bool HasStringArg(Type aType); static bool HasNthPairArg(Type aType); static bool HasSelectorListArg(Type aType) { - return aType == Type::any || - aType == Type::host || - aType == Type::hostContext; - } - static bool HasOptionalSelectorListArg(Type aType) { - return aType == Type::host; + return aType == Type::any; } static bool IsUserActionPseudoClass(Type aType); diff --git a/layout/style/nsCSSRuleProcessor.cpp b/layout/style/nsCSSRuleProcessor.cpp index dbd0e099b0..810a8f8f00 100644 --- a/layout/style/nsCSSRuleProcessor.cpp +++ b/layout/style/nsCSSRuleProcessor.cpp @@ -48,7 +48,6 @@ #include "nsCSSRules.h" #include "nsStyleSet.h" #include "mozilla/dom/Element.h" -#include "mozilla/dom/ShadowRoot.h" #include "nsNthIndexCache.h" #include "mozilla/ArrayUtils.h" #include "mozilla/EventStates.h" @@ -1343,17 +1342,9 @@ struct NodeMatchContext { // mForStyling is false, we have to assume we don't know.) const bool mIsRelevantLink; - // If the node should be considered featureless (as specified in - // selectors 4), then mIsFeature should be set to true to prevent - // matching unless the selector is a special pseudo class or pseudo - // element that matches featureless elements. - const bool mIsFeatureless; - - NodeMatchContext(EventStates aStateMask, bool aIsRelevantLink, - bool aIsFeatureless = false) + NodeMatchContext(EventStates aStateMask, bool aIsRelevantLink) : mStateMask(aStateMask) , mIsRelevantLink(aIsRelevantLink) - , mIsFeatureless(aIsFeatureless) { } }; @@ -1640,11 +1631,6 @@ StateSelectorMatches(Element* aElement, return true; } -static bool AnySelectorInArgListMatches(Element* aElement, - nsPseudoClassList* aList, - NodeMatchContext& aNodeMatchContext, - TreeMatchContext& aTreeMatchContext); - static bool StateSelectorMatches(Element* aElement, nsCSSSelector* aSelector, @@ -1666,26 +1652,6 @@ StateSelectorMatches(Element* aElement, return true; } -// Returns whether aSelector can match featureless elements. -static bool CanMatchFeaturelessElement(nsCSSSelector* aSelector) -{ - if (aSelector->HasFeatureSelectors()) { - return false; - } - - for (nsPseudoClassList* pseudoClass = aSelector->mPseudoClassList; - pseudoClass; - pseudoClass = pseudoClass->mNext) { - if (pseudoClass->mType == CSSPseudoClassType::host || - pseudoClass->mType == CSSPseudoClassType::hostContext) { - return true; - } - } - - return false; -} - - // |aDependence| has two functions: // * when non-null, it indicates that we're processing a negation, // which is done only when SelectorMatches calls itself recursively @@ -1706,11 +1672,6 @@ static bool SelectorMatches(Element* aElement, "is false since we don't know how to set it correctly in " "Has(Attribute|State)DependentStyle"); - if (aNodeMatchContext.mIsFeatureless && - !CanMatchFeaturelessElement(aSelector)) { - return false; - } - // namespace/tag match // optimization : bail out early if we can if ((kNameSpaceID_Unknown != aSelector->mNameSpace && @@ -1909,89 +1870,18 @@ static bool SelectorMatches(Element* aElement, case CSSPseudoClassType::any: { - if (!AnySelectorInArgListMatches(aElement, pseudoClass, - aNodeMatchContext, - aTreeMatchContext)) { - return false; - } - } - break; - - case CSSPseudoClassType::host: - { - // In order to match :host, the element must be a shadow root host, - // we must be matching only against host pseudo selectors, and the - // selector's context must be the shadow root (the selector must be - // featureless, the left-most selector, and be in a shadow root - // style). The :host selector may also be be functional, with a - // compound selector. If this is the case, then also ensure that the - // host element matches against the compound - // selector. - - // We match automatically if GetParent() and GetShadowRoot() have - // the same result. Without special casing this ahead of all other - // selector matching, it fails. Have not determined the cause. - - if (aElement->GetParent() == aElement->GetShadowRoot()) { - break; - } - - // Match if any selector in the argument list matches. - - NodeMatchContext nodeContext(EventStates(), - nsCSSRuleProcessor::IsLink(aElement)); - if (AnySelectorInArgListMatches(aElement, pseudoClass, - nodeContext, - aTreeMatchContext)) { - break; - } - - // Finally, with the exception of the two above cases, make sure we - // don't match if GetContainingShadow() returns null. For whatever - // reason, we can't test for this case first. - - if (aElement->GetContainingShadow() == nullptr) { - return false; - } - - } - break; - - - case CSSPseudoClassType::hostContext: - { - // In order to match host-context, the element must be a - // shadow root host and the selector's context must be the - // shadow root (aTreeMatchContext.mScopedRoot is set to the - // host of the shadow root where the style is contained, - // thus the element must be mScopedRoot). If the UNKNOWN - // selector flag is set, relax the shadow root host - // requirement because this pseudo class walks through - // ancestors looking for a match, thus the selector can be - // dependant on aElement even though it is not the host. The - // dependency would otherwise be missed because when UNKNOWN - // is set, selector matching may not have started from the top. - if (!((aElement->GetShadowRoot() && - aElement == aTreeMatchContext.mScopedRoot) || - aSelectorFlags & SelectorMatchesFlags::UNKNOWN)) { - return false; - } - - Element* currentElement = aElement; - while (currentElement) { - NodeMatchContext nodeContext(EventStates(), - nsCSSRuleProcessor::IsLink(currentElement)); - if (AnySelectorInArgListMatches(currentElement, pseudoClass, - nodeContext, - aTreeMatchContext)) { + nsCSSSelectorList *l; + for (l = pseudoClass->u.mSelectors; l; l = l->mNext) { + nsCSSSelector *s = l->mSelectors; + MOZ_ASSERT(!s->mNext && !s->IsPseudoElement(), + "parser failed"); + if (SelectorMatches( + aElement, s, aNodeMatchContext, aTreeMatchContext, + SelectorMatchesFlags::IS_PSEUDO_CLASS_ARGUMENT)) { break; } - - nsIContent* flattenedParent = currentElement->GetFlattenedTreeParent(); - currentElement = flattenedParent && flattenedParent->IsElement() ? - flattenedParent->AsElement() : nullptr; } - if (!currentElement) { + if (!l) { return false; } } @@ -2373,26 +2263,6 @@ static bool SelectorMatches(Element* aElement, return result; } -static bool AnySelectorInArgListMatches(Element* aElement, - nsPseudoClassList* aList, - NodeMatchContext& aNodeMatchContext, - TreeMatchContext& aTreeMatchContext) -{ - nsCSSSelectorList *l; - for (l = aList->u.mSelectors; l; l = l->mNext) { - nsCSSSelector *s = l->mSelectors; - MOZ_ASSERT(!s->mNext && !s->IsPseudoElement(), - "parser failed"); - if (SelectorMatches( - aElement, s, aNodeMatchContext, aTreeMatchContext, - SelectorMatchesFlags::IS_PSEUDO_CLASS_ARGUMENT)) { - break; - } - } - - return !!l; -} - #undef STATE_CHECK #ifdef DEBUG @@ -2482,9 +2352,7 @@ SelectorMatchesTree(Element* aPrevElement, MOZ_ASSERT(!aSelector || !aSelector->IsPseudoElement()); nsCSSSelector* selector = aSelector; Element* prevElement = aPrevElement; - bool crossedShadowRootBoundary = false; while (selector) { // check compound selectors - bool contentIsFeatureless = false; NS_ASSERTION(!selector->mNext || selector->mNext->mOperator != char16_t(0), "compound selector without combinator"); @@ -2515,20 +2383,6 @@ SelectorMatchesTree(Element* aPrevElement, // to test against is the parent else { nsIContent *content = prevElement->GetParent(); - - // In the shadow tree, the shadow host behaves as if it - // is a featureless parent of top-level elements of the shadow - // tree. Only cross shadow root boundary when the selector is the - // left most selector because ancestors of the host are not in - // the selector match list. - ShadowRoot* shadowRoot = content ? - ShadowRoot::FromNode(content) : nullptr; - if (shadowRoot && !selector->mNext && !crossedShadowRootBoundary) { - content = shadowRoot->GetHost(); - crossedShadowRootBoundary = true; - contentIsFeatureless = true; - } - // GetParent could return a document fragment; we only want // element parents. if (content && content->IsElement()) { @@ -2580,8 +2434,7 @@ SelectorMatchesTree(Element* aPrevElement, } const bool isRelevantLink = (aFlags & eLookForRelevantLink) && nsCSSRuleProcessor::IsLink(element); - - NodeMatchContext nodeContext(EventStates(), isRelevantLink, contentIsFeatureless); + NodeMatchContext nodeContext(EventStates(), isRelevantLink); if (isRelevantLink) { // If we find an ancestor of the matched node that is a link // during the matching process, then it's the relevant link (see @@ -2651,29 +2504,6 @@ void ContentEnumFunc(const RuleValue& value, nsCSSSelector* aSelector, // We won't match; nothing else to do here return; } - // If mOnlyMatchHostPseudo is set, then we only want to match against - // selectors that contain a :host-context pseudo class. - if (data->mTreeMatchContext.mOnlyMatchHostPseudo) { - nsCSSSelector* selector = aSelector; - while (selector && selector->mNext != nullptr) { - selector = selector->mNext; - } - - bool seenHostPseudo = false; - for (nsPseudoClassList* pseudoClass = selector->mPseudoClassList; - pseudoClass; - pseudoClass = pseudoClass->mNext) { - if (pseudoClass->mType == CSSPseudoClassType::host || - pseudoClass->mType == CSSPseudoClassType::hostContext) { - seenHostPseudo = true; - break; - } - } - - if (!seenHostPseudo) { - return; - } - } if (!data->mTreeMatchContext.SetStyleScopeForSelectorMatching(data->mElement, data->mScope)) { // The selector is for a rule in a scoped style sheet, and the subject @@ -2733,8 +2563,7 @@ nsCSSRuleProcessor::RulesMatching(ElementRuleProcessorData *aData) if (cascade) { NodeMatchContext nodeContext(EventStates(), - nsCSSRuleProcessor::IsLink(aData->mElement), - aData->mElementIsFeatureless); + nsCSSRuleProcessor::IsLink(aData->mElement)); cascade->mRuleHash.EnumerateAllRules(aData->mElement, aData, nodeContext); } } @@ -3018,34 +2847,6 @@ AttributeEnumFunc(nsCSSSelector* aSelector, nsRestyleHint possibleChange = RestyleHintForSelectorWithAttributeChange(aData->change, aSelector, aRightmostSelector); - // If mOnlyMatchHostPseudo is set, then we only want to match against - // selectors that contain a :host-context pseudo class. - if (data->mTreeMatchContext.mOnlyMatchHostPseudo) { - nsCSSSelector* selector = aSelector; - while (selector && selector->mNext != nullptr) { - selector = selector->mNext; - } - - bool seenHostPseudo = false; - for (nsPseudoClassList* pseudoClass = selector->mPseudoClassList; - pseudoClass; - pseudoClass = pseudoClass->mNext) { - if (pseudoClass->mType == CSSPseudoClassType::host || - pseudoClass->mType == CSSPseudoClassType::hostContext) { - // :host-context will walk ancestors looking for a match of a compound - // selector, thus any changes to ancestors may require restyling the - // subtree. - possibleChange |= eRestyle_Subtree; - seenHostPseudo = true; - break; - } - } - - if (!seenHostPseudo) { - return; - } - } - // If, ignoring eRestyle_SomeDescendants, enumData->change already includes // all the bits of possibleChange, don't bother calling SelectorMatches, since @@ -3517,12 +3318,10 @@ AddSelector(RuleCascadeData* aCascade, } } - // Recur through any :-moz-any or :host-context selectors + // Recur through any :-moz-any selectors for (nsPseudoClassList* pseudoClass = negation->mPseudoClassList; pseudoClass; pseudoClass = pseudoClass->mNext) { - if (pseudoClass->mType == CSSPseudoClassType::any || - pseudoClass->mType == CSSPseudoClassType::host || - pseudoClass->mType == CSSPseudoClassType::hostContext) { + if (pseudoClass->mType == CSSPseudoClassType::any) { for (nsCSSSelectorList *l = pseudoClass->u.mSelectors; l; l = l->mNext) { nsCSSSelector *s = l->mSelectors; if (!AddSelector(aCascade, aSelectorInTopLevel, s, @@ -4171,7 +3970,6 @@ TreeMatchContext::InitAncestors(Element *aElement) for (uint32_t i = ancestors.Length(); i-- != 0; ) { mAncestorFilter.PushAncestor(ancestors[i]); PushStyleScope(ancestors[i]); - PushShadowHost(ancestors[i]); } } } diff --git a/layout/style/nsRuleProcessorData.h b/layout/style/nsRuleProcessorData.h index 769c53f573..6f8cba8959 100644 --- a/layout/style/nsRuleProcessorData.h +++ b/layout/style/nsRuleProcessorData.h @@ -164,23 +164,6 @@ struct MOZ_STACK_CLASS TreeMatchContext { mStyleScopes.TruncateLength(mStyleScopes.Length() - 1); } } - - void PushShadowHost(mozilla::dom::Element* aElement) - { - NS_PRECONDITION(aElement, "aElement must not be null"); - if (aElement->GetShadowRoot()) { - mShadowHosts.AppendElement(aElement); - } - } - - void PopShadowHost(mozilla::dom::Element* aElement) - { - NS_PRECONDITION(aElement, "aElement must not be null"); - if (mShadowHosts.SafeLastElement(nullptr) == aElement) { - mShadowHosts.TruncateLength(mShadowHosts.Length() - 1); - } - } - bool PopStyleScopeForSelectorMatching(mozilla::dom::Element* aElement) { @@ -250,7 +233,6 @@ struct MOZ_STACK_CLASS TreeMatchContext { MOZ_GUARD_OBJECT_NOTIFIER_PARAM) : mPushedAncestor(false) , mPushedStyleScope(false) - , mPushedShadowHost(false) , mTreeMatchContext(aTreeMatchContext) , mElement(nullptr) { @@ -263,10 +245,8 @@ struct MOZ_STACK_CLASS TreeMatchContext { mElement = aElement; mPushedAncestor = true; mPushedStyleScope = true; - mPushedShadowHost = true; mTreeMatchContext.mAncestorFilter.PushAncestor(aElement); mTreeMatchContext.PushStyleScope(aElement); - mTreeMatchContext.PushShadowHost(aElement); } } @@ -298,15 +278,11 @@ struct MOZ_STACK_CLASS TreeMatchContext { if (mPushedStyleScope) { mTreeMatchContext.PopStyleScope(mElement); } - if (mPushedShadowHost) { - mTreeMatchContext.PopShadowHost(mElement); - } } private: bool mPushedAncestor; bool mPushedStyleScope; - bool mPushedShadowHost; TreeMatchContext& mTreeMatchContext; mozilla::dom::Element* mElement; MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER @@ -366,11 +342,6 @@ struct MOZ_STACK_CLASS TreeMatchContext { // The document we're working with. nsIDocument* const mDocument; - // Only selectors that contain :host or :host-context pseudo class - // should be matched against elements. All other selectors should not - // match. - bool mOnlyMatchHostPseudo; - // Root of scoped stylesheet (set and unset by the supplier of the // scoped stylesheet). nsIContent* mScopedRoot; @@ -412,9 +383,6 @@ struct MOZ_STACK_CLASS TreeMatchContext { //