Closed Bug 1387934 Opened 7 years ago Closed 7 years ago

stylo: inDOMUtils::SelectorMatchesElement should not match with bogus pseudo

Categories

(Core :: CSS Parsing and Computation, defect, P2)

defect

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: xidorn, Assigned: ferjm)

References

(Blocks 1 open bug)

Details

Attachments

(1 file)

layout/inspector/tests/test_selectormatcheselement.html fails because of this.

It returns true for
> utils.selectorMatchesElement(element, elementRule, 0, ":bogus")
where the bogus pseudo shouldn't match anything actually.

This should be an easy one to fix. Just do a special check before https://searchfox.org/mozilla-central/rev/b52285fffc13f36eca6b47de735d4e4403b3859e/layout/style/ServoStyleRule.cpp#276-291 should be enough.
Assignee: nobody → ferjmoreno
Comment on attachment 8896322 [details]
Bug 1387934 - stylo: inDOMUtils::SelectorMatchesElement should not match with bogus pseudo.

https://reviewboard.mozilla.org/r/167574/#review173034

::: layout/style/ServoStyleRule.cpp:288
(Diff revision 1)
> +  *aMatches = (aPseudo.IsEmpty() || pseudoType != CSSPseudoElementType::NotPseudo)
> +    ? Servo_StyleRule_SelectorMatchesElement(mRawRule,
> -                                                     aElement,
> +                                             aElement,
> -                                                     aSelectorIndex,
> +                                             aSelectorIndex,
> -                                                     pseudoType);
> +                                             pseudoType)
> +    : false;

Doesn't seem to be very readable... Could you just do an early return for that case?

Actually, I guess we can just skip `NS_Atomize` and `GetPseudoType` if `aPseudo` is empty, which can make the function slightly faster and should also make the code clearer.
Attachment #8896322 - Flags: review?(xidorn+moz) → review+
Priority: -- → P2
Pushed by ferjmoreno@gmail.com:
https://hg.mozilla.org/integration/autoland/rev/5cbcc0b81f21
stylo: inDOMUtils::SelectorMatchesElement should not match with bogus pseudo. r=xidorn
https://hg.mozilla.org/mozilla-central/rev/5cbcc0b81f21
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla57
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: