|
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 |
|
3 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
|
4 |
|
5 /* DOM object representing lists of values in DOM computed style */ |
|
6 |
|
7 #ifndef nsDOMCSSValueList_h___ |
|
8 #define nsDOMCSSValueList_h___ |
|
9 |
|
10 #include "nsIDOMCSSValueList.h" |
|
11 #include "CSSValue.h" |
|
12 #include "nsTArray.h" |
|
13 |
|
14 class nsDOMCSSValueList MOZ_FINAL : public mozilla::dom::CSSValue, |
|
15 public nsIDOMCSSValueList |
|
16 { |
|
17 public: |
|
18 NS_DECL_CYCLE_COLLECTING_ISUPPORTS |
|
19 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_AMBIGUOUS(nsDOMCSSValueList, mozilla::dom::CSSValue) |
|
20 |
|
21 // nsIDOMCSSValue |
|
22 NS_DECL_NSIDOMCSSVALUE |
|
23 |
|
24 // nsDOMCSSValueList |
|
25 nsDOMCSSValueList(bool aCommaDelimited, bool aReadonly); |
|
26 ~nsDOMCSSValueList(); |
|
27 |
|
28 /** |
|
29 * Adds a value to this list. |
|
30 */ |
|
31 void AppendCSSValue(CSSValue* aValue); |
|
32 |
|
33 virtual void GetCssText(nsString& aText, mozilla::ErrorResult& aRv) |
|
34 MOZ_OVERRIDE MOZ_FINAL; |
|
35 virtual void SetCssText(const nsAString& aText, |
|
36 mozilla::ErrorResult& aRv) MOZ_OVERRIDE MOZ_FINAL; |
|
37 virtual uint16_t CssValueType() const MOZ_OVERRIDE MOZ_FINAL; |
|
38 |
|
39 CSSValue* IndexedGetter(uint32_t aIdx, bool& aFound) const |
|
40 { |
|
41 aFound = aIdx <= Length(); |
|
42 return Item(aIdx); |
|
43 } |
|
44 |
|
45 CSSValue* Item(uint32_t aIndex) const |
|
46 { |
|
47 return mCSSValues.SafeElementAt(aIndex); |
|
48 } |
|
49 |
|
50 uint32_t Length() const |
|
51 { |
|
52 return mCSSValues.Length(); |
|
53 } |
|
54 |
|
55 nsISupports* GetParentObject() |
|
56 { |
|
57 return nullptr; |
|
58 } |
|
59 |
|
60 virtual JSObject *WrapObject(JSContext *cx) MOZ_OVERRIDE; |
|
61 |
|
62 private: |
|
63 bool mCommaDelimited; // some value lists use a comma |
|
64 // as the delimiter, some just use |
|
65 // spaces. |
|
66 |
|
67 bool mReadonly; // Are we read-only? |
|
68 |
|
69 InfallibleTArray<nsRefPtr<CSSValue> > mCSSValues; |
|
70 }; |
|
71 |
|
72 #endif /* nsDOMCSSValueList_h___ */ |