tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

commit e427768e823658da89832dd9d1bbeaa18480c017
parent ab4222ad998420801334ee213e78b565db3c210e
Author: Jan Varga <jvarga@igalia.com>
Date:   Mon,  8 Dec 2025 17:11:33 +0000

Bug 1990419 - Add custom ToTyped implementation for CSSPixelLength; r=firefox-style-system-reviewers,dshin

This patch adds the missing ToTyped implementation for CSSPixelLength,
enabling reification of computed <length> values into CSSNumericValue objects.
The lack of this implementation previously prevented the <length> WPT from
passing for scroll-margin-* properties.

Differential Revision: https://phabricator.services.mozilla.com/D271051

Diffstat:
Mservo/components/style/values/computed/length.rs | 12++++++++++--
Mtesting/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/scroll-margin.html.ini | 24------------------------
2 files changed, 10 insertions(+), 26 deletions(-)

diff --git a/servo/components/style/values/computed/length.rs b/servo/components/style/values/computed/length.rs @@ -21,7 +21,7 @@ use crate::Zero; use app_units::Au; use std::fmt::{self, Write}; use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub, SubAssign}; -use style_traits::{CSSPixel, CssWriter, ToCss}; +use style_traits::{CSSPixel, CssString, CssWriter, NumericValue, ToCss, ToTyped, TypedValue}; pub use super::image::Image; pub use super::length_percentage::{LengthPercentage, NonNegativeLengthPercentage}; @@ -181,7 +181,6 @@ impl NonNegativeLengthPercentageOrAuto { ToAnimatedZero, ToComputedValue, ToShmem, - ToTyped, )] #[repr(C)] pub struct CSSPixelLength(CSSFloat); @@ -333,6 +332,15 @@ impl ToCss for CSSPixelLength { } } +impl ToTyped for CSSPixelLength { + fn to_typed(&self) -> Option<TypedValue> { + Some(TypedValue::Numeric(NumericValue::Unit { + value: self.0 as f32, + unit: CssString::from("px"), + })) + } +} + impl std::iter::Sum for CSSPixelLength { fn sum<I: Iterator<Item = Self>>(iter: I) -> Self { iter.fold(Length::zero(), Add::add) diff --git a/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/scroll-margin.html.ini b/testing/web-platform/meta/css/css-typed-om/the-stylepropertymap/properties/scroll-margin.html.ini @@ -3,9 +3,6 @@ [Can set 'scroll-margin-top' to var() references: ] expected: FAIL - [Can set 'scroll-margin-top' to a length: ] - expected: FAIL - [Setting 'scroll-margin-top' to a percent: throws TypeError] expected: FAIL @@ -27,9 +24,6 @@ [Can set 'scroll-margin-left' to var() references: ] expected: FAIL - [Can set 'scroll-margin-left' to a length: ] - expected: FAIL - [Setting 'scroll-margin-left' to a percent: throws TypeError] expected: FAIL @@ -51,9 +45,6 @@ [Can set 'scroll-margin-right' to var() references: ] expected: FAIL - [Can set 'scroll-margin-right' to a length: ] - expected: FAIL - [Setting 'scroll-margin-right' to a percent: throws TypeError] expected: FAIL @@ -75,9 +66,6 @@ [Can set 'scroll-margin-bottom' to var() references: ] expected: FAIL - [Can set 'scroll-margin-bottom' to a length: ] - expected: FAIL - [Setting 'scroll-margin-bottom' to a percent: throws TypeError] expected: FAIL @@ -99,9 +87,6 @@ [Can set 'scroll-margin-inline-start' to var() references: ] expected: FAIL - [Can set 'scroll-margin-inline-start' to a length: ] - expected: FAIL - [Setting 'scroll-margin-inline-start' to a percent: throws TypeError] expected: FAIL @@ -123,9 +108,6 @@ [Can set 'scroll-margin-block-start' to var() references: ] expected: FAIL - [Can set 'scroll-margin-block-start' to a length: ] - expected: FAIL - [Setting 'scroll-margin-block-start' to a percent: throws TypeError] expected: FAIL @@ -147,9 +129,6 @@ [Can set 'scroll-margin-inline-end' to var() references: ] expected: FAIL - [Can set 'scroll-margin-inline-end' to a length: ] - expected: FAIL - [Setting 'scroll-margin-inline-end' to a percent: throws TypeError] expected: FAIL @@ -171,9 +150,6 @@ [Can set 'scroll-margin-block-end' to var() references: ] expected: FAIL - [Can set 'scroll-margin-block-end' to a length: ] - expected: FAIL - [Setting 'scroll-margin-block-end' to a percent: throws TypeError] expected: FAIL