/* 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::parser::{Parse, ParserContext}; 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::Color; usecrate::values::specified::{AllowQuirks, NonNegativeNumber, NonNegativeNumberOrPercentage}; usecrate::Zero; use app_units::Au; use cssparser::Parser; use std::fmt::{self, Write}; use style_traits::{values::SequenceWriter, CssWriter, ParseError, ToCss};
/// 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,
)] #[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>;
/// 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>;
/// 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)] pubstruct BorderSideWidth(LineWidth);
impl ToComputedValue for BorderSideWidth { type ComputedValue = app_units::Au;
#[inline] fn to_computed_value(&self, context: &Context) -> Self::ComputedValue { let width = self.0.to_computed_value(context); // 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 width == Au(0) { return width;
}
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.