зеркало из https://github.com/mozilla/gecko-dev.git
Backed out 4 changesets (bug 1774537) for causing mochitest failures on test_group_wheelevents.html CLOSED TREE
Backed out changeset 8a52eb5b9043 (bug 1774537) Backed out changeset 5fb8ccdcbfea (bug 1774537) Backed out changeset 44f1a68c16f4 (bug 1774537) Backed out changeset 1f32db09b9a8 (bug 1774537)
This commit is contained in:
Родитель
2e84c628da
Коммит
a8bd595d93
|
@ -10,15 +10,14 @@
|
|||
#include <iosfwd>
|
||||
#include <stdint.h> // for uint8_t, uint32_t, uint64_t
|
||||
|
||||
#include "FrameMetrics.h" // for FrameMetrics
|
||||
#include "mozilla/DefineEnum.h" // for MOZ_DEFINE_ENUM
|
||||
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
||||
#include "mozilla/gfx/Rect.h" // for RoundedIn
|
||||
#include "mozilla/gfx/ScaleFactor.h" // for ScaleFactor
|
||||
#include "mozilla/ScrollSnapTargetId.h" // for ScrollSnapTargetIds
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp
|
||||
#include "Units.h" // for CSSRect, CSSPixel, etc
|
||||
#include "UnitTransforms.h" // for ViewAs
|
||||
#include "FrameMetrics.h" // for FrameMetrics
|
||||
#include "mozilla/DefineEnum.h" // for MOZ_DEFINE_ENUM
|
||||
#include "mozilla/gfx/BasePoint.h" // for BasePoint
|
||||
#include "mozilla/gfx/Rect.h" // for RoundedIn
|
||||
#include "mozilla/gfx/ScaleFactor.h" // for ScaleFactor
|
||||
#include "mozilla/TimeStamp.h" // for TimeStamp
|
||||
#include "Units.h" // for CSSRect, CSSPixel, etc
|
||||
#include "UnitTransforms.h" // for ViewAs
|
||||
|
||||
namespace IPC {
|
||||
template <typename T>
|
||||
|
@ -66,8 +65,7 @@ struct RepaintRequest {
|
|||
const ScreenMargin& aDisplayportMargins,
|
||||
const ScrollOffsetUpdateType aScrollUpdateType,
|
||||
APZScrollAnimationType aScrollAnimationType,
|
||||
const APZScrollGeneration& aScrollGenerationOnApz,
|
||||
const ScrollSnapTargetIds& aLastSnapTargetIds)
|
||||
const APZScrollGeneration& aScrollGenerationOnApz)
|
||||
: mScrollId(aOther.GetScrollId()),
|
||||
mPresShellResolution(aOther.GetPresShellResolution()),
|
||||
mCompositionBounds(aOther.GetCompositionBounds()),
|
||||
|
@ -84,7 +82,6 @@ struct RepaintRequest {
|
|||
mPaintRequestTime(aOther.GetPaintRequestTime()),
|
||||
mScrollUpdateType(aScrollUpdateType),
|
||||
mScrollAnimationType(aScrollAnimationType),
|
||||
mLastSnapTargetIds(aLastSnapTargetIds),
|
||||
mIsRootContent(aOther.IsRootContent()),
|
||||
mIsScrollInfoLayer(aOther.IsScrollInfoLayer()) {}
|
||||
|
||||
|
@ -107,7 +104,6 @@ struct RepaintRequest {
|
|||
mPaintRequestTime == aOther.mPaintRequestTime &&
|
||||
mScrollUpdateType == aOther.mScrollUpdateType &&
|
||||
mScrollAnimationType == aOther.mScrollAnimationType &&
|
||||
mLastSnapTargetIds == aOther.mLastSnapTargetIds &&
|
||||
mIsRootContent == aOther.mIsRootContent &&
|
||||
mIsScrollInfoLayer == aOther.mIsScrollInfoLayer;
|
||||
}
|
||||
|
@ -202,10 +198,6 @@ struct RepaintRequest {
|
|||
return mScrollAnimationType;
|
||||
}
|
||||
|
||||
const ScrollSnapTargetIds& GetLastSnapTargetIds() const {
|
||||
return mLastSnapTargetIds;
|
||||
}
|
||||
|
||||
protected:
|
||||
void SetIsRootContent(bool aIsRootContent) {
|
||||
mIsRootContent = aIsRootContent;
|
||||
|
@ -306,8 +298,6 @@ struct RepaintRequest {
|
|||
|
||||
APZScrollAnimationType mScrollAnimationType;
|
||||
|
||||
ScrollSnapTargetIds mLastSnapTargetIds;
|
||||
|
||||
// Whether or not this is the root scroll frame for the root content document.
|
||||
bool mIsRootContent : 1;
|
||||
|
||||
|
|
|
@ -1976,7 +1976,7 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) {
|
|||
CSSPoint destination = GetKeyboardDestination(aEvent.mAction);
|
||||
ScrollOrigin scrollOrigin =
|
||||
SmoothScrollAnimation::GetScrollOriginForAction(aEvent.mAction.mType);
|
||||
Maybe<CSSSnapTarget> snapTarget = MaybeAdjustDestinationForScrollSnapping(
|
||||
bool scrollSnapped = MaybeAdjustDestinationForScrollSnapping(
|
||||
aEvent, destination, GetScrollSnapFlagsForKeyboardAction(aEvent.mAction));
|
||||
ScrollMode scrollMode = apz::GetScrollModeForOrigin(scrollOrigin);
|
||||
|
||||
|
@ -2006,16 +2006,7 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) {
|
|||
distance, ScrollSource::Keyboard);
|
||||
|
||||
CallDispatchScroll(startPoint, endPoint, handoffState);
|
||||
ParentLayerPoint remainingDelta = endPoint - startPoint;
|
||||
if (remainingDelta != delta) {
|
||||
// If any scrolling happened, set KEYBOARD_SCROLL explicitly so that it
|
||||
// will trigger a TransformEnd notification.
|
||||
SetState(KEYBOARD_SCROLL);
|
||||
}
|
||||
|
||||
if (snapTarget) {
|
||||
mLastSnapTargetIds = std::move(snapTarget->mTargetIds);
|
||||
}
|
||||
SetState(NOTHING);
|
||||
|
||||
return nsEventStatus_eConsumeDoDefault;
|
||||
|
@ -2026,13 +2017,13 @@ nsEventStatus AsyncPanZoomController::OnKeyboard(const KeyboardInput& aEvent) {
|
|||
// update it.
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
|
||||
if (snapTarget) {
|
||||
if (scrollSnapped) {
|
||||
// If we're scroll snapping, use a smooth scroll animation to get
|
||||
// the desired physics. Note that SmoothMsdScrollTo() will re-use an
|
||||
// existing smooth scroll animation if there is one.
|
||||
APZC_LOG("%p keyboard scrolling to snap point %s\n", this,
|
||||
ToString(destination).c_str());
|
||||
SmoothMsdScrollTo(std::move(*snapTarget), ScrollTriggeredByScript::No);
|
||||
SmoothMsdScrollTo(destination, ScrollTriggeredByScript::No);
|
||||
return nsEventStatus_eConsumeDoDefault;
|
||||
}
|
||||
|
||||
|
@ -2421,9 +2412,8 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(
|
|||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
startPosition = Metrics().GetVisualScrollOffset();
|
||||
}
|
||||
Maybe<CSSSnapTarget> snapTarget =
|
||||
MaybeAdjustDeltaForScrollSnappingOnWheelInput(aEvent, delta,
|
||||
startPosition);
|
||||
MaybeAdjustDeltaForScrollSnappingOnWheelInput(aEvent, delta,
|
||||
startPosition);
|
||||
|
||||
ScreenPoint distance = ToScreenCoordinates(
|
||||
ParentLayerPoint(fabs(delta.x), fabs(delta.y)), aEvent.mLocalOrigin);
|
||||
|
@ -2436,18 +2426,8 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(
|
|||
ParentLayerPoint startPoint = aEvent.mLocalOrigin;
|
||||
ParentLayerPoint endPoint = aEvent.mLocalOrigin - delta;
|
||||
RecordScrollPayload(aEvent.mTimeStamp);
|
||||
|
||||
CallDispatchScroll(startPoint, endPoint, handoffState);
|
||||
ParentLayerPoint remainingDelta = endPoint - startPoint;
|
||||
if (remainingDelta != delta) {
|
||||
// If any scrolling happened, set WHEEL_SCROLL explicitly so that it
|
||||
// will trigger a TransformEnd notification.
|
||||
SetState(WHEEL_SCROLL);
|
||||
}
|
||||
|
||||
if (snapTarget) {
|
||||
mLastSnapTargetIds = std::move(snapTarget->mTargetIds);
|
||||
}
|
||||
SetState(NOTHING);
|
||||
|
||||
// The calls above handle their own locking; moreover,
|
||||
|
@ -2472,15 +2452,14 @@ nsEventStatus AsyncPanZoomController::OnScrollWheel(
|
|||
CSSPoint startPosition = GetCurrentAnimationDestination(lock).valueOr(
|
||||
Metrics().GetVisualScrollOffset());
|
||||
|
||||
if (Maybe<CSSSnapTarget> snapTarget =
|
||||
MaybeAdjustDeltaForScrollSnappingOnWheelInput(aEvent, delta,
|
||||
startPosition)) {
|
||||
if (MaybeAdjustDeltaForScrollSnappingOnWheelInput(aEvent, delta,
|
||||
startPosition)) {
|
||||
// If we're scroll snapping, use a smooth scroll animation to get
|
||||
// the desired physics. Note that SmoothMsdScrollTo() will re-use an
|
||||
// existing smooth scroll animation if there is one.
|
||||
APZC_LOG("%p wheel scrolling to snap point %s\n", this,
|
||||
ToString(startPosition).c_str());
|
||||
SmoothMsdScrollTo(std::move(*snapTarget), ScrollTriggeredByScript::No);
|
||||
SmoothMsdScrollTo(startPosition, ScrollTriggeredByScript::No);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -3819,14 +3798,12 @@ void AsyncPanZoomController::SmoothScrollTo(const CSSPoint& aDestination,
|
|||
}
|
||||
|
||||
void AsyncPanZoomController::SmoothMsdScrollTo(
|
||||
CSSSnapTarget&& aDestination, ScrollTriggeredByScript aTriggeredByScript) {
|
||||
const CSSPoint& aDestination, ScrollTriggeredByScript aTriggeredByScript) {
|
||||
if (mState == SMOOTHMSD_SCROLL && mAnimation) {
|
||||
APZC_LOG("%p updating destination on existing animation\n", this);
|
||||
RefPtr<SmoothMsdScrollAnimation> animation(
|
||||
static_cast<SmoothMsdScrollAnimation*>(mAnimation.get()));
|
||||
animation->SetDestination(aDestination.mPosition,
|
||||
std::move(aDestination.mTargetIds),
|
||||
aTriggeredByScript);
|
||||
animation->SetDestination(aDestination, aTriggeredByScript);
|
||||
} else {
|
||||
CancelAnimation();
|
||||
SetState(SMOOTHMSD_SCROLL);
|
||||
|
@ -3839,11 +3816,10 @@ void AsyncPanZoomController::SmoothMsdScrollTo(
|
|||
}
|
||||
|
||||
StartAnimation(new SmoothMsdScrollAnimation(
|
||||
*this, Metrics().GetVisualScrollOffset(), initialVelocity,
|
||||
aDestination.mPosition,
|
||||
*this, Metrics().GetVisualScrollOffset(), initialVelocity, aDestination,
|
||||
StaticPrefs::layout_css_scroll_behavior_spring_constant(),
|
||||
StaticPrefs::layout_css_scroll_behavior_damping_ratio(),
|
||||
std::move(aDestination.mTargetIds), aTriggeredByScript));
|
||||
aTriggeredByScript));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3994,7 +3970,6 @@ void AsyncPanZoomController::CancelAnimation(CancelAnimationFlags aFlags) {
|
|||
}
|
||||
|
||||
SetState(NOTHING);
|
||||
mLastSnapTargetIds = ScrollSnapTargetIds{};
|
||||
mAnimation = nullptr;
|
||||
// Since there is no animation in progress now the axes should
|
||||
// have no velocity either. If we are dropping the velocity from a non-zero
|
||||
|
@ -4421,7 +4396,7 @@ void AsyncPanZoomController::RequestContentRepaint(
|
|||
: APZScrollAnimationType::TriggeredByUserInput;
|
||||
}
|
||||
RepaintRequest request(aFrameMetrics, aDisplayportMargins, aUpdateType,
|
||||
animationType, mScrollGeneration, mLastSnapTargetIds);
|
||||
animationType, mScrollGeneration);
|
||||
|
||||
if (request.IsRootContent() && request.GetZoom() != mLastNotifiedZoom &&
|
||||
mState != PINCHING && mState != ANIMATING_ZOOM) {
|
||||
|
@ -4447,9 +4422,7 @@ void AsyncPanZoomController::RequestContentRepaint(
|
|||
request.GetScrollUpdateType() ==
|
||||
mLastPaintRequestMetrics.GetScrollUpdateType() &&
|
||||
request.GetScrollAnimationType() ==
|
||||
mLastPaintRequestMetrics.GetScrollAnimationType() &&
|
||||
request.GetLastSnapTargetIds() ==
|
||||
mLastPaintRequestMetrics.GetLastSnapTargetIds()) {
|
||||
mLastPaintRequestMetrics.GetScrollAnimationType()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -4525,10 +4498,6 @@ bool AsyncPanZoomController::UpdateAnimation(
|
|||
*aOutDeferredTasks = mAnimation->TakeDeferredTasks();
|
||||
if (!continueAnimation) {
|
||||
SetState(NOTHING);
|
||||
if (mAnimation->AsSmoothMsdScrollAnimation()) {
|
||||
mLastSnapTargetIds =
|
||||
mAnimation->AsSmoothMsdScrollAnimation()->TakeSnapTargetIds();
|
||||
}
|
||||
mAnimation = nullptr;
|
||||
}
|
||||
// Request a repaint at the end of the animation in case something such as a
|
||||
|
@ -5336,9 +5305,8 @@ void AsyncPanZoomController::NotifyLayersUpdated(
|
|||
}
|
||||
|
||||
if (scrollUpdate.GetMode() == ScrollMode::SmoothMsd) {
|
||||
SmoothMsdScrollTo(
|
||||
CSSSnapTarget{destination, scrollUpdate.GetSnapTargetIds()},
|
||||
scrollUpdate.GetScrollTriggeredByScript());
|
||||
SmoothMsdScrollTo(destination,
|
||||
scrollUpdate.GetScrollTriggeredByScript());
|
||||
} else {
|
||||
MOZ_ASSERT(scrollUpdate.GetMode() == ScrollMode::Smooth);
|
||||
MOZ_ASSERT(!scrollUpdate.WasTriggeredByScript());
|
||||
|
@ -6106,7 +6074,7 @@ void AsyncPanZoomController::SetTestAsyncZoom(
|
|||
ScheduleComposite();
|
||||
}
|
||||
|
||||
Maybe<CSSSnapTarget> AsyncPanZoomController::FindSnapPointNear(
|
||||
Maybe<CSSPoint> AsyncPanZoomController::FindSnapPointNear(
|
||||
const CSSPoint& aDestination, ScrollUnit aUnit,
|
||||
ScrollSnapFlags aSnapFlags) {
|
||||
mRecursiveMutex.AssertCurrentThreadIn();
|
||||
|
@ -6123,20 +6091,19 @@ Maybe<CSSSnapTarget> AsyncPanZoomController::FindSnapPointNear(
|
|||
// of the scroll frame's scroll range. Clamp it here (this matches the
|
||||
// behaviour of the main-thread code path, which clamps it in
|
||||
// nsGfxScrollFrame::ScrollTo()).
|
||||
return Some(CSSSnapTarget{scrollRange.ClampPoint(cssSnapPoint),
|
||||
snapTarget->mTargetIds});
|
||||
return Some(scrollRange.ClampPoint(cssSnapPoint));
|
||||
}
|
||||
return Nothing();
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::ScrollSnapNear(const CSSPoint& aDestination,
|
||||
ScrollSnapFlags aSnapFlags) {
|
||||
if (Maybe<CSSSnapTarget> snapTarget = FindSnapPointNear(
|
||||
if (Maybe<CSSPoint> snapPoint = FindSnapPointNear(
|
||||
aDestination, ScrollUnit::DEVICE_PIXELS, aSnapFlags)) {
|
||||
if (snapTarget->mPosition != Metrics().GetVisualScrollOffset()) {
|
||||
if (*snapPoint != Metrics().GetVisualScrollOffset()) {
|
||||
APZC_LOG("%p smooth scrolling to snap point %s\n", this,
|
||||
ToString(snapTarget->mPosition).c_str());
|
||||
SmoothMsdScrollTo(std::move(*snapTarget), ScrollTriggeredByScript::No);
|
||||
ToString(*snapPoint).c_str());
|
||||
SmoothMsdScrollTo(*snapPoint, ScrollTriggeredByScript::No);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6175,9 +6142,8 @@ void AsyncPanZoomController::ScrollSnapToDestination() {
|
|||
if (predictedDelta != ParentLayerPoint()) {
|
||||
snapFlags |= ScrollSnapFlags::IntendedDirection;
|
||||
}
|
||||
if (Maybe<CSSSnapTarget> snapTarget = MaybeAdjustDeltaForScrollSnapping(
|
||||
ScrollUnit::DEVICE_PIXELS, snapFlags, predictedDelta,
|
||||
startPosition)) {
|
||||
if (MaybeAdjustDeltaForScrollSnapping(ScrollUnit::DEVICE_PIXELS, snapFlags,
|
||||
predictedDelta, startPosition)) {
|
||||
APZC_LOG(
|
||||
"%p fling snapping. friction: %f velocity: %f, %f "
|
||||
"predictedDelta: %f, %f position: %f, %f "
|
||||
|
@ -6187,38 +6153,37 @@ void AsyncPanZoomController::ScrollSnapToDestination() {
|
|||
(float)Metrics().GetVisualScrollOffset().y, (float)startPosition.x,
|
||||
(float)startPosition.y);
|
||||
|
||||
SmoothMsdScrollTo(std::move(*snapTarget), ScrollTriggeredByScript::No);
|
||||
SmoothMsdScrollTo(startPosition, ScrollTriggeredByScript::No);
|
||||
}
|
||||
}
|
||||
|
||||
Maybe<CSSSnapTarget> AsyncPanZoomController::MaybeAdjustDeltaForScrollSnapping(
|
||||
bool AsyncPanZoomController::MaybeAdjustDeltaForScrollSnapping(
|
||||
ScrollUnit aUnit, ScrollSnapFlags aSnapFlags, ParentLayerPoint& aDelta,
|
||||
CSSPoint& aStartPosition) {
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
CSSToParentLayerScale zoom = Metrics().GetZoom();
|
||||
if (zoom == CSSToParentLayerScale(0)) {
|
||||
return Nothing();
|
||||
return false;
|
||||
}
|
||||
CSSPoint destination = Metrics().CalculateScrollRange().ClampPoint(
|
||||
aStartPosition + (aDelta / zoom));
|
||||
|
||||
if (Maybe<CSSSnapTarget> snapTarget =
|
||||
if (Maybe<CSSPoint> snapPoint =
|
||||
FindSnapPointNear(destination, aUnit, aSnapFlags)) {
|
||||
aDelta = (snapTarget->mPosition - aStartPosition) * zoom;
|
||||
aStartPosition = snapTarget->mPosition;
|
||||
return snapTarget;
|
||||
aDelta = (*snapPoint - aStartPosition) * zoom;
|
||||
aStartPosition = *snapPoint;
|
||||
return true;
|
||||
}
|
||||
return Nothing();
|
||||
return false;
|
||||
}
|
||||
|
||||
Maybe<CSSSnapTarget>
|
||||
AsyncPanZoomController::MaybeAdjustDeltaForScrollSnappingOnWheelInput(
|
||||
bool AsyncPanZoomController::MaybeAdjustDeltaForScrollSnappingOnWheelInput(
|
||||
const ScrollWheelInput& aEvent, ParentLayerPoint& aDelta,
|
||||
CSSPoint& aStartPosition) {
|
||||
// Don't scroll snap for pixel scrolls. This matches the main thread
|
||||
// behaviour in EventStateManager::DoScrollText().
|
||||
if (aEvent.mDeltaType == ScrollWheelInput::SCROLLDELTA_PIXEL) {
|
||||
return Nothing();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Note that this MaybeAdjustDeltaForScrollSnappingOnWheelInput also gets
|
||||
|
@ -6239,19 +6204,18 @@ AsyncPanZoomController::MaybeAdjustDeltaForScrollSnappingOnWheelInput(
|
|||
ScrollSnapFlags::IntendedDirection, aDelta, aStartPosition);
|
||||
}
|
||||
|
||||
Maybe<CSSSnapTarget>
|
||||
AsyncPanZoomController::MaybeAdjustDestinationForScrollSnapping(
|
||||
bool AsyncPanZoomController::MaybeAdjustDestinationForScrollSnapping(
|
||||
const KeyboardInput& aEvent, CSSPoint& aDestination,
|
||||
ScrollSnapFlags aSnapFlags) {
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
ScrollUnit unit = KeyboardScrollAction::GetScrollUnit(aEvent.mAction.mType);
|
||||
|
||||
if (Maybe<CSSSnapTarget> snapPoint =
|
||||
if (Maybe<CSSPoint> snapPoint =
|
||||
FindSnapPointNear(aDestination, unit, aSnapFlags)) {
|
||||
aDestination = snapPoint->mPosition;
|
||||
return snapPoint;
|
||||
aDestination = *snapPoint;
|
||||
return true;
|
||||
}
|
||||
return Nothing();
|
||||
return false;
|
||||
}
|
||||
|
||||
void AsyncPanZoomController::SetZoomAnimationId(
|
||||
|
|
|
@ -1521,7 +1521,7 @@ class AsyncPanZoomController {
|
|||
|
||||
// Start a smooth-scrolling animation to the given destination, with MSD
|
||||
// physics that is suited for scroll-snapping.
|
||||
void SmoothMsdScrollTo(CSSSnapTarget&& aDestination,
|
||||
void SmoothMsdScrollTo(const CSSPoint& aDestination,
|
||||
ScrollTriggeredByScript aTriggeredByScript);
|
||||
|
||||
// Returns whether overscroll is allowed during an event.
|
||||
|
@ -1754,7 +1754,6 @@ class AsyncPanZoomController {
|
|||
// is in a panning state.
|
||||
TimeDuration mTouchStartRestingTimeBeforePan;
|
||||
Maybe<ParentLayerCoord> mMinimumVelocityDuringPan;
|
||||
ScrollSnapTargetIds mLastSnapTargetIds;
|
||||
// Extra offset to add to the async scroll position for testing
|
||||
CSSPoint mTestAsyncScrollOffset;
|
||||
// Extra zoom to include in the aync zoom for testing
|
||||
|
@ -1795,19 +1794,20 @@ class AsyncPanZoomController {
|
|||
// |aUnit| affects the snapping behaviour (see ScrollSnapUtils::
|
||||
// GetSnapPointForDestination).
|
||||
// Returns true iff. a target snap point was found.
|
||||
Maybe<CSSSnapTarget> MaybeAdjustDeltaForScrollSnapping(
|
||||
ScrollUnit aUnit, ScrollSnapFlags aSnapFlags, ParentLayerPoint& aDelta,
|
||||
CSSPoint& aStartPosition);
|
||||
bool MaybeAdjustDeltaForScrollSnapping(ScrollUnit aUnit,
|
||||
ScrollSnapFlags aFlags,
|
||||
ParentLayerPoint& aDelta,
|
||||
CSSPoint& aStartPosition);
|
||||
|
||||
// A wrapper function of MaybeAdjustDeltaForScrollSnapping for
|
||||
// ScrollWheelInput.
|
||||
Maybe<CSSSnapTarget> MaybeAdjustDeltaForScrollSnappingOnWheelInput(
|
||||
bool MaybeAdjustDeltaForScrollSnappingOnWheelInput(
|
||||
const ScrollWheelInput& aEvent, ParentLayerPoint& aDelta,
|
||||
CSSPoint& aStartPosition);
|
||||
|
||||
Maybe<CSSSnapTarget> MaybeAdjustDestinationForScrollSnapping(
|
||||
const KeyboardInput& aEvent, CSSPoint& aDestination,
|
||||
ScrollSnapFlags aSnapFlags);
|
||||
bool MaybeAdjustDestinationForScrollSnapping(const KeyboardInput& aEvent,
|
||||
CSSPoint& aDestination,
|
||||
ScrollSnapFlags aSnapFlags);
|
||||
|
||||
// Snap to a snap position nearby the current scroll position, if appropriate.
|
||||
void ScrollSnap(ScrollSnapFlags aSnapFlags);
|
||||
|
@ -1824,9 +1824,9 @@ class AsyncPanZoomController {
|
|||
// |aUnit| affects the snapping behaviour (see ScrollSnapUtils::
|
||||
// GetSnapPointForDestination). It should generally be determined by the
|
||||
// type of event that's triggering the scroll.
|
||||
Maybe<CSSSnapTarget> FindSnapPointNear(const CSSPoint& aDestination,
|
||||
ScrollUnit aUnit,
|
||||
ScrollSnapFlags aSnapFlags);
|
||||
Maybe<CSSPoint> FindSnapPointNear(const CSSPoint& aDestination,
|
||||
ScrollUnit aUnit,
|
||||
ScrollSnapFlags aSnapFlags);
|
||||
|
||||
friend std::ostream& operator<<(
|
||||
std::ostream& aOut, const AsyncPanZoomController::PanZoomState& aState);
|
||||
|
|
|
@ -13,14 +13,12 @@ SmoothMsdScrollAnimation::SmoothMsdScrollAnimation(
|
|||
AsyncPanZoomController& aApzc, const CSSPoint& aInitialPosition,
|
||||
const CSSPoint& aInitialVelocity, const CSSPoint& aDestination,
|
||||
double aSpringConstant, double aDampingRatio,
|
||||
ScrollSnapTargetIds&& aSnapTargetIds,
|
||||
ScrollTriggeredByScript aTriggeredByScript)
|
||||
: mApzc(aApzc),
|
||||
mXAxisModel(aInitialPosition.x, aDestination.x, aInitialVelocity.x,
|
||||
aSpringConstant, aDampingRatio),
|
||||
mYAxisModel(aInitialPosition.y, aDestination.y, aInitialVelocity.y,
|
||||
aSpringConstant, aDampingRatio),
|
||||
mSnapTargetIds(std::move(aSnapTargetIds)),
|
||||
mTriggeredByScript(aTriggeredByScript) {}
|
||||
|
||||
bool SmoothMsdScrollAnimation::DoSample(FrameMetrics& aFrameMetrics,
|
||||
|
@ -118,11 +116,10 @@ bool SmoothMsdScrollAnimation::DoSample(FrameMetrics& aFrameMetrics,
|
|||
}
|
||||
|
||||
void SmoothMsdScrollAnimation::SetDestination(
|
||||
const CSSPoint& aNewDestination, ScrollSnapTargetIds&& aSnapTargetIds,
|
||||
const CSSPoint& aNewDestination,
|
||||
ScrollTriggeredByScript aTriggeredByScript) {
|
||||
mXAxisModel.SetDestination(aNewDestination.x);
|
||||
mYAxisModel.SetDestination(aNewDestination.y);
|
||||
mSnapTargetIds = std::move(aSnapTargetIds);
|
||||
mTriggeredByScript = aTriggeredByScript;
|
||||
}
|
||||
|
||||
|
|
|
@ -23,7 +23,6 @@ class SmoothMsdScrollAnimation final : public AsyncPanZoomAnimation {
|
|||
const CSSPoint& aInitialVelocity,
|
||||
const CSSPoint& aDestination, double aSpringConstant,
|
||||
double aDampingRatio,
|
||||
ScrollSnapTargetIds&& aSnapTargetIds,
|
||||
ScrollTriggeredByScript aTriggeredByScript);
|
||||
|
||||
/**
|
||||
|
@ -36,7 +35,6 @@ class SmoothMsdScrollAnimation final : public AsyncPanZoomAnimation {
|
|||
const TimeDuration& aDelta) override;
|
||||
|
||||
void SetDestination(const CSSPoint& aNewDestination,
|
||||
ScrollSnapTargetIds&& aSnapTargetIds,
|
||||
ScrollTriggeredByScript aTriggeredByScript);
|
||||
CSSPoint GetDestination() const;
|
||||
SmoothMsdScrollAnimation* AsSmoothMsdScrollAnimation() override;
|
||||
|
@ -45,13 +43,10 @@ class SmoothMsdScrollAnimation final : public AsyncPanZoomAnimation {
|
|||
return mTriggeredByScript == ScrollTriggeredByScript::Yes;
|
||||
}
|
||||
|
||||
ScrollSnapTargetIds TakeSnapTargetIds() { return std::move(mSnapTargetIds); }
|
||||
|
||||
private:
|
||||
AsyncPanZoomController& mApzc;
|
||||
AxisPhysicsMSDModel mXAxisModel;
|
||||
AxisPhysicsMSDModel mYAxisModel;
|
||||
ScrollSnapTargetIds mSnapTargetIds;
|
||||
ScrollTriggeredByScript mTriggeredByScript;
|
||||
};
|
||||
|
||||
|
|
|
@ -77,18 +77,6 @@ function nativeArrowDownKey() {
|
|||
);
|
||||
}
|
||||
|
||||
function nativeArrowUpKey() {
|
||||
switch (getPlatform()) {
|
||||
case "windows":
|
||||
return WIN_VK_UP;
|
||||
case "mac":
|
||||
return MAC_VK_UpArrow;
|
||||
}
|
||||
throw new Error(
|
||||
"Native key events not supported on platform " + getPlatform()
|
||||
);
|
||||
}
|
||||
|
||||
// Given an event target which may be a window or an element, get the associated window.
|
||||
function windowForTarget(aTarget) {
|
||||
if (aTarget.Window && aTarget instanceof aTarget.Window) {
|
||||
|
|
|
@ -1,81 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Re-snapping to the last snapped element on APZ</title>
|
||||
<script src="apz_test_utils.js"></script>
|
||||
<script src="apz_test_native_event_utils.js"></script>
|
||||
<script src="/tests/SimpleTest/paint_listener.js"></script>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
div {
|
||||
position: absolute;
|
||||
}
|
||||
#scroller {
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
overflow-y: scroll;
|
||||
scroll-snap-type: y proximity; /* to escape from the last snap point */
|
||||
}
|
||||
.child {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
background-color: blue;
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="scroller">
|
||||
<div class="child" style="top: 0px;"></div>
|
||||
<div class="child" style="top: 200px;"></div>
|
||||
<div id="spacer" style="width: 100%; height: 2000px;"></div>
|
||||
</div>
|
||||
<script type="application/javascript">
|
||||
async function test() {
|
||||
const proximityThreshold =
|
||||
SpecialPowers.getIntPref("layout.css.scroll-snap.proximity-threshold");
|
||||
|
||||
let transformEndPromise = promiseTransformEnd();
|
||||
await promiseMoveMouseAndScrollWheelOver(scroller, 100, 100);
|
||||
|
||||
await transformEndPromise;
|
||||
await promiseApzFlushedRepaints();
|
||||
|
||||
is(scroller.scrollTop, 200, "snap to 200px");
|
||||
|
||||
document.querySelectorAll(".child")[1].style.top = "400px";
|
||||
is(scroller.scrollTop, 400, "re-snap to 400px");
|
||||
|
||||
// Make sure the new snap position has been reflected in APZ side.
|
||||
await promiseApzFlushedRepaints();
|
||||
|
||||
// Now trigger another wheel scroll to escape from the last snap point.
|
||||
transformEndPromise = promiseTransformEnd();
|
||||
// With a small `layout.css.scroll-behavior.spring-constant` preference
|
||||
// value (it's set in test_group_scroll_snap.html), an async scroll
|
||||
// operation, e.g. a wheel scroll operation, fires multiple scroll events
|
||||
// so that here we wait the first scroll event here by specifying
|
||||
// `waitForScroll=true`, there should be other scroll events after the
|
||||
// first one.
|
||||
await promiseMoveMouseAndScrollWheelOver(scroller, 100, 100,
|
||||
true /* waitForScroll */, proximityThreshold + 1000);
|
||||
|
||||
// Expand the scrollable region during the wheel scroll.
|
||||
spacer.style.height = "2200px";
|
||||
|
||||
await transformEndPromise;
|
||||
await promiseApzFlushedRepaints();
|
||||
|
||||
isnot(scroller.scrollTop, 400, "Do not re-snap to the original 400px point");
|
||||
}
|
||||
|
||||
waitUntilApzStable()
|
||||
.then(test)
|
||||
.then(subtestDone, subtestFailed);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,72 +0,0 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Re-snapping to the last snapped element on APZ</title>
|
||||
<script src="apz_test_utils.js"></script>
|
||||
<script src="apz_test_native_event_utils.js"></script>
|
||||
<script src="/tests/SimpleTest/paint_listener.js"></script>
|
||||
<style>
|
||||
body {
|
||||
margin: 0;
|
||||
}
|
||||
div {
|
||||
position: absolute;
|
||||
}
|
||||
#scroller {
|
||||
width: 100%;
|
||||
height: 500px;
|
||||
overflow-y: scroll;
|
||||
scroll-snap-type: y proximity; /* to escape from the last snap point */
|
||||
}
|
||||
.child {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
background-color: blue;
|
||||
scroll-snap-align: start;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<div id="scroller">
|
||||
<div class="child" style="top: 0px;"></div>
|
||||
<div class="child" style="top: 200px;"></div>
|
||||
<div id="spacer" style="width: 100%; height: 2000px;"></div>
|
||||
</div>
|
||||
<script type="application/javascript">
|
||||
async function test() {
|
||||
const proximityThreshold =
|
||||
SpecialPowers.getIntPref("layout.css.scroll-snap.proximity-threshold");
|
||||
|
||||
let transformEndPromise = promiseTransformEnd();
|
||||
scroller.scrollBy({left: 0, top: 100, behavior: "smooth"});
|
||||
|
||||
await transformEndPromise;
|
||||
await promiseApzFlushedRepaints();
|
||||
|
||||
is(scroller.scrollTop, 200, "snap to 200px");
|
||||
|
||||
document.querySelectorAll(".child")[1].style.top = "400px";
|
||||
is(scroller.scrollTop, 400, "re-snap to 400px");
|
||||
|
||||
// Now trigger another async scroll to escape from the last snap point.
|
||||
transformEndPromise = promiseTransformEnd();
|
||||
scroller.scrollBy({left: 0, top: proximityThreshold + 100,
|
||||
behavior: "smooth"});
|
||||
|
||||
// Expand the scrollable region during the async scroll.
|
||||
spacer.style.height = "2200px";
|
||||
|
||||
await transformEndPromise;
|
||||
await promiseApzFlushedRepaints();
|
||||
|
||||
isnot(scroller.scrollTop, 400, "Do not re-snap to the original 400px point");
|
||||
}
|
||||
|
||||
waitUntilApzStable()
|
||||
.then(test)
|
||||
.then(subtestDone, subtestFailed);
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
|
@ -1,48 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<script src="apz_test_utils.js"></script>
|
||||
<script src="apz_test_native_event_utils.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/NativeKeyCodes.js"></script>
|
||||
<script src="/tests/SimpleTest/paint_listener.js"></script>
|
||||
<style>
|
||||
html, body { margin: 0; }
|
||||
|
||||
body {
|
||||
height: 10000px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
async function test() {
|
||||
// Send a native key event which doesn't cause any scroll, so that now
|
||||
// subsequent native key events will be able to be handled by APZ. See bug
|
||||
// 1774519 about what happens without this event.
|
||||
const UpArrowKeyCode = nativeArrowUpKey();
|
||||
await new Promise(resolve => {
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US,
|
||||
UpArrowKeyCode, {} /* no modifier */,
|
||||
"", "", resolve); });
|
||||
|
||||
const transformEndPromise = promiseTransformEnd();
|
||||
const DownArrowKeyCode = nativeArrowDownKey();
|
||||
await new Promise(resolve => {
|
||||
synthesizeNativeKey(KEYBOARD_LAYOUT_EN_US,
|
||||
DownArrowKeyCode, {} /* no modifier */,
|
||||
"", "", resolve); });
|
||||
await transformEndPromise;
|
||||
ok(true, "Got an APZ:TransformEnd ");
|
||||
}
|
||||
|
||||
if (getPlatform() == "mac" || getPlatform() == "windows") {
|
||||
waitUntilApzStable()
|
||||
.then(test)
|
||||
.then(subtestDone, subtestFailed);
|
||||
} else {
|
||||
ok(true, "Skipping test because native key events are not supported on " +
|
||||
getPlatform());
|
||||
subtestDone();
|
||||
}
|
||||
</script>
|
|
@ -1,28 +0,0 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<meta charset="utf-8">
|
||||
<script src="apz_test_utils.js"></script>
|
||||
<script src="apz_test_native_event_utils.js"></script>
|
||||
<script src="/tests/SimpleTest/EventUtils.js"></script>
|
||||
<script src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<script src="/tests/SimpleTest/paint_listener.js"></script>
|
||||
<style>
|
||||
html, body { margin: 0; }
|
||||
|
||||
body {
|
||||
height: 10000px;
|
||||
}
|
||||
</style>
|
||||
|
||||
<script>
|
||||
async function test() {
|
||||
let transformEndPromise = promiseTransformEnd();
|
||||
await promiseMoveMouseAndScrollWheelOver(document.documentElement, 100, 100);
|
||||
|
||||
await transformEndPromise;
|
||||
ok(true, "Got an APZ:TransformEnd ");
|
||||
}
|
||||
waitUntilApzStable()
|
||||
.then(test)
|
||||
.then(subtestDone, subtestFailed);
|
||||
</script>
|
|
@ -38,8 +38,6 @@ var subtests = [
|
|||
{"file": "helper_scroll_snap_on_page_down_scroll.html"},
|
||||
{"file": "helper_scroll_snap_on_page_down_scroll.html",
|
||||
prefs: [["test.events.async.enabled", true]]},
|
||||
{"file": "helper_transform_end_on_keyboard_scroll.html",
|
||||
prefs: [["general.smoothScroll", false]] },
|
||||
];
|
||||
|
||||
if (isKeyApzEnabled()) {
|
||||
|
|
|
@ -19,18 +19,6 @@ const prefs = [
|
|||
|
||||
const subtests = [
|
||||
{"file": "helper_scroll_snap_no_valid_snap_position.html", "prefs": prefs},
|
||||
{"file": "helper_scroll_snap_resnap_after_async_scroll.html",
|
||||
// Specify a small `layout.css.scroll-behavior.spring-constant` value to
|
||||
// keep the smooth scroll animation running long enough so that we can
|
||||
// trigger a reflow during the animation.
|
||||
"prefs": [["layout.css.scroll-behavior.spring-constant", 10],
|
||||
["apz.test.mac.synth_wheel_input", true]]},
|
||||
{"file": "helper_scroll_snap_resnap_after_async_scroll.html",
|
||||
"prefs": [["general.smoothScroll", false],
|
||||
["apz.test.mac.synth_wheel_input", true]]},
|
||||
{"file": "helper_scroll_snap_resnap_after_async_scrollBy.html",
|
||||
// Same as above helper_scroll_snap_resnap_after_async_scroll.html.
|
||||
"prefs": [["layout.css.scroll-behavior.spring-constant", 10]]},
|
||||
];
|
||||
|
||||
if (isApzEnabled()) {
|
||||
|
|
|
@ -58,8 +58,6 @@ var subtests = [
|
|||
{"file": "helper_relative_scroll_smoothness.html?input-type=wheel&scroll-method=scrollBy", prefs: smoothness_prefs },
|
||||
{"file": "helper_relative_scroll_smoothness.html?input-type=wheel&scroll-method=scrollTo", prefs: smoothness_prefs },
|
||||
{"file": "helper_relative_scroll_smoothness.html?input-type=wheel&scroll-method=scrollTop", prefs: smoothness_prefs },
|
||||
{"file": "helper_transform_end_on_wheel_scroll.html",
|
||||
prefs: [["general.smoothScroll", false]] },
|
||||
];
|
||||
|
||||
// Only Windows has the test api implemented for this test.
|
||||
|
|
|
@ -129,9 +129,7 @@ static CSSPoint ScrollFrameTo(nsIScrollableFrame* aFrame,
|
|||
// request because we'll clobber that one, which is bad.
|
||||
bool scrollInProgress = APZCCallbackHelper::IsScrollInProgress(aFrame);
|
||||
if (!scrollInProgress) {
|
||||
ScrollSnapTargetIds snapTargetIds = aRequest.GetLastSnapTargetIds();
|
||||
aFrame->ScrollToCSSPixelsForApz(targetScrollPosition,
|
||||
std::move(snapTargetIds));
|
||||
aFrame->ScrollToCSSPixelsForApz(targetScrollPosition);
|
||||
geckoScrollPosition = CSSPoint::FromAppUnits(aFrame->GetScrollPosition());
|
||||
aSuccessOut = true;
|
||||
}
|
||||
|
@ -389,9 +387,7 @@ void APZCCallbackHelper::UpdateRootFrame(const RepaintRequest& aRequest) {
|
|||
nsLayoutUtils::FindScrollableFrameFor(aRequest.GetScrollId());
|
||||
CSSPoint currentScrollPosition =
|
||||
CSSPoint::FromAppUnits(sf->GetScrollPosition());
|
||||
ScrollSnapTargetIds snapTargetIds = aRequest.GetLastSnapTargetIds();
|
||||
sf->ScrollToCSSPixelsForApz(currentScrollPosition,
|
||||
std::move(snapTargetIds));
|
||||
sf->ScrollToCSSPixelsForApz(currentScrollPosition);
|
||||
}
|
||||
|
||||
// Do this as late as possible since scrolling can flush layout. It also
|
||||
|
|
|
@ -305,21 +305,6 @@ struct ParamTraits<mozilla::APZScrollAnimationType>
|
|||
mozilla::APZScrollAnimationType, mozilla::APZScrollAnimationType::No,
|
||||
mozilla::APZScrollAnimationType::TriggeredByUserInput> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::ScrollSnapTargetIds> {
|
||||
typedef mozilla::ScrollSnapTargetIds paramType;
|
||||
|
||||
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
||||
WriteParam(aWriter, aParam.mIdsOnX);
|
||||
WriteParam(aWriter, aParam.mIdsOnY);
|
||||
}
|
||||
|
||||
static bool Read(MessageReader* aReader, paramType* aResult) {
|
||||
return ReadParam(aReader, &aResult->mIdsOnX) &&
|
||||
ReadParam(aReader, &aResult->mIdsOnY);
|
||||
}
|
||||
};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::layers::RepaintRequest>
|
||||
: BitfieldHelper<mozilla::layers::RepaintRequest> {
|
||||
|
@ -342,7 +327,6 @@ struct ParamTraits<mozilla::layers::RepaintRequest>
|
|||
WriteParam(aWriter, aParam.mPaintRequestTime);
|
||||
WriteParam(aWriter, aParam.mScrollUpdateType);
|
||||
WriteParam(aWriter, aParam.mScrollAnimationType);
|
||||
WriteParam(aWriter, aParam.mLastSnapTargetIds);
|
||||
WriteParam(aWriter, aParam.mIsRootContent);
|
||||
WriteParam(aWriter, aParam.mIsScrollInfoLayer);
|
||||
}
|
||||
|
@ -365,7 +349,6 @@ struct ParamTraits<mozilla::layers::RepaintRequest>
|
|||
ReadParam(aReader, &aResult->mPaintRequestTime) &&
|
||||
ReadParam(aReader, &aResult->mScrollUpdateType) &&
|
||||
ReadParam(aReader, &aResult->mScrollAnimationType) &&
|
||||
ReadParam(aReader, &aResult->mLastSnapTargetIds) &&
|
||||
ReadBoolForBitfield(aReader, aResult, ¶mType::SetIsRootContent) &&
|
||||
ReadBoolForBitfield(aReader, aResult,
|
||||
¶mType::SetIsScrollInfoLayer));
|
||||
|
@ -481,58 +464,8 @@ struct ParamTraits<mozilla::ScrollGeneration<T>>
|
|||
: PlainOldDataSerializer<mozilla::ScrollGeneration<T>> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::ScrollUpdateType>
|
||||
: public ContiguousEnumSerializerInclusive<
|
||||
mozilla::ScrollUpdateType, mozilla::ScrollUpdateType::Absolute,
|
||||
mozilla::ScrollUpdateType::PureRelative> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::ScrollMode>
|
||||
: public ContiguousEnumSerializerInclusive<mozilla::ScrollMode,
|
||||
mozilla::ScrollMode::Instant,
|
||||
mozilla::ScrollMode::Normal> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::ScrollOrigin>
|
||||
: public ContiguousEnumSerializerInclusive<
|
||||
mozilla::ScrollOrigin, mozilla::ScrollOrigin::None,
|
||||
mozilla::ScrollOrigin::Scrollbars> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::ScrollTriggeredByScript>
|
||||
: public ContiguousEnumSerializerInclusive<
|
||||
mozilla::ScrollTriggeredByScript,
|
||||
mozilla::ScrollTriggeredByScript::No,
|
||||
mozilla::ScrollTriggeredByScript::Yes> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::ScrollPositionUpdate> {
|
||||
typedef mozilla::ScrollPositionUpdate paramType;
|
||||
|
||||
static void Write(MessageWriter* aWriter, const paramType& aParam) {
|
||||
WriteParam(aWriter, aParam.mScrollGeneration);
|
||||
WriteParam(aWriter, aParam.mType);
|
||||
WriteParam(aWriter, aParam.mScrollMode);
|
||||
WriteParam(aWriter, aParam.mScrollOrigin);
|
||||
WriteParam(aWriter, aParam.mDestination);
|
||||
WriteParam(aWriter, aParam.mSource);
|
||||
WriteParam(aWriter, aParam.mDelta);
|
||||
WriteParam(aWriter, aParam.mTriggeredByScript);
|
||||
WriteParam(aWriter, aParam.mSnapTargetIds);
|
||||
}
|
||||
|
||||
static bool Read(MessageReader* aReader, paramType* aResult) {
|
||||
return ReadParam(aReader, &aResult->mScrollGeneration) &&
|
||||
ReadParam(aReader, &aResult->mType) &&
|
||||
ReadParam(aReader, &aResult->mScrollMode) &&
|
||||
ReadParam(aReader, &aResult->mScrollOrigin) &&
|
||||
ReadParam(aReader, &aResult->mDestination) &&
|
||||
ReadParam(aReader, &aResult->mSource) &&
|
||||
ReadParam(aReader, &aResult->mDelta) &&
|
||||
ReadParam(aReader, &aResult->mTriggeredByScript) &&
|
||||
ReadParam(aReader, &aResult->mSnapTargetIds);
|
||||
}
|
||||
};
|
||||
struct ParamTraits<mozilla::ScrollPositionUpdate>
|
||||
: PlainOldDataSerializer<mozilla::ScrollPositionUpdate> {};
|
||||
|
||||
template <>
|
||||
struct ParamTraits<mozilla::layers::ScrollMetadata>
|
||||
|
|
|
@ -59,8 +59,7 @@ ScrollPositionUpdate ScrollPositionUpdate::NewRelativeScroll(
|
|||
/*static*/
|
||||
ScrollPositionUpdate ScrollPositionUpdate::NewSmoothScroll(
|
||||
ScrollOrigin aOrigin, nsPoint aDestination,
|
||||
ScrollTriggeredByScript aTriggeredByScript,
|
||||
UniquePtr<ScrollSnapTargetIds> aSnapTargetIds) {
|
||||
ScrollTriggeredByScript aTriggeredByScript) {
|
||||
MOZ_ASSERT(aOrigin != ScrollOrigin::NotSpecified);
|
||||
MOZ_ASSERT(aOrigin != ScrollOrigin::None);
|
||||
|
||||
|
@ -71,9 +70,6 @@ ScrollPositionUpdate ScrollPositionUpdate::NewSmoothScroll(
|
|||
ret.mScrollOrigin = aOrigin;
|
||||
ret.mDestination = CSSPoint::FromAppUnits(aDestination);
|
||||
ret.mTriggeredByScript = aTriggeredByScript;
|
||||
if (aSnapTargetIds) {
|
||||
ret.mSnapTargetIds = *aSnapTargetIds;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,15 +11,9 @@
|
|||
#include "nsPoint.h"
|
||||
#include "mozilla/ScrollGeneration.h"
|
||||
#include "mozilla/ScrollOrigin.h"
|
||||
#include "mozilla/ScrollSnapTargetId.h"
|
||||
#include "mozilla/ScrollTypes.h"
|
||||
#include "Units.h"
|
||||
|
||||
namespace IPC {
|
||||
template <typename T>
|
||||
struct ParamTraits;
|
||||
} // namespace IPC
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
enum class ScrollUpdateType {
|
||||
|
@ -47,8 +41,6 @@ enum class ScrollTriggeredByScript : bool { No, Yes };
|
|||
* occurred independently on the compositor side.
|
||||
*/
|
||||
class ScrollPositionUpdate {
|
||||
friend struct IPC::ParamTraits<mozilla::ScrollPositionUpdate>;
|
||||
|
||||
public:
|
||||
// Constructor for IPC use only.
|
||||
explicit ScrollPositionUpdate();
|
||||
|
@ -67,15 +59,9 @@ class ScrollPositionUpdate {
|
|||
// Create a ScrollPositionUpdate for a new absolute/smooth scroll, which
|
||||
// animates smoothly to the given destination from whatever the current
|
||||
// scroll position is in the receiver.
|
||||
// If the smooth operation involves snapping to |aDestination|,
|
||||
// |aSnapTargetIds| has snap-target-ids for snapping. Once after this smooth
|
||||
// scroll finished on the target APZC, the ids will be reported back to the
|
||||
// main-thread as the last snap target ids which will be used for re-snapping
|
||||
// to the same snapped element(s).
|
||||
static ScrollPositionUpdate NewSmoothScroll(
|
||||
ScrollOrigin aOrigin, nsPoint aDestination,
|
||||
ScrollTriggeredByScript aTriggeredByScript,
|
||||
UniquePtr<ScrollSnapTargetIds> aSnapTargetIds);
|
||||
ScrollTriggeredByScript aTriggeredByScript);
|
||||
// Create a ScrollPositionUpdate for a new pure-relative scroll. The
|
||||
// aMode parameter controls whether or not this is a smooth animation or
|
||||
// instantaneous scroll.
|
||||
|
@ -103,7 +89,6 @@ class ScrollPositionUpdate {
|
|||
bool WasTriggeredByScript() const {
|
||||
return mTriggeredByScript == ScrollTriggeredByScript::Yes;
|
||||
}
|
||||
const ScrollSnapTargetIds& GetSnapTargetIds() const { return mSnapTargetIds; }
|
||||
|
||||
friend std::ostream& operator<<(std::ostream& aStream,
|
||||
const ScrollPositionUpdate& aUpdate);
|
||||
|
@ -122,7 +107,6 @@ class ScrollPositionUpdate {
|
|||
// mDelta is not populated when mType == Absolute || mType == Relative.
|
||||
CSSPoint mDelta;
|
||||
ScrollTriggeredByScript mTriggeredByScript;
|
||||
ScrollSnapTargetIds mSnapTargetIds;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
|
|
@ -8,7 +8,6 @@
|
|||
#include <cstdint>
|
||||
#include "nsPoint.h"
|
||||
#include "nsTArray.h"
|
||||
#include "Units.h"
|
||||
|
||||
namespace mozilla {
|
||||
|
||||
|
@ -21,9 +20,6 @@ enum class ScrollSnapTargetId : uintptr_t {
|
|||
struct ScrollSnapTargetIds {
|
||||
CopyableTArray<ScrollSnapTargetId> mIdsOnX;
|
||||
CopyableTArray<ScrollSnapTargetId> mIdsOnY;
|
||||
bool operator==(const ScrollSnapTargetIds& aOther) const {
|
||||
return mIdsOnX == aOther.mIdsOnX && mIdsOnY == aOther.mIdsOnY;
|
||||
}
|
||||
};
|
||||
|
||||
struct SnapTarget {
|
||||
|
@ -31,11 +27,6 @@ struct SnapTarget {
|
|||
ScrollSnapTargetIds mTargetIds;
|
||||
};
|
||||
|
||||
struct CSSSnapTarget {
|
||||
CSSPoint mPosition;
|
||||
ScrollSnapTargetIds mTargetIds;
|
||||
};
|
||||
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_ScrollSnapTargetId_h_
|
||||
|
|
|
@ -2530,15 +2530,14 @@ void ScrollFrameHelper::ScrollToCSSPixels(const CSSIntPoint& aScrollPosition,
|
|||
}
|
||||
|
||||
void ScrollFrameHelper::ScrollToCSSPixelsForApz(
|
||||
const CSSPoint& aScrollPosition, ScrollSnapTargetIds&& aLastSnapTargetIds) {
|
||||
const CSSPoint& aScrollPosition) {
|
||||
nsPoint pt = CSSPoint::ToAppUnits(aScrollPosition);
|
||||
nscoord halfRange = nsPresContext::CSSPixelsToAppUnits(1000);
|
||||
nsRect range(pt.x - halfRange, pt.y - halfRange, 2 * halfRange - 1,
|
||||
2 * halfRange - 1);
|
||||
ScrollToWithOrigin(
|
||||
pt, &range,
|
||||
ScrollOperationParams{ScrollMode::Instant, ScrollOrigin::Apz,
|
||||
std::move(aLastSnapTargetIds)});
|
||||
ScrollOperationParams{ScrollMode::Instant, ScrollOrigin::Apz});
|
||||
// 'this' might be destroyed here
|
||||
}
|
||||
|
||||
|
@ -2634,7 +2633,7 @@ void ScrollFrameHelper::ScrollToWithOrigin(nsPoint aScrollPosition,
|
|||
|
||||
if (nsLayoutUtils::AsyncPanZoomEnabled(mOuter) && WantAsyncScroll()) {
|
||||
ApzSmoothScrollTo(mDestination, aParams.mOrigin,
|
||||
aParams.mTriggeredByScript, std::move(snapTargetIds));
|
||||
aParams.mTriggeredByScript);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -8041,11 +8040,6 @@ bool ScrollFrameHelper::IsLastSnappedTarget(const nsIFrame* aFrame) const {
|
|||
}
|
||||
|
||||
void ScrollFrameHelper::TryResnap() {
|
||||
// If there's any async scroll is running, don't clobber the scroll.
|
||||
if (!ScrollAnimationState().isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (auto snapTarget = GetSnapPointForResnap()) {
|
||||
// We are going to re-snap so that we need to clobber scroll anchoring.
|
||||
mAnchor.UserScrolled();
|
||||
|
@ -8186,8 +8180,7 @@ void ScrollFrameHelper::AsyncScrollbarDragRejected() {
|
|||
|
||||
void ScrollFrameHelper::ApzSmoothScrollTo(
|
||||
const nsPoint& aDestination, ScrollOrigin aOrigin,
|
||||
ScrollTriggeredByScript aTriggeredByScript,
|
||||
UniquePtr<ScrollSnapTargetIds> aSnapTargetIds) {
|
||||
ScrollTriggeredByScript aTriggeredByScript) {
|
||||
if (mApzSmoothScrollDestination == Some(aDestination)) {
|
||||
// If we already sent APZ a smooth-scroll request to this
|
||||
// destination (i.e. it was the last request
|
||||
|
@ -8209,7 +8202,7 @@ void ScrollFrameHelper::ApzSmoothScrollTo(
|
|||
MOZ_ASSERT(aOrigin != ScrollOrigin::None);
|
||||
mApzSmoothScrollDestination = Some(aDestination);
|
||||
AppendScrollUpdate(ScrollPositionUpdate::NewSmoothScroll(
|
||||
aOrigin, aDestination, aTriggeredByScript, std::move(aSnapTargetIds)));
|
||||
aOrigin, aDestination, aTriggeredByScript));
|
||||
|
||||
nsIContent* content = mOuter->GetContent();
|
||||
if (!DisplayPortUtils::HasNonMinimalNonZeroDisplayPort(content)) {
|
||||
|
@ -8260,13 +8253,12 @@ bool ScrollFrameHelper::SmoothScrollVisual(
|
|||
// smooth scroll destination to send to APZ.
|
||||
mDestination = GetVisualScrollRange().ClampPoint(aVisualViewportOffset);
|
||||
|
||||
UniquePtr<ScrollSnapTargetIds> snapTargetIds;
|
||||
// Perform the scroll.
|
||||
ApzSmoothScrollTo(mDestination,
|
||||
aUpdateType == FrameMetrics::eRestore
|
||||
? ScrollOrigin::Restore
|
||||
: ScrollOrigin::Other,
|
||||
ScrollTriggeredByScript::No, std::move(snapTargetIds));
|
||||
ScrollTriggeredByScript::No);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -274,9 +274,7 @@ class ScrollFrameHelper : public nsIReflowCallback {
|
|||
/**
|
||||
* @note This method might destroy the frame, pres shell and other objects.
|
||||
*/
|
||||
void ScrollToCSSPixelsForApz(
|
||||
const mozilla::CSSPoint& aScrollPosition,
|
||||
mozilla::ScrollSnapTargetIds&& aLastSnapTargetIds);
|
||||
void ScrollToCSSPixelsForApz(const mozilla::CSSPoint& aScrollPosition);
|
||||
|
||||
CSSIntPoint GetScrollPositionCSSPixels();
|
||||
/**
|
||||
|
@ -879,8 +877,7 @@ class ScrollFrameHelper : public nsIReflowCallback {
|
|||
// either the layout or the visual scroll range (APZ will happily smooth
|
||||
// scroll to either).
|
||||
void ApzSmoothScrollTo(const nsPoint& aDestination, ScrollOrigin aOrigin,
|
||||
ScrollTriggeredByScript aTriggeredByScript,
|
||||
UniquePtr<ScrollSnapTargetIds> aSnapTargetIds);
|
||||
ScrollTriggeredByScript aTriggeredByScript);
|
||||
|
||||
// Removes any RefreshDriver observers we might have registered.
|
||||
void RemoveObservers();
|
||||
|
@ -1105,11 +1102,8 @@ class nsHTMLScrollFrame : public nsContainerFrame,
|
|||
ScrollMode aMode = ScrollMode::Instant) final {
|
||||
mHelper.ScrollToCSSPixels(aScrollPosition, aMode);
|
||||
}
|
||||
void ScrollToCSSPixelsForApz(
|
||||
const mozilla::CSSPoint& aScrollPosition,
|
||||
mozilla::ScrollSnapTargetIds&& aLastSnapTargetIds) final {
|
||||
mHelper.ScrollToCSSPixelsForApz(aScrollPosition,
|
||||
std::move(aLastSnapTargetIds));
|
||||
void ScrollToCSSPixelsForApz(const mozilla::CSSPoint& aScrollPosition) final {
|
||||
mHelper.ScrollToCSSPixelsForApz(aScrollPosition);
|
||||
}
|
||||
/**
|
||||
* @note This method might destroy the frame, pres shell and other objects.
|
||||
|
@ -1587,11 +1581,8 @@ class nsXULScrollFrame final : public nsBoxFrame,
|
|||
ScrollMode aMode = ScrollMode::Instant) final {
|
||||
mHelper.ScrollToCSSPixels(aScrollPosition, aMode);
|
||||
}
|
||||
void ScrollToCSSPixelsForApz(
|
||||
const mozilla::CSSPoint& aScrollPosition,
|
||||
mozilla::ScrollSnapTargetIds&& aLastSnapTargetIds) final {
|
||||
mHelper.ScrollToCSSPixelsForApz(aScrollPosition,
|
||||
std::move(aLastSnapTargetIds));
|
||||
void ScrollToCSSPixelsForApz(const mozilla::CSSPoint& aScrollPosition) final {
|
||||
mHelper.ScrollToCSSPixelsForApz(aScrollPosition);
|
||||
}
|
||||
CSSIntPoint GetScrollPositionCSSPixels() final {
|
||||
return mHelper.GetScrollPositionCSSPixels();
|
||||
|
|
|
@ -294,8 +294,7 @@ class nsIScrollableFrame : public nsIScrollbarMediator {
|
|||
* number of layer pixels (so the operation is fast and looks clean).
|
||||
*/
|
||||
virtual void ScrollToCSSPixelsForApz(
|
||||
const mozilla::CSSPoint& aScrollPosition,
|
||||
mozilla::ScrollSnapTargetIds&& aLastSnapTargetIds) = 0;
|
||||
const mozilla::CSSPoint& aScrollPosition) = 0;
|
||||
|
||||
/**
|
||||
* Returns the scroll position in integer CSS pixels, rounded to the nearest
|
||||
|
|
Загрузка…
Ссылка в новой задаче