Page Speed Optimization Libraries
1.13.35.1
|
#include "srcset_slot.h"
Classes | |
struct | ImageCandidate |
Public Member Functions | |
SrcSetSlotCollection (RewriteDriver *driver, HtmlElement *element, HtmlElement::Attribute *attribute) | |
void | Initialize (CommonFilter *filter) |
int | num_image_candidates () |
SrcSetSlot * | slot (int idx) |
may be nullptr. | |
const GoogleString & | url (int idx) |
void | set_url (int idx, GoogleString new_url) |
const GoogleString & | descriptor (int idx) |
HtmlElement * | element () const |
HtmlElement::Attribute * | attribute () const |
CommonFilter * | filter () const |
The first filter that created this slot collection. There may be others. | |
RewriteDriver * | driver () |
int | begin_line_number () const |
int | end_line_number () const |
void | Commit () |
Public Member Functions inherited from net_instaweb::RefCounted< SrcSetSlotCollection > | |
void | Release () |
void | AddRef () |
bool | HasOneRef () |
Static Public Member Functions | |
static void | ParseSrcSet (StringPiece input, std::vector< ImageCandidate > *out) |
static GoogleString | Serialize (const std::vector< ImageCandidate > &in) |
Protected Member Functions | |
REFCOUNT_FRIEND_DECLARATION (SrcSetSlotCollection) | |
Since the various images inside a src attribute share the attribute, we hook them all up to a single SrcSetSlotCollection (which they own).
net_instaweb::SrcSetSlotCollection::SrcSetSlotCollection | ( | RewriteDriver * | driver, |
HtmlElement * | element, | ||
HtmlElement::Attribute * | attribute | ||
) |
Note: you need to separately call Initialize() to actually create all the slots and the like. This sets up just enough to be able to compare slots.
void net_instaweb::SrcSetSlotCollection::Commit | ( | ) |
This serializes everything back to the attribute. (Which is sadly quadratic, but the size should be small enough that it's more practical than trying to coordinate).
void net_instaweb::SrcSetSlotCollection::Initialize | ( | CommonFilter * | filter | ) |
This will parse the passed in srcset attribute, and create all the slots, and all their resources.
|
static |
Parses the input srcset attribute into *out (replacing its contents), filling in the url and descriptor fields (but not trying to create resources or fill in slot).