summaryrefslogtreecommitdiffstats
path: root/dom
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-09-23 08:24:14 +0000
committerMoonchild <moonchild@palemoon.org>2020-09-23 08:24:14 +0000
commit388b9c8022986c3d83bc622b79a742b3c3ea671f (patch)
tree92ba7f74c385b906686e034e4c4620263f104ca6 /dom
parentf5e5b5c32e9439973a430b7cc0159d754b53dba6 (diff)
downloadUXP-388b9c8022986c3d83bc622b79a742b3c3ea671f.tar
UXP-388b9c8022986c3d83bc622b79a742b3c3ea671f.tar.gz
UXP-388b9c8022986c3d83bc622b79a742b3c3ea671f.tar.lz
UXP-388b9c8022986c3d83bc622b79a742b3c3ea671f.tar.xz
UXP-388b9c8022986c3d83bc622b79a742b3c3ea671f.zip
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.
Diffstat (limited to 'dom')
-rw-r--r--dom/base/nsDocument.cpp2
-rw-r--r--dom/webidl/MediaQueryList.webidl16
-rw-r--r--dom/webidl/MediaQueryListEvent.webidl18
-rw-r--r--dom/webidl/moz.build1
4 files changed, 30 insertions, 7 deletions
diff --git a/dom/base/nsDocument.cpp b/dom/base/nsDocument.cpp
index 5bf89f26a..3c427704f 100644
--- a/dom/base/nsDocument.cpp
+++ b/dom/base/nsDocument.cpp
@@ -1785,7 +1785,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(nsDocument)
l != &tmp->mDOMMediaQueryLists; ) {
PRCList *next = PR_NEXT_LINK(l);
MediaQueryList *mql = static_cast<MediaQueryList*>(l);
- mql->RemoveAllListeners();
+ mql->Disconnect();
l = next;
}
diff --git a/dom/webidl/MediaQueryList.webidl b/dom/webidl/MediaQueryList.webidl
index 519ddb0e5..af641a268 100644
--- a/dom/webidl/MediaQueryList.webidl
+++ b/dom/webidl/MediaQueryList.webidl
@@ -4,17 +4,21 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* The origin of this IDL file is
- * http://dev.w3.org/csswg/cssom-view/#the-mediaquerylist-interface
+ * https://drafts.csswg.org/cssom-view/#mediaquerylist
*
* Copyright © 2012 W3C® (MIT, ERCIM, Keio), All Rights Reserved. W3C
* liability, trademark and document use rules apply.
*/
-interface MediaQueryList {
+interface MediaQueryList : EventTarget {
readonly attribute DOMString media;
readonly attribute boolean matches;
- void addListener(MediaQueryListListener listener);
- void removeListener(MediaQueryListListener listener);
-};
-callback MediaQueryListListener = void (MediaQueryList list);
+ [Throws]
+ void addListener(EventListener? listener);
+
+ [Throws]
+ void removeListener(EventListener? listener);
+
+ attribute EventHandler onchange;
+};
diff --git a/dom/webidl/MediaQueryListEvent.webidl b/dom/webidl/MediaQueryListEvent.webidl
new file mode 100644
index 000000000..f3a66fb57
--- /dev/null
+++ b/dom/webidl/MediaQueryListEvent.webidl
@@ -0,0 +1,18 @@
+/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/.
+ *
+ * https://drafts.csswg.org/cssom-view/#mediaquerylistevent
+ */
+
+[Constructor(DOMString type, optional MediaQueryListEventInit eventInitDict)]
+interface MediaQueryListEvent : Event {
+ readonly attribute DOMString media;
+ readonly attribute boolean matches;
+};
+
+dictionary MediaQueryListEventInit : EventInit {
+ DOMString media = "";
+ boolean matches = false;
+};
diff --git a/dom/webidl/moz.build b/dom/webidl/moz.build
index 7dc30a897..041969fdd 100644
--- a/dom/webidl/moz.build
+++ b/dom/webidl/moz.build
@@ -681,6 +681,7 @@ GENERATED_EVENTS_WEBIDL_FILES = [
'HashChangeEvent.webidl',
'HiddenPluginEvent.webidl',
'ImageCaptureErrorEvent.webidl',
+ 'MediaQueryListEvent.webidl',
'MediaStreamEvent.webidl',
'MediaStreamTrackEvent.webidl',
'MozSettingsEvent.webidl',