OLD | NEW |
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 24 matching lines...) Expand all Loading... |
35 #include <memory> | 35 #include <memory> |
36 | 36 |
37 namespace blink { | 37 namespace blink { |
38 | 38 |
39 class CORE_EXPORT AtomicHTMLToken { | 39 class CORE_EXPORT AtomicHTMLToken { |
40 STACK_ALLOCATED(); | 40 STACK_ALLOCATED(); |
41 WTF_MAKE_NONCOPYABLE(AtomicHTMLToken); | 41 WTF_MAKE_NONCOPYABLE(AtomicHTMLToken); |
42 | 42 |
43 public: | 43 public: |
44 bool forceQuirks() const { | 44 bool forceQuirks() const { |
45 ASSERT(m_type == HTMLToken::DOCTYPE); | 45 DCHECK_EQ(m_type, HTMLToken::DOCTYPE); |
46 return m_doctypeData->m_forceQuirks; | 46 return m_doctypeData->m_forceQuirks; |
47 } | 47 } |
48 | 48 |
49 HTMLToken::TokenType type() const { return m_type; } | 49 HTMLToken::TokenType type() const { return m_type; } |
50 | 50 |
51 const AtomicString& name() const { | 51 const AtomicString& name() const { |
52 ASSERT(usesName()); | 52 DCHECK(usesName()); |
53 return m_name; | 53 return m_name; |
54 } | 54 } |
55 | 55 |
56 void setName(const AtomicString& name) { | 56 void setName(const AtomicString& name) { |
57 ASSERT(usesName()); | 57 DCHECK(usesName()); |
58 m_name = name; | 58 m_name = name; |
59 } | 59 } |
60 | 60 |
61 bool selfClosing() const { | 61 bool selfClosing() const { |
62 ASSERT(m_type == HTMLToken::StartTag || m_type == HTMLToken::EndTag); | 62 DCHECK(m_type == HTMLToken::StartTag || m_type == HTMLToken::EndTag); |
63 return m_selfClosing; | 63 return m_selfClosing; |
64 } | 64 } |
65 | 65 |
66 Attribute* getAttributeItem(const QualifiedName& attributeName) { | 66 Attribute* getAttributeItem(const QualifiedName& attributeName) { |
67 ASSERT(usesAttributes()); | 67 DCHECK(usesAttributes()); |
68 return findAttributeInVector(m_attributes, attributeName); | 68 return findAttributeInVector(m_attributes, attributeName); |
69 } | 69 } |
70 | 70 |
71 Vector<Attribute>& attributes() { | 71 Vector<Attribute>& attributes() { |
72 ASSERT(usesAttributes()); | 72 DCHECK(usesAttributes()); |
73 return m_attributes; | 73 return m_attributes; |
74 } | 74 } |
75 | 75 |
76 const Vector<Attribute>& attributes() const { | 76 const Vector<Attribute>& attributes() const { |
77 ASSERT(usesAttributes()); | 77 DCHECK(usesAttributes()); |
78 return m_attributes; | 78 return m_attributes; |
79 } | 79 } |
80 | 80 |
81 const String& characters() const { | 81 const String& characters() const { |
82 ASSERT(m_type == HTMLToken::Character); | 82 DCHECK_EQ(m_type, HTMLToken::Character); |
83 return m_data; | 83 return m_data; |
84 } | 84 } |
85 | 85 |
86 const String& comment() const { | 86 const String& comment() const { |
87 ASSERT(m_type == HTMLToken::Comment); | 87 DCHECK_EQ(m_type, HTMLToken::Comment); |
88 return m_data; | 88 return m_data; |
89 } | 89 } |
90 | 90 |
91 // FIXME: Distinguish between a missing public identifer and an empty one. | 91 // FIXME: Distinguish between a missing public identifer and an empty one. |
92 Vector<UChar>& publicIdentifier() const { | 92 Vector<UChar>& publicIdentifier() const { |
93 ASSERT(m_type == HTMLToken::DOCTYPE); | 93 DCHECK_EQ(m_type, HTMLToken::DOCTYPE); |
94 return m_doctypeData->m_publicIdentifier; | 94 return m_doctypeData->m_publicIdentifier; |
95 } | 95 } |
96 | 96 |
97 // FIXME: Distinguish between a missing system identifer and an empty one. | 97 // FIXME: Distinguish between a missing system identifer and an empty one. |
98 Vector<UChar>& systemIdentifier() const { | 98 Vector<UChar>& systemIdentifier() const { |
99 ASSERT(m_type == HTMLToken::DOCTYPE); | 99 DCHECK_EQ(m_type, HTMLToken::DOCTYPE); |
100 return m_doctypeData->m_systemIdentifier; | 100 return m_doctypeData->m_systemIdentifier; |
101 } | 101 } |
102 | 102 |
103 explicit AtomicHTMLToken(HTMLToken& token) : m_type(token.type()) { | 103 explicit AtomicHTMLToken(HTMLToken& token) : m_type(token.type()) { |
104 switch (m_type) { | 104 switch (m_type) { |
105 case HTMLToken::Uninitialized: | 105 case HTMLToken::Uninitialized: |
106 ASSERT_NOT_REACHED(); | 106 NOTREACHED(); |
107 break; | 107 break; |
108 case HTMLToken::DOCTYPE: | 108 case HTMLToken::DOCTYPE: |
109 m_name = AtomicString(token.name()); | 109 m_name = AtomicString(token.name()); |
110 m_doctypeData = token.releaseDoctypeData(); | 110 m_doctypeData = token.releaseDoctypeData(); |
111 break; | 111 break; |
112 case HTMLToken::EndOfFile: | 112 case HTMLToken::EndOfFile: |
113 break; | 113 break; |
114 case HTMLToken::StartTag: | 114 case HTMLToken::StartTag: |
115 case HTMLToken::EndTag: { | 115 case HTMLToken::EndTag: { |
116 m_selfClosing = token.selfClosing(); | 116 m_selfClosing = token.selfClosing(); |
(...skipping 12 matching lines...) Expand all Loading... |
129 else | 129 else |
130 m_data = String(token.data()); | 130 m_data = String(token.data()); |
131 break; | 131 break; |
132 } | 132 } |
133 } | 133 } |
134 | 134 |
135 explicit AtomicHTMLToken(const CompactHTMLToken& token) | 135 explicit AtomicHTMLToken(const CompactHTMLToken& token) |
136 : m_type(token.type()) { | 136 : m_type(token.type()) { |
137 switch (m_type) { | 137 switch (m_type) { |
138 case HTMLToken::Uninitialized: | 138 case HTMLToken::Uninitialized: |
139 ASSERT_NOT_REACHED(); | 139 NOTREACHED(); |
140 break; | 140 break; |
141 case HTMLToken::DOCTYPE: | 141 case HTMLToken::DOCTYPE: |
142 m_name = AtomicString(token.data()); | 142 m_name = AtomicString(token.data()); |
143 m_doctypeData = WTF::makeUnique<DoctypeData>(); | 143 m_doctypeData = WTF::makeUnique<DoctypeData>(); |
144 m_doctypeData->m_hasPublicIdentifier = true; | 144 m_doctypeData->m_hasPublicIdentifier = true; |
145 token.publicIdentifier().appendTo(m_doctypeData->m_publicIdentifier); | 145 token.publicIdentifier().appendTo(m_doctypeData->m_publicIdentifier); |
146 m_doctypeData->m_hasSystemIdentifier = true; | 146 m_doctypeData->m_hasSystemIdentifier = true; |
147 token.systemIdentifier().appendTo(m_doctypeData->m_systemIdentifier); | 147 token.systemIdentifier().appendTo(m_doctypeData->m_systemIdentifier); |
148 m_doctypeData->m_forceQuirks = token.doctypeForcesQuirks(); | 148 m_doctypeData->m_forceQuirks = token.doctypeForcesQuirks(); |
149 break; | 149 break; |
(...skipping 25 matching lines...) Expand all Loading... |
175 explicit AtomicHTMLToken(HTMLToken::TokenType type) | 175 explicit AtomicHTMLToken(HTMLToken::TokenType type) |
176 : m_type(type), m_selfClosing(false) {} | 176 : m_type(type), m_selfClosing(false) {} |
177 | 177 |
178 AtomicHTMLToken(HTMLToken::TokenType type, | 178 AtomicHTMLToken(HTMLToken::TokenType type, |
179 const AtomicString& name, | 179 const AtomicString& name, |
180 const Vector<Attribute>& attributes = Vector<Attribute>()) | 180 const Vector<Attribute>& attributes = Vector<Attribute>()) |
181 : m_type(type), | 181 : m_type(type), |
182 m_name(name), | 182 m_name(name), |
183 m_selfClosing(false), | 183 m_selfClosing(false), |
184 m_attributes(attributes) { | 184 m_attributes(attributes) { |
185 ASSERT(usesName()); | 185 DCHECK(usesName()); |
186 } | 186 } |
187 | 187 |
188 #ifndef NDEBUG | 188 #ifndef NDEBUG |
189 void show() const; | 189 void show() const; |
190 #endif | 190 #endif |
191 | 191 |
192 private: | 192 private: |
193 HTMLToken::TokenType m_type; | 193 HTMLToken::TokenType m_type; |
194 | 194 |
195 void initializeAttributes(const HTMLToken::AttributeList& attributes); | 195 void initializeAttributes(const HTMLToken::AttributeList& attributes); |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 const QualifiedName& name = nameForAttribute(attribute); | 233 const QualifiedName& name = nameForAttribute(attribute); |
234 // FIXME: This is N^2 for the number of attributes. | 234 // FIXME: This is N^2 for the number of attributes. |
235 if (!findAttributeInVector(m_attributes, name)) | 235 if (!findAttributeInVector(m_attributes, name)) |
236 m_attributes.push_back(Attribute(name, value)); | 236 m_attributes.push_back(Attribute(name, value)); |
237 } | 237 } |
238 } | 238 } |
239 | 239 |
240 } // namespace blink | 240 } // namespace blink |
241 | 241 |
242 #endif | 242 #endif |
OLD | NEW |