|
| CssHierarchy (CssFilter *filter) |
|
void | InitializeRoot (const GoogleUrl &css_base_url, const GoogleUrl &css_trim_url, const StringPiece input_contents, bool has_unparseables, int64 flattened_result_limit, Css::Stylesheet *stylesheet, MessageHandler *message_handler) |
|
bool | NeedsRewriting () const |
| A hierarchy needs rewriting only if it has an import to read and expand.
|
|
const StringPiece | url () const |
|
const StringPiece | url_for_humans () const |
|
const GoogleUrl & | css_base_url () const |
|
const GoogleUrl & | css_trim_url () const |
|
const GoogleUrl & | css_resolution_base () |
|
const Css::Stylesheet * | stylesheet () const |
|
Css::Stylesheet * | mutable_stylesheet () |
|
void | set_stylesheet (Css::Stylesheet *stylesheet) |
|
const StringPiece | input_contents () const |
|
void | set_input_contents (const StringPiece input_contents) |
|
GoogleString * | input_contents_backing_store () |
|
void | set_input_contents_to_backing_store () |
|
const GoogleString & | minified_contents () const |
|
void | set_minified_contents (const StringPiece minified_contents) |
|
const GoogleString & | charset () const |
|
GoogleString * | mutable_charset () |
|
const GoogleString & | charset_source () const |
|
const StringVector & | media () const |
|
StringVector * | mutable_media () |
|
const std::vector
< CssHierarchy * > & | children () const |
| Intended for access to children; add new children using ExpandChildren.
|
|
std::vector< CssHierarchy * > & | children () |
|
bool | input_contents_resolved () const |
|
void | set_input_contents_resolved (bool x) |
|
bool | flattening_succeeded () const |
|
void | set_flattening_succeeded (bool ok) |
|
const GoogleString & | flattening_failure_reason () const |
|
void | AddFlatteningFailureReason (const GoogleString &reason) |
|
bool | unparseable_detected () const |
|
void | set_unparseable_detected (bool ok) |
|
int64 | flattened_result_limit () const |
|
void | set_flattened_result_limit (int64 x) |
|
bool | CheckCharsetOk (const ResourcePtr &resource, GoogleString *failure_reason) |
|
bool | Parse () |
|
bool | ExpandChildren () |
|
void | RollUpContents () |
|
bool | RollUpStylesheets () |
|
Representation of a CSS with all the information required for import flattening, image rewriting, and minifying. A flattened CSS has had all of its 's replaced with the contents of the 'd file (and each of those have had their 's replaced, and so on recursively).
Lifecycle: Processing: Construct + InitializeRoot if (ExpandChildren) <---------------—+ for each child | InitializeNested | set_input_contents | if (Parse) | if (CheckCharsetOk) | Kick off recursion from here –+ Harvesting (when all the children of a node have completed): if you need the rolled-up text form: RollUpContents Use minified_contents if you need the rolled-up parsed form: RollUpStylesheet Use stylesheet
If we haven't already, determine the charset of this CSS, then check if it is compatible with the charset of its parent; currently they are compatible if they're exactly the same (ignoring case). The charset of this CSS is taken from resource's headers if specified, else from the rule in the parsed CSS, if any, else from the owning document (our parent). Returns true if the charsets are compatible, otherwise returns false and sets the failure reason. The charset is always determined and set regardless of the return value.
- Todo:
- TODO(matterbury): A potential future enhancement is to allow 'compatible' charsets, like a US-ASCII child in a UTF-8 parent, since US-ASCII is a subset of UTF-8.
void net_instaweb::CssHierarchy::RollUpContents |
( |
| ) |
|
Recursively roll up this CSS's textual form such that minified_contents() returns the flattened version of this CSS with 's replaced with the contents of the imported file, all rules removed, and the entire result minified. Intended for use by nested hierarchies that need to produce their flattened+minimized CSS for their parent to incorporate into their own flattened+minimized CSS. If anything goes wrong with the rolling up then the minified contents are set to the original contents. If the textual form hasn't yet been parsed this method will do so by invoking Parse, since the parsed form is required for minification. If rolling up succeeds, any charset and imports are removed from the parsed stylesheet, to match the flattened+minimized CSS for the input contents (without charset/imports), and to help speed up the ultimate call to RollUpStylesheets().