Line data Source code
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 final : public mozilla::dom::CSSValue,
15 : public nsIDOMCSSValueList
16 : {
17 : public:
18 : NS_DECL_CYCLE_COLLECTING_ISUPPORTS
19 0 : 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 :
27 : /**
28 : * Adds a value to this list.
29 : */
30 : void AppendCSSValue(already_AddRefed<CSSValue> aValue);
31 :
32 : virtual void GetCssText(nsString& aText, mozilla::ErrorResult& aRv)
33 : override final;
34 : virtual void SetCssText(const nsAString& aText,
35 : mozilla::ErrorResult& aRv) override final;
36 : virtual uint16_t CssValueType() const override final;
37 :
38 0 : CSSValue* IndexedGetter(uint32_t aIdx, bool& aFound) const
39 : {
40 0 : aFound = aIdx <= Length();
41 0 : return Item(aIdx);
42 : }
43 :
44 0 : CSSValue* Item(uint32_t aIndex) const
45 : {
46 0 : return mCSSValues.SafeElementAt(aIndex);
47 : }
48 :
49 0 : uint32_t Length() const
50 : {
51 0 : return mCSSValues.Length();
52 : }
53 :
54 0 : nsISupports* GetParentObject()
55 : {
56 0 : return nullptr;
57 : }
58 :
59 : virtual JSObject *WrapObject(JSContext *cx, JS::Handle<JSObject*> aGivenProto) override;
60 :
61 : private:
62 : ~nsDOMCSSValueList();
63 :
64 : bool mCommaDelimited; // some value lists use a comma
65 : // as the delimiter, some just use
66 : // spaces.
67 :
68 : bool mReadonly; // Are we read-only?
69 :
70 : InfallibleTArray<RefPtr<CSSValue> > mCSSValues;
71 : };
72 :
73 : #endif /* nsDOMCSSValueList_h___ */
|