style: Use cbindgen for border-style and outline-style.

I'm pretty sure the FIXME I left in the outline-style code is a bug,
but I want to clean this up further and I didn't want to fix it without adding
a test.

Differential Revision: https://phabricator.services.mozilla.com/D12859
This commit is contained in:
Emilio Cobos Álvarez 2018-11-30 05:27:28 +00:00
parent fd73f1665a
commit efecd06a28
5 changed files with 80 additions and 95 deletions

View file

@ -21,8 +21,8 @@ use style_traits::{CssWriter, ParseError, ToCss};
/// A specified value for a single side of a `border-style` property.
///
/// The integer values here correspond to the border conflict resolution rules
/// in CSS 2.1 § 17.6.2.1. Higher values override lower values.
/// 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(
@ -39,17 +39,18 @@ use style_traits::{CssWriter, ParseError, ToCss};
ToComputedValue,
ToCss,
)]
#[repr(u8)]
pub enum BorderStyle {
Hidden = -2,
None = -1,
Inset = 0,
Groove = 1,
Outset = 2,
Ridge = 3,
Dotted = 4,
Dashed = 5,
Solid = 6,
Double = 7,
Hidden,
None,
Inset,
Groove,
Outset,
Ridge,
Dotted,
Dashed,
Solid,
Double,
}
impl BorderStyle {

View file

@ -23,19 +23,20 @@ use style_traits::ParseError;
ToComputedValue,
ToCss,
)]
#[repr(C, u8)]
/// <https://drafts.csswg.org/css-ui/#propdef-outline-style>
pub enum OutlineStyle {
/// auto
Auto,
/// <border-style>
Other(BorderStyle),
BorderStyle(BorderStyle),
}
impl OutlineStyle {
#[inline]
/// Get default value as None
pub fn none() -> OutlineStyle {
OutlineStyle::Other(BorderStyle::None)
OutlineStyle::BorderStyle(BorderStyle::None)
}
#[inline]
@ -43,7 +44,7 @@ impl OutlineStyle {
pub fn none_or_hidden(&self) -> bool {
match *self {
OutlineStyle::Auto => false,
OutlineStyle::Other(ref border_style) => border_style.none_or_hidden(),
OutlineStyle::BorderStyle(ref style) => style.none_or_hidden(),
}
}
}
@ -59,7 +60,7 @@ impl Parse for OutlineStyle {
.new_custom_error(SelectorParseErrorKind::UnexpectedIdent("hidden".into())));
}
return Ok(OutlineStyle::Other(border_style));
return Ok(OutlineStyle::BorderStyle(border_style));
}
input.expect_ident_matching("auto")?;