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();
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);
}

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

@ -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<nsISupports> container = mDocument->GetContainer();
if (container) {
nsCOMPtr<nsILoadContext> 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<nsISupports> container = mDocument->GetContainer();
if (container) {
nsCOMPtr<nsILoadContext> loadContext = do_QueryInterface(container);
NS_ASSERTION(loadContext, "Couldn't get loadContext from container; assuming no private browsing.");
if (loadContext) {
mUsingPrivateBrowsing = loadContext->UsePrivateBrowsing();
}
}
}
}