Auto merge of #17418 - bzbarsky:dir-pseudo-classes, r=emilio

Add pseudo-classes to match on the state of the "dir" attribute.

Fixes the servo parts of Gecko bug 1373798 <https://bugzilla.mozilla.org/show_bug.cgi?id=1373798>

<!-- 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=1373798
<!-- 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/17418)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-06-19 19:25:45 -07:00 committed by GitHub
commit 27add56298
5 changed files with 94 additions and 70 deletions

View file

@ -120,6 +120,18 @@ bitflags! {
const IN_LTR_STATE = 1 << 44, const IN_LTR_STATE = 1 << 44,
/// State that elements that match :dir(rtl) are in. /// State that elements that match :dir(rtl) are in.
const IN_RTL_STATE = 1 << 45, const IN_RTL_STATE = 1 << 45,
/// State that HTML elements that have a "dir" attr are in.
const IN_HAS_DIR_ATTR_STATE = 1 << 46,
/// State that HTML elements with dir="ltr" (or something
/// case-insensitively equal to "ltr") are in.
const IN_HAS_DIR_ATTR_LTR_STATE = 1 << 47,
/// State that HTML elements with dir="rtl" (or something
/// case-insensitively equal to "rtl") are in.
const IN_HAS_DIR_ATTR_RTL_STATE = 1 << 48,
/// State that HTML <bdi> elements without a valid-valued "dir" attr or
/// any HTML elements (including <bdi>) with dir="auto" (or something
/// case-insensitively equal to "auto") are in.
const IN_HAS_DIR_ATTR_LIKE_AUTO_STATE = 1 << 49,
/// Non-standard & undocumented. /// Non-standard & undocumented.
const IN_AUTOFILL_STATE = 1 << 50, const IN_AUTOFILL_STATE = 1 << 50,
/// Non-standard & undocumented. /// Non-standard & undocumented.

View file

@ -10668,28 +10668,32 @@ pub mod root {
mozHandlerBlocked = 59, mozHandlerBlocked = 59,
mozHandlerCrashed = 60, mozHandlerCrashed = 60,
mozMathIncrementScriptLevel = 61, mozMathIncrementScriptLevel = 61,
mozAutofill = 62, mozHasDirAttr = 62,
mozAutofillPreview = 63, mozDirAttrLTR = 63,
required = 64, mozDirAttrRTL = 64,
optional = 65, mozDirAttrLikeAuto = 65,
valid = 66, mozAutofill = 66,
invalid = 67, mozAutofillPreview = 67,
inRange = 68, required = 68,
outOfRange = 69, optional = 69,
defaultPseudo = 70, valid = 70,
placeholderShown = 71, invalid = 71,
mozReadOnly = 72, inRange = 72,
mozReadWrite = 73, outOfRange = 73,
mozSubmitInvalid = 74, defaultPseudo = 74,
mozUIInvalid = 75, placeholderShown = 75,
mozUIValid = 76, mozReadOnly = 76,
mozMeterOptimum = 77, mozReadWrite = 77,
mozMeterSubOptimum = 78, mozSubmitInvalid = 78,
mozMeterSubSubOptimum = 79, mozUIInvalid = 79,
mozPlaceholder = 80, mozUIValid = 80,
Count = 81, mozMeterOptimum = 81,
NotPseudo = 82, mozMeterSubOptimum = 82,
MAX = 83, mozMeterSubSubOptimum = 83,
mozPlaceholder = 84,
Count = 85,
NotPseudo = 86,
MAX = 87,
} }
#[repr(C)] #[repr(C)]
#[derive(Debug)] #[derive(Debug)]
@ -16146,19 +16150,17 @@ pub mod root {
NodeIsContent = 17, NodeIsContent = 17,
ElementHasAnimations = 18, ElementHasAnimations = 18,
NodeHasValidDirAttribute = 19, NodeHasValidDirAttribute = 19,
NodeHasFixedDir = 20, NodeHasDirAutoSet = 20,
NodeHasDirAutoSet = 21, NodeHasTextNodeDirectionalityMap = 21,
NodeHasTextNodeDirectionalityMap = 22, NodeAncestorHasDirAuto = 22,
NodeHasDirAuto = 23, ElementIsInStyleScope = 23,
NodeAncestorHasDirAuto = 24, ElementIsScopedStyleRoot = 24,
ElementIsInStyleScope = 25, NodeHandlingClick = 25,
ElementIsScopedStyleRoot = 26, NodeHasRelevantHoverRules = 26,
NodeHandlingClick = 27, ElementHasWeirdParserInsertionMode = 27,
NodeHasRelevantHoverRules = 28, ParserHasNotified = 28,
ElementHasWeirdParserInsertionMode = 29, MayBeApzAware = 29,
ParserHasNotified = 30, BooleanFlagCount = 30,
MayBeApzAware = 31,
BooleanFlagCount = 32,
} }
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy)] #[derive(Debug, Copy)]

View file

@ -10401,28 +10401,32 @@ pub mod root {
mozHandlerBlocked = 59, mozHandlerBlocked = 59,
mozHandlerCrashed = 60, mozHandlerCrashed = 60,
mozMathIncrementScriptLevel = 61, mozMathIncrementScriptLevel = 61,
mozAutofill = 62, mozHasDirAttr = 62,
mozAutofillPreview = 63, mozDirAttrLTR = 63,
required = 64, mozDirAttrRTL = 64,
optional = 65, mozDirAttrLikeAuto = 65,
valid = 66, mozAutofill = 66,
invalid = 67, mozAutofillPreview = 67,
inRange = 68, required = 68,
outOfRange = 69, optional = 69,
defaultPseudo = 70, valid = 70,
placeholderShown = 71, invalid = 71,
mozReadOnly = 72, inRange = 72,
mozReadWrite = 73, outOfRange = 73,
mozSubmitInvalid = 74, defaultPseudo = 74,
mozUIInvalid = 75, placeholderShown = 75,
mozUIValid = 76, mozReadOnly = 76,
mozMeterOptimum = 77, mozReadWrite = 77,
mozMeterSubOptimum = 78, mozSubmitInvalid = 78,
mozMeterSubSubOptimum = 79, mozUIInvalid = 79,
mozPlaceholder = 80, mozUIValid = 80,
Count = 81, mozMeterOptimum = 81,
NotPseudo = 82, mozMeterSubOptimum = 82,
MAX = 83, mozMeterSubSubOptimum = 83,
mozPlaceholder = 84,
Count = 85,
NotPseudo = 86,
MAX = 87,
} }
#[repr(C)] #[repr(C)]
#[derive(Debug)] #[derive(Debug)]
@ -15782,19 +15786,17 @@ pub mod root {
NodeIsContent = 17, NodeIsContent = 17,
ElementHasAnimations = 18, ElementHasAnimations = 18,
NodeHasValidDirAttribute = 19, NodeHasValidDirAttribute = 19,
NodeHasFixedDir = 20, NodeHasDirAutoSet = 20,
NodeHasDirAutoSet = 21, NodeHasTextNodeDirectionalityMap = 21,
NodeHasTextNodeDirectionalityMap = 22, NodeAncestorHasDirAuto = 22,
NodeHasDirAuto = 23, ElementIsInStyleScope = 23,
NodeAncestorHasDirAuto = 24, ElementIsScopedStyleRoot = 24,
ElementIsInStyleScope = 25, NodeHandlingClick = 25,
ElementIsScopedStyleRoot = 26, NodeHasRelevantHoverRules = 26,
NodeHandlingClick = 27, ElementHasWeirdParserInsertionMode = 27,
NodeHasRelevantHoverRules = 28, ParserHasNotified = 28,
ElementHasWeirdParserInsertionMode = 29, MayBeApzAware = 29,
ParserHasNotified = 30, BooleanFlagCount = 30,
MayBeApzAware = 31,
BooleanFlagCount = 32,
} }
#[repr(C)] #[repr(C)]
#[derive(Debug, Copy)] #[derive(Debug, Copy)]

View file

@ -72,6 +72,10 @@ macro_rules! apply_non_ts_list {
("-moz-broken", MozBroken, mozBroken, IN_BROKEN_STATE, _), ("-moz-broken", MozBroken, mozBroken, IN_BROKEN_STATE, _),
("-moz-loading", MozLoading, mozLoading, IN_LOADING_STATE, _), ("-moz-loading", MozLoading, mozLoading, IN_LOADING_STATE, _),
("-moz-suppressed", MozSuppressed, mozSuppressed, IN_SUPPRESSED_STATE, PSEUDO_CLASS_INTERNAL), ("-moz-suppressed", MozSuppressed, mozSuppressed, IN_SUPPRESSED_STATE, PSEUDO_CLASS_INTERNAL),
("-moz-has-dir-attr", MozHasDirAttr, mozHasDirAttr, IN_HAS_DIR_ATTR_STATE, PSEUDO_CLASS_INTERNAL),
("-moz-dir-attr-ltr", MozDirAttrLTR, mozDirAttrLTR, IN_HAS_DIR_ATTR_LTR_STATE, PSEUDO_CLASS_INTERNAL),
("-moz-dir-attr-rtl", MozDirAttrRTL, mozDirAttrRTL, IN_HAS_DIR_ATTR_RTL_STATE, PSEUDO_CLASS_INTERNAL),
("-moz-dir-attr-like-auto", MozDirAttrLikeAuto, mozDirAttrLikeAuto, IN_HAS_DIR_ATTR_LIKE_AUTO_STATE, PSEUDO_CLASS_INTERNAL),
("-moz-autofill", MozAutofill, mozAutofill, IN_AUTOFILL_STATE, PSEUDO_CLASS_INTERNAL), ("-moz-autofill", MozAutofill, mozAutofill, IN_AUTOFILL_STATE, PSEUDO_CLASS_INTERNAL),
("-moz-autofill-preview", MozAutofillPreview, mozAutofillPreview, IN_AUTOFILL_PREVIEW_STATE, PSEUDO_CLASS_INTERNAL), ("-moz-autofill-preview", MozAutofillPreview, mozAutofillPreview, IN_AUTOFILL_PREVIEW_STATE, PSEUDO_CLASS_INTERNAL),

View file

@ -1517,6 +1517,10 @@ impl<'le> ::selectors::Element for GeckoElement<'le> {
NonTSPseudoClass::MozMeterOptimum | NonTSPseudoClass::MozMeterOptimum |
NonTSPseudoClass::MozMeterSubOptimum | NonTSPseudoClass::MozMeterSubOptimum |
NonTSPseudoClass::MozMeterSubSubOptimum | NonTSPseudoClass::MozMeterSubSubOptimum |
NonTSPseudoClass::MozHasDirAttr |
NonTSPseudoClass::MozDirAttrLTR |
NonTSPseudoClass::MozDirAttrRTL |
NonTSPseudoClass::MozDirAttrLikeAuto |
NonTSPseudoClass::MozAutofill | NonTSPseudoClass::MozAutofill |
NonTSPseudoClass::MozAutofillPreview => { NonTSPseudoClass::MozAutofillPreview => {
self.get_state().intersects(pseudo_class.state_flag()) self.get_state().intersects(pseudo_class.state_flag())