19 #ifndef PAGESPEED_KERNEL_HTML_HTML_ELEMENT_H_
20 #define PAGESPEED_KERNEL_HTML_HTML_ELEMENT_H_
30 namespace net_instaweb {
86 HtmlName name()
const {
return name_; }
87 void set_name(
const HtmlName& name) { name_ = name; }
119 if (!decoded_value_computed_) {
120 ComputeDecodedValue();
122 return decoded_value_.get();
125 void set_decoding_error(
bool x) { decoding_error_ = x; }
126 bool decoding_error()
const {
127 if (!decoded_value_computed_) {
128 ComputeDecodedValue();
130 return decoding_error_;
158 void SetValue(
const StringPiece& value);
165 void set_quote_style(
QuoteStyle new_quote_style) {
166 quote_style_ = new_quote_style;
172 void ComputeDecodedValue()
const;
178 static inline void CopyValue(
const StringPiece& src,
183 mutable bool decoding_error_;
184 mutable bool decoded_value_computed_;
217 typedef InlineSList<Attribute> AttributeList;
218 typedef InlineSList<Attribute>::Iterator AttributeIterator;
219 typedef InlineSList<Attribute>::ConstIterator AttributeConstIterator;
221 virtual ~HtmlElement();
229 virtual bool live()
const {
return (data_.get() != NULL) && data_->live_; }
247 const StringPiece& decoded_value,
251 const StringPiece& escaped_value,
265 const Attribute* result = const_this->
FindAttribute(keyword);
266 return const_cast<Attribute*
>(result);
271 const HtmlElement* const_this =
this;
273 return const_cast<Attribute*
>(result);
278 return attribute !=
nullptr;
292 if (attribute != NULL) {
308 if (attribute != NULL) {
317 StringPiece
name_str()
const {
return data_->name_.value(); }
324 const HtmlName& name()
const {
return data_->name_; }
331 const AttributeList& attributes()
const {
return data_->attributes_; }
332 AttributeList* mutable_attributes() {
return &data_->attributes_; }
334 friend class HtmlParse;
335 friend class HtmlLexer;
337 Style style()
const {
return data_->style_; }
338 void set_style(
Style style) { data_->style_ = style; }
343 void DebugPrint()
const;
345 int begin_line_number()
const {
return data_->begin_line_number_; }
346 int end_line_number()
const {
return data_->end_line_number_; }
350 HtmlEventList* queue);
352 virtual HtmlEventListIterator
begin()
const {
return data_->begin_; }
353 virtual HtmlEventListIterator
end()
const {
return data_->end_; }
360 const HtmlEventListIterator&
begin,
361 const HtmlEventListIterator&
end);
366 static const unsigned kMaxLineNumber = 0x00ffffff;
379 unsigned begin_line_number_ : 24;
381 unsigned end_line_number_ : 24;
385 AttributeList attributes_;
386 HtmlEventListIterator begin_;
387 HtmlEventListIterator end_;
393 void set_begin(
const HtmlEventListIterator&
begin) { data_->begin_ =
begin; }
394 void set_end(
const HtmlEventListIterator&
end) { data_->end_ =
end; }
396 void set_begin_line_number(
int line) { data_->begin_line_number_ = line; }
397 void set_end_line_number(
int line) { data_->end_line_number_ = line; }
400 HtmlElement(HtmlElement* parent,
const HtmlName& name,
401 const HtmlEventListIterator&
begin,
402 const HtmlEventListIterator&
end);
409 void FreeData() { data_.reset(NULL); }
411 scoped_ptr<Data> data_;
StringPiece name_str() const
Definition: html_element.h:317
Definition: html_element.h:66
void set_name(const HtmlName &new_tag)
Definition: html_element.h:329
E.g. anchor
Definition: html_element.h:53
virtual HtmlEventListIterator end() const
Return an iterator pointing to the last event associated with this node.
Definition: html_element.h:353
virtual GoogleString ToString() const
QuoteStyle
Various ways things can be quoted (or not)
Definition: html_element.h:60
const char * quote_str() const
Textual form of quote for printing.
synthesized tag, or not yet closed in source
Definition: html_element.h:51
const char * EscapedAttributeValue(HtmlName::Keyword name) const
Definition: html_element.h:306
virtual bool live() const
Definition: html_element.h:229
bool DeleteAttribute(HtmlName::Keyword keyword)
virtual void MarkAsDead(const HtmlEventListIterator &end)
Definition: html_element.h:42
const Attribute * FindAttribute(HtmlName::Keyword keyword) const
QuoteStyle quote_style() const
Definition: html_element.h:135
virtual void SynthesizeEvents(const HtmlEventListIterator &iter, HtmlEventList *queue)
void AddEscapedAttribute(const HtmlName &name, const StringPiece &escaped_value, QuoteStyle quote_style)
As AddAttribute, but assumes value has been escaped for html output.
E.g. <img...> <meta...> <link...> <br...> <input...>
Definition: html_element.h:52
std::string GoogleString
PAGESPEED_KERNEL_BASE_STRING_H_.
Definition: string.h:24
Style
Definition: html_element.h:50
HtmlName::Keyword keyword() const
Definition: html_element.h:322
E.g. <head>
Definition: html_element.h:54
Keyword keyword() const
HtmlName's should be normally constructed using HtmlParse::MakeName.
Definition: html_name.h:260
const char * DecodedValueOrNull() const
Definition: html_element.h:118
Definition: html_node.h:43
StringPiece value() const
Return the atom string, which may not be case folded.
Definition: html_name.h:263
HtmlName::Keyword keyword() const
Definition: html_element.h:84
const char * AttributeValue(HtmlName::Keyword name) const
Definition: html_element.h:290
Definition: html_name.h:31
const char * escaped_value() const
Definition: html_element.h:91
StringPiece name_str() const
Definition: html_element.h:79
void SetEscapedValue(const StringPiece &value)
Keyword
Definition: html_name.h:39
Definition: inline_slist.h:39
virtual HtmlEventListIterator begin() const
Return an iterator pointing to the first event associated with this node.
Definition: html_element.h:352
void AddAttribute(const Attribute &attr)
void SetValue(const StringPiece &value)
Programatically hidden element.
Definition: html_element.h:56
Was never closed in source, so don't serialize close-tag.
Definition: html_element.h:55