mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
style: Refactor InvalidationMap flags to use bitflags.
Differential Revision: https://phabricator.services.mozilla.com/D55862
This commit is contained in:
parent
51c1dfee2d
commit
5e7d429c0a
3 changed files with 35 additions and 30 deletions
|
@ -42,6 +42,7 @@ where
|
|||
descendant_invalidations: &'a mut DescendantInvalidationLists<'selectors>,
|
||||
sibling_invalidations: &'a mut InvalidationVector<'selectors>,
|
||||
invalidates_self: bool,
|
||||
attr_selector_flags: InvalidationMapFlags,
|
||||
}
|
||||
|
||||
/// An invalidation processor for style changes due to state and attribute
|
||||
|
@ -155,6 +156,8 @@ where
|
|||
return false;
|
||||
}
|
||||
|
||||
let mut attr_selector_flags = InvalidationMapFlags::empty();
|
||||
|
||||
// If we the visited state changed, we force a restyle here. Matching
|
||||
// doesn't depend on the actual visited state at all, so we can't look
|
||||
// at matching results to decide what to do for this case.
|
||||
|
@ -172,6 +175,7 @@ where
|
|||
let mut classes_removed = SmallVec::<[Atom; 8]>::new();
|
||||
let mut classes_added = SmallVec::<[Atom; 8]>::new();
|
||||
if snapshot.class_changed() {
|
||||
attr_selector_flags.insert(InvalidationMapFlags::HAS_CLASS_ATTR_SELECTOR);
|
||||
// TODO(emilio): Do this more efficiently!
|
||||
snapshot.each_class(|c| {
|
||||
if !element.has_class(c, CaseSensitivity::CaseSensitive) {
|
||||
|
@ -189,6 +193,7 @@ where
|
|||
let mut id_removed = None;
|
||||
let mut id_added = None;
|
||||
if snapshot.id_changed() {
|
||||
attr_selector_flags.insert(InvalidationMapFlags::HAS_ID_ATTR_SELECTOR);
|
||||
let old_id = snapshot.id_attr();
|
||||
let current_id = element.id();
|
||||
|
||||
|
@ -199,7 +204,7 @@ where
|
|||
}
|
||||
|
||||
if log_enabled!(::log::Level::Debug) {
|
||||
debug!("Collecting changes for: {:?}", element);
|
||||
debug!("Collecting changes for: {:?}, flags {:?}", element, attr_selector_flags);
|
||||
if !state_changes.is_empty() {
|
||||
debug!(" > state: {:?}", state_changes);
|
||||
}
|
||||
|
@ -247,6 +252,7 @@ where
|
|||
descendant_invalidations,
|
||||
sibling_invalidations,
|
||||
invalidates_self: false,
|
||||
attr_selector_flags,
|
||||
};
|
||||
|
||||
let document_origins = if !matches_document_author_rules {
|
||||
|
@ -357,8 +363,7 @@ where
|
|||
}
|
||||
|
||||
let should_examine_attribute_selector_map = self.snapshot.other_attr_changed() ||
|
||||
(self.snapshot.class_changed() && map.has_class_attribute_selectors) ||
|
||||
(self.snapshot.id_changed() && map.has_id_attribute_selectors);
|
||||
map.flags.intersects(self.attr_selector_flags);
|
||||
|
||||
if should_examine_attribute_selector_map {
|
||||
self.collect_dependencies_in_map(&map.other_attribute_affecting_selectors)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue