зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1323983 part 1 - Ensure to release the pointer even if the document has been detached. r=smaug
MozReview-Commit-ID: FY5lDQBYl6U --HG-- extra : rebase_source : 47159f623c46549b48c786b28b5c00c246288076
This commit is contained in:
Родитель
8ce87f653c
Коммит
be76c082e0
|
@ -11703,6 +11703,13 @@ nsDocument::SetPointerLock(Element* aElement, int aCursorStyle)
|
|||
nsIPresShell* shell = GetShell();
|
||||
if (!shell) {
|
||||
NS_WARNING("SetPointerLock(): No PresShell");
|
||||
if (!aElement) {
|
||||
// If we are unlocking pointer lock, but for some reason the doc
|
||||
// has already detached from the presshell, just ask the event
|
||||
// state manager to release the pointer.
|
||||
EventStateManager::SetPointerLock(nullptr, nullptr);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
nsPresContext* presContext = shell->GetPresContext();
|
||||
|
@ -11728,7 +11735,7 @@ nsDocument::SetPointerLock(Element* aElement, int aCursorStyle)
|
|||
RefPtr<EventStateManager> esm = presContext->EventStateManager();
|
||||
esm->SetCursor(aCursorStyle, nullptr, false,
|
||||
0.0f, 0.0f, widget, true);
|
||||
esm->SetPointerLock(widget, aElement);
|
||||
EventStateManager::SetPointerLock(widget, aElement);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -268,6 +268,7 @@ bool EventStateManager::sNormalLMouseEventInProcess = false;
|
|||
EventStateManager* EventStateManager::sActiveESM = nullptr;
|
||||
nsIDocument* EventStateManager::sMouseOverDocument = nullptr;
|
||||
nsWeakFrame EventStateManager::sLastDragOverFrame = nullptr;
|
||||
LayoutDeviceIntPoint EventStateManager::sPreLockPoint = LayoutDeviceIntPoint(0, 0);
|
||||
LayoutDeviceIntPoint EventStateManager::sLastRefPoint = kInvalidRefPoint;
|
||||
CSSIntPoint EventStateManager::sLastScreenPoint = CSSIntPoint(0, 0);
|
||||
LayoutDeviceIntPoint EventStateManager::sSynthCenteringPoint = kInvalidRefPoint;
|
||||
|
@ -290,7 +291,6 @@ EventStateManager::DeltaAccumulator*
|
|||
EventStateManager::EventStateManager()
|
||||
: mLockCursor(0)
|
||||
, mLastFrameConsumedSetCursor(false)
|
||||
, mPreLockPoint(0,0)
|
||||
, mCurrentTarget(nullptr)
|
||||
// init d&d gesture state machine variables
|
||||
, mGestureDownPoint(0,0)
|
||||
|
@ -4357,7 +4357,7 @@ EventStateManager::GetWrapperByEventID(WidgetMouseEvent* aEvent)
|
|||
return helper;
|
||||
}
|
||||
|
||||
void
|
||||
/* static */ void
|
||||
EventStateManager::SetPointerLock(nsIWidget* aWidget,
|
||||
nsIContent* aElement)
|
||||
{
|
||||
|
@ -4375,7 +4375,7 @@ EventStateManager::SetPointerLock(nsIWidget* aWidget,
|
|||
MOZ_ASSERT(aWidget, "Locking pointer requires a widget");
|
||||
|
||||
// Store the last known ref point so we can reposition the pointer after unlock.
|
||||
mPreLockPoint = sLastRefPoint;
|
||||
sPreLockPoint = sLastRefPoint;
|
||||
|
||||
// Fire a synthetic mouse move to ensure event state is updated. We first
|
||||
// set the mouse to the center of the window, so that the mouse event
|
||||
|
@ -4393,13 +4393,13 @@ EventStateManager::SetPointerLock(nsIWidget* aWidget,
|
|||
// synthetic mouse event. We first reset sLastRefPoint to its
|
||||
// pre-pointerlock position, so that the synthetic mouse event reports
|
||||
// no movement.
|
||||
sLastRefPoint = mPreLockPoint;
|
||||
sLastRefPoint = sPreLockPoint;
|
||||
// Reset SynthCenteringPoint to invalid so that next time we start
|
||||
// locking pointer, it has its initial value.
|
||||
sSynthCenteringPoint = kInvalidRefPoint;
|
||||
if (aWidget) {
|
||||
aWidget->SynthesizeNativeMouseMove(
|
||||
mPreLockPoint + aWidget->WidgetToScreenOffset(), nullptr);
|
||||
sPreLockPoint + aWidget->WidgetToScreenOffset(), nullptr);
|
||||
}
|
||||
|
||||
// Unsuppress DnD
|
||||
|
|
|
@ -921,7 +921,7 @@ private:
|
|||
// Last mouse event mRefPoint (the offset from the widget's origin in
|
||||
// device pixels) when mouse was locked, used to restore mouse position
|
||||
// after unlocking.
|
||||
LayoutDeviceIntPoint mPreLockPoint;
|
||||
static LayoutDeviceIntPoint sPreLockPoint;
|
||||
|
||||
// Stores the mRefPoint of the last synthetic mouse move we dispatched
|
||||
// to re-center the mouse when we were pointer locked. If this is (-1,-1) it
|
||||
|
@ -1015,7 +1015,7 @@ public:
|
|||
void KillClickHoldTimer();
|
||||
void FireContextClick();
|
||||
|
||||
void SetPointerLock(nsIWidget* aWidget, nsIContent* aElement) ;
|
||||
static void SetPointerLock(nsIWidget* aWidget, nsIContent* aElement) ;
|
||||
static void sClickHoldCallback ( nsITimer* aTimer, void* aESM ) ;
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче