Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
delay_images_filter.h
Go to the documentation of this file.
1 /*
2  * Copyright 2011 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 
70 
71 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_DELAY_IMAGES_FILTER_H_
72 #define NET_INSTAWEB_REWRITER_PUBLIC_DELAY_IMAGES_FILTER_H_
73 
81 
82 namespace net_instaweb {
83 
84 class Statistics;
85 
87  public:
88  static const char kDelayImagesSuffix[];
89  static const char kDelayImagesInlineSuffix[];
90  static const char kImageOnloadCode[];
91  static const char kImageOnloadJsSnippet[];
92 
93  explicit DelayImagesFilter(RewriteDriver* driver);
94  virtual ~DelayImagesFilter();
95 
96  virtual void StartDocumentImpl();
97  virtual void StartElementImpl(HtmlElement* element) { }
98  virtual void EndElementImpl(HtmlElement* element);
99 
100  virtual void EndDocument();
101 
102  virtual const char* Name() const { return "DelayImages"; }
103 
104  virtual void DetermineEnabled(GoogleString* disabled_reason);
105 
106  static void InitStats(Statistics* statistics);
107  static void Terminate();
108  ScriptUsage GetScriptUsage() const override { return kWillInjectScripts; }
109 
110  private:
113  void MaybeAddImageOnloadJsSnippet(HtmlElement* element);
114 
116  void InsertLowResImagesAndJs(HtmlElement* element, bool insert_after_element);
117 
119  void InsertHighResJs(HtmlElement* element);
120 
123  bool ShouldRewriteInplace() const;
124 
125  int num_low_res_inlined_images_;
126  StringStringMap low_res_data_map_;
127 
131  bool insert_low_res_images_inplace_;
132 
137  bool lazyload_highres_images_;
138 
139  bool is_script_inserted_;
140 
141  bool added_image_onload_js_;
142 
143 
144 };
145 
146 }
147 
148 #endif
Definition: common_filter.h:47
Base class for implementations of monitoring statistics.
Definition: statistics.h:342
virtual const char * Name() const
The name of this filter – used for logging and debugging.
Definition: delay_images_filter.h:102
virtual void DetermineEnabled(GoogleString *disabled_reason)
Definition: html_element.h:42
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
ScriptUsage
Describes a filter's relationship with scripts.
Definition: html_filter.h:38
Definition: rewrite_driver.h:100
ScriptUsage GetScriptUsage() const override
Definition: delay_images_filter.h:108
Definition: delay_images_filter.h:86