diff options
author | Moonchild <moonchild@palemoon.org> | 2020-09-23 23:45:46 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-09-23 23:45:46 +0000 |
commit | 9f5c27ba479c54d4ebb1bd59b61fbf793f6df93f (patch) | |
tree | 831e0ae1649d6135429def03688bc93ff7c86b03 /layout/style/MediaQueryList.h | |
parent | 42f895f27f239e973c9c06241f7a58da7381353c (diff) | |
parent | f624bd1375655dea196cdcb70a9860bc5817df49 (diff) | |
download | UXP-RELBASE_20200929.tar UXP-RELBASE_20200929.tar.gz UXP-RELBASE_20200929.tar.lz UXP-RELBASE_20200929.tar.xz UXP-RELBASE_20200929.zip |
Merge branch 'redwood' into releaseRELBASE_20200929RC_20200924
Diffstat (limited to 'layout/style/MediaQueryList.h')
-rw-r--r-- | layout/style/MediaQueryList.h | 48 |
1 files changed, 30 insertions, 18 deletions
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<MediaQueryList> mql; - RefPtr<mozilla::dom::MediaQueryListListener> callback; - }; - - // Appends listeners that need notification to aListenersToNotify - void MediumFeaturesChanged(nsTArray<HandleChangeData>& aListenersToNotify); - - bool HasListeners() const { return !mCallbacks.IsEmpty(); } - - void RemoveAllListeners(); + void MaybeNotify(); JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> 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<bool>& 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<nsMediaList> mMediaList; bool mMatches; bool mMatchesValid; - nsTArray<RefPtr<mozilla::dom::MediaQueryListListener>> mCallbacks; + bool mIsKeptAlive; }; } // namespace dom |