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
This commit is contained in:
Emilio Cobos Álvarez 2018-12-11 01:50:32 +01:00
parent 3f58e0b069
commit 901c055519
8 changed files with 46 additions and 44 deletions

View file

@ -64,5 +64,6 @@ include = [
"ScrollSnapType",
"OverflowClipBox",
"Resize",
"Overflow",
]
item_types = ["enums", "structs", "typedefs"]

View file

@ -325,6 +325,7 @@ class Longhand(object):
"NonNegativeNumber",
"Opacity",
"OutlineStyle",
"Overflow",
"OverflowClipBox",
"OverflowWrap",
"OverscrollBehavior",

View file

@ -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 {

View file

@ -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" %>

View file

@ -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};

View file

@ -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};

View file

@ -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,
}

View file

@ -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};