From 388b9c8022986c3d83bc622b79a742b3c3ea671f 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/style/MediaQueryList.h | 48 +++++++++++++++++++++++++++---------------- 1 file changed, 30 insertions(+), 18 deletions(-) (limited to 'layout/style/MediaQueryList.h') diff --git a/layout/style/MediaQueryList.h b/layout/style/MediaQueryList.h index 5ba568528..d2acb34c1 100644 --- a/layout/style/MediaQueryList.h +++ b/layout/style/MediaQueryList.h @@ -16,6 +16,7 @@ #include "prclist.h" #include "mozilla/Attributes.h" #include "nsWrapperCache.h" +#include "mozilla/DOMEventTargetHelper.h" #include "mozilla/dom/MediaQueryListBinding.h" class nsIDocument; @@ -24,8 +25,7 @@ class nsMediaList; namespace mozilla { namespace dom { -class MediaQueryList final : public nsISupports, - public nsWrapperCache, +class MediaQueryList final : public DOMEventTargetHelper, public PRCList { public: @@ -37,33 +37,45 @@ private: ~MediaQueryList(); public: - NS_DECL_CYCLE_COLLECTING_ISUPPORTS - NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaQueryList) + NS_DECL_ISUPPORTS_INHERITED + NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(MediaQueryList, DOMEventTargetHelper) nsISupports* GetParentObject() const; - struct HandleChangeData { - RefPtr mql; - RefPtr callback; - }; - - // Appends listeners that need notification to aListenersToNotify - void MediumFeaturesChanged(nsTArray& aListenersToNotify); - - bool HasListeners() const { return !mCallbacks.IsEmpty(); } - - void RemoveAllListeners(); + void MaybeNotify(); JSObject* WrapObject(JSContext* aCx, JS::Handle aGivenProto) override; // WebIDL methods void GetMedia(nsAString& aMedia); bool Matches(); - void AddListener(mozilla::dom::MediaQueryListListener& aListener); - void RemoveListener(mozilla::dom::MediaQueryListListener& aListener); + void AddListener(EventListener* aListener, ErrorResult& aRv); + void RemoveListener(EventListener* aListener, ErrorResult& aRv); + + EventHandlerNonNull* GetOnchange(); + void SetOnchange(EventHandlerNonNull* aCallback); + + using nsIDOMEventTarget::AddEventListener; + using nsIDOMEventTarget::RemoveEventListener; + + virtual void AddEventListener(const nsAString& aType, + EventListener* aCallback, + const AddEventListenerOptionsOrBoolean& aOptions, + const Nullable& aWantsUntrusted, + ErrorResult& aRv) override; + virtual void RemoveEventListener(const nsAString& aType, + EventListener* aCallback, + const EventListenerOptionsOrBoolean& aOptions, + ErrorResult& aRv) override; + + bool HasListeners(); + + void Disconnect(); private: void RecomputeMatches(); + + void UpdateMustKeepAlive(); // We only need a pointer to the document to support lazy // reevaluation following dynamic changes. However, this lazy @@ -84,7 +96,7 @@ private: RefPtr mMediaList; bool mMatches; bool mMatchesValid; - nsTArray> mCallbacks; + bool mIsKeptAlive; }; } // namespace dom -- cgit v1.2.3 From 528b88d7048728c70227817ab59223e329171d15 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 23 Sep 2020 15:14:30 +0000 Subject: Issue #1656 - Part 3: Nuke more vim config lines in the tree. Another S&R run with some smarter matching. --- layout/style/MediaQueryList.h | 1 - 1 file changed, 1 deletion(-) (limited to 'layout/style/MediaQueryList.h') diff --git a/layout/style/MediaQueryList.h b/layout/style/MediaQueryList.h index d2acb34c1..b660d523e 100644 --- a/layout/style/MediaQueryList.h +++ b/layout/style/MediaQueryList.h @@ -1,5 +1,4 @@ /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/* vim: set shiftwidth=2 tabstop=8 autoindent cindent expandtab: */ /* 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/. */ -- cgit v1.2.3