aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEmilio Cobos Álvarez <emilio@crisal.io>2018-12-11 01:50:32 +0100
committerEmilio Cobos Álvarez <emilio@crisal.io>2018-12-16 13:35:05 +0100
commit901c055519198872460352fc43ff997f7e1dac12 (patch)
tree6a069e7c1b4b0c18d4e9b4bf2b365378886cf8d5
parent3f58e0b069859515844da0565a06a7950af4862f (diff)
downloadservo-901c055519198872460352fc43ff997f7e1dac12.tar.gz
servo-901c055519198872460352fc43ff997f7e1dac12.zip
style: Move overflow to use cbindgen.
It's one of the most annoying / hacky mako bits we have. Differential Revision: https://phabricator.services.mozilla.com/D14084
-rw-r--r--components/style/cbindgen.toml1
-rw-r--r--components/style/properties/data.py1
-rw-r--r--components/style/properties/gecko.mako.rs25
-rw-r--r--components/style/properties/longhands/box.mako.rs32
-rw-r--r--components/style/values/computed/box.rs2
-rw-r--r--components/style/values/computed/mod.rs2
-rw-r--r--components/style/values/specified/box.rs25
-rw-r--r--components/style/values/specified/mod.rs2
8 files changed, 46 insertions, 44 deletions
diff --git a/components/style/cbindgen.toml b/components/style/cbindgen.toml
index 3b5d56f9882..6005126fb27 100644
--- a/components/style/cbindgen.toml
+++ b/components/style/cbindgen.toml
@@ -64,5 +64,6 @@ include = [
"ScrollSnapType",
"OverflowClipBox",
"Resize",
+ "Overflow",
]
item_types = ["enums", "structs", "typedefs"]
diff --git a/components/style/properties/data.py b/components/style/properties/data.py
index 52d8cf8ec03..8faaa163823 100644
--- a/components/style/properties/data.py
+++ b/components/style/properties/data.py
@@ -325,6 +325,7 @@ class Longhand(object):
"NonNegativeNumber",
"Opacity",
"OutlineStyle",
+ "Overflow",
"OverflowClipBox",
"OverflowWrap",
"OverscrollBehavior",
diff --git a/components/style/properties/gecko.mako.rs b/components/style/properties/gecko.mako.rs
index 6381bc1f47e..5f96b42c10a 100644
--- a/components/style/properties/gecko.mako.rs
+++ b/components/style/properties/gecko.mako.rs
@@ -1394,6 +1394,7 @@ impl Clone for ${style_struct.gecko_struct_name} {
"OverflowClipBox": impl_simple,
"ScrollSnapType": impl_simple,
"Float": impl_simple,
+ "Overflow": impl_simple,
"BreakBetween": impl_simple,
"BreakWithin": impl_simple,
"Resize": impl_simple,
@@ -3011,7 +3012,7 @@ fn static_assert() {
}
</%def>
-<% skip_box_longhands= """display overflow-y vertical-align
+<% skip_box_longhands= """display vertical-align
animation-name animation-delay animation-duration
animation-direction animation-fill-mode animation-play-state
animation-iteration-count animation-timing-function
@@ -3063,28 +3064,6 @@ fn static_assert() {
) %>
${impl_keyword('clear', 'mBreakType', clear_keyword)}
- <% overflow_x = data.longhands_by_name["overflow-x"] %>
- pub fn set_overflow_y(&mut self, v: longhands::overflow_y::computed_value::T) {
- use crate::properties::longhands::overflow_x::computed_value::T as BaseType;
- // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
- self.gecko.mOverflowY = match v {
- % for value in overflow_x.keyword.values_for('gecko'):
- BaseType::${to_camel_case(value)} => structs::${overflow_x.keyword.gecko_constant(value)} as u8,
- % endfor
- };
- }
- ${impl_simple_copy('overflow_y', 'mOverflowY')}
- pub fn clone_overflow_y(&self) -> longhands::overflow_y::computed_value::T {
- use crate::properties::longhands::overflow_x::computed_value::T as BaseType;
- // FIXME(bholley): Align binary representations and ditch |match| for cast + static_asserts
- match self.gecko.mOverflowY as u32 {
- % for value in overflow_x.keyword.values_for('gecko'):
- structs::${overflow_x.keyword.gecko_constant(value)} => BaseType::${to_camel_case(value)},
- % endfor
- x => panic!("Found unexpected value in style struct for overflow_y property: {}", x),
- }
- }
-
pub fn set_vertical_align(&mut self, v: longhands::vertical_align::computed_value::T) {
use crate::values::generics::box_::VerticalAlign;
let value = match v {
diff --git a/components/style/properties/longhands/box.mako.rs b/components/style/properties/longhands/box.mako.rs
index f0bf6b0bcdb..1e0629861e4 100644
--- a/components/style/properties/longhands/box.mako.rs
+++ b/components/style/properties/longhands/box.mako.rs
@@ -100,34 +100,30 @@ ${helpers.single_keyword("-servo-overflow-clip-box", "padding-box content-box",
)}
% endfor
-<%
- overflow_custom_consts = { "-moz-hidden-unscrollable": "CLIP" }
-%>
-
// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`.
//
// We allow it to apply to placeholders for UA sheets, which set it !important.
-${helpers.single_keyword(
+${helpers.predefined_type(
"overflow-x",
- "visible hidden scroll auto",
+ "Overflow",
+ "computed::Overflow::Visible",
animation_value_type="discrete",
- extra_gecko_values="-moz-hidden-unscrollable",
- custom_consts=overflow_custom_consts,
- gecko_constant_prefix="NS_STYLE_OVERFLOW",
flags="APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-x",
+ needs_context=False,
servo_restyle_damage = "reflow",
)}
-// FIXME(pcwalton, #2742): Implement scrolling for `scroll` and `auto`.
-//
-// We allow it to apply to placeholders for UA sheets, which set it !important.
-<%helpers:longhand name="overflow-y" animation_value_type="discrete"
- flags="APPLIES_TO_PLACEHOLDER",
- spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-y"
- servo_restyle_damage = "reflow">
- pub use super::overflow_x::{SpecifiedValue, parse, get_initial_value, computed_value};
-</%helpers:longhand>
+${helpers.predefined_type(
+ "overflow-y",
+ "Overflow",
+ "computed::Overflow::Visible",
+ animation_value_type="discrete",
+ flags="APPLIES_TO_PLACEHOLDER",
+ spec="https://drafts.csswg.org/css-overflow/#propdef-overflow-y",
+ needs_context=False,
+ servo_restyle_damage = "reflow",
+)}
<% transition_extra_prefixes = "moz:layout.css.prefixes.transitions webkit" %>
diff --git a/components/style/values/computed/box.rs b/components/style/values/computed/box.rs
index 9ba38f04015..32ac16fb574 100644
--- a/components/style/values/computed/box.rs
+++ b/components/style/values/computed/box.rs
@@ -13,7 +13,7 @@ use crate::values::specified::box_ as specified;
pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween, BreakWithin};
pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat};
-pub use crate::values::specified::box_::{Contain, Display, OverflowClipBox};
+pub use crate::values::specified::box_::{Contain, Display, Overflow, OverflowClipBox};
pub use crate::values::specified::box_::{OverscrollBehavior, ScrollSnapType};
pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange};
diff --git a/components/style/values/computed/mod.rs b/components/style/values/computed/mod.rs
index d05d42e0102..8e135b52caa 100644
--- a/components/style/values/computed/mod.rs
+++ b/components/style/values/computed/mod.rs
@@ -43,7 +43,7 @@ pub use self::border::{BorderImageRepeat, BorderImageSideWidth};
pub use self::border::{BorderImageSlice, BorderImageWidth};
pub use self::box_::{AnimationIterationCount, AnimationName, Contain};
pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float};
-pub use self::box_::{Display, TransitionProperty};
+pub use self::box_::{Display, TransitionProperty, Overflow};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
pub use self::box_::{ScrollSnapType, TouchAction, VerticalAlign, WillChange};
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
diff --git a/components/style/values/specified/box.rs b/components/style/values/specified/box.rs
index 84cbe9e879c..54030ba7139 100644
--- a/components/style/values/specified/box.rs
+++ b/components/style/values/specified/box.rs
@@ -1363,3 +1363,28 @@ pub enum BreakWithin {
Auto,
Avoid,
}
+
+/// The value for the `overflow-x` / `overflow-y` properties.
+#[allow(missing_docs)]
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Eq,
+ Hash,
+ MallocSizeOf,
+ Parse,
+ PartialEq,
+ SpecifiedValueInfo,
+ ToCss,
+ ToComputedValue,
+)]
+#[repr(u8)]
+pub enum Overflow {
+ Visible,
+ Hidden,
+ Scroll,
+ Auto,
+ #[cfg(feature = "gecko")]
+ MozHiddenUnscrollable,
+}
diff --git a/components/style/values/specified/mod.rs b/components/style/values/specified/mod.rs
index c185dce80d0..3b8278c3287 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, BorderStyle};
pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
-pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float};
+pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float, Overflow};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
pub use self::box_::{ScrollSnapType, TouchAction, TransitionProperty, VerticalAlign, WillChange};
pub use self::color::{Color, ColorPropertyValue, RGBAColor};