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"
62 nsHtml5HtmlAttributes
* nsHtml5HtmlAttributes::EMPTY_ATTRIBUTES
= nsnull
;
64 nsHtml5HtmlAttributes::nsHtml5HtmlAttributes(PRInt32 mode
)
67 names(jArray
<nsHtml5AttributeName
*,PRInt32
>::newJArray(5)),
68 values(jArray
<nsString
*,PRInt32
>::newJArray(5))
70 MOZ_COUNT_CTOR(nsHtml5HtmlAttributes
);
74 nsHtml5HtmlAttributes::~nsHtml5HtmlAttributes()
76 MOZ_COUNT_DTOR(nsHtml5HtmlAttributes
);
81 nsHtml5HtmlAttributes::getIndex(nsHtml5AttributeName
* name
)
83 for (PRInt32 i
= 0; i
< length
; i
++) {
84 if (names
[i
] == name
) {
92 nsHtml5HtmlAttributes::getLength()
98 nsHtml5HtmlAttributes::getLocalName(PRInt32 index
)
100 if (index
< length
&& index
>= 0) {
101 return names
[index
]->getLocal(mode
);
107 nsHtml5AttributeName
*
108 nsHtml5HtmlAttributes::getAttributeName(PRInt32 index
)
110 if (index
< length
&& index
>= 0) {
118 nsHtml5HtmlAttributes::getURI(PRInt32 index
)
120 if (index
< length
&& index
>= 0) {
121 return names
[index
]->getUri(mode
);
128 nsHtml5HtmlAttributes::getPrefix(PRInt32 index
)
130 if (index
< length
&& index
>= 0) {
131 return names
[index
]->getPrefix(mode
);
138 nsHtml5HtmlAttributes::getValue(PRInt32 index
)
140 if (index
< length
&& index
>= 0) {
141 return values
[index
];
148 nsHtml5HtmlAttributes::getValue(nsHtml5AttributeName
* name
)
150 PRInt32 index
= getIndex(name
);
154 return getValue(index
);
159 nsHtml5HtmlAttributes::addAttribute(nsHtml5AttributeName
* name
, nsString
* value
)
161 if (names
.length
== length
) {
162 PRInt32 newLen
= length
<< 1;
163 jArray
<nsHtml5AttributeName
*,PRInt32
> newNames
= jArray
<nsHtml5AttributeName
*,PRInt32
>::newJArray(newLen
);
164 nsHtml5ArrayCopy::arraycopy(names
, newNames
, names
.length
);
166 jArray
<nsString
*,PRInt32
> newValues
= jArray
<nsString
*,PRInt32
>::newJArray(newLen
);
167 nsHtml5ArrayCopy::arraycopy(values
, newValues
, values
.length
);
170 names
[length
] = name
;
171 values
[length
] = value
;
176 nsHtml5HtmlAttributes::clear(PRInt32 m
)
178 for (PRInt32 i
= 0; i
< length
; i
++) {
181 nsHtml5Portability::releaseString(values
[i
]);
189 nsHtml5HtmlAttributes::releaseValue(PRInt32 i
)
191 nsHtml5Portability::releaseString(values
[i
]);
195 nsHtml5HtmlAttributes::clearWithoutReleasingContents()
197 for (PRInt32 i
= 0; i
< length
; i
++) {
205 nsHtml5HtmlAttributes::contains(nsHtml5AttributeName
* name
)
207 for (PRInt32 i
= 0; i
< length
; i
++) {
208 if (name
->equalsAnother(names
[i
])) {
216 nsHtml5HtmlAttributes::adjustForMath()
218 mode
= NS_HTML5ATTRIBUTE_NAME_MATHML
;
222 nsHtml5HtmlAttributes::adjustForSvg()
224 mode
= NS_HTML5ATTRIBUTE_NAME_SVG
;
227 nsHtml5HtmlAttributes
*
228 nsHtml5HtmlAttributes::cloneAttributes(nsHtml5AtomTable
* interner
)
231 nsHtml5HtmlAttributes
* clone
= new nsHtml5HtmlAttributes(0);
232 for (PRInt32 i
= 0; i
< length
; i
++) {
233 clone
->addAttribute(names
[i
]->cloneAttributeName(interner
), nsHtml5Portability::newStringFromString(values
[i
]));
239 nsHtml5HtmlAttributes::equalsAnother(nsHtml5HtmlAttributes
* other
)
242 PRInt32 otherLength
= other
->getLength();
243 if (length
!= otherLength
) {
246 for (PRInt32 i
= 0; i
< length
; i
++) {
247 PRBool found
= PR_FALSE
;
248 nsIAtom
* ownLocal
= names
[i
]->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML
);
249 for (PRInt32 j
= 0; j
< otherLength
; j
++) {
250 if (ownLocal
== other
->names
[j
]->getLocal(NS_HTML5ATTRIBUTE_NAME_HTML
)) {
252 if (!nsHtml5Portability::stringEqualsString(values
[i
], other
->values
[j
])) {
265 nsHtml5HtmlAttributes::initializeStatics()
267 EMPTY_ATTRIBUTES
= new nsHtml5HtmlAttributes(NS_HTML5ATTRIBUTE_NAME_HTML
);
271 nsHtml5HtmlAttributes::releaseStatics()
273 delete EMPTY_ATTRIBUTES
;