diff --git a/content/base/src/nsGenericElement.cpp b/content/base/src/nsGenericElement.cpp index ae94f38ea8f6..c548d83f0446 100644 --- a/content/base/src/nsGenericElement.cpp +++ b/content/base/src/nsGenericElement.cpp @@ -6132,7 +6132,7 @@ inline static nsresult FindMatchingElements(nsINode* aRoot, nsIDocument* doc = aRoot->OwnerDoc(); TreeMatchContext matchingContext(false, nsRuleWalker::eRelevantLinkUnvisited, - doc); + doc, TreeMatchContext::eNeverMatchVisited); doc->FlushPendingLinkUpdates(); // Fast-path selectors involving IDs. We can only do this if aRoot @@ -6246,7 +6246,8 @@ nsGenericElement::MozMatchesSelector(const nsAString& aSelector, nsresult* aResu OwnerDoc()->FlushPendingLinkUpdates(); TreeMatchContext matchingContext(false, nsRuleWalker::eRelevantLinkUnvisited, - OwnerDoc()); + OwnerDoc(), + TreeMatchContext::eNeverMatchVisited); matches = nsCSSRuleProcessor::SelectorListMatches(this, matchingContext, selectorList); } diff --git a/layout/style/nsRuleProcessorData.h b/layout/style/nsRuleProcessorData.h index 4dea271cff57..06064feb2e9d 100644 --- a/layout/style/nsRuleProcessorData.h +++ b/layout/style/nsRuleProcessorData.h @@ -192,10 +192,16 @@ struct NS_STACK_CLASS TreeMatchContext { // Whether this document is using PB mode bool mUsingPrivateBrowsing; + enum MatchVisited { + eNeverMatchVisited, + eMatchVisitedDefault + }; + // Constructor to use when creating a tree match context for styling TreeMatchContext(bool aForStyling, nsRuleWalker::VisitedHandlingType aVisitedHandling, - nsIDocument* aDocument) + nsIDocument* aDocument, + MatchVisited aMatchVisited = eMatchVisitedDefault) : mForStyling(aForStyling) , mHaveRelevantLink(false) , mVisitedHandling(aVisitedHandling) @@ -205,12 +211,14 @@ struct NS_STACK_CLASS TreeMatchContext { , mCompatMode(aDocument->GetCompatibilityMode()) , mUsingPrivateBrowsing(false) { - nsCOMPtr container = mDocument->GetContainer(); - if (container) { - nsCOMPtr loadContext = do_QueryInterface(container); - NS_ASSERTION(loadContext, "Couldn't get loadContext from container; assuming no private browsing."); - if (loadContext) { - mUsingPrivateBrowsing = loadContext->UsePrivateBrowsing(); + if (aMatchVisited != eNeverMatchVisited) { + nsCOMPtr container = mDocument->GetContainer(); + if (container) { + nsCOMPtr loadContext = do_QueryInterface(container); + NS_ASSERTION(loadContext, "Couldn't get loadContext from container; assuming no private browsing."); + if (loadContext) { + mUsingPrivateBrowsing = loadContext->UsePrivateBrowsing(); + } } } }