From 19102cb3b9d37001f567b90d0f68d6c4c38772f0 Mon Sep 17 00:00:00 2001 From: Hiroyuki Ikezoe Date: Thu, 11 Apr 2019 06:19:13 +0000 Subject: [PATCH] Bug 1312163 - Rename ScrollSnapType to ScrollSnapStrictness. r=emilio The scroll snap strictness is defined in the new spec [1], and the structure is the exactly same as the old scroll snap type structure. [1] https://drafts.csswg.org/css-scroll-snap-1/#snap-strictness Differential Revision: https://phabricator.services.mozilla.com/D21621 --HG-- extra : moz-landing-system : lando --- gfx/layers/FrameMetrics.h | 12 ++++++------ gfx/layers/apz/test/gtest/TestSnapping.cpp | 4 ++-- gfx/layers/ipc/LayersMessageUtils.h | 7 ++++--- layout/base/ScrollStyles.h | 8 ++++---- layout/base/nsPresContext.cpp | 4 ++-- layout/generic/ScrollSnap.cpp | 8 ++++---- layout/generic/nsGfxScrollFrame.cpp | 9 +++++---- layout/style/ServoBindings.toml | 2 +- layout/style/nsStyleStruct.cpp | 4 ++-- layout/style/nsStyleStruct.h | 4 ++-- servo/components/style/properties/data.py | 2 +- .../style/properties/longhands/box.mako.rs | 4 ++-- servo/components/style/values/computed/box.rs | 2 +- servo/components/style/values/computed/mod.rs | 2 +- servo/components/style/values/specified/box.rs | 3 ++- servo/components/style/values/specified/mod.rs | 2 +- servo/ports/geckolib/cbindgen.toml | 2 +- 17 files changed, 41 insertions(+), 38 deletions(-) diff --git a/gfx/layers/FrameMetrics.h b/gfx/layers/FrameMetrics.h index 60d8a2c5c92e..ce3ed6159902 100644 --- a/gfx/layers/FrameMetrics.h +++ b/gfx/layers/FrameMetrics.h @@ -723,15 +723,15 @@ struct ScrollSnapInfo { } bool HasScrollSnapping() const { - return mScrollSnapTypeY != mozilla::StyleScrollSnapType::None || - mScrollSnapTypeX != mozilla::StyleScrollSnapType::None; + return mScrollSnapTypeY != mozilla::StyleScrollSnapStrictness::None || + mScrollSnapTypeX != mozilla::StyleScrollSnapStrictness::None; } // The scroll frame's scroll-snap-type. - mozilla::StyleScrollSnapType mScrollSnapTypeX = - mozilla::StyleScrollSnapType::None; - mozilla::StyleScrollSnapType mScrollSnapTypeY = - mozilla::StyleScrollSnapType::None; + mozilla::StyleScrollSnapStrictness mScrollSnapTypeX = + mozilla::StyleScrollSnapStrictness::None; + mozilla::StyleScrollSnapStrictness mScrollSnapTypeY = + mozilla::StyleScrollSnapStrictness::None; // The intervals derived from the scroll frame's scroll-snap-points. Maybe mScrollSnapIntervalX; diff --git a/gfx/layers/apz/test/gtest/TestSnapping.cpp b/gfx/layers/apz/test/gtest/TestSnapping.cpp index 47f52fb6b10a..cf2c3853c648 100644 --- a/gfx/layers/apz/test/gtest/TestSnapping.cpp +++ b/gfx/layers/apz/test/gtest/TestSnapping.cpp @@ -26,7 +26,7 @@ TEST_F(APZCSnappingTester, Bug1265510) { SetScrollHandoff(layers[1], root); ScrollSnapInfo snap; - snap.mScrollSnapTypeY = StyleScrollSnapType::Mandatory; + snap.mScrollSnapTypeY = StyleScrollSnapStrictness::Mandatory; snap.mScrollSnapIntervalY = Some(100 * AppUnitsPerCSSPixel()); ScrollMetadata metadata = root->GetScrollMetadata(0); @@ -96,7 +96,7 @@ TEST_F(APZCSnappingTester, Snap_After_Pinch) { // Set up some basic scroll snapping ScrollSnapInfo snap; - snap.mScrollSnapTypeY = StyleScrollSnapType::Mandatory; + snap.mScrollSnapTypeY = StyleScrollSnapStrictness::Mandatory; snap.mScrollSnapIntervalY = Some(100 * AppUnitsPerCSSPixel()); // Save the scroll snap info on the root APZC. diff --git a/gfx/layers/ipc/LayersMessageUtils.h b/gfx/layers/ipc/LayersMessageUtils.h index 2a5e44596e0c..8c7ae9ce2af6 100644 --- a/gfx/layers/ipc/LayersMessageUtils.h +++ b/gfx/layers/ipc/LayersMessageUtils.h @@ -87,10 +87,11 @@ struct ParamTraits mozilla::layers::kHighestScaleMode> {}; template <> -struct ParamTraits +struct ParamTraits : public ContiguousEnumSerializerInclusive< - mozilla::StyleScrollSnapType, mozilla::StyleScrollSnapType::None, - mozilla::StyleScrollSnapType::Proximity> {}; + mozilla::StyleScrollSnapStrictness, + mozilla::StyleScrollSnapStrictness::None, + mozilla::StyleScrollSnapStrictness::Proximity> {}; template <> struct ParamTraits diff --git a/layout/base/ScrollStyles.h b/layout/base/ScrollStyles.h index 65ef37c8d3dd..b7daefbfb574 100644 --- a/layout/base/ScrollStyles.h +++ b/layout/base/ScrollStyles.h @@ -26,8 +26,8 @@ struct ScrollStyles { uint8_t mScrollBehavior; StyleOverscrollBehavior mOverscrollBehaviorX; StyleOverscrollBehavior mOverscrollBehaviorY; - StyleScrollSnapType mScrollSnapTypeX; - StyleScrollSnapType mScrollSnapTypeY; + StyleScrollSnapStrictness mScrollSnapTypeX; + StyleScrollSnapStrictness mScrollSnapTypeY; nsStyleCoord mScrollSnapPointsX; nsStyleCoord mScrollSnapPointsY; LengthPercentage mScrollSnapDestinationX; @@ -39,8 +39,8 @@ struct ScrollStyles { mScrollBehavior(NS_STYLE_SCROLL_BEHAVIOR_AUTO), mOverscrollBehaviorX(StyleOverscrollBehavior::Auto), mOverscrollBehaviorY(StyleOverscrollBehavior::Auto), - mScrollSnapTypeX(StyleScrollSnapType::None), - mScrollSnapTypeY(StyleScrollSnapType::None), + mScrollSnapTypeX(StyleScrollSnapStrictness::None), + mScrollSnapTypeY(StyleScrollSnapStrictness::None), mScrollSnapPointsX(nsStyleCoord(eStyleUnit_None)), mScrollSnapPointsY(nsStyleCoord(eStyleUnit_None)), mScrollSnapDestinationX(LengthPercentage::Zero()), diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index 54786a9d3b7d..461a4e584f78 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1021,8 +1021,8 @@ static bool CheckOverflow(const nsStyleDisplay* aDisplay, aDisplay->mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_AUTO && aDisplay->mOverscrollBehaviorX == StyleOverscrollBehavior::Auto && aDisplay->mOverscrollBehaviorY == StyleOverscrollBehavior::Auto && - aDisplay->mScrollSnapTypeX == StyleScrollSnapType::None && - aDisplay->mScrollSnapTypeY == StyleScrollSnapType::None && + aDisplay->mScrollSnapTypeX == StyleScrollSnapStrictness::None && + aDisplay->mScrollSnapTypeY == StyleScrollSnapStrictness::None && aDisplay->mScrollSnapPointsX == nsStyleCoord(eStyleUnit_None) && aDisplay->mScrollSnapPointsY == nsStyleCoord(eStyleUnit_None) && aDisplay->mScrollSnapDestination.horizontal == LengthPercentage::Zero() && diff --git a/layout/generic/ScrollSnap.cpp b/layout/generic/ScrollSnap.cpp index f8fc08fdb959..0c34d1d33fb9 100644 --- a/layout/generic/ScrollSnap.cpp +++ b/layout/generic/ScrollSnap.cpp @@ -236,8 +236,8 @@ Maybe ScrollSnapUtils::GetSnapPointForDestination( const ScrollSnapInfo& aSnapInfo, nsIScrollableFrame::ScrollUnit aUnit, const nsRect& aScrollRange, const nsPoint& aStartPos, const nsPoint& aDestination) { - if (aSnapInfo.mScrollSnapTypeY == StyleScrollSnapType::None && - aSnapInfo.mScrollSnapTypeX == StyleScrollSnapType::None) { + if (aSnapInfo.mScrollSnapTypeY == StyleScrollSnapStrictness::None && + aSnapInfo.mScrollSnapTypeX == StyleScrollSnapStrictness::None) { return Nothing(); } @@ -260,13 +260,13 @@ Maybe ScrollSnapUtils::GetSnapPointForDestination( nsPoint finalPos = calcSnapPoints.GetBestEdge(); nscoord proximityThreshold = gfxPrefs::ScrollSnapProximityThreshold(); proximityThreshold = nsPresContext::CSSPixelsToAppUnits(proximityThreshold); - if (aSnapInfo.mScrollSnapTypeY == StyleScrollSnapType::Proximity && + if (aSnapInfo.mScrollSnapTypeY == StyleScrollSnapStrictness::Proximity && std::abs(aDestination.y - finalPos.y) > proximityThreshold) { finalPos.y = aDestination.y; } else { snapped = true; } - if (aSnapInfo.mScrollSnapTypeX == StyleScrollSnapType::Proximity && + if (aSnapInfo.mScrollSnapTypeX == StyleScrollSnapStrictness::Proximity && std::abs(aDestination.x - finalPos.x) > proximityThreshold) { finalPos.x = aDestination.x; } else { diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index 46fe76369830..1f818cbe5e45 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -4211,8 +4211,9 @@ void ScrollFrameHelper::ScrollBy(nsIntPoint aDelta, if (aSnap == nsIScrollableFrame::ENABLE_SNAP) { ScrollStyles styles = GetScrollStylesFromFrame(); - if (styles.mScrollSnapTypeY != StyleScrollSnapType::None || - styles.mScrollSnapTypeX != StyleScrollSnapType::None) { + + if (styles.mScrollSnapTypeY != StyleScrollSnapStrictness::None || + styles.mScrollSnapTypeX != StyleScrollSnapStrictness::None) { nscoord appUnitsPerDevPixel = mOuter->PresContext()->AppUnitsPerDevPixel(); deltaMultiplier = nsSize(appUnitsPerDevPixel, appUnitsPerDevPixel); @@ -6535,8 +6536,8 @@ static layers::ScrollSnapInfo ComputeScrollSnapInfo( ScrollStyles styles = aScrollFrame.GetScrollStylesFromFrame(); - if (styles.mScrollSnapTypeY == StyleScrollSnapType::None && - styles.mScrollSnapTypeX == StyleScrollSnapType::None) { + if (styles.mScrollSnapTypeY == StyleScrollSnapStrictness::None && + styles.mScrollSnapTypeX == StyleScrollSnapStrictness::None) { // We won't be snapping, short-circuit the computation. return result; } diff --git a/layout/style/ServoBindings.toml b/layout/style/ServoBindings.toml index 2a422375536c..f6ea48f7c053 100644 --- a/layout/style/ServoBindings.toml +++ b/layout/style/ServoBindings.toml @@ -413,7 +413,7 @@ cbindgen-types = [ { gecko = "StyleBorderStyle", servo = "values::computed::BorderStyle" }, { gecko = "StyleOutlineStyle", servo = "values::computed::OutlineStyle" }, { gecko = "StyleScrollSnapAlign", servo = "values::computed::ScrollSnapAlign" }, - { gecko = "StyleScrollSnapType", servo = "values::computed::ScrollSnapType" }, + { gecko = "StyleScrollSnapStrictness", servo = "values::computed::ScrollSnapStrictness" }, { gecko = "StyleResize", servo = "values::computed::Resize" }, { gecko = "StyleOverflowClipBox", servo = "values::computed::OverflowClipBox" }, { gecko = "StyleFloat", servo = "values::computed::Float" }, diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index 2bda4ff05dcc..167c1ee94052 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -2939,8 +2939,8 @@ nsStyleDisplay::nsStyleDisplay(const Document& aDocument) mOverscrollBehaviorX(StyleOverscrollBehavior::Auto), mOverscrollBehaviorY(StyleOverscrollBehavior::Auto), mOverflowAnchor(StyleOverflowAnchor::Auto), - mScrollSnapTypeX(StyleScrollSnapType::None), - mScrollSnapTypeY(StyleScrollSnapType::None), + mScrollSnapTypeX(StyleScrollSnapStrictness::None), + mScrollSnapTypeY(StyleScrollSnapStrictness::None), mScrollSnapPointsX(eStyleUnit_None), mScrollSnapPointsY(eStyleUnit_None), mScrollSnapDestination( diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index b601d0997f83..cd1b71a12c44 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -1895,8 +1895,8 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay { mozilla::StyleOverscrollBehavior mOverscrollBehaviorY; mozilla::StyleOverflowAnchor mOverflowAnchor; mozilla::StyleScrollSnapAlign mScrollSnapAlign; - mozilla::StyleScrollSnapType mScrollSnapTypeX; - mozilla::StyleScrollSnapType mScrollSnapTypeY; + mozilla::StyleScrollSnapStrictness mScrollSnapTypeX; + mozilla::StyleScrollSnapStrictness mScrollSnapTypeY; nsStyleCoord mScrollSnapPointsX; nsStyleCoord mScrollSnapPointsY; mozilla::Position mScrollSnapDestination; diff --git a/servo/components/style/properties/data.py b/servo/components/style/properties/data.py index 52cdcf15d22b..b6d42d8ecd5b 100644 --- a/servo/components/style/properties/data.py +++ b/servo/components/style/properties/data.py @@ -341,7 +341,7 @@ class Longhand(object): "SVGOpacity", "SVGPaintOrder", "ScrollSnapAlign", - "ScrollSnapType", + "ScrollSnapStrictness", "TextAlign", "TextDecorationLine", "TextEmphasisPosition", diff --git a/servo/components/style/properties/longhands/box.mako.rs b/servo/components/style/properties/longhands/box.mako.rs index dcfcb343040d..9d18753f53fb 100644 --- a/servo/components/style/properties/longhands/box.mako.rs +++ b/servo/components/style/properties/longhands/box.mako.rs @@ -430,8 +430,8 @@ ${helpers.predefined_type( % for axis in ["x", "y"]: ${helpers.predefined_type( "scroll-snap-type-" + axis, - "ScrollSnapType", - "computed::ScrollSnapType::None", + "ScrollSnapStrictness", + "computed::ScrollSnapStrictness::None", products="gecko", needs_context=False, gecko_pref="layout.css.scroll-snap.enabled", diff --git a/servo/components/style/values/computed/box.rs b/servo/components/style/values/computed/box.rs index 1fb92bec13ab..fc7df203d54d 100644 --- a/servo/components/style/values/computed/box.rs +++ b/servo/components/style/values/computed/box.rs @@ -15,7 +15,7 @@ pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween pub use crate::values::specified::box_::{Clear as SpecifiedClear, Float as SpecifiedFloat}; pub use crate::values::specified::box_::{Contain, Display, Overflow}; pub use crate::values::specified::box_::{OverflowAnchor, OverflowClipBox}; -pub use crate::values::specified::box_::{OverscrollBehavior, ScrollSnapAlign, ScrollSnapType}; +pub use crate::values::specified::box_::{OverscrollBehavior, ScrollSnapAlign, ScrollSnapStrictness}; pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange}; /// A computed value for the `vertical-align` property. diff --git a/servo/components/style/values/computed/mod.rs b/servo/components/style/values/computed/mod.rs index f01661cbc9cc..74df937904d3 100644 --- a/servo/components/style/values/computed/mod.rs +++ b/servo/components/style/values/computed/mod.rs @@ -42,7 +42,7 @@ pub use self::box_::{AnimationIterationCount, AnimationName, Contain}; pub use self::box_::{Appearance, BreakBetween, BreakWithin, Clear, Float}; pub use self::box_::{Display, Overflow, OverflowAnchor, TransitionProperty}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize}; -pub use self::box_::{ScrollSnapAlign, ScrollSnapType, TouchAction, VerticalAlign, WillChange}; +pub use self::box_::{ScrollSnapAlign, ScrollSnapStrictness, TouchAction, VerticalAlign, WillChange}; pub use self::color::{Color, ColorOrAuto, ColorPropertyValue}; pub use self::column::ColumnCount; pub use self::counters::{Content, ContentItem, CounterIncrement, CounterSetOrReset}; diff --git a/servo/components/style/values/specified/box.rs b/servo/components/style/values/specified/box.rs index 86bb824748c8..29e2272f6b11 100644 --- a/servo/components/style/values/specified/box.rs +++ b/servo/components/style/values/specified/box.rs @@ -379,6 +379,7 @@ impl Parse for AnimationName { } } +/// https://drafts.csswg.org/css-scroll-snap-1/#snap-strictness #[allow(missing_docs)] #[cfg_attr(feature = "servo", derive(Deserialize, Serialize))] #[derive( @@ -396,7 +397,7 @@ impl Parse for AnimationName { ToShmem, )] #[repr(u8)] -pub enum ScrollSnapType { +pub enum ScrollSnapStrictness { None, Mandatory, Proximity, diff --git a/servo/components/style/values/specified/mod.rs b/servo/components/style/values/specified/mod.rs index ea69fd5c5779..09675d01fe25 100644 --- a/servo/components/style/values/specified/mod.rs +++ b/servo/components/style/values/specified/mod.rs @@ -40,7 +40,7 @@ pub use self::box_::{AnimationIterationCount, AnimationName, Contain, Display}; pub use self::box_::{Appearance, BreakBetween, BreakWithin}; pub use self::box_::{Clear, Float, Overflow, OverflowAnchor}; pub use self::box_::{OverflowClipBox, OverscrollBehavior, Perspective, Resize}; -pub use self::box_::{ScrollSnapAlign, ScrollSnapType}; +pub use self::box_::{ScrollSnapAlign, ScrollSnapStrictness}; pub use self::box_::{TouchAction, TransitionProperty, VerticalAlign, WillChange}; pub use self::color::{Color, ColorOrAuto, ColorPropertyValue}; pub use self::column::ColumnCount; diff --git a/servo/ports/geckolib/cbindgen.toml b/servo/ports/geckolib/cbindgen.toml index a022a1e8a1bc..cd1fa099ad23 100644 --- a/servo/ports/geckolib/cbindgen.toml +++ b/servo/ports/geckolib/cbindgen.toml @@ -71,7 +71,7 @@ include = [ "Float", "OverscrollBehavior", "ScrollSnapAlign", - "ScrollSnapType", + "ScrollSnapStrictness", "OverflowAnchor", "OverflowClipBox", "Resize",