blob: 0835f35b84da6f8822705a7bf04948d053162f66 [file] [log] [blame]
%{
// html_name.cc is automatically generated from html_name.gperf.
// Author: jmarantz@google.com
#include "base/logging.h"
#include "net/instaweb/htmlparse/public/html_name.h"
#include "net/instaweb/util/public/string_util.h"
namespace net_instaweb {
%}
%compare-strncmp
%define class-name KeywordMapper
%define lookup-function-name Lookup
%define word-array-name kHtmlNameTable
%global-table
%ignore-case
%includes
%language=C++
%readonly-tables
%struct-type
struct KeywordMap {const char* name; net_instaweb::HtmlName::Keyword keyword;};
%%
### These names can be used as element tags, or attribute names. This is not
### a complete list of HTML names -- just the ones we want to scan for while
### rewriting.
"?xml", HtmlName::kXml
"a", HtmlName::kA
"abbr", HtmlName::kAbbr
"action", HtmlName::kAction
"address", HtmlName::kAddress,
"alt", HtmlName::kAlt
"area", HtmlName::kArea
"article", HtmlName::kArticle
"aside", HtmlName::kAside,
"async", HtmlName::kAsync
"audio", HtmlName::kAudio
"autocomplete", HtmlName::kAutocomplete
"autofocus", HtmlName::kAutofocus
"autoplay", HtmlName::kAutoplay
"b", HtmlName::kB
"background", HtmlName::kBackground
"base", HtmlName::kBase
"bdi", HtmlName::kBdi
"bdo", HtmlName::kBdo
"blockquote", HtmlName::kBlockquote
"body", HtmlName::kBody
"br", HtmlName::kBr
"button", HtmlName::kButton
"charset", HtmlName::kCharset
"checked", HtmlName::kChecked
"cite", HtmlName::kCite
"class", HtmlName::kClass
"code", HtmlName::kCode
"col", HtmlName::kCol
"colgroup", HtmlName::kColgroup
"colspan", HtmlName::kColspan
"command", HtmlName::kCommand
"content", HtmlName::kContent
"controls", HtmlName::kControls
"data", HtmlName::kData
"dd", HtmlName::kDd
"declare", HtmlName::kDeclare
"defaultchecked", HtmlName::kDefaultchecked
"defaultselected", HtmlName::kDefaultselected
"defer", HtmlName::kDefer
"del", HtmlName::kDel
"details", HtmlName::kDetails
"dfn", HtmlName::kDfn
"dir", HtmlName::kDir
"disabled", HtmlName::kDisabled
"display", HtmlName::kDisplay
"div", HtmlName::kDiv
"dl", HtmlName::kDl
"dt", HtmlName::kDt
"em", HtmlName::kEm
"embed", HtmlName::kEmbed
"enctype", HtmlName::kEnctype
"event", HtmlName::kEvent
"fieldset", HtmlName::kFieldset
"font", HtmlName::kFont
"footer", HtmlName::kFooter
"for", HtmlName::kFor
"form", HtmlName::kForm
"formaction", HtmlName::kFormaction
"formnovalidate", HtmlName::kFormnovalidate
"frame", HtmlName::kFrame
"frameborder", HtmlName::kFrameborder
"h1", HtmlName::kH1
"h2", HtmlName::kH2
"h3", HtmlName::kH3
"h4", HtmlName::kH4
"h5", HtmlName::kH5
"h6", HtmlName::kH6
"head", HtmlName::kHead
"header", HtmlName::kHeader
"height", HtmlName::kHeight
"hgroup", HtmlName::kHgroup
"hr", HtmlName::kHr
"href", HtmlName::kHref
"html", HtmlName::kHtml
"http-equiv", HtmlName::kHttpEquiv
"i", HtmlName::kI
"icon", HtmlName::kIcon
"id", HtmlName::kId
"iframe", HtmlName::kIframe
"img", HtmlName::kImg
"indeterminate", HtmlName::kIndeterminate
"ins", HtmlName::kIns
"input", HtmlName::kInput
"ismap", HtmlName::kIsmap
"kbd", HtmlName::kKbd
"keygen", HtmlName::kKeygen
"keytype", HtmlName::kKeytype
"lang", HtmlName::kLang
"language", HtmlName::kLanguage
"li", HtmlName::kLi
"link", HtmlName::kLink
"loop", HtmlName::kLoop
"manifest", HtmlName::kManifest
"mark", HtmlName::kMark
"marquee", HtmlName::kMarquee
"media", HtmlName::kMedia
"menu", HtmlName::kMenu
"meta", HtmlName::kMeta
"method", HtmlName::kMethod
"multiple", HtmlName::kMultiple
"muted", HtmlName::kMuted
"name", HtmlName::kName
"nav", HtmlName::kNav
"noembed", HtmlName::kNoembed
"nohref", HtmlName::kNohref
"noresize", HtmlName::kNoresize
"noscript", HtmlName::kNoscript
"novalidate", HtmlName::kNovalidate
"object", HtmlName::kObject
"ol", HtmlName::kOl
"onclick", HtmlName::kOnclick
"onload", HtmlName::kOnload
"open", HtmlName::kOpen
"optgroup", HtmlName::kOptgroup
"option", HtmlName::kOption
"other", HtmlName::kOther
"p", HtmlName::kP
"pagespeed_blank_src", HtmlName::kPagespeedBlankSrc
"pagespeed_high_res_src", HtmlName::kPagespeedHighResSrc
"pagespeed_iframe", HtmlName::kPagespeedIframe
"pagespeed_lazy_src", HtmlName::kPagespeedLazySrc
"pagespeed_low_res_src", HtmlName::kPagespeedLowResSrc
"pagespeed_lsc_expiry", HtmlName::kPagespeedLscExpiry
"pagespeed_lsc_hash", HtmlName::kPagespeedLscHash
"pagespeed_lsc_url", HtmlName::kPagespeedLscUrl
"pagespeed_no_defer", HtmlName::kPagespeedNoDefer
"pagespeed_no_transform", HtmlName::kPagespeedNoTransform
"pagespeed_orig_src", HtmlName::kPagespeedOrigSrc
"pagespeed_orig_type", HtmlName::kPagespeedOrigType
"pagespeed_size", HtmlName::kPagespeedSize
"param", HtmlName::kParam
"pre", HtmlName::kPre
"profile", HtmlName::kProfile
"q", HtmlName::kQ
"readonly", HtmlName::kReadonly
"rel", HtmlName::kRel
"required", HtmlName::kRequired
"reversed", HtmlName::kReversed
"rowspan", HtmlName::kRowspan
"rp", HtmlName::kRp
"rt", HtmlName::kRt
"ruby", HtmlName::kRuby
"s", HtmlName::kS
"samp", HtmlName::kSamp
"scoped", HtmlName::kScoped
"script", HtmlName::kScript
"scrolling", HtmlName::kScrolling
"seamless", HtmlName::kSeamless
"section", HtmlName::kSection
"select", HtmlName::kSelect
"selected", HtmlName::kSelected
"shape", HtmlName::kShape
"small", HtmlName::kSmall
"source", HtmlName::kSource
"span", HtmlName::kSpan
"src", HtmlName::kSrc
"strong", HtmlName::kStrong
"style", HtmlName::kStyle
"sub", HtmlName::kSub
"table", HtmlName::kTable
"tag", HtmlName::kTag
"tbody", HtmlName::kTbody
"td", HtmlName::kTd
"test", HtmlName::kTest
"textarea", HtmlName::kTextarea
"tfoot", HtmlName::kTfoot
"th", HtmlName::kTh
"thead", HtmlName::kThead
"time", HtmlName::kTime
"tr", HtmlName::kTr
"track", HtmlName::kTrack
"type", HtmlName::kType
"u", HtmlName::kU
"ul", HtmlName::kUl
"valuetype", HtmlName::kValuetype
"var", HtmlName::kVar
"video", HtmlName::kVideo
"wbr", HtmlName::kWbr
"width", HtmlName::kWidth
"wrap", HtmlName::kWrap
"xmp", HtmlName::kXmp
%%
HtmlName::Keyword HtmlName::Lookup(const StringPiece& keyword) {
const KeywordMap* keyword_map = KeywordMapper::Lookup(keyword.data(),
keyword.size());
if (keyword_map != NULL) {
return keyword_map->keyword;
}
return HtmlName::kNotAKeyword;
}
bool HtmlName::Iterator::AtEnd() const {
return index_ > MAX_HASH_VALUE;
}
void HtmlName::Iterator::Next() {
DCHECK(!AtEnd());
++index_;
while (!AtEnd() && (*(kHtmlNameTable[index_].name) == '\0')) {
++index_;
}
}
const char* HtmlName::Iterator::name() const {
DCHECK(!AtEnd());
return kHtmlNameTable[index_].name;
}
HtmlName::Keyword HtmlName::Iterator::keyword() const {
DCHECK(!AtEnd());
return kHtmlNameTable[index_].keyword;
}
int HtmlName::num_keywords() {
return TOTAL_KEYWORDS;
}
} // namespace net_instaweb