Bug 1404897: Implement Element.matches using stylo. r=heycam
MozReview-Commit-ID: 7nxYVcweu0W
This commit is contained in:
@@ -3496,21 +3496,31 @@ Element::Closest(const nsAString& aSelector, ErrorResult& aResult)
|
||||
bool
|
||||
Element::Matches(const nsAString& aSelector, ErrorResult& aError)
|
||||
{
|
||||
nsCSSSelectorList* selectorList = ParseSelectorList(aSelector, aError);
|
||||
if (!selectorList) {
|
||||
// Either we failed (and aError already has the exception), or this
|
||||
// is a pseudo-element-only selector that matches nothing.
|
||||
return false;
|
||||
}
|
||||
|
||||
TreeMatchContext matchingContext(false,
|
||||
nsRuleWalker::eRelevantLinkUnvisited,
|
||||
OwnerDoc(),
|
||||
TreeMatchContext::eNeverMatchVisited);
|
||||
matchingContext.SetHasSpecifiedScope();
|
||||
matchingContext.AddScopeElement(this);
|
||||
return nsCSSRuleProcessor::SelectorListMatches(this, matchingContext,
|
||||
selectorList);
|
||||
return WithSelectorList<bool>(
|
||||
aSelector,
|
||||
aError,
|
||||
[&](const RawServoSelectorList* aList) {
|
||||
if (!aList) {
|
||||
return false;
|
||||
}
|
||||
return Servo_SelectorList_Matches(this, aList);
|
||||
},
|
||||
[&](nsCSSSelectorList* aList) {
|
||||
if (!aList) {
|
||||
// Either we failed (and aError already has the exception), or this
|
||||
// is a pseudo-element-only selector that matches nothing.
|
||||
return false;
|
||||
}
|
||||
TreeMatchContext matchingContext(false,
|
||||
nsRuleWalker::eRelevantLinkUnvisited,
|
||||
OwnerDoc(),
|
||||
TreeMatchContext::eNeverMatchVisited);
|
||||
matchingContext.SetHasSpecifiedScope();
|
||||
matchingContext.AddScopeElement(this);
|
||||
return nsCSSRuleProcessor::SelectorListMatches(this, matchingContext,
|
||||
aList);
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
static const nsAttrValue::EnumTable kCORSAttributeTable[] = {
|
||||
|
||||
Reference in New Issue
Block a user