commit 351bcb391f295e719e0300b746444936991cfcac
parent b528dd56433537d7fb5e4d86ab2fd730e904f1ac
Author: Oriol Brufau <obrufau@igalia.com>
Date: Tue, 7 Oct 2025 12:23:20 +0000
Bug 1992880 - Add method to obtain TextTransformCase from TextTransform. r=firefox-style-system-reviewers,emilio
This is useful for Servo.
Differential Revision: https://phabricator.services.mozilla.com/D267702
Diffstat:
1 file changed, 12 insertions(+), 0 deletions(-)
diff --git a/servo/components/style/values/specified/text.rs b/servo/components/style/values/specified/text.rs
@@ -453,6 +453,18 @@ impl TextTransform {
// Case bits are exclusive with each other.
case.is_empty() || case.bits().is_power_of_two()
}
+
+ /// Returns the corresponding TextTransformCase.
+ pub fn case(&self) -> TextTransformCase {
+ match *self & Self::CASE_TRANSFORMS {
+ Self::NONE => TextTransformCase::None,
+ Self::UPPERCASE => TextTransformCase::Uppercase,
+ Self::LOWERCASE => TextTransformCase::Lowercase,
+ Self::CAPITALIZE => TextTransformCase::Capitalize,
+ Self::MATH_AUTO => TextTransformCase::MathAuto,
+ _ => unreachable!("Case bits are exclusive with each other"),
+ }
+ }
}
/// Specified and computed value of text-align-last.