Bumping manifests a=b2g-bump
[gecko.git] / layout / style / nsDOMCSSValueList.cpp
blobcd8f3ed9910e6bac2e2d560d8f2365e661bd36d6
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/. */
5 /* DOM object representing lists of values in DOM computed style */
7 #include "nsDOMCSSValueList.h"
8 #include "mozilla/dom/CSSValueListBinding.h"
9 #include "nsAutoPtr.h"
11 using namespace mozilla;
13 nsDOMCSSValueList::nsDOMCSSValueList(bool aCommaDelimited, bool aReadonly)
14 : CSSValue(), mCommaDelimited(aCommaDelimited), mReadonly(aReadonly)
16 SetIsDOMBinding();
19 nsDOMCSSValueList::~nsDOMCSSValueList()
23 NS_IMPL_CYCLE_COLLECTING_ADDREF(nsDOMCSSValueList)
24 NS_IMPL_CYCLE_COLLECTING_RELEASE(nsDOMCSSValueList)
26 // QueryInterface implementation for nsDOMCSSValueList
27 NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(nsDOMCSSValueList)
28 NS_WRAPPERCACHE_INTERFACE_MAP_ENTRY
29 NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValue)
30 NS_INTERFACE_MAP_ENTRY(nsIDOMCSSValueList)
31 NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, CSSValue)
32 NS_INTERFACE_MAP_END
34 NS_IMPL_CYCLE_COLLECTION_WRAPPERCACHE(nsDOMCSSValueList, mCSSValues)
36 JSObject*
37 nsDOMCSSValueList::WrapObject(JSContext *cx)
39 return dom::CSSValueListBinding::Wrap(cx, this);
42 void
43 nsDOMCSSValueList::AppendCSSValue(CSSValue* aValue)
45 mCSSValues.AppendElement(aValue);
48 // nsIDOMCSSValue
50 NS_IMETHODIMP
51 nsDOMCSSValueList::GetCssText(nsAString& aCssText)
53 aCssText.Truncate();
55 uint32_t count = mCSSValues.Length();
57 nsAutoString separator;
58 if (mCommaDelimited) {
59 separator.AssignLiteral(", ");
61 else {
62 separator.Assign(char16_t(' '));
65 nsAutoString tmpStr;
66 for (uint32_t i = 0; i < count; ++i) {
67 CSSValue *cssValue = mCSSValues[i];
68 NS_ASSERTION(cssValue, "Eek! Someone filled the value list with null CSSValues!");
69 ErrorResult dummy;
70 if (cssValue) {
71 cssValue->GetCssText(tmpStr, dummy);
73 if (tmpStr.IsEmpty()) {
75 #ifdef DEBUG_caillon
76 NS_ERROR("Eek! An empty CSSValue! Bad!");
77 #endif
79 continue;
82 // If this isn't the first item in the list, then
83 // it's ok to append a separator.
84 if (!aCssText.IsEmpty()) {
85 aCssText.Append(separator);
87 aCssText.Append(tmpStr);
91 return NS_OK;
94 void
95 nsDOMCSSValueList::GetCssText(nsString& aText, ErrorResult& aRv)
97 aRv = GetCssText(aText);
100 NS_IMETHODIMP
101 nsDOMCSSValueList::SetCssText(const nsAString& aCssText)
103 if (mReadonly) {
104 return NS_ERROR_DOM_NO_MODIFICATION_ALLOWED_ERR;
107 NS_NOTYETIMPLEMENTED("Can't SetCssText yet: please write me!");
108 return NS_OK;
111 void
112 nsDOMCSSValueList::SetCssText(const nsAString& aText, ErrorResult& aRv)
114 aRv = SetCssText(aText);
117 NS_IMETHODIMP
118 nsDOMCSSValueList::GetCssValueType(uint16_t* aValueType)
120 NS_ENSURE_ARG_POINTER(aValueType);
121 *aValueType = nsIDOMCSSValue::CSS_VALUE_LIST;
122 return NS_OK;
125 uint16_t
126 nsDOMCSSValueList::CssValueType() const
128 return nsIDOMCSSValue::CSS_VALUE_LIST;