Bug 971393 PresShell shouldn't discard events which won't cause DOM events even while it's not safe to dispatch DOM events r=smaug
authorMasayuki Nakano <masayuki@d-toybox.com>
Thu, 10 Jul 2014 13:47:03 +0900
changeset 193243 24e6a1f858970c9f4c40ec40d6934513d9fd325d
parent 193242 3988e2a46e9f6f82ef3274baaaffaa09b54bc83b
child 193244 72b71b739c1e11903a53ee9d84c0ac7374d4722c
push id27112
push usercbook@mozilla.com
push dateThu, 10 Jul 2014 12:47:23 +0000
treeherdermozilla-central@6e9f72bdd32e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs971393
milestone33.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 971393 PresShell shouldn't discard events which won't cause DOM events even while it's not safe to dispatch DOM events r=smaug
layout/base/nsPresShell.cpp
--- a/layout/base/nsPresShell.cpp
+++ b/layout/base/nsPresShell.cpp
@@ -6867,18 +6867,26 @@ PresShell::HandleEvent(nsIFrame* aFrame,
       }
     }
   }
 
   if (sPointerEventEnabled) {
     UpdateActivePointerState(aEvent);
   }
 
-  if (!nsContentUtils::IsSafeToRunScript())
+  if (!nsContentUtils::IsSafeToRunScript() &&
+      aEvent->IsAllowedToDispatchDOMEvent()) {
+#ifdef DEBUG
+    if (aEvent->IsIMERelatedEvent()) {
+      nsPrintfCString warning("%d event is discarded", aEvent->message);
+      NS_WARNING(warning.get());
+    }
+#endif
     return NS_OK;
+  }
 
   nsIContent* capturingContent =
     (aEvent->HasMouseEventMessage() ||
      aEvent->eventStructType == NS_WHEEL_EVENT ? GetCapturingContent() :
                                                  nullptr);
 
   nsCOMPtr<nsIDocument> retargetEventDoc;
   if (!aDontRetargetEvents) {
@@ -7716,16 +7724,18 @@ PresShell::HandleEventInternal(WidgetEve
     // 2. Give event to the DOM for third party and JS use.
     if (NS_SUCCEEDED(rv)) {
       bool wasHandlingKeyBoardEvent =
         nsContentUtils::IsHandlingKeyBoardEvent();
       if (aEvent->eventStructType == NS_KEY_EVENT) {
         nsContentUtils::SetIsHandlingKeyBoardEvent(true);
       }
       if (aEvent->IsAllowedToDispatchDOMEvent()) {
+        MOZ_ASSERT(nsContentUtils::IsSafeToRunScript(),
+          "Somebody changed aEvent to cause a DOM event!");
         nsPresShellEventCB eventCB(this);
         if (aEvent->eventStructType == NS_TOUCH_EVENT) {
           DispatchTouchEvent(aEvent, aStatus, &eventCB, touchIsNew);
         } else {
           nsCOMPtr<nsINode> eventTarget = mCurrentEventContent.get();
           nsPresShellEventCB* eventCBPtr = &eventCB;
           if (!eventTarget) {
             nsCOMPtr<nsIContent> targetContent;