mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01: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:
|
% for pseudo in PSEUDOS:
|
||||||
/// ${pseudo.value}
|
/// ${pseudo.value}
|
||||||
% if pseudo.is_tree_pseudo_element():
|
% if pseudo.is_tree_pseudo_element():
|
||||||
${pseudo.capitalized()}(ThinBoxedSlice<Atom>),
|
${pseudo.capitalized_pseudo()}(ThinBoxedSlice<Atom>),
|
||||||
% else:
|
% else:
|
||||||
${pseudo.capitalized()},
|
${pseudo.capitalized_pseudo()},
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
|
@ -41,7 +41,7 @@ pub const EAGER_PSEUDOS: [PseudoElement; EAGER_PSEUDO_COUNT] = [
|
||||||
];
|
];
|
||||||
|
|
||||||
<%def name="pseudo_element_variant(pseudo, tree_arg='..')">\
|
<%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>
|
</%def>
|
||||||
|
|
||||||
impl PseudoElement {
|
impl PseudoElement {
|
||||||
|
@ -120,7 +120,7 @@ impl PseudoElement {
|
||||||
% elif pseudo.is_anon_box():
|
% elif pseudo.is_anon_box():
|
||||||
structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS,
|
structs::CSS_PSEUDO_ELEMENT_ENABLED_IN_UA_SHEETS,
|
||||||
% else:
|
% else:
|
||||||
structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_${pseudo.original_ident},
|
structs::SERVO_CSS_PSEUDO_ELEMENT_FLAGS_${pseudo.pseudo_ident},
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ impl PseudoElement {
|
||||||
match type_ {
|
match type_ {
|
||||||
% for pseudo in PSEUDOS:
|
% for pseudo in PSEUDOS:
|
||||||
% if not pseudo.is_anon_box():
|
% if not pseudo.is_anon_box():
|
||||||
CSSPseudoElementType::${pseudo.original_ident} => {
|
CSSPseudoElementType::${pseudo.pseudo_ident} => {
|
||||||
Some(${pseudo_element_variant(pseudo)})
|
Some(${pseudo_element_variant(pseudo)})
|
||||||
},
|
},
|
||||||
% endif
|
% endif
|
||||||
|
@ -149,13 +149,13 @@ impl PseudoElement {
|
||||||
match *self {
|
match *self {
|
||||||
% for pseudo in PSEUDOS:
|
% for pseudo in PSEUDOS:
|
||||||
% if not pseudo.is_anon_box():
|
% 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():
|
% elif pseudo.is_tree_pseudo_element():
|
||||||
PseudoElement::${pseudo.capitalized()}(..) => CSSPseudoElementType::XULTree,
|
PseudoElement::${pseudo.capitalized_pseudo()}(..) => CSSPseudoElementType::XULTree,
|
||||||
% elif pseudo.is_inheriting_anon_box():
|
% elif pseudo.is_inheriting_anon_box():
|
||||||
PseudoElement::${pseudo.capitalized()} => CSSPseudoElementType_InheritingAnonBox,
|
PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType_InheritingAnonBox,
|
||||||
% else:
|
% else:
|
||||||
PseudoElement::${pseudo.capitalized()} => CSSPseudoElementType::NonInheritingAnonBox,
|
PseudoElement::${pseudo.capitalized_pseudo()} => CSSPseudoElementType::NonInheritingAnonBox,
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
}
|
}
|
||||||
|
@ -171,7 +171,7 @@ impl PseudoElement {
|
||||||
pub fn tree_pseudo_args(&self) -> Option<<&[Atom]> {
|
pub fn tree_pseudo_args(&self) -> Option<<&[Atom]> {
|
||||||
match *self {
|
match *self {
|
||||||
% for pseudo in TREE_PSEUDOS:
|
% for pseudo in TREE_PSEUDOS:
|
||||||
PseudoElement::${pseudo.capitalized()}(ref args) => Some(args),
|
PseudoElement::${pseudo.capitalized_pseudo()}(ref args) => Some(args),
|
||||||
% endfor
|
% endfor
|
||||||
_ => None,
|
_ => None,
|
||||||
}
|
}
|
||||||
|
@ -213,7 +213,7 @@ impl PseudoElement {
|
||||||
% for pseudo in PSEUDOS:
|
% for pseudo in PSEUDOS:
|
||||||
% if pseudo.is_tree_pseudo_element():
|
% if pseudo.is_tree_pseudo_element():
|
||||||
if atom == &atom!("${pseudo.value}") {
|
if atom == &atom!("${pseudo.value}") {
|
||||||
return Some(PseudoElement::${pseudo.capitalized()}(args.into()));
|
return Some(PseudoElement::${pseudo.capitalized_pseudo()}(args.into()));
|
||||||
}
|
}
|
||||||
% endif
|
% endif
|
||||||
% endfor
|
% endfor
|
||||||
|
|
|
@ -28,14 +28,14 @@ def gnu_symbolify(source, ident):
|
||||||
return "_ZN{}{}{}{}E".format(len(source.CLASS), source.CLASS, len(ident), ident)
|
return "_ZN{}{}{}{}E".format(len(source.CLASS), source.CLASS, len(ident), ident)
|
||||||
|
|
||||||
|
|
||||||
def msvc64_symbolify(source, ident):
|
def msvc64_symbolify(source, ident, ty):
|
||||||
return "?{}@{}@@2PEAV{}@@EA".format(ident, source.CLASS, source.TYPE)
|
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 "_".
|
# Prepend "\x01" to avoid LLVM prefixing the mangled name with "_".
|
||||||
# See https://github.com/rust-lang/rust/issues/36097
|
# 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:
|
class GkAtomSource:
|
||||||
|
@ -46,16 +46,6 @@ class GkAtomSource:
|
||||||
TYPE = "nsStaticAtom"
|
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:
|
class CSSAnonBoxesAtomSource:
|
||||||
PATTERN = re.compile('^(CSS_ANON_BOX|CSS_NON_INHERITING_ANON_BOX|CSS_WRAPPER_ANON_BOX)\(([^,]*),[^"]*"([^"]*)"()\)', # NOQA: E501
|
PATTERN = re.compile('^(CSS_ANON_BOX|CSS_NON_INHERITING_ANON_BOX|CSS_WRAPPER_ANON_BOX)\(([^,]*),[^"]*"([^"]*)"()\)', # NOQA: E501
|
||||||
re.MULTILINE)
|
re.MULTILINE)
|
||||||
|
@ -66,7 +56,6 @@ class CSSAnonBoxesAtomSource:
|
||||||
|
|
||||||
SOURCES = [
|
SOURCES = [
|
||||||
GkAtomSource,
|
GkAtomSource,
|
||||||
CSSPseudoElementsAtomSource,
|
|
||||||
CSSAnonBoxesAtomSource,
|
CSSAnonBoxesAtomSource,
|
||||||
]
|
]
|
||||||
|
|
||||||
|
@ -86,6 +75,11 @@ class Atom:
|
||||||
self.source = source
|
self.source = source
|
||||||
self.macro = macro_name
|
self.macro = macro_name
|
||||||
self.ty = ty
|
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():
|
if self.is_anon_box():
|
||||||
assert self.is_inheriting_anon_box() or self.is_non_inheriting_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)
|
return gnu_symbolify(self.source, self.original_ident)
|
||||||
|
|
||||||
def msvc32_symbol(self):
|
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):
|
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):
|
def type(self):
|
||||||
return self.ty
|
return self.ty
|
||||||
|
|
||||||
def capitalized(self):
|
def capitalized_pseudo(self):
|
||||||
return self.original_ident[0].upper() + self.original_ident[1:]
|
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):
|
def is_anon_box(self):
|
||||||
return self.type() == "nsICSSAnonBoxPseudo"
|
return self.type() == "nsICSSAnonBoxPseudo"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue