Bug 1700051: part 48) Slightly simplify `mozInlineSpellWordUtil::FindRealWordContaini...
[gecko.git] / layout / style / MediaList.h
blob29ce7cfdc752cde1873601033a4675280e46b8a6
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_SCRIPT_HOLDER_CLASS(MediaList)
33 // Needed for CSSOM, but please don't use it outside of that :)
34 explicit MediaList(already_AddRefed<RawServoMediaList> 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& aMediaText);
46 void SetText(const nsACString& aMediaText);
47 bool Matches(const Document&) const;
49 void SetStyleSheet(StyleSheet* aSheet);
51 // WebIDL
52 void GetMediaText(nsACString& aMediaText);
53 void SetMediaText(const nsACString& aMediaText);
54 uint32_t Length();
55 void IndexedGetter(uint32_t aIndex, bool& aFound, nsACString& aReturn);
56 void Item(uint32_t aIndex, nsACString& aResult);
57 void DeleteMedium(const nsACString& aMedium, ErrorResult& aRv);
58 void AppendMedium(const nsACString& aMedium, ErrorResult& aRv);
60 size_t SizeOfExcludingThis(MallocSizeOf aMallocSizeOf) const;
62 size_t SizeOfIncludingThis(MallocSizeOf aMallocSizeOf) const {
63 return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
66 protected:
67 MediaList(const nsACString& aMedia, CallerType);
68 MediaList();
70 void SetTextInternal(const nsACString& aMediaText, CallerType);
72 void Delete(const nsACString& aOldMedium, ErrorResult& aRv);
73 void Append(const nsACString& aNewMedium, ErrorResult& aRv);
75 ~MediaList() {
76 MOZ_ASSERT(!mStyleSheet, "Backpointer should have been cleared");
79 bool IsReadOnly() const;
81 // not refcounted; sheet will let us know when it goes away
82 // mStyleSheet is the sheet that needs to be dirtied when this
83 // medialist changes
84 StyleSheet* mStyleSheet = nullptr;
86 private:
87 template <typename Func>
88 inline void DoMediaChange(Func aCallback, ErrorResult& aRv);
89 RefPtr<RawServoMediaList> mRawList;
92 } // namespace dom
93 } // namespace mozilla
95 #endif // mozilla_dom_MediaList_h