aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout')
-rw-r--r--components/layout/display_list_builder.rs9
-rw-r--r--components/layout/fragment.rs9
2 files changed, 11 insertions, 7 deletions
diff --git a/components/layout/display_list_builder.rs b/components/layout/display_list_builder.rs
index 36336b94b44..63ec70b7096 100644
--- a/components/layout/display_list_builder.rs
+++ b/components/layout/display_list_builder.rs
@@ -2803,12 +2803,13 @@ struct StopRun {
stop_count: usize,
}
-fn position_to_offset(position: LengthOrPercentage, Au(total_length): Au) -> f32 {
+fn position_to_offset(position: LengthOrPercentage, total_length: Au) -> f32 {
match position {
- LengthOrPercentage::Length(Au(length)) => length as f32 / total_length as f32,
+ LengthOrPercentage::Length(Au(length)) => length as f32 / total_length.0 as f32,
LengthOrPercentage::Percentage(percentage) => percentage as f32,
- LengthOrPercentage::Calc(calc) =>
- calc.percentage() + (calc.length().0 as f32) / (total_length as f32),
+ LengthOrPercentage::Calc(calc) => {
+ calc.to_used_value(Some(total_length)).unwrap().0 as f32 / total_length.0 as f32
+ },
}
}
diff --git a/components/layout/fragment.rs b/components/layout/fragment.rs
index 11b82bceb61..c0991ea2535 100644
--- a/components/layout/fragment.rs
+++ b/components/layout/fragment.rs
@@ -1504,7 +1504,11 @@ impl Fragment {
result_inline
}
LengthOrPercentageOrAuto::Length(length) => length,
- LengthOrPercentageOrAuto::Calc(calc) => calc.length(),
+ LengthOrPercentageOrAuto::Calc(calc) => {
+ // TODO(nox): This is probably wrong, because it accounts neither for
+ // clamping (not sure if necessary here) nor percentage.
+ calc.unclamped_length()
+ },
};
let size_constraint = self.size_constraint(None, Direction::Inline);
@@ -2233,8 +2237,7 @@ impl Fragment {
offset -= minimum_line_metrics.space_needed().scale_by(percentage)
}
vertical_align::T::LengthOrPercentage(LengthOrPercentage::Calc(formula)) => {
- offset -= minimum_line_metrics.space_needed().scale_by(formula.percentage()) +
- formula.length()
+ offset -= formula.to_used_value(Some(minimum_line_metrics.space_needed())).unwrap()
}
}
}