1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
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/. */
7 /* DOM object representing lists of values in DOM computed style */
9 #include "nsDOMCSSValueList.h"
13 #include "mozilla/ErrorResult.h"
16 using namespace mozilla
;
17 using namespace mozilla::dom
;
19 nsDOMCSSValueList::nsDOMCSSValueList(bool aCommaDelimited
)
20 : CSSValue(), mCommaDelimited(aCommaDelimited
) {}
22 nsDOMCSSValueList::~nsDOMCSSValueList() = default;
24 void nsDOMCSSValueList::AppendCSSValue(already_AddRefed
<CSSValue
> aValue
) {
25 RefPtr
<CSSValue
> val
= aValue
;
26 mCSSValues
.AppendElement(std::move(val
));
29 void nsDOMCSSValueList::GetCssText(nsAString
& aCssText
) {
32 uint32_t count
= mCSSValues
.Length();
34 nsAutoString separator
;
35 if (mCommaDelimited
) {
36 separator
.AssignLiteral(", ");
38 separator
.Assign(char16_t(' '));
42 for (uint32_t i
= 0; i
< count
; ++i
) {
43 CSSValue
* cssValue
= mCSSValues
[i
];
44 NS_ASSERTION(cssValue
,
45 "Eek! Someone filled the value list with null CSSValues!");
48 cssValue
->GetCssText(tmpStr
, dummy
);
50 if (tmpStr
.IsEmpty()) {
52 NS_ERROR("Eek! An empty CSSValue! Bad!");
58 // If this isn't the first item in the list, then
59 // it's ok to append a separator.
60 if (!aCssText
.IsEmpty()) {
61 aCssText
.Append(separator
);
63 aCssText
.Append(tmpStr
);
68 void nsDOMCSSValueList::GetCssText(nsString
& aCssText
, ErrorResult
& aRv
) {