layout: Switch IndependentLayout to use Au instead of Length (#31083)

* use au in layout

* fmt

* review fix
This commit is contained in:
atbrakhi 2024-01-15 15:31:21 +01:00 committed by GitHub
parent efa38c67fe
commit 1b847c3166
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
8 changed files with 52 additions and 21 deletions

View file

@ -2,6 +2,7 @@
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
use app_units::Au;
use servo_config::pref;
use style::computed_values::mix_blend_mode::T as ComputedMixBlendMode;
use style::computed_values::position::T as ComputedPosition;
@ -626,3 +627,16 @@ fn size_to_length(size: &Size) -> LengthPercentageOrAuto {
Size::Auto => LengthPercentageOrAuto::Auto,
}
}
pub(crate) trait Clamp: Sized {
fn clamp_between_extremums(self, min: Self, max: Option<Self>) -> Self;
}
impl Clamp for Au {
fn clamp_between_extremums(self, min: Self, max: Option<Self>) -> Self {
match max {
Some(max_value) => self.min(max_value).max(min),
None => self.max(min),
}
}
}