Page Speed Optimization Libraries
1.2.24.1
|
00001 /* 00002 * Copyright 2010 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00018 00019 #ifndef NET_INSTAWEB_HTMLPARSE_PUBLIC_HTML_NAME_H_ 00020 #define NET_INSTAWEB_HTMLPARSE_PUBLIC_HTML_NAME_H_ 00021 00022 #include "net/instaweb/util/public/string_util.h" 00023 00024 namespace net_instaweb { 00025 00031 class HtmlName { 00032 public: 00039 enum Keyword { 00040 kXml, 00041 kA, 00042 kAbbr, 00043 kAction, 00044 kAddress, 00045 kAlt, 00046 kArea, 00047 kArticle, 00048 kAside, 00049 kAsync, 00050 kAudio, 00051 kAutocomplete, 00052 kAutofocus, 00053 kAutoplay, 00054 kB, 00055 kBackground, 00056 kBase, 00057 kBdi, 00058 kBdo, 00059 kBlockquote, 00060 kBody, 00061 kBr, 00062 kButton, 00063 kCharset, 00064 kChecked, 00065 kCite, 00066 kClass, 00067 kCode, 00068 kCol, 00069 kColgroup, 00070 kColspan, 00071 kCommand, 00072 kContent, 00073 kControls, 00074 kData, 00075 kDataSrc, 00076 kDd, 00077 kDeclare, 00078 kDefaultchecked, 00079 kDefaultselected, 00080 kDefer, 00081 kDel, 00082 kDetails, 00083 kDfn, 00084 kDir, 00085 kDisabled, 00086 kDisplay, 00087 kDiv, 00088 kDl, 00089 kDt, 00090 kEm, 00091 kEmbed, 00092 kEnctype, 00093 kEvent, 00094 kFieldset, 00095 kFont, 00096 kFooter, 00097 kFor, 00098 kForm, 00099 kFormaction, 00100 kFormnovalidate, 00101 kFrame, 00102 kFrameborder, 00103 kH1, 00104 kH2, 00105 kH3, 00106 kH4, 00107 kH5, 00108 kH6, 00109 kHead, 00110 kHeader, 00111 kHeight, 00112 kHgroup, 00113 kHr, 00114 kHref, 00115 kHtml, 00116 kHttpEquiv, 00117 kI, 00118 kIcon, 00119 kId, 00120 kIframe, 00121 kImg, 00122 kIndeterminate, 00123 kIns, 00124 kInput, 00125 kIsmap, 00126 kKbd, 00127 kKeygen, 00128 kKeytype, 00129 kLang, 00130 kLanguage, 00131 kLi, 00132 kLink, 00133 kLoop, 00134 kManifest, 00135 kMark, 00136 kMarquee, 00137 kMedia, 00138 kMenu, 00139 kMeta, 00140 kMethod, 00141 kMultiple, 00142 kMuted, 00143 kName, 00144 kNav, 00145 kNoembed, 00146 kNohref, 00147 kNoresize, 00148 kNoscript, 00149 kNovalidate, 00150 kObject, 00151 kOl, 00152 kOnclick, 00153 kOnload, 00154 kOpen, 00155 kOptgroup, 00156 kOption, 00157 kOther, 00158 kP, 00159 kPagespeedBlankSrc, 00160 kPagespeedHighResSrc, 00161 kPagespeedIframe, 00162 kPagespeedLazySrc, 00163 kPagespeedLowResSrc, 00164 kPagespeedLscExpiry, 00165 kPagespeedLscHash, 00166 kPagespeedLscUrl, 00167 kPagespeedNoDefer, 00168 kPagespeedNoTransform, 00169 kPagespeedOrigSrc, 00170 kPagespeedOrigType, 00171 kPagespeedSize, 00172 kParam, 00173 kPre, 00174 kProfile, 00175 kQ, 00176 kReadonly, 00177 kRel, 00178 kRequired, 00179 kReversed, 00180 kRowspan, 00181 kRp, 00182 kRt, 00183 kRuby, 00184 kS, 00185 kSamp, 00186 kScoped, 00187 kScript, 00188 kScrolling, 00189 kSeamless, 00190 kSection, 00191 kSelect, 00192 kSelected, 00193 kShape, 00194 kSmall, 00195 kSource, 00196 kSpan, 00197 kSrc, 00198 kStrong, 00199 kStyle, 00200 kSub, 00201 kTable, 00202 kTag, 00203 kTbody, 00204 kTd, 00205 kTest, 00206 kTextarea, 00207 kTfoot, 00208 kTh, 00209 kThead, 00210 kTime, 00211 kTr, 00212 kTrack, 00213 kType, 00214 kU, 00215 kUl, 00216 kValuetype, 00217 kVar, 00218 kVideo, 00219 kWbr, 00220 kWidth, 00221 kWrap, 00222 kXmp, 00223 kNotAKeyword 00224 }; 00225 00231 HtmlName(Keyword keyword, const char* str) 00232 : keyword_(keyword), c_str_(str) { 00233 } 00234 00237 Keyword keyword() const { return keyword_; } 00238 00240 const char* c_str() const { return c_str_; } 00241 00246 class Iterator { 00247 public: 00248 Iterator() : index_(-1) { Next(); } 00249 bool AtEnd() const; 00250 void Next(); 00251 Keyword keyword() const; 00252 const char* name() const; 00253 00254 private: 00255 int index_; 00256 00258 }; 00259 00260 static int num_keywords(); 00261 static Keyword Lookup(const StringPiece& name); 00262 00263 private: 00264 friend class HtmlNameTest; 00265 00266 Keyword keyword_; 00267 const char* c_str_; 00268 00270 }; 00271 00272 } 00273 00274 #endif ///< NET_INSTAWEB_HTMLPARSE_PUBLIC_HTML_NAME_H_