|
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ |
|
2 /* This Source Code Form is subject to the terms of the Mozilla Public |
|
3 * License, v. 2.0. If a copy of the MPL was not distributed with this |
|
4 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
5 |
|
6 /* DOM object representing rectangle values in DOM computed style */ |
|
7 |
|
8 #include "mozilla/dom/RectBinding.h" |
|
9 #include "nsROCSSPrimitiveValue.h" |
|
10 #include "nsDOMCSSRect.h" |
|
11 |
|
12 using namespace mozilla; |
|
13 |
|
14 nsDOMCSSRect::nsDOMCSSRect(nsROCSSPrimitiveValue* aTop, |
|
15 nsROCSSPrimitiveValue* aRight, |
|
16 nsROCSSPrimitiveValue* aBottom, |
|
17 nsROCSSPrimitiveValue* aLeft) |
|
18 : mTop(aTop), mRight(aRight), mBottom(aBottom), mLeft(aLeft) |
|
19 { |
|
20 SetIsDOMBinding(); |
|
21 } |
|
22 |
|
23 nsDOMCSSRect::~nsDOMCSSRect(void) |
|
24 { |
|
25 } |
|
26 |
|
27 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCSSRect) |
|
28 NS_INTERFACE_MAP_ENTRY(nsIDOMRect) |
|
29 NS_INTERFACE_MAP_ENTRY(nsISupports) |
|
30 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY |
|
31 NS_INTERFACE_MAP_END |
|
32 |
|
33 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSRect) |
|
34 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSRect) |
|
35 |
|
36 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE_4(nsDOMCSSRect, mTop, mBottom, mLeft, mRight) |
|
37 |
|
38 JSObject* |
|
39 nsDOMCSSRect::WrapObject(JSContext* cx) |
|
40 { |
|
41 return dom::RectBinding::Wrap(cx, this); |
|
42 } |
|
43 |
|
44 NS_IMETHODIMP |
|
45 nsDOMCSSRect::GetTop(nsIDOMCSSPrimitiveValue** aTop) |
|
46 { |
|
47 NS_ENSURE_TRUE(mTop, NS_ERROR_NOT_INITIALIZED); |
|
48 *aTop = mTop; |
|
49 NS_ADDREF(*aTop); |
|
50 return NS_OK; |
|
51 } |
|
52 |
|
53 NS_IMETHODIMP |
|
54 nsDOMCSSRect::GetRight(nsIDOMCSSPrimitiveValue** aRight) |
|
55 { |
|
56 NS_ENSURE_TRUE(mRight, NS_ERROR_NOT_INITIALIZED); |
|
57 *aRight = mRight; |
|
58 NS_ADDREF(*aRight); |
|
59 return NS_OK; |
|
60 } |
|
61 |
|
62 NS_IMETHODIMP |
|
63 nsDOMCSSRect::GetBottom(nsIDOMCSSPrimitiveValue** aBottom) |
|
64 { |
|
65 NS_ENSURE_TRUE(mBottom, NS_ERROR_NOT_INITIALIZED); |
|
66 *aBottom = mBottom; |
|
67 NS_ADDREF(*aBottom); |
|
68 return NS_OK; |
|
69 } |
|
70 |
|
71 NS_IMETHODIMP |
|
72 nsDOMCSSRect::GetLeft(nsIDOMCSSPrimitiveValue** aLeft) |
|
73 { |
|
74 NS_ENSURE_TRUE(mLeft, NS_ERROR_NOT_INITIALIZED); |
|
75 *aLeft = mLeft; |
|
76 NS_ADDREF(*aLeft); |
|
77 return NS_OK; |
|
78 } |