mirror of
https://github.com/servo/servo.git
synced 2025-08-03 20:50:07 +01:00
This reverts commit 8e15389cae
.
This commit is contained in:
parent
8e15389cae
commit
d6ae8dc112
152 changed files with 4622 additions and 5862 deletions
|
@ -16,13 +16,6 @@ use crate::stylist::RuleInclusion;
|
|||
use crate::traversal_flags::TraversalFlags;
|
||||
use selectors::NthIndexCache;
|
||||
use smallvec::SmallVec;
|
||||
use std::collections::HashMap;
|
||||
|
||||
/// A cache from element reference to known-valid computed style.
|
||||
pub type UndisplayedStyleCache = HashMap<
|
||||
selectors::OpaqueElement,
|
||||
servo_arc::Arc<crate::properties::ComputedValues>,
|
||||
>;
|
||||
|
||||
/// A per-traversal-level chunk of data. This is sent down by the traversal, and
|
||||
/// currently only holds the dom depth for the bloom filter.
|
||||
|
@ -301,7 +294,6 @@ pub fn resolve_style<E>(
|
|||
element: E,
|
||||
rule_inclusion: RuleInclusion,
|
||||
pseudo: Option<&PseudoElement>,
|
||||
mut undisplayed_style_cache: Option<&mut UndisplayedStyleCache>,
|
||||
) -> ElementStyles
|
||||
where
|
||||
E: TElement,
|
||||
|
@ -312,11 +304,6 @@ where
|
|||
element.borrow_data().map_or(true, |d| !d.has_styles()),
|
||||
"Why are we here?"
|
||||
);
|
||||
debug_assert!(
|
||||
rule_inclusion == RuleInclusion::All || undisplayed_style_cache.is_none(),
|
||||
"can't use the cache for default styles only"
|
||||
);
|
||||
|
||||
let mut ancestors_requiring_style_resolution = SmallVec::<[E; 16]>::new();
|
||||
|
||||
// Clear the bloom filter, just in case the caller is reusing TLS.
|
||||
|
@ -333,12 +320,6 @@ where
|
|||
}
|
||||
}
|
||||
}
|
||||
if let Some(ref mut cache) = undisplayed_style_cache {
|
||||
if let Some(s) = cache.get(¤t.opaque()) {
|
||||
style = Some(s.clone());
|
||||
break;
|
||||
}
|
||||
}
|
||||
ancestors_requiring_style_resolution.push(current);
|
||||
ancestor = current.traversal_parent();
|
||||
}
|
||||
|
@ -356,9 +337,7 @@ where
|
|||
}
|
||||
|
||||
ancestor = ancestor.unwrap().traversal_parent();
|
||||
layout_parent_style = ancestor.and_then(|a| {
|
||||
a.borrow_data().map(|data| data.styles.primary().clone())
|
||||
});
|
||||
layout_parent_style = ancestor.map(|a| a.borrow_data().unwrap().styles.primary().clone());
|
||||
}
|
||||
|
||||
for ancestor in ancestors_requiring_style_resolution.iter().rev() {
|
||||
|
@ -381,27 +360,18 @@ where
|
|||
layout_parent_style = style.clone();
|
||||
}
|
||||
|
||||
if let Some(ref mut cache) = undisplayed_style_cache {
|
||||
cache.insert(ancestor.opaque(), style.clone().unwrap());
|
||||
}
|
||||
context.thread_local.bloom_filter.push(*ancestor);
|
||||
}
|
||||
|
||||
context.thread_local.bloom_filter.assert_complete(element);
|
||||
let styles: ElementStyles = StyleResolverForElement::new(
|
||||
StyleResolverForElement::new(
|
||||
element,
|
||||
context,
|
||||
rule_inclusion,
|
||||
PseudoElementResolution::Force,
|
||||
)
|
||||
.resolve_style(style.as_deref(), layout_parent_style.as_deref())
|
||||
.into();
|
||||
|
||||
if let Some(ref mut cache) = undisplayed_style_cache {
|
||||
cache.insert(element.opaque(), styles.primary().clone());
|
||||
}
|
||||
|
||||
styles
|
||||
.into()
|
||||
}
|
||||
|
||||
/// Calculates the style for a single node.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue