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>
This commit is contained in:
Boris Zbarsky 2017-06-19 14:44:12 -04:00
parent e41b7d06b4
commit e4660c2b5b
5 changed files with 94 additions and 70 deletions

View file

@ -120,6 +120,18 @@ bitflags! {
const IN_LTR_STATE = 1 << 44,
/// State that elements that match :dir(rtl) are in.
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.
const IN_AUTOFILL_STATE = 1 << 50,
/// Non-standard & undocumented.

View file

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

View file

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

View file

@ -72,6 +72,10 @@ macro_rules! apply_non_ts_list {
("-moz-broken", MozBroken, mozBroken, IN_BROKEN_STATE, _),
("-moz-loading", MozLoading, mozLoading, IN_LOADING_STATE, _),
("-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-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::MozMeterSubOptimum |
NonTSPseudoClass::MozMeterSubSubOptimum |
NonTSPseudoClass::MozHasDirAttr |
NonTSPseudoClass::MozDirAttrLTR |
NonTSPseudoClass::MozDirAttrRTL |
NonTSPseudoClass::MozDirAttrLikeAuto |
NonTSPseudoClass::MozAutofill |
NonTSPseudoClass::MozAutofillPreview => {
self.get_state().intersects(pseudo_class.state_flag())