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

#include "critical_css_beacon_filter.h"

Inheritance diagram for net_instaweb::CriticalCssBeaconFilter:
net_instaweb::CssSummarizerBase net_instaweb::RewriteFilter net_instaweb::CommonFilter net_instaweb::EmptyHtmlFilter net_instaweb::HtmlFilter

Public Member Functions

 CriticalCssBeaconFilter (RewriteDriver *driver)
 
virtual const char * Name () const
 The name of this filter – used for logging and debugging.
 
virtual const char * id () const
 
virtual
RewriteDriver::InlineAuthorizationPolicy 
AllowUnauthorizedDomain () const
 
virtual bool IntendedForInlining () const
 Selectors are inlined into javascript.
 
ScriptUsage GetScriptUsage () const override
 
- Public Member Functions inherited from net_instaweb::CssSummarizerBase
 CssSummarizerBase (RewriteDriver *driver)
 
- Public Member Functions inherited from net_instaweb::RewriteFilter
 RewriteFilter (RewriteDriver *driver)
 
virtual bool CanModifyUrls ()
 
virtual const UrlSegmentEncoderencoder () const
 
virtual bool ComputeOnTheFly () const
 
virtual RewriteContextMakeNestedRewriteContext (RewriteContext *parent, const ResourceSlotPtr &slot)
 
virtual void EncodeUserAgentIntoResourceContext (ResourceContext *context) const
 
virtual const
RewriteOptions::Filter
RelatedFilters (int *num_filters) const
 
virtual const StringPieceVector * RelatedOptions () 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 ()
 
void AddJsToElement (StringPiece js, HtmlElement *script)
 
- Public Member Functions inherited from net_instaweb::EmptyHtmlFilter
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
bool is_enabled () const
 
void set_is_enabled (bool is_enabled)
 

Static Public Member Functions

static void InitStats (Statistics *statistics)
 
- Static Public Member Functions inherited from net_instaweb::CssSummarizerBase
static void InitStats (Statistics *statistics)
 
- 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 kInitializePageSpeedJs []
 
static const char kCriticalCssBeaconAddedCount []
 Statistics:
 
static const char kCriticalCssNoBeaconDueToMissingData []
 
static const char kCriticalCssSkippedDueToCharset []
 
- Static Public Attributes inherited from net_instaweb::CssSummarizerBase
static const char kNumCssUsedForCriticalCssComputation []
 
static const char kNumCssNotUsedForCriticalCssComputation []
 
- 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 bool MustSummarize (HtmlElement *element) const
 
virtual void Summarize (Css::Stylesheet *stylesheet, GoogleString *out) const
 
virtual void SummariesDone ()
 
virtual void DetermineEnabled (GoogleString *disabled_reason)
 
- Protected Member Functions inherited from net_instaweb::CssSummarizerBase
virtual GoogleString CacheKeySuffix () const
 
virtual void RenderSummary (int pos, HtmlElement *element, HtmlCharactersNode *char_node, bool *is_element_deleted)
 
virtual void WillNotRenderSummary (int pos, HtmlElement *element, HtmlCharactersNode *char_node)
 
int NumStyles () const
 
const SummaryInfoGetSummaryForStyle (int pos) const
 
virtual void StartDocumentImpl ()
 
virtual void EndDocument ()
 
virtual void StartElementImpl (HtmlElement *element)
 
virtual void Characters (HtmlCharactersNode *characters)
 
virtual void EndElementImpl (HtmlElement *element)
 
virtual void RenderDone ()
 
virtual RewriteContextMakeRewriteContext ()
 
- 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 ()
 

Additional Inherited Members

- Public Types inherited from net_instaweb::HtmlFilter
enum  ScriptUsage { kWillInjectScripts, kMayInjectScripts, kNeverInjectsScripts }
 Describes a filter's relationship with scripts. More...
 
- Protected Types inherited from net_instaweb::CssSummarizerBase
enum  SummaryState {
  kSummaryOk, kSummaryStillPending, kSummaryCssParseError, kSummaryResourceCreationFailed,
  kSummaryInputUnavailable, kSummarySlotRemoved
}
 

Detailed Description

Figure out the set of CSS selectors referenced from a page, saving those selectors in an OutputResource for each CSS <style> or <link> on the page. Based on that set of candidate critical selectors, inject javascript for detecting critical above the fold css selectors after the page has loaded. Assumes CSS have been flattened first.

Member Function Documentation

virtual RewriteDriver::InlineAuthorizationPolicy net_instaweb::CriticalCssBeaconFilter::AllowUnauthorizedDomain ( ) const
inlinevirtual

This filter needs access to all critical selectors (even those from unauthorized domains) in order to let the clients use them while detecting critical selectors that can be subsequently beaconed back to the server and eventually inlined into the HTML.

Reimplemented from net_instaweb::CommonFilter.

virtual void net_instaweb::CriticalCssBeaconFilter::DetermineEnabled ( GoogleString disabled_reason)
protectedvirtual

Override DetermineEnabled so that filters that use the DOM cohort of the property cache can enable writing of it in the RewriterDriver. Filters inheriting from RewriteDriver that use the DOM cohort should override UsePropertyCacheDomCohort to return true.

Reimplemented from net_instaweb::RewriteFilter.

ScriptUsage net_instaweb::CriticalCssBeaconFilter::GetScriptUsage ( ) const
inlineoverridevirtual

Note: there is also kRequiresScriptExecutionFilterSet in rewrite_options.cc, which identifies filters that will leave broken pages if javascript is disabled, and hence require noscript handing. The set of filters that CanInjectScripts is larger, as it includes filters that might inject beacons or other optional functionality that is not page-critical.

Implements net_instaweb::HtmlFilter.

virtual bool net_instaweb::CriticalCssBeaconFilter::MustSummarize ( HtmlElement element) const
protectedvirtual

This method should be overridden if some CSS should not go through the summarization process (eg because it uses an inapplicable media type and we'll just throw it away when we're done anyway). By default all CSS must be summarized.

Reimplemented from net_instaweb::CssSummarizerBase.

virtual void net_instaweb::CriticalCssBeaconFilter::SummariesDone ( )
protectedvirtual

This is called at the end of the document when all outstanding summary computations have completed, regardless of whether successful or not. It will not be called at all if they are still ongoing, however.

It's called from a context which allows HTML parser state access. You can insert things at end of document by constructing an HtmlNode* using the factories in HtmlParse and calling CommonFilter::InsertNodeAtBodyEnd(node).

Note that the timing of this can vary widely — it can occur during initial parse, during the render phase, or even at RenderDone, so implementors should not make assumptions about what other filters may have done to the DOM.

Base version does nothing.

Reimplemented from net_instaweb::CssSummarizerBase.

virtual void net_instaweb::CriticalCssBeaconFilter::Summarize ( Css::Stylesheet *  stylesheet,
GoogleString out 
) const
protectedvirtual

This should be overridden to compute a per-resource summary. The method should not modify the object state, and only put the result into *out as it may not be invoked in case of a cache hit. The subclass may mutate *stylesheet if it so wishes.

Note: this is called on a rewrite thread, so it should not access HTML parser state.

Implements net_instaweb::CssSummarizerBase.


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