Auto merge of #16895 - bzbarsky:moz-is-html, r=emilio

Add :-moz-is-html support for stylo.

<!-- Please describe your changes on the following line: -->

---
<!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `__` with appropriate data: -->
- [X] `./mach build -d` does not report any errors
- [X] `./mach test-tidy` does not report any errors
- [X] These changes fix https://bugzilla.mozilla.org/show_bug.cgi?id=1365165

<!-- Either: -->
- [ ] There are tests for these changes OR
- [ ] These changes do not require tests because _____

<!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.-->

<!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. -->

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16895)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-05-16 14:36:13 -05:00 committed by GitHub
commit 7b9e9caa1d
3 changed files with 8 additions and 3 deletions

View file

@ -25,8 +25,6 @@
*
* Pending pseudo-classes:
*
* :-moz-is-html -> Used only in UA sheets, should be easy to support.
*
* :-moz-lwtheme, :-moz-lwtheme-brighttext, :-moz-lwtheme-darktext,
* :-moz-window-inactive.
*
@ -108,6 +106,7 @@ macro_rules! apply_non_ts_list {
("-moz-last-node", MozLastNode, lastNode, _, _),
("-moz-only-whitespace", MozOnlyWhitespace, mozOnlyWhitespace, _, _),
("-moz-native-anonymous", MozNativeAnonymous, mozNativeAnonymous, _, PSEUDO_CLASS_INTERNAL),
("-moz-is-html", MozIsHTML, mozIsHTML, _, _),
],
string: [
("-moz-system-metric", MozSystemMetric, mozSystemMetric, _, PSEUDO_CLASS_INTERNAL),

View file

@ -164,7 +164,10 @@ impl NonTSPseudoClass {
// revalidation, because we already compare states for elements and
// candidates.
self.state_flag().is_empty() &&
!matches!(*self, NonTSPseudoClass::MozAny(_) | NonTSPseudoClass::Dir(_))
!matches!(*self,
NonTSPseudoClass::MozAny(_) |
NonTSPseudoClass::Dir(_) |
NonTSPseudoClass::MozIsHTML)
}
/// Convert NonTSPseudoClass to Gecko's CSSPseudoClassType.

View file

@ -1217,6 +1217,9 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::MozNativeAnonymous => unsafe {
Gecko_MatchesElement(pseudo_class.to_gecko_pseudoclasstype().unwrap(), self.0)
},
NonTSPseudoClass::MozIsHTML => {
self.is_html_element_in_html_document()
}
NonTSPseudoClass::MozAny(ref sels) => {
sels.iter().any(|s| {
matches_complex_selector(s, self, context, flags_setter)