servo: Merge #19368 - Bug 951793 - Add support for the 'overscroll-behavior' CSS property (Servo changes) (from theres-waldo:bug951793); r=emilio

Servo changes for [bug 951793](https://bugzilla.mozilla.org/show_bug.cgi?id=951793).

Source-Repo: https://github.com/servo/servo
Source-Revision: 6158a4bf91d8d38900c5fec8bb20ff219e444f61

--HG--
extra : subtree_source : https%3A//hg.mozilla.org/projects/converted-servo-linear
extra : subtree_revision : b3142a8aae8deb3d9c00a3907f30bde63b570fdd
This commit is contained in:
Botond Ballo 2017-11-24 17:02:56 -06:00
Родитель 8036ceae73
Коммит 0b68301bed
8 изменённых файлов: 109 добавлений и 39 удалений

Различия файлов скрыты, потому что одна или несколько строк слишком длинны

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

@ -3099,6 +3099,8 @@ fn static_assert() {
scroll-snap-points-x scroll-snap-points-y
scroll-snap-type-x scroll-snap-type-y scroll-snap-coordinate
perspective-origin -moz-binding will-change
overscroll-behavior-x overscroll-behavior-y
perspective-origin -moz-binding will-change
shape-outside contain touch-action""" %>
<%self:impl_trait style_struct_name="Box" skip_longhands="${skip_box_longhands}">
@ -3486,6 +3488,11 @@ fn static_assert() {
${impl_keyword('scroll_snap_type_y', 'mScrollSnapTypeY', scroll_snap_type_keyword)}
${impl_keyword('scroll_snap_type_x', 'mScrollSnapTypeX', scroll_snap_type_keyword)}
<% overscroll_behavior_keyword = Keyword("overscroll-behavior", "Auto Contain None",
gecko_enum_prefix="StyleOverscrollBehavior") %>
${impl_keyword('overscroll_behavior_x', 'mOverscrollBehaviorX', overscroll_behavior_keyword)}
${impl_keyword('overscroll_behavior_y', 'mOverscrollBehaviorY', overscroll_behavior_keyword)}
pub fn set_perspective_origin(&mut self, v: longhands::perspective_origin::computed_value::T) {
self.gecko.mPerspectiveOrigin[0].set(v.horizontal);
self.gecko.mPerspectiveOrigin[1].set(v.vertical);

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

@ -601,6 +601,19 @@ ${helpers.single_keyword("scroll-behavior",
)}
% endfor
% for axis in ["x", "y"]:
${helpers.predefined_type(
"overscroll-behavior-" + axis,
"OverscrollBehavior",
"computed::OverscrollBehavior::Auto",
products="gecko",
needs_context=False,
gecko_pref="layout.css.overscroll-behavior.enabled",
spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties",
animation_value_type="discrete"
)}
% endfor
// Compositing and Blending Level 1
// http://www.w3.org/TR/compositing-1/
${helpers.single_keyword("isolation",

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

@ -346,7 +346,7 @@ macro_rules! try_parse_one {
}
impl<'a> ToCss for LonghandsToSerialize<'a> {
// Serializes into the single keyword value if both scroll-snap-type and scroll-snap-type-y are same.
// Serializes into the single keyword value if both scroll-snap-type-x and scroll-snap-type-y are same.
// Otherwise into an empty string. This is done to match Gecko's behaviour.
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
if self.scroll_snap_type_x == self.scroll_snap_type_y {
@ -358,6 +358,36 @@ macro_rules! try_parse_one {
}
</%helpers:shorthand>
<%helpers:shorthand name="overscroll-behavior" products="gecko"
gecko_pref="layout.css.overscroll-behavior.enabled"
sub_properties="overscroll-behavior-x overscroll-behavior-y"
spec="https://wicg.github.io/overscroll-behavior/#overscroll-behavior-properties">
pub fn parse_value<'i, 't>(
_: &ParserContext,
input: &mut Parser<'i, 't>
) -> Result<Longhands, ParseError<'i>> {
use values::specified::OverscrollBehavior;
let behavior_x = OverscrollBehavior::parse(input)?;
let behavior_y = input.try(OverscrollBehavior::parse).unwrap_or(behavior_x);
Ok(expanded! {
overscroll_behavior_x: behavior_x,
overscroll_behavior_y: behavior_y,
})
}
impl<'a> ToCss for LonghandsToSerialize<'a> {
// Serializes into the single keyword value if both overscroll-behavior-x and overscroll-behavior-y are same.
// Otherwise into two values separated by a space.
fn to_css<W>(&self, dest: &mut W) -> fmt::Result where W: fmt::Write {
self.overscroll_behavior_x.to_css(dest)?;
if self.overscroll_behavior_y != self.overscroll_behavior_x {
dest.write_str(" ")?;
self.overscroll_behavior_y.to_css(dest)?;
}
Ok(())
}
}
</%helpers:shorthand>
<%helpers:shorthand name="-moz-transform" products="gecko"
sub_properties="transform"

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

@ -9,7 +9,7 @@ use values::computed::length::LengthOrPercentage;
use values::generics::box_::AnimationIterationCount as GenericAnimationIterationCount;
use values::generics::box_::VerticalAlign as GenericVerticalAlign;
pub use values::specified::box_::{AnimationName, ScrollSnapType};
pub use values::specified::box_::{AnimationName, OverscrollBehavior, ScrollSnapType};
/// A computed value for the `vertical-align` property.
pub type VerticalAlign = GenericVerticalAlign<LengthOrPercentage>;

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

@ -40,7 +40,7 @@ pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVa
pub use self::font::{FontLanguageOverride, FontVariantSettings, FontVariantEastAsian};
pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings};
pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XTextZoom, XLang};
pub use self::box_::{AnimationIterationCount, AnimationName, ScrollSnapType, VerticalAlign};
pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior, ScrollSnapType, VerticalAlign};
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
pub use self::flex::FlexBasis;

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

@ -117,3 +117,10 @@ define_css_keyword_enum! { ScrollSnapType:
"proximity" => Proximity,
}
add_impls_for_keyword_enum!(ScrollSnapType);
define_css_keyword_enum! { OverscrollBehavior:
"auto" => Auto,
"contain" => Contain,
"none" => None,
}
add_impls_for_keyword_enum!(OverscrollBehavior);

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

@ -34,7 +34,7 @@ pub use self::font::{FontSize, FontSizeAdjust, FontSynthesis, FontWeight, FontVa
pub use self::font::{FontLanguageOverride, FontVariantSettings, FontVariantEastAsian};
pub use self::font::{FontVariantLigatures, FontVariantNumeric, FontFeatureSettings};
pub use self::font::{MozScriptLevel, MozScriptMinSize, MozScriptSizeMultiplier, XTextZoom, XLang};
pub use self::box_::{AnimationIterationCount, AnimationName, ScrollSnapType, VerticalAlign};
pub use self::box_::{AnimationIterationCount, AnimationName, OverscrollBehavior, ScrollSnapType, VerticalAlign};
pub use self::color::{Color, ColorPropertyValue, RGBAColor};
pub use self::effects::{BoxShadow, Filter, SimpleShadow};
pub use self::flex::FlexBasis;