зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1312163 - Switch to the new scroll-snap-type syntax for the old scroll snap implementation and drop the scroll-snap-type-{x,y} longhands. r=emilio
Now scroll-snap-type is a longhand property. Depends on D21621 Differential Revision: https://phabricator.services.mozilla.com/D21622 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
19102cb3b9
Коммит
eab764a7ae
|
@ -133,8 +133,7 @@ exports.ANIMATION_TYPE_FOR_LONGHANDS = [
|
|||
"scroll-snap-destination",
|
||||
"scroll-snap-points-x",
|
||||
"scroll-snap-points-y",
|
||||
"scroll-snap-type-x",
|
||||
"scroll-snap-type-y",
|
||||
"scroll-snap-type",
|
||||
"shape-rendering",
|
||||
"-moz-stack-sizing",
|
||||
"scrollbar-width",
|
||||
|
|
|
@ -3081,8 +3081,7 @@ exports.CSS_PROPERTIES = {
|
|||
"offset-path",
|
||||
"scroll-behavior",
|
||||
"scroll-snap-align",
|
||||
"scroll-snap-type-x",
|
||||
"scroll-snap-type-y",
|
||||
"scroll-snap-type",
|
||||
"overscroll-behavior-x",
|
||||
"overscroll-behavior-y",
|
||||
"isolation",
|
||||
|
@ -9065,50 +9064,21 @@ exports.CSS_PROPERTIES = {
|
|||
"scroll-snap-type": {
|
||||
"isInherited": false,
|
||||
"subproperties": [
|
||||
"scroll-snap-type-x",
|
||||
"scroll-snap-type-y"
|
||||
"scroll-snap-type"
|
||||
],
|
||||
"supports": [],
|
||||
"values": [
|
||||
"block",
|
||||
"both",
|
||||
"inherit",
|
||||
"initial",
|
||||
"inline",
|
||||
"mandatory",
|
||||
"none",
|
||||
"proximity",
|
||||
"revert",
|
||||
"unset"
|
||||
]
|
||||
},
|
||||
"scroll-snap-type-x": {
|
||||
"isInherited": false,
|
||||
"subproperties": [
|
||||
"scroll-snap-type-x"
|
||||
],
|
||||
"supports": [],
|
||||
"values": [
|
||||
"inherit",
|
||||
"initial",
|
||||
"mandatory",
|
||||
"none",
|
||||
"proximity",
|
||||
"revert",
|
||||
"unset"
|
||||
]
|
||||
},
|
||||
"scroll-snap-type-y": {
|
||||
"isInherited": false,
|
||||
"subproperties": [
|
||||
"scroll-snap-type-y"
|
||||
],
|
||||
"supports": [],
|
||||
"values": [
|
||||
"inherit",
|
||||
"initial",
|
||||
"mandatory",
|
||||
"none",
|
||||
"proximity",
|
||||
"revert",
|
||||
"unset"
|
||||
"unset",
|
||||
"x",
|
||||
"y"
|
||||
]
|
||||
},
|
||||
"scrollbar-color": {
|
||||
|
@ -10274,6 +10244,10 @@ exports.PREFERENCES = [
|
|||
"scroll-snap-align",
|
||||
"layout.css.scroll-snap-v1.enabled"
|
||||
],
|
||||
[
|
||||
"scroll-snap-type",
|
||||
"layout.css.scroll-snap.enabled"
|
||||
],
|
||||
[
|
||||
"scrollbar-width",
|
||||
"layout.css.scrollbar-width.enabled"
|
||||
|
@ -10306,14 +10280,6 @@ exports.PREFERENCES = [
|
|||
"overscroll-behavior-y",
|
||||
"layout.css.overscroll-behavior.enabled"
|
||||
],
|
||||
[
|
||||
"scroll-snap-type-x",
|
||||
"layout.css.scroll-snap.enabled"
|
||||
],
|
||||
[
|
||||
"scroll-snap-type-y",
|
||||
"layout.css.scroll-snap.enabled"
|
||||
],
|
||||
[
|
||||
"font-variation-settings",
|
||||
"layout.css.font-variations.enabled"
|
||||
|
@ -10438,10 +10404,6 @@ exports.PREFERENCES = [
|
|||
"overflow-clip-box",
|
||||
"layout.css.overflow-clip-box.enabled"
|
||||
],
|
||||
[
|
||||
"scroll-snap-type",
|
||||
"layout.css.scroll-snap.enabled"
|
||||
],
|
||||
[
|
||||
"overscroll-behavior",
|
||||
"layout.css.overscroll-behavior.enabled"
|
||||
|
|
|
@ -9,31 +9,69 @@
|
|||
|
||||
namespace mozilla {
|
||||
|
||||
ScrollStyles::ScrollStyles(StyleOverflow aH, StyleOverflow aV,
|
||||
const nsStyleDisplay* aDisplay)
|
||||
void ScrollStyles::InitializeScrollSnapType(WritingMode aWritingMode,
|
||||
const nsStyleDisplay* aDisplay) {
|
||||
mScrollSnapTypeX = StyleScrollSnapStrictness::None;
|
||||
mScrollSnapTypeY = StyleScrollSnapStrictness::None;
|
||||
|
||||
if (aDisplay->mScrollSnapType.strictness == StyleScrollSnapStrictness::None) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (aDisplay->mScrollSnapType.axis) {
|
||||
case StyleScrollSnapAxis::X:
|
||||
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
|
||||
break;
|
||||
case StyleScrollSnapAxis::Y:
|
||||
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
|
||||
break;
|
||||
case StyleScrollSnapAxis::Block:
|
||||
if (aWritingMode.IsVertical()) {
|
||||
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
|
||||
} else {
|
||||
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
|
||||
}
|
||||
break;
|
||||
case StyleScrollSnapAxis::Inline:
|
||||
if (aWritingMode.IsVertical()) {
|
||||
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
|
||||
} else {
|
||||
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
|
||||
}
|
||||
break;
|
||||
case StyleScrollSnapAxis::Both:
|
||||
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
|
||||
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ScrollStyles::ScrollStyles(WritingMode aWritingMode, StyleOverflow aH,
|
||||
StyleOverflow aV, const nsStyleDisplay* aDisplay)
|
||||
: mHorizontal(aH),
|
||||
mVertical(aV),
|
||||
mScrollBehavior(aDisplay->mScrollBehavior),
|
||||
mOverscrollBehaviorX(aDisplay->mOverscrollBehaviorX),
|
||||
mOverscrollBehaviorY(aDisplay->mOverscrollBehaviorY),
|
||||
mScrollSnapTypeX(aDisplay->mScrollSnapTypeX),
|
||||
mScrollSnapTypeY(aDisplay->mScrollSnapTypeY),
|
||||
mScrollSnapPointsX(aDisplay->mScrollSnapPointsX),
|
||||
mScrollSnapPointsY(aDisplay->mScrollSnapPointsY),
|
||||
mScrollSnapDestinationX(aDisplay->mScrollSnapDestination.horizontal),
|
||||
mScrollSnapDestinationY(aDisplay->mScrollSnapDestination.vertical) {}
|
||||
mScrollSnapDestinationY(aDisplay->mScrollSnapDestination.vertical) {
|
||||
InitializeScrollSnapType(aWritingMode, aDisplay);
|
||||
}
|
||||
|
||||
ScrollStyles::ScrollStyles(const nsStyleDisplay* aDisplay)
|
||||
ScrollStyles::ScrollStyles(WritingMode aWritingMode,
|
||||
const nsStyleDisplay* aDisplay)
|
||||
: mHorizontal(aDisplay->mOverflowX),
|
||||
mVertical(aDisplay->mOverflowY),
|
||||
mScrollBehavior(aDisplay->mScrollBehavior),
|
||||
mOverscrollBehaviorX(aDisplay->mOverscrollBehaviorX),
|
||||
mOverscrollBehaviorY(aDisplay->mOverscrollBehaviorY),
|
||||
mScrollSnapTypeX(aDisplay->mScrollSnapTypeX),
|
||||
mScrollSnapTypeY(aDisplay->mScrollSnapTypeY),
|
||||
mScrollSnapPointsX(aDisplay->mScrollSnapPointsX),
|
||||
mScrollSnapPointsY(aDisplay->mScrollSnapPointsY),
|
||||
mScrollSnapDestinationX(aDisplay->mScrollSnapDestination.horizontal),
|
||||
mScrollSnapDestinationY(aDisplay->mScrollSnapDestination.vertical) {}
|
||||
mScrollSnapDestinationY(aDisplay->mScrollSnapDestination.vertical) {
|
||||
InitializeScrollSnapType(aWritingMode, aDisplay);
|
||||
}
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -46,8 +46,11 @@ struct ScrollStyles {
|
|||
mScrollSnapDestinationX(LengthPercentage::Zero()),
|
||||
mScrollSnapDestinationY(LengthPercentage::Zero()) {}
|
||||
|
||||
explicit ScrollStyles(const nsStyleDisplay* aDisplay);
|
||||
ScrollStyles(StyleOverflow aH, StyleOverflow aV, const nsStyleDisplay*);
|
||||
ScrollStyles(WritingMode aWritingMode, const nsStyleDisplay* aDisplay);
|
||||
ScrollStyles(WritingMode aWritingMode, StyleOverflow aH, StyleOverflow aV,
|
||||
const nsStyleDisplay* aDisplay);
|
||||
void InitializeScrollSnapType(WritingMode aWritingMode,
|
||||
const nsStyleDisplay* aDisplay);
|
||||
bool operator==(const ScrollStyles& aStyles) const {
|
||||
return aStyles.mHorizontal == mHorizontal &&
|
||||
aStyles.mVertical == mVertical &&
|
||||
|
|
|
@ -1015,26 +1015,27 @@ gfxSize nsPresContext::ScreenSizeInchesForFontInflation(bool* aChanged) {
|
|||
return deviceSizeInches;
|
||||
}
|
||||
|
||||
static bool CheckOverflow(const nsStyleDisplay* aDisplay,
|
||||
static bool CheckOverflow(ComputedStyle* aComputedStyle,
|
||||
ScrollStyles* aStyles) {
|
||||
if (aDisplay->mOverflowX == StyleOverflow::Visible &&
|
||||
aDisplay->mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_AUTO &&
|
||||
aDisplay->mOverscrollBehaviorX == StyleOverscrollBehavior::Auto &&
|
||||
aDisplay->mOverscrollBehaviorY == StyleOverscrollBehavior::Auto &&
|
||||
aDisplay->mScrollSnapTypeX == StyleScrollSnapStrictness::None &&
|
||||
aDisplay->mScrollSnapTypeY == StyleScrollSnapStrictness::None &&
|
||||
aDisplay->mScrollSnapPointsX == nsStyleCoord(eStyleUnit_None) &&
|
||||
aDisplay->mScrollSnapPointsY == nsStyleCoord(eStyleUnit_None) &&
|
||||
aDisplay->mScrollSnapDestination.horizontal == LengthPercentage::Zero() &&
|
||||
aDisplay->mScrollSnapDestination.vertical == LengthPercentage::Zero()) {
|
||||
const nsStyleDisplay* display = aComputedStyle->StyleDisplay();
|
||||
if (display->mOverflowX == StyleOverflow::Visible &&
|
||||
display->mScrollBehavior == NS_STYLE_SCROLL_BEHAVIOR_AUTO &&
|
||||
display->mOverscrollBehaviorX == StyleOverscrollBehavior::Auto &&
|
||||
display->mOverscrollBehaviorY == StyleOverscrollBehavior::Auto &&
|
||||
display->mScrollSnapType.strictness == StyleScrollSnapStrictness::None &&
|
||||
display->mScrollSnapPointsX == nsStyleCoord(eStyleUnit_None) &&
|
||||
display->mScrollSnapPointsY == nsStyleCoord(eStyleUnit_None) &&
|
||||
display->mScrollSnapDestination.horizontal == LengthPercentage::Zero() &&
|
||||
display->mScrollSnapDestination.vertical == LengthPercentage::Zero()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (aDisplay->mOverflowX == StyleOverflow::MozHiddenUnscrollable) {
|
||||
*aStyles =
|
||||
ScrollStyles(StyleOverflow::Hidden, StyleOverflow::Hidden, aDisplay);
|
||||
WritingMode writingMode = WritingMode(aComputedStyle);
|
||||
if (display->mOverflowX == StyleOverflow::MozHiddenUnscrollable) {
|
||||
*aStyles = ScrollStyles(writingMode, StyleOverflow::Hidden,
|
||||
StyleOverflow::Hidden, display);
|
||||
} else {
|
||||
*aStyles = ScrollStyles(aDisplay);
|
||||
*aStyles = ScrollStyles(writingMode, display);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
@ -1053,7 +1054,7 @@ static Element* GetPropagatedScrollStylesForViewport(
|
|||
// Check the style on the document root element
|
||||
ServoStyleSet* styleSet = aPresContext->StyleSet();
|
||||
RefPtr<ComputedStyle> rootStyle = styleSet->ResolveStyleLazily(*docElement);
|
||||
if (CheckOverflow(rootStyle->StyleDisplay(), aStyles)) {
|
||||
if (CheckOverflow(rootStyle, aStyles)) {
|
||||
// tell caller we stole the overflow style from the root element
|
||||
return docElement;
|
||||
}
|
||||
|
@ -1083,7 +1084,7 @@ static Element* GetPropagatedScrollStylesForViewport(
|
|||
// https://github.com/w3c/csswg-drafts/issues/3779
|
||||
RefPtr<ComputedStyle> bodyStyle = styleSet->ResolveStyleLazily(*bodyElement);
|
||||
|
||||
if (CheckOverflow(bodyStyle->StyleDisplay(), aStyles)) {
|
||||
if (CheckOverflow(bodyStyle, aStyles)) {
|
||||
// tell caller we stole the overflow style from the body element
|
||||
return bodyElement;
|
||||
}
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
var testCases = [
|
||||
{
|
||||
"description" : "Proximity + Within proximity => Snaps to point (Right)",
|
||||
"scrollSnapType" : "proximity",
|
||||
"scrollSnapType" : "both proximity",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -34,7 +34,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Proximity + Within proximity => Snaps to point (Left)",
|
||||
"scrollSnapType" : "proximity",
|
||||
"scrollSnapType" : "both proximity",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -49,7 +49,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Proximity + Within proximity => Snaps to point (Up)",
|
||||
"scrollSnapType" : "proximity",
|
||||
"scrollSnapType" : "both proximity",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -64,7 +64,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Proximity + Within proximity => Snaps to point (Down)",
|
||||
"scrollSnapType" : "proximity",
|
||||
"scrollSnapType" : "both proximity",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -79,7 +79,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Proximity + Beyond proximity => Does not snap to point (Right)",
|
||||
"scrollSnapType" : "proximity",
|
||||
"scrollSnapType" : "both proximity",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -94,7 +94,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Proximity + Beyond proximity => Does not snap to point (Left)",
|
||||
"scrollSnapType" : "proximity",
|
||||
"scrollSnapType" : "both proximity",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -109,7 +109,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Proximity + Beyond proximity => Does not snap to point (Up)",
|
||||
"scrollSnapType" : "proximity",
|
||||
"scrollSnapType" : "both proximity",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -124,7 +124,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Proximity + Beyond proximity => Does not snap to point (Down)",
|
||||
"scrollSnapType" : "proximity",
|
||||
"scrollSnapType" : "both proximity",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -139,7 +139,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + Beyond proximity => Snaps to point (Right)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -154,7 +154,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + Beyond proximity => Snaps to point (Left)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -169,7 +169,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + Beyond proximity => Snaps to point (Up)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -184,7 +184,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + Beyond proximity => Snaps to point (Down)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -199,7 +199,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + No snap points => Does not snap or scroll (Left)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -214,7 +214,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + No snap points => Does not snap or scroll (Right)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -229,7 +229,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + No snap points => Does not snap or scroll (Up)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -244,7 +244,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + No snap points => Does not snap or scroll (Down)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -259,7 +259,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-y + scroll-snap-destination + Start of page + No snap point at start of page => Does not snap to top of page (Up)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "repeat(500px)",
|
||||
"scrollSnapDestination" : "25px 25px",
|
||||
|
@ -274,7 +274,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-y + scroll-snap-destination + Start of page + No snap point at start of page => Does not snap to top of page (Page Up)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "repeat(500px)",
|
||||
"scrollSnapDestination" : "25px 25px",
|
||||
|
@ -289,7 +289,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-y + scroll-snap-destination + Start of page + No snap point at start of page => Snaps to highest snap point (Home)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "repeat(500px)",
|
||||
"scrollSnapDestination" : "25px 25px",
|
||||
|
@ -304,7 +304,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-x + scroll-snap-destination + Start of page + No snap point at start of page => Does not snap to left of page (Left)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "repeat(500px)",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "25px 25px",
|
||||
|
@ -319,7 +319,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-y + negative scroll-snap-destination + End of page + No snap point at end of page => Does not snap to end of page (Down)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "repeat(500px)",
|
||||
"scrollSnapDestination" : "-25px -25px",
|
||||
|
@ -334,7 +334,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-y + negative scroll-snap-destination + End of page + No snap point at end of page => Does not snap to end of page (Page Down)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "repeat(500px)",
|
||||
"scrollSnapDestination" : "-25px -25px",
|
||||
|
@ -349,7 +349,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-y + negative scroll-snap-destination + End of page + No snap point at end of page => Snaps to lowest snap point (End)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "repeat(500px)",
|
||||
"scrollSnapDestination" : "-25px -25px",
|
||||
|
@ -364,7 +364,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-coordinate + No snap point at start of page => Does not snap to top of page (Home)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -379,7 +379,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-coordinate + No snap point at end of page => Does not snap to end of page (End)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -394,7 +394,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-y greater than scrolling rect + positive non-zero scroll-snap-destination => No snap points, does not scroll or snap (Left)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "repeat(1500px)",
|
||||
"scrollSnapDestination" : "25px 25px",
|
||||
|
@ -409,7 +409,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-y greater than scrolling rect + positive non-zero scroll-snap-destination => No snap points, does not scroll or snap (Right)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "repeat(1500px)",
|
||||
"scrollSnapDestination" : "25px 25px",
|
||||
|
@ -424,7 +424,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-y greater than scrolling rect + positive non-zero scroll-snap-destination => No snap points, does not scroll or snap (Up)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "repeat(1500px)",
|
||||
"scrollSnapDestination" : "25px 25px",
|
||||
|
@ -439,7 +439,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-y greater than scrolling rect + positive non-zero scroll-snap-destination => No snap points, does not scroll or snap (Down)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "repeat(1500px)",
|
||||
"scrollSnapDestination" : "25px 25px",
|
||||
|
@ -454,7 +454,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Right #1)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "repeat(200px)",
|
||||
"scrollSnapPointsY" : "repeat(200px)",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -469,7 +469,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Right #2)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "repeat(200px)",
|
||||
"scrollSnapPointsY" : "repeat(200px)",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -485,7 +485,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Right #3)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "repeat(200px)",
|
||||
"scrollSnapPointsY" : "repeat(200px)",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -500,7 +500,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Up #1)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "repeat(200px)",
|
||||
"scrollSnapPointsY" : "repeat(200px)",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -515,7 +515,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Up #2)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "repeat(200px)",
|
||||
"scrollSnapPointsY" : "repeat(200px)",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -530,7 +530,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Mandatory + scroll-snap-points-{x|y} + scroll-snap-coordinate with two points => Interval and element snapping points are combined. Test 1 snap point generated by scroll-snap-points-{x|y} and two generated by scroll-snap-coordinate, ensure that they are evaluated as snap points. (Up #3)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "repeat(200px)",
|
||||
"scrollSnapPointsY" : "repeat(200px)",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -545,7 +545,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Ensure that when paging down/up that the next snap point in the direction of the scroll is selected rather than a closer point in the opposite direction (page Down)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -560,7 +560,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Ensure that when paging down/up that the next snap point in the direction of the scroll is selected rather than a closer point in the opposite direction (Page Up)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -575,7 +575,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Ensure that when paging down/up that the farthest snap point before the destination is selected and prioritized over a snap point that is past the destination, even if the snap point past the destination is closer to the destination. Setup - two snap points between current position and destination and one snap point past the destination which is closer than any of the other points. Scrollable rect size is 500px. (Page Down)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -590,7 +590,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Ensure that when paging down/up that the farthest snap point before the destination is selected and prioritized over a snap point that is past the destination, even if the snap point past the destination is closer to the destination. Setup - two snap points between current position and destination and one snap point past the destination which is closer than any of the other points. Scrollable rect size is 500px. (Page Up)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -605,7 +605,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Ensure that when paging down/up that the closest snap point past the destination is selected when no snap points exist between the starting position and the destination. Additionally, a snap point closer to the destination than the one past the snap point, but not in the scrolling direction, must not be selected. Setup - Two snap points beyond the destination and one snap point in the opposite direction of scrolling which is closest to the destination. Scrollable rect size is 500px. (Page Down)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -620,7 +620,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Ensure that when paging down/up that the closest snap point past the destination is selected when no snap points exist between the starting position and the destination. Additionally, a snap point closer to the destination than the one past the snap point, but not in the scrolling direction, must not be selected. Setup - Two snap points beyond the destination and one snap point in the opposite direction of scrolling which is closest to the destination. Scrollable rect size is 500px. (Page Up)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -635,7 +635,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Ensure that when scrolling by lines up,down,left,or right, that the closest snap point to the destination in the direction of travel is selected. Setup - Two snap points in the direction of travel and one in the opposite direction. Snap point in opposite direction is closest to the destination but must not be selected. (Down)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -650,7 +650,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Ensure that when scrolling by lines up,down,left,or right, that the closest snap point to the destination in the direction of travel is selected. Setup - Two snap points in the direction of travel and one in the opposite direction. Snap point in opposite direction is closest to the destination but must not be selected. (Up)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
@ -665,7 +665,7 @@ var testCases = [
|
|||
|
||||
{
|
||||
"description" : "Ensure that when scrolling by lines up,down,left,or right, that the closest snap point to the destination in the direction of travel is selected. Setup - Two snap points in the direction of travel and one in the opposite direction. Snap point in opposite direction is closest to the destination but must not be selected. (Left)",
|
||||
"scrollSnapType" : "mandatory",
|
||||
"scrollSnapType" : "both mandatory",
|
||||
"scrollSnapPointsX" : "none",
|
||||
"scrollSnapPointsY" : "none",
|
||||
"scrollSnapDestination" : "0px 0px",
|
||||
|
|
|
@ -243,7 +243,7 @@ function doTest() {
|
|||
lastScrollLeft = sc.scrollLeft;
|
||||
|
||||
sc.scrollTo(testCase.startScroll.x, testCase.startScroll.y);
|
||||
sc.style.scrollSnapType = "mandatory";
|
||||
sc.style.scrollSnapType = "both mandatory";
|
||||
sd.style.scrollSnapCoordinate = testCase.snapCoord;
|
||||
|
||||
synthesizeMouse(sc,
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
try { computed.getPropertyValue('quotes') } catch (e) {}
|
||||
try { header_0.style.setProperty('scroll-behavior', 'smooth', undefined) } catch (e) {}
|
||||
try { window.scrollBy(256, 1) } catch (e) {}
|
||||
try { header_0.style.setProperty('scroll-snap-type', 'mandatory', '') } catch (e) {}
|
||||
try { header_0.style.setProperty('scroll-snap-type', 'both mandatory', '') } catch (e) {}
|
||||
try { header_0.getClientRects() } catch (e) {}
|
||||
try { style_1.sheet.insertRule('i { }', undefined) } catch (e) {}
|
||||
}
|
||||
|
|
|
@ -4034,7 +4034,7 @@ ScrollStyles ScrollFrameHelper::GetScrollStylesFromFrame() const {
|
|||
|
||||
if (!mIsRoot) {
|
||||
const nsStyleDisplay* disp = mOuter->StyleDisplay();
|
||||
return ScrollStyles(disp);
|
||||
return ScrollStyles(mOuter->GetWritingMode(), disp);
|
||||
}
|
||||
|
||||
ScrollStyles result = presContext->GetViewportScrollStylesOverride();
|
||||
|
|
|
@ -414,6 +414,7 @@ cbindgen-types = [
|
|||
{ gecko = "StyleOutlineStyle", servo = "values::computed::OutlineStyle" },
|
||||
{ gecko = "StyleScrollSnapAlign", servo = "values::computed::ScrollSnapAlign" },
|
||||
{ gecko = "StyleScrollSnapStrictness", servo = "values::computed::ScrollSnapStrictness" },
|
||||
{ gecko = "StyleScrollSnapType", servo = "values::computed::ScrollSnapType" },
|
||||
{ gecko = "StyleResize", servo = "values::computed::Resize" },
|
||||
{ gecko = "StyleOverflowClipBox", servo = "values::computed::OverflowClipBox" },
|
||||
{ gecko = "StyleFloat", servo = "values::computed::Float" },
|
||||
|
|
|
@ -2939,8 +2939,8 @@ nsStyleDisplay::nsStyleDisplay(const Document& aDocument)
|
|||
mOverscrollBehaviorX(StyleOverscrollBehavior::Auto),
|
||||
mOverscrollBehaviorY(StyleOverscrollBehavior::Auto),
|
||||
mOverflowAnchor(StyleOverflowAnchor::Auto),
|
||||
mScrollSnapTypeX(StyleScrollSnapStrictness::None),
|
||||
mScrollSnapTypeY(StyleScrollSnapStrictness::None),
|
||||
mScrollSnapType(
|
||||
{StyleScrollSnapAxis::Both, StyleScrollSnapStrictness::None}),
|
||||
mScrollSnapPointsX(eStyleUnit_None),
|
||||
mScrollSnapPointsY(eStyleUnit_None),
|
||||
mScrollSnapDestination(
|
||||
|
@ -3004,8 +3004,7 @@ nsStyleDisplay::nsStyleDisplay(const nsStyleDisplay& aSource)
|
|||
mScrollBehavior(aSource.mScrollBehavior),
|
||||
mOverscrollBehaviorX(aSource.mOverscrollBehaviorX),
|
||||
mOverscrollBehaviorY(aSource.mOverscrollBehaviorY),
|
||||
mScrollSnapTypeX(aSource.mScrollSnapTypeX),
|
||||
mScrollSnapTypeY(aSource.mScrollSnapTypeY),
|
||||
mScrollSnapType(aSource.mScrollSnapType),
|
||||
mScrollSnapPointsX(aSource.mScrollSnapPointsX),
|
||||
mScrollSnapPointsY(aSource.mScrollSnapPointsY),
|
||||
mScrollSnapDestination(aSource.mScrollSnapDestination),
|
||||
|
@ -3145,8 +3144,7 @@ nsChangeHint nsStyleDisplay::CalcDifference(
|
|||
mContain != aNewData.mContain ||
|
||||
(mFloat == StyleFloat::None) != (aNewData.mFloat == StyleFloat::None) ||
|
||||
mScrollBehavior != aNewData.mScrollBehavior ||
|
||||
mScrollSnapTypeX != aNewData.mScrollSnapTypeX ||
|
||||
mScrollSnapTypeY != aNewData.mScrollSnapTypeY ||
|
||||
mScrollSnapType != aNewData.mScrollSnapType ||
|
||||
mScrollSnapPointsX != aNewData.mScrollSnapPointsX ||
|
||||
mScrollSnapPointsY != aNewData.mScrollSnapPointsY ||
|
||||
mScrollSnapDestination != aNewData.mScrollSnapDestination ||
|
||||
|
|
|
@ -1895,8 +1895,7 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleDisplay {
|
|||
mozilla::StyleOverscrollBehavior mOverscrollBehaviorY;
|
||||
mozilla::StyleOverflowAnchor mOverflowAnchor;
|
||||
mozilla::StyleScrollSnapAlign mScrollSnapAlign;
|
||||
mozilla::StyleScrollSnapStrictness mScrollSnapTypeX;
|
||||
mozilla::StyleScrollSnapStrictness mScrollSnapTypeY;
|
||||
mozilla::StyleScrollSnapType mScrollSnapType;
|
||||
nsStyleCoord mScrollSnapPointsX;
|
||||
nsStyleCoord mScrollSnapPointsY;
|
||||
mozilla::Position mScrollSnapDestination;
|
||||
|
|
|
@ -7690,31 +7690,26 @@ if (IsCSSPropertyPrefEnabled("layout.css.scroll-snap.enabled")) {
|
|||
gCSSProperties["scroll-snap-type"] = {
|
||||
domProp: "scrollSnapType",
|
||||
inherited: false,
|
||||
type: CSS_TYPE_TRUE_SHORTHAND,
|
||||
subproperties: [ "scroll-snap-type-x", "scroll-snap-type-y" ],
|
||||
initial_values: [ "none" ],
|
||||
other_values: [ "mandatory", "proximity" ],
|
||||
invalid_values: [ "auto", "1px" ]
|
||||
};
|
||||
gCSSProperties["scroll-snap-type-x"] = {
|
||||
domProp: "scrollSnapTypeX",
|
||||
inherited: false,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "none" ],
|
||||
other_values: ["mandatory", "proximity"],
|
||||
invalid_values: [ "auto", "1px" ]
|
||||
};
|
||||
gCSSProperties["scroll-snap-type-y"] = {
|
||||
domProp: "scrollSnapTypeY",
|
||||
inherited: false,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "none" ],
|
||||
other_values: ["mandatory", "proximity"],
|
||||
other_values: [ "both mandatory", "both" ],
|
||||
invalid_values: [ "auto", "1px" ]
|
||||
};
|
||||
}
|
||||
|
||||
if (IsCSSPropertyPrefEnabled("layout.css.scroll-snap-v1.enabled")) {
|
||||
gCSSProperties["scroll-snap-type"] = {
|
||||
domProp: "scrollSnapType",
|
||||
inherited: false,
|
||||
type: CSS_TYPE_LONGHAND,
|
||||
initial_values: [ "none" ],
|
||||
other_values: [ "both mandatory", "y mandatory", "inline proximity",
|
||||
"both", "x", "y", "block", "inline" ],
|
||||
invalid_values: [ "auto", "1px", "x y", "block mandatory inline",
|
||||
"mandatory", "proximity", "mandatory inline",
|
||||
"proximity both", "mandatory x", "proximity y",
|
||||
"mandatory block", "proximity mandatory" ],
|
||||
};
|
||||
gCSSProperties["scroll-snap-align"] = {
|
||||
domProp: "scrollSnapAlign",
|
||||
inherited: false,
|
||||
|
|
|
@ -341,7 +341,9 @@ class Longhand(object):
|
|||
"SVGOpacity",
|
||||
"SVGPaintOrder",
|
||||
"ScrollSnapAlign",
|
||||
"ScrollSnapAxis",
|
||||
"ScrollSnapStrictness",
|
||||
"ScrollSnapType",
|
||||
"TextAlign",
|
||||
"TextDecorationLine",
|
||||
"TextEmphasisPosition",
|
||||
|
|
|
@ -427,18 +427,15 @@ ${helpers.predefined_type(
|
|||
animation_value_type="discrete",
|
||||
)}
|
||||
|
||||
% for axis in ["x", "y"]:
|
||||
${helpers.predefined_type(
|
||||
"scroll-snap-type-" + axis,
|
||||
"ScrollSnapStrictness",
|
||||
"computed::ScrollSnapStrictness::None",
|
||||
products="gecko",
|
||||
needs_context=False,
|
||||
gecko_pref="layout.css.scroll-snap.enabled",
|
||||
spec="Nonstandard (https://developer.mozilla.org/en-US/docs/Web/CSS/scroll-snap-type-x)",
|
||||
animation_value_type="discrete",
|
||||
)}
|
||||
% endfor
|
||||
${helpers.predefined_type(
|
||||
"scroll-snap-type",
|
||||
"ScrollSnapType",
|
||||
"computed::ScrollSnapType::none()",
|
||||
products="gecko",
|
||||
gecko_pref="layout.css.scroll-snap.enabled",
|
||||
spec="https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-type",
|
||||
animation_value_type="discrete",
|
||||
)}
|
||||
|
||||
% for axis in ["x", "y"]:
|
||||
${helpers.predefined_type(
|
||||
|
|
|
@ -303,36 +303,6 @@ macro_rules! try_parse_one {
|
|||
}
|
||||
</%helpers:shorthand>
|
||||
|
||||
<%helpers:shorthand name="scroll-snap-type" products="gecko"
|
||||
gecko_pref="layout.css.scroll-snap.enabled"
|
||||
sub_properties="scroll-snap-type-x scroll-snap-type-y"
|
||||
spec="https://drafts.csswg.org/css-scroll-snap/#propdef-scroll-snap-type">
|
||||
use crate::properties::longhands::scroll_snap_type_x;
|
||||
|
||||
pub fn parse_value<'i, 't>(
|
||||
context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Longhands, ParseError<'i>> {
|
||||
let result = scroll_snap_type_x::parse(context, input)?;
|
||||
Ok(expanded! {
|
||||
scroll_snap_type_x: result,
|
||||
scroll_snap_type_y: result,
|
||||
})
|
||||
}
|
||||
|
||||
impl<'a> ToCss for LonghandsToSerialize<'a> {
|
||||
// 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 CssWriter<W>) -> fmt::Result where W: fmt::Write {
|
||||
if self.scroll_snap_type_x == self.scroll_snap_type_y {
|
||||
self.scroll_snap_type_x.to_css(dest)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
}
|
||||
</%helpers:shorthand>
|
||||
|
||||
${helpers.two_properties_shorthand(
|
||||
"overscroll-behavior",
|
||||
"overscroll-behavior-x",
|
||||
|
|
|
@ -14,8 +14,8 @@ use crate::values::specified::box_ as specified;
|
|||
pub use crate::values::specified::box_::{AnimationName, Appearance, BreakBetween, BreakWithin};
|
||||
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, ScrollSnapStrictness};
|
||||
pub use crate::values::specified::box_::{OverflowAnchor, OverflowClipBox, OverscrollBehavior};
|
||||
pub use crate::values::specified::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType};
|
||||
pub use crate::values::specified::box_::{TouchAction, TransitionProperty, WillChange};
|
||||
|
||||
/// A computed value for the `vertical-align` property.
|
||||
|
|
|
@ -42,7 +42,8 @@ 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, ScrollSnapStrictness, TouchAction, VerticalAlign, WillChange};
|
||||
pub use self::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType};
|
||||
pub use self::box_::{TouchAction, VerticalAlign, WillChange};
|
||||
pub use self::color::{Color, ColorOrAuto, ColorPropertyValue};
|
||||
pub use self::column::ColumnCount;
|
||||
pub use self::counters::{Content, ContentItem, CounterIncrement, CounterSetOrReset};
|
||||
|
|
|
@ -379,6 +379,32 @@ impl Parse for AnimationName {
|
|||
}
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-scroll-snap-1/#snap-axis
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
MallocSizeOf,
|
||||
Parse,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToCss,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(u8)]
|
||||
pub enum ScrollSnapAxis {
|
||||
X,
|
||||
Y,
|
||||
Block,
|
||||
Inline,
|
||||
Both,
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-scroll-snap-1/#snap-strictness
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
|
@ -398,11 +424,77 @@ impl Parse for AnimationName {
|
|||
)]
|
||||
#[repr(u8)]
|
||||
pub enum ScrollSnapStrictness {
|
||||
None,
|
||||
#[css(skip)]
|
||||
None, // Used to represent scroll-snap-type: none. It's not parsed.
|
||||
Mandatory,
|
||||
Proximity,
|
||||
}
|
||||
|
||||
/// https://drafts.csswg.org/css-scroll-snap-1/#scroll-snap-type
|
||||
#[allow(missing_docs)]
|
||||
#[cfg_attr(feature = "servo", derive(Deserialize, Serialize))]
|
||||
#[derive(
|
||||
Clone,
|
||||
Copy,
|
||||
Debug,
|
||||
Eq,
|
||||
MallocSizeOf,
|
||||
PartialEq,
|
||||
SpecifiedValueInfo,
|
||||
ToComputedValue,
|
||||
ToResolvedValue,
|
||||
ToShmem,
|
||||
)]
|
||||
#[repr(C)]
|
||||
pub struct ScrollSnapType {
|
||||
axis: ScrollSnapAxis,
|
||||
strictness: ScrollSnapStrictness,
|
||||
}
|
||||
|
||||
impl ScrollSnapType {
|
||||
/// Returns `none`.
|
||||
#[inline]
|
||||
pub fn none() -> Self {
|
||||
Self {
|
||||
axis: ScrollSnapAxis::Both,
|
||||
strictness: ScrollSnapStrictness::None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Parse for ScrollSnapType {
|
||||
/// none | [ x | y | block | inline | both ] [ mandatory | proximity ]?
|
||||
fn parse<'i, 't>(
|
||||
_context: &ParserContext,
|
||||
input: &mut Parser<'i, 't>,
|
||||
) -> Result<Self, ParseError<'i>> {
|
||||
if input.try(|input| input.expect_ident_matching("none")).is_ok() {
|
||||
return Ok(ScrollSnapType::none());
|
||||
}
|
||||
|
||||
let axis = ScrollSnapAxis::parse(input)?;
|
||||
let strictness = input.try(ScrollSnapStrictness::parse).unwrap_or(ScrollSnapStrictness::Proximity);
|
||||
Ok(Self { axis, strictness })
|
||||
}
|
||||
}
|
||||
|
||||
impl ToCss for ScrollSnapType {
|
||||
fn to_css<W>(&self, dest: &mut CssWriter<W>) -> fmt::Result
|
||||
where
|
||||
W: Write,
|
||||
{
|
||||
if self.strictness == ScrollSnapStrictness::None {
|
||||
return dest.write_str("none");
|
||||
}
|
||||
self.axis.to_css(dest)?;
|
||||
if self.strictness != ScrollSnapStrictness::Proximity {
|
||||
dest.write_str(" ")?;
|
||||
self.strictness.to_css(dest)?;
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
/// Specified value of scroll-snap-align keyword value.
|
||||
#[allow(missing_docs)]
|
||||
#[derive(
|
||||
|
|
|
@ -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, ScrollSnapStrictness};
|
||||
pub use self::box_::{ScrollSnapAlign, ScrollSnapAxis, ScrollSnapStrictness, ScrollSnapType};
|
||||
pub use self::box_::{TouchAction, TransitionProperty, VerticalAlign, WillChange};
|
||||
pub use self::color::{Color, ColorOrAuto, ColorPropertyValue};
|
||||
pub use self::column::ColumnCount;
|
||||
|
|
|
@ -71,7 +71,9 @@ include = [
|
|||
"Float",
|
||||
"OverscrollBehavior",
|
||||
"ScrollSnapAlign",
|
||||
"ScrollSnapAxis",
|
||||
"ScrollSnapStrictness",
|
||||
"ScrollSnapType",
|
||||
"OverflowAnchor",
|
||||
"OverflowClipBox",
|
||||
"Resize",
|
||||
|
|
|
@ -1,7 +0,0 @@
|
|||
[scroll-snap-type-invalid.html]
|
||||
[e.style['scroll-snap-type'\] = "mandatory" should not set the property value]
|
||||
expected: FAIL
|
||||
|
||||
[e.style['scroll-snap-type'\] = "proximity" should not set the property value]
|
||||
expected: FAIL
|
||||
|
|
@ -1,22 +0,0 @@
|
|||
[scroll-snap-type-valid.html]
|
||||
[e.style['scroll-snap-type'\] = "block" should set the property value]
|
||||
expected: FAIL
|
||||
|
||||
[e.style['scroll-snap-type'\] = "y mandatory" should set the property value]
|
||||
expected: FAIL
|
||||
|
||||
[e.style['scroll-snap-type'\] = "both" should set the property value]
|
||||
expected: FAIL
|
||||
|
||||
[e.style['scroll-snap-type'\] = "inline proximity" should set the property value]
|
||||
expected: FAIL
|
||||
|
||||
[e.style['scroll-snap-type'\] = "y" should set the property value]
|
||||
expected: FAIL
|
||||
|
||||
[e.style['scroll-snap-type'\] = "inline" should set the property value]
|
||||
expected: FAIL
|
||||
|
||||
[e.style['scroll-snap-type'\] = "x" should set the property value]
|
||||
expected: FAIL
|
||||
|
|
@ -33,7 +33,7 @@ assert_not_inherited('scroll-padding-right', 'auto', '10px');
|
|||
assert_not_inherited('scroll-padding-top', 'auto', '10px');
|
||||
assert_not_inherited('scroll-snap-align', 'none', 'start end');
|
||||
assert_not_inherited('scroll-snap-stop', 'normal', 'always');
|
||||
assert_not_inherited('scroll-snap-type', 'none', 'inline proximity');
|
||||
assert_not_inherited('scroll-snap-type', 'none', 'inline');
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -20,7 +20,7 @@ test_valid_value("scroll-snap-type", "inline");
|
|||
test_valid_value("scroll-snap-type", "both");
|
||||
|
||||
test_valid_value("scroll-snap-type", "y mandatory");
|
||||
test_valid_value("scroll-snap-type", "inline proximity");
|
||||
test_valid_value("scroll-snap-type", "inline proximity", "inline"); // The shortest serialization is preferable
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
|
|
@ -1175,18 +1175,6 @@ const gCSSProperties = {
|
|||
{ type: 'discrete', options: [ [ 'auto', 'smooth' ] ] }
|
||||
]
|
||||
},
|
||||
'scroll-snap-type-x': {
|
||||
// https://developer.mozilla.org/en/docs/Web/CSS/scroll-snap-type-x
|
||||
types: [
|
||||
{ type: 'discrete', options: [ [ 'mandatory', 'proximity' ] ] }
|
||||
]
|
||||
},
|
||||
'scroll-snap-type-y': {
|
||||
// https://developer.mozilla.org/en/docs/Web/CSS/scroll-snap-type-y
|
||||
types: [
|
||||
{ type: 'discrete', options: [ [ 'mandatory', 'proximity' ] ] }
|
||||
]
|
||||
},
|
||||
'shape-outside': {
|
||||
// http://dev.w3.org/csswg/css-shapes/#propdef-shape-outside
|
||||
types: [
|
||||
|
|
|
@ -309,7 +309,7 @@ button.month-year.active::after {
|
|||
margin: var(--spinner-margin-top-bottom) 0;
|
||||
cursor: default;
|
||||
overflow-y: scroll;
|
||||
scroll-snap-type: mandatory;
|
||||
scroll-snap-type: both mandatory;
|
||||
scroll-snap-points-y: repeat(100%);
|
||||
}
|
||||
|
||||
|
@ -379,4 +379,4 @@ button.month-year.active::after {
|
|||
|
||||
.spacer {
|
||||
width: var(--day-period-spacing-width);
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче