1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim:set ts=2 sw=2 et tw=78: */
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 file,
5  * You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_dom_ScreenLuminance_h
8 #define mozilla_dom_ScreenLuminance_h
9 
10 #include "nsCycleCollectionParticipant.h"
11 #include "nsISupportsImpl.h"
12 #include "nsWrapperCache.h"
13 
14 class nsScreen;
15 
16 namespace mozilla {
17 namespace dom {
18 
19 class ScreenLuminance final : public nsWrapperCache {
20  public:
21   // Ref counting and cycle collection
NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(ScreenLuminance)22   NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(ScreenLuminance)
23   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(ScreenLuminance)
24 
25   // WebIDL methods
26   double Min() const { return mMin; }
Max()27   double Max() const { return mMax; }
MaxAverage()28   double MaxAverage() const { return mMaxAverage; }
29   // End WebIDL methods
30 
ScreenLuminance(nsScreen * aScreen,double aMin,double aMax,double aMaxAverage)31   ScreenLuminance(nsScreen* aScreen, double aMin, double aMax,
32                   double aMaxAverage)
33       : mScreen(aScreen), mMin(aMin), mMax(aMax), mMaxAverage(aMaxAverage) {}
34 
GetParentObject()35   nsScreen* GetParentObject() const { return mScreen; }
36   JSObject* WrapObject(JSContext* aCx,
37                        JS::Handle<JSObject*> aGivenProto) override;
38 
39  private:
40   virtual ~ScreenLuminance() = default;
41 
42   RefPtr<nsScreen> mScreen;
43   double mMin;
44   double mMax;
45   double mMaxAverage;
46 };
47 
48 }  // namespace dom
49 }  // namespace mozilla
50 
51 #endif  // mozilla_dom_ScreenLuminance_h
52