aboutsummaryrefslogtreecommitdiffstats
path: root/components/layout_2020/style_ext.rs
diff options
context:
space:
mode:
Diffstat (limited to 'components/layout_2020/style_ext.rs')
-rw-r--r--components/layout_2020/style_ext.rs14
1 files changed, 14 insertions, 0 deletions
diff --git a/components/layout_2020/style_ext.rs b/components/layout_2020/style_ext.rs
index a2017e5d0d5..50c19b7d8b6 100644
--- a/components/layout_2020/style_ext.rs
+++ b/components/layout_2020/style_ext.rs
@@ -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),
+ }
+ }
+}