mirror of
https://github.com/servo/servo.git
synced 2025-08-06 22:15:33 +01:00
style: Move outline-style outside of mako
This commit is contained in:
parent
0fa605d243
commit
b9b91b33be
8 changed files with 87 additions and 56 deletions
|
@ -54,6 +54,7 @@ pub use super::specified::{BorderStyle, TextDecorationLine};
|
|||
pub use self::length::{CalcLengthOrPercentage, Length, LengthOrNone, LengthOrNumber, LengthOrPercentage};
|
||||
pub use self::length::{LengthOrPercentageOrAuto, LengthOrPercentageOrNone, MaxLength, MozLength};
|
||||
pub use self::length::{CSSPixelLength, NonNegativeLength, NonNegativeLengthOrPercentage};
|
||||
pub use self::outline::OutlineStyle;
|
||||
pub use self::percentage::Percentage;
|
||||
pub use self::position::{Position, GridAutoFlow, GridTemplateAreas};
|
||||
pub use self::svg::{SVGLength, SVGOpacity, SVGPaint, SVGPaintKind, SVGStrokeDashArray, SVGWidth};
|
||||
|
@ -79,6 +80,7 @@ pub mod image;
|
|||
#[cfg(feature = "gecko")]
|
||||
pub mod gecko;
|
||||
pub mod length;
|
||||
pub mod outline;
|
||||
pub mod percentage;
|
||||
pub mod position;
|
||||
pub mod rect;
|
||||
|
|
7
components/style/values/computed/outline.rs
Normal file
7
components/style/values/computed/outline.rs
Normal file
|
@ -0,0 +1,7 @@
|
|||
/* 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 http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Computed values for outline properties
|
||||
|
||||
pub use values::specified::OutlineStyle;
|
|
@ -49,6 +49,7 @@ pub use self::length::{LengthOrPercentage, LengthOrPercentageOrAuto};
|
|||
pub use self::length::{LengthOrPercentageOrNone, MaxLength, MozLength};
|
||||
pub use self::length::{NoCalcLength, ViewportPercentageLength};
|
||||
pub use self::length::NonNegativeLengthOrPercentage;
|
||||
pub use self::outline::OutlineStyle;
|
||||
pub use self::rect::LengthOrNumberRect;
|
||||
pub use self::percentage::Percentage;
|
||||
pub use self::position::{Position, PositionComponent, GridAutoFlow, GridTemplateAreas};
|
||||
|
@ -78,6 +79,7 @@ pub mod gecko;
|
|||
pub mod grid;
|
||||
pub mod image;
|
||||
pub mod length;
|
||||
pub mod outline;
|
||||
pub mod percentage;
|
||||
pub mod position;
|
||||
pub mod rect;
|
||||
|
|
56
components/style/values/specified/outline.rs
Normal file
56
components/style/values/specified/outline.rs
Normal file
|
@ -0,0 +1,56 @@
|
|||
/* 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 http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
//! Specified values for outline properties
|
||||
|
||||
use cssparser::Parser;
|
||||
use parser::{Parse, ParserContext};
|
||||
use selectors::parser::SelectorParseErrorKind;
|
||||
use style_traits::ParseError;
|
||||
use values::specified::BorderStyle;
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, MallocSizeOf, Ord)]
|
||||
#[derive(PartialEq, PartialOrd, ToComputedValue, ToCss)]
|
||||
/// <https://drafts.csswg.org/css-ui/#propdef-outline-style>
|
||||
pub enum OutlineStyle {
|
||||
/// auto
|
||||
Auto,
|
||||
/// <border-style>
|
||||
Other(BorderStyle),
|
||||
}
|
||||
|
||||
impl OutlineStyle {
|
||||
#[inline]
|
||||
/// Get default value as None
|
||||
pub fn none() -> OutlineStyle {
|
||||
OutlineStyle::Other(BorderStyle::None)
|
||||
}
|
||||
|
||||
#[inline]
|
||||
/// Get value for None or Hidden
|
||||
pub fn none_or_hidden(&self) -> bool {
|
||||
match *self {
|
||||
OutlineStyle::Auto => false,
|
||||
OutlineStyle::Other(ref border_style) => border_style.none_or_hidden()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for OutlineStyle {
|
||||
fn parse<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>
|
||||
) -> Result<OutlineStyle, ParseError<'i>> {
|
||||
if let Ok(border_style) = input.try(|i| BorderStyle::parse(context, i)) {
|
||||
if let BorderStyle::Hidden = border_style {
|
||||
return Err(input.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("hidden".into())));
|
||||
}
|
||||
|
||||
return Ok(OutlineStyle::Other(border_style));
|
||||
}
|
||||
|
||||
input.expect_ident_matching("auto")?;
|
||||
Ok(OutlineStyle::Auto)
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue