Log element during selector matching

MozReview-Commit-ID: D8eFyRCy5BR
This commit is contained in:
J. Ryan Stinnett 2017-06-06 16:36:25 -05:00
parent eaefcbe551
commit 6b1b8bbee8
8 changed files with 35 additions and 2 deletions

1
Cargo.lock generated
View file

@ -2518,6 +2518,7 @@ dependencies = [
"bitflags 0.7.0 (registry+https://github.com/rust-lang/crates.io-index)",
"cssparser 0.13.7 (registry+https://github.com/rust-lang/crates.io-index)",
"fnv 1.0.5 (registry+https://github.com/rust-lang/crates.io-index)",
"log 0.3.8 (registry+https://github.com/rust-lang/crates.io-index)",
"matches 0.1.4 (registry+https://github.com/rust-lang/crates.io-index)",
"phf 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",
"phf_codegen 0.7.21 (registry+https://github.com/rust-lang/crates.io-index)",

View file

@ -151,6 +151,12 @@ impl fmt::Debug for Element {
}
}
impl fmt::Debug for Root<Element> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
(**self).fmt(f)
}
}
#[derive(PartialEq, HeapSizeOf)]
pub enum ElementCreator {
ParserCreated(u64),

View file

@ -25,6 +25,7 @@ gecko_like_types = []
bitflags = "0.7"
matches = "0.1"
cssparser = "0.13.7"
log = "0.3"
fnv = "1.0"
phf = "0.7.18"
precomputed-hash = "0.1"

View file

@ -4,6 +4,7 @@
#[macro_use] extern crate bitflags;
#[macro_use] extern crate cssparser;
#[macro_use] extern crate log;
#[macro_use] extern crate matches;
extern crate fnv;
extern crate phf;

View file

@ -198,7 +198,7 @@ fn may_match<E>(hashes: &AncestorHashes,
/// and `is_unvisited` are based on relevant link state of only the current
/// complex selector being matched (not the global relevant link status for all
/// selectors in `MatchingContext`).
#[derive(PartialEq, Eq, Copy, Clone)]
#[derive(PartialEq, Eq, Copy, Clone, Debug)]
pub enum RelevantLinkStatus {
/// Looking for a possible relevant link. This is the initial mode when
/// matching a selector.
@ -429,6 +429,9 @@ fn matches_complex_selector_internal<E, F>(mut selector_iter: SelectorIter<E::Im
matches_simple_selector(simple, element, context, &relevant_link, flags_setter)
});
debug!("Matching for {:?}, simple selector {:?}, relevant link {:?}",
element, selector_iter, relevant_link);
let combinator = selector_iter.next_sequence();
let siblings = combinator.map_or(false, |c| c.is_sibling());
if siblings {

View file

@ -453,6 +453,16 @@ impl<'a, Impl: SelectorImpl> Iterator for SelectorIter<'a, Impl> {
}
}
impl<'a, Impl: SelectorImpl> fmt::Debug for SelectorIter<'a, Impl> {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let iter = self.iter.clone().rev();
for component in iter {
component.to_css(f)?
}
Ok(())
}
}
/// An iterator over all simple selectors belonging to ancestors.
pub struct AncestorIter<'a, Impl: 'a + SelectorImpl>(SelectorIter<'a, Impl>);
impl<'a, Impl: 'a + SelectorImpl> AncestorIter<'a, Impl> {

View file

@ -8,8 +8,9 @@
use attr::{AttrSelectorOperation, NamespaceConstraint};
use matching::{ElementSelectorFlags, MatchingContext, RelevantLinkStatus};
use parser::SelectorImpl;
use std::fmt::Debug;
pub trait Element: Sized {
pub trait Element: Sized + Debug {
type Impl: SelectorImpl;
fn parent_element(&self) -> Option<Self>;

View file

@ -29,6 +29,7 @@ use smallvec::SmallVec;
use std::cell::Cell;
use std::clone::Clone;
use std::cmp;
use std::fmt;
/// When the ElementState of an element (like IN_HOVER_STATE) changes,
/// certain pseudo-classes (like :hover) may require us to restyle that
@ -607,6 +608,15 @@ impl<'a, E> ElementWrapper<'a, E>
}
}
impl<'a, E> fmt::Debug for ElementWrapper<'a, E>
where E: TElement,
{
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
// Ignore other fields for now, can change later if needed.
self.element.fmt(f)
}
}
#[cfg(feature = "gecko")]
fn dir_selector_to_state(s: &[u16]) -> ElementState {
// Jump through some hoops to deal with our Box<[u16]> thing.