19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_CSS_HIERARCHY_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_CSS_HIERARCHY_H_
36 namespace net_instaweb {
66 static const char kFailureReasonPrefix[];
78 const StringPiece input_contents,
79 bool has_unparseables,
80 int64 flattened_result_limit,
81 Css::Stylesheet* stylesheet,
86 return flattening_succeeded_ && !url_.empty();
89 const StringPiece url()
const {
return url_; }
90 const StringPiece url_for_humans()
const {
91 return (url_.empty() ?
"inline"
96 const GoogleUrl& css_base_url()
const {
return css_base_url_; }
97 const GoogleUrl& css_trim_url()
const {
return css_trim_url_; }
103 return (input_contents_resolved_ ? css_trim_url_ : css_base_url_);
106 const Css::Stylesheet* stylesheet()
const {
return stylesheet_.get(); }
107 Css::Stylesheet* mutable_stylesheet() {
return stylesheet_.get(); }
108 void set_stylesheet(Css::Stylesheet* stylesheet);
110 const StringPiece input_contents()
const {
return input_contents_; }
114 input_contents_ = input_contents;
118 return &input_contents_backing_store_;
120 void set_input_contents_to_backing_store() {
121 input_contents_ = input_contents_backing_store_;
124 const GoogleString& minified_contents()
const {
return minified_contents_; }
125 void set_minified_contents(
const StringPiece minified_contents);
127 const GoogleString& charset()
const {
return charset_; }
130 const GoogleString& charset_source()
const {
return charset_source_; }
132 const StringVector& media()
const {
return media_; }
133 StringVector* mutable_media() {
return &media_; }
136 const std::vector<CssHierarchy*>&
children()
const {
return children_; }
137 std::vector<CssHierarchy*>&
children() {
return children_; }
139 bool input_contents_resolved()
const {
return input_contents_resolved_; }
140 void set_input_contents_resolved(
bool x) { input_contents_resolved_ = x; }
142 bool flattening_succeeded()
const {
return flattening_succeeded_; }
143 void set_flattening_succeeded(
bool ok) { flattening_succeeded_ = ok; }
146 return flattening_failure_reason_;
155 bool unparseable_detected()
const {
return unparseable_detected_; }
156 void set_unparseable_detected(
bool ok) { unparseable_detected_ = ok; }
158 int64 flattened_result_limit()
const {
return flattened_result_limit_; }
159 void set_flattened_result_limit(int64 x) { flattened_result_limit_ = x; }
229 friend class CssHierarchyTest;
235 const GoogleUrl& import_url);
238 void ResizeChildren(
int n);
243 bool IsRecursive()
const;
250 bool DetermineImportMedia(
const StringVector& containing_media,
251 const StringVector& import_media);
259 bool DetermineRulesetMedia(StringVector* ruleset_media);
269 GoogleUrl css_base_url_;
273 GoogleUrl css_trim_url_;
282 std::vector<CssHierarchy*> children_;
285 StringPiece input_contents_;
300 scoped_ptr<Css::Stylesheet> stylesheet_;
320 bool input_contents_resolved_;
325 bool flattening_succeeded_;
332 bool unparseable_detected_;
342 int64 flattened_result_limit_;
345 MessageHandler* message_handler_;
class GoogleUrl
Definition: google_url.h:58
bool NeedsRewriting() const
A hierarchy needs rewriting only if it has an import to read and expand.
Definition: css_hierarchy.h:85
Definition: css_hierarchy.h:64
bool CheckCharsetOk(const ResourcePtr &resource, GoogleString *failure_reason)
const std::vector< CssHierarchy * > & children() const
Intended for access to children; add new children using ExpandChildren.
Definition: css_hierarchy.h:136
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)
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
void set_input_contents(const StringPiece input_contents)
Definition: css_hierarchy.h:113
const GoogleUrl & css_resolution_base()
Definition: css_hierarchy.h:102
CssHierarchy(CssFilter *filter)
Definition: message_handler.h:39
Definition: css_filter.h:74
bool IsDataUrl(const StringPiece url)
Determine if the given URL is a data: URL. Cheaper than ParseDataUrl.
void AddFlatteningFailureReason(const GoogleString &reason)