Page Speed Optimization Libraries
1.4.26.1
|
Classes | |
class | Attribute |
struct | Data |
Public Types | |
enum | CloseStyle { AUTO_CLOSE, IMPLICIT_CLOSE, EXPLICIT_CLOSE, BRIEF_CLOSE, UNCLOSED } |
enum | QuoteStyle { NO_QUOTE, SINGLE_QUOTE, DOUBLE_QUOTE } |
Various ways things can be quoted (or not) | |
typedef InlineSList< Attribute > | AttributeList |
typedef InlineSList< Attribute > ::Iterator | AttributeIterator |
typedef InlineSList< Attribute > ::ConstIterator | AttributeConstIterator |
Public Member Functions | |
virtual bool | live () const |
virtual void | MarkAsDead (const HtmlEventListIterator &end) |
void | AddAttribute (const Attribute &attr) |
void | AddAttribute (const HtmlName &name, const StringPiece &decoded_value, QuoteStyle quote_style) |
void | AddEscapedAttribute (const HtmlName &name, const StringPiece &escaped_value, QuoteStyle quote_style) |
As AddAttribute, but assumes value has been escaped for html output. | |
bool | DeleteAttribute (HtmlName::Keyword keyword) |
const Attribute * | FindAttribute (HtmlName::Keyword keyword) const |
Attribute * | FindAttribute (HtmlName::Keyword keyword) |
const char * | AttributeValue (HtmlName::Keyword name) const |
const char * | EscapedAttributeValue (HtmlName::Keyword name) const |
const char * | name_str () const |
HtmlName::Keyword | keyword () const |
const HtmlName & | name () const |
void | set_name (const HtmlName &new_tag) |
const AttributeList & | attributes () const |
AttributeList * | mutable_attributes () |
CloseStyle | close_style () const |
void | set_close_style (CloseStyle style) |
void | ToString (GoogleString *buf) const |
void | DebugPrint () const |
int | begin_line_number () const |
int | end_line_number () const |
Protected Member Functions | |
virtual void | SynthesizeEvents (const HtmlEventListIterator &iter, HtmlEventList *queue) |
virtual HtmlEventListIterator | begin () const |
Return an iterator pointing to the first event associated with this node. | |
virtual HtmlEventListIterator | end () const |
Return an iterator pointing to the last event associated with this node. | |
Friends | |
class | HtmlParse |
class | HtmlLexer |
Tags can be closed in three ways: implicitly (e.g. <img ..>), briefly (e.g.
), or explicitly (<a...>...). The Lexer will always record the way it parsed a tag, but synthesized elements will have AUTO_CLOSE, and rewritten elements may no longer qualify for the closing style with which they were parsed.
AUTO_CLOSE |
synthesized tag, or not yet closed in source |
IMPLICIT_CLOSE |
E.g. <img...> <meta...> <link...> <br...> <input...> |
EXPLICIT_CLOSE |
E.g. anchor |
BRIEF_CLOSE |
E.g. <head> |
UNCLOSED |
Was never closed in source. |
void net_instaweb::HtmlElement::AddAttribute | ( | const Attribute & | attr | ) |
Add a copy of an attribute to this element. The attribute may come from this element, or another one.
void net_instaweb::HtmlElement::AddAttribute | ( | const HtmlName & | name, |
const StringPiece & | decoded_value, | ||
QuoteStyle | quote_style | ||
) |
Unconditionally add attribute, copying value. For binary attributes (those without values) use value=NULL.
Doesn't check for attribute duplication (which is illegal in html).
The value, if non-null, is assumed to be unescaped. See also AddEscapedAttribute.
const char* net_instaweb::HtmlElement::AttributeValue | ( | HtmlName::Keyword | name | ) | const [inline] |
Look up decoded attribute value by name. Returns NULL if: 1. no attribute exists 2. the attribute has no value. 3. the attribute has a value, but it cannot currently be safely decoded. If you care about this distinction, call FindAttribute. Use this only if you don't intend to change the attribute value; if you might change the attribute value, use FindAttribute instead (this avoids a double lookup).
bool net_instaweb::HtmlElement::DeleteAttribute | ( | HtmlName::Keyword | keyword | ) |
Remove the attribute with the given name. Return true if the attribute was deleted, false if it wasn't there to begin with.
const char* net_instaweb::HtmlElement::EscapedAttributeValue | ( | HtmlName::Keyword | name | ) | const [inline] |
Look up escaped attribute value by name. Returns NULL if: 1. no attribute exists 2. the attribute has no value. If you care about this distinction, call FindAttribute. Use this only if you don't intend to change the attribute value; if you might change the attribute value, use FindAttribute instead (this avoids a double lookup).
const Attribute* net_instaweb::HtmlElement::FindAttribute | ( | HtmlName::Keyword | keyword | ) | const |
Look up attribute by name. NULL if no attribute exists. Use this for attributes whose value you might want to change after lookup.
HtmlName::Keyword net_instaweb::HtmlElement::keyword | ( | ) | const [inline] |
Returns the HTML keyword enum. If this tag name is not recognized, returns HtmlName::kNotAKeyword, and you can examine name_str().
virtual void net_instaweb::HtmlElement::MarkAsDead | ( | const HtmlEventListIterator & | end | ) | [virtual] |
Marks a node as dead. The queue's end iterator should be passed in, to remove references to stale iterators, and to force IsRewritable to return false.
Implements net_instaweb::HtmlNode.
const char* net_instaweb::HtmlElement::name_str | ( | ) | const [inline] |
Returns the element tag name, which is not guaranteed to be case-folded. Compare keyword() to the Keyword constant found in html_name.h for fast tag name comparisons.
void net_instaweb::HtmlElement::set_name | ( | const HtmlName & | new_tag | ) | [inline] |
Changing that tag of an element should only occur if the caller knows that the old attributes make sense for the new tag. E.g. a div could be changed to a span.
virtual void net_instaweb::HtmlElement::SynthesizeEvents | ( | const HtmlEventListIterator & | iter, |
HtmlEventList * | queue | ||
) | [protected, virtual] |
Create new event object(s) representing this node, and insert them into the queue just before the given iterator; also, update this node object as necessary so that begin() and end() will return iterators pointing to the new event(s). The line number for each event should probably be -1.
Implements net_instaweb::HtmlNode.
void net_instaweb::HtmlElement::ToString | ( | GoogleString * | buf | ) | const |
Render an element as a string for debugging. This is not intended as a fully legal serialization.