Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
style: Implement flow-relative values for resize property.
  • Loading branch information
upsuper authored and emilio committed Aug 18, 2018
1 parent 5299ce3 commit c77ecd6
Show file tree
Hide file tree
Showing 7 changed files with 87 additions and 9 deletions.
1 change: 1 addition & 0 deletions components/style/properties/data.py
Expand Up @@ -325,6 +325,7 @@ def specified_is_copy(self):
"OverflowClipBox",
"OverscrollBehavior",
"Percentage",
"Resize",
"SVGOpacity",
"SVGPaintOrder",
"ScrollSnapType",
Expand Down
3 changes: 3 additions & 0 deletions components/style/properties/gecko.mako.rs
Expand Up @@ -3106,6 +3106,9 @@ fn static_assert() {
) %>
${impl_keyword('clear', 'mBreakType', clear_keyword)}

<% resize_keyword = Keyword("resize", "None Both Horizontal Vertical") %>
${impl_keyword('resize', 'mResize', resize_keyword)}

<% overflow_x = data.longhands_by_name["overflow-x"] %>
pub fn set_overflow_y(&mut self, v: longhands::overflow_y::computed_value::T) {
use properties::longhands::overflow_x::computed_value::T as BaseType;
Expand Down
18 changes: 11 additions & 7 deletions components/style/properties/longhands/box.mako.rs
Expand Up @@ -422,17 +422,21 @@ ${helpers.single_keyword("page-break-inside",

// CSS Basic User Interface Module Level 3
// http://dev.w3.org/csswg/css-ui
// FIXME support logical values `block` and `inline` (https://drafts.csswg.org/css-logical-props/#resize)
//
// This is APPLIES_TO_PLACEHOLDER so we can override, in the UA sheet, the
// 'resize' property we'd inherit from textarea otherwise. Basically, just
// makes the UA rules easier to write.
${helpers.single_keyword("resize",
"none both horizontal vertical",
products="gecko",
spec="https://drafts.csswg.org/css-ui/#propdef-resize",
flags="APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")}
${helpers.predefined_type(
"resize",
"Resize",
"computed::Resize::None",
products="gecko",
animation_value_type="discrete",
needs_context=False,
gecko_ffi_name="mResize",
flags="APPLIES_TO_PLACEHOLDER",
spec="https://drafts.csswg.org/css-ui/#propdef-resize",
)}

${helpers.predefined_type(
"perspective",
Expand Down
55 changes: 55 additions & 0 deletions components/style/values/computed/box.rs
Expand Up @@ -9,6 +9,7 @@ use values::computed::length::{LengthOrPercentage, NonNegativeLength};
use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
use values::generics::box_::Perspective as GenericPerspective;
use values::generics::box_::VerticalAlign as GenericVerticalAlign;
use values::specified::box_ as specified;

pub use values::specified::box_::{AnimationName, Appearance, Contain, Display, OverflowClipBox};
pub use values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat};
Expand Down Expand Up @@ -139,3 +140,57 @@ impl ToComputedValue for SpecifiedClear {
}
}
}

/// A computed value for the `resize` property.
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq, ToCss)]
pub enum Resize {
None,
Both,
Horizontal,
Vertical,
}

impl ToComputedValue for specified::Resize {
type ComputedValue = Resize;

#[inline]
fn to_computed_value(&self, context: &Context) -> Resize {
let is_vertical = context.style().writing_mode.is_vertical();
match self {
specified::Resize::Inline => {
context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode);
if is_vertical {
Resize::Vertical
} else {
Resize::Horizontal
}
}
specified::Resize::Block => {
context.rule_cache_conditions.borrow_mut()
.set_writing_mode_dependency(context.builder.writing_mode);
if is_vertical {
Resize::Horizontal
} else {
Resize::Vertical
}
}
specified::Resize::None => Resize::None,
specified::Resize::Both => Resize::Both,
specified::Resize::Horizontal => Resize::Horizontal,
specified::Resize::Vertical => Resize::Vertical,
}
}

#[inline]
fn from_computed_value(computed: &Resize) -> specified::Resize {
match computed {
Resize::None => specified::Resize::None,
Resize::Both => specified::Resize::Both,
Resize::Horizontal => specified::Resize::Horizontal,
Resize::Vertical => specified::Resize::Vertical,
}
}
}
2 changes: 1 addition & 1 deletion components/style/values/computed/mod.rs
Expand Up @@ -44,7 +44,7 @@ pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumer
pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display, TransitionProperty};
pub use self::box_::{Appearance, Clear, Float};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize};
pub use self::box_::{ScrollSnapType, TouchAction, VerticalAlign, WillChange};
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
pub use self::column::ColumnCount;
Expand Down
15 changes: 15 additions & 0 deletions components/style/values/specified/box.rs
Expand Up @@ -884,6 +884,21 @@ pub enum Clear {
InlineEnd
}

/// https://drafts.csswg.org/css-ui/#propdef-resize
#[allow(missing_docs)]
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
#[derive(Clone, Copy, Debug, Eq, Hash, MallocSizeOf, Parse, PartialEq,
SpecifiedValueInfo, ToCss)]
pub enum Resize {
None,
Both,
Horizontal,
Vertical,
// https://drafts.csswg.org/css-logical-1/#resize
Inline,
Block,
}

/// The value for the `appearance` property.
///
/// https://developer.mozilla.org/en-US/docs/Web/CSS/-moz-appearance
Expand Down
2 changes: 1 addition & 1 deletion components/style/values/specified/mod.rs
Expand Up @@ -39,7 +39,7 @@ pub use self::font::{FontFeatureSettings, FontVariantLigatures, FontVariantNumer
pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XLang, XTextZoom};
pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display};
pub use self::box_::{Appearance, Clear, Float};
pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective};
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::counters::{Content, ContentItem, CounterIncrement, CounterReset};
Expand Down

0 comments on commit c77ecd6

Please sign in to comment.