1 /* 2 * Copyright (c) 2007 Henri Sivonen 3 * Copyright (c) 2008-2015 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 /* 25 * THIS IS A GENERATED FILE. PLEASE DO NOT EDIT. 26 * Please edit MetaScanner.java instead and regenerate. 27 */ 28 29 #ifndef nsHtml5MetaScanner_h 30 #define nsHtml5MetaScanner_h 31 32 #include "jArray.h" 33 #include "nsAHtml5TreeBuilderState.h" 34 #include "nsAtom.h" 35 #include "nsGkAtoms.h" 36 #include "nsHtml5ArrayCopy.h" 37 #include "nsHtml5AtomTable.h" 38 #include "nsHtml5ByteReadable.h" 39 #include "nsHtml5ContentCreatorFunction.h" 40 #include "nsHtml5Macros.h" 41 #include "nsHtml5Portability.h" 42 #include "nsHtml5String.h" 43 #include "nsIContent.h" 44 #include "nsIContentHandle.h" 45 #include "nsNameSpaceManager.h" 46 #include "nsTraceRefcnt.h" 47 48 class nsHtml5StreamParser; 49 50 class nsHtml5AttributeName; 51 class nsHtml5ElementName; 52 class nsHtml5Tokenizer; 53 class nsHtml5TreeBuilder; 54 class nsHtml5UTF16Buffer; 55 class nsHtml5StateSnapshot; 56 class nsHtml5Portability; 57 58 class nsHtml5MetaScanner { 59 private: 60 static staticJArray<char16_t, int32_t> CHARSET; 61 static staticJArray<char16_t, int32_t> CONTENT; 62 static staticJArray<char16_t, int32_t> HTTP_EQUIV; 63 static staticJArray<char16_t, int32_t> CONTENT_TYPE; 64 static const int32_t NO = 0; 65 66 static const int32_t M = 1; 67 68 static const int32_t E = 2; 69 70 static const int32_t T = 3; 71 72 static const int32_t A = 4; 73 74 static const int32_t DATA = 0; 75 76 static const int32_t TAG_OPEN = 1; 77 78 static const int32_t SCAN_UNTIL_GT = 2; 79 80 static const int32_t TAG_NAME = 3; 81 82 static const int32_t BEFORE_ATTRIBUTE_NAME = 4; 83 84 static const int32_t ATTRIBUTE_NAME = 5; 85 86 static const int32_t AFTER_ATTRIBUTE_NAME = 6; 87 88 static const int32_t BEFORE_ATTRIBUTE_VALUE = 7; 89 90 static const int32_t ATTRIBUTE_VALUE_DOUBLE_QUOTED = 8; 91 92 static const int32_t ATTRIBUTE_VALUE_SINGLE_QUOTED = 9; 93 94 static const int32_t ATTRIBUTE_VALUE_UNQUOTED = 10; 95 96 static const int32_t AFTER_ATTRIBUTE_VALUE_QUOTED = 11; 97 98 static const int32_t MARKUP_DECLARATION_OPEN = 13; 99 100 static const int32_t MARKUP_DECLARATION_HYPHEN = 14; 101 102 static const int32_t COMMENT_START = 15; 103 104 static const int32_t COMMENT_START_DASH = 16; 105 106 static const int32_t COMMENT = 17; 107 108 static const int32_t COMMENT_END_DASH = 18; 109 110 static const int32_t COMMENT_END = 19; 111 112 static const int32_t SELF_CLOSING_START_TAG = 20; 113 114 static const int32_t HTTP_EQUIV_NOT_SEEN = 0; 115 116 static const int32_t HTTP_EQUIV_CONTENT_TYPE = 1; 117 118 static const int32_t HTTP_EQUIV_OTHER = 2; 119 120 protected: 121 nsHtml5ByteReadable* readable; 122 123 private: 124 int32_t metaState; 125 int32_t contentIndex; 126 int32_t charsetIndex; 127 int32_t httpEquivIndex; 128 int32_t contentTypeIndex; 129 130 protected: 131 int32_t stateSave; 132 133 private: 134 int32_t strBufLen; 135 autoJArray<char16_t, int32_t> strBuf; 136 nsHtml5String content; 137 nsHtml5String charset; 138 int32_t httpEquivState; 139 nsHtml5TreeBuilder* treeBuilder; 140 141 public: 142 explicit nsHtml5MetaScanner(nsHtml5TreeBuilder* tb); 143 ~nsHtml5MetaScanner(); 144 145 protected: 146 void stateLoop(int32_t state); 147 148 private: 149 void handleCharInAttributeValue(int32_t c); toAsciiLowerCase(int32_t c)150 inline int32_t toAsciiLowerCase(int32_t c) { 151 if (c >= 'A' && c <= 'Z') { 152 return c + 0x20; 153 } 154 return c; 155 } 156 157 void addToBuffer(int32_t c); 158 void handleAttributeValue(); 159 bool handleTag(); 160 bool handleTagInner(); 161 162 protected: 163 bool tryCharset(nsHtml5String encoding); 164 165 public: 166 static void initializeStatics(); 167 static void releaseStatics(); 168 169 #include "nsHtml5MetaScannerHSupplement.h" 170 }; 171 172 #endif 173