Page Speed Optimization Libraries  1.12.34.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Classes | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Member Functions | Friends | List of all members
net_instaweb::CssFilter Class Reference

#include "css_filter.h"

Inheritance diagram for net_instaweb::CssFilter:
net_instaweb::RewriteFilter net_instaweb::CommonFilter net_instaweb::EmptyHtmlFilter net_instaweb::HtmlFilter

Classes

class  Context
 Context used by CssFilter under async flow. More...
 

Public Member Functions

 CssFilter (RewriteDriver *driver, CacheExtender *cache_extender, ImageRewriteFilter *image_rewriter, ImageCombineFilter *image_combiner)
 
virtual void StartDocumentImpl ()
 
virtual void StartElementImpl (HtmlElement *element)
 
virtual void Characters (HtmlCharactersNode *characters)
 
virtual void EndElementImpl (HtmlElement *element)
 
virtual const char * Name () const
 The name of this filter – used for logging and debugging.
 
virtual const char * id () const
 
virtual void EncodeUserAgentIntoResourceContext (ResourceContext *context) const
 
RewriteContextMakeNestedFlatteningContextInNewSlot (const ResourcePtr &resource, const GoogleString &location, CssFilter::Context *rewriter, RewriteContext *parent, CssHierarchy *hierarchy)
 
virtual const
RewriteOptions::Filter
RelatedFilters (int *num_filters) const
 
virtual const StringPieceVector * RelatedOptions () const
 
- Public Member Functions inherited from net_instaweb::RewriteFilter
 RewriteFilter (RewriteDriver *driver)
 
virtual void DetermineEnabled (GoogleString *disabled_reason)
 
virtual bool CanModifyUrls ()
 
virtual bool ComputeOnTheFly () const
 
- Public Member Functions inherited from net_instaweb::CommonFilter
 CommonFilter (RewriteDriver *driver)
 
const GoogleUrlbase_url () const
 Getters. More...
 
const GoogleUrldecoded_base_url () const
 
RewriteDriverdriver () const
 
HtmlElementnoscript_element () const
 
void InsertNodeAtBodyEnd (HtmlNode *data)
 
virtual void StartDocument ()
 Note: Don't overload these methods, overload the implementers instead!
 
virtual void StartElement (HtmlElement *element)
 
virtual void EndElement (HtmlElement *element)
 
ResourcePtr CreateInputResource (StringPiece input_url, bool *is_authorized)
 
ResourcePtr CreateInputResourceOrInsertDebugComment (StringPiece input_url, HtmlElement *element)
 
void ResolveUrl (StringPiece input_url, GoogleUrl *out_url)
 
bool BaseUrlIsValid () const
 
bool DebugMode () const
 
bool CanAddPagespeedOnloadToImage (const HtmlElement &)
 
virtual void LogFilterModifiedContent ()
 
virtual
RewriteDriver::InlineAuthorizationPolicy 
AllowUnauthorizedDomain () const
 
virtual bool IntendedForInlining () const
 
void AddJsToElement (StringPiece js, HtmlElement *script)
 
- Public Member Functions inherited from net_instaweb::EmptyHtmlFilter
virtual void EndDocument ()
 
virtual void Cdata (HtmlCdataNode *cdata)
 Called for CDATA blocks (e.g. <![CDATA[foobar]]>)
 
virtual void Comment (HtmlCommentNode *comment)
 Called for HTML comments that aren't IE directives (e.g. ).
 
virtual void IEDirective (HtmlIEDirectiveNode *directive)
 
virtual void Directive (HtmlDirectiveNode *directive)
 Called for HTML directives (e.g. <!doctype foobar>).
 
virtual void Flush ()
 
ScriptUsage GetScriptUsage () const override
 
- Public Member Functions inherited from net_instaweb::HtmlFilter
virtual void RenderDone ()
 
bool is_enabled () const
 
void set_is_enabled (bool is_enabled)
 

Static Public Member Functions

static void InitStats (Statistics *statistics)
 
static void Initialize ()
 Initialize & Terminate must be paired.
 
static void Terminate ()
 
static void AddRelatedOptions (StringPieceVector *target)
 Add this filters related options to the given vector.
 
- Static Public Member Functions inherited from net_instaweb::RewriteFilter
static StringPiece GetCharsetForScript (const Resource *script, const StringPiece attribute_charset, const StringPiece enclosing_charset)
 
static GoogleString GetCharsetForStylesheet (const Resource *stylesheet, const StringPiece attribute_charset, const StringPiece enclosing_charset)
 
- Static Public Member Functions inherited from net_instaweb::CommonFilter
static bool ExtractMetaTagDetails (const HtmlElement &element, const ResponseHeaders *headers, GoogleString *content, GoogleString *mime_type, GoogleString *charset)
 

Static Public Attributes

static const char kBlocksRewritten []
 
static const char kParseFailures []
 
static const char kFallbackRewrites []
 
static const char kFallbackFailures []
 
static const char kRewritesDropped []
 
static const char kTotalBytesSaved []
 
static const char kTotalOriginalBytes []
 
static const char kUses []
 
static const char kCharsetMismatch []
 
static const char kInvalidUrl []
 
static const char kLimitExceeded []
 
static const char kMinifyFailed []
 
static const char kRecursion []
 
static const char kComplexQueries []
 
- Static Public Attributes inherited from net_instaweb::CommonFilter
static const char kCreateResourceFailedDebugMsg []
 Debug message to be inserted when resource creation fails.
 

Protected Member Functions

virtual RewriteContextMakeRewriteContext ()
 
virtual const UrlSegmentEncoderencoder () const
 
virtual RewriteContextMakeNestedRewriteContext (RewriteContext *parent, const ResourceSlotPtr &slot)
 
- Protected Member Functions inherited from net_instaweb::RewriteFilter
virtual const char * LoggingId ()
 This class logs using id().
 
- Protected Member Functions inherited from net_instaweb::CommonFilter
ServerContextserver_context () const
 
const RewriteOptionsrewrite_options ()
 

Friends

class Context
 
class CssFlattenImportsContext
 for statistics
 
class CssHierarchy
 for statistics
 

Additional Inherited Members

- Public Types inherited from net_instaweb::HtmlFilter
enum  ScriptUsage { kWillInjectScripts, kMayInjectScripts, kNeverInjectsScripts }
 Describes a filter's relationship with scripts. More...
 

Detailed Description

Find and parse all CSS in the page and apply transformations including: minification, combining, refactoring, and optimizing sub-resources.

Currently only does basic minification.

Note that CssCombineFilter currently does combining (although there is a bug) but CssFilter will eventually replace this.

Currently only deals with inline <style> tags and external <link> resources. It does not consider style= attributes on arbitrary elements.

Constructor & Destructor Documentation

net_instaweb::CssFilter::CssFilter ( RewriteDriver driver,
CacheExtender cache_extender,
ImageRewriteFilter image_rewriter,
ImageCombineFilter image_combiner 
)
Parameters
cache_extender
Todo:
TODO(sligocki): Temporary pattern until we figure out a better way to do this without passing all filters around everywhere.

Member Function Documentation

virtual void net_instaweb::CssFilter::Characters ( HtmlCharactersNode characters)
virtual

If a subclass overloads this function and wishes to use InsertNodeAtBodyEnd(), it needs to make an upcall to this implementation for InsertNodeAtBodyEnd() to work correctly.

Reimplemented from net_instaweb::CommonFilter.

virtual const UrlSegmentEncoder* net_instaweb::CssFilter::encoder ( ) const
protectedvirtual

All RewriteFilters define how they encode URLs and other associated information needed for a rewrite into a URL. The default implementation handles a single URL with no extra data. The filter owns the encoder.

Reimplemented from net_instaweb::RewriteFilter.

virtual void net_instaweb::CssFilter::EncodeUserAgentIntoResourceContext ( ResourceContext *  context) const
virtual

Encodes user agent information needed by the filter into ResourceContext. See additional header document for RewriteContext::EncodeUserAgentIntoResourceContext.

Reimplemented from net_instaweb::RewriteFilter.

static void net_instaweb::CssFilter::InitStats ( Statistics statistics)
static

May be called multiple times, in case there are multiple statistics objects.

virtual RewriteContext* net_instaweb::CssFilter::MakeNestedRewriteContext ( RewriteContext parent,
const ResourceSlotPtr slot 
)
protectedvirtual

Generates a nested RewriteContext appropriate for this filter. Default implementation returns NULL. This is used to implement ajax rewriting.

Reimplemented from net_instaweb::RewriteFilter.

virtual RewriteContext* net_instaweb::CssFilter::MakeRewriteContext ( )
protectedvirtual

Generates a RewriteContext appropriate for this filter. Default implementation returns NULL. This must be overridden by filters. This is used to implement Fetch.

Reimplemented from net_instaweb::RewriteFilter.

virtual const RewriteOptions::Filter* net_instaweb::CssFilter::RelatedFilters ( int *  num_filters) const
inlinevirtual

Determines which filters are related to this RewriteFilter. Note, for example, that the ImageRewriteFilter class implements lots of different RewriteOptions::Filters.

This is used for embedding the relevant enabled filter IDs. See the doc for RewriteOptions::add_options_to_urls_. We want to support that without bloating URLs excessively adding unrelated filter settings.

The vector is returned in numerically increasing order so binary_search is possible.

*num_filters is set to the size of this array.

Ownership of the filter-vector is not transferred to the caller; it is expected to return a pointer to a static vector.

Reimplemented from net_instaweb::RewriteFilter.

virtual const StringPieceVector* net_instaweb::CssFilter::RelatedOptions ( ) const
inlinevirtual

Return the names of options related to this RewriteFilter in case-insensitive alphabetical order. NULL means there are none. Ownership of the vector is not transferred to the caller.

Reimplemented from net_instaweb::RewriteFilter.

virtual void net_instaweb::CssFilter::StartDocumentImpl ( )
virtual

Overload these implementer methods: Intentionally left abstract so that implementers don't forget to change the name from Blah to BlahImpl.

Implements net_instaweb::CommonFilter.


The documentation for this class was generated from the following file: