mirror of
https://github.com/servo/servo.git
synced 2025-07-23 15:23:42 +01:00
style: Make input[type=number] pseudo-elements accessible to chrome.
Bug: 1433389 Reviewed-by: jwatt MozReview-Commit-ID: 2ycajPYd3CV
This commit is contained in:
parent
f2df3052d9
commit
b76bbdf501
3 changed files with 62 additions and 28 deletions
|
@ -124,16 +124,26 @@ impl PseudoElement {
|
|||
!self.is_eager() && !self.is_precomputed()
|
||||
}
|
||||
|
||||
/// Whether this pseudo-element is web-exposed.
|
||||
pub fn exposed_in_non_ua_sheets(&self) -> bool {
|
||||
(self.flags() & structs::CSS_PSEUDO_ELEMENT_UA_SHEET_ONLY) == 0
|
||||
}
|
||||
|
||||
/// Whether this pseudo-element supports user action selectors.
|
||||
pub fn supports_user_action_state(&self) -> bool {
|
||||
(self.flags() & structs::CSS_PSEUDO_ELEMENT_SUPPORTS_USER_ACTION_STATE) != 0
|
||||
}
|
||||
|
||||
/// Whether this pseudo-element is enabled for all content.
|
||||
pub fn enabled_in_content(&self) -> bool {
|
||||
(self.flags() & structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS_AND_CHROME) == 0
|
||||
}
|
||||
|
||||
/// Whether this pseudo is enabled explicitly in UA sheets.
|
||||
pub fn enabled_in_ua_sheets(&self) -> bool {
|
||||
(self.flags() & structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS) != 0
|
||||
}
|
||||
|
||||
/// Whether this pseudo is enabled explicitly in chrome sheets.
|
||||
pub fn enabled_in_chrome(&self) -> bool {
|
||||
(self.flags() & structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_CHROME) != 0
|
||||
}
|
||||
|
||||
/// Whether this pseudo-element skips flex/grid container display-based
|
||||
/// fixup.
|
||||
#[inline]
|
||||
|
|
|
@ -114,7 +114,7 @@ impl PseudoElement {
|
|||
% if pseudo.is_tree_pseudo_element():
|
||||
0,
|
||||
% elif pseudo.is_anon_box():
|
||||
structs::CSS_PSEUDO_ELEMENT_UA_SHEET_ONLY,
|
||||
structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS,
|
||||
% else:
|
||||
structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_${pseudo.original_ident},
|
||||
% endif
|
||||
|
@ -224,19 +224,24 @@ impl PseudoElement {
|
|||
///
|
||||
/// Returns `None` if the pseudo-element is not recognised.
|
||||
#[inline]
|
||||
pub fn from_slice(s: &str, in_ua_stylesheet: bool) -> Option<Self> {
|
||||
#[allow(unused_imports)] use std::ascii::AsciiExt;
|
||||
|
||||
pub fn from_slice(name: &str) -> Option<Self> {
|
||||
// We don't need to support tree pseudos because functional
|
||||
// pseudo-elements needs arguments, and thus should be created
|
||||
// via other methods.
|
||||
% for pseudo in SIMPLE_PSEUDOS:
|
||||
if in_ua_stylesheet || ${pseudo_element_variant(pseudo)}.exposed_in_non_ua_sheets() {
|
||||
if s.eq_ignore_ascii_case("${pseudo.value[1:]}") {
|
||||
return Some(${pseudo_element_variant(pseudo)});
|
||||
match_ignore_ascii_case! { name,
|
||||
% for pseudo in SIMPLE_PSEUDOS:
|
||||
"${pseudo.value[1:]}" => {
|
||||
return Some(${pseudo_element_variant(pseudo)})
|
||||
}
|
||||
% endfor
|
||||
_ => {
|
||||
// FIXME: -moz-tree check should probably be
|
||||
// ascii-case-insensitive.
|
||||
if name.starts_with("-moz-tree-") {
|
||||
return PseudoElement::tree_pseudo_element(name, Box::new([]))
|
||||
}
|
||||
}
|
||||
% endfor
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
|
|
@ -159,10 +159,10 @@ impl NonTSPseudoClass {
|
|||
/// Returns whether the pseudo-class is enabled in content sheets.
|
||||
fn is_enabled_in_content(&self) -> bool {
|
||||
use gecko_bindings::structs::mozilla;
|
||||
match self {
|
||||
match *self {
|
||||
// For pseudo-classes with pref, the availability in content
|
||||
// depends on the pref.
|
||||
&NonTSPseudoClass::Fullscreen =>
|
||||
NonTSPseudoClass::Fullscreen =>
|
||||
unsafe { mozilla::StylePrefs_sUnprefixedFullscreenApiEnabled },
|
||||
// Otherwise, a pseudo-class is enabled in content when it
|
||||
// doesn't have any enabled flag.
|
||||
|
@ -322,6 +322,25 @@ impl<'a> SelectorParser<'a> {
|
|||
|
||||
return false;
|
||||
}
|
||||
|
||||
fn is_pseudo_element_enabled(
|
||||
&self,
|
||||
pseudo_element: &PseudoElement,
|
||||
) -> bool {
|
||||
if pseudo_element.enabled_in_content() {
|
||||
return true;
|
||||
}
|
||||
|
||||
if self.in_user_agent_stylesheet() && pseudo_element.enabled_in_ua_sheets() {
|
||||
return true;
|
||||
}
|
||||
|
||||
if self.chrome_rules_enabled() && pseudo_element.enabled_in_chrome() {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
|
||||
|
@ -418,17 +437,15 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
|
|||
location: SourceLocation,
|
||||
name: CowRcStr<'i>,
|
||||
) -> Result<PseudoElement, ParseError<'i>> {
|
||||
PseudoElement::from_slice(&name, self.in_user_agent_stylesheet())
|
||||
.or_else(|| {
|
||||
// FIXME: -moz-tree check should probably be
|
||||
// ascii-case-insensitive.
|
||||
if name.starts_with("-moz-tree-") {
|
||||
PseudoElement::tree_pseudo_element(&name, Box::new([]))
|
||||
} else {
|
||||
None
|
||||
}
|
||||
})
|
||||
.ok_or(location.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name.clone())))
|
||||
if let Some(pseudo) = PseudoElement::from_slice(&name) {
|
||||
if self.is_pseudo_element_enabled(&pseudo) {
|
||||
return Ok(pseudo);
|
||||
}
|
||||
}
|
||||
|
||||
Err(location.new_custom_error(
|
||||
SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)
|
||||
))
|
||||
}
|
||||
|
||||
fn parse_functional_pseudo_element<'t>(
|
||||
|
@ -456,7 +473,9 @@ impl<'a, 'i> ::selectors::Parser<'i> for SelectorParser<'a> {
|
|||
return Ok(pseudo);
|
||||
}
|
||||
}
|
||||
Err(parser.new_custom_error(SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name.clone())))
|
||||
Err(parser.new_custom_error(
|
||||
SelectorParseErrorKind::UnsupportedPseudoClassOrElement(name)
|
||||
))
|
||||
}
|
||||
|
||||
fn default_namespace(&self) -> Option<Namespace> {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue