style: Implement flow-relative values for resize property.

Differential Revision: https://phabricator.services.mozilla.com/D2908
This commit is contained in:
Xidorn Quan 2018-08-08 23:40:06 +00:00 committed by Emilio Cobos Álvarez
parent 5299ce31aa
commit c77ecd6984
No known key found for this signature in database
GPG key ID: 056B727BB9C1027C
7 changed files with 87 additions and 9 deletions

View file

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

View file

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

View file

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

View file

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