2
* Copyright 2010 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: sligocki@google.com (Shawn Ligocki)
19
#ifndef NET_INSTAWEB_REWRITER_PUBLIC_CSS_OUTLINE_FILTER_H_
20
#define NET_INSTAWEB_REWRITER_PUBLIC_CSS_OUTLINE_FILTER_H_
24
#include "net/instaweb/rewriter/public/common_filter.h"
25
#include "net/instaweb/util/public/basictypes.h"
26
#include "net/instaweb/util/public/string.h"
27
#include "net/instaweb/util/public/string_util.h"
29
namespace net_instaweb {
31
class HtmlCharactersNode;
37
// Filter to take explicit <style> and <script> tags and outline them to files.
38
class CssOutlineFilter : public CommonFilter {
40
static const char kFilterId[];
42
explicit CssOutlineFilter(RewriteDriver* driver);
43
virtual ~CssOutlineFilter();
45
virtual void StartDocumentImpl();
47
virtual void StartElementImpl(HtmlElement* element);
48
virtual void EndElementImpl(HtmlElement* element);
52
// HTML Events we expect to be in <style> elements.
53
virtual void Characters(HtmlCharactersNode* characters);
55
virtual const char* Name() const { return "OutlineCss"; }
58
bool WriteResource(const StringPiece& content, OutputResource* resource,
59
MessageHandler* handler);
60
void OutlineStyle(HtmlElement* element, const GoogleString& content);
62
// The style element we are in (if it hasn't been flushed).
63
// If we are not in a style element, inline_element_ == NULL.
64
HtmlElement* inline_element_;
65
// CharactersNode to be outlined.
66
HtmlCharactersNode* inline_chars_;
67
size_t size_threshold_bytes_;
68
// HTML strings interned into a symbol table.
70
DISALLOW_COPY_AND_ASSIGN(CssOutlineFilter);
73
} // namespace net_instaweb
75
#endif // NET_INSTAWEB_REWRITER_PUBLIC_CSS_OUTLINE_FILTER_H_