content/canvas/src/CanvasPattern.h

branch
TOR_BUG_9701
changeset 11
deefc01c0e14
equal deleted inserted replaced
-1:000000000000 0:b4f614642a51
1 /* This Source Code Form is subject to the terms of the Mozilla Public
2 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
3 * You can obtain one at http://mozilla.org/MPL/2.0/. */
4
5 #ifndef mozilla_dom_CanvasPattern_h
6 #define mozilla_dom_CanvasPattern_h
7
8 #include "mozilla/Attributes.h"
9 #include "mozilla/dom/CanvasRenderingContext2DBinding.h"
10 #include "mozilla/dom/CanvasRenderingContext2D.h"
11 #include "mozilla/RefPtr.h"
12 #include "nsISupports.h"
13 #include "nsWrapperCache.h"
14
15 class nsIPrincipal;
16
17 namespace mozilla {
18 namespace gfx {
19 class SourceSurface;
20 }
21
22 namespace dom {
23
24 class CanvasPattern MOZ_FINAL : public nsWrapperCache
25 {
26 public:
27 NS_INLINE_DECL_CYCLE_COLLECTING_NATIVE_REFCOUNTING(CanvasPattern)
28 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_NATIVE_CLASS(CanvasPattern)
29
30 MOZ_BEGIN_NESTED_ENUM_CLASS(RepeatMode, uint8_t)
31 REPEAT,
32 REPEATX,
33 REPEATY,
34 NOREPEAT
35 MOZ_END_NESTED_ENUM_CLASS(RepeatMode)
36
37 CanvasPattern(CanvasRenderingContext2D* aContext,
38 gfx::SourceSurface* aSurface,
39 RepeatMode aRepeat,
40 nsIPrincipal* principalForSecurityCheck,
41 bool forceWriteOnly,
42 bool CORSUsed)
43 : mContext(aContext)
44 , mSurface(aSurface)
45 , mPrincipal(principalForSecurityCheck)
46 , mForceWriteOnly(forceWriteOnly)
47 , mCORSUsed(CORSUsed)
48 , mRepeat(aRepeat)
49 {
50 SetIsDOMBinding();
51 }
52
53 JSObject* WrapObject(JSContext* aCx) MOZ_OVERRIDE
54 {
55 return CanvasPatternBinding::Wrap(aCx, this);
56 }
57
58 CanvasRenderingContext2D* GetParentObject()
59 {
60 return mContext;
61 }
62
63 nsRefPtr<CanvasRenderingContext2D> mContext;
64 RefPtr<gfx::SourceSurface> mSurface;
65 nsCOMPtr<nsIPrincipal> mPrincipal;
66 const bool mForceWriteOnly;
67 const bool mCORSUsed;
68 const RepeatMode mRepeat;
69 };
70
71 MOZ_FINISH_NESTED_ENUM_CLASS(CanvasPattern::RepeatMode)
72
73 }
74 }
75
76 #endif // mozilla_dom_CanvasPattern_h

mercurial