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

Classes

class  Transformer
 

Public Types

enum  InputPortion { kInputIncludesEnd, kInputDoesNotIncludeEnd }
 

Public Member Functions

 CssTagScanner (Transformer *transformer, MessageHandler *handler)
 
bool TransformUrlsStreaming (StringPiece contents, InputPortion input_portion, Writer *writer)
 
GoogleString RetainedForReparse () const
 

Static Public Member Functions

static bool ParseCssElement (HtmlElement *element, HtmlElement::Attribute **href, const char **media, StringPieceVector *nonstandard_attributes)
 
static bool ParseCssElement (HtmlElement *element, HtmlElement::Attribute **href, const char **media)
 
static bool TransformUrls (StringPiece contents, Writer *writer, Transformer *transformer, MessageHandler *handler)
 
static bool HasImport (const StringPiece &contents, MessageHandler *handler)
 
static bool HasUrl (const StringPiece &contents)
 Detemines whether this CSS contains a URI value (aka URL).
 
static bool IsStylesheetOrAlternate (const StringPiece &attribute_value)
 
static bool IsAlternateStylesheet (const StringPiece &attribute_value)
 Does this rel attribute value represent an alternate stylesheet?
 

Static Public Attributes

static const char kStylesheet []
 
static const char kAlternate []
 
static const char kUriValue []
 

Member Enumeration Documentation

When parsing streaming input, we need to be told if the given input portion goes up to end-of-file (since it affects whether something may continue the last token of the input).

Constructor & Destructor Documentation

net_instaweb::CssTagScanner::CssTagScanner ( Transformer transformer,
MessageHandler handler 
)

An instance of CssTagScanner should be created to use TransformUrlsStreaming; other APIs do not need this. *transformer will be used to to transform URLs in CSS, and *handler for logging.

Member Function Documentation

static bool net_instaweb::CssTagScanner::HasImport ( const StringPiece &  contents,
MessageHandler handler 
)
static

Does this CSS file contain ? If so, it cannot be combined with previous CSS files. This may give false-positives, but no false-negatives.

static bool net_instaweb::CssTagScanner::IsStylesheetOrAlternate ( const StringPiece &  attribute_value)
static

Does this attribute value represent a stylesheet or alternate stylesheet? Should be called with element->AttributeValue(HtmlName::kRel) as the arg.

static bool net_instaweb::CssTagScanner::ParseCssElement ( HtmlElement element,
HtmlElement::Attribute **  href,
const char **  media,
StringPieceVector *  nonstandard_attributes 
)
static

Examines an HTML element to determine if it's a CSS link, extracting out the href, the media type (if any) and any nonstandard attributes. If it's not CSS, href is set to NULL, media is set to "", and no nonstandard attributes are identified. NULL may be passed for nonstandard_attributes to indicate the caller doesn't need them collected.

static bool net_instaweb::CssTagScanner::ParseCssElement ( HtmlElement element,
HtmlElement::Attribute **  href,
const char **  media 
)
inlinestatic

Many callers don't care about nonstandard attributes, so we provide a version that discards that information.

nonstandard attributes

GoogleString net_instaweb::CssTagScanner::RetainedForReparse ( ) const
inline

Returns what was retained by TransformUrlsStreaming for reparsing. Meant for use in tests.

static bool net_instaweb::CssTagScanner::TransformUrls ( StringPiece  contents,
Writer writer,
Transformer transformer,
MessageHandler handler 
)
static

Scans the contents of a CSS file, looking for the pattern url(xxx). Performs an arbitrary mutation on all such URLs. If xxx is quoted with single-quotes or double-quotes, those are retained and the URL inside is transformed.

bool net_instaweb::CssTagScanner::TransformUrlsStreaming ( StringPiece  contents,
InputPortion  input_portion,
Writer writer 
)

Like above, but handles incomplete input. In such a case, all chunks other than the last one should be served with input_portion == kInputDoesNotIncludeEnd. Note that this method store some state for reparsing, so you can't concurrently run two streams through the same CssTagScanner object.


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