Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
html_filter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2010 Google Inc.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http:///www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
18 
19 #ifndef PAGESPEED_KERNEL_HTML_HTML_FILTER_H_
20 #define PAGESPEED_KERNEL_HTML_HTML_FILTER_H_
21 
23 
24 namespace net_instaweb {
25 
26 class HtmlCdataNode;
27 class HtmlCharactersNode;
28 class HtmlCommentNode;
29 class HtmlDirectiveNode;
30 class HtmlElement;
31 class HtmlIEDirectiveNode;
32 
35 class HtmlFilter {
36  public:
38  enum ScriptUsage {
44 
50 
56  };
57 
58  HtmlFilter();
59  virtual ~HtmlFilter();
60 
63  virtual void StartDocument() = 0;
64 
68  virtual void EndDocument() = 0;
69 
76  virtual void StartElement(HtmlElement* element) = 0;
77  virtual void EndElement(HtmlElement* element) = 0;
78 
80  virtual void Cdata(HtmlCdataNode* cdata) = 0;
81 
83  virtual void Comment(HtmlCommentNode* comment) = 0;
84 
90  virtual void IEDirective(HtmlIEDirectiveNode* directive) = 0;
91 
93  virtual void Characters(HtmlCharactersNode* characters) = 0;
94 
96  virtual void Directive(HtmlDirectiveNode* directive) = 0;
97 
107  virtual void Flush() = 0;
108 
115  virtual void RenderDone();
116 
121  virtual void DetermineEnabled(GoogleString* disabled_reason) = 0;
122 
125  bool is_enabled() const { return is_enabled_; }
126 
131  void set_is_enabled(bool is_enabled) { is_enabled_ = is_enabled; }
132 
135  virtual bool CanModifyUrls() = 0;
136 
143  virtual ScriptUsage GetScriptUsage() const = 0;
144 
146  virtual const char* Name() const = 0;
147 
148  private:
149  bool is_enabled_;
150 };
151 
152 }
153 
154 #endif
virtual bool CanModifyUrls()=0
Definition: html_filter.h:35
virtual void EndDocument()=0
Leaf node representing raw characters in HTML.
Definition: html_node.h:167
virtual void StartElement(HtmlElement *element)=0
Indicates this filter never injects scripts.
Definition: html_filter.h:55
virtual ScriptUsage GetScriptUsage() const =0
virtual void Directive(HtmlDirectiveNode *directive)=0
Called for HTML directives (e.g. <!doctype foobar>).
Definition: html_element.h:42
virtual void IEDirective(HtmlIEDirectiveNode *directive)=0
virtual void RenderDone()
Leaf node representing an HTML comment.
Definition: html_node.h:193
virtual void Flush()=0
virtual void DetermineEnabled(GoogleString *disabled_reason)=0
void set_is_enabled(bool is_enabled)
Definition: html_filter.h:131
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
bool is_enabled() const
Definition: html_filter.h:125
virtual void Cdata(HtmlCdataNode *cdata)=0
Called for CDATA blocks (e.g. <![CDATA[foobar]]>)
ScriptUsage
Describes a filter's relationship with scripts.
Definition: html_filter.h:38
virtual void Characters(HtmlCharactersNode *characters)=0
Called for raw characters between tags.
Leaf node representing an HTML directive.
Definition: html_node.h:233
virtual const char * Name() const =0
The name of this filter – used for logging and debugging.
virtual void StartDocument()=0
Leaf node representing a CDATA section.
Definition: html_node.h:147
Leaf node representing an HTML IE directive.
Definition: html_node.h:213