summaryrefslogtreecommitdiffstats
path: root/servo/components/style/invalidation/element/element_wrapper.rs
diff options
context:
space:
mode:
Diffstat (limited to 'servo/components/style/invalidation/element/element_wrapper.rs')
-rw-r--r--servo/components/style/invalidation/element/element_wrapper.rs24
1 files changed, 24 insertions, 0 deletions
diff --git a/servo/components/style/invalidation/element/element_wrapper.rs b/servo/components/style/invalidation/element/element_wrapper.rs
index e17afd7774..9a39b7d5a0 100644
--- a/servo/components/style/invalidation/element/element_wrapper.rs
+++ b/servo/components/style/invalidation/element/element_wrapper.rs
@@ -73,6 +73,18 @@ pub trait ElementSnapshot: Sized {
where
F: FnMut(&AtomIdent);
+
+ /// If this snapshot contains CustomStateSet information.
+ fn has_custom_states(&self) -> bool;
+
+ /// A callback that should be called for each CustomState of the snapshot.
+ fn has_custom_state(&self, state: &AtomIdent) -> bool;
+
+ /// A callback that should be called for each CustomState of the snapshot.
+ fn each_custom_state<F>(&self, callback: F)
+ where
+ F: FnMut(&AtomIdent);
+
/// The `xml:lang=""` or `lang=""` attribute value per this snapshot.
fn lang_attr(&self) -> Option<AttrValue>;
}
@@ -213,6 +225,11 @@ where
.match_element_lang(Some(self.get_lang()), lang_arg);
},
+ // CustomStateSet should match against the snapshot before element
+ NonTSPseudoClass::CustomState(ref state) => {
+ return self.has_custom_state(&state.0)
+ },
+
_ => {},
}
@@ -357,6 +374,13 @@ where
}
}
+ fn has_custom_state(&self, state: &AtomIdent) -> bool {
+ match self.snapshot() {
+ Some(snapshot) if snapshot.has_custom_states() => snapshot.has_custom_state(state),
+ _ => self.element.has_custom_state(state),
+ }
+ }
+
fn is_empty(&self) -> bool {
self.element.is_empty()
}