mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Various cleanups
Remove some hacks in layout, and unused function in style.
This commit is contained in:
parent
951c050690
commit
6da65d605b
3 changed files with 24 additions and 69 deletions
|
@ -1167,11 +1167,7 @@ impl Fragment {
|
|||
/// can be expensive to compute, so if possible use the `border_padding` field instead.
|
||||
#[inline]
|
||||
pub fn border_width(&self) -> LogicalMargin<Au> {
|
||||
let style_border_width = match self.specific {
|
||||
SpecificFragmentInfo::ScannedText(_) |
|
||||
SpecificFragmentInfo::InlineBlock(_) => LogicalMargin::zero(self.style.writing_mode),
|
||||
_ => self.style().logical_border_width(),
|
||||
};
|
||||
let style_border_width = self.style().logical_border_width();
|
||||
|
||||
// NOTE: We can have nodes with different writing mode inside
|
||||
// the inline fragment context, so we need to overwrite the
|
||||
|
@ -1216,6 +1212,17 @@ impl Fragment {
|
|||
/// Do not use this method if the inline direction margins are to be computed some other way
|
||||
/// (for example, via constraint solving for blocks).
|
||||
pub fn compute_inline_direction_margins(&mut self, containing_block_inline_size: Au) {
|
||||
match self.specific {
|
||||
SpecificFragmentInfo::Table |
|
||||
SpecificFragmentInfo::TableCell |
|
||||
SpecificFragmentInfo::TableRow |
|
||||
SpecificFragmentInfo::TableColumn(_) |
|
||||
SpecificFragmentInfo::InlineAbsoluteHypothetical(_) => {
|
||||
self.margin.inline_start = Au(0);
|
||||
self.margin.inline_end = Au(0);
|
||||
return
|
||||
}
|
||||
_ => {
|
||||
let margin = self.style().logical_margin();
|
||||
self.margin.inline_start =
|
||||
MaybeAuto::from_style(margin.inline_start,
|
||||
|
@ -1223,6 +1230,8 @@ impl Fragment {
|
|||
self.margin.inline_end =
|
||||
MaybeAuto::from_style(margin.inline_end,
|
||||
containing_block_inline_size).specified_or_zero();
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(ref inline_context) = self.inline_context {
|
||||
for node in &inline_context.nodes {
|
||||
|
@ -1240,8 +1249,8 @@ impl Fragment {
|
|||
containing_block_inline_size).specified_or_zero()
|
||||
};
|
||||
|
||||
self.margin.inline_start = self.margin.inline_start + this_inline_start_margin;
|
||||
self.margin.inline_end = self.margin.inline_end + this_inline_end_margin;
|
||||
self.margin.inline_start += this_inline_start_margin;
|
||||
self.margin.inline_end += this_inline_end_margin;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1290,14 +1299,10 @@ impl Fragment {
|
|||
};
|
||||
|
||||
// Compute padding from the fragment's style.
|
||||
//
|
||||
// This is zero in the case of `inline-block` because that padding is applied to the
|
||||
// wrapped block, not the fragment.
|
||||
let padding_from_style = match self.specific {
|
||||
SpecificFragmentInfo::TableColumn(_) |
|
||||
SpecificFragmentInfo::TableRow |
|
||||
SpecificFragmentInfo::TableWrapper |
|
||||
SpecificFragmentInfo::InlineBlock(_) => LogicalMargin::zero(self.style.writing_mode),
|
||||
SpecificFragmentInfo::TableWrapper => LogicalMargin::zero(self.style.writing_mode),
|
||||
_ => model::padding_from_style(self.style(), containing_block_inline_size, self.style().writing_mode),
|
||||
};
|
||||
|
||||
|
|
|
@ -2398,53 +2398,6 @@ pub fn apply_declarations<'a, F, I>(device: &Device,
|
|||
style
|
||||
}
|
||||
|
||||
/// Modifies the style for an anonymous flow so it resets all its non-inherited
|
||||
/// style structs, and set their borders and outlines to zero.
|
||||
///
|
||||
/// Also, it gets a new display value, which is honored except when it's
|
||||
/// `inline`.
|
||||
#[cfg(feature = "servo")]
|
||||
pub fn modify_style_for_anonymous_flow(style: &mut Arc<ComputedValues>,
|
||||
new_display_value: longhands::display::computed_value::T) {
|
||||
// The 'align-self' property needs some special treatment since
|
||||
// its value depends on the 'align-items' value of its parent.
|
||||
% if "align-items" in data.longhands_by_name:
|
||||
use computed_values::align_self::T as align_self;
|
||||
use computed_values::align_items::T as align_items;
|
||||
let self_align =
|
||||
match style.position.align_items {
|
||||
align_items::stretch => align_self::stretch,
|
||||
align_items::baseline => align_self::baseline,
|
||||
align_items::flex_start => align_self::flex_start,
|
||||
align_items::flex_end => align_self::flex_end,
|
||||
align_items::center => align_self::center,
|
||||
};
|
||||
% endif
|
||||
let inital_values = &*INITIAL_SERVO_VALUES;
|
||||
let mut style = Arc::make_mut(style);
|
||||
% for style_struct in data.active_style_structs():
|
||||
% if not style_struct.inherited:
|
||||
style.${style_struct.ident} = inital_values.clone_${style_struct.name_lower}();
|
||||
% endif
|
||||
% endfor
|
||||
% if "align-items" in data.longhands_by_name:
|
||||
let position = Arc::make_mut(&mut style.position);
|
||||
position.align_self = self_align;
|
||||
% endif
|
||||
if new_display_value != longhands::display::computed_value::T::inline {
|
||||
let new_box = Arc::make_mut(&mut style.box_);
|
||||
new_box.display = new_display_value;
|
||||
}
|
||||
let border = Arc::make_mut(&mut style.border);
|
||||
% for side in ["top", "right", "bottom", "left"]:
|
||||
// Like calling to_computed_value, which wouldn't type check.
|
||||
border.border_${side}_width = Au(0);
|
||||
% endfor
|
||||
// Initial value of outline-style is always none for anonymous box.
|
||||
let outline = Arc::make_mut(&mut style.outline);
|
||||
outline.outline_width = Au(0);
|
||||
}
|
||||
|
||||
/// Adjusts borders as appropriate to account for a fragment's status as the
|
||||
/// first or last fragment within the range of an element.
|
||||
///
|
||||
|
|
|
@ -1,3 +0,0 @@
|
|||
[flexbox_nested-flex.htm]
|
||||
type: reftest
|
||||
expected: FAIL
|
Loading…
Add table
Add a link
Reference in a new issue