From 086c044dc34dfc0f74fbe41f4ecb402b2cd34884 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:13:33 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- servo/components/style/values/computed/animation.rs | 4 ++-- servo/components/style/values/computed/color.rs | 5 ++--- servo/components/style/values/computed/length_percentage.rs | 13 +++++++++++++ servo/components/style/values/computed/mod.rs | 2 +- 4 files changed, 18 insertions(+), 6 deletions(-) (limited to 'servo/components/style/values/computed') diff --git a/servo/components/style/values/computed/animation.rs b/servo/components/style/values/computed/animation.rs index 626dbe5347..b626687a36 100644 --- a/servo/components/style/values/computed/animation.rs +++ b/servo/components/style/values/computed/animation.rs @@ -11,8 +11,8 @@ use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; pub use crate::values::specified::animation::{ - AnimationName, ScrollAxis, ScrollTimelineName, TransitionProperty, AnimationComposition, - AnimationDirection, AnimationFillMode, AnimationPlayState, + AnimationComposition, AnimationDirection, AnimationFillMode, AnimationName, AnimationPlayState, + ScrollAxis, ScrollTimelineName, TransitionBehavior, TransitionProperty, }; /// A computed value for the `animation-iteration-count` property. diff --git a/servo/components/style/values/computed/color.rs b/servo/components/style/values/computed/color.rs index 9b5185d923..8aa50ba5ad 100644 --- a/servo/components/style/values/computed/color.rs +++ b/servo/components/style/values/computed/color.rs @@ -4,14 +4,13 @@ //! Computed color values. -use crate::color::parsing::Color as CSSParserColor; use crate::color::AbsoluteColor; use crate::values::animated::ToAnimatedZero; use crate::values::computed::percentage::Percentage; use crate::values::generics::color::{ GenericCaretColor, GenericColor, GenericColorMix, GenericColorOrAuto, }; -use std::fmt; +use std::fmt::{self, Write}; use style_traits::{CssWriter, ToCss}; pub use crate::values::specified::color::{ColorScheme, ForcedColorAdjust, PrintColorAdjust}; @@ -32,7 +31,7 @@ impl ToCss for Color { { match *self { Self::Absolute(ref c) => c.to_css(dest), - Self::CurrentColor => cssparser::ToCss::to_css(&CSSParserColor::CurrentColor, dest), + Self::CurrentColor => dest.write_str("currentcolor"), Self::ColorMix(ref m) => m.to_css(dest), } } diff --git a/servo/components/style/values/computed/length_percentage.rs b/servo/components/style/values/computed/length_percentage.rs index 898281a7ef..0dbd2de76d 100644 --- a/servo/components/style/values/computed/length_percentage.rs +++ b/servo/components/style/values/computed/length_percentage.rs @@ -443,6 +443,19 @@ impl LengthPercentage { } } + /// Converts to a `` with given basis. Returns None if the basis is 0. + #[inline] + pub fn to_percentage_of(&self, basis: Length) -> Option { + if basis.px() == 0. { + return None; + } + Some(match self.unpack() { + Unpacked::Length(l) => Percentage(l.px() / basis.px()), + Unpacked::Percentage(p) => p, + Unpacked::Calc(ref c) => Percentage(c.resolve(basis).px() / basis.px()), + }) + } + /// Returns the used value. #[inline] pub fn to_used_value(&self, containing_length: Au) -> Au { diff --git a/servo/components/style/values/computed/mod.rs b/servo/components/style/values/computed/mod.rs index de5db2cdab..85aadb401f 100644 --- a/servo/components/style/values/computed/mod.rs +++ b/servo/components/style/values/computed/mod.rs @@ -47,7 +47,7 @@ pub use self::angle::Angle; pub use self::animation::{ AnimationIterationCount, AnimationName, AnimationTimeline, AnimationPlayState, AnimationFillMode, AnimationComposition, AnimationDirection, ScrollAxis, - ScrollTimelineName, TransitionProperty, ViewTimelineInset + ScrollTimelineName, TransitionBehavior, TransitionProperty, ViewTimelineInset }; pub use self::background::{BackgroundRepeat, BackgroundSize}; pub use self::basic_shape::FillRule; -- cgit v1.2.3