Merge inbound to mozilla-central a=merge

This commit is contained in:
Coroiu Cristina 2019-05-27 00:13:53 +03:00
commit 16e94ed95a
11 changed files with 51 additions and 221 deletions

View File

@ -86,9 +86,6 @@ class SVGAnimatedLength {
typedef mozilla::dom::SVGElement SVGElement;
typedef mozilla::dom::SVGViewportElement SVGViewportElement;
typedef mozilla::dom::UserSpaceMetrics UserSpaceMetrics;
typedef mozilla::SMILAttr SMILAttr;
typedef mozilla::SMILValue SMILValue;
typedef mozilla::SVGContentUtils SVGContentUtils;
public:
void Init(uint8_t aCtxType = mozilla::SVGContentUtils::XY,

View File

@ -1822,8 +1822,8 @@ nsEventStatus AsyncPanZoomController::OnScaleEnd(
}
nsEventStatus AsyncPanZoomController::HandleEndOfPan() {
MOZ_ASSERT(GetCurrentTouchBlock() || GetCurrentPanGestureBlock());
GetCurrentInputBlock()->GetOverscrollHandoffChain()->FlushRepaints();
MOZ_ASSERT(GetCurrentTouchBlock());
GetCurrentTouchBlock()->GetOverscrollHandoffChain()->FlushRepaints();
ParentLayerPoint flingVelocity = GetVelocityVector();
// Clear our velocities; if DispatchFling() gives the fling to us,
@ -1845,7 +1845,7 @@ nsEventStatus AsyncPanZoomController::HandleEndOfPan() {
if (flingVelocity.Length() < StaticPrefs::APZFlingMinVelocityThreshold()) {
// Relieve overscroll now if needed, since we will not transition to a fling
// animation and then an overscroll animation, and relieve it then.
GetCurrentInputBlock()
GetCurrentTouchBlock()
->GetOverscrollHandoffChain()
->SnapBackOverscrolledApzc(this);
return nsEventStatus_eConsumeNoDefault;
@ -1856,8 +1856,8 @@ nsEventStatus AsyncPanZoomController::HandleEndOfPan() {
// which nulls out mTreeManager, could be called concurrently.
if (APZCTreeManager* treeManagerLocal = GetApzcTreeManager()) {
const FlingHandoffState handoffState{
flingVelocity, GetCurrentInputBlock()->GetOverscrollHandoffChain(),
false /* not handoff */, GetCurrentInputBlock()->GetScrolledApzc()};
flingVelocity, GetCurrentTouchBlock()->GetOverscrollHandoffChain(),
false /* not handoff */, GetCurrentTouchBlock()->GetScrolledApzc()};
treeManagerLocal->DispatchFling(this, handoffState);
}
return nsEventStatus_eConsumeNoDefault;
@ -2556,35 +2556,6 @@ nsEventStatus AsyncPanZoomController::OnPan(const PanGestureInput& aEvent,
ScreenPoint physicalPanDisplacement = aEvent.mPanDisplacement;
ParentLayerPoint logicalPanDisplacement =
aEvent.UserMultipliedLocalPanDisplacement();
if (aEvent.mDeltaType == PanGestureInput::PANDELTA_PAGE) {
// Pan events with page units are used by Gtk, so this replicates Gtk:
// https://gitlab.gnome.org/GNOME/gtk/blob/c734c7e9188b56f56c3a504abee05fa40c5475ac/gtk/gtkrange.c#L3065-3073
CSSSize pageScrollSize;
CSSToParentLayerScale2D zoom;
{
// Grab the lock to access the frame metrics.
RecursiveMutexAutoLock lock(mRecursiveMutex);
pageScrollSize = mScrollMetadata.GetPageScrollAmount() /
Metrics().GetDevPixelsPerCSSPixel();
zoom = Metrics().GetZoom();
}
// scrollUnit* is in units of "ParentLayer pixels per page proportion"...
auto scrollUnitWidth = std::min(std::pow(pageScrollSize.width, 2.0 / 3.0),
pageScrollSize.width / 2.0) *
zoom.xScale;
auto scrollUnitHeight = std::min(std::pow(pageScrollSize.height, 2.0 / 3.0),
pageScrollSize.height / 2.0) *
zoom.yScale;
// ... and pan displacements are in units of "page proportion count"
// here, so the products of them and scrollUnit* are in ParentLayer pixels
ParentLayerPoint physicalPanDisplacementPL(
physicalPanDisplacement.x * scrollUnitWidth,
physicalPanDisplacement.y * scrollUnitHeight);
physicalPanDisplacement = ToScreenCoordinates(physicalPanDisplacementPL,
aEvent.mLocalPanStartPoint);
logicalPanDisplacement.x *= scrollUnitWidth;
logicalPanDisplacement.y *= scrollUnitHeight;
}
MOZ_ASSERT(GetCurrentPanGestureBlock());
AdjustDeltaForAllowedScrollDirections(
@ -2601,9 +2572,9 @@ nsEventStatus AsyncPanZoomController::OnPan(const PanGestureInput& aEvent,
// aEvent.mLocalStartPoint) would mess up velocity calculation. (This is
// the only caller of UpdateWithTouchAtDevicePoint() for pan events, so
// there is no risk of other calls resetting the position.)
mX.UpdateWithTouchAtDevicePoint(mX.GetPos() - logicalPanDisplacement.x,
mX.UpdateWithTouchAtDevicePoint(mX.GetPos() + logicalPanDisplacement.x,
aEvent.mTime);
mY.UpdateWithTouchAtDevicePoint(mY.GetPos() - logicalPanDisplacement.y,
mY.UpdateWithTouchAtDevicePoint(mY.GetPos() + logicalPanDisplacement.y,
aEvent.mTime);
HandlePanningUpdate(physicalPanDisplacement);
@ -2638,12 +2609,6 @@ nsEventStatus AsyncPanZoomController::OnPanEnd(const PanGestureInput& aEvent) {
mX.EndTouch(aEvent.mTime);
mY.EndTouch(aEvent.mTime);
// Use HandleEndOfPan for fling on platforms that don't
// emit momentum events (Gtk).
if (aEvent.mSimulateMomentum) {
return HandleEndOfPan();
}
// Drop any velocity on axes where we don't have room to scroll anyways
// (in this APZC, or an APZC further in the handoff chain).
// This ensures that we don't enlarge the display port unnecessarily.

View File

@ -160,6 +160,25 @@ struct ParamTraits<mozilla::layers::CompositableHandle> {
}
};
// Helper class for reading bitfields.
// If T has bitfields members, derive ParamTraits<T> from BitfieldHelper<T>.
template <typename ParamType>
struct BitfieldHelper {
// We need this helper because we can't get the address of a bitfield to
// pass directly to ReadParam. So instead we read it into a temporary bool
// and set the bitfield using a setter function
static bool ReadBoolForBitfield(const Message* aMsg, PickleIterator* aIter,
ParamType* aResult,
void (ParamType::*aSetter)(bool)) {
bool value;
if (ReadParam(aMsg, aIter, &value)) {
(aResult->*aSetter)(value);
return true;
}
return false;
}
};
template <>
struct ParamTraits<mozilla::layers::FrameMetrics>
: BitfieldHelper<mozilla::layers::FrameMetrics> {

View File

@ -1088,25 +1088,6 @@ struct ParamTraits<nsILoadInfo::CrossOriginPolicy>
: EnumSerializer<nsILoadInfo::CrossOriginPolicy,
CrossOriginPolicyValidator> {};
// Helper class for reading bitfields.
// If T has bitfields members, derive ParamTraits<T> from BitfieldHelper<T>.
template <typename ParamType>
struct BitfieldHelper {
// We need this helper because we can't get the address of a bitfield to
// pass directly to ReadParam. So instead we read it into a temporary bool
// and set the bitfield using a setter function
static bool ReadBoolForBitfield(const Message* aMsg, PickleIterator* aIter,
ParamType* aResult,
void (ParamType::*aSetter)(bool)) {
bool value;
if (ReadParam(aMsg, aIter, &value)) {
(aResult->*aSetter)(value);
return true;
}
return false;
}
};
} /* namespace IPC */
#endif /* __IPC_GLUE_IPCMESSAGEUTILS_H__ */

View File

@ -477,6 +477,7 @@ WidgetWheelEvent PanGestureInput::ToWidgetWheelEvent(nsIWidget* aWidget) const {
mPanStartPoint,
PixelCastJustification::LayoutDeviceIsScreenForUntransformedEvent));
wheelEvent.mButtons = 0;
wheelEvent.mDeltaMode = WheelEvent_Binding::DOM_DELTA_PIXEL;
wheelEvent.mMayHaveMomentum = true; // pan inputs may have momentum
wheelEvent.mIsMomentum = IsMomentum();
wheelEvent.mLineOrPageDeltaX = mLineOrPageDeltaX;
@ -485,16 +486,6 @@ WidgetWheelEvent PanGestureInput::ToWidgetWheelEvent(nsIWidget* aWidget) const {
wheelEvent.mDeltaY = mPanDisplacement.y;
wheelEvent.mFlags.mHandledByAPZ = mHandledByAPZ;
wheelEvent.mFocusSequenceNumber = mFocusSequenceNumber;
if (mDeltaType == PanGestureInput::PANDELTA_PAGE) {
// Emulate legacy widget/gtk behavior
wheelEvent.mDeltaMode = WheelEvent_Binding::DOM_DELTA_LINE;
wheelEvent.mIsNoLineOrPageDelta = true;
wheelEvent.mScrollType = WidgetWheelEvent::SCROLL_ASYNCHRONOUSELY;
wheelEvent.mDeltaX *= 3;
wheelEvent.mDeltaY *= 3;
} else {
wheelEvent.mDeltaMode = WheelEvent_Binding::DOM_DELTA_PIXEL;
}
return wheelEvent;
}
@ -507,14 +498,6 @@ bool PanGestureInput::TransformToLocal(
}
mLocalPanStartPoint = *panStartPoint;
if (mDeltaType == PanGestureInput::PANDELTA_PAGE) {
// Skip transforming the pan displacement because we want
// raw page proportion counts.
mLocalPanDisplacement.x = mPanDisplacement.x;
mLocalPanDisplacement.y = mPanDisplacement.y;
return true;
}
Maybe<ParentLayerPoint> panDisplacement =
UntransformVector(aTransform, mPanDisplacement, mPanStartPoint);
if (!panDisplacement) {

View File

@ -332,17 +332,6 @@ class PanGestureInput : public InputData {
// user has stopped the animation by putting their fingers on a touchpad.
PANGESTURE_MOMENTUMEND
));
MOZ_DEFINE_ENUM_AT_CLASS_SCOPE(
PanDeltaType, (
// There are three kinds of scroll delta modes in Gecko: "page", "line"
// and "pixel". Touchpad pan gestures only support "page" and "pixel".
//
// NOTE: PANDELTA_PAGE currently replicates Gtk behavior
// (see AsyncPanZoomController::OnPan).
PANDELTA_PAGE,
PANDELTA_PIXEL
));
// clang-format on
PanGestureInput(PanGestureType aType, uint32_t aTime, TimeStamp aTimeStamp,
@ -379,13 +368,11 @@ class PanGestureInput : public InputData {
double mUserDeltaMultiplierX;
double mUserDeltaMultiplierY;
PanDeltaType mDeltaType = PANDELTA_PIXEL;
bool mHandledByAPZ : 1;
bool mHandledByAPZ;
// true if this is a PANGESTURE_END event that will be followed by a
// PANGESTURE_MOMENTUMSTART event.
bool mFollowedByMomentum : 1;
bool mFollowedByMomentum;
// If this is true, and this event started a new input block that couldn't
// find a scrollable target which is scrollable in the horizontal component
@ -393,32 +380,15 @@ class PanGestureInput : public InputData {
// hold until a content response has arrived, even if the block has a
// confirmed target.
// This is used by events that can result in a swipe instead of a scroll.
bool mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection : 1;
bool mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection;
// This is used by APZ to communicate to the macOS widget code whether
// the overscroll-behavior of the scroll frame handling this swipe allows
// non-local overscroll behaviors in the horizontal direction (such as
// swipe navigation).
bool mOverscrollBehaviorAllowsSwipe : 1;
bool mOverscrollBehaviorAllowsSwipe;
// true if APZ should do a fling animation after this pan ends, like
// it would with touchscreens. (For platforms that don't emit momentum
// events.)
bool mSimulateMomentum : 1;
void SetHandledByAPZ(bool aHandled) { mHandledByAPZ = aHandled; }
void SetFollowedByMomentum(bool aFollowed) {
mFollowedByMomentum = aFollowed;
}
void SetRequiresContentResponseIfCannotScrollHorizontallyInStartDirection(
bool aRequires) {
mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection =
aRequires;
}
void SetOverscrollBehaviorAllowsSwipe(bool aAllows) {
mOverscrollBehaviorAllowsSwipe = aAllows;
}
void SetSimulateMomentum(bool aSimulate) { mSimulateMomentum = aSimulate; }
// XXX: If adding any more bools, switch to using bitfields instead.
};
/**

View File

@ -119,9 +119,6 @@ using namespace mozilla::widget;
#include "mozilla/layers/CompositorThread.h"
#include "mozilla/layers/KnowsCompositor.h"
#include "mozilla/layers/APZInputBridge.h"
#include "mozilla/layers/IAPZCTreeManager.h"
#ifdef MOZ_X11
# include "GLContextGLX.h" // for GLContextGLX::FindVisual()
# include "GtkCompositorWidget.h"
@ -3003,7 +3000,6 @@ void nsWindow::OnScrollEvent(GdkEventScroll* aEvent) {
if (aEvent->direction != GDK_SCROLL_SMOOTH &&
mLastScrollEventTime == aEvent->time)
return;
mLastScrollEventTime = aEvent->time;
#endif
WidgetWheelEvent wheelEvent(true, eWheel, this);
wheelEvent.mDeltaMode = dom::WheelEvent_Binding::DOM_DELTA_LINE;
@ -3011,52 +3007,21 @@ void nsWindow::OnScrollEvent(GdkEventScroll* aEvent) {
#if GTK_CHECK_VERSION(3, 4, 0)
case GDK_SCROLL_SMOOTH: {
// As of GTK 3.4, all directional scroll events are provided by
// the GDK_SCROLL_SMOOTH direction on XInput2 and Wayland devices.
// Special handling for touchpads to support flings
// (also known as kinetic/inertial/momentum scrolling)
GdkDevice* device = gdk_event_get_source_device((GdkEvent*)aEvent);
GdkInputSource source = gdk_device_get_source(device);
if (source == GDK_SOURCE_TOUCHSCREEN || source == GDK_SOURCE_TOUCHPAD) {
if (gtk_check_version(3, 20, 0) == nullptr) {
static auto sGdkEventIsScrollStopEvent =
(gboolean(*)(const GdkEvent*))dlsym(
RTLD_DEFAULT, "gdk_event_is_scroll_stop_event");
PanGestureInput::PanGestureType eventType =
PanGestureInput::PANGESTURE_PAN;
if (sGdkEventIsScrollStopEvent((GdkEvent*)aEvent)) {
eventType = PanGestureInput::PANGESTURE_END;
mPanInProgress = false;
} else if (!mPanInProgress) {
eventType = PanGestureInput::PANGESTURE_START;
mPanInProgress = true;
}
LayoutDeviceIntPoint touchPoint = GetRefPoint(this, aEvent);
PanGestureInput panEvent(
eventType, aEvent->time, GetEventTimeStamp(aEvent->time),
ScreenPoint(touchPoint.x, touchPoint.y),
ScreenPoint(aEvent->delta_x, aEvent->delta_y),
KeymapWrapper::ComputeKeyModifiers(aEvent->state));
panEvent.mDeltaType = PanGestureInput::PANDELTA_PAGE;
panEvent.mSimulateMomentum = true;
DispatchPanGestureInput(panEvent);
return;
}
// Older GTK doesn't support stop events, so we can't support fling
// there
wheelEvent.mScrollType = WidgetWheelEvent::SCROLL_ASYNCHRONOUSELY;
}
// the GDK_SCROLL_SMOOTH direction on XInput2 devices.
mLastScrollEventTime = aEvent->time;
// TODO - use a more appropriate scrolling unit than lines.
// Multiply event deltas by 3 to emulate legacy behaviour.
wheelEvent.mDeltaX = aEvent->delta_x * 3;
wheelEvent.mDeltaY = aEvent->delta_y * 3;
wheelEvent.mIsNoLineOrPageDelta = true;
// This next step manually unsets smooth scrolling for touch devices
// that trigger GDK_SCROLL_SMOOTH. We use the slave device, which
// represents the actual input.
GdkDevice* device = gdk_event_get_source_device((GdkEvent*)aEvent);
GdkInputSource source = gdk_device_get_source(device);
if (source == GDK_SOURCE_TOUCHSCREEN || source == GDK_SOURCE_TOUCHPAD) {
wheelEvent.mScrollType = WidgetWheelEvent::SCROLL_ASYNCHRONOUSELY;
}
break;
}
#endif
@ -4277,8 +4242,7 @@ LayoutDeviceIntSize nsWindow::GetSafeWindowSize(LayoutDeviceIntSize aSize) {
LayoutDeviceIntSize result = aSize;
int32_t maxSize = 32767;
if (mLayerManager && mLayerManager->AsKnowsCompositor()) {
maxSize = std::min(maxSize,
mLayerManager->AsKnowsCompositor()->GetMaxTextureSize());
maxSize = std::min(maxSize, mLayerManager->AsKnowsCompositor()->GetMaxTextureSize());
}
if (result.width > maxSize) {
result.width = maxSize;

View File

@ -491,8 +491,6 @@ class nsWindow final : public nsBaseWidget {
// This field omits duplicate scroll events caused by GNOME bug 726878.
guint32 mLastScrollEventTime;
bool mPanInProgress = false;
// for touch event handling
nsRefPtrHashtable<nsPtrHashKey<GdkEventSequence>, mozilla::dom::Touch>
mTouches;

View File

@ -1096,29 +1096,6 @@ void nsBaseWidget::DispatchTouchInput(MultiTouchInput& aInput) {
}
}
void nsBaseWidget::DispatchPanGestureInput(PanGestureInput& aInput) {
MOZ_ASSERT(NS_IsMainThread());
if (mAPZC) {
MOZ_ASSERT(APZThreadUtils::IsControllerThread());
uint64_t inputBlockId = 0;
ScrollableLayerGuid guid;
nsEventStatus result =
mAPZC->InputBridge()->ReceiveInputEvent(aInput, &guid, &inputBlockId);
if (result == nsEventStatus_eConsumeNoDefault) {
return;
}
WidgetWheelEvent event = aInput.ToWidgetWheelEvent(this);
ProcessUntransformedAPZEvent(&event, guid, inputBlockId, result);
} else {
WidgetWheelEvent event = aInput.ToWidgetWheelEvent(this);
nsEventStatus status;
DispatchEvent(&event, status);
}
}
nsEventStatus nsBaseWidget::DispatchInputEvent(WidgetInputEvent* aEvent) {
MOZ_ASSERT(NS_IsMainThread());
if (mAPZC) {

View File

@ -618,14 +618,6 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
*/
void DispatchTouchInput(mozilla::MultiTouchInput& aInput);
/**
* Dispatch the given PanGestureInput through APZ to Gecko (if APZ is enabled)
* or directly to gecko (if APZ is not enabled). This function must only
* be called from the main thread, and if APZ is enabled, that must also be
* the APZ controller thread.
*/
void DispatchPanGestureInput(mozilla::PanGestureInput& aInput);
#if defined(XP_WIN)
void UpdateScrollCapture() override;

View File

@ -1211,15 +1211,7 @@ struct ParamTraits<mozilla::PanGestureInput::PanGestureType>
mozilla::PanGestureInput::sHighestPanGestureType> {};
template <>
struct ParamTraits<mozilla::PanGestureInput::PanDeltaType>
: public ContiguousEnumSerializerInclusive<
mozilla::PanGestureInput::PanDeltaType,
mozilla::PanGestureInput::PanDeltaType::PANDELTA_PAGE,
mozilla::PanGestureInput::sHighestPanDeltaType> {};
template <>
struct ParamTraits<mozilla::PanGestureInput>
: BitfieldHelper<mozilla::PanGestureInput> {
struct ParamTraits<mozilla::PanGestureInput> {
typedef mozilla::PanGestureInput paramType;
static void Write(Message* aMsg, const paramType& aParam) {
@ -1233,7 +1225,6 @@ struct ParamTraits<mozilla::PanGestureInput>
WriteParam(aMsg, aParam.mLineOrPageDeltaY);
WriteParam(aMsg, aParam.mUserDeltaMultiplierX);
WriteParam(aMsg, aParam.mUserDeltaMultiplierY);
WriteParam(aMsg, aParam.mDeltaType);
WriteParam(aMsg, aParam.mHandledByAPZ);
WriteParam(aMsg, aParam.mFollowedByMomentum);
WriteParam(
@ -1241,7 +1232,6 @@ struct ParamTraits<mozilla::PanGestureInput>
aParam
.mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection);
WriteParam(aMsg, aParam.mOverscrollBehaviorAllowsSwipe);
WriteParam(aMsg, aParam.mSimulateMomentum);
}
static bool Read(const Message* aMsg, PickleIterator* aIter,
@ -1256,19 +1246,13 @@ struct ParamTraits<mozilla::PanGestureInput>
ReadParam(aMsg, aIter, &aResult->mLineOrPageDeltaY) &&
ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierX) &&
ReadParam(aMsg, aIter, &aResult->mUserDeltaMultiplierY) &&
ReadParam(aMsg, aIter, &aResult->mDeltaType) &&
ReadBoolForBitfield(aMsg, aIter, aResult,
&paramType::SetHandledByAPZ) &&
ReadBoolForBitfield(aMsg, aIter, aResult,
&paramType::SetFollowedByMomentum) &&
ReadBoolForBitfield(
aMsg, aIter, aResult,
&paramType::
SetRequiresContentResponseIfCannotScrollHorizontallyInStartDirection) &&
ReadBoolForBitfield(aMsg, aIter, aResult,
&paramType::SetOverscrollBehaviorAllowsSwipe) &&
ReadBoolForBitfield(aMsg, aIter, aResult,
&paramType::SetSimulateMomentum);
ReadParam(aMsg, aIter, &aResult->mHandledByAPZ) &&
ReadParam(aMsg, aIter, &aResult->mFollowedByMomentum) &&
ReadParam(
aMsg, aIter,
&aResult
->mRequiresContentResponseIfCannotScrollHorizontallyInStartDirection) &&
ReadParam(aMsg, aIter, &aResult->mOverscrollBehaviorAllowsSwipe);
}
};