mirror of
https://github.com/servo/servo.git
synced 2025-08-07 06:25:32 +01:00
stylo: Convert pseudo-elements to an Atom wrapper.
This commit is contained in:
parent
b1091dff58
commit
d612d9f5ef
3 changed files with 129 additions and 280 deletions
|
@ -42,3 +42,28 @@ fn assert_restyle_hints_match() {
|
|||
check_enum_value_non_static!(nsRestyleHint::eRestyle_SomeDescendants, RESTYLE_DESCENDANTS.bits());
|
||||
check_enum_value_non_static!(nsRestyleHint::eRestyle_LaterSiblings, RESTYLE_LATER_SIBLINGS.bits());
|
||||
}
|
||||
|
||||
// Note that we can't call each_pseudo_element, parse_pseudo_element, or
|
||||
// similar, because we'd need the foreign atom symbols to link.
|
||||
#[test]
|
||||
fn assert_basic_pseudo_elements() {
|
||||
let mut saw_before = false;
|
||||
let mut saw_after = false;
|
||||
|
||||
macro_rules! pseudo_element {
|
||||
(":before", $atom:expr, false) => {
|
||||
saw_before = true;
|
||||
};
|
||||
(":after", $atom:expr, false) => {
|
||||
saw_after = true;
|
||||
};
|
||||
($pseudo_str_with_colon:expr, $atom:expr, $is_anon_box:expr) => {
|
||||
// Do nothing
|
||||
};
|
||||
}
|
||||
|
||||
include!("../../components/style/generated/gecko_pseudo_element_helper.rs");
|
||||
|
||||
assert!(saw_before);
|
||||
assert!(saw_after);
|
||||
}
|
||||
|
|
|
@ -134,6 +134,21 @@ impl WeakAtom {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Debug for WeakAtom {
|
||||
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(w, "Gecko WeakAtom({:p}, {})", self, self)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for WeakAtom {
|
||||
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
|
||||
for c in self.chars() {
|
||||
try!(write!(w, "{}", c.unwrap_or(char::REPLACEMENT_CHARACTER)))
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
impl Atom {
|
||||
pub unsafe fn with<F>(ptr: *mut nsIAtom, callback: &mut F) where F: FnMut(&Atom) {
|
||||
let atom = Atom(WeakAtom::new(ptr));
|
||||
|
@ -217,16 +232,15 @@ impl Deserialize for Atom {
|
|||
|
||||
impl fmt::Debug for Atom {
|
||||
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
|
||||
write!(w, "Gecko Atom {:p}", self.0)
|
||||
write!(w, "Gecko Atom({:p}, {})", self.0, self)
|
||||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for Atom {
|
||||
fn fmt(&self, w: &mut fmt::Formatter) -> fmt::Result {
|
||||
for c in self.chars() {
|
||||
try!(write!(w, "{}", c.unwrap_or(char::REPLACEMENT_CHARACTER)))
|
||||
unsafe {
|
||||
(&*self.0).fmt(w)
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue