| 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 13 matching lines...) Expand all Loading... |
| 24 */ | 24 */ |
| 25 | 25 |
| 26 #ifndef AtomicHTMLToken_h | 26 #ifndef AtomicHTMLToken_h |
| 27 #define AtomicHTMLToken_h | 27 #define AtomicHTMLToken_h |
| 28 | 28 |
| 29 #include "core/HTMLElementLookupTrie.h" | 29 #include "core/HTMLElementLookupTrie.h" |
| 30 #include "core/dom/Attribute.h" | 30 #include "core/dom/Attribute.h" |
| 31 #include "core/html/parser/CompactHTMLToken.h" | 31 #include "core/html/parser/CompactHTMLToken.h" |
| 32 #include "core/html/parser/HTMLToken.h" | 32 #include "core/html/parser/HTMLToken.h" |
| 33 #include "wtf/Allocator.h" | 33 #include "wtf/Allocator.h" |
| 34 #include "wtf/PtrUtil.h" | |
| 35 #include <memory> | |
| 36 | 34 |
| 37 namespace blink { | 35 namespace blink { |
| 38 | 36 |
| 39 class CORE_EXPORT AtomicHTMLToken { | 37 class CORE_EXPORT AtomicHTMLToken { |
| 40 STACK_ALLOCATED(); | 38 STACK_ALLOCATED(); |
| 41 WTF_MAKE_NONCOPYABLE(AtomicHTMLToken); | 39 WTF_MAKE_NONCOPYABLE(AtomicHTMLToken); |
| 42 public: | 40 public: |
| 43 | 41 |
| 44 bool forceQuirks() const | 42 bool forceQuirks() const |
| 45 { | 43 { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 144 |
| 147 explicit AtomicHTMLToken(const CompactHTMLToken& token) | 145 explicit AtomicHTMLToken(const CompactHTMLToken& token) |
| 148 : m_type(token.type()) | 146 : m_type(token.type()) |
| 149 { | 147 { |
| 150 switch (m_type) { | 148 switch (m_type) { |
| 151 case HTMLToken::Uninitialized: | 149 case HTMLToken::Uninitialized: |
| 152 ASSERT_NOT_REACHED(); | 150 ASSERT_NOT_REACHED(); |
| 153 break; | 151 break; |
| 154 case HTMLToken::DOCTYPE: | 152 case HTMLToken::DOCTYPE: |
| 155 m_name = AtomicString(token.data()); | 153 m_name = AtomicString(token.data()); |
| 156 m_doctypeData = wrapUnique(new DoctypeData()); | 154 m_doctypeData = adoptPtr(new DoctypeData()); |
| 157 m_doctypeData->m_hasPublicIdentifier = true; | 155 m_doctypeData->m_hasPublicIdentifier = true; |
| 158 append(m_doctypeData->m_publicIdentifier, token.publicIdentifier()); | 156 append(m_doctypeData->m_publicIdentifier, token.publicIdentifier()); |
| 159 m_doctypeData->m_hasSystemIdentifier = true; | 157 m_doctypeData->m_hasSystemIdentifier = true; |
| 160 append(m_doctypeData->m_systemIdentifier, token.systemIdentifier()); | 158 append(m_doctypeData->m_systemIdentifier, token.systemIdentifier()); |
| 161 m_doctypeData->m_forceQuirks = token.doctypeForcesQuirks(); | 159 m_doctypeData->m_forceQuirks = token.doctypeForcesQuirks(); |
| 162 break; | 160 break; |
| 163 case HTMLToken::EndOfFile: | 161 case HTMLToken::EndOfFile: |
| 164 break; | 162 break; |
| 165 case HTMLToken::StartTag: | 163 case HTMLToken::StartTag: |
| 166 m_attributes.reserveInitialCapacity(token.attributes().size()); | 164 m_attributes.reserveInitialCapacity(token.attributes().size()); |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 | 205 |
| 208 bool usesAttributes() const; | 206 bool usesAttributes() const; |
| 209 | 207 |
| 210 // "name" for DOCTYPE, StartTag, and EndTag | 208 // "name" for DOCTYPE, StartTag, and EndTag |
| 211 AtomicString m_name; | 209 AtomicString m_name; |
| 212 | 210 |
| 213 // "data" for Comment, "characters" for Character | 211 // "data" for Comment, "characters" for Character |
| 214 String m_data; | 212 String m_data; |
| 215 | 213 |
| 216 // For DOCTYPE | 214 // For DOCTYPE |
| 217 std::unique_ptr<DoctypeData> m_doctypeData; | 215 OwnPtr<DoctypeData> m_doctypeData; |
| 218 | 216 |
| 219 // For StartTag and EndTag | 217 // For StartTag and EndTag |
| 220 bool m_selfClosing; | 218 bool m_selfClosing; |
| 221 | 219 |
| 222 Vector<Attribute> m_attributes; | 220 Vector<Attribute> m_attributes; |
| 223 }; | 221 }; |
| 224 | 222 |
| 225 inline void AtomicHTMLToken::initializeAttributes(const HTMLToken::AttributeList
& attributes) | 223 inline void AtomicHTMLToken::initializeAttributes(const HTMLToken::AttributeList
& attributes) |
| 226 { | 224 { |
| 227 size_t size = attributes.size(); | 225 size_t size = attributes.size(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 244 const QualifiedName& name = nameForAttribute(attribute); | 242 const QualifiedName& name = nameForAttribute(attribute); |
| 245 // FIXME: This is N^2 for the number of attributes. | 243 // FIXME: This is N^2 for the number of attributes. |
| 246 if (!findAttributeInVector(m_attributes, name)) | 244 if (!findAttributeInVector(m_attributes, name)) |
| 247 m_attributes.append(Attribute(name, value)); | 245 m_attributes.append(Attribute(name, value)); |
| 248 } | 246 } |
| 249 } | 247 } |
| 250 | 248 |
| 251 } // namespace blink | 249 } // namespace blink |
| 252 | 250 |
| 253 #endif | 251 #endif |
| OLD | NEW |