mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
style: Make Invalidation work in terms of a dependency, not a selector.
That way we can look at the parent dependency as described in the previous patch. An alternative would be to add a: parent_dependency: Option<&'a Dependency> on construction to `Invalidation`, but this way seems slightly better to avoid growing the struct. It's not even one more indirection because the selector is contained directly in the Dependency struct. Differential Revision: https://phabricator.services.mozilla.com/D71422
This commit is contained in:
parent
c1bc588c93
commit
4b5de772c6
5 changed files with 315 additions and 202 deletions
|
@ -9,6 +9,7 @@ use crate::context::QuirksMode;
|
|||
use crate::dom::{TDocument, TElement, TNode, TShadowRoot};
|
||||
use crate::invalidation::element::invalidator::{DescendantInvalidationLists, Invalidation};
|
||||
use crate::invalidation::element::invalidator::{InvalidationProcessor, InvalidationVector};
|
||||
use crate::invalidation::element::invalidation_map::Dependency;
|
||||
use crate::Atom;
|
||||
use selectors::attr::CaseSensitivity;
|
||||
use selectors::matching::{self, MatchingContext, MatchingMode};
|
||||
|
@ -130,7 +131,7 @@ where
|
|||
{
|
||||
results: &'a mut Q::Output,
|
||||
matching_context: MatchingContext<'a, E::Impl>,
|
||||
selector_list: &'a SelectorList<E::Impl>,
|
||||
dependencies: &'a [Dependency],
|
||||
}
|
||||
|
||||
impl<'a, E, Q> InvalidationProcessor<'a, E> for QuerySelectorProcessor<'a, E, Q>
|
||||
|
@ -143,6 +144,11 @@ where
|
|||
true
|
||||
}
|
||||
|
||||
fn check_outer_dependency(&mut self, _: &Dependency, _: E) -> bool {
|
||||
debug_assert!(false, "How? We should only have parent-less dependencies here!");
|
||||
true
|
||||
}
|
||||
|
||||
fn collect_invalidations(
|
||||
&mut self,
|
||||
element: E,
|
||||
|
@ -171,11 +177,10 @@ where
|
|||
self_invalidations
|
||||
};
|
||||
|
||||
for selector in self.selector_list.0.iter() {
|
||||
for dependency in self.dependencies.iter() {
|
||||
target_vector.push(Invalidation::new(
|
||||
selector,
|
||||
dependency,
|
||||
self.matching_context.current_host.clone(),
|
||||
0,
|
||||
))
|
||||
}
|
||||
|
||||
|
@ -642,10 +647,13 @@ pub fn query_selector<E, Q>(
|
|||
if root_element.is_some() || !invalidation_may_be_useful {
|
||||
query_selector_slow::<E, Q>(root, selector_list, results, &mut matching_context);
|
||||
} else {
|
||||
let dependencies = selector_list.0.iter().map(|selector| {
|
||||
Dependency::for_full_selector_invalidation(selector.clone())
|
||||
}).collect::<SmallVec<[_; 5]>>();
|
||||
let mut processor = QuerySelectorProcessor::<E, Q> {
|
||||
results,
|
||||
matching_context,
|
||||
selector_list,
|
||||
dependencies: &dependencies,
|
||||
};
|
||||
|
||||
for node in root.dom_children() {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue