Push a context on the stack when notifying a MediaQueryListListener. (Bug 652317) r=smaug
authorL. David Baron <dbaron@dbaron.org>
Sat, 23 Apr 2011 13:19:01 -0700
changeset 68475 26ba14209541b2574d423db589ebf11a87cc2129
parent 68474 296792b874b9ed81c7517a8dd2aa76f5e9323bbc
child 68476 ca06f7d30a9fadeb93675cf398f35dff6ca708ad
push id19656
push userdbaron@mozilla.com
push dateSat, 23 Apr 2011 20:19:42 +0000
treeherdermozilla-central@26ba14209541 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs652317
milestone6.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
Push a context on the stack when notifying a MediaQueryListListener. (Bug 652317) r=smaug
layout/base/nsPresContext.cpp
--- a/layout/base/nsPresContext.cpp
+++ b/layout/base/nsPresContext.cpp
@@ -1687,19 +1687,27 @@ nsPresContext::MediaFeatureValuesChanged
     // listeners in the order added.
     nsDOMMediaQueryList::NotifyList notifyList;
     for (PRCList *l = PR_LIST_HEAD(&mDOMMediaQueryLists);
          l != &mDOMMediaQueryLists; l = PR_NEXT_LINK(l)) {
       nsDOMMediaQueryList *mql = static_cast<nsDOMMediaQueryList*>(l);
       mql->MediumFeaturesChanged(notifyList);
     }
 
-    for (PRUint32 i = 0, i_end = notifyList.Length(); i != i_end; ++i) {
-      nsDOMMediaQueryList::HandleChangeData &d = notifyList[i];
-      d.listener->HandleChange(d.mql);
+    if (!notifyList.IsEmpty()) {
+      nsPIDOMWindow *win = mDocument->GetInnerWindow();
+      nsCOMPtr<nsPIDOMEventTarget> et = do_QueryInterface(win);
+      nsCxPusher pusher;
+
+      for (PRUint32 i = 0, i_end = notifyList.Length(); i != i_end; ++i) {
+        if (pusher.RePush(et)) {
+          nsDOMMediaQueryList::HandleChangeData &d = notifyList[i];
+          d.listener->HandleChange(d.mql);
+        }
+      }
     }
 
     // NOTE:  When |notifyList| goes out of scope, our destructor could run.
   }
 }
 
 void
 nsPresContext::PostMediaFeatureValuesChangedEvent()