Bug 1351783 part 12 - Create and sync focus sequence numbers. r=kats,botond,dvander

Focus can change at any moment in a document. This causes non-determinism and
correctness problems for doing keyboard apz scrolling. To get around this, we
will maintain deterministic behavior for focus changes initiated by input events
and see if we can get away with more non-determinism for things like `setTimeout`

In order to do this, we disable async keyboard scrolling when an input event is
processed that could have a event listener. We then attach a sequence number to
that input event and dispatch it to content. In content, we record the highest
sequence number that we have processed from an event, and send that on each focus
update. Using this, we can determine in APZ if we have a current focus target or
if we are still waiting for an input event to be processed and focus to be
reconfirmed.

MozReview-Commit-ID: CWcu8YEFQz4
This commit is contained in:
Ryan Hunt
2017-06-05 19:45:31 -05:00
parent 3eb832e2a9
commit 03a67c3376
21 changed files with 188 additions and 37 deletions

View File

@@ -23,6 +23,7 @@ InputData::~InputData()
InputData::InputData(InputType aInputType)
: mInputType(aInputType)
, mTime(0)
, mFocusSequenceNumber(0)
, modifiers(0)
{
}
@@ -32,6 +33,7 @@ InputData::InputData(InputType aInputType, uint32_t aTime, TimeStamp aTimeStamp,
: mInputType(aInputType)
, mTime(aTime)
, mTimeStamp(aTimeStamp)
, mFocusSequenceNumber(0)
, modifiers(aModifiers)
{
}
@@ -226,6 +228,7 @@ MultiTouchInput::ToWidgetTouchEvent(nsIWidget* aWidget) const
event.mTime = this->mTime;
event.mTimeStamp = this->mTimeStamp;
event.mFlags.mHandledByAPZ = mHandledByAPZ;
event.mFocusSequenceNumber = mFocusSequenceNumber;
for (size_t i = 0; i < mTouches.Length(); i++) {
*event.mTouches.AppendElement() = mTouches[i].ToNewDOMTouch();
@@ -269,6 +272,7 @@ MultiTouchInput::ToWidgetMouseEvent(nsIWidget* aWidget) const
event.inputSource = nsIDOMMouseEvent::MOZ_SOURCE_TOUCH;
event.mModifiers = modifiers;
event.mFlags.mHandledByAPZ = mHandledByAPZ;
event.mFocusSequenceNumber = mFocusSequenceNumber;
if (mouseEventMessage != eMouseMove) {
event.mClickCount = 1;
@@ -470,6 +474,7 @@ MouseInput::ToWidgetMouseEvent(nsIWidget* aWidget) const
event.mClickCount = clickCount;
event.inputSource = mInputSource;
event.mIgnoreRootScrollFrame = true;
event.mFocusSequenceNumber = mFocusSequenceNumber;
return event;
}
@@ -537,6 +542,7 @@ PanGestureInput::ToWidgetWheelEvent(nsIWidget* aWidget) const
wheelEvent.mDeltaX = mPanDisplacement.x;
wheelEvent.mDeltaY = mPanDisplacement.y;
wheelEvent.mFlags.mHandledByAPZ = mHandledByAPZ;
wheelEvent.mFocusSequenceNumber = mFocusSequenceNumber;
return wheelEvent;
}
@@ -764,6 +770,7 @@ ScrollWheelInput::ToWidgetWheelEvent(nsIWidget* aWidget) const
wheelEvent.mAllowToOverrideSystemScrollSpeed =
mAllowToOverrideSystemScrollSpeed;
wheelEvent.mFlags.mHandledByAPZ = mHandledByAPZ;
wheelEvent.mFocusSequenceNumber = mFocusSequenceNumber;
return wheelEvent;
}