style/values/specified/rect.rs
1/* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this
3 * file, You can obtain one at https://mozilla.org/MPL/2.0/. */
4
5//! Specified types for CSS borders.
6
7use crate::typed_om::{ToTyped, TypedValue};
8use crate::values::generics::rect::Rect;
9use crate::values::specified::length::NonNegativeLengthOrNumber;
10use thin_vec::ThinVec;
11
12/// A specified rectangle made of four `<length-or-number>` values.
13pub type NonNegativeLengthOrNumberRect = Rect<NonNegativeLengthOrNumber>;
14
15impl ToTyped for NonNegativeLengthOrNumberRect {
16 // Note: The specification does not currently define how border image
17 // outset should be reified into Typed OM. The current behavior follows
18 // existing WPT coverage (border-image-outset.html). Syncing spec with
19 // UA/WPT behavior tracked in
20 // https://github.com/w3c/csswg-drafts/issues/13907
21 fn to_typed(&self, dest: &mut ThinVec<TypedValue>) -> Result<(), ()> {
22 if !self.all_sides_equal() {
23 return Err(());
24 }
25
26 self.0.to_typed(dest)
27 }
28}