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 #include "SVGStringList.h"
9 #include "nsCharSeparatedTokenizer.h"
10 #include "nsContentUtils.h"
11 #include "nsReadableUtils.h"
13 #include "nsWhitespaceTokenizer.h"
14 #include "SVGContentUtils.h"
18 nsresult
SVGStringList::CopyFrom(const SVGStringList
& rhs
) {
19 if (!mStrings
.Assign(rhs
.mStrings
, fallible
)) {
20 return NS_ERROR_OUT_OF_MEMORY
;
26 void SVGStringList::GetValue(nsAString
& aValue
) const {
27 aValue
= StringJoin(mIsCommaSeparated
? u
", "_ns
: u
" "_ns
, mStrings
);
30 nsresult
SVGStringList::SetValue(const nsAString
& aValue
) {
33 if (mIsCommaSeparated
) {
34 nsCharSeparatedTokenizerTemplate
<nsContentUtils::IsHTMLWhitespace
>
35 tokenizer(aValue
, ',');
37 while (tokenizer
.hasMoreTokens()) {
38 if (!temp
.AppendItem(tokenizer
.nextToken())) {
39 return NS_ERROR_OUT_OF_MEMORY
;
42 if (tokenizer
.separatorAfterCurrentToken()) {
43 return NS_ERROR_DOM_SYNTAX_ERR
; // trailing comma
46 nsWhitespaceTokenizerTemplate
<nsContentUtils::IsHTMLWhitespace
> tokenizer(
49 while (tokenizer
.hasMoreTokens()) {
50 if (!temp
.AppendItem(tokenizer
.nextToken())) {
51 return NS_ERROR_OUT_OF_MEMORY
;
56 return CopyFrom(temp
);
59 } // namespace mozilla