diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:13:27 +0000 |
commit | 40a355a42d4a9444dc753c04c6608dade2f06a23 (patch) | |
tree | 871fc667d2de662f171103ce5ec067014ef85e61 /servo/components/style/values/computed | |
parent | Adding upstream version 124.0.1. (diff) | |
download | firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.tar.xz firefox-40a355a42d4a9444dc753c04c6608dade2f06a23.zip |
Adding upstream version 125.0.1.upstream/125.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'servo/components/style/values/computed')
4 files changed, 18 insertions, 6 deletions
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 `<percentage>` with given basis. Returns None if the basis is 0. + #[inline] + pub fn to_percentage_of(&self, basis: Length) -> Option<Percentage> { + 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; |