mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
style: Remove some uses of StyleBuilder::for_derived_style.
for_derived_style(default_values) is effectively for_inheritance(default_values). MozReview-Commit-ID: DfTeD49uTlp
This commit is contained in:
parent
1662fd7357
commit
7fb470c373
4 changed files with 20 additions and 27 deletions
|
@ -2783,8 +2783,12 @@ impl<'a> StyleBuilder<'a> {
|
||||||
self.flags.contains(ComputedValueFlags::IS_STYLE_IF_VISITED)
|
self.flags.contains(ComputedValueFlags::IS_STYLE_IF_VISITED)
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Creates a StyleBuilder holding only references to the structs of `s`, in
|
/// NOTE(emilio): This is done so we can compute relative units with respect
|
||||||
/// order to create a derived style.
|
/// to the parent style, but all the early properties / writing-mode / etc
|
||||||
|
/// are already set to the right ones on the kid.
|
||||||
|
///
|
||||||
|
/// Do _not_ actually call this to construct a style, this should mostly be
|
||||||
|
/// used for animations.
|
||||||
pub fn for_derived_style(
|
pub fn for_derived_style(
|
||||||
device: &'a Device,
|
device: &'a Device,
|
||||||
style_to_derive_from: &'a ComputedValues,
|
style_to_derive_from: &'a ComputedValues,
|
||||||
|
@ -2805,11 +2809,11 @@ impl<'a> StyleBuilder<'a> {
|
||||||
reset_style,
|
reset_style,
|
||||||
pseudo,
|
pseudo,
|
||||||
modified_reset: false,
|
modified_reset: false,
|
||||||
rules: None, // FIXME(emilio): Dubious...
|
rules: None,
|
||||||
custom_properties: style_to_derive_from.custom_properties().cloned(),
|
custom_properties: style_to_derive_from.custom_properties().cloned(),
|
||||||
writing_mode: style_to_derive_from.writing_mode,
|
writing_mode: style_to_derive_from.writing_mode,
|
||||||
flags: style_to_derive_from.flags,
|
flags: style_to_derive_from.flags,
|
||||||
visited_style: style_to_derive_from.clone_visited_style(),
|
visited_style: None,
|
||||||
% for style_struct in data.active_style_structs():
|
% for style_struct in data.active_style_structs():
|
||||||
${style_struct.ident}: StyleStructRef::Borrowed(
|
${style_struct.ident}: StyleStructRef::Borrowed(
|
||||||
style_to_derive_from.${style_struct.name_lower}_arc()
|
style_to_derive_from.${style_struct.name_lower}_arc()
|
||||||
|
|
|
@ -720,7 +720,7 @@ impl MaybeNew for ViewportConstraints {
|
||||||
let mut conditions = RuleCacheConditions::default();
|
let mut conditions = RuleCacheConditions::default();
|
||||||
let context = Context {
|
let context = Context {
|
||||||
is_root_element: false,
|
is_root_element: false,
|
||||||
builder: StyleBuilder::for_derived_style(device, default_values, None, None),
|
builder: StyleBuilder::for_inheritance(device, default_values, None),
|
||||||
font_metrics_provider: &provider,
|
font_metrics_provider: &provider,
|
||||||
cached_system_font: None,
|
cached_system_font: None,
|
||||||
in_media_query: false,
|
in_media_query: false,
|
||||||
|
|
|
@ -179,7 +179,7 @@ impl<'a> Context<'a> {
|
||||||
|
|
||||||
let context = Context {
|
let context = Context {
|
||||||
is_root_element: false,
|
is_root_element: false,
|
||||||
builder: StyleBuilder::for_derived_style(device, default_values, None, None),
|
builder: StyleBuilder::for_inheritance(device, default_values, None),
|
||||||
font_metrics_provider: &provider,
|
font_metrics_provider: &provider,
|
||||||
cached_system_font: None,
|
cached_system_font: None,
|
||||||
in_media_query: true,
|
in_media_query: true,
|
||||||
|
|
|
@ -2318,30 +2318,19 @@ pub extern "C" fn Servo_ComputedValues_Inherit(
|
||||||
let atom = Atom::from(pseudo_tag);
|
let atom = Atom::from(pseudo_tag);
|
||||||
let pseudo = PseudoElement::from_anon_box_atom(&atom)
|
let pseudo = PseudoElement::from_anon_box_atom(&atom)
|
||||||
.expect("Not an anon-box? Gah!");
|
.expect("Not an anon-box? Gah!");
|
||||||
let style = if let Some(reference) = parent_style_context {
|
let device = data.stylist.device();
|
||||||
let mut style = StyleBuilder::for_inheritance(
|
|
||||||
data.stylist.device(),
|
|
||||||
reference,
|
|
||||||
Some(&pseudo)
|
|
||||||
);
|
|
||||||
|
|
||||||
if for_text {
|
let mut style = StyleBuilder::for_inheritance(
|
||||||
StyleAdjuster::new(&mut style)
|
data.stylist.device(),
|
||||||
.adjust_for_text();
|
parent_style_context.unwrap_or_else(|| device.default_computed_values()),
|
||||||
}
|
Some(&pseudo)
|
||||||
|
);
|
||||||
|
|
||||||
style.build()
|
if for_text {
|
||||||
} else {
|
StyleAdjuster::new(&mut style).adjust_for_text();
|
||||||
debug_assert!(!for_text);
|
}
|
||||||
StyleBuilder::for_derived_style(
|
|
||||||
data.stylist.device(),
|
|
||||||
data.default_computed_values(),
|
|
||||||
/* parent_style = */ None,
|
|
||||||
Some(&pseudo),
|
|
||||||
).build()
|
|
||||||
};
|
|
||||||
|
|
||||||
style.into()
|
style.build().into()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[no_mangle]
|
#[no_mangle]
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue