Page Speed Optimization Libraries
1.4.26.1
|
#include "common_filter.h"
Public Member Functions | |
CommonFilter (RewriteDriver *driver) | |
const GoogleUrl & | base_url () const |
Getters. | |
const GoogleUrl & | decoded_base_url () const |
HtmlElement * | noscript_element () const |
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 (const StringPiece &input_url) |
bool | BaseUrlIsValid () const |
RewriteDriver * | driver () const |
bool | DebugMode () const |
virtual void | LogFilterModifiedContent () |
Static Public Member Functions | |
static bool | ExtractMetaTagDetails (const HtmlElement &element, const ResponseHeaders *headers, GoogleString *content, GoogleString *mime_type, GoogleString *charset) |
Protected Member Functions | |
virtual void | StartDocumentImpl ()=0 |
virtual void | StartElementImpl (HtmlElement *element)=0 |
virtual void | EndElementImpl (HtmlElement *element)=0 |
virtual const char * | LoggingId () |
Protected Attributes | |
RewriteDriver * | driver_ |
Protected pointers for inheritors to use. | |
ServerContext * | server_context_ |
const RewriteOptions * | rewrite_options_ |
CommonFilter encapsulates useful functionality that many filters will want. All filters who want this functionality should inherit from CommonFilter and define the Helper methods rather than the main methods.
Currently, it stores whether we are in a <noscript> element (in which case, we should be careful about moving things out of this element).
The base-tag is maintained in the RewriteDriver, although it can be accessed via a convenience method here for historical reasons.
const GoogleUrl& net_instaweb::CommonFilter::base_url | ( | ) | const |
Getters.
URL of the requested HTML or resource.
bool net_instaweb::CommonFilter::BaseUrlIsValid | ( | ) | const |
Returns whether or not the base url is valid. This value will change as a filter processes the document. E.g. If there are url refs before the base tag is reached, it will return false until the filter sees the base tag. After the filter sees the base tag, it will return true.
ResourcePtr net_instaweb::CommonFilter::CreateInputResource | ( | const StringPiece & | input_url | ) |
Creates an input resource with the url evaluated based on input_url which may need to be absolutified relative to base_url(). Returns NULL if the input resource url isn't valid, or can't legally be rewritten in the context of this page.
bool net_instaweb::CommonFilter::DebugMode | ( | ) | const [inline] |
Returns whether the current options specify the "debug" filter. If set, then other filters can annotate output HTML with HTML comments indicating why they did or did not do an optimization, using HtmlParse::InsertComment.
const GoogleUrl& net_instaweb::CommonFilter::decoded_base_url | ( | ) | const |
For rewritten resources, decoded_base_url() is the base of the original (un-rewritten) resource's URL.
static bool net_instaweb::CommonFilter::ExtractMetaTagDetails | ( | const HtmlElement & | element, |
const ResponseHeaders * | headers, | ||
GoogleString * | content, | ||
GoogleString * | mime_type, | ||
GoogleString * | charset | ||
) | [static] |
Utility function to extract the mime type and/or charset from a meta tag, either the HTML4 http-equiv form or the HTML5 charset form: element is the meta tag element to process. headers is optional: if provided it is checked to see if it already has a content type with the tag's value; if so, returns false. content is set to the content attribute's value, http-equiv form only. mime_type is set to the extracted mime type, if any. charset is the set to the extracted charset, if any. returns true if the details were extracted, false if not. If true is returned then content will be empty for the HTML5 charset form and non-empty for the HTML4 http-equiv form; also an http-equiv attribute with a blank mime type returns false as it's not a valid format.
virtual void net_instaweb::CommonFilter::LogFilterModifiedContent | ( | ) | [virtual] |
Add this filter to the logged list of applied rewriters. The intended semantics of this are that it should only include filters that modified the content of the response to the request being processed. This class logs using Name(); subclasses may do otherwise.
virtual const char* net_instaweb::CommonFilter::LoggingId | ( | ) | [inline, protected, virtual] |
ID string used in logging. Inheritors should supply whatever short ID string they use.
Reimplemented in net_instaweb::RewriteFilter.
virtual void net_instaweb::CommonFilter::StartDocumentImpl | ( | ) | [protected, pure virtual] |
Overload these implementer methods: Intentionally left abstract so that implementers don't forget to change the name from Blah to BlahImpl.
Implemented in net_instaweb::CombiningFilter, net_instaweb::NestedFilter, net_instaweb::CssSummarizerBase, net_instaweb::ImageRewriteFilter, net_instaweb::CssFilter, net_instaweb::SimpleTextFilter, net_instaweb::ImageCombineFilter, net_instaweb::JsCombineFilter, net_instaweb::LocalStorageCacheFilter, net_instaweb::CriticalSelectorFilter, net_instaweb::JavascriptFilter, net_instaweb::CacheExtender, net_instaweb::UrlLeftTrimFilter, net_instaweb::InsertGAFilter, net_instaweb::CssCombineFilter, net_instaweb::CollectFlushEarlyContentFilter, net_instaweb::MetaTagFilter, net_instaweb::CssOutlineFilter, net_instaweb::CssInlineFilter, net_instaweb::DomainRewriteFilter, net_instaweb::JsOutlineFilter, net_instaweb::CssMoveToHeadFilter, net_instaweb::JsInlineFilter, net_instaweb::FlushHtmlFilter, net_instaweb::InsertDnsPrefetchFilter, and net_instaweb::RedirectOnSizeLimitFilter.
virtual void net_instaweb::CommonFilter::StartElement | ( | HtmlElement * | element | ) | [virtual] |
When an HTML element is encountered during parsing, each filter's StartElement method is called. The HtmlElement lives for the entire duration of the document.
Reimplemented from net_instaweb::EmptyHtmlFilter.