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 428852 3067ce95b439f75c85c57f51d54623edf5eafa24
parent 428851 10405ae76f204c476465dcfaca4cd6b4edfcc444
child 428853 ef59984ad7b0ef0e882d6c48b1c0bc6a1a9e2932
push id7761
push userjlund@mozilla.com
push dateFri, 15 Sep 2017 00:19:52 +0000
treeherdermozilla-beta@c38455951db4 [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;