|
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 |
|
5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
6 |
|
7 #include "mozilla/dom/TextTrackRegion.h" |
|
8 #include "mozilla/dom/VTTRegionBinding.h" |
|
9 |
|
10 namespace mozilla { |
|
11 namespace dom { |
|
12 |
|
13 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_1(TextTrackRegion, mParent) |
|
14 NS_IMPL_CYCLE_COLLECTING_ADDREF(TextTrackRegion) |
|
15 NS_IMPL_CYCLE_COLLECTING_RELEASE(TextTrackRegion) |
|
16 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(TextTrackRegion) |
|
17 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
|
18 NS_INTERFACE_MAP_ENTRY(nsISupports) |
|
19 NS_INTERFACE_MAP_END |
|
20 |
|
21 JSObject* |
|
22 TextTrackRegion::WrapObject(JSContext* aCx) |
|
23 { |
|
24 return VTTRegionBinding::Wrap(aCx, this); |
|
25 } |
|
26 |
|
27 already_AddRefed<TextTrackRegion> |
|
28 TextTrackRegion::Constructor(const GlobalObject& aGlobal, ErrorResult& aRv) |
|
29 { |
|
30 nsCOMPtr<nsPIDOMWindow> window = do_QueryInterface(aGlobal.GetAsSupports()); |
|
31 if (!window) { |
|
32 aRv.Throw(NS_ERROR_FAILURE); |
|
33 return nullptr; |
|
34 } |
|
35 |
|
36 nsRefPtr<TextTrackRegion> region = new TextTrackRegion(aGlobal.GetAsSupports()); |
|
37 return region.forget(); |
|
38 } |
|
39 |
|
40 TextTrackRegion::TextTrackRegion(nsISupports* aGlobal) |
|
41 : mParent(aGlobal) |
|
42 , mWidth(100) |
|
43 , mLines(3) |
|
44 , mRegionAnchorX(0) |
|
45 , mRegionAnchorY(100) |
|
46 , mViewportAnchorX(0) |
|
47 , mViewportAnchorY(100) |
|
48 { |
|
49 SetIsDOMBinding(); |
|
50 } |
|
51 |
|
52 void |
|
53 TextTrackRegion::CopyValues(TextTrackRegion& aRegion) |
|
54 { |
|
55 mWidth = aRegion.Width(); |
|
56 mLines = aRegion.Lines(); |
|
57 mRegionAnchorX = aRegion.RegionAnchorX(); |
|
58 mRegionAnchorY = aRegion.RegionAnchorY(); |
|
59 mViewportAnchorX = aRegion.ViewportAnchorX(); |
|
60 mViewportAnchorY = aRegion.ViewportAnchorY(); |
|
61 mScroll = aRegion.Scroll(); |
|
62 } |
|
63 |
|
64 } //namespace dom |
|
65 } //namespace mozilla |
|
66 |