Bug 762345 - Skip all the QIing stuff in the TreeMatchContext constructor if possible; r=bzbarsky

This commit is contained in:
Ehsan Akhgari 2012-06-07 15:19:56 -04:00
Родитель 4868367e85
Коммит b354f9cf8c
2 изменённых файлов: 18 добавлений и 9 удалений

Просмотреть файл

@ -6132,7 +6132,7 @@ inline static nsresult FindMatchingElements(nsINode* aRoot,
nsIDocument* doc = aRoot->OwnerDoc(); nsIDocument* doc = aRoot->OwnerDoc();
TreeMatchContext matchingContext(false, nsRuleWalker::eRelevantLinkUnvisited, TreeMatchContext matchingContext(false, nsRuleWalker::eRelevantLinkUnvisited,
doc); doc, TreeMatchContext::eNeverMatchVisited);
doc->FlushPendingLinkUpdates(); doc->FlushPendingLinkUpdates();
// Fast-path selectors involving IDs. We can only do this if aRoot // 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(); OwnerDoc()->FlushPendingLinkUpdates();
TreeMatchContext matchingContext(false, TreeMatchContext matchingContext(false,
nsRuleWalker::eRelevantLinkUnvisited, nsRuleWalker::eRelevantLinkUnvisited,
OwnerDoc()); OwnerDoc(),
TreeMatchContext::eNeverMatchVisited);
matches = nsCSSRuleProcessor::SelectorListMatches(this, matchingContext, matches = nsCSSRuleProcessor::SelectorListMatches(this, matchingContext,
selectorList); selectorList);
} }

Просмотреть файл

@ -192,10 +192,16 @@ struct NS_STACK_CLASS TreeMatchContext {
// Whether this document is using PB mode // Whether this document is using PB mode
bool mUsingPrivateBrowsing; bool mUsingPrivateBrowsing;
enum MatchVisited {
eNeverMatchVisited,
eMatchVisitedDefault
};
// Constructor to use when creating a tree match context for styling // Constructor to use when creating a tree match context for styling
TreeMatchContext(bool aForStyling, TreeMatchContext(bool aForStyling,
nsRuleWalker::VisitedHandlingType aVisitedHandling, nsRuleWalker::VisitedHandlingType aVisitedHandling,
nsIDocument* aDocument) nsIDocument* aDocument,
MatchVisited aMatchVisited = eMatchVisitedDefault)
: mForStyling(aForStyling) : mForStyling(aForStyling)
, mHaveRelevantLink(false) , mHaveRelevantLink(false)
, mVisitedHandling(aVisitedHandling) , mVisitedHandling(aVisitedHandling)
@ -205,12 +211,14 @@ struct NS_STACK_CLASS TreeMatchContext {
, mCompatMode(aDocument->GetCompatibilityMode()) , mCompatMode(aDocument->GetCompatibilityMode())
, mUsingPrivateBrowsing(false) , mUsingPrivateBrowsing(false)
{ {
nsCOMPtr<nsISupports> container = mDocument->GetContainer(); if (aMatchVisited != eNeverMatchVisited) {
if (container) { nsCOMPtr<nsISupports> container = mDocument->GetContainer();
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(container); if (container) {
NS_ASSERTION(loadContext, "Couldn't get loadContext from container; assuming no private browsing."); nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(container);
if (loadContext) { NS_ASSERTION(loadContext, "Couldn't get loadContext from container; assuming no private browsing.");
mUsingPrivateBrowsing = loadContext->UsePrivateBrowsing(); if (loadContext) {
mUsingPrivateBrowsing = loadContext->UsePrivateBrowsing();
}
} }
} }
} }