Bug 712130 - Defer autofocus until after frame construction. r=bz

The autofocus attribute on form elements forces layout in CheckIfFocusable.
To avoid unpleasant FOUCs, defer autofocus processing until frames are
constructed in PresShell::Initialize.

Resolve the race between nsAutoFocusEvent running and page load by checking the
readystate at time of event posting. Skip autofocus if the element moved to a
different window in the meantime.

MozReview-Commit-ID: 90jiJYJWmRg
This commit is contained in:
decltype
2018-01-08 22:35:00 +01:00
parent 8735f74909
commit 402ab7cd6d
6 changed files with 142 additions and 63 deletions

View File

@@ -1817,6 +1817,8 @@ PresShell::Initialize(nscoord aWidth, nscoord aHeight)
NS_ENSURE_STATE(!mHaveShutDown);
}
mDocument->TriggerAutoFocus();
NS_ASSERTION(rootFrame, "How did that happen?");
// Note: when the frame was created above it had the NS_FRAME_IS_DIRTY bit