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:
@@ -802,6 +802,7 @@ nsIPresShell::nsIPresShell()
|
||||
, mObservingLayoutFlushes(false)
|
||||
, mNeedThrottledAnimationFlush(true)
|
||||
, mPresShellId(0)
|
||||
, mAPZFocusSequenceNumber(0)
|
||||
, mFontSizeInflationEmPerLine(0)
|
||||
, mFontSizeInflationMinTwips(0)
|
||||
, mFontSizeInflationLineThreshold(0)
|
||||
@@ -6340,7 +6341,7 @@ PresShell::Paint(nsView* aViewToPaint,
|
||||
// Update the focus target for async keyboard scrolling. This will be forwarded
|
||||
// to APZ by nsDisplayList::PaintRoot. We need to to do this before we enter
|
||||
// the paint phase because dispatching eVoid events can cause layout to happen.
|
||||
mAPZFocusTarget = FocusTarget(this);
|
||||
mAPZFocusTarget = FocusTarget(this, mAPZFocusSequenceNumber);
|
||||
|
||||
nsPresContext* presContext = GetPresContext();
|
||||
AUTO_LAYOUT_PHASE_ENTRY_POINT(presContext, Paint);
|
||||
@@ -7154,6 +7155,12 @@ PresShell::HandleEvent(nsIFrame* aFrame,
|
||||
|
||||
NS_ASSERTION(aFrame, "aFrame should be not null");
|
||||
|
||||
// Update the latest focus sequence number with this new sequence number
|
||||
if (mAPZFocusSequenceNumber < aEvent->mFocusSequenceNumber) {
|
||||
// XXX should we push a new FocusTarget to APZ here
|
||||
mAPZFocusSequenceNumber = aEvent->mFocusSequenceNumber;
|
||||
}
|
||||
|
||||
if (sPointerEventEnabled) {
|
||||
AutoWeakFrame weakFrame(aFrame);
|
||||
nsCOMPtr<nsIContent> targetContent;
|
||||
|
||||
Reference in New Issue
Block a user