mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
uses app units in display_list (#33420)
Signed-off-by: atbrakhi <atbrakhi@igalia.com> Co-authored-by: Martin Robinson <mrobinson@igalia.com>
This commit is contained in:
parent
52f89c95b9
commit
f76692035b
14 changed files with 133 additions and 141 deletions
|
@ -1268,6 +1268,6 @@ impl SequentialLayoutState {
|
|||
.size
|
||||
.to_logical(container_writing_mode),
|
||||
}
|
||||
.to_physical(Some(&containing_block));
|
||||
.to_physical(Some(containing_block));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ use itertools::Either;
|
|||
use servo_arc::Arc;
|
||||
use style::computed_values::white_space_collapse::T as WhiteSpaceCollapse;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::Length;
|
||||
use style::values::generics::box_::{GenericVerticalAlign, VerticalAlignKeyword};
|
||||
use style::values::generics::font::LineHeight;
|
||||
use style::values::specified::align::AlignFlags;
|
||||
|
@ -433,7 +432,7 @@ impl<'layout_data, 'layout> LineItemLayout<'layout_data, 'layout> {
|
|||
let inline_box_containing_block = ContainingBlock {
|
||||
inline_size: content_rect.size.inline,
|
||||
block_size: AuOrAuto::Auto,
|
||||
style: &self.layout.containing_block.style,
|
||||
style: self.layout.containing_block.style,
|
||||
};
|
||||
let fragments = inner_state
|
||||
.fragments
|
||||
|
@ -515,11 +514,11 @@ impl<'layout_data, 'layout> LineItemLayout<'layout_data, 'layout> {
|
|||
// baseline, so we need to make it relative to the line block start.
|
||||
match inline_box_state.base.style.clone_vertical_align() {
|
||||
GenericVerticalAlign::Keyword(VerticalAlignKeyword::Top) => {
|
||||
let line_height: Au = line_height(style, font_metrics).into();
|
||||
let line_height: Au = line_height(style, font_metrics);
|
||||
(line_height - line_gap).scale_by(0.5)
|
||||
},
|
||||
GenericVerticalAlign::Keyword(VerticalAlignKeyword::Bottom) => {
|
||||
let line_height: Au = line_height(style, font_metrics).into();
|
||||
let line_height: Au = line_height(style, font_metrics);
|
||||
let half_leading = (line_height - line_gap).scale_by(0.5);
|
||||
self.line_metrics.block_size - line_height + half_leading
|
||||
},
|
||||
|
@ -875,13 +874,13 @@ pub(super) struct FloatLineItem {
|
|||
pub needs_placement: bool,
|
||||
}
|
||||
|
||||
fn line_height(parent_style: &ComputedValues, font_metrics: &FontMetrics) -> Length {
|
||||
fn line_height(parent_style: &ComputedValues, font_metrics: &FontMetrics) -> Au {
|
||||
let font = parent_style.get_font();
|
||||
let font_size = font.font_size.computed_size();
|
||||
match font.line_height {
|
||||
LineHeight::Normal => Length::from(font_metrics.line_gap),
|
||||
LineHeight::Number(number) => font_size * number.0,
|
||||
LineHeight::Length(length) => length.0,
|
||||
LineHeight::Normal => font_metrics.line_gap,
|
||||
LineHeight::Number(number) => (font_size * number.0).into(),
|
||||
LineHeight::Length(length) => length.0.into(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1685,7 +1685,7 @@ impl InlineFormattingContext {
|
|||
|
||||
FlowLayout {
|
||||
fragments: layout.fragments,
|
||||
content_block_size: content_block_size.into(),
|
||||
content_block_size: content_block_size,
|
||||
collapsible_margins_in_children,
|
||||
baselines: layout.baselines,
|
||||
}
|
||||
|
@ -1865,18 +1865,12 @@ impl InlineContainerState {
|
|||
VerticalAlign::Keyword(VerticalAlignKeyword::Baseline) |
|
||||
VerticalAlign::Keyword(VerticalAlignKeyword::Top) |
|
||||
VerticalAlign::Keyword(VerticalAlignKeyword::Bottom) => Au::zero(),
|
||||
VerticalAlign::Keyword(VerticalAlignKeyword::Sub) => Au::from_f32_px(
|
||||
block_size
|
||||
.resolve()
|
||||
.scale_by(FONT_SUBSCRIPT_OFFSET_RATIO)
|
||||
.to_f32_px(),
|
||||
),
|
||||
VerticalAlign::Keyword(VerticalAlignKeyword::Super) => -Au::from_f32_px(
|
||||
block_size
|
||||
.resolve()
|
||||
.scale_by(FONT_SUPERSCRIPT_OFFSET_RATIO)
|
||||
.to_f32_px(),
|
||||
),
|
||||
VerticalAlign::Keyword(VerticalAlignKeyword::Sub) => {
|
||||
block_size.resolve().scale_by(FONT_SUBSCRIPT_OFFSET_RATIO)
|
||||
},
|
||||
VerticalAlign::Keyword(VerticalAlignKeyword::Super) => {
|
||||
-block_size.resolve().scale_by(FONT_SUPERSCRIPT_OFFSET_RATIO)
|
||||
},
|
||||
VerticalAlign::Keyword(VerticalAlignKeyword::TextTop) => {
|
||||
child_block_size.size_for_baseline_positioning.ascent - self.font_metrics.ascent
|
||||
},
|
||||
|
@ -1893,7 +1887,7 @@ impl InlineContainerState {
|
|||
child_block_size.size_for_baseline_positioning.descent
|
||||
},
|
||||
VerticalAlign::Length(length_percentage) => {
|
||||
(-length_percentage.resolve(child_block_size.line_height.into())).into()
|
||||
-length_percentage.to_used_value(child_block_size.line_height)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,7 +13,7 @@ use servo_arc::Arc;
|
|||
use style::computed_values::clear::T as Clear;
|
||||
use style::computed_values::float::T as Float;
|
||||
use style::properties::ComputedValues;
|
||||
use style::values::computed::{Length, Size};
|
||||
use style::values::computed::Size;
|
||||
use style::values::specified::align::AlignFlags;
|
||||
use style::values::specified::{Display, TextAlignKeyword};
|
||||
use style::Zero;
|
||||
|
@ -196,7 +196,7 @@ impl BlockLevelBox {
|
|||
|
||||
pub(crate) struct FlowLayout {
|
||||
pub fragments: Vec<Fragment>,
|
||||
pub content_block_size: Length,
|
||||
pub content_block_size: Au,
|
||||
pub collapsible_margins_in_children: CollapsedBlockMargins,
|
||||
/// The offset of the baselines in this layout in the content area, if there were some. This is
|
||||
/// used to propagate inflow baselines to the ancestors of `display: inline-block` elements
|
||||
|
@ -285,7 +285,7 @@ impl OutsideMarker {
|
|||
},
|
||||
size: LogicalVec2 {
|
||||
inline: max_inline_size,
|
||||
block: flow_layout.content_block_size.into(),
|
||||
block: flow_layout.content_block_size,
|
||||
},
|
||||
};
|
||||
|
||||
|
@ -341,7 +341,7 @@ impl BlockFormattingContext {
|
|||
|
||||
IndependentLayout {
|
||||
fragments: flow_layout.fragments,
|
||||
content_block_size: Au::from(flow_layout.content_block_size) +
|
||||
content_block_size: flow_layout.content_block_size +
|
||||
flow_layout.collapsible_margins_in_children.end.solve() +
|
||||
clearance.unwrap_or_default(),
|
||||
content_inline_size_for_table: None,
|
||||
|
@ -856,7 +856,7 @@ fn layout_in_flow_non_replaced_block_level_same_formatting_context(
|
|||
sequential_layout_state.as_deref_mut(),
|
||||
CollapsibleWithParentStartMargin(start_margin_can_collapse_with_children),
|
||||
);
|
||||
let mut content_block_size: Au = flow_layout.content_block_size.into();
|
||||
let mut content_block_size: Au = flow_layout.content_block_size;
|
||||
|
||||
// Update margins.
|
||||
let mut block_margins_collapsed_with_children = CollapsedBlockMargins::from_margin(&margin);
|
||||
|
@ -1842,7 +1842,7 @@ impl<'container> PlacementState<'container> {
|
|||
}
|
||||
}
|
||||
|
||||
fn finish(mut self) -> (Length, CollapsedBlockMargins, Baselines) {
|
||||
fn finish(mut self) -> (Au, CollapsedBlockMargins, Baselines) {
|
||||
if !self.last_in_flow_margin_collapses_with_parent_end_margin {
|
||||
self.current_block_direction_position += self.current_margin.solve();
|
||||
self.current_margin = CollapsedMargin::zero();
|
||||
|
@ -1861,7 +1861,7 @@ impl<'container> PlacementState<'container> {
|
|||
};
|
||||
|
||||
(
|
||||
total_block_size.into(),
|
||||
total_block_size,
|
||||
CollapsedBlockMargins {
|
||||
collapsed_through,
|
||||
start: self.start_margin,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue