mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
style: Make the TElement type arrive to the cascade
function.
Not super-proud of this one, but it's the easiest way I could think of. The changeset looks bigger than what it is, because while at it I've rewrapped a fair amount of functions around to use proper block indentation. Alternatives are parameterizing Stylist by <E>, which is not fun, or moving the concrete element from layout_thread to layout, but that implies layout depending on script, which isn't fun either. Other alternative is implementing an empty enum and making anon boxes work on it. It has the advantage of removing the annoying type parameter, but the disadvantage of instantiating `cascade` twice, which isn't great, and having to maintain all the boilerplate of a `TElement` implementation that just does nothing.
This commit is contained in:
parent
6f543d3de1
commit
5ac12b5df4
10 changed files with 425 additions and 207 deletions
|
@ -12,6 +12,7 @@
|
|||
|
||||
#[cfg(feature = "servo")]
|
||||
use app_units::Au;
|
||||
use dom::TElement;
|
||||
use custom_properties::CustomPropertiesBuilder;
|
||||
use servo_arc::{Arc, UniqueArc};
|
||||
use smallbitvec::SmallBitVec;
|
||||
|
@ -3188,7 +3189,7 @@ bitflags! {
|
|||
/// Returns the computed values.
|
||||
/// * `flags`: Various flags.
|
||||
///
|
||||
pub fn cascade(
|
||||
pub fn cascade<E>(
|
||||
device: &Device,
|
||||
pseudo: Option<<&PseudoElement>,
|
||||
rule_node: &StrongRuleNode,
|
||||
|
@ -3202,7 +3203,11 @@ pub fn cascade(
|
|||
quirks_mode: QuirksMode,
|
||||
rule_cache: Option<<&RuleCache>,
|
||||
rule_cache_conditions: &mut RuleCacheConditions,
|
||||
) -> Arc<ComputedValues> {
|
||||
element: Option<E>,
|
||||
) -> Arc<ComputedValues>
|
||||
where
|
||||
E: TElement,
|
||||
{
|
||||
debug_assert_eq!(parent_style.is_some(), parent_style_ignoring_first_line.is_some());
|
||||
let empty = SmallBitVec::new();
|
||||
|
||||
|
@ -3261,12 +3266,13 @@ pub fn cascade(
|
|||
quirks_mode,
|
||||
rule_cache,
|
||||
rule_cache_conditions,
|
||||
element,
|
||||
)
|
||||
}
|
||||
|
||||
/// NOTE: This function expects the declaration with more priority to appear
|
||||
/// first.
|
||||
pub fn apply_declarations<'a, F, I>(
|
||||
pub fn apply_declarations<'a, E, F, I>(
|
||||
device: &Device,
|
||||
pseudo: Option<<&PseudoElement>,
|
||||
rules: &StrongRuleNode,
|
||||
|
@ -3281,8 +3287,10 @@ pub fn apply_declarations<'a, F, I>(
|
|||
quirks_mode: QuirksMode,
|
||||
rule_cache: Option<<&RuleCache>,
|
||||
rule_cache_conditions: &mut RuleCacheConditions,
|
||||
_element: Option<E>,
|
||||
) -> Arc<ComputedValues>
|
||||
where
|
||||
E: TElement,
|
||||
F: Fn() -> I,
|
||||
I: Iterator<Item = (&'a PropertyDeclaration, CascadeLevel)>,
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue