зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1358017 - Part 4: Implements the auto-dir scrolling feature(without the "honour root" functionality) in APZ r=kats
This commit implements the auto-dir scrolling functionality in APZ, based on part 1 to part 3. However, the functionality of mousewheel.autodir.honourroot will be implemented in a future. MozReview-Commit-ID: 9xai99x71gh --HG-- extra : rebase_source : 118d188f730e3fb91d147b076a053cb04e622e55
This commit is contained in:
Родитель
7a6384c9c7
Коммит
fe2d79f73f
|
@ -258,6 +258,9 @@ enum class WheelDeltaAdjustmentStrategy : uint8_t
|
|||
// listener or a plugin, delta values are never going to be adjusted.
|
||||
eAutoDir,
|
||||
eAutoDirWithRootHonour,
|
||||
// Not an actual strategy. This is just used as an upper bound for
|
||||
// ContiguousEnumSerializer.
|
||||
eSentinel,
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
|
@ -487,6 +487,17 @@ public:
|
|||
mScrollableRect = aScrollableRect;
|
||||
}
|
||||
|
||||
// If the frame is in vertical-RTL writing mode(E.g. "writing-mode:
|
||||
// vertical-rl" in CSS), or if it's in horizontal-RTL writing-mode(E.g.
|
||||
// "writing-mode: horizontal-tb; direction: rtl;" in CSS), then this function
|
||||
// returns true. From the representation perspective, frames whose horizontal
|
||||
// contents start at rightside also cause their horizontal scrollbars, if any,
|
||||
// initially start at rightside. So we can also learn about the initial side
|
||||
// of the horizontal scrollbar for the frame by calling this function.
|
||||
bool IsHorizontalContentRightToLeft() {
|
||||
return mScrollableRect.x < 0;
|
||||
}
|
||||
|
||||
void SetPaintRequestTime(const TimeStamp& aTime) {
|
||||
mPaintRequestTime = aTime;
|
||||
}
|
||||
|
|
|
@ -139,7 +139,8 @@ APZInputBridge::ReceiveInputEvent(
|
|||
wheelEvent.mDeltaMode),
|
||||
origin,
|
||||
wheelEvent.mDeltaX, wheelEvent.mDeltaY,
|
||||
wheelEvent.mAllowToOverrideSystemScrollSpeed);
|
||||
wheelEvent.mAllowToOverrideSystemScrollSpeed,
|
||||
strategy);
|
||||
|
||||
// We add the user multiplier as a separate field, rather than premultiplying
|
||||
// it, because if the input is converted back to a WidgetWheelEvent, then
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
|
||||
#include "APZCTreeManager.h" // for APZCTreeManager
|
||||
#include "AsyncPanZoomAnimation.h" // for AsyncPanZoomAnimation
|
||||
#include "AutoDirWheelDeltaAdjuster.h" // for APZAutoDirWheelDeltaAdjuster
|
||||
#include "AutoscrollAnimation.h" // for AutoscrollAnimation
|
||||
#include "Axis.h" // for AxisX, AxisY, Axis, etc
|
||||
#include "CheckerboardEvent.h" // for CheckerboardEvent
|
||||
|
@ -1732,6 +1733,19 @@ AllowsScrollingMoreThanOnePage(double aMultiplier)
|
|||
|
||||
ParentLayerPoint
|
||||
AsyncPanZoomController::GetScrollWheelDelta(const ScrollWheelInput& aEvent) const
|
||||
{
|
||||
return GetScrollWheelDelta(aEvent,
|
||||
aEvent.mDeltaX, aEvent.mDeltaY,
|
||||
aEvent.mUserDeltaMultiplierX,
|
||||
aEvent.mUserDeltaMultiplierY);
|
||||
}
|
||||
|
||||
ParentLayerPoint
|
||||
AsyncPanZoomController::GetScrollWheelDelta(const ScrollWheelInput& aEvent,
|
||||
double aDeltaX,
|
||||
double aDeltaY,
|
||||
double aMultiplierX,
|
||||
double aMultiplierY) const
|
||||
{
|
||||
ParentLayerSize scrollAmount;
|
||||
ParentLayerSize pageScrollSize;
|
||||
|
@ -1750,24 +1764,25 @@ AsyncPanZoomController::GetScrollWheelDelta(const ScrollWheelInput& aEvent) cons
|
|||
ParentLayerPoint delta;
|
||||
switch (aEvent.mDeltaType) {
|
||||
case ScrollWheelInput::SCROLLDELTA_LINE: {
|
||||
delta.x = aEvent.mDeltaX * scrollAmount.width;
|
||||
delta.y = aEvent.mDeltaY * scrollAmount.height;
|
||||
delta.x = aDeltaX * scrollAmount.width;
|
||||
delta.y = aDeltaY * scrollAmount.height;
|
||||
break;
|
||||
}
|
||||
case ScrollWheelInput::SCROLLDELTA_PAGE: {
|
||||
delta.x = aEvent.mDeltaX * pageScrollSize.width;
|
||||
delta.y = aEvent.mDeltaY * pageScrollSize.height;
|
||||
delta.x = aDeltaX * pageScrollSize.width;
|
||||
delta.y = aDeltaY * pageScrollSize.height;
|
||||
break;
|
||||
}
|
||||
case ScrollWheelInput::SCROLLDELTA_PIXEL: {
|
||||
delta = ToParentLayerCoordinates(ScreenPoint(aEvent.mDeltaX, aEvent.mDeltaY), aEvent.mOrigin);
|
||||
delta = ToParentLayerCoordinates(ScreenPoint(aDeltaX, aDeltaY),
|
||||
aEvent.mOrigin);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Apply user-set multipliers.
|
||||
delta.x *= aEvent.mUserDeltaMultiplierX;
|
||||
delta.y *= aEvent.mUserDeltaMultiplierY;
|
||||
delta.x *= aMultiplierX;
|
||||
delta.y *= aMultiplierY;
|
||||
|
||||
// For the conditions under which we allow system scroll overrides, see
|
||||
// EventStateManager::DeltaAccumulator::ComputeScrollAmountForDefaultAction
|
||||
|
@ -1798,13 +1813,13 @@ AsyncPanZoomController::GetScrollWheelDelta(const ScrollWheelInput& aEvent) cons
|
|||
|
||||
// We shouldn't scroll more than one page at once except when the
|
||||
// user preference is large.
|
||||
if (!AllowsScrollingMoreThanOnePage(aEvent.mUserDeltaMultiplierX) &&
|
||||
if (!AllowsScrollingMoreThanOnePage(aMultiplierX) &&
|
||||
Abs(delta.x) > pageScrollSize.width) {
|
||||
delta.x = (delta.x >= 0)
|
||||
? pageScrollSize.width
|
||||
: -pageScrollSize.width;
|
||||
}
|
||||
if (!AllowsScrollingMoreThanOnePage(aEvent.mUserDeltaMultiplierY) &&
|
||||
if (!AllowsScrollingMoreThanOnePage(aMultiplierY) &&
|
||||
Abs(delta.y) > pageScrollSize.height) {
|
||||
delta.y = (delta.y >= 0)
|
||||
? pageScrollSize.height
|
||||
|
@ -1987,6 +2002,26 @@ AsyncPanZoomController::CanScroll(const InputData& aEvent) const
|
|||
}
|
||||
|
||||
if (SCROLLWHEEL_INPUT == aEvent.mInputType) {
|
||||
const ScrollWheelInput& scrollWheelInput = aEvent.AsScrollWheelInput();
|
||||
// If it's a wheel scroll, we first check if it is an auto-dir scroll.
|
||||
// 1. For an auto-dir scroll, check if it's delta should be adjusted, if it
|
||||
// is, then we can conclude it must be scrollable; otherwise, fall back
|
||||
// to checking if it is scrollable without adjusting its delta.
|
||||
// 2. For a non-auto-dir scroll, simply check if it is scrollable without
|
||||
// adjusting its delta.
|
||||
if (scrollWheelInput.IsAutoDir()) {
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
auto deltaX = scrollWheelInput.mDeltaX;
|
||||
auto deltaY = scrollWheelInput.mDeltaY;
|
||||
bool isRTL = IsContentOfHonouredTargetRightToLeft(
|
||||
scrollWheelInput.HonoursRoot());
|
||||
APZAutoDirWheelDeltaAdjuster adjuster(deltaX, deltaY, mX, mY, isRTL);
|
||||
if (adjuster.ShouldBeAdjusted()) {
|
||||
// If we detect that the delta values should be adjusted for an auto-dir
|
||||
// wheel scroll, then it is impossible to be an unscrollable scroll.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return CanScrollWithWheel(delta);
|
||||
}
|
||||
return CanScroll(delta);
|
||||
|
@ -2045,6 +2080,16 @@ AsyncPanZoomController::CanScroll(ScrollDirection aDirection) const
|
|||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
AsyncPanZoomController::IsContentOfHonouredTargetRightToLeft(
|
||||
bool aHonoursRoot) const
|
||||
{
|
||||
// TODO The current implementation only honours the scrolling target, the
|
||||
// functionality of honouring root is going to be added in the next commit.
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
return mFrameMetrics.IsHorizontalContentRightToLeft();
|
||||
}
|
||||
|
||||
bool
|
||||
AsyncPanZoomController::AllowScrollHandoffInCurrentBlock() const
|
||||
{
|
||||
|
@ -2084,10 +2129,52 @@ AdjustDeltaForAllowedScrollDirections(
|
|||
|
||||
nsEventStatus AsyncPanZoomController::OnScrollWheel(const ScrollWheelInput& aEvent)
|
||||
{
|
||||
ParentLayerPoint delta = GetScrollWheelDelta(aEvent);
|
||||
APZC_LOG("%p got a scroll-wheel with delta %s\n", this, Stringify(delta).c_str());
|
||||
// Get the scroll wheel's delta values in parent-layer pixels. But before
|
||||
// getting the values, we need to check if it is an auto-dir scroll and if it
|
||||
// should be adjusted, if both answers are yes, let's adjust X and Y values
|
||||
// first, and then get the delta values in parent-layer pixels based on the
|
||||
// adjusted values.
|
||||
bool adjustedByAutoDir = false;
|
||||
ParentLayerPoint delta;
|
||||
if (aEvent.IsAutoDir()) {
|
||||
// It's an auto-dir scroll, so check if its delta should be adjusted, if so,
|
||||
// adjust it.
|
||||
RecursiveMutexAutoLock lock(mRecursiveMutex);
|
||||
auto deltaX = aEvent.mDeltaX;
|
||||
auto deltaY = aEvent.mDeltaY;
|
||||
bool isRTL = IsContentOfHonouredTargetRightToLeft(aEvent.HonoursRoot());
|
||||
APZAutoDirWheelDeltaAdjuster adjuster(deltaX, deltaY, mX, mY, isRTL);
|
||||
if (adjuster.ShouldBeAdjusted()) {
|
||||
adjuster.Adjust();
|
||||
// If the original delta values have been adjusted, we pass them to
|
||||
// replace the original delta values in |aEvent| so that the delta values
|
||||
// in parent-layer pixels are caculated based on the adjusted values, not
|
||||
// the original ones.
|
||||
// Pay special attention to the last two parameters. They are in a swaped
|
||||
// order so that they still correspond to their delta after adjustment.
|
||||
delta = GetScrollWheelDelta(aEvent,
|
||||
deltaX, deltaY,
|
||||
aEvent.mUserDeltaMultiplierY,
|
||||
aEvent.mUserDeltaMultiplierX);
|
||||
adjustedByAutoDir = true;
|
||||
}
|
||||
}
|
||||
if (!adjustedByAutoDir) {
|
||||
// If the original delta values haven't been adjusted by auto-dir, just pass
|
||||
// the |aEvent| and caculate the delta values in parent-layer pixels based
|
||||
// on the original delta values from |aEvent|.
|
||||
delta = GetScrollWheelDelta(aEvent);
|
||||
}
|
||||
|
||||
if ((delta.x || delta.y) && !CanScrollWithWheel(delta)) {
|
||||
APZC_LOG("%p got a scroll-wheel with delta in parent-layer pixels: %s\n",
|
||||
this, Stringify(delta).c_str());
|
||||
|
||||
if (adjustedByAutoDir) {
|
||||
MOZ_ASSERT(delta.x || delta.y,
|
||||
"Adjusted auto-dir delta values can never be all-zero.");
|
||||
APZC_LOG("%p got a scroll-wheel with adjusted auto-dir delta values\n",
|
||||
this);
|
||||
} else if ((delta.x || delta.y) && !CanScrollWithWheel(delta)) {
|
||||
// We can't scroll this apz anymore, so we simply drop the event.
|
||||
if (mInputQueue->GetActiveWheelTransaction() &&
|
||||
gfxPrefs::MouseScrollTestingEnabled()) {
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
#include "mozilla/UniquePtr.h"
|
||||
#include "mozilla/Atomics.h"
|
||||
#include "InputData.h"
|
||||
#include "Axis.h"
|
||||
#include "Axis.h" // for Axis, Side, etc.
|
||||
#include "InputQueue.h"
|
||||
#include "APZUtils.h"
|
||||
#include "Layers.h" // for Layer::ScrollDirection
|
||||
|
@ -509,6 +509,13 @@ public:
|
|||
|
||||
bool OverscrollBehaviorAllowsSwipe() const;
|
||||
|
||||
private:
|
||||
// Get whether the horizontal content of the honoured target of auto-dir
|
||||
// scrolling starts from right to left. If you don't know of auto-dir
|
||||
// scrolling or what a honoured target means,
|
||||
// @see mozilla::WheelDeltaAdjustmentStrategy
|
||||
bool IsContentOfHonouredTargetRightToLeft(bool aHonoursRoot) const;
|
||||
|
||||
protected:
|
||||
// Protected destructor, to discourage deletion outside of Release():
|
||||
virtual ~AsyncPanZoomController();
|
||||
|
@ -575,8 +582,40 @@ protected:
|
|||
*/
|
||||
nsEventStatus OnScrollWheel(const ScrollWheelInput& aEvent);
|
||||
|
||||
/**
|
||||
* Gets the scroll wheel delta's values in parent-layer pixels from the
|
||||
* original delta's values of a wheel input.
|
||||
*/
|
||||
ParentLayerPoint GetScrollWheelDelta(const ScrollWheelInput& aEvent) const;
|
||||
|
||||
/**
|
||||
* This function is like GetScrollWheelDelta(aEvent).
|
||||
* The difference is the four added parameters provide values as alternatives
|
||||
* to the original wheel input's delta values, so |aEvent|'s delta values are
|
||||
* ignored in this function, we only use some other member variables and
|
||||
* functions of |aEvent|.
|
||||
*/
|
||||
ParentLayerPoint
|
||||
GetScrollWheelDelta(const ScrollWheelInput& aEvent,
|
||||
double aDeltaX,
|
||||
double aDeltaY,
|
||||
double aMultiplierX,
|
||||
double aMultiplierY) const;
|
||||
|
||||
/**
|
||||
* This deleted function is used for:
|
||||
* 1. avoiding accidental implicit value type conversions of input delta
|
||||
* values when callers intend to call the above function;
|
||||
* 2. decoupling the manual relationship between the delta value type and the
|
||||
* above function. If by any chance the defined delta value type in
|
||||
* ScrollWheelInput has changed, this will automatically result in build
|
||||
* time failure, so we can learn of it the first time and accordingly
|
||||
* redefine those parameters' value types in the above function.
|
||||
*/
|
||||
template <typename T>
|
||||
ParentLayerPoint
|
||||
GetScrollWheelDelta(ScrollWheelInput&, T, T, T, T) = delete;
|
||||
|
||||
/**
|
||||
* Helper methods for handling keyboard events.
|
||||
*/
|
||||
|
|
|
@ -0,0 +1,102 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef __mozilla_layers_AutoDirWheelDeltaAdjuster_h__
|
||||
#define __mozilla_layers_AutoDirWheelDeltaAdjuster_h__
|
||||
|
||||
#include "Axis.h" // for AxisX, AxisY, Side
|
||||
#include "mozilla/WheelHandlingHelper.h" // for AutoDirWheelDeltaAdjuster
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
||||
/**
|
||||
* About AutoDirWheelDeltaAdjuster:
|
||||
* For an AutoDir wheel scroll, there's some situations where we should adjust a
|
||||
* wheel event's delta values. AutoDirWheelDeltaAdjuster converts delta values
|
||||
* for AutoDir scrolling. An AutoDir wheel scroll lets the user scroll a frame
|
||||
* with only one scrollbar, using either a vertical or a horzizontal wheel.
|
||||
* For more detail about the concept of AutoDir scrolling, see the comments in
|
||||
* AutoDirWheelDeltaAdjuster.
|
||||
*
|
||||
* This is the APZ implementation of AutoDirWheelDeltaAdjuster.
|
||||
*/
|
||||
class MOZ_STACK_CLASS APZAutoDirWheelDeltaAdjuster final
|
||||
: public AutoDirWheelDeltaAdjuster
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* @param aDeltaX DeltaX for a wheel event whose delta values will
|
||||
* be adjusted upon calling adjust() when
|
||||
* ShouldBeAdjusted() returns true.
|
||||
* @param aDeltaY DeltaY for a wheel event, like DeltaX.
|
||||
* @param aAxisX The X axis information provider for the current
|
||||
* frame, such as whether the frame can be scrolled
|
||||
* horizontally, leftwards or rightwards.
|
||||
* @param aAxisY The Y axis information provider for the current
|
||||
* frame, such as whether the frame can be scrolled
|
||||
* vertically, upwards or downwards.
|
||||
* @param aIsHorizontalContentRightToLeft
|
||||
* Indicates whether the horizontal content starts
|
||||
* at rightside. This value will decide which edge
|
||||
* the adjusted scroll goes towards, in other words,
|
||||
* it will decide the sign of the adjusted delta
|
||||
* values). For detailed information, see
|
||||
* IsHorizontalContentRightToLeft() in
|
||||
* the base class AutoDirWheelDeltaAdjuster.
|
||||
*/
|
||||
explicit
|
||||
APZAutoDirWheelDeltaAdjuster(double& aDeltaX,
|
||||
double& aDeltaY,
|
||||
const AxisX& aAxisX,
|
||||
const AxisY& aAxisY,
|
||||
bool aIsHorizontalContentRightToLeft)
|
||||
: AutoDirWheelDeltaAdjuster(aDeltaX, aDeltaY)
|
||||
, mAxisX(aAxisX)
|
||||
, mAxisY(aAxisY)
|
||||
, mIsHorizontalContentRightToLeft(aIsHorizontalContentRightToLeft)
|
||||
{
|
||||
}
|
||||
|
||||
private:
|
||||
virtual bool CanScrollAlongXAxis() const override
|
||||
{
|
||||
return mAxisX.CanScroll();
|
||||
}
|
||||
virtual bool CanScrollAlongYAxis() const override
|
||||
{
|
||||
return mAxisY.CanScroll();
|
||||
}
|
||||
virtual bool CanScrollUpwards() const override
|
||||
{
|
||||
return mAxisY.CanScrollTo(eSideTop);
|
||||
}
|
||||
virtual bool CanScrollDownwards() const override
|
||||
{
|
||||
return mAxisY.CanScrollTo(eSideBottom);
|
||||
}
|
||||
virtual bool CanScrollLeftwards() const override
|
||||
{
|
||||
return mAxisX.CanScrollTo(eSideLeft);
|
||||
}
|
||||
virtual bool CanScrollRightwards() const override
|
||||
{
|
||||
return mAxisX.CanScrollTo(eSideRight);
|
||||
}
|
||||
virtual bool IsHorizontalContentRightToLeft() const override
|
||||
{
|
||||
return mIsHorizontalContentRightToLeft;
|
||||
}
|
||||
|
||||
const AxisX& mAxisX;
|
||||
const AxisY& mAxisY;
|
||||
bool mIsHorizontalContentRightToLeft;
|
||||
};
|
||||
|
||||
} // namespace layers
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // __mozilla_layers_AutoDirWheelDeltaAdjuster_h__
|
|
@ -545,6 +545,19 @@ const char* AxisX::Name() const
|
|||
return "X";
|
||||
}
|
||||
|
||||
bool AxisX::CanScrollTo(Side aSide) const
|
||||
{
|
||||
switch (aSide) {
|
||||
case eSideLeft:
|
||||
return CanScroll(-COORDINATE_EPSILON * 2);
|
||||
case eSideRight:
|
||||
return CanScroll(COORDINATE_EPSILON * 2);
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("aSide is out of valid values");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
OverscrollBehavior AxisX::GetOverscrollBehavior() const
|
||||
{
|
||||
return GetScrollMetadata().GetOverscrollBehavior().mBehaviorX;
|
||||
|
@ -586,6 +599,19 @@ const char* AxisY::Name() const
|
|||
return "Y";
|
||||
}
|
||||
|
||||
bool AxisY::CanScrollTo(Side aSide) const
|
||||
{
|
||||
switch (aSide) {
|
||||
case eSideTop:
|
||||
return CanScroll(-COORDINATE_EPSILON * 2);
|
||||
case eSideBottom:
|
||||
return CanScroll(COORDINATE_EPSILON * 2);
|
||||
default:
|
||||
MOZ_ASSERT_UNREACHABLE("aSide is out of valid values");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
OverscrollBehavior AxisY::GetOverscrollBehavior() const
|
||||
{
|
||||
return GetScrollMetadata().GetOverscrollBehavior().mBehaviorY;
|
||||
|
|
|
@ -8,11 +8,13 @@
|
|||
#define mozilla_layers_Axis_h
|
||||
|
||||
#include <sys/types.h> // for int32_t
|
||||
|
||||
#include "APZUtils.h"
|
||||
#include "AxisPhysicsMSDModel.h"
|
||||
#include "Units.h"
|
||||
#include "mozilla/gfx/Types.h" // for Side
|
||||
#include "mozilla/TimeStamp.h" // for TimeDuration
|
||||
#include "nsTArray.h" // for nsTArray
|
||||
#include "Units.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace layers {
|
||||
|
@ -313,6 +315,7 @@ public:
|
|||
virtual CSSToParentLayerScale GetScaleForAxis(const CSSToParentLayerScale2D& aScale) const override;
|
||||
virtual ScreenPoint MakePoint(ScreenCoord aCoord) const override;
|
||||
virtual const char* Name() const override;
|
||||
bool CanScrollTo(Side aSide) const;
|
||||
private:
|
||||
virtual OverscrollBehavior GetOverscrollBehavior() const override;
|
||||
};
|
||||
|
@ -326,6 +329,7 @@ public:
|
|||
virtual CSSToParentLayerScale GetScaleForAxis(const CSSToParentLayerScale2D& aScale) const override;
|
||||
virtual ScreenPoint MakePoint(ScreenCoord aCoord) const override;
|
||||
virtual const char* Name() const override;
|
||||
bool CanScrollTo(Side aSide) const;
|
||||
private:
|
||||
virtual OverscrollBehavior GetOverscrollBehavior() const override;
|
||||
};
|
||||
|
|
|
@ -249,7 +249,7 @@ Wheel(const RefPtr<InputReceiver>& aTarget, const ScreenIntPoint& aPoint,
|
|||
{
|
||||
ScrollWheelInput input(MillisecondsSinceStartup(aTime), aTime, 0,
|
||||
ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL,
|
||||
aPoint, aDelta.x, aDelta.y, false);
|
||||
aPoint, aDelta.x, aDelta.y, false, WheelDeltaAdjustmentStrategy::eNone);
|
||||
return aTarget->ReceiveInputEvent(input, nullptr, aOutInputBlockId);
|
||||
}
|
||||
|
||||
|
@ -260,7 +260,7 @@ SmoothWheel(const RefPtr<InputReceiver>& aTarget, const ScreenIntPoint& aPoint,
|
|||
{
|
||||
ScrollWheelInput input(MillisecondsSinceStartup(aTime), aTime, 0,
|
||||
ScrollWheelInput::SCROLLMODE_SMOOTH, ScrollWheelInput::SCROLLDELTA_LINE,
|
||||
aPoint, aDelta.x, aDelta.y, false);
|
||||
aPoint, aDelta.x, aDelta.y, false, WheelDeltaAdjustmentStrategy::eNone);
|
||||
return aTarget->ReceiveInputEvent(input, nullptr, aOutInputBlockId);
|
||||
}
|
||||
|
||||
|
|
|
@ -475,7 +475,7 @@ TEST_F(APZHitTestingTester, TestRepaintFlushOnWheelEvents) {
|
|||
for (int i = 0; i < 3; i++) {
|
||||
ScrollWheelInput swi(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0,
|
||||
ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL,
|
||||
origin, 0, 10, false);
|
||||
origin, 0, 10, false, WheelDeltaAdjustmentStrategy::eNone);
|
||||
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, manager->ReceiveInputEvent(swi, nullptr, nullptr));
|
||||
EXPECT_EQ(origin, swi.mOrigin);
|
||||
|
||||
|
@ -501,7 +501,7 @@ TEST_F(APZHitTestingTester, TestForceDisableApz) {
|
|||
ScreenPoint origin(100, 50);
|
||||
ScrollWheelInput swi(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0,
|
||||
ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL,
|
||||
origin, 0, 10, false);
|
||||
origin, 0, 10, false, WheelDeltaAdjustmentStrategy::eNone);
|
||||
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, manager->ReceiveInputEvent(swi, nullptr, nullptr));
|
||||
EXPECT_EQ(origin, swi.mOrigin);
|
||||
|
||||
|
@ -528,7 +528,7 @@ TEST_F(APZHitTestingTester, TestForceDisableApz) {
|
|||
// flushed).
|
||||
swi = ScrollWheelInput(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0,
|
||||
ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL,
|
||||
origin, 0, 0, false);
|
||||
origin, 0, 0, false, WheelDeltaAdjustmentStrategy::eNone);
|
||||
EXPECT_EQ(nsEventStatus_eConsumeDoDefault, manager->ReceiveInputEvent(swi, nullptr, nullptr));
|
||||
EXPECT_EQ(origin, swi.mOrigin);
|
||||
}
|
||||
|
|
|
@ -104,7 +104,7 @@ TEST_F(APZCTreeManagerTester, Bug1198900) {
|
|||
ScreenPoint origin(100, 50);
|
||||
ScrollWheelInput swi(MillisecondsSinceStartup(mcc->Time()), mcc->Time(), 0,
|
||||
ScrollWheelInput::SCROLLMODE_INSTANT, ScrollWheelInput::SCROLLDELTA_PIXEL,
|
||||
origin, 0, 10, false);
|
||||
origin, 0, 10, false, WheelDeltaAdjustmentStrategy::eNone);
|
||||
uint64_t blockId;
|
||||
manager->ReceiveInputEvent(swi, nullptr, &blockId);
|
||||
manager->ContentReceivedInputBlock(blockId, /* preventDefault= */ true);
|
||||
|
|
|
@ -688,7 +688,9 @@ ScrollWheelInput::ScrollWheelInput(uint32_t aTime, TimeStamp aTimeStamp,
|
|||
ScrollDeltaType aDeltaType,
|
||||
const ScreenPoint& aOrigin, double aDeltaX,
|
||||
double aDeltaY,
|
||||
bool aAllowToOverrideSystemScrollSpeed)
|
||||
bool aAllowToOverrideSystemScrollSpeed,
|
||||
WheelDeltaAdjustmentStrategy
|
||||
aWheelDeltaAdjustmentStrategy)
|
||||
: InputData(SCROLLWHEEL_INPUT, aTime, aTimeStamp, aModifiers)
|
||||
, mDeltaType(aDeltaType)
|
||||
, mScrollMode(aScrollMode)
|
||||
|
@ -704,6 +706,7 @@ ScrollWheelInput::ScrollWheelInput(uint32_t aTime, TimeStamp aTimeStamp,
|
|||
, mMayHaveMomentum(false)
|
||||
, mIsMomentum(false)
|
||||
, mAllowToOverrideSystemScrollSpeed(aAllowToOverrideSystemScrollSpeed)
|
||||
, mWheelDeltaAdjustmentStrategy(aWheelDeltaAdjustmentStrategy)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -724,6 +727,7 @@ ScrollWheelInput::ScrollWheelInput(const WidgetWheelEvent& aWheelEvent)
|
|||
, mIsMomentum(aWheelEvent.mIsMomentum)
|
||||
, mAllowToOverrideSystemScrollSpeed(
|
||||
aWheelEvent.mAllowToOverrideSystemScrollSpeed)
|
||||
, mWheelDeltaAdjustmentStrategy(WheelDeltaAdjustmentStrategy::eNone)
|
||||
{
|
||||
mOrigin =
|
||||
ScreenPoint(ViewAs<ScreenPixel>(aWheelEvent.mRefPoint,
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "mozilla/DefineEnum.h"
|
||||
#include "mozilla/EventForwards.h"
|
||||
#include "mozilla/TimeStamp.h"
|
||||
#include "mozilla/WheelHandlingHelper.h" // for WheelDeltaAdjustmentStrategy
|
||||
#include "mozilla/gfx/MatrixFwd.h"
|
||||
#include "mozilla/layers/KeyboardScrollAction.h"
|
||||
|
||||
|
@ -532,7 +533,8 @@ public:
|
|||
ScrollWheelInput(uint32_t aTime, TimeStamp aTimeStamp, Modifiers aModifiers,
|
||||
ScrollMode aScrollMode, ScrollDeltaType aDeltaType,
|
||||
const ScreenPoint& aOrigin, double aDeltaX, double aDeltaY,
|
||||
bool aAllowToOverrideSystemScrollSpeed);
|
||||
bool aAllowToOverrideSystemScrollSpeed,
|
||||
WheelDeltaAdjustmentStrategy aWheelDeltaAdjustmentStrategy);
|
||||
explicit ScrollWheelInput(const WidgetWheelEvent& aEvent);
|
||||
|
||||
static ScrollDeltaType DeltaTypeForDeltaMode(uint32_t aDeltaMode);
|
||||
|
@ -544,6 +546,34 @@ public:
|
|||
|
||||
bool IsCustomizedByUserPrefs() const;
|
||||
|
||||
// The following two functions are for auto-dir scrolling. For detailed
|
||||
// information on auto-dir, @see mozilla::WheelDeltaAdjustmentStrategy
|
||||
bool IsAutoDir() const
|
||||
{
|
||||
switch (mWheelDeltaAdjustmentStrategy) {
|
||||
case WheelDeltaAdjustmentStrategy::eAutoDir:
|
||||
case WheelDeltaAdjustmentStrategy::eAutoDirWithRootHonour:
|
||||
return true;
|
||||
default:
|
||||
// Prevent compilation errors generated by -Werror=switch
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
// Indicates which element this scroll honours if it's an auto-dir scroll.
|
||||
// If true, honour the root element; otherwise, honour the currently scrolling
|
||||
// target.
|
||||
// Note that if IsAutoDir() returns false, then this function also returns
|
||||
// false, but false in this case is meaningless as IsAutoDir() indicates it's
|
||||
// not an auto-dir scroll.
|
||||
// For detailed information on auto-dir,
|
||||
// @see mozilla::WheelDeltaAdjustmentStrategy
|
||||
bool HonoursRoot() const
|
||||
{
|
||||
return WheelDeltaAdjustmentStrategy::eAutoDirWithRootHonour ==
|
||||
mWheelDeltaAdjustmentStrategy;
|
||||
}
|
||||
|
||||
// Warning, this class is serialized and sent over IPC. Any change to its
|
||||
// fields must be reflected in its ParamTraits<>, in nsGUIEventIPC.h
|
||||
ScrollDeltaType mDeltaType;
|
||||
|
@ -582,6 +612,10 @@ public:
|
|||
bool mMayHaveMomentum;
|
||||
bool mIsMomentum;
|
||||
bool mAllowToOverrideSystemScrollSpeed;
|
||||
|
||||
// Sometimes a wheel event input's wheel delta should be adjusted. This member
|
||||
// specifies how to adjust the wheel delta.
|
||||
WheelDeltaAdjustmentStrategy mWheelDeltaAdjustmentStrategy;
|
||||
};
|
||||
|
||||
class KeyboardInput : public InputData
|
||||
|
|
|
@ -15,6 +15,7 @@
|
|||
#include "mozilla/TouchEvents.h"
|
||||
#include "mozilla/TypeTraits.h"
|
||||
#include "mozilla/WeakPtr.h"
|
||||
#include "mozilla/WheelHandlingHelper.h" // for WheelDeltaAdjustmentStrategy
|
||||
|
||||
#include "mozilla/dom/ContentParent.h"
|
||||
#include "mozilla/dom/ContentChild.h"
|
||||
|
@ -488,7 +489,13 @@ public:
|
|||
ScrollWheelInput::SCROLLDELTA_PIXEL,
|
||||
origin,
|
||||
aHScroll, aVScroll,
|
||||
false);
|
||||
false,
|
||||
// XXX Do we need to support auto-dir scrolling
|
||||
// for Android widgets with a wheel device?
|
||||
// Currently, I just leave it unimplemented. If
|
||||
// we need to implement it, what's the extra work
|
||||
// to do?
|
||||
WheelDeltaAdjustmentStrategy::eNone);
|
||||
|
||||
ScrollableLayerGuid guid;
|
||||
uint64_t blockId;
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
#include "mozilla/WheelHandlingHelper.h" // for WheelDeltaAdjustmentStrategy
|
||||
#include "mozilla/dom/DataTransfer.h"
|
||||
#include "mozilla/dom/MouseEventBinding.h"
|
||||
#include "mozilla/dom/SimpleGestureEventBinding.h"
|
||||
|
@ -5013,7 +5014,17 @@ GetIntegerDeltaForEvent(NSEvent* aEvent)
|
|||
position,
|
||||
preciseDelta.x,
|
||||
preciseDelta.y,
|
||||
false);
|
||||
false,
|
||||
// This parameter is used for wheel delta
|
||||
// adjustment, such as auto-dir scrolling,
|
||||
// but we do't need to do anything special here
|
||||
// since this wheel event is sent to
|
||||
// DispatchAPZWheelInputEvent, which turns this
|
||||
// ScrollWheelInput back into a WidgetWheelEvent
|
||||
// and then it goes through the regular handling
|
||||
// in APZInputBridge. So passing |eNone| won't
|
||||
// pass up the necessary wheel delta adjustment.
|
||||
WheelDeltaAdjustmentStrategy::eNone);
|
||||
wheelEvent.mLineOrPageDeltaX = lineOrPageDelta.x;
|
||||
wheelEvent.mLineOrPageDeltaY = lineOrPageDelta.y;
|
||||
wheelEvent.mIsMomentum = nsCocoaUtils::IsMomentumScrollEvent(theEvent);
|
||||
|
@ -5029,7 +5040,17 @@ GetIntegerDeltaForEvent(NSEvent* aEvent)
|
|||
position,
|
||||
lineOrPageDelta.x,
|
||||
lineOrPageDelta.y,
|
||||
false);
|
||||
false,
|
||||
// This parameter is used for wheel delta
|
||||
// adjustment, such as auto-dir scrolling,
|
||||
// but we do't need to do anything special here
|
||||
// since this wheel event is sent to
|
||||
// DispatchAPZWheelInputEvent, which turns this
|
||||
// ScrollWheelInput back into a WidgetWheelEvent
|
||||
// and then it goes through the regular handling
|
||||
// in APZInputBridge. So passing |eNone| won't
|
||||
// pass up the necessary wheel delta adjustment.
|
||||
WheelDeltaAdjustmentStrategy::eNone);
|
||||
wheelEvent.mLineOrPageDeltaX = lineOrPageDelta.x;
|
||||
wheelEvent.mLineOrPageDeltaY = lineOrPageDelta.y;
|
||||
geckoChildDeathGrip->DispatchAPZWheelInputEvent(wheelEvent, false);
|
||||
|
|
|
@ -14,6 +14,7 @@
|
|||
#include "mozilla/MouseEvents.h"
|
||||
#include "mozilla/TextEvents.h"
|
||||
#include "mozilla/TouchEvents.h"
|
||||
#include "mozilla/WheelHandlingHelper.h" // for WheelDeltaAdjustmentStrategy
|
||||
#include "mozilla/dom/Selection.h"
|
||||
#include "InputData.h"
|
||||
|
||||
|
@ -1352,6 +1353,14 @@ struct ParamTraits<mozilla::ScrollWheelInput::ScrollMode>
|
|||
mozilla::ScrollWheelInput::sHighestScrollMode>
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::WheelDeltaAdjustmentStrategy> :
|
||||
public ContiguousEnumSerializer<
|
||||
mozilla::WheelDeltaAdjustmentStrategy,
|
||||
mozilla::WheelDeltaAdjustmentStrategy(0),
|
||||
mozilla::WheelDeltaAdjustmentStrategy::eSentinel>
|
||||
{};
|
||||
|
||||
template<>
|
||||
struct ParamTraits<mozilla::ScrollWheelInput>
|
||||
{
|
||||
|
@ -1375,6 +1384,7 @@ struct ParamTraits<mozilla::ScrollWheelInput>
|
|||
WriteParam(aMsg, aParam.mMayHaveMomentum);
|
||||
WriteParam(aMsg, aParam.mIsMomentum);
|
||||
WriteParam(aMsg, aParam.mAllowToOverrideSystemScrollSpeed);
|
||||
WriteParam(aMsg, aParam.mWheelDeltaAdjustmentStrategy);
|
||||
}
|
||||
|
||||
static bool Read(const Message* aMsg, PickleIterator* aIter, paramType* aResult)
|
||||
|
@ -1394,7 +1404,9 @@ struct ParamTraits<mozilla::ScrollWheelInput>
|
|||
ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierY) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mMayHaveMomentum) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mIsMomentum) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mAllowToOverrideSystemScrollSpeed);
|
||||
ReadParam(aMsg, aIter,
|
||||
&aResult->mAllowToOverrideSystemScrollSpeed) &&
|
||||
ReadParam(aMsg, aIter, &aResult->mWheelDeltaAdjustmentStrategy);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче