~alinuxninja/nginx-edge/trunk

« back to all changes in this revision

Viewing changes to debian/modules/ngx_pagespeed/psol/include/net/instaweb/rewriter/public/js_outline_filter.h

  • Committer: Vivian
  • Date: 2015-12-04 18:20:11 UTC
  • Revision ID: git-v1:a36f2bc32e884f7473b3a47040e5411306144d7d
* Do not extract psol.tar.gz

Show diffs side-by-side

added added

removed removed

Lines of Context:
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
 
 
17
 
// Author: sligocki@google.com (Shawn Ligocki)
18
 
 
19
 
#ifndef NET_INSTAWEB_REWRITER_PUBLIC_JS_OUTLINE_FILTER_H_
20
 
#define NET_INSTAWEB_REWRITER_PUBLIC_JS_OUTLINE_FILTER_H_
21
 
 
22
 
#include <cstddef>
23
 
 
24
 
#include "net/instaweb/rewriter/public/common_filter.h"
25
 
#include "net/instaweb/rewriter/public/script_tag_scanner.h"
26
 
#include "net/instaweb/util/public/basictypes.h"
27
 
#include "net/instaweb/util/public/string.h"
28
 
 
29
 
namespace net_instaweb {
30
 
class HtmlCharactersNode;
31
 
class HtmlElement;
32
 
class MessageHandler;
33
 
class OutputResource;
34
 
class ServerContext;
35
 
class RewriteDriver;
36
 
 
37
 
// Filter to take explicit <style> and <script> tags and outline them to files.
38
 
class JsOutlineFilter : public CommonFilter {
39
 
 public:
40
 
  explicit JsOutlineFilter(RewriteDriver* driver);
41
 
  virtual ~JsOutlineFilter();
42
 
  static const char kFilterId[];
43
 
 
44
 
  virtual void StartDocumentImpl();
45
 
 
46
 
  virtual void StartElementImpl(HtmlElement* element);
47
 
  virtual void EndElementImpl(HtmlElement* element);
48
 
 
49
 
  virtual void Flush();
50
 
 
51
 
  // HTML Events we expect to be in <script> elements.
52
 
  virtual void Characters(HtmlCharactersNode* characters);
53
 
 
54
 
  virtual const char* Name() const { return "OutlineJs"; }
55
 
 
56
 
 private:
57
 
  bool WriteResource(const GoogleString& content, OutputResource* resource,
58
 
                     MessageHandler* handler);
59
 
  void OutlineScript(HtmlElement* element, const GoogleString& content);
60
 
 
61
 
  // The script element we are in (if it hasn't been flushed).
62
 
  // If we are not in a script element, inline_element_ == NULL.
63
 
  HtmlElement* inline_element_;
64
 
  // CharactersNode to be outlined.
65
 
  HtmlCharactersNode* inline_chars_;
66
 
  ServerContext* server_context_;
67
 
  size_t size_threshold_bytes_;
68
 
  ScriptTagScanner script_tag_scanner_;
69
 
 
70
 
  DISALLOW_COPY_AND_ASSIGN(JsOutlineFilter);
71
 
};
72
 
 
73
 
}  // namespace net_instaweb
74
 
 
75
 
#endif  // NET_INSTAWEB_REWRITER_PUBLIC_JS_OUTLINE_FILTER_H_