mirror of
https://github.com/servo/servo.git
synced 2025-08-11 00:15:32 +01:00
Bug 1322945 - Improve ergonomics and share more code for style crate DOM tree logging. r=heycam
MozReview-Commit-ID: 4Fy3ujpI4n2
This commit is contained in:
parent
3a56954069
commit
61eadbe7f1
5 changed files with 113 additions and 83 deletions
|
@ -50,6 +50,20 @@ use stylist::ApplicableDeclarationBlock;
|
|||
#[derive(Clone, Copy)]
|
||||
pub struct GeckoNode<'ln>(pub &'ln RawGeckoNode);
|
||||
|
||||
impl<'ln> fmt::Debug for GeckoNode<'ln> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
if let Some(el) = self.as_element() {
|
||||
el.fmt(f)
|
||||
} else {
|
||||
if self.is_text_node() {
|
||||
write!(f, "<text node> ({:#x})", self.opaque().0)
|
||||
} else {
|
||||
write!(f, "<non-text node> ({:#x})", self.opaque().0)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'ln> GeckoNode<'ln> {
|
||||
fn from_content(content: &'ln nsIContent) -> Self {
|
||||
GeckoNode(&content._base)
|
||||
|
@ -102,19 +116,6 @@ impl<'ln> TNode for GeckoNode<'ln> {
|
|||
GeckoNode(&*(n.0 as *mut RawGeckoNode))
|
||||
}
|
||||
|
||||
fn dump(self) {
|
||||
if self.is_text_node() {
|
||||
println!("Text ({:?})", &self.0 as *const _);
|
||||
} else {
|
||||
let el = self.as_element().unwrap();
|
||||
println!("Element {} ({:?})", el.get_local_name(), &el.0 as *const _);
|
||||
}
|
||||
}
|
||||
|
||||
fn dump_style(self) {
|
||||
unimplemented!()
|
||||
}
|
||||
|
||||
fn children(self) -> LayoutIterator<GeckoChildrenIterator<'ln>> {
|
||||
let maybe_iter = unsafe { Gecko_MaybeCreateStyleChildrenIterator(self.0) };
|
||||
if let Some(iter) = maybe_iter.into_owned_opt() {
|
||||
|
@ -211,7 +212,7 @@ impl<'le> fmt::Debug for GeckoElement<'le> {
|
|||
if let Some(id) = self.get_id() {
|
||||
try!(write!(f, " id={}", id));
|
||||
}
|
||||
write!(f, "> ({:?})", self.0 as *const _)
|
||||
write!(f, "> ({:#x})", self.as_node().opaque().0)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue