Bug 992488 - Return false early from inDOMUtils::SelectorMatchesElement if the selector is for a pseudo-element. r=bzbarsky
authorCameron McCormack <cam@mcc.id.au>
Tue, 15 Apr 2014 12:28:57 +1000
changeset 190468 1515ebdea6768197428fd998cbbaf458b0187209
parent 190467 4743c6a40048186d9a794ffeaf9036b9ee2e4d29
child 190469 6cc06a35f253203d7986d07f3188415eef4aa5bc
push idunknown
push userunknown
push dateunknown
reviewersbzbarsky
bugs992488
milestone31.0a1
Bug 992488 - Return false early from inDOMUtils::SelectorMatchesElement if the selector is for a pseudo-element. r=bzbarsky
layout/inspector/inDOMUtils.cpp
--- a/layout/inspector/inDOMUtils.cpp
+++ b/layout/inspector/inDOMUtils.cpp
@@ -365,16 +365,25 @@ inDOMUtils::SelectorMatchesElement(nsIDO
   nsCSSSelectorList* tail = GetSelectorAtIndex(aRule, aSelectorIndex, rv);
   if (rv.Failed()) {
     return rv.ErrorCode();
   }
 
   // We want just the one list item, not the whole list tail
   nsAutoPtr<nsCSSSelectorList> sel(tail->Clone(false));
 
+  // SelectorListMatches does not handle selectors that begin with a
+  // pseudo-element, which you can get from selectors like
+  // |input::-moz-placeholder:hover|.  This function doesn't take
+  // a pseudo-element nsIAtom*, so we know we can't match.
+  if (sel->mSelectors->IsPseudoElement()) {
+    *aMatches = false;
+    return NS_OK;
+  }
+
   element->OwnerDoc()->FlushPendingLinkUpdates();
   // XXXbz what exactly should we do with visited state here?
   TreeMatchContext matchingContext(false,
                                    nsRuleWalker::eRelevantLinkUnvisited,
                                    element->OwnerDoc(),
                                    TreeMatchContext::eNeverMatchVisited);
   *aMatches = nsCSSRuleProcessor::SelectorListMatches(element, matchingContext,
                                                       sel);