2 * Copyright (c) 2007 Henri Sivonen
3 * Copyright (c) 2008-2009 Mozilla Foundation
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice shall be included in
13 * all copies or substantial portions of the Software.
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
21 * DEALINGS IN THE SOFTWARE.
25 * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT.
26 * Please edit HtmlAttributes.java instead and regenerate.
29 #define nsHtml5HtmlAttributes_cpp__
33 #include "nsHtml5AtomTable.h"
35 #include "nsINameSpaceManager.h"
36 #include "nsIContent.h"
37 #include "nsIDocument.h"
38 #include "nsTraceRefcnt.h"
40 #include "nsHtml5DocumentMode.h"
41 #include "nsHtml5ArrayCopy.h"
42 #include "nsHtml5NamedCharacters.h"
43 #include "nsHtml5NamedCharactersAccel.h"
44 #include "nsHtml5Atoms.h"
45 #include "nsHtml5ByteReadable.h"
46 #include "nsIUnicodeDecoder.h"
47 #include "nsAHtml5TreeBuilderState.h"
48 #include "nsHtml5Macros.h"
50 #include "nsHtml5Tokenizer.h"
51 #include "nsHtml5TreeBuilder.h"
52 #include "nsHtml5MetaScanner.h"
53 #include "nsHtml5AttributeName.h"
54 #include "nsHtml5ElementName.h"
55 #include "nsHtml5StackNode.h"
56 #include "nsHtml5UTF16Buffer.h"
57 #include "nsHtml5StateSnapshot.h"
58 #include "nsHtml5Portability.h"
60 #include "nsHtml5HtmlAttributes.h"
63 nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(PRInt32 mode
)
66 names(jArray
<nsHtml5AttributeName
*,PRInt32
>(5)),
67 values(jArray
<nsString
*,PRInt32
>(5))
69 MOZ_COUNT_CTOR(nsHtml5HtmlAttributes
);
73 nsHtml5HtmlAttributes::~nsHtml5HtmlAttributes()
75 MOZ_COUNT_DTOR(nsHtml5HtmlAttributes
);
82 nsHtml5HtmlAttributes::getIndex(nsHtml5AttributeName
* name
)
84 for (PRInt32 i
= 0; i
< length
; i
++) {
85 if (names
[i
] == name
) {
93 nsHtml5HtmlAttributes::getLength()
99 nsHtml5HtmlAttributes::getLocalName(PRInt32 index
)
101 if (index
< length
&& index
>= 0) {
102 return names
[index
]->getLocal(mode
);
108 nsHtml5AttributeName
*
109 nsHtml5HtmlAttributes::getAttributeName(PRInt32 index
)
111 if (index
< length
&& index
>= 0) {
119 nsHtml5HtmlAttributes::getURI(PRInt32 index
)
121 if (index
< length
&& index
>= 0) {
122 return names
[index
]->getUri(mode
);
129 nsHtml5HtmlAttributes::getPrefix(PRInt32 index
)
131 if (index
< length
&& index
>= 0) {
132 return names
[index
]->getPrefix(mode
);
139 nsHtml5HtmlAttributes::getValue(PRInt32 index
)
141 if (index
< length
&& index
>= 0) {
142 return values
[index
];
149 nsHtml5HtmlAttributes::getValue(nsHtml5AttributeName
* name
)
151 PRInt32 index
= getIndex(name
);
155 return getValue(index
);
160 nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName
* name
, nsString
* value
)
162 if (names
.length
== length
) {
163 PRInt32 newLen
= length
<< 1;
164 jArray
<nsHtml5AttributeName
*,PRInt32
> newNames
= jArray
<nsHtml5AttributeName
*,PRInt32
>(newLen
);
165 nsHtml5ArrayCopy::arraycopy(names
, newNames
, names
.length
);
168 jArray
<nsString
*,PRInt32
> newValues
= jArray
<nsString
*,PRInt32
>(newLen
);
169 nsHtml5ArrayCopy::arraycopy(values
, newValues
, values
.length
);
173 names
[length
] = name
;
174 values
[length
] = value
;
179 nsHtml5HtmlAttributes::clear(PRInt32 m
)
181 for (PRInt32 i
= 0; i
< length
; i
++) {
184 nsHtml5Portability::releaseString(values
[i
]);
192 nsHtml5HtmlAttributes::releaseValue(PRInt32 i
)
194 nsHtml5Portability::releaseString(values
[i
]);
198 nsHtml5HtmlAttributes::clearWithoutReleasingContents()
200 for (PRInt32 i
= 0; i
< length
; i
++) {
208 nsHtml5HtmlAttributes::contains(nsHtml5AttributeName
* name
)
210 for (PRInt32 i
= 0; i
< length
; i
++) {
211 if (name
->equalsAnother(names
[i
])) {
219 nsHtml5HtmlAttributes::adjustForMath()
221 mode
= NS_HTML5ATTRIBUTE_NAME_MATHML
;
225 nsHtml5HtmlAttributes::adjustForSvg()
227 mode
= NS_HTML5ATTRIBUTE_NAME_SVG
;
230 nsHtml5HtmlAttributes
*
231 nsHtml5HtmlAttributes::cloneAttributes(nsHtml5AtomTable
* interner
)
234 nsHtml5HtmlAttributes
* clone
= new nsHtml5HtmlAttributes(0);
235 for (PRInt32 i
= 0; i
< length
; i
++) {
236 clone
->addAttribute(names
[i
]->cloneAttributeName(interner
), nsHtml5Portability::newStringFromString(values
[i
]));
242 nsHtml5HtmlAttributes::initializeStatics()
244 EMPTY_ATTRIBUTES
= new nsHtml5HtmlAttributes(NS_HTML5ATTRIBUTE_NAME_HTML
);
248 nsHtml5HtmlAttributes::releaseStatics()
250 delete EMPTY_ATTRIBUTES
;