Coverage Report

Created: 2018-09-25 14:53

/work/obj-fuzz/dist/include/mozilla/dom/ImageData.h
Line
Count
Source (jump to first uncovered line)
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_ImageData_h
8
#define mozilla_dom_ImageData_h
9
10
#include "mozilla/Attributes.h"
11
#include "mozilla/dom/BindingUtils.h"
12
#include "mozilla/dom/TypedArray.h"
13
#include <stdint.h>
14
15
#include "nsCycleCollectionParticipant.h"
16
#include "nsISupportsImpl.h"
17
#include "js/RootingAPI.h"
18
19
namespace mozilla {
20
namespace dom {
21
22
class ImageData final : public nsISupports
23
{
24
  ~ImageData()
25
0
  {
26
0
    DropData();
27
0
  }
28
29
public:
30
  ImageData(uint32_t aWidth, uint32_t aHeight, JSObject& aData)
31
    : mWidth(aWidth)
32
    , mHeight(aHeight)
33
    , mData(&aData)
34
0
  {
35
0
    HoldData();
36
0
  }
37
38
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
39
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageData)
40
41
  static already_AddRefed<ImageData>
42
    Constructor(const GlobalObject& aGlobal,
43
                const uint32_t aWidth,
44
                const uint32_t aHeight,
45
                ErrorResult& aRv);
46
47
  static already_AddRefed<ImageData>
48
    Constructor(const GlobalObject& aGlobal,
49
                const Uint8ClampedArray& aData,
50
                const uint32_t aWidth,
51
                const Optional<uint32_t>& aHeight,
52
                ErrorResult& aRv);
53
54
  uint32_t Width() const
55
0
  {
56
0
    return mWidth;
57
0
  }
58
  uint32_t Height() const
59
0
  {
60
0
    return mHeight;
61
0
  }
62
  void GetData(JSContext* cx, JS::MutableHandle<JSObject*> aData) const
63
0
  {
64
0
    aData.set(GetDataObject());
65
0
  }
66
  JSObject* GetDataObject() const
67
0
  {
68
0
    return mData;
69
0
  }
70
71
  bool WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto, JS::MutableHandle<JSObject*> aReflector);
72
73
private:
74
  void HoldData();
75
  void DropData();
76
77
  ImageData() = delete;
78
79
  uint32_t mWidth, mHeight;
80
  JS::Heap<JSObject*> mData;
81
};
82
83
} // namespace dom
84
} // namespace mozilla
85
86
#endif // mozilla_dom_ImageData_h