Page Speed Optimization Libraries  1.2.24.1
net/instaweb/rewriter/public/css_combine_filter.h
Go to the documentation of this file.
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/url_multipart_encoder.h"
00028 
00029 namespace net_instaweb {
00030 
00031 class HtmlElement;
00032 class HtmlIEDirectiveNode;
00033 class RewriteContext;
00034 class RewriteDriver;
00035 class Statistics;
00036 class UrlSegmentEncoder;
00037 
00038 class CssCombineFilter : public RewriteFilter {
00039  public:
00042   static const char kCssFileCountReduction[];
00043 
00044   explicit CssCombineFilter(RewriteDriver* rewrite_driver);
00045   virtual ~CssCombineFilter();
00046 
00047   static void InitStats(Statistics* statistics);
00048 
00049   virtual void StartDocumentImpl();
00050   virtual void EndDocument();
00051   virtual void StartElementImpl(HtmlElement* element);
00052   virtual void EndElementImpl(HtmlElement* element) {}
00053   virtual void Flush();
00054   virtual void IEDirective(HtmlIEDirectiveNode* directive);
00055   virtual const char* Name() const { return "CssCombine"; }
00056   virtual const UrlSegmentEncoder* encoder() const {
00057     return &multipart_encoder_;
00058   }
00059 
00060   virtual RewriteContext* MakeRewriteContext();
00061   virtual const char* id() const { return RewriteOptions::kCssCombinerId; }
00062 
00063  private:
00064   class Context;
00065   class CssCombiner;
00066 
00067   CssCombiner* combiner();
00068   void NextCombination(const char* debug_help);
00069   Context* MakeContext();
00070 
00071   CssTagScanner css_tag_scanner_;
00072   scoped_ptr<Context> context_;
00073   UrlMultipartEncoder multipart_encoder_;
00074   bool end_document_found_;
00075 
00076   DISALLOW_COPY_AND_ASSIGN(CssCombineFilter);
00077 };
00078 
00079 }  
00080 
00081 #endif  ///< NET_INSTAWEB_REWRITER_PUBLIC_CSS_COMBINE_FILTER_H_
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines