net_instaweb::ImageRewriteFilter Class Reference

#include "image_rewrite_filter.h"

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

List of all members.

Public Member Functions

 ImageRewriteFilter (RewriteDriver *driver)
virtual void StartDocumentImpl ()
virtual void StartElementImpl (HtmlElement *element)
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
RewriteContextMakeNestedRewriteContextForCss (int64 css_image_inline_max_bytes, RewriteContext *parent, const ResourceSlotPtr &slot)
virtual RewriteContextMakeNestedRewriteContext (RewriteContext *parent, const ResourceSlotPtr &slot)

Static Public Member Functions

static void Initialize (Statistics *statistics)
static bool TryInline (int64 image_inline_max_bytes, const CachedResult *cached_result, GoogleString *data_url)
static bool ParseDimensionAttribute (const char *position, int *value)

Static Public Attributes

static const char kImageOngoingRewrites []
 name for statistic used to bound rewriting work.
static const char kImageRewritesDroppedDueToLoad []

Protected Member Functions

virtual const UrlSegmentEncoderencoder () const
virtual RewriteContextMakeRewriteContext ()

Friends

class Context

Detailed Description

Identify img tags in html and optimize them.

Todo:
TODO(jmaessen): Big open question: how best to link pulled-in resources to rewritten urls, when in general those urls will be in a different domain.

Member Function Documentation

virtual const UrlSegmentEncoder* net_instaweb::ImageRewriteFilter::encoder (  )  const [protected, virtual]

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 RewriteContext* net_instaweb::ImageRewriteFilter::MakeNestedRewriteContext ( RewriteContext parent,
const ResourceSlotPtr slot 
) [virtual]

Creates a nested rewrite for the given parent and slot and returns it. The result is not registered with the parent.

Reimplemented from net_instaweb::RewriteFilter.

RewriteContext* net_instaweb::ImageRewriteFilter::MakeNestedRewriteContextForCss ( int64  css_image_inline_max_bytes,
RewriteContext parent,
const ResourceSlotPtr slot 
)

Creates a nested rewrite for an image inside a CSS file with the given parent and slot, and returns it. The result is not registered with the parent.

virtual RewriteContext* net_instaweb::ImageRewriteFilter::MakeRewriteContext (  )  [protected, virtual]

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.

static bool net_instaweb::ImageRewriteFilter::ParseDimensionAttribute ( const char *  position,
int *  value 
) [static]

The valid contents of a dimension attribute on an image element have one of the following forms: "45%" "45%px" "+45.0%" [45% of browser width; we can't handle this] "45", "+45", "45px", "45arbitraryjunk" "45px%" [45 pixels regardless of junk] Technically 0 is an invalid dimension, so we'll reject those as well; note that 0 dimensions occur in the wild and Safari and Chrome at least don't display anything.

We actually reject the arbitraryjunk cases, as older browsers (eg FF9, which isn't *that* old) don't deal with them at all. So the only trailing stuff we allow is px possibly with some white space. Note that some older browsers (like FF9) accept other units such as "in" or "pt" as synonyms for px!

We round fractions, as fractional pixels appear to be rounded in practice (and our image resize algorithms require integer pixel sizes).

Far more detail in the spec at: http://www.whatwg.org/specs/web-apps/current-work/multipage/ common-microsyntaxes.htmlpercentages-and-dimensions

virtual void net_instaweb::ImageRewriteFilter::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.

static bool net_instaweb::ImageRewriteFilter::TryInline ( int64  image_inline_max_bytes,
const CachedResult *  cached_result,
GoogleString data_url 
) [static]

Can we inline resource? If so, encode its contents into the data_url, otherwise leave data_url alone.


Member Data Documentation

TimedVariable denoting image rewrites we dropped due to load (too many concurrent rewrites)


The documentation for this class was generated from the following file:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Tue May 29 16:34:00 2012 for Page Speed Optimization Libraries by  doxygen 1.6.3