Bug 1879449 [wpt PR 44489] - [wptrunner] Add `infrastructure/expected-fail/` test...
[gecko.git] / layout / style / MediaList.h
blobafa24195344a3c358c543ffc64d3acae81feaaf1
1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4 * License, v. 2.0. If a copy of the MPL was not distributed with this
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
7 /* base class for representation of media lists */
9 #ifndef mozilla_dom_MediaList_h
10 #define mozilla_dom_MediaList_h
12 #include "mozilla/dom/BindingDeclarations.h"
13 #include "mozilla/ServoBindingTypes.h"
14 #include "mozilla/ServoUtils.h"
16 #include "nsWrapperCache.h"
18 class nsMediaQueryResultCacheKey;
20 namespace mozilla {
21 class ErrorResult;
22 class StyleSheet;
24 namespace dom {
26 class Document;
28 class MediaList final : public nsISupports, public nsWrapperCache {
29 public:
30 NS_DECL_CYCLE_COLLECTING_ISUPPORTS
31 NS_DECL_CYCLE_COLLECTION_WRAPPERCACHE_CLASS(MediaList)
33 // Needed for CSSOM, but please don't use it outside of that :)
34 explicit MediaList(already_AddRefed<StyleLockedMediaList> aRawList)
35 : mRawList(aRawList) {}
37 static already_AddRefed<MediaList> Create(
38 const nsACString& aMedia, CallerType aCallerType = CallerType::NonSystem);
40 already_AddRefed<MediaList> Clone();
42 JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) final;
43 nsISupports* GetParentObject() const;
45 void GetText(nsACString&) const;
46 void SetText(const nsACString&);
47 bool Matches(const Document&) const;
48 bool IsViewportDependent() const;
50 void SetStyleSheet(StyleSheet* aSheet);
51 void SetRawAfterClone(RefPtr<StyleLockedMediaList> aRaw) {
52 mRawList = std::move(aRaw);
55 // WebIDL
56 void GetMediaText(nsACString& aMediaText) const {
57 return GetText(aMediaText);
59 void SetMediaText(const nsACString&);
60 uint32_t Length() const;
61 void IndexedGetter(uint32_t aIndex, bool& aFound, nsACString&) const;
62 void Item(uint32_t aIndex, nsACString&);
63 void DeleteMedium(const nsACString&, ErrorResult&);
64 void AppendMedium(const nsACString&, ErrorResult&);
66 size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const;
68 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
69 return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
72 protected:
73 MediaList(const nsACString& aMedia, CallerType);
74 MediaList();
76 void SetTextInternal(const nsACString& aMediaText, CallerType);
78 void Delete(const nsACString& aOldMedium, ErrorResult& aRv);
79 void Append(const nsACString& aNewMedium, ErrorResult& aRv);
81 ~MediaList() {
82 MOZ_ASSERT(!mStyleSheet, "Backpointer should have been cleared");
85 bool IsReadOnly() const;
87 // not refcounted; sheet will let us know when it goes away
88 // mStyleSheet is the sheet that needs to be dirtied when this
89 // medialist changes
90 StyleSheet* mStyleSheet = nullptr;
92 private:
93 template <typename Func>
94 inline void DoMediaChange(Func aCallback, ErrorResult& aRv);
95 RefPtr<StyleLockedMediaList> mRawList;
98 } // namespace dom
99 } // namespace mozilla
101 #endif // mozilla_dom_MediaList_h