diff options
author | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-11-15 08:15:13 +0000 |
---|---|---|
committer | Emilio Cobos Álvarez <emilio@crisal.io> | 2018-11-17 09:56:03 +0100 |
commit | d9de68ad6a703b60215b64f40f90ddd19d86797a (patch) | |
tree | 42fc59495ba837062126031ec3ca2c0b53827f35 | |
parent | 9f28242def7718a5c3e04a61093890d504743010 (diff) | |
download | servo-d9de68ad6a703b60215b64f40f90ddd19d86797a.tar.gz servo-d9de68ad6a703b60215b64f40f90ddd19d86797a.zip |
style: Move the page-break-{before,after} properties to not use mako.
And respect the computed value of `left` / `right` / etc.
Differential Revision: https://phabricator.services.mozilla.com/D11872
-rw-r--r-- | components/style/cbindgen.toml | 1 | ||||
-rw-r--r-- | components/style/properties/data.py | 1 | ||||
-rw-r--r-- | components/style/properties/gecko.mako.rs | 33 | ||||
-rw-r--r-- | components/style/properties/longhands/box.mako.rs | 13 | ||||
-rw-r--r-- | components/style/values/computed/box.rs | 10 | ||||
-rw-r--r-- | components/style/values/computed/mod.rs | 2 | ||||
-rw-r--r-- | components/style/values/specified/box.rs | 26 | ||||
-rw-r--r-- | components/style/values/specified/mod.rs | 2 |
8 files changed, 44 insertions, 44 deletions
diff --git a/components/style/cbindgen.toml b/components/style/cbindgen.toml index d9efc9d9e18..098022cf13d 100644 --- a/components/style/cbindgen.toml +++ b/components/style/cbindgen.toml @@ -39,6 +39,7 @@ derive_helper_methods = true prefix = "Style" include = [ "Appearance", + "BreakBetween", "ComputedFontStretchRange", "ComputedFontStyleDescriptor", "ComputedFontWeightRange", diff --git a/components/style/properties/data.py b/components/style/properties/data.py index 97e2f7f0d84..c0be33177f2 100644 --- a/components/style/properties/data.py +++ b/components/style/properties/data.py @@ -291,6 +291,7 @@ class Longhand(object): "AlignItems", "AlignSelf", "Appearance", + "BreakBetween", "BackgroundRepeat", "BorderImageRepeat", "BorderStyle", diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs index 2cc8cf2bcd3..15d4c40773b 100644 --- a/components/style/properties/gecko.mako.rs +++ b/components/style/properties/gecko.mako.rs @@ -1396,6 +1396,7 @@ impl Clone for ${style_struct.gecko_struct_name} { # Types used with predefined_type()-defined properties that we can auto-generate. predefined_types = { + "BreakBetween": impl_simple, "Color": impl_color, "ColorOrAuto": impl_color, "GreaterThanOrEqualToOneNumber": impl_simple, @@ -3029,8 +3030,7 @@ fn static_assert() { animation-iteration-count animation-timing-function transition-duration transition-delay transition-timing-function transition-property - page-break-before page-break-after rotate - scroll-snap-points-x scroll-snap-points-y + rotate scroll-snap-points-x scroll-snap-points-y scroll-snap-type-x scroll-snap-type-y scroll-snap-coordinate perspective-origin -moz-binding will-change offset-path overscroll-behavior-x overscroll-behavior-y @@ -3149,35 +3149,6 @@ fn static_assert() { <%call expr="impl_coord_copy('vertical_align', 'mVerticalAlign')"></%call> - % for kind in ["before", "after"]: - // Temp fix for Bugzilla bug 24000. - // Map 'auto' and 'avoid' to false, and 'always', 'left', and 'right' to true. - // "A conforming user agent may interpret the values 'left' and 'right' - // as 'always'." - CSS2.1, section 13.3.1 - pub fn set_page_break_${kind}(&mut self, v: longhands::page_break_${kind}::computed_value::T) { - use crate::computed_values::page_break_${kind}::T; - - let result = match v { - T::Auto => false, - T::Always => true, - T::Avoid => false, - T::Left => true, - T::Right => true - }; - self.gecko.mBreak${kind.title()} = result; - } - - ${impl_simple_copy('page_break_' + kind, 'mBreak' + kind.title())} - - // Temp fix for Bugzilla bug 24000. - // See set_page_break_before/after for detail. - pub fn clone_page_break_${kind}(&self) -> longhands::page_break_${kind}::computed_value::T { - use crate::computed_values::page_break_${kind}::T; - - if self.gecko.mBreak${kind.title()} { T::Always } else { T::Auto } - } - % endfor - ${impl_style_coord("scroll_snap_points_x", "mScrollSnapPointsX")} ${impl_style_coord("scroll_snap_points_y", "mScrollSnapPointsY")} diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs index 685e97aa3b0..da0e919f784 100644 --- a/components/style/properties/longhands/box.mako.rs +++ b/components/style/properties/longhands/box.mako.rs @@ -437,18 +437,21 @@ ${helpers.single_keyword( animation_value_type="discrete", )} -// TODO add support for logical values recto and verso -${helpers.single_keyword( +${helpers.predefined_type( "page-break-after", - "auto always avoid left right", + "BreakBetween", + "computed::BreakBetween::Auto", + needs_context=False, products="gecko", spec="https://drafts.csswg.org/css2/page.html#propdef-page-break-after", animation_value_type="discrete", )} -${helpers.single_keyword( +${helpers.predefined_type( "page-break-before", - "auto always avoid left right", + "BreakBetween", + "computed::BreakBetween::Auto", + needs_context=False, products="gecko", spec="https://drafts.csswg.org/css2/page.html#propdef-page-break-before", animation_value_type="discrete", diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs index 0cf6ab3e39c..dd168b72b39 100644 --- a/components/style/values/computed/box.rs +++ b/components/style/values/computed/box.rs @@ -11,13 +11,11 @@ use crate::values::generics::box_::Perspective as GenericPerspective; use crate::values::generics::box_::VerticalAlign as GenericVerticalAlign; use crate::values::specified::box_ as specified; -pub use crate::values::specified::box_::{ - AnimationName, Appearance, Contain, Display, OverflowClipBox, -}; +pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween}; +pub use crate::values::specified::box_::{Contain, Display, OverflowClipBox}; pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat}; -pub use crate::values::specified::box_::{ - OverscrollBehavior, ScrollSnapType, TouchAction, TransitionProperty, WillChange, -}; +pub use crate::values::specified::box_::{OverscrollBehavior, ScrollSnapType}; +pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange}; /// A computed value for the `vertical-align` property. pub type VerticalAlign = GenericVerticalAlign<LengthOrPercentage>; diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs index 75c95e1a956..3f3b29189ab 100644 --- a/components/style/values/computed/mod.rs +++ b/components/style/values/computed/mod.rs @@ -42,7 +42,7 @@ pub use self::border::{BorderCornerRadius, BorderRadius, BorderSpacing}; pub use self::border::{BorderImageRepeat, BorderImageSideWidth}; pub use self::border::{BorderImageSlice, BorderImageWidth}; pub use self::box_::{AnimationIterationCount, AnimationName, Contain}; -pub use self::box_::{Appearance, Clear, Float}; +pub use self::box_::{Appearance, BreakBetween, Clear, Float}; pub use self::box_::{Display, TransitionProperty}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize}; pub use self::box_::{ScrollSnapType, TouchAction, VerticalAlign, WillChange}; diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs index 6a207d0a90c..8d0c9f38be9 100644 --- a/components/style/values/specified/box.rs +++ b/components/style/values/specified/box.rs @@ -1289,3 +1289,29 @@ pub enum Appearance { #[css(skip)] Count, } + +/// A kind of break between two boxes. +/// +/// https://drafts.csswg.org/css-break/#break-between +#[allow(missing_docs)] +#[derive( + Clone, + Copy, + Debug, + Eq, + Hash, + MallocSizeOf, + Parse, + PartialEq, + SpecifiedValueInfo, + ToCss, + ToComputedValue, +)] +#[repr(u8)] +pub enum BreakBetween { + Auto, + Always, + Avoid, + Left, + Right, +} diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs index 22bdc233e5d..6fa8dbb4101 100644 --- a/components/style/values/specified/mod.rs +++ b/components/style/values/specified/mod.rs @@ -36,7 +36,7 @@ pub use self::border::{BorderCornerRadius, BorderImageSlice, BorderImageWidth}; pub use self::border::{BorderImageRepeat, BorderImageSideWidth}; pub use self::border::{BorderRadius, BorderSideWidth, BorderSpacing}; pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display}; -pub use self::box_::{Appearance, Clear, Float}; +pub use self::box_::{Appearance, BreakBetween, 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}; |