net_instaweb::css_util Namespace Reference

Classes

class  StyleExtractor

Enumerations

enum  DimensionState {
  kNoDimensions, kHasHeightOnly, kHasWidthOnly, kHasBothDimensions,
  kNotParsable
}

Functions

DimensionState GetDimensions (Css::Declarations *decls, int *width, int *height)
void VectorizeMediaAttribute (const StringPiece &input_media, StringVector *output_vector)
GoogleString StringifyMediaVector (const StringVector &import_media)
void ConvertUnicodeVectorToStringVector (const std::vector< UnicodeText > &in_vector, StringVector *out_vector)
void ConvertStringVectorToUnicodeVector (const StringVector &in_vector, std::vector< UnicodeText > *out_vector)
void ClearVectorIfContainsMediaAll (StringVector *media)
template<typename T >
void EliminateElementsNotIn (std::vector< T > *sorted_inner, const std::vector< T > &sorted_outer)

Detailed Description

Todo:
TODO(nforman): remove this namespace and put everything into the StyleExtractor class.

Enumeration Type Documentation

Enumerator:
kNoDimensions 

No dimensions found.

kHasHeightOnly 

Found height only.

kHasWidthOnly 

Found width only.

kHasBothDimensions 

Found both width and height.

kNotParsable 

Found a dimension, but couldn't extract a value.


Function Documentation

void net_instaweb::css_util::ClearVectorIfContainsMediaAll ( StringVector *  media  ) 

Clear the given vector if it contains the media 'all'. This is required because Css::Parser doesn't treat 'all' specially but we do for efficiency.

void net_instaweb::css_util::ConvertStringVectorToUnicodeVector ( const StringVector &  in_vector,
std::vector< UnicodeText > *  out_vector 
)

Convert a vector of UTF-8 GoogleString's to UnicodeText's. Elements are trimmed and any empty elements are ignored.

void net_instaweb::css_util::ConvertUnicodeVectorToStringVector ( const std::vector< UnicodeText > &  in_vector,
StringVector *  out_vector 
)

Convert a vector of UnicodeText's (from Css::Import.media) to a vector of UTF-8 GoogleString's for use of the above functions. Elements are trimmed and any empty elements are ignored.

template<typename T >
void net_instaweb::css_util::EliminateElementsNotIn ( std::vector< T > *  sorted_inner,
const std::vector< T > &  sorted_outer 
) [inline]

Eliminate all elements from the first vector that are not in the second vector, with the caveat that an empty vector (first or second) means 'the set of all possible values', meaning that if the second vector is empty then no elements are removed from the first vector, and if the first vector is empty then the second vector is copied into it. Both vectors must be sorted on entry.

No more outer elements => delete all remaining inner elements.

This inner element is in the outer => keep it and move on.

This outer element isn't in the inner => skip it, try the next.

This inner element isn't in the outer => delete it, move on.

DimensionState net_instaweb::css_util::GetDimensions ( Css::Declarations *  decls,
int *  width,
int *  height 
)

Extract the width and height values out of a list of declarations. If a value was not found, it will be populated with kNoValue. This is "safe" because even if someone specifies a width:-1; it will be ignored: "If a negative length value is set on a property that does not allow negative length values, the declaration is ignored." http://www.w3.org/TR/CSS2/syndata.html#value-def-length

GoogleString net_instaweb::css_util::StringifyMediaVector ( const StringVector &  import_media  ) 

Convert a vector of media types to a media string. If the input vector is empty then the answer is 'all', the inverse of the vectorizing function above; if you want the empty string then test the vector yourself. Otherwise the answer is a comma-separated list of media types.

void net_instaweb::css_util::VectorizeMediaAttribute ( const StringPiece &  input_media,
StringVector *  output_vector 
)

Utility functions for handling CSS media types as vectors of strings. There is an argument to use StringPiece's rather than GoogleString's here, but CssFilter::FlattenImportsContext cannot use StringPiece's because it doesn't keep the original strings, so copies in GoogleString's are required. Convert a media string, from either a media attribute or after , to a vector of media types. If any of the input media types are 'all' then an empty vector is returned: 'all' means all media types are accepted so it subsumes all other types, and an empty vector representation is most useful.

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines
Generated on Tue May 29 16:34:23 2012 for Page Speed Optimization Libraries by  doxygen 1.6.3