зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1857674 - Reuse is_root_element from style builder r=emilio
Depends on D191161 Differential Revision: https://phabricator.services.mozilla.com/D191615
This commit is contained in:
Родитель
c93e4c276e
Коммит
32d6979b28
|
@ -793,18 +793,14 @@ pub struct CustomPropertiesBuilder<'a, 'b: 'a> {
|
||||||
reverted: PrecomputedHashMap<&'a Name, (CascadePriority, bool)>,
|
reverted: PrecomputedHashMap<&'a Name, (CascadePriority, bool)>,
|
||||||
stylist: &'a Stylist,
|
stylist: &'a Stylist,
|
||||||
computed_context: &'a computed::Context<'b>,
|
computed_context: &'a computed::Context<'b>,
|
||||||
is_root_element: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a, 'b: 'a> CustomPropertiesBuilder<'a, 'b> {
|
impl<'a, 'b: 'a> CustomPropertiesBuilder<'a, 'b> {
|
||||||
/// Create a new builder, inheriting from a given custom properties map.
|
/// Create a new builder, inheriting from a given custom properties map.
|
||||||
pub fn new(
|
pub fn new(stylist: &'a Stylist, computed_context: &'a computed::Context<'b>) -> Self {
|
||||||
stylist: &'a Stylist,
|
|
||||||
computed_context: &'a computed::Context<'b>,
|
|
||||||
is_root_element: bool,
|
|
||||||
) -> Self {
|
|
||||||
let inherited = computed_context.inherited_custom_properties();
|
let inherited = computed_context.inherited_custom_properties();
|
||||||
let initial_values = stylist.get_custom_property_initial_values();
|
let initial_values = stylist.get_custom_property_initial_values();
|
||||||
|
let is_root_element = computed_context.is_root_element();
|
||||||
Self {
|
Self {
|
||||||
seen: PrecomputedHashSet::default(),
|
seen: PrecomputedHashSet::default(),
|
||||||
reverted: Default::default(),
|
reverted: Default::default(),
|
||||||
|
@ -820,7 +816,6 @@ impl<'a, 'b: 'a> CustomPropertiesBuilder<'a, 'b> {
|
||||||
},
|
},
|
||||||
stylist,
|
stylist,
|
||||||
computed_context,
|
computed_context,
|
||||||
is_root_element,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -865,7 +860,6 @@ impl<'a, 'b: 'a> CustomPropertiesBuilder<'a, 'b> {
|
||||||
map,
|
map,
|
||||||
self.stylist,
|
self.stylist,
|
||||||
self.computed_context,
|
self.computed_context,
|
||||||
self.is_root_element,
|
|
||||||
);
|
);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1033,7 +1027,6 @@ impl<'a, 'b: 'a> CustomPropertiesBuilder<'a, 'b> {
|
||||||
&self.seen,
|
&self.seen,
|
||||||
self.stylist,
|
self.stylist,
|
||||||
self.computed_context,
|
self.computed_context,
|
||||||
self.is_root_element,
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1075,7 +1068,6 @@ fn substitute_all(
|
||||||
seen: &PrecomputedHashSet<&Name>,
|
seen: &PrecomputedHashSet<&Name>,
|
||||||
stylist: &Stylist,
|
stylist: &Stylist,
|
||||||
computed_context: &computed::Context,
|
computed_context: &computed::Context,
|
||||||
is_root_element: bool,
|
|
||||||
) {
|
) {
|
||||||
// The cycle dependencies removal in this function is a variant
|
// The cycle dependencies removal in this function is a variant
|
||||||
// of Tarjan's algorithm. It is mostly based on the pseudo-code
|
// of Tarjan's algorithm. It is mostly based on the pseudo-code
|
||||||
|
@ -1117,8 +1109,6 @@ fn substitute_all(
|
||||||
/// The computed context is used to get inherited custom
|
/// The computed context is used to get inherited custom
|
||||||
/// properties and compute registered custom properties.
|
/// properties and compute registered custom properties.
|
||||||
computed_context: &'a computed::Context<'b>,
|
computed_context: &'a computed::Context<'b>,
|
||||||
/// Whether this is the root element.
|
|
||||||
is_root_element: bool,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// This function combines the traversal for cycle removal and value
|
/// This function combines the traversal for cycle removal and value
|
||||||
|
@ -1264,7 +1254,6 @@ fn substitute_all(
|
||||||
&mut context.map,
|
&mut context.map,
|
||||||
context.stylist,
|
context.stylist,
|
||||||
context.computed_context,
|
context.computed_context,
|
||||||
context.is_root_element,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
// All resolved, so return the signal value.
|
// All resolved, so return the signal value.
|
||||||
|
@ -1283,7 +1272,6 @@ fn substitute_all(
|
||||||
map: custom_properties_map,
|
map: custom_properties_map,
|
||||||
stylist,
|
stylist,
|
||||||
computed_context,
|
computed_context,
|
||||||
is_root_element,
|
|
||||||
};
|
};
|
||||||
traverse(name, &mut context);
|
traverse(name, &mut context);
|
||||||
}
|
}
|
||||||
|
@ -1329,11 +1317,11 @@ fn substitute_references_in_value_and_apply(
|
||||||
custom_properties: &mut ComputedCustomProperties,
|
custom_properties: &mut ComputedCustomProperties,
|
||||||
stylist: &Stylist,
|
stylist: &Stylist,
|
||||||
computed_context: &computed::Context,
|
computed_context: &computed::Context,
|
||||||
is_root_element: bool,
|
|
||||||
) {
|
) {
|
||||||
debug_assert!(value.has_references());
|
debug_assert!(value.has_references());
|
||||||
|
|
||||||
let inherited = computed_context.inherited_custom_properties();
|
let inherited = computed_context.inherited_custom_properties();
|
||||||
|
let is_root_element = computed_context.is_root_element();
|
||||||
let custom_registration = stylist.get_custom_property_registration(&name);
|
let custom_registration = stylist.get_custom_property_registration(&name);
|
||||||
let mut computed_value = ComputedValue::empty();
|
let mut computed_value = ComputedValue::empty();
|
||||||
|
|
||||||
|
|
|
@ -321,8 +321,7 @@ where
|
||||||
},
|
},
|
||||||
CascadeMode::Unvisited { visited_rules } => {
|
CascadeMode::Unvisited { visited_rules } => {
|
||||||
cascade.context.builder.custom_properties = {
|
cascade.context.builder.custom_properties = {
|
||||||
let mut builder =
|
let mut builder = CustomPropertiesBuilder::new(stylist, cascade.context);
|
||||||
CustomPropertiesBuilder::new(stylist, cascade.context, is_root_element);
|
|
||||||
iter_declarations(iter, &mut declarations, Some(&mut builder));
|
iter_declarations(iter, &mut declarations, Some(&mut builder));
|
||||||
builder.build()
|
builder.build()
|
||||||
};
|
};
|
||||||
|
|
|
@ -956,7 +956,7 @@ impl PropertyDeclarationBlock {
|
||||||
stylist: &Stylist,
|
stylist: &Stylist,
|
||||||
context: &Context,
|
context: &Context,
|
||||||
) -> ComputedCustomProperties {
|
) -> ComputedCustomProperties {
|
||||||
let mut builder = CustomPropertiesBuilder::new(stylist, context, false);
|
let mut builder = CustomPropertiesBuilder::new(stylist, context);
|
||||||
|
|
||||||
for declaration in self.normal_declaration_iter() {
|
for declaration in self.normal_declaration_iter() {
|
||||||
if let PropertyDeclaration::Custom(ref declaration) = *declaration {
|
if let PropertyDeclaration::Custom(ref declaration) = *declaration {
|
||||||
|
|
|
@ -321,6 +321,11 @@ impl<'a> Context<'a> {
|
||||||
&self.builder.inherited_custom_properties()
|
&self.builder.inherited_custom_properties()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Whether the style is for the root element.
|
||||||
|
pub fn is_root_element(&self) -> bool {
|
||||||
|
self.builder.is_root_element
|
||||||
|
}
|
||||||
|
|
||||||
/// Queries font metrics.
|
/// Queries font metrics.
|
||||||
pub fn query_font_metrics(
|
pub fn query_font_metrics(
|
||||||
&self,
|
&self,
|
||||||
|
|
Загрузка…
Ссылка в новой задаче