aboutsummaryrefslogtreecommitdiffstats
path: root/components/style/gecko
diff options
context:
space:
mode:
Diffstat (limited to 'components/style/gecko')
-rw-r--r--components/style/gecko/snapshot_helpers.rs28
-rw-r--r--components/style/gecko/wrapper.rs3
2 files changed, 31 insertions, 0 deletions
diff --git a/components/style/gecko/snapshot_helpers.rs b/components/style/gecko/snapshot_helpers.rs
index 992a3652820..73d740012b2 100644
--- a/components/style/gecko/snapshot_helpers.rs
+++ b/components/style/gecko/snapshot_helpers.rs
@@ -4,13 +4,17 @@
//! Element an snapshot common logic.
+use crate::dom::TElement;
use crate::gecko_bindings::bindings;
use crate::gecko_bindings::structs::{self, nsAtom};
+use crate::invalidation::element::element_wrapper::ElementSnapshot;
+use crate::selector_parser::SnapshotMap;
use crate::string_cache::WeakAtom;
use crate::values::AtomIdent;
use crate::Atom;
use crate::CaseSensitivityExt;
use selectors::attr::CaseSensitivity;
+use smallvec::SmallVec;
/// A function that, given an element of type `T`, allows you to get a single
/// class or a class list.
@@ -166,3 +170,27 @@ where
}
}
}
+
+/// Returns a list of classes that were either added to or removed from the
+/// element since the snapshot.
+pub fn classes_changed<E: TElement>(element: &E, snapshots: &SnapshotMap) -> SmallVec<[Atom; 8]> {
+ debug_assert!(element.has_snapshot(), "Why bothering?");
+ let snapshot = snapshots.get(element).expect("has_snapshot lied");
+ if !snapshot.class_changed() {
+ return SmallVec::new();
+ }
+
+ let mut classes_changed = SmallVec::<[Atom; 8]>::new();
+ snapshot.each_class(|c| {
+ if !element.has_class(c, CaseSensitivity::CaseSensitive) {
+ classes_changed.push(c.0.clone());
+ }
+ });
+ element.each_class(|c| {
+ if !snapshot.has_class(c, CaseSensitivity::CaseSensitive) {
+ classes_changed.push(c.0.clone());
+ }
+ });
+
+ classes_changed
+}
diff --git a/components/style/gecko/wrapper.rs b/components/style/gecko/wrapper.rs
index 8d4fb224639..2d02d31cca1 100644
--- a/components/style/gecko/wrapper.rs
+++ b/components/style/gecko/wrapper.rs
@@ -910,6 +910,9 @@ fn selector_flags_to_node_flags(flags: ElementSelectorFlags) -> u32 {
if flags.contains(ElementSelectorFlags::HAS_SLOW_SELECTOR_LATER_SIBLINGS) {
gecko_flags |= NODE_HAS_SLOW_SELECTOR_LATER_SIBLINGS as u32;
}
+ if flags.contains(ElementSelectorFlags::HAS_SLOW_SELECTOR_NTH_OF) {
+ gecko_flags |= NODE_HAS_SLOW_SELECTOR_NTH_OF as u32;
+ }
if flags.contains(ElementSelectorFlags::HAS_EDGE_CHILD_SELECTOR) {
gecko_flags |= NODE_HAS_EDGE_CHILD_SELECTOR as u32;
}