From 43a97878ce14b72f0981164f87f2e35e14151312 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 7 Apr 2024 11:22:09 +0200 Subject: Adding upstream version 110.0.1. Signed-off-by: Daniel Baumann --- servo/components/style/values/specified/outline.rs | 71 ++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 servo/components/style/values/specified/outline.rs (limited to 'servo/components/style/values/specified/outline.rs') diff --git a/servo/components/style/values/specified/outline.rs b/servo/components/style/values/specified/outline.rs new file mode 100644 index 0000000000..6e5382d4c2 --- /dev/null +++ b/servo/components/style/values/specified/outline.rs @@ -0,0 +1,71 @@ +/* This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at https://mozilla.org/MPL/2.0/. */ + +//! Specified values for outline properties + +use crate::parser::{Parse, ParserContext}; +use crate::values::specified::BorderStyle; +use cssparser::Parser; +use selectors::parser::SelectorParseErrorKind; +use style_traits::ParseError; + +#[derive( + Clone, + Copy, + Debug, + Eq, + MallocSizeOf, + Ord, + PartialEq, + PartialOrd, + SpecifiedValueInfo, + ToComputedValue, + ToCss, + ToResolvedValue, + ToShmem, +)] +#[repr(C, u8)] +/// +pub enum OutlineStyle { + /// auto + Auto, + /// + BorderStyle(BorderStyle), +} + +impl OutlineStyle { + #[inline] + /// Get default value as None + pub fn none() -> OutlineStyle { + OutlineStyle::BorderStyle(BorderStyle::None) + } + + #[inline] + /// Get value for None or Hidden + pub fn none_or_hidden(&self) -> bool { + match *self { + OutlineStyle::Auto => false, + OutlineStyle::BorderStyle(ref style) => style.none_or_hidden(), + } + } +} + +impl Parse for OutlineStyle { + fn parse<'i, 't>( + _context: &ParserContext, + input: &mut Parser<'i, 't>, + ) -> Result> { + if let Ok(border_style) = input.try_parse(BorderStyle::parse) { + if let BorderStyle::Hidden = border_style { + return Err(input + .new_custom_error(SelectorParseErrorKind::UnexpectedIdent("hidden".into()))); + } + + return Ok(OutlineStyle::BorderStyle(border_style)); + } + + input.expect_ident_matching("auto")?; + Ok(OutlineStyle::Auto) + } +} -- cgit v1.2.3