Bug 1377447 - Add a new flush type between Frames and InterruptibleLayout to initialize layout if needed and use it from CheckIfFocusable; r=smaug

This commit is contained in:
Ehsan Akhgari 2017-07-03 23:36:24 -04:00
parent a62cae74d4
commit d39018ac62
10 changed files with 25 additions and 8 deletions

View File

@ -27,12 +27,13 @@ enum class FlushType : uint8_t {
notifications. */
Style = 3, /* As above, plus flush style reresolution */
Frames = Style,
InterruptibleLayout = 4, /* As above, plus flush reflow,
EnsurePresShellInitAndFrames = 4, /* As above, plus ensure the pres shell is alive */
InterruptibleLayout = 5, /* As above, plus flush reflow,
but allow it to be interrupted (so
an incomplete layout may result) */
Layout = 5, /* As above, but layout must run to
Layout = 6, /* As above, but layout must run to
completion */
Display = 6, /* As above, plus flush painting */
Display = 7, /* As above, plus flush painting */
Count
};

View File

@ -1567,9 +1567,10 @@ nsFocusManager::CheckIfFocusable(nsIContent* aContent, uint32_t aFlags)
return nullptr;
}
// Make sure that our frames are up to date
// Make sure that our frames are up to date while ensuring the presshell is
// also initialized in case we come from an autofocus event.
mEventHandlingNeedsFlush = false;
doc->FlushPendingNotifications(FlushType::Frames);
doc->FlushPendingNotifications(FlushType::EnsurePresShellInitAndFrames);
nsIPresShell *shell = doc->GetShell();
if (!shell)

View File

@ -1068,7 +1068,7 @@ HTMLContentSink::FlushPendingNotifications(FlushType aType)
FlushTags();
}
}
if (aType >= FlushType::InterruptibleLayout) {
if (aType >= FlushType::EnsurePresShellInitAndFrames) {
// Make sure that layout has started so that the reflow flush
// will actually happen.
StartLayout(true);

View File

@ -1465,7 +1465,7 @@ nsXMLContentSink::FlushPendingNotifications(FlushType aType)
FlushText(false);
}
}
if (aType >= FlushType::InterruptibleLayout) {
if (aType >= FlushType::EnsurePresShellInitAndFrames) {
// Make sure that layout has started so that the reflow flush
// will actually happen.
MaybeStartLayout(true);

View File

@ -4090,6 +4090,9 @@ PresShell::DoFlushPendingNotifications(mozilla::ChangesToFlush aFlush)
"",
"Content",
"ContentAndNotify",
// As far as the profiler is concerned, EnsurePresShellInitAndFrames and
// Frames are the same
"Style",
"Style",
"InterruptibleLayout",
"Layout",

View File

@ -0,0 +1,3 @@
<!DOCTYPE html>
<html>
<input type="text" autofocus="">

View File

@ -0,0 +1,4 @@
<!DOCTYPE html>
<html>
<link rel="stylesheet" href="nothing">
<input type="text" autofocus="">

View File

@ -0,0 +1,3 @@
<!DOCTYPE html>
<html>
<input type="text">

View File

@ -2032,3 +2032,5 @@ fails-if(!stylo||styloVsGecko) == 1365162-1.html 1365162-1-ref.html
== 1375674.html 1375674-ref.html
== 1372041.html 1372041-ref.html
== 1376092.html 1376092-ref.html
== 1377447-1.html 1377447-1-ref.html
!= 1377447-1.html 1377447-2.html

View File

@ -216,7 +216,7 @@ nsHtml5TreeOpExecutor::SetParser(nsParserBase* aParser)
void
nsHtml5TreeOpExecutor::FlushPendingNotifications(FlushType aType)
{
if (aType >= FlushType::InterruptibleLayout) {
if (aType >= FlushType::EnsurePresShellInitAndFrames) {
// Bug 577508 / 253951
nsContentSink::StartLayout(true);
}