From 312f0b3a767112621278c97c1f5099e37238b337 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 23 Sep 2020 08:24:14 +0000 Subject: Issue #1655: Update MediaQueryList to the current draft spec. This make MediaQueryList inherit from EventTarget and adds MediaQueryListEvent as an interface as well as the onchange() method. This should not affect compatibility with other code; the event object is a MediaQueryListEvent instance, which is recognized as a MediaListQuery instance. --- layout/base/nsPresContext.cpp | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'layout/base') diff --git a/layout/base/nsPresContext.cpp b/layout/base/nsPresContext.cpp index befb5deb2..1d90b967a 100644 --- a/layout/base/nsPresContext.cpp +++ b/layout/base/nsPresContext.cpp @@ -1931,33 +1931,13 @@ nsPresContext::MediaFeatureValuesChanged(nsRestyleHint aRestyleHint, if (!PR_CLIST_IS_EMPTY(mDocument->MediaQueryLists())) { // We build a list of all the notifications we're going to send - // before we send any of them. (The spec says the notifications - // should be a queued task, so any removals that happen during the - // notifications shouldn't affect what gets notified.) Furthermore, - // we hold strong pointers to everything we're going to make - // notification calls to, since each notification involves calling - // arbitrary script that might otherwise destroy these objects, or, - // for that matter, |this|. - // - // Note that we intentionally send the notifications to media query - // list in the order they were created and, for each list, to the - // listeners in the order added. - nsTArray notifyList; + // before we send any of them. for (PRCList *l = PR_LIST_HEAD(mDocument->MediaQueryLists()); l != mDocument->MediaQueryLists(); l = PR_NEXT_LINK(l)) { + nsAutoMicroTask mt; MediaQueryList *mql = static_cast(l); - mql->MediumFeaturesChanged(notifyList); + mql->MaybeNotify(); } - - if (!notifyList.IsEmpty()) { - for (uint32_t i = 0, i_end = notifyList.Length(); i != i_end; ++i) { - nsAutoMicroTask mt; - MediaQueryList::HandleChangeData &d = notifyList[i]; - d.callback->Call(*d.mql); - } - } - - // NOTE: When |notifyList| goes out of scope, our destructor could run. } } -- cgit v1.2.3