1 /*
2  * Copyright (c) 2007 Henri Sivonen
3  * Copyright (c) 2008-2017 Mozilla Foundation
4  *
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:
11  *
12  * The above copyright notice and this permission notice shall be included in
13  * all copies or substantial portions of the Software.
14  *
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.
22  */
23 
24 #ifndef nsHtml5HtmlAttributes_h
25 #define nsHtml5HtmlAttributes_h
26 
27 #include "nsAtom.h"
28 #include "nsHtml5AtomTable.h"
29 #include "nsHtml5String.h"
30 #include "nsNameSpaceManager.h"
31 #include "nsIContent.h"
32 #include "nsTraceRefcnt.h"
33 #include "jArray.h"
34 #include "nsHtml5ArrayCopy.h"
35 #include "nsAHtml5TreeBuilderState.h"
36 #include "nsHtml5ByteReadable.h"
37 #include "nsHtml5Macros.h"
38 #include "nsIContentHandle.h"
39 #include "nsTArray.h"
40 #include "nsHtml5AttributeEntry.h"
41 
42 class nsHtml5StreamParser;
43 
44 class nsHtml5Tokenizer;
45 class nsHtml5TreeBuilder;
46 class nsHtml5MetaScanner;
47 class nsHtml5AttributeName;
48 class nsHtml5ElementName;
49 class nsHtml5UTF16Buffer;
50 class nsHtml5StateSnapshot;
51 class nsHtml5Portability;
52 
53 class nsHtml5HtmlAttributes {
54  public:
55   static nsHtml5HtmlAttributes* EMPTY_ATTRIBUTES;
56 
57  private:
58   AutoTArray<nsHtml5AttributeEntry, 5> mStorage;
59   int32_t mMode;
60   void AddEntry(nsHtml5AttributeEntry&& aEntry);
61 
62  public:
63   explicit nsHtml5HtmlAttributes(int32_t aMode);
64   ~nsHtml5HtmlAttributes();
65 
66   // Remove getIndex when removing isindex support
67   int32_t getIndex(nsHtml5AttributeName* aName);
68 
69   nsHtml5String getValue(nsHtml5AttributeName* aName);
70   int32_t getLength();
71   nsAtom* getLocalNameNoBoundsCheck(int32_t aIndex);
72   int32_t getURINoBoundsCheck(int32_t aIndex);
73   nsAtom* getPrefixNoBoundsCheck(int32_t aIndex);
74   nsHtml5String getValueNoBoundsCheck(int32_t aIndex);
75   nsHtml5AttributeName* getAttributeNameNoBoundsCheck(int32_t aIndex);
76   int32_t getLineNoBoundsCheck(int32_t aIndex);
77   void addAttribute(nsHtml5AttributeName* aName, nsHtml5String aValue,
78                     int32_t aLine);
79   void AddAttributeWithLocal(nsAtom* aName, nsHtml5String aValue,
80                              int32_t aLine);
81   void clear(int32_t aMode);
82   void releaseValue(int32_t aIndex);
83   void clearWithoutReleasingContents();
84   bool contains(nsHtml5AttributeName* aName);
85   void adjustForMath();
86   void adjustForSvg();
87   nsHtml5HtmlAttributes* cloneAttributes();
88   bool equalsAnother(nsHtml5HtmlAttributes* aOther);
89   static void initializeStatics();
90   static void releaseStatics();
91 };
92 
93 #endif
94