Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(234)

Side by Side Diff: sky/engine/core/html/parser/AtomicHTMLToken.h

Issue 682893002: Parse comments according to parsing.md (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | sky/engine/core/html/parser/CompactHTMLToken.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2013 Google, Inc. All Rights Reserved. 2 * Copyright (C) 2013 Google, Inc. All Rights Reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 ASSERT(usesAttributes()); 76 ASSERT(usesAttributes());
77 return m_attributes; 77 return m_attributes;
78 } 78 }
79 79
80 const String& characters() const 80 const String& characters() const
81 { 81 {
82 ASSERT(m_type == HTMLToken::Character); 82 ASSERT(m_type == HTMLToken::Character);
83 return m_data; 83 return m_data;
84 } 84 }
85 85
86 const String& comment() const
87 {
88 ASSERT(m_type == HTMLToken::Comment);
89 return m_data;
90 }
91
92 explicit AtomicHTMLToken(HTMLToken& token) 86 explicit AtomicHTMLToken(HTMLToken& token)
93 : m_type(token.type()) 87 : m_type(token.type())
94 { 88 {
95 switch (m_type) { 89 switch (m_type) {
96 case HTMLToken::Uninitialized: 90 case HTMLToken::Uninitialized:
97 ASSERT_NOT_REACHED(); 91 ASSERT_NOT_REACHED();
98 break; 92 break;
99 case HTMLToken::EndOfFile: 93 case HTMLToken::EndOfFile:
100 break; 94 break;
101 case HTMLToken::StartTag: 95 case HTMLToken::StartTag:
102 case HTMLToken::EndTag: { 96 case HTMLToken::EndTag: {
103 m_selfClosing = token.selfClosing(); 97 m_selfClosing = token.selfClosing();
104 if (StringImpl* tagName = lookupHTMLTag(token.name().data(), token.n ame().size())) 98 if (StringImpl* tagName = lookupHTMLTag(token.name().data(), token.n ame().size()))
105 m_name = AtomicString(tagName); 99 m_name = AtomicString(tagName);
106 else 100 else
107 m_name = AtomicString(token.name()); 101 m_name = AtomicString(token.name());
108 initializeAttributes(token.attributes()); 102 initializeAttributes(token.attributes());
109 break; 103 break;
110 } 104 }
111 case HTMLToken::Character: 105 case HTMLToken::Character:
112 case HTMLToken::Comment:
113 if (token.isAll8BitData()) 106 if (token.isAll8BitData())
114 m_data = String::make8BitFrom16BitSource(token.data()); 107 m_data = String::make8BitFrom16BitSource(token.data());
115 else 108 else
116 m_data = String(token.data()); 109 m_data = String(token.data());
117 break; 110 break;
118 } 111 }
119 } 112 }
120 113
121 explicit AtomicHTMLToken(const CompactHTMLToken& token) 114 explicit AtomicHTMLToken(const CompactHTMLToken& token)
122 : m_type(token.type()) 115 : m_type(token.type())
(...skipping 11 matching lines...) Expand all
134 // FIXME: This is N^2 for the number of attributes. 127 // FIXME: This is N^2 for the number of attributes.
135 if (!findAttributeInVector(m_attributes, name)) 128 if (!findAttributeInVector(m_attributes, name))
136 m_attributes.append(Attribute(name, AtomicString(it->value)) ); 129 m_attributes.append(Attribute(name, AtomicString(it->value)) );
137 } 130 }
138 // Fall through! 131 // Fall through!
139 case HTMLToken::EndTag: 132 case HTMLToken::EndTag:
140 m_selfClosing = token.selfClosing(); 133 m_selfClosing = token.selfClosing();
141 m_name = AtomicString(token.data()); 134 m_name = AtomicString(token.data());
142 break; 135 break;
143 case HTMLToken::Character: 136 case HTMLToken::Character:
144 case HTMLToken::Comment:
145 m_data = token.data(); 137 m_data = token.data();
146 break; 138 break;
147 } 139 }
148 } 140 }
149 141
150 explicit AtomicHTMLToken(HTMLToken::Type type) 142 explicit AtomicHTMLToken(HTMLToken::Type type)
151 : m_type(type) 143 : m_type(type)
152 , m_selfClosing(false) 144 , m_selfClosing(false)
153 { 145 {
154 } 146 }
(...skipping 13 matching lines...) Expand all
168 void initializeAttributes(const HTMLToken::AttributeList& attributes); 160 void initializeAttributes(const HTMLToken::AttributeList& attributes);
169 QualifiedName nameForAttribute(const HTMLToken::Attribute&) const; 161 QualifiedName nameForAttribute(const HTMLToken::Attribute&) const;
170 162
171 bool usesName() const; 163 bool usesName() const;
172 164
173 bool usesAttributes() const; 165 bool usesAttributes() const;
174 166
175 // "name" for StartTag and EndTag 167 // "name" for StartTag and EndTag
176 AtomicString m_name; 168 AtomicString m_name;
177 169
178 // "data" for Comment, "characters" for Character 170 // "characters" for Character
179 String m_data; 171 String m_data;
180 172
181 // For StartTag and EndTag 173 // For StartTag and EndTag
182 bool m_selfClosing; 174 bool m_selfClosing;
183 175
184 Vector<Attribute> m_attributes; 176 Vector<Attribute> m_attributes;
185 }; 177 };
186 178
187 inline void AtomicHTMLToken::initializeAttributes(const HTMLToken::AttributeList & attributes) 179 inline void AtomicHTMLToken::initializeAttributes(const HTMLToken::AttributeList & attributes)
188 { 180 {
(...skipping 17 matching lines...) Expand all
206 const QualifiedName& name = nameForAttribute(attribute); 198 const QualifiedName& name = nameForAttribute(attribute);
207 // FIXME: This is N^2 for the number of attributes. 199 // FIXME: This is N^2 for the number of attributes.
208 if (!findAttributeInVector(m_attributes, name)) 200 if (!findAttributeInVector(m_attributes, name))
209 m_attributes.append(Attribute(name, value)); 201 m_attributes.append(Attribute(name, value));
210 } 202 }
211 } 203 }
212 204
213 } 205 }
214 206
215 #endif 207 #endif
OLDNEW
« no previous file with comments | « no previous file | sky/engine/core/html/parser/CompactHTMLToken.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698