19 #ifndef PAGESPEED_KERNEL_HTML_HTML_KEYWORDS_H_
20 #define PAGESPEED_KERNEL_HTML_HTML_KEYWORDS_H_
32 namespace net_instaweb {
54 if (keyword < HtmlName::kNotAKeyword) {
55 return &singleton_->keyword_vector_[keyword];
64 return singleton_->EscapeHelper(unescaped, buf);
75 bool* decoding_error) {
76 return singleton_->UnescapeHelper(escaped, buf, decoding_error);
94 return std::binary_search(singleton_->auto_close_.begin(),
95 singleton_->auto_close_.end(),
96 MakeKeywordPair(k1, k2));
103 return std::binary_search(singleton_->contained_.begin(),
104 singleton_->contained_.end(),
105 MakeKeywordPair(k1, k2));
114 return std::binary_search(singleton_->optionally_closed_.begin(),
115 singleton_->optionally_closed_.end(),
123 static bool WritePre(StringPiece text, StringPiece style,
127 typedef int32 KeywordPair;
128 typedef std::vector<KeywordPair> KeywordPairVec;
129 typedef std::vector<HtmlName::Keyword> KeywordVec;
132 const char* UnescapeAttributeValue();
133 void InitEscapeSequences();
134 void InitAutoClose();
136 void InitOptionallyClosedKeywords();
155 bool TryUnescape(
bool accumulate_numeric_code,
156 uint32 numeric_value,
164 return (static_cast<KeywordPair>(k1) << 16) |
static_cast<KeywordPair
>(k2);
171 void AddCrossProduct(
const StringPiece& k1_list,
const StringPiece& k2_list,
172 KeywordPairVec* kmap);
173 void AddAutoClose(
const StringPiece& k1_list,
const StringPiece& k2_list) {
174 AddCrossProduct(k1_list, k2_list, &auto_close_);
176 void AddContained(
const StringPiece& k1_list,
const StringPiece& k2_list) {
177 AddCrossProduct(k1_list, k2_list, &contained_);
181 void AddToSet(
const StringPiece& klist, KeywordVec* kset);
183 static HtmlKeywords* singleton_;
185 StringPiece EscapeHelper(
const StringPiece& unescaped,
187 StringPiece UnescapeHelper(
const StringPiece& escaped,
189 bool* decoding_error)
const;
196 typedef sparse_hash_map<
199 CaseFoldStringEqual> StringStringSparseHashMapInsensitive;
200 typedef sparse_hash_map<
202 CasePreserveStringHash> StringStringSparseHashMapSensitive;
204 StringStringSparseHashMapInsensitive unescape_insensitive_map_;
205 StringStringSparseHashMapSensitive unescape_sensitive_map_;
206 StringStringSparseHashMapSensitive escape_map_;
210 StringPieceVector keyword_vector_;
214 KeywordPairVec auto_close_;
215 KeywordPairVec contained_;
216 KeywordVec optionally_closed_;
static bool IsOptionallyClosedTag(HtmlName::Keyword keyword)
Definition: html_keywords.h:113
Definition: html_keywords.h:40
static bool WritePre(StringPiece text, StringPiece style, Writer *writer, MessageHandler *handler)
static bool IsAutoClose(HtmlName::Keyword k1, HtmlName::Keyword k2)
Definition: html_keywords.h:93
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
static StringPiece Escape(const StringPiece &unescaped, GoogleString *buf)
Definition: html_keywords.h:63
static StringPiece Unescape(const StringPiece &escaped, GoogleString *buf, bool *decoding_error)
Definition: html_keywords.h:74
Interface for writing bytes to an output stream.
Definition: writer.h:29
static bool IsContained(HtmlName::Keyword k1, HtmlName::Keyword k2)
Definition: html_keywords.h:102
Keyword
Definition: html_name.h:39
Definition: message_handler.h:39
static const StringPiece * KeywordToString(HtmlName::Keyword keyword)
Returns an HTML keyword as a string, or NULL if not a keyword.
Definition: html_keywords.h:53