19 #ifndef PAGESPEED_KERNEL_HTML_HTML_EVENT_H_
20 #define PAGESPEED_KERNEL_HTML_HTML_EVENT_H_
29 namespace net_instaweb {
33 explicit HtmlEvent(
int line_number) : line_number_(line_number) {
48 virtual HtmlNode* GetNode() {
return NULL; }
49 virtual HtmlCharactersNode* GetCharactersNode() {
return NULL; }
52 int line_number()
const {
return line_number_; }
64 virtual GoogleString ToString()
const {
return "StartDocument"; }
74 virtual GoogleString ToString()
const {
return "EndDocument"; }
88 return StrCat(
"StartElement ", element_->
ToString());
93 HtmlElement* element_;
104 virtual void Run(
HtmlFilter* filter) { filter->EndElement(element_); }
106 return StrCat(
"EndElement ", element_->
ToString());
109 virtual HtmlElement* GetNode() {
return element_; }
111 HtmlElement* element_;
119 virtual HtmlNode* GetNode() {
return GetLeafNode(); }
129 directive_(directive) {
133 return StrCat(
"IEDirective ", directive_->contents());
135 virtual HtmlLeafNode* GetLeafNode() {
return directive_; }
150 return StrCat(
"Cdata ", cdata_->contents());
167 return StrCat(
"Comment ", comment_->contents());
169 virtual HtmlLeafNode* GetLeafNode() {
return comment_; }
181 characters_(characters) {
185 return StrCat(
"Characters ", characters_->contents());
187 virtual HtmlLeafNode* GetLeafNode() {
return characters_; }
199 directive_(directive) {
203 return StrCat(
"Directive: ", directive_->contents());
205 virtual HtmlLeafNode* GetLeafNode() {
return directive_; }
Definition: html_node.h:103
Definition: html_filter.h:35
virtual void EndDocument()=0
Definition: html_event.h:177
Definition: html_event.h:116
Definition: html_event.h:31
virtual GoogleString ToString() const
Leaf node representing raw characters in HTML.
Definition: html_node.h:167
virtual void StartElement(HtmlElement *element)=0
virtual void Directive(HtmlDirectiveNode *directive)=0
Called for HTML directives (e.g. <!doctype foobar>).
virtual HtmlElement * GetElementIfStartEvent()
Definition: html_event.h:90
Definition: html_event.h:98
Definition: html_element.h:42
virtual void IEDirective(HtmlIEDirectiveNode *directive)=0
Definition: html_event.h:195
virtual HtmlElement * GetElementIfEndEvent()
Definition: html_event.h:45
virtual void Comment(HtmlCommentNode *comment)=0
Called for HTML comments that aren't IE directives (e.g. ).
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
virtual void Cdata(HtmlCdataNode *cdata)=0
Called for CDATA blocks (e.g. <![CDATA[foobar]]>)
virtual HtmlElement * GetElementIfEndEvent()
Definition: html_event.h:108
Definition: html_event.h:80
Definition: html_node.h:43
virtual void Characters(HtmlCharactersNode *characters)=0
Called for raw characters between tags.
Definition: html_event.h:142
Leaf node representing an HTML directive.
Definition: html_node.h:233
Definition: html_event.h:125
virtual void StartDocument()=0
Definition: html_event.h:60
Leaf node representing a CDATA section.
Definition: html_node.h:147
Leaf node representing an HTML IE directive.
Definition: html_node.h:213
Definition: html_event.h:70
virtual HtmlElement * GetElementIfStartEvent()
Definition: html_event.h:41