/* This Source Code Form is subject to the terms of the Mozilla Public *License,v.2.0.IfacopyoftheMPLwasnotdistributedwiththis
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
//! Specified types for CSS values related to borders.
usecrate::derives::*; usecrate::parser::{Parse, ParserContext}; usecrate::typed_om::{ToTyped, TypedValue}; usecrate::values::computed::border::BorderSideWidth as ComputedBorderSideWidth; usecrate::values::computed::{Context, ToComputedValue}; usecrate::values::generics::border::{
GenericBorderCornerRadius, GenericBorderImageSideWidth, GenericBorderImageSlice,
GenericBorderRadius, GenericBorderSpacing,
}; usecrate::values::generics::rect::Rect; usecrate::values::generics::size::Size2D; usecrate::values::specified::length::{Length, NonNegativeLength, NonNegativeLengthPercentage}; usecrate::values::specified::{AllowQuirks, NonNegativeNumber, NonNegativeNumberOrPercentage}; usecrate::Zero; use app_units::Au; use cssparser::Parser; use std::fmt::{self, Write}; use style_traits::{CssWriter, ParseError, ToCss}; use thin_vec::ThinVec;
/// A specified value for a single side of a `border-style` property. /// /// The order here corresponds to the integer values from the border conflict /// resolution rules in CSS 2.1 § 17.6.2.1. Higher values override lower values. #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[derive(
Clone,
Copy,
Debug,
Eq,
FromPrimitive,
MallocSizeOf,
Ord,
Parse,
PartialEq,
PartialOrd,
SpecifiedValueInfo,
ToComputedValue,
ToCss,
ToResolvedValue,
ToShmem,
ToTyped,
)] #[repr(u8)] pubenum BorderStyle {
Hidden,
None,
Inset,
Groove,
Outset,
Ridge,
Dotted,
Dashed,
Solid,
Double,
}
impl BorderStyle { /// Whether this border style is either none or hidden. #[inline] pubfn none_or_hidden(&self) -> bool {
matches!(*self, BorderStyle::None | BorderStyle::Hidden)
}
}
/// A specified value for the `border-image-width` property. pubtype BorderImageWidth = Rect<BorderImageSideWidth>;
impl ToTyped for BorderImageWidth { // Note: The specification does not currently define how border image width // should be reified into Typed OM. The current behavior follows existing // WPT coverage (border-image-width.html). Syncing spec with UA/WPT // behavior tracked in https://github.com/w3c/csswg-drafts/issues/13907 fn to_typed(&self, dest: &mut ThinVec<TypedValue>) -> Result<(), ()> { if !self.all_sides_equal() { return Err(());
}
self.0.to_typed(dest)
}
}
/// A specified value for a single side of a `border-image-width` property. pubtype BorderImageSideWidth =
GenericBorderImageSideWidth<NonNegativeLengthPercentage, NonNegativeNumber>;
/// A specified value for the `border-image-slice` property. pubtype BorderImageSlice = GenericBorderImageSlice<NonNegativeNumberOrPercentage>;
impl ToTyped for BorderImageSlice { // Note: The specification does not currently define how border image slice // should be reified into Typed OM. The current behavior follows existing // WPT coverage (border-image-slice.html). Syncing spec with UA/WPT // behavior tracked in https://github.com/w3c/csswg-drafts/issues/13907 fn to_typed(&self, dest: &mut ThinVec<TypedValue>) -> Result<(), ()> { ifself.fill { return Err(());
}
let offsets = &self.offsets;
if !offsets.all_sides_equal() { return Err(());
}
offsets.0.to_typed(dest)
}
}
/// A specified value for the `border-radius` property. pubtype BorderRadius = GenericBorderRadius<NonNegativeLengthPercentage>;
/// A specified value for the `border-*-radius` longhand properties. pubtype BorderCornerRadius = GenericBorderCornerRadius<NonNegativeLengthPercentage>;
/// A specified value for the `border-spacing` longhand properties. pubtype BorderSpacing = GenericBorderSpacing<NonNegativeLength>;
/// A specified value for a single side of the `border-width` property. The difference between this /// and LineWidth is whether we snap to device pixels or not. #[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss, ToShmem, ToTyped)] pubstruct BorderSideWidth(LineWidth);
// Round `width` down to the nearest device pixel, but any non-zero value that would round // down to zero is clamped to 1 device pixel. if len == Au(0) { return len;
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.