Bug 1396323 - Don't initialize HTMLInputElement editor for eVoidEvent. r=ehsan
authorRyan Hunt <rhunt@eqrion.net>
Tue, 05 Sep 2017 15:09:53 -0500
changeset 379368 3067ce95b439
parent 379367 10405ae76f20
child 379369 ef59984ad7b0
push id32453
push userarchaeopteryx@coole-files.de
push date2017-09-07 10:39 +0000
treeherdermozilla-central@37b95547f0d2 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1396323
milestone57.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1396323 - Don't initialize HTMLInputElement editor for eVoidEvent. r=ehsan Keyboard APZ dispatches an eVoidEvent to gather all event targets that a key event would normally go to. This can sometimes trigger an HTMLInputElement to initialize its editor, which can cause unnecessary DOM modifications. MozReview-Commit-ID: 6EEttouVB81
dom/html/HTMLInputElement.cpp
--- a/dom/html/HTMLInputElement.cpp
+++ b/dom/html/HTMLInputElement.cpp
@@ -3567,23 +3567,27 @@ HTMLInputElement::SelectAll(nsPresContex
 bool
 HTMLInputElement::NeedToInitializeEditorForEvent(
                     EventChainPreVisitor& aVisitor) const
 {
   // We only need to initialize the editor for single line input controls because they
   // are lazily initialized.  We don't need to initialize the control for
   // certain types of events, because we know that those events are safe to be
   // handled without the editor being initialized.  These events include:
-  // mousein/move/out, overflow/underflow, and DOM mutation events.
+  // mousein/move/out, overflow/underflow, DOM mutation, and void events. Void
+  // events are dispatched frequently by async keyboard scrolling to focused
+  // elements, so it's important to handle them to prevent excessive DOM
+  // mutations.
   if (!IsSingleLineTextControl(false) ||
       aVisitor.mEvent->mClass == eMutationEventClass) {
     return false;
   }
 
   switch (aVisitor.mEvent->mMessage) {
+  case eVoidEvent:
   case eMouseMove:
   case eMouseEnterIntoWidget:
   case eMouseExitFromWidget:
   case eMouseOver:
   case eMouseOut:
   case eScrollPortUnderflow:
   case eScrollPortOverflow:
     return false;