Bug 934785: Only change the popup control state on the main thread. r=smaug
authorKyle Huey <khuey@kylehuey.com>
Tue, 05 Nov 2013 22:16:26 +0800
changeset 153625 782ffc958634445db5a6b765e9898426422a66c1
parent 153624 aab2a2b73b900689ad2b16dcd7f3ba694c4fcf2e
child 153626 2e66e700722394f2329aace31a28f0d4f9b8cea5
push id25596
push userryanvm@gmail.com
push dateTue, 05 Nov 2013 20:28:59 +0000
treeherdermozilla-central@8b89e6626298 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs934785
milestone28.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 934785: Only change the popup control state on the main thread. r=smaug
content/events/src/nsEventListenerManager.cpp
dom/base/nsGlobalWindow.cpp
--- a/content/events/src/nsEventListenerManager.cpp
+++ b/content/events/src/nsEventListenerManager.cpp
@@ -976,17 +976,21 @@ nsEventListenerManager::HandleEventInter
                                             nsCxPusher* aPusher)
 {
   //Set the value of the internal PreventDefault flag properly based on aEventStatus
   if (*aEventStatus == nsEventStatus_eConsumeNoDefault) {
     aEvent->mFlags.mDefaultPrevented = true;
   }
 
   nsAutoTObserverArray<nsListenerStruct, 2>::EndLimitedIterator iter(mListeners);
-  nsAutoPopupStatePusher popupStatePusher(nsDOMEvent::GetEventPopupControlState(aEvent));
+  Maybe<nsAutoPopupStatePusher> popupStatePusher;
+  if (mIsMainThreadELM) {
+    popupStatePusher.construct(nsDOMEvent::GetEventPopupControlState(aEvent));
+  }
+
   bool hasListener = false;
   while (iter.HasMore()) {
     if (aEvent->mFlags.mImmediatePropagationStopped) {
       break;
     }
     nsListenerStruct* ls = &iter.GetNext();
     // Check that the phase is same in event and event listener.
     // Handle only trusted events, except when listener permits untrusted events.
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1941,28 +1941,32 @@ nsGlobalWindow::SetInitialPrincipalToSub
     nsRect r = shell->GetPresContext()->GetVisibleArea();
     shell->Initialize(r.width, r.height);
   }
 }
 
 PopupControlState
 PushPopupControlState(PopupControlState aState, bool aForce)
 {
+  MOZ_ASSERT(NS_IsMainThread());
+
   PopupControlState oldState = gPopupControlState;
 
   if (aState < gPopupControlState || aForce) {
     gPopupControlState = aState;
   }
 
   return oldState;
 }
 
 void
 PopPopupControlState(PopupControlState aState)
 {
+  MOZ_ASSERT(NS_IsMainThread());
+
   gPopupControlState = aState;
 }
 
 PopupControlState
 nsGlobalWindow::PushPopupControlState(PopupControlState aState,
                                       bool aForce) const
 {
   return ::PushPopupControlState(aState, aForce);
@@ -1972,16 +1976,17 @@ void
 nsGlobalWindow::PopPopupControlState(PopupControlState aState) const
 {
   ::PopPopupControlState(aState);
 }
 
 PopupControlState
 nsGlobalWindow::GetPopupControlState() const
 {
+  MOZ_ASSERT(NS_IsMainThread());
   return gPopupControlState;
 }
 
 #define WINDOWSTATEHOLDER_IID \
 {0x0b917c3e, 0xbd50, 0x4683, {0xaf, 0xc9, 0xc7, 0x81, 0x07, 0xae, 0x33, 0x26}}
 
 class WindowStateHolder MOZ_FINAL : public nsISupports
 {