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 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 if (attributes.at(i).name().matches(name)) | 58 if (attributes.at(i).name().matches(name)) |
59 return &attributes.at(i); | 59 return &attributes.at(i); |
60 } | 60 } |
61 return 0; | 61 return 0; |
62 } | 62 } |
63 | 63 |
64 class HTMLToken { | 64 class HTMLToken { |
65 WTF_MAKE_NONCOPYABLE(HTMLToken); | 65 WTF_MAKE_NONCOPYABLE(HTMLToken); |
66 USING_FAST_MALLOC(HTMLToken); | 66 USING_FAST_MALLOC(HTMLToken); |
67 public: | 67 public: |
68 enum Type { | 68 enum TokenType { |
69 Uninitialized, | 69 Uninitialized, |
70 DOCTYPE, | 70 DOCTYPE, |
71 StartTag, | 71 StartTag, |
72 EndTag, | 72 EndTag, |
73 Comment, | 73 Comment, |
74 Character, | 74 Character, |
75 EndOfFile, | 75 EndOfFile, |
76 }; | 76 }; |
77 | 77 |
78 class Attribute { | 78 class Attribute { |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
128 // Don't call Vector::clear() as that would destroy the | 128 // Don't call Vector::clear() as that would destroy the |
129 // alloced VectorBuffer. If the innerHTML'd content has | 129 // alloced VectorBuffer. If the innerHTML'd content has |
130 // two 257 character text nodes in a row, we'll needlessly | 130 // two 257 character text nodes in a row, we'll needlessly |
131 // thrash malloc. When we finally finish the parse the | 131 // thrash malloc. When we finally finish the parse the |
132 // HTMLToken will be destroyed and the VectorBuffer released. | 132 // HTMLToken will be destroyed and the VectorBuffer released. |
133 m_data.shrink(0); | 133 m_data.shrink(0); |
134 m_orAllData = 0; | 134 m_orAllData = 0; |
135 } | 135 } |
136 | 136 |
137 bool isUninitialized() { return m_type == Uninitialized; } | 137 bool isUninitialized() { return m_type == Uninitialized; } |
138 Type type() const { return m_type; } | 138 TokenType type() const { return m_type; } |
139 | 139 |
140 void makeEndOfFile() | 140 void makeEndOfFile() |
141 { | 141 { |
142 ASSERT(m_type == Uninitialized); | 142 ASSERT(m_type == Uninitialized); |
143 m_type = EndOfFile; | 143 m_type = EndOfFile; |
144 } | 144 } |
145 | 145 |
146 /* Range and offset methods exposed for HTMLSourceTracker and HTMLViewSource
Parser */ | 146 /* Range and offset methods exposed for HTMLSourceTracker and HTMLViewSource
Parser */ |
147 int startIndex() const { return m_range.start; } | 147 int startIndex() const { return m_range.start; } |
148 int endIndex() const { return m_range.end; } | 148 int endIndex() const { return m_range.end; } |
(...skipping 303 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
452 | 452 |
453 // Only for XSSAuditor | 453 // Only for XSSAuditor |
454 void eraseCharacters() | 454 void eraseCharacters() |
455 { | 455 { |
456 ASSERT(m_type == Character); | 456 ASSERT(m_type == Character); |
457 m_data.clear(); | 457 m_data.clear(); |
458 m_orAllData = 0; | 458 m_orAllData = 0; |
459 } | 459 } |
460 | 460 |
461 private: | 461 private: |
462 Type m_type; | 462 TokenType m_type; |
463 Attribute::Range m_range; // Always starts at zero. | 463 Attribute::Range m_range; // Always starts at zero. |
464 int m_baseOffset; | 464 int m_baseOffset; |
465 DataVector m_data; | 465 DataVector m_data; |
466 UChar m_orAllData; | 466 UChar m_orAllData; |
467 | 467 |
468 // For StartTag and EndTag | 468 // For StartTag and EndTag |
469 bool m_selfClosing; | 469 bool m_selfClosing; |
470 AttributeList m_attributes; | 470 AttributeList m_attributes; |
471 | 471 |
472 // A pointer into m_attributes used during lexing. | 472 // A pointer into m_attributes used during lexing. |
473 Attribute* m_currentAttribute; | 473 Attribute* m_currentAttribute; |
474 | 474 |
475 // For DOCTYPE | 475 // For DOCTYPE |
476 OwnPtr<DoctypeData> m_doctypeData; | 476 OwnPtr<DoctypeData> m_doctypeData; |
477 }; | 477 }; |
478 | 478 |
479 } // namespace blink | 479 } // namespace blink |
480 | 480 |
481 #endif | 481 #endif |
OLD | NEW |