Bug 1546219 - Rename mScrollSnapType{X,Y} to mScrollSnapStrictness{X,Y}. r=botond

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Hiroyuki Ikezoe 2019-05-22 17:43:34 +00:00
Родитель 94cf690698
Коммит d3e6eadc70
8 изменённых файлов: 60 добавлений и 57 удалений

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

@ -90,39 +90,39 @@ void ScrollMetadata::SetUsesContainerScrolling(bool aValue) {
mUsesContainerScrolling = aValue;
}
void ScrollSnapInfo::InitializeScrollSnapType(WritingMode aWritingMode,
const nsStyleDisplay* aDisplay) {
void ScrollSnapInfo::InitializeScrollSnapStrictness(
WritingMode aWritingMode, const nsStyleDisplay* aDisplay) {
if (aDisplay->mScrollSnapType.strictness == StyleScrollSnapStrictness::None) {
return;
}
mScrollSnapTypeX = StyleScrollSnapStrictness::None;
mScrollSnapTypeY = StyleScrollSnapStrictness::None;
mScrollSnapStrictnessX = StyleScrollSnapStrictness::None;
mScrollSnapStrictnessY = StyleScrollSnapStrictness::None;
switch (aDisplay->mScrollSnapType.axis) {
case StyleScrollSnapAxis::X:
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessX = aDisplay->mScrollSnapType.strictness;
break;
case StyleScrollSnapAxis::Y:
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessY = aDisplay->mScrollSnapType.strictness;
break;
case StyleScrollSnapAxis::Block:
if (aWritingMode.IsVertical()) {
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessX = aDisplay->mScrollSnapType.strictness;
} else {
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessY = aDisplay->mScrollSnapType.strictness;
}
break;
case StyleScrollSnapAxis::Inline:
if (aWritingMode.IsVertical()) {
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessY = aDisplay->mScrollSnapType.strictness;
} else {
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessX = aDisplay->mScrollSnapType.strictness;
}
break;
case StyleScrollSnapAxis::Both:
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessX = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessY = aDisplay->mScrollSnapType.strictness;
break;
}
}

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

@ -719,8 +719,8 @@ struct ScrollSnapInfo {
ScrollSnapInfo() = default;
bool operator==(const ScrollSnapInfo& aOther) const {
return mScrollSnapTypeX == aOther.mScrollSnapTypeX &&
mScrollSnapTypeY == aOther.mScrollSnapTypeY &&
return mScrollSnapStrictnessX == aOther.mScrollSnapStrictnessX &&
mScrollSnapStrictnessY == aOther.mScrollSnapStrictnessY &&
mScrollSnapIntervalX == aOther.mScrollSnapIntervalX &&
mScrollSnapIntervalY == aOther.mScrollSnapIntervalY &&
mScrollSnapDestination == aOther.mScrollSnapDestination &&
@ -733,24 +733,25 @@ struct ScrollSnapInfo {
}
bool HasScrollSnapping() const {
return mScrollSnapTypeY != mozilla::StyleScrollSnapStrictness::None ||
mScrollSnapTypeX != mozilla::StyleScrollSnapStrictness::None;
return mScrollSnapStrictnessY != mozilla::StyleScrollSnapStrictness::None ||
mScrollSnapStrictnessX != mozilla::StyleScrollSnapStrictness::None;
}
bool HasSnapPositions() const {
return (!mSnapPositionX.IsEmpty() &&
mScrollSnapTypeX != mozilla::StyleScrollSnapStrictness::None) ||
mScrollSnapStrictnessX !=
mozilla::StyleScrollSnapStrictness::None) ||
(!mSnapPositionY.IsEmpty() &&
mScrollSnapTypeY != mozilla::StyleScrollSnapStrictness::None);
mScrollSnapStrictnessY != mozilla::StyleScrollSnapStrictness::None);
}
void InitializeScrollSnapType(WritingMode aWritingMode,
const nsStyleDisplay* aDisplay);
void InitializeScrollSnapStrictness(WritingMode aWritingMode,
const nsStyleDisplay* aDisplay);
// The scroll frame's scroll-snap-type.
mozilla::StyleScrollSnapStrictness mScrollSnapTypeX =
mozilla::StyleScrollSnapStrictness mScrollSnapStrictnessX =
mozilla::StyleScrollSnapStrictness::None;
mozilla::StyleScrollSnapStrictness mScrollSnapTypeY =
mozilla::StyleScrollSnapStrictness mScrollSnapStrictnessY =
mozilla::StyleScrollSnapStrictness::None;
// The intervals derived from the scroll frame's scroll-snap-points.

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

@ -27,7 +27,7 @@ TEST_F(APZCSnappingTester, Bug1265510) {
SetScrollHandoff(layers[1], root);
ScrollSnapInfo snap;
snap.mScrollSnapTypeY = StyleScrollSnapStrictness::Mandatory;
snap.mScrollSnapStrictnessY = StyleScrollSnapStrictness::Mandatory;
if (StaticPrefs::layout_css_scroll_snap_v1_enabled()) {
snap.mSnapPositionY.AppendElement(0 * AppUnitsPerCSSPixel());
snap.mSnapPositionY.AppendElement(100 * AppUnitsPerCSSPixel());
@ -102,7 +102,7 @@ TEST_F(APZCSnappingTester, Snap_After_Pinch) {
// Set up some basic scroll snapping
ScrollSnapInfo snap;
snap.mScrollSnapTypeY = StyleScrollSnapStrictness::Mandatory;
snap.mScrollSnapStrictnessY = StyleScrollSnapStrictness::Mandatory;
if (StaticPrefs::layout_css_scroll_snap_v1_enabled()) {
snap.mSnapPositionY.AppendElement(0 * AppUnitsPerCSSPixel());

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

@ -332,8 +332,8 @@ struct ParamTraits<mozilla::layers::ScrollSnapInfo> {
typedef mozilla::layers::ScrollSnapInfo paramType;
static void Write(Message* aMsg, const paramType& aParam) {
WriteParam(aMsg, aParam.mScrollSnapTypeX);
WriteParam(aMsg, aParam.mScrollSnapTypeY);
WriteParam(aMsg, aParam.mScrollSnapStrictnessX);
WriteParam(aMsg, aParam.mScrollSnapStrictnessY);
WriteParam(aMsg, aParam.mScrollSnapIntervalX);
WriteParam(aMsg, aParam.mScrollSnapIntervalY);
WriteParam(aMsg, aParam.mScrollSnapDestination);
@ -347,8 +347,8 @@ struct ParamTraits<mozilla::layers::ScrollSnapInfo> {
static bool Read(const Message* aMsg, PickleIterator* aIter,
paramType* aResult) {
return (ReadParam(aMsg, aIter, &aResult->mScrollSnapTypeX) &&
ReadParam(aMsg, aIter, &aResult->mScrollSnapTypeY) &&
return (ReadParam(aMsg, aIter, &aResult->mScrollSnapStrictnessX) &&
ReadParam(aMsg, aIter, &aResult->mScrollSnapStrictnessY) &&
ReadParam(aMsg, aIter, &aResult->mScrollSnapIntervalX) &&
ReadParam(aMsg, aIter, &aResult->mScrollSnapIntervalY) &&
ReadParam(aMsg, aIter, &aResult->mScrollSnapDestination) &&

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

@ -10,10 +10,10 @@
namespace mozilla {
void ScrollStyles::InitializeScrollSnapType(WritingMode aWritingMode,
const nsStyleDisplay* aDisplay) {
mScrollSnapTypeX = StyleScrollSnapStrictness::None;
mScrollSnapTypeY = StyleScrollSnapStrictness::None;
void ScrollStyles::InitializeScrollSnapStrictness(
WritingMode aWritingMode, const nsStyleDisplay* aDisplay) {
mScrollSnapStrictnessX = StyleScrollSnapStrictness::None;
mScrollSnapStrictnessY = StyleScrollSnapStrictness::None;
if (aDisplay->mScrollSnapType.strictness == StyleScrollSnapStrictness::None) {
return;
@ -21,28 +21,28 @@ void ScrollStyles::InitializeScrollSnapType(WritingMode aWritingMode,
switch (aDisplay->mScrollSnapType.axis) {
case StyleScrollSnapAxis::X:
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessX = aDisplay->mScrollSnapType.strictness;
break;
case StyleScrollSnapAxis::Y:
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessY = aDisplay->mScrollSnapType.strictness;
break;
case StyleScrollSnapAxis::Block:
if (aWritingMode.IsVertical()) {
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessX = aDisplay->mScrollSnapType.strictness;
} else {
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessY = aDisplay->mScrollSnapType.strictness;
}
break;
case StyleScrollSnapAxis::Inline:
if (aWritingMode.IsVertical()) {
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessY = aDisplay->mScrollSnapType.strictness;
} else {
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessX = aDisplay->mScrollSnapType.strictness;
}
break;
case StyleScrollSnapAxis::Both:
mScrollSnapTypeX = aDisplay->mScrollSnapType.strictness;
mScrollSnapTypeY = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessX = aDisplay->mScrollSnapType.strictness;
mScrollSnapStrictnessY = aDisplay->mScrollSnapType.strictness;
break;
}
}
@ -54,7 +54,7 @@ ScrollStyles::ScrollStyles(WritingMode aWritingMode, StyleOverflow aH,
mScrollBehavior(aDisplay->mScrollBehavior),
mOverscrollBehaviorX(aDisplay->mOverscrollBehaviorX),
mOverscrollBehaviorY(aDisplay->mOverscrollBehaviorY) {
InitializeScrollSnapType(aWritingMode, aDisplay);
InitializeScrollSnapStrictness(aWritingMode, aDisplay);
}
ScrollStyles::ScrollStyles(WritingMode aWritingMode,
@ -64,7 +64,7 @@ ScrollStyles::ScrollStyles(WritingMode aWritingMode,
mScrollBehavior(aDisplay->mScrollBehavior),
mOverscrollBehaviorX(aDisplay->mOverscrollBehaviorX),
mOverscrollBehaviorY(aDisplay->mOverscrollBehaviorY) {
InitializeScrollSnapType(aWritingMode, aDisplay);
InitializeScrollSnapStrictness(aWritingMode, aDisplay);
}
} // namespace mozilla

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

@ -26,8 +26,8 @@ struct ScrollStyles {
uint8_t mScrollBehavior;
StyleOverscrollBehavior mOverscrollBehaviorX;
StyleOverscrollBehavior mOverscrollBehaviorY;
StyleScrollSnapStrictness mScrollSnapTypeX;
StyleScrollSnapStrictness mScrollSnapTypeY;
StyleScrollSnapStrictness mScrollSnapStrictnessX;
StyleScrollSnapStrictness mScrollSnapStrictnessY;
ScrollStyles(StyleOverflow aH, StyleOverflow aV)
: mHorizontal(aH),
@ -35,22 +35,22 @@ struct ScrollStyles {
mScrollBehavior(NS_STYLE_SCROLL_BEHAVIOR_AUTO),
mOverscrollBehaviorX(StyleOverscrollBehavior::Auto),
mOverscrollBehaviorY(StyleOverscrollBehavior::Auto),
mScrollSnapTypeX(StyleScrollSnapStrictness::None),
mScrollSnapTypeY(StyleScrollSnapStrictness::None) {}
mScrollSnapStrictnessX(StyleScrollSnapStrictness::None),
mScrollSnapStrictnessY(StyleScrollSnapStrictness::None) {}
ScrollStyles(WritingMode aWritingMode, const nsStyleDisplay* aDisplay);
ScrollStyles(WritingMode aWritingMode, StyleOverflow aH, StyleOverflow aV,
const nsStyleDisplay* aDisplay);
void InitializeScrollSnapType(WritingMode aWritingMode,
const nsStyleDisplay* aDisplay);
void InitializeScrollSnapStrictness(WritingMode aWritingMode,
const nsStyleDisplay* aDisplay);
bool operator==(const ScrollStyles& aStyles) const {
return aStyles.mHorizontal == mHorizontal &&
aStyles.mVertical == mVertical &&
aStyles.mScrollBehavior == mScrollBehavior &&
aStyles.mOverscrollBehaviorX == mOverscrollBehaviorX &&
aStyles.mOverscrollBehaviorY == mOverscrollBehaviorY &&
aStyles.mScrollSnapTypeX == mScrollSnapTypeX &&
aStyles.mScrollSnapTypeY == mScrollSnapTypeY;
aStyles.mScrollSnapStrictnessX == mScrollSnapStrictnessX &&
aStyles.mScrollSnapStrictnessY == mScrollSnapStrictnessY;
}
bool operator!=(const ScrollStyles& aStyles) const {
return !(*this == aStyles);

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

@ -275,8 +275,8 @@ Maybe<nsPoint> ScrollSnapUtils::GetSnapPointForDestination(
const ScrollSnapInfo& aSnapInfo, nsIScrollableFrame::ScrollUnit aUnit,
const nsRect& aScrollRange, const nsPoint& aStartPos,
const nsPoint& aDestination) {
if (aSnapInfo.mScrollSnapTypeY == StyleScrollSnapStrictness::None &&
aSnapInfo.mScrollSnapTypeX == StyleScrollSnapStrictness::None) {
if (aSnapInfo.mScrollSnapStrictnessY == StyleScrollSnapStrictness::None &&
aSnapInfo.mScrollSnapStrictnessX == StyleScrollSnapStrictness::None) {
return Nothing();
}
@ -335,13 +335,15 @@ Maybe<nsPoint> ScrollSnapUtils::GetSnapPointForDestination(
nsPoint finalPos = calcSnapPoints.GetBestEdge();
nscoord proximityThreshold = gfxPrefs::ScrollSnapProximityThreshold();
proximityThreshold = nsPresContext::CSSPixelsToAppUnits(proximityThreshold);
if (aSnapInfo.mScrollSnapTypeY == StyleScrollSnapStrictness::Proximity &&
if (aSnapInfo.mScrollSnapStrictnessY ==
StyleScrollSnapStrictness::Proximity &&
std::abs(aDestination.y - finalPos.y) > proximityThreshold) {
finalPos.y = aDestination.y;
} else {
snapped = true;
}
if (aSnapInfo.mScrollSnapTypeX == StyleScrollSnapStrictness::Proximity &&
if (aSnapInfo.mScrollSnapStrictnessX ==
StyleScrollSnapStrictness::Proximity &&
std::abs(aDestination.x - finalPos.x) > proximityThreshold) {
finalPos.x = aDestination.x;
} else {

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

@ -5390,8 +5390,8 @@ bool ScrollFrameHelper::NeedsScrollSnap() const {
}
ScrollStyles styles = GetScrollStylesFromFrame();
return styles.mScrollSnapTypeY != StyleScrollSnapStrictness::None ||
styles.mScrollSnapTypeX != StyleScrollSnapStrictness::None;
return styles.mScrollSnapStrictnessY != StyleScrollSnapStrictness::None ||
styles.mScrollSnapStrictnessX != StyleScrollSnapStrictness::None;
}
bool ScrollFrameHelper::IsScrollbarOnRight() const {
@ -6838,7 +6838,7 @@ layers::ScrollSnapInfo ScrollFrameHelper::ComputeScrollSnapInfo(
}
WritingMode writingMode = GetFrameForDir()->GetWritingMode();
result.InitializeScrollSnapType(writingMode, disp);
result.InitializeScrollSnapStrictness(writingMode, disp);
nsRect snapport = GetScrollPortRect();
nsMargin scrollPadding = GetScrollPadding();