mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
Introduce CalcLengthOrPercentage::unclamped_length
This is necessary for some operations, notably converting this to something suitable for gecko.
This commit is contained in:
parent
bcf1a6c5e5
commit
307dd74ecf
9 changed files with 32 additions and 20 deletions
|
@ -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
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue