19 #ifndef NET_INSTAWEB_REWRITER_PUBLIC_RESOURCE_SLOT_H_
20 #define NET_INSTAWEB_REWRITER_PUBLIC_RESOURCE_SLOT_H_
25 #include "net/instaweb/htmlparse/public/html_element.h"
28 #include "net/instaweb/util/public/ref_counted_ptr.h"
31 #include "net/instaweb/util/public/vector_deque.h"
32 #include "pagespeed/kernel/base/ref_counted_ptr.h"
33 #include "pagespeed/kernel/http/google_url.h"
35 namespace net_instaweb {
37 class HtmlResourceSlot;
43 typedef RefCountedPtr<ResourceSlot> ResourceSlotPtr;
44 typedef RefCountedPtr<HtmlResourceSlot> HtmlResourceSlotPtr;
45 typedef std::vector<ResourceSlotPtr> ResourceSlotVector;
56 : resource_(resource),
57 disable_rendering_(
false),
58 should_delete_element_(
false),
59 disable_further_processing_(
false),
60 was_optimized_(
false) {
63 ResourcePtr resource()
const {
return resource_; }
65 virtual HtmlElement*
element()
const = 0;
86 bool disable_rendering()
const {
return disable_rendering_; }
95 should_delete_element_ =
true;
96 disable_further_processing_ =
true;
98 bool should_delete_element()
const {
return should_delete_element_; }
119 disable_further_processing_ = x;
122 bool disable_further_processing()
const {
123 return disable_further_processing_;
131 virtual void Render() = 0;
174 UrlRelativity url_relativity,
175 const GoogleUrl& base_url);
182 ResourcePtr resource_;
183 bool disable_rendering_;
184 bool should_delete_element_;
185 bool disable_further_processing_;
190 VectorDeque<RewriteContext*> contexts_;
202 virtual HtmlElement*
element()
const {
return NULL; }
218 HtmlElement::Attribute* attribute,
221 virtual HtmlElement*
element()
const {
return element_; }
222 HtmlElement::Attribute* attribute()
const {
return attribute_; }
238 HtmlElement* element_;
239 HtmlElement::Attribute* attribute_;
241 UrlRelativity url_relativity_;
243 int begin_line_number_;
244 int end_line_number_;
251 bool operator()(
const HtmlResourceSlotPtr& p,
252 const HtmlResourceSlotPtr& q)
const;
255 typedef std::set<HtmlResourceSlotPtr,
virtual void Finished()
Definition: resource_slot.h:136
void set_disable_rendering(bool x)
Definition: resource_slot.h:85
bool was_optimized() const
Definition: resource_slot.h:106
virtual GoogleString LocationString()
void SetResource(const ResourcePtr &resource)
static GoogleString RelativizeOrPassthrough(const RewriteOptions *options, StringPiece url, UrlRelativity url_relativity, const GoogleUrl &base_url)
Definition: resource_slot.h:53
virtual bool DirectSetUrl(const StringPiece &url)
virtual bool CanDirectSetUrl()
Definition: resource_slot.h:152
Definition: resource_slot.h:214
virtual GoogleString LocationString()
virtual HtmlElement * element() const
Return HTML element associated with slot, or NULL if none (CSS, IPRO)
Definition: resource_slot.h:221
void RequestDeleteElement()
Definition: resource_slot.h:94
virtual HtmlElement * element() const
Return HTML element associated with slot, or NULL if none (CSS, IPRO)
Definition: resource_slot.h:202
void set_disable_further_processing(bool x)
Definition: resource_slot.h:118
UrlRelativity url_relativity() const
Definition: resource_slot.h:231
Definition: resource_slot.h:197
Definition: rewrite_driver.h:98
RewriteContext * LastContext() const
void AddContext(RewriteContext *context)
Adds a new context to this slot.
Definition: resource_slot.h:159
virtual bool DirectSetUrl(const StringPiece &url)
Definition: rewrite_context.h:144
virtual bool CanDirectSetUrl()
Definition: resource_slot.h:227
Definition: resource_slot.h:249
virtual GoogleString LocationString()=0
Definition: rewrite_options.h:81
void DetachContext(RewriteContext *context)
virtual HtmlElement * element() const =0
Return HTML element associated with slot, or NULL if none (CSS, IPRO)
void set_was_optimized(bool x)
Marks the slot as having been optimized.
Definition: resource_slot.h:109