aboutsummaryrefslogtreecommitdiffstats
path: root/components
diff options
context:
space:
mode:
authorJ. Ryan Stinnett <jryans@gmail.com>2017-06-06 16:36:25 -0500
committerJ. Ryan Stinnett <jryans@gmail.com>2017-06-07 14:23:53 -0500
commit6b1b8bbee83a090b67dbccb83ac527052559a5a6 (patch)
treeb030192f5a88a97d7734af280716eb371891cd81 /components
parenteaefcbe55186b874b96c6dffc7e8dd2b6283634d (diff)
downloadservo-6b1b8bbee83a090b67dbccb83ac527052559a5a6.tar.gz
servo-6b1b8bbee83a090b67dbccb83ac527052559a5a6.zip
Log element during selector matching
MozReview-Commit-ID: D8eFyRCy5BR
Diffstat (limited to 'components')
-rw-r--r--components/script/dom/element.rs6
-rw-r--r--components/selectors/Cargo.toml1
-rw-r--r--components/selectors/lib.rs1
-rw-r--r--components/selectors/matching.rs5
-rw-r--r--components/selectors/parser.rs10
-rw-r--r--components/selectors/tree.rs3
-rw-r--r--components/style/restyle_hints.rs10
7 files changed, 34 insertions, 2 deletions
diff --git a/components/script/dom/element.rs b/components/script/dom/element.rs
index f875986edd2..c0d4b6b700a 100644
--- a/components/script/dom/element.rs
+++ b/components/script/dom/element.rs
@@ -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),
diff --git a/components/selectors/Cargo.toml b/components/selectors/Cargo.toml
index 15aba3d1811..90ff6ecaa17 100644
--- a/components/selectors/Cargo.toml
+++ b/components/selectors/Cargo.toml
@@ -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"
diff --git a/components/selectors/lib.rs b/components/selectors/lib.rs
index a6f4acd3d84..130475271fc 100644
--- a/components/selectors/lib.rs
+++ b/components/selectors/lib.rs
@@ -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;
diff --git a/components/selectors/matching.rs b/components/selectors/matching.rs
index 3c269427421..84ddde2b261 100644
--- a/components/selectors/matching.rs
+++ b/components/selectors/matching.rs
@@ -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 {
diff --git a/components/selectors/parser.rs b/components/selectors/parser.rs
index 92ba8c17601..a00122a3208 100644
--- a/components/selectors/parser.rs
+++ b/components/selectors/parser.rs
@@ -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> {
diff --git a/components/selectors/tree.rs b/components/selectors/tree.rs
index 6122f22490f..93b59dbb4c5 100644
--- a/components/selectors/tree.rs
+++ b/components/selectors/tree.rs
@@ -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>;
diff --git a/components/style/restyle_hints.rs b/components/style/restyle_hints.rs
index 53e33608967..44eec13f13c 100644
--- a/components/style/restyle_hints.rs
+++ b/components/style/restyle_hints.rs
@@ -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.