2
* Copyright 2011 Google Inc.
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
8
* http://www.apache.org/licenses/LICENSE-2.0
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.
17
// Author: jmarantz@google.com (Joshua Marantz)
19
#ifndef NET_INSTAWEB_REWRITER_PUBLIC_SCAN_FILTER_H_
20
#define NET_INSTAWEB_REWRITER_PUBLIC_SCAN_FILTER_H_
22
#include "net/instaweb/htmlparse/public/empty_html_filter.h"
24
namespace net_instaweb {
27
class HtmlCharactersNode;
28
class HtmlCommentNode;
29
class HtmlDirectiveNode;
31
class HtmlIEDirectiveNode;
34
// Filter that is run before any other, to help track base-tag usage and
35
// changes to help identify and deal conservatively with situation where HTML
36
// files update the base-tag more than once or use the base-tag prior to it
37
// being changed. Such situations are not well-defined and what we want to
38
// do is avoid rewriting any resources whose interpretation might be hard
39
// to predict due to browser differences.
40
class ScanFilter : public EmptyHtmlFilter {
42
explicit ScanFilter(RewriteDriver* driver);
43
virtual ~ScanFilter();
45
virtual void StartDocument();
46
virtual void StartElement(HtmlElement* element);
47
virtual void Cdata(HtmlCdataNode* cdata);
48
virtual void Comment(HtmlCommentNode* comment);
49
virtual void IEDirective(HtmlIEDirectiveNode* directive);
50
virtual void Characters(HtmlCharactersNode* characters);
51
virtual void Directive(HtmlDirectiveNode* directive);
54
virtual const char* Name() const { return "Scan"; }
57
RewriteDriver* driver_;
61
bool seen_meta_tag_charset_;
64
} // namespace net_instaweb
66
#endif // NET_INSTAWEB_REWRITER_PUBLIC_SCAN_FILTER_H_