mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +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)
|
||||
}
|
||||
|
||||
/// Creates a StyleBuilder holding only references to the structs of `s`, in
|
||||
/// order to create a derived style.
|
||||
/// NOTE(emilio): This is done so we can compute relative units with respect
|
||||
/// 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(
|
||||
device: &'a Device,
|
||||
style_to_derive_from: &'a ComputedValues,
|
||||
|
@ -2805,11 +2809,11 @@ impl<'a> StyleBuilder<'a> {
|
|||
reset_style,
|
||||
pseudo,
|
||||
modified_reset: false,
|
||||
rules: None, // FIXME(emilio): Dubious...
|
||||
rules: None,
|
||||
custom_properties: style_to_derive_from.custom_properties().cloned(),
|
||||
writing_mode: style_to_derive_from.writing_mode,
|
||||
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():
|
||||
${style_struct.ident}: StyleStructRef::Borrowed(
|
||||
style_to_derive_from.${style_struct.name_lower}_arc()
|
||||
|
|
|
@ -720,7 +720,7 @@ impl MaybeNew for ViewportConstraints {
|
|||
let mut conditions = RuleCacheConditions::default();
|
||||
let context = Context {
|
||||
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,
|
||||
cached_system_font: None,
|
||||
in_media_query: false,
|
||||
|
|
|
@ -179,7 +179,7 @@ impl<'a> Context<'a> {
|
|||
|
||||
let context = Context {
|
||||
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,
|
||||
cached_system_font: None,
|
||||
in_media_query: true,
|
||||
|
|
|
@ -2318,30 +2318,19 @@ pub extern "C" fn Servo_ComputedValues_Inherit(
|
|||
let atom = Atom::from(pseudo_tag);
|
||||
let pseudo = PseudoElement::from_anon_box_atom(&atom)
|
||||
.expect("Not an anon-box? Gah!");
|
||||
let style = if let Some(reference) = parent_style_context {
|
||||
let mut style = StyleBuilder::for_inheritance(
|
||||
data.stylist.device(),
|
||||
reference,
|
||||
Some(&pseudo)
|
||||
);
|
||||
let device = data.stylist.device();
|
||||
|
||||
if for_text {
|
||||
StyleAdjuster::new(&mut style)
|
||||
.adjust_for_text();
|
||||
}
|
||||
let mut style = StyleBuilder::for_inheritance(
|
||||
data.stylist.device(),
|
||||
parent_style_context.unwrap_or_else(|| device.default_computed_values()),
|
||||
Some(&pseudo)
|
||||
);
|
||||
|
||||
style.build()
|
||||
} else {
|
||||
debug_assert!(!for_text);
|
||||
StyleBuilder::for_derived_style(
|
||||
data.stylist.device(),
|
||||
data.default_computed_values(),
|
||||
/* parent_style = */ None,
|
||||
Some(&pseudo),
|
||||
).build()
|
||||
};
|
||||
if for_text {
|
||||
StyleAdjuster::new(&mut style).adjust_for_text();
|
||||
}
|
||||
|
||||
style.into()
|
||||
style.build().into()
|
||||
}
|
||||
|
||||
#[no_mangle]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue