Page Speed Optimization Libraries
1.2.24.1
|
00001 /* 00002 * Copyright 2011 Google Inc. 00003 * 00004 * Licensed under the Apache License, Version 2.0 (the "License"); 00005 * you may not use this file except in compliance with the License. 00006 * You may obtain a copy of the License at 00007 * 00008 * http:///www.apache.org/licenses/LICENSE-2.0 00009 * 00010 * Unless required by applicable law or agreed to in writing, software 00011 * distributed under the License is distributed on an "AS IS" BASIS, 00012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 00013 * See the License for the specific language governing permissions and 00014 * limitations under the License. 00015 */ 00016 00070 00071 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_DELAY_IMAGES_FILTER_H_ 00072 #define NET_INSTAWEB_REWRITER_PUBLIC_DELAY_IMAGES_FILTER_H_ 00073 00074 #include "net/instaweb/htmlparse/public/empty_html_filter.h" 00075 #include "net/instaweb/util/public/basictypes.h" 00076 #include "net/instaweb/util/public/string_util.h" 00077 00078 namespace net_instaweb { 00079 00080 class HtmlElement; 00081 class RewriteDriver; 00082 class StaticJavascriptManager; 00083 class Statistics; 00084 00085 class DelayImagesFilter : public EmptyHtmlFilter { 00086 public: 00087 static const char kDelayImagesSuffix[]; 00088 static const char kDelayImagesInlineSuffix[]; 00089 static const char kOnloadFunction[]; 00090 00091 explicit DelayImagesFilter(RewriteDriver* driver); 00092 virtual ~DelayImagesFilter(); 00093 00094 virtual void StartDocument(); 00095 virtual void EndDocument(); 00096 virtual void EndElement(HtmlElement* element); 00097 00098 virtual const char* Name() const { return "DelayImages"; } 00099 00100 static void InitStats(Statistics* statistics); 00101 static void Terminate(); 00102 00103 private: 00106 void InsertDelayImagesJS(HtmlElement* element); 00107 00110 void InsertDelayImagesInlineJS(HtmlElement* element); 00111 00112 RewriteDriver* driver_; 00113 StaticJavascriptManager* static_js_manager_; 00114 00118 bool low_res_map_inserted_; 00119 int num_low_res_inlined_images_; 00120 StringStringMap low_res_data_map_; 00121 00125 bool insert_low_res_images_inplace_; 00126 00129 bool is_experimental_enabled_; 00130 DISALLOW_COPY_AND_ASSIGN(DelayImagesFilter); 00131 }; 00132 00133 } 00134 00135 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_DELAY_IMAGES_FILTER_H_