Bug 1509717 - Move BorderStyle to border.rs. r=heycam
authorEmilio Cobos Álvarez <emilio@crisal.io>
Fri, 30 Nov 2018 05:16:52 +0000
changeset 448935 70030bab1073c89c41311368a224178257cb9068
parent 448934 7cd2172b993f1c7c876f415c11549bd319aebbf3
child 448936 c5b713000513a2cdc1fdbc70aeb8f7d78bd687b2
push id35129
push usernerli@mozilla.com
push dateFri, 30 Nov 2018 09:34:14 +0000
treeherdermozilla-central@c5b713000513 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersheycam
bugs1509717
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1509717 - Move BorderStyle to border.rs. r=heycam Differential Revision: https://phabricator.services.mozilla.com/D12858
servo/components/style/values/specified/border.rs
servo/components/style/values/specified/mod.rs
--- a/servo/components/style/values/specified/border.rs
+++ b/servo/components/style/values/specified/border.rs
@@ -14,16 +14,57 @@ use crate::values::generics::border::Bor
 use crate::values::generics::rect::Rect;
 use crate::values::generics::size::Size;
 use crate::values::specified::length::{Length, LengthOrPercentage, NonNegativeLength};
 use crate::values::specified::{AllowQuirks, Number, NumberOrPercentage};
 use cssparser::Parser;
 use std::fmt::{self, Write};
 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.
+#[allow(missing_docs)]
+#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
+#[derive(
+    Clone,
+    Copy,
+    Debug,
+    Eq,
+    MallocSizeOf,
+    Ord,
+    Parse,
+    PartialEq,
+    PartialOrd,
+    SpecifiedValueInfo,
+    ToComputedValue,
+    ToCss,
+)]
+pub enum BorderStyle {
+    Hidden = -2,
+    None = -1,
+    Inset = 0,
+    Groove = 1,
+    Outset = 2,
+    Ridge = 3,
+    Dotted = 4,
+    Dashed = 5,
+    Solid = 6,
+    Double = 7,
+}
+
+impl BorderStyle {
+    /// Whether this border style is either none or hidden.
+    #[inline]
+    pub fn none_or_hidden(&self) -> bool {
+        matches!(*self, BorderStyle::None | BorderStyle::Hidden)
+    }
+}
+
 /// A specified value for a single side of the `border-width` property.
 #[derive(Clone, Debug, MallocSizeOf, PartialEq, SpecifiedValueInfo, ToCss)]
 pub enum BorderSideWidth {
     /// `thin`
     Thin,
     /// `medium`
     Medium,
     /// `thick`
--- a/servo/components/style/values/specified/mod.rs
+++ b/servo/components/style/values/specified/mod.rs
@@ -29,17 +29,17 @@ use style_traits::{CssWriter, ParseError
 pub use self::align::{AlignContent, AlignItems, AlignSelf, ContentDistribution};
 #[cfg(feature = "gecko")]
 pub use self::align::{JustifyContent, JustifyItems, JustifySelf, SelfAlignment};
 pub use self::angle::Angle;
 pub use self::background::{BackgroundRepeat, BackgroundSize};
 pub use self::basic_shape::FillRule;
 pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth};
 pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
-pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing};
+pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing, BorderStyle};
 pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
 pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float};
 pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
 pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange};
 pub use self::color::{Color, ColorPropertyValue, RGBAColor};
 pub use self::column::ColumnCount;
 pub use self::counters::{Content, ContentItem, CounterIncrement, CounterReset};
 pub use self::easing::TimingFunction;
@@ -147,56 +147,16 @@ fn parse_number_with_clamping_mode<'i, '
     let result = input.parse_nested_block(|i| CalcNode::parse_number(context, i))?;
 
     Ok(Number {
         value: result.min(f32::MAX).max(f32::MIN),
         calc_clamping_mode: Some(clamping_mode),
     })
 }
 
-// The integer values here correspond to the border conflict resolution rules in CSS 2.1 §
-// 17.6.2.1. Higher values override lower values.
-//
-// FIXME(emilio): Should move to border.rs
-#[allow(missing_docs)]
-#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
-#[derive(
-    Clone,
-    Copy,
-    Debug,
-    Eq,
-    MallocSizeOf,
-    Ord,
-    Parse,
-    PartialEq,
-    PartialOrd,
-    SpecifiedValueInfo,
-    ToComputedValue,
-    ToCss,
-)]
-pub enum BorderStyle {
-    None = -1,
-    Solid = 6,
-    Double = 7,
-    Dotted = 4,
-    Dashed = 5,
-    Hidden = -2,
-    Groove = 1,
-    Ridge = 3,
-    Inset = 0,
-    Outset = 2,
-}
-
-impl BorderStyle {
-    /// Whether this border style is either none or hidden.
-    pub fn none_or_hidden(&self) -> bool {
-        matches!(*self, BorderStyle::None | BorderStyle::Hidden)
-    }
-}
-
 /// A CSS `<number>` specified value.
 ///
 /// https://drafts.csswg.org/css-values-3/#number-value
 #[derive(Clone, Copy, Debug, MallocSizeOf, PartialEq, PartialOrd)]
 pub struct Number {
     /// The numeric value itself.
     value: CSSFloat,
     /// If this number came from a calc() expression, this tells how clamping