Bug 1348786 - Move SendMayStartSwipe() into nsBaseWidget. r=tnikkel

Differential Revision: https://phabricator.services.mozilla.com/D134365
This commit is contained in:
Hiroyuki Ikezoe 2022-01-05 09:08:07 +00:00
Родитель cc326dc6bf
Коммит b6f644b523
4 изменённых файлов: 31 добавлений и 31 удалений

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

@ -524,13 +524,6 @@ class nsChildView final : public nsBaseWidget {
nsIWidget* GetWidgetForListenerEvents();
struct SwipeInfo {
bool wantsSwipe;
uint32_t allowedDirections;
};
SwipeInfo SendMayStartSwipe(const mozilla::PanGestureInput& aSwipeStartEvent);
protected:
ChildView* mView; // my parallel cocoa view, [STRONG]
RefPtr<mozilla::widget::TextInputHandler> mTextInputHandler;

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

@ -1802,30 +1802,6 @@ mozilla::VibrancyManager& nsChildView::EnsureVibrancyManager() {
return *mVibrancyManager;
}
nsChildView::SwipeInfo nsChildView::SendMayStartSwipe(
const mozilla::PanGestureInput& aSwipeStartEvent) {
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
uint32_t direction = (aSwipeStartEvent.mPanDisplacement.x > 0.0)
? (uint32_t)dom::SimpleGestureEvent_Binding::DIRECTION_RIGHT
: (uint32_t)dom::SimpleGestureEvent_Binding::DIRECTION_LEFT;
// We're ready to start the animation. Tell Gecko about it, and at the same
// time ask it if it really wants to start an animation for this event.
// This event also reports back the directions that we can swipe in.
LayoutDeviceIntPoint position =
RoundedToInt(aSwipeStartEvent.mPanStartPoint * ScreenToLayoutDeviceScale(1));
WidgetSimpleGestureEvent geckoEvent = SwipeTracker::CreateSwipeGestureEvent(
eSwipeGestureMayStart, this, position, aSwipeStartEvent.mTimeStamp);
geckoEvent.mDirection = direction;
geckoEvent.mDelta = 0.0;
geckoEvent.mAllowedDirections = 0;
bool shouldStartSwipe = DispatchWindowEvent(geckoEvent); // event cancelled == swipe should start
SwipeInfo result = {shouldStartSwipe, geckoEvent.mAllowedDirections};
return result;
}
void nsChildView::UpdateBoundsFromView() {
auto oldSize = mBounds.Size();
mBounds = CocoaPointsToDevPixels([mView frame]);

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

@ -2088,6 +2088,32 @@ void nsBaseWidget::TrackScrollEventAsSwipe(
}
}
nsBaseWidget::SwipeInfo nsBaseWidget::SendMayStartSwipe(
const mozilla::PanGestureInput& aSwipeStartEvent) {
nsCOMPtr<nsIWidget> kungFuDeathGrip(this);
uint32_t direction =
(aSwipeStartEvent.mPanDisplacement.x > 0.0)
? (uint32_t)dom::SimpleGestureEvent_Binding::DIRECTION_RIGHT
: (uint32_t)dom::SimpleGestureEvent_Binding::DIRECTION_LEFT;
// We're ready to start the animation. Tell Gecko about it, and at the same
// time ask it if it really wants to start an animation for this event.
// This event also reports back the directions that we can swipe in.
LayoutDeviceIntPoint position = RoundedToInt(aSwipeStartEvent.mPanStartPoint *
ScreenToLayoutDeviceScale(1));
WidgetSimpleGestureEvent geckoEvent = SwipeTracker::CreateSwipeGestureEvent(
eSwipeGestureMayStart, this, position, aSwipeStartEvent.mTimeStamp);
geckoEvent.mDirection = direction;
geckoEvent.mDelta = 0.0;
geckoEvent.mAllowedDirections = 0;
bool shouldStartSwipe =
DispatchWindowEvent(geckoEvent); // event cancelled == swipe should start
SwipeInfo result = {shouldStartSwipe, geckoEvent.mAllowedDirections};
return result;
}
const IMENotificationRequests& nsIWidget::IMENotificationRequestsRef() {
TextEventDispatcher* dispatcher = GetTextEventDispatcher();
return dispatcher->IMENotificationRequestsRef();

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

@ -330,6 +330,11 @@ class nsBaseWidget : public nsIWidget, public nsSupportsWeakReference {
void ReportSwipeStarted(uint64_t aInputBlockId, bool aStartSwipe) override;
void TrackScrollEventAsSwipe(const mozilla::PanGestureInput& aSwipeStartEvent,
uint32_t aAllowedDirections);
struct SwipeInfo {
bool wantsSwipe;
uint32_t allowedDirections;
};
SwipeInfo SendMayStartSwipe(const mozilla::PanGestureInput& aSwipeStartEvent);
void NotifyWindowDestroyed();
void NotifySizeMoveDone();