aboutsummaryrefslogtreecommitdiffstats
path: root/components/style
diff options
context:
space:
mode:
Diffstat (limited to 'components/style')
-rw-r--r--components/style/gecko/pseudo_element.rs2
-rw-r--r--components/style/gecko/pseudo_element_definition.mako.rs30
-rw-r--r--components/style/stylist.rs7
3 files changed, 35 insertions, 4 deletions
diff --git a/components/style/gecko/pseudo_element.rs b/components/style/gecko/pseudo_element.rs
index 73fe905ebd8..b30d7764d17 100644
--- a/components/style/gecko/pseudo_element.rs
+++ b/components/style/gecko/pseudo_element.rs
@@ -14,7 +14,7 @@ use properties::{ComputedValues, PropertyFlags};
use properties::longhands::display::computed_value::T as Display;
use selector_parser::{NonTSPseudoClass, PseudoElementCascadeType, SelectorImpl};
use std::fmt;
-use str::starts_with_ignore_ascii_case;
+use str::{starts_with_ignore_ascii_case, string_as_ascii_lowercase};
use string_cache::Atom;
use thin_slice::ThinBoxedSlice;
use values::serialize_atom_identifier;
diff --git a/components/style/gecko/pseudo_element_definition.mako.rs b/components/style/gecko/pseudo_element_definition.mako.rs
index 2395ff32f78..7c45ee8bfb7 100644
--- a/components/style/gecko/pseudo_element_definition.mako.rs
+++ b/components/style/gecko/pseudo_element_definition.mako.rs
@@ -13,6 +13,9 @@ pub enum PseudoElement {
${pseudo.capitalized_pseudo()},
% endif
% endfor
+ /// ::-webkit-* that we don't recognize
+ /// https://github.com/whatwg/compat/issues/103
+ UnknownWebkit(Atom),
}
/// Important: If you change this, you should also update Gecko's
@@ -47,11 +50,12 @@ PseudoElement::${pseudo.capitalized_pseudo()}${"({})".format(tree_arg) if pseudo
impl PseudoElement {
/// Get the pseudo-element as an atom.
#[inline]
- pub fn atom(&self) -> Atom {
+ fn atom(&self) -> Atom {
match *self {
% for pseudo in PSEUDOS:
${pseudo_element_variant(pseudo)} => atom!("${pseudo.value}"),
% endfor
+ PseudoElement::UnknownWebkit(..) => unreachable!(),
}
}
@@ -62,6 +66,7 @@ impl PseudoElement {
% for i, pseudo in enumerate(PSEUDOS):
${pseudo_element_variant(pseudo)} => ${i},
% endfor
+ PseudoElement::UnknownWebkit(..) => unreachable!(),
}
}
@@ -105,6 +110,12 @@ impl PseudoElement {
}
}
+ /// Whether this pseudo-element is an unknown Webkit-prefixed pseudo-element.
+ #[inline]
+ pub fn is_unknown_webkit_pseudo_element(&self) -> bool {
+ matches!(*self, PseudoElement::UnknownWebkit(..))
+ }
+
/// Gets the flags associated to this pseudo-element, or 0 if it's an
/// anonymous box.
pub fn flags(&self) -> u32 {
@@ -123,6 +134,7 @@ impl PseudoElement {
structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_${pseudo.pseudo_ident},
% endif
% endfor
+ PseudoElement::UnknownWebkit(..) => 0,
}
}
@@ -143,7 +155,7 @@ impl PseudoElement {
/// Construct a `CSSPseudoElementType` from a pseudo-element
#[inline]
- pub fn pseudo_type(&self) -> CSSPseudoElementType {
+ fn pseudo_type(&self) -> CSSPseudoElementType {
use gecko_bindings::structs::CSSPseudoElementType_InheritingAnonBox;
match *self {
@@ -158,6 +170,7 @@ impl PseudoElement {
PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType::NonInheritingAnonBox,
% endif
% endfor
+ PseudoElement::UnknownWebkit(..) => unreachable!(),
}
}
@@ -245,6 +258,15 @@ impl PseudoElement {
if starts_with_ignore_ascii_case(name, "-moz-tree-") {
return PseudoElement::tree_pseudo_element(name, Box::new([]))
}
+ if unsafe {
+ structs::StaticPrefs_sVarCache_layout_css_unknown_webkit_pseudo_element
+ } {
+ const WEBKIT_PREFIX: &str = "-webkit-";
+ if starts_with_ignore_ascii_case(name, WEBKIT_PREFIX) {
+ let part = string_as_ascii_lowercase(&name[WEBKIT_PREFIX.len()..]);
+ return Some(PseudoElement::UnknownWebkit(part.into()));
+ }
+ }
}
}
@@ -275,6 +297,10 @@ impl ToCss for PseudoElement {
% for pseudo in PSEUDOS:
${pseudo_element_variant(pseudo)} => dest.write_str("${pseudo.value}")?,
% endfor
+ PseudoElement::UnknownWebkit(ref atom) => {
+ dest.write_str(":-webkit-")?;
+ serialize_atom_identifier(atom, dest)?;
+ }
}
if let Some(args) = self.tree_pseudo_args() {
if !args.is_empty() {
diff --git a/components/style/stylist.rs b/components/style/stylist.rs
index 1fbf493667f..5dbb4dd5dc8 100644
--- a/components/style/stylist.rs
+++ b/components/style/stylist.rs
@@ -1878,7 +1878,9 @@ impl ElementAndPseudoRules {
pseudo_element: Option<&PseudoElement>,
quirks_mode: QuirksMode,
) -> Result<(), FailedAllocationError> {
- debug_assert!(pseudo_element.map_or(true, |pseudo| !pseudo.is_precomputed()));
+ debug_assert!(pseudo_element.map_or(true, |pseudo| {
+ !pseudo.is_precomputed() && !pseudo.is_unknown_webkit_pseudo_element()
+ }));
let map = match pseudo_element {
None => &mut self.element_map,
@@ -2191,6 +2193,9 @@ impl CascadeData {
));
continue;
}
+ if pseudo.is_unknown_webkit_pseudo_element() {
+ continue;
+ }
}
let hashes = AncestorHashes::new(&selector, quirks_mode);