Bug 1464786 - Implement flow-relative values for resize property. r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D2908

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Xidorn Quan 2018-08-08 23:40:06 +00:00
Родитель 48b3246876
Коммит 34de342864
10 изменённых файлов: 91 добавлений и 10 удалений

Просмотреть файл

@ -7868,10 +7868,12 @@ exports.CSS_PROPERTIES = {
],
"supports": [],
"values": [
"block",
"both",
"horizontal",
"inherit",
"initial",
"inline",
"none",
"unset",
"vertical"

Просмотреть файл

@ -95,6 +95,7 @@ SERIALIZED_PREDEFINED_TYPES = [
"NonNegativeLengthOrPercentage",
"ListStyleType",
"Opacity",
"Resize",
"url::ImageUrlOrNone",
]

Просмотреть файл

@ -2401,7 +2401,7 @@ var gCSSProperties = {
// No applies_to_placeholder because we have a !important rule in forms.css.
prerequisites: { "display": "block", "overflow": "auto" },
initial_values: [ "none" ],
other_values: [ "both", "horizontal", "vertical" ],
other_values: [ "both", "horizontal", "vertical", "inline", "block" ],
invalid_values: []
},
"-moz-stack-sizing": {

Просмотреть файл

@ -325,6 +325,7 @@ class Longhand(object):
"OverflowClipBox",
"OverscrollBehavior",
"Percentage",
"Resize",
"SVGOpacity",
"SVGPaintOrder",
"ScrollSnapType",

Просмотреть файл

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

Просмотреть файл

@ -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",
${helpers.predefined_type(
"resize",
"Resize",
"computed::Resize::None",
products="gecko",
spec="https://drafts.csswg.org/css-ui/#propdef-resize",
animation_value_type="discrete",
needs_context=False,
gecko_ffi_name="mResize",
flags="APPLIES_TO_PLACEHOLDER",
animation_value_type="discrete")}
spec="https://drafts.csswg.org/css-ui/#propdef-resize",
)}
${helpers.predefined_type(
"perspective",

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

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