mirror of
https://github.com/servo/servo.git
synced 2025-08-04 21:20:23 +01:00
style: Move the bounds up in InvalidationProcessor.
This commit is contained in:
parent
a5e2f2c76c
commit
557353c1f6
2 changed files with 34 additions and 58 deletions
|
@ -53,8 +53,11 @@ where
|
|||
/// changes.
|
||||
pub struct StateAndAttrInvalidationProcessor;
|
||||
|
||||
impl InvalidationProcessor for StateAndAttrInvalidationProcessor {
|
||||
fn collect_invalidations<E>(
|
||||
impl<E> InvalidationProcessor<E> for StateAndAttrInvalidationProcessor
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
fn collect_invalidations(
|
||||
&self,
|
||||
element: E,
|
||||
mut data: Option<&mut ElementData>,
|
||||
|
@ -62,10 +65,7 @@ impl InvalidationProcessor for StateAndAttrInvalidationProcessor {
|
|||
shared_context: &SharedStyleContext,
|
||||
descendant_invalidations: &mut InvalidationVector,
|
||||
sibling_invalidations: &mut InvalidationVector,
|
||||
) -> bool
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
) -> bool {
|
||||
debug_assert!(element.has_snapshot(), "Why bothering?");
|
||||
debug_assert!(data.is_some(), "How exactly?");
|
||||
|
||||
|
@ -176,14 +176,11 @@ impl InvalidationProcessor for StateAndAttrInvalidationProcessor {
|
|||
invalidated_self
|
||||
}
|
||||
|
||||
fn should_process_descendants<E>(
|
||||
fn should_process_descendants(
|
||||
&self,
|
||||
_element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
) -> bool
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
) -> bool {
|
||||
let data = match data {
|
||||
None => return false,
|
||||
Some(ref data) => data,
|
||||
|
@ -196,28 +193,22 @@ impl InvalidationProcessor for StateAndAttrInvalidationProcessor {
|
|||
!data.hint.contains_subtree()
|
||||
}
|
||||
|
||||
fn recursion_limit_exceeded<E>(
|
||||
fn recursion_limit_exceeded(
|
||||
&self,
|
||||
_element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
)
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
) {
|
||||
if let Some(data) = data {
|
||||
data.hint.insert(RESTYLE_DESCENDANTS);
|
||||
}
|
||||
}
|
||||
|
||||
fn invalidated_child<E>(
|
||||
fn invalidated_child(
|
||||
&self,
|
||||
element: E,
|
||||
_data: Option<&mut ElementData>,
|
||||
child: E,
|
||||
)
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
) {
|
||||
if child.get_data().is_none() {
|
||||
return;
|
||||
}
|
||||
|
@ -238,14 +229,11 @@ impl InvalidationProcessor for StateAndAttrInvalidationProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
fn invalidated_descendants<E>(
|
||||
fn invalidated_descendants(
|
||||
&self,
|
||||
element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
)
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
) {
|
||||
// FIXME(emilio): We probably want to walk the flattened tree here too,
|
||||
// and remove invalidated_child instead, or something like that.
|
||||
if data.as_ref().map_or(false, |d| !d.styles.is_display_none()) {
|
||||
|
@ -253,14 +241,11 @@ impl InvalidationProcessor for StateAndAttrInvalidationProcessor {
|
|||
}
|
||||
}
|
||||
|
||||
fn invalidated_self<E>(
|
||||
fn invalidated_self(
|
||||
&self,
|
||||
_element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
)
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
) {
|
||||
if let Some(data) = data {
|
||||
data.hint.insert(RESTYLE_SELF);
|
||||
}
|
||||
|
|
|
@ -21,11 +21,14 @@ use std::fmt;
|
|||
///
|
||||
/// The `data` argument is a mutable reference to the element's style data, if
|
||||
/// any.
|
||||
pub trait InvalidationProcessor {
|
||||
pub trait InvalidationProcessor<E>
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
/// Collect invalidations for a given element's descendants and siblings.
|
||||
///
|
||||
/// Returns whether the element itself was invalidated.
|
||||
fn collect_invalidations<E>(
|
||||
fn collect_invalidations(
|
||||
&self,
|
||||
element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
|
@ -33,57 +36,45 @@ pub trait InvalidationProcessor {
|
|||
shared_context: &SharedStyleContext,
|
||||
descendant_invalidations: &mut InvalidationVector,
|
||||
sibling_invalidations: &mut InvalidationVector,
|
||||
) -> bool
|
||||
where
|
||||
E: TElement;
|
||||
) -> bool;
|
||||
|
||||
/// Returns whether the invalidation process should process the descendants
|
||||
/// of the given element.
|
||||
fn should_process_descendants<E>(
|
||||
fn should_process_descendants(
|
||||
&self,
|
||||
element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
) -> bool
|
||||
where
|
||||
E: TElement;
|
||||
) -> bool;
|
||||
|
||||
/// Executes an arbitrary action when the recursion limit is exceded (if
|
||||
/// any).
|
||||
fn recursion_limit_exceeded<E>(
|
||||
fn recursion_limit_exceeded(
|
||||
&self,
|
||||
element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
)
|
||||
where
|
||||
E: TElement;
|
||||
);
|
||||
|
||||
/// Executes an arbitrary action when a direct child is invalidated.
|
||||
fn invalidated_child<E>(
|
||||
fn invalidated_child(
|
||||
&self,
|
||||
element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
child: E,
|
||||
)
|
||||
where
|
||||
E: TElement;
|
||||
);
|
||||
|
||||
/// Executes an action when `Self` is invalidated.
|
||||
fn invalidated_self<E>(
|
||||
fn invalidated_self(
|
||||
&self,
|
||||
element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
)
|
||||
where
|
||||
E: TElement;
|
||||
);
|
||||
|
||||
/// Executes an action when any descendant of `Self` is invalidated.
|
||||
fn invalidated_descendants<E>(
|
||||
fn invalidated_descendants(
|
||||
&self,
|
||||
element: E,
|
||||
data: Option<&mut ElementData>,
|
||||
)
|
||||
where
|
||||
E: TElement;
|
||||
);
|
||||
}
|
||||
|
||||
/// The struct that takes care of encapsulating all the logic on where and how
|
||||
|
@ -91,7 +82,7 @@ pub trait InvalidationProcessor {
|
|||
pub struct TreeStyleInvalidator<'a, 'b: 'a, E, P: 'a>
|
||||
where
|
||||
E: TElement,
|
||||
P: InvalidationProcessor
|
||||
P: InvalidationProcessor<E>
|
||||
{
|
||||
element: E,
|
||||
// TODO(emilio): It's tempting enough to just avoid running invalidation for
|
||||
|
@ -242,7 +233,7 @@ impl InvalidationResult {
|
|||
impl<'a, 'b: 'a, E, P: 'a> TreeStyleInvalidator<'a, 'b, E, P>
|
||||
where
|
||||
E: TElement,
|
||||
P: InvalidationProcessor,
|
||||
P: InvalidationProcessor<E>,
|
||||
{
|
||||
/// Trivially constructs a new `TreeStyleInvalidator`.
|
||||
pub fn new(
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue