Page Speed Optimization Libraries
1.7.30.3
|
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 StaticAssetManager; 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 virtual void DetermineEnabled(); 00101 00102 static void InitStats(Statistics* statistics); 00103 static void Terminate(); 00104 00105 private: 00107 void InsertLowResImagesAndJs(HtmlElement* element, bool insert_after_element); 00108 00110 void InsertHighResJs(HtmlElement* element); 00111 00114 bool ShouldRewriteInplace() const; 00115 00116 RewriteDriver* driver_; 00117 StaticAssetManager* static_asset_manager_; 00118 00119 int num_low_res_inlined_images_; 00120 StringStringMap low_res_data_map_; 00121 00125 bool insert_low_res_images_inplace_; 00126 00131 bool lazyload_highres_images_; 00132 00133 bool is_script_inserted_; 00134 00135 DISALLOW_COPY_AND_ASSIGN(DelayImagesFilter); 00136 }; 00137 00138 } 00139 00140 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_DELAY_IMAGES_FILTER_H_