mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
style: Move CSS pseudo-element atoms to nsGkAtoms.
Differential Revision: https://phabricator.services.mozilla.com/D3283
This commit is contained in:
parent
cc3c059bfc
commit
99a292dd6d
2 changed files with 30 additions and 30 deletions
|
@ -8,9 +8,9 @@ pub enum PseudoElement {
|
|||
% for pseudo in PSEUDOS:
|
||||
/// ${pseudo.value}
|
||||
% if pseudo.is_tree_pseudo_element():
|
||||
${pseudo.capitalized()}(ThinBoxedSlice<Atom>),
|
||||
${pseudo.capitalized_pseudo()}(ThinBoxedSlice<Atom>),
|
||||
% else:
|
||||
${pseudo.capitalized()},
|
||||
${pseudo.capitalized_pseudo()},
|
||||
% endif
|
||||
% endfor
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ pub const EAGER_PSEUDOS: [PseudoElement; EAGER_PSEUDO_COUNT] = [
|
|||
];
|
||||
|
||||
<%def name="pseudo_element_variant(pseudo, tree_arg='..')">\
|
||||
PseudoElement::${pseudo.capitalized()}${"({})".format(tree_arg) if pseudo.is_tree_pseudo_element() else ""}\
|
||||
PseudoElement::${pseudo.capitalized_pseudo()}${"({})".format(tree_arg) if pseudo.is_tree_pseudo_element() else ""}\
|
||||
</%def>
|
||||
|
||||
impl PseudoElement {
|
||||
|
@ -120,7 +120,7 @@ impl PseudoElement {
|
|||
% elif pseudo.is_anon_box():
|
||||
structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS,
|
||||
% else:
|
||||
structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_${pseudo.original_ident},
|
||||
structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_${pseudo.pseudo_ident},
|
||||
% endif
|
||||
% endfor
|
||||
}
|
||||
|
@ -132,7 +132,7 @@ impl PseudoElement {
|
|||
match type_ {
|
||||
% for pseudo in PSEUDOS:
|
||||
% if not pseudo.is_anon_box():
|
||||
CSSPseudoElementType::${pseudo.original_ident} => {
|
||||
CSSPseudoElementType::${pseudo.pseudo_ident} => {
|
||||
Some(${pseudo_element_variant(pseudo)})
|
||||
},
|
||||
% endif
|
||||
|
@ -149,13 +149,13 @@ impl PseudoElement {
|
|||
match *self {
|
||||
% for pseudo in PSEUDOS:
|
||||
% if not pseudo.is_anon_box():
|
||||
PseudoElement::${pseudo.capitalized()} => CSSPseudoElementType::${pseudo.original_ident},
|
||||
PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType::${pseudo.pseudo_ident},
|
||||
% elif pseudo.is_tree_pseudo_element():
|
||||
PseudoElement::${pseudo.capitalized()}(..) => CSSPseudoElementType::XULTree,
|
||||
PseudoElement::${pseudo.capitalized_pseudo()}(..) => CSSPseudoElementType::XULTree,
|
||||
% elif pseudo.is_inheriting_anon_box():
|
||||
PseudoElement::${pseudo.capitalized()} => CSSPseudoElementType_InheritingAnonBox,
|
||||
PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType_InheritingAnonBox,
|
||||
% else:
|
||||
PseudoElement::${pseudo.capitalized()} => CSSPseudoElementType::NonInheritingAnonBox,
|
||||
PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType::NonInheritingAnonBox,
|
||||
% endif
|
||||
% endfor
|
||||
}
|
||||
|
@ -171,7 +171,7 @@ impl PseudoElement {
|
|||
pub fn tree_pseudo_args(&self) -> Option<<&[Atom]> {
|
||||
match *self {
|
||||
% for pseudo in TREE_PSEUDOS:
|
||||
PseudoElement::${pseudo.capitalized()}(ref args) => Some(args),
|
||||
PseudoElement::${pseudo.capitalized_pseudo()}(ref args) => Some(args),
|
||||
% endfor
|
||||
_ => None,
|
||||
}
|
||||
|
@ -213,7 +213,7 @@ impl PseudoElement {
|
|||
% for pseudo in PSEUDOS:
|
||||
% if pseudo.is_tree_pseudo_element():
|
||||
if atom == &atom!("${pseudo.value}") {
|
||||
return Some(PseudoElement::${pseudo.capitalized()}(args.into()));
|
||||
return Some(PseudoElement::${pseudo.capitalized_pseudo()}(args.into()));
|
||||
}
|
||||
% endif
|
||||
% endfor
|
||||
|
|
|
@ -28,14 +28,14 @@ def gnu_symbolify(source, ident):
|
|||
return "_ZN{}{}{}{}E".format(len(source.CLASS), source.CLASS, len(ident), ident)
|
||||
|
||||
|
||||
def msvc64_symbolify(source, ident):
|
||||
return "?{}@{}@@2PEAV{}@@EA".format(ident, source.CLASS, source.TYPE)
|
||||
def msvc64_symbolify(source, ident, ty):
|
||||
return "?{}@{}@@2PEAV{}@@EA".format(ident, source.CLASS, ty)
|
||||
|
||||
|
||||
def msvc32_symbolify(source, ident):
|
||||
def msvc32_symbolify(source, ident, ty):
|
||||
# Prepend "\x01" to avoid LLVM prefixing the mangled name with "_".
|
||||
# See https://github.com/rust-lang/rust/issues/36097
|
||||
return "\\x01?{}@{}@@2PAV{}@@A".format(ident, source.CLASS, source.TYPE)
|
||||
return "\\x01?{}@{}@@2PAV{}@@A".format(ident, source.CLASS, ty)
|
||||
|
||||
|
||||
class GkAtomSource:
|
||||
|
@ -46,16 +46,6 @@ class GkAtomSource:
|
|||
TYPE = "nsStaticAtom"
|
||||
|
||||
|
||||
class CSSPseudoElementsAtomSource:
|
||||
PATTERN = re.compile('^(CSS_PSEUDO_ELEMENT)\(([^,]*),[^"]*"([^"]*)",()',
|
||||
re.MULTILINE)
|
||||
FILE = "include/nsCSSPseudoElementList.h"
|
||||
CLASS = "nsCSSPseudoElements"
|
||||
# NB: nsICSSPseudoElement is effectively the same as a nsStaticAtom, but we need
|
||||
# this for MSVC name mangling.
|
||||
TYPE = "nsICSSPseudoElement"
|
||||
|
||||
|
||||
class CSSAnonBoxesAtomSource:
|
||||
PATTERN = re.compile('^(CSS_ANON_BOX|CSS_NON_INHERITING_ANON_BOX|CSS_WRAPPER_ANON_BOX)\(([^,]*),[^"]*"([^"]*)"()\)', # NOQA: E501
|
||||
re.MULTILINE)
|
||||
|
@ -66,7 +56,6 @@ class CSSAnonBoxesAtomSource:
|
|||
|
||||
SOURCES = [
|
||||
GkAtomSource,
|
||||
CSSPseudoElementsAtomSource,
|
||||
CSSAnonBoxesAtomSource,
|
||||
]
|
||||
|
||||
|
@ -86,6 +75,11 @@ class Atom:
|
|||
self.source = source
|
||||
self.macro = macro_name
|
||||
self.ty = ty
|
||||
if self.is_pseudo():
|
||||
if self.is_non_anon_box_pseudo():
|
||||
self.pseudo_ident = (ident.split("_", 1))[1]
|
||||
else:
|
||||
self.pseudo_ident = ident
|
||||
if self.is_anon_box():
|
||||
assert self.is_inheriting_anon_box() or self.is_non_inheriting_anon_box()
|
||||
|
||||
|
@ -96,16 +90,22 @@ class Atom:
|
|||
return gnu_symbolify(self.source, self.original_ident)
|
||||
|
||||
def msvc32_symbol(self):
|
||||
return msvc32_symbolify(self.source, self.original_ident)
|
||||
return msvc32_symbolify(self.source, self.original_ident, self.ty)
|
||||
|
||||
def msvc64_symbol(self):
|
||||
return msvc64_symbolify(self.source, self.original_ident)
|
||||
return msvc64_symbolify(self.source, self.original_ident, self.ty)
|
||||
|
||||
def type(self):
|
||||
return self.ty
|
||||
|
||||
def capitalized(self):
|
||||
return self.original_ident[0].upper() + self.original_ident[1:]
|
||||
def capitalized_pseudo(self):
|
||||
return self.pseudo_ident[0].upper() + self.pseudo_ident[1:]
|
||||
|
||||
def is_pseudo(self):
|
||||
return self.is_non_anon_box_pseudo() or self.is_anon_box()
|
||||
|
||||
def is_non_anon_box_pseudo(self):
|
||||
return self.type() == "nsICSSPseudoElement"
|
||||
|
||||
def is_anon_box(self):
|
||||
return self.type() == "nsICSSAnonBoxPseudo"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue