Page Speed Optimization Libraries
1.7.30.1
|
00001 /* 00002 * Copyright 2010 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 00018 00019 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CSS_COMBINE_FILTER_H_ 00020 #define NET_INSTAWEB_REWRITER_PUBLIC_CSS_COMBINE_FILTER_H_ 00021 00022 #include "net/instaweb/rewriter/public/css_tag_scanner.h" 00023 #include "net/instaweb/rewriter/public/rewrite_filter.h" 00024 #include "net/instaweb/rewriter/public/rewrite_options.h" 00025 #include "net/instaweb/util/public/basictypes.h" 00026 #include "net/instaweb/util/public/scoped_ptr.h" 00027 #include "net/instaweb/util/public/string_util.h" 00028 #include "net/instaweb/util/public/url_multipart_encoder.h" 00029 00030 namespace net_instaweb { 00031 00032 class HtmlElement; 00033 class HtmlIEDirectiveNode; 00034 class RewriteContext; 00035 class RewriteDriver; 00036 class Statistics; 00037 class UrlSegmentEncoder; 00038 class Variable; 00039 00040 class CssCombineFilter : public RewriteFilter { 00041 public: 00045 static const char kCssCombineOpportunities[]; 00047 static const char kCssFileCountReduction[]; 00048 00049 explicit CssCombineFilter(RewriteDriver* rewrite_driver); 00050 virtual ~CssCombineFilter(); 00051 00052 static void InitStats(Statistics* statistics); 00053 00054 virtual void StartDocumentImpl(); 00055 virtual void EndDocument(); 00056 virtual void StartElementImpl(HtmlElement* element); 00057 virtual void EndElementImpl(HtmlElement* element) {} 00058 virtual void Flush(); 00059 virtual void DetermineEnabled(); 00060 virtual void IEDirective(HtmlIEDirectiveNode* directive); 00061 virtual const char* Name() const { return "CssCombine"; } 00062 virtual const UrlSegmentEncoder* encoder() const { 00063 return &multipart_encoder_; 00064 } 00065 00066 virtual RewriteContext* MakeRewriteContext(); 00067 virtual const char* id() const { return RewriteOptions::kCssCombinerId; } 00068 00069 private: 00070 class Context; 00071 class CssCombiner; 00072 00073 CssCombiner* combiner(); 00074 void NextCombination(StringPiece debug_help); 00075 Context* MakeContext(); 00076 00077 CssTagScanner css_tag_scanner_; 00078 scoped_ptr<Context> context_; 00079 UrlMultipartEncoder multipart_encoder_; 00080 bool end_document_found_; 00081 int css_links_; 00082 00083 Variable* css_combine_opportunities_; 00084 00085 DISALLOW_COPY_AND_ASSIGN(CssCombineFilter); 00086 }; 00087 00088 } 00089 00090 #endif ///< NET_INSTAWEB_REWRITER_PUBLIC_CSS_COMBINE_FILTER_H_