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

Side by Side Diff: sky/engine/core/html/parser/HTMLToken.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
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 } 43 }
44 44
45 class HTMLToken { 45 class HTMLToken {
46 WTF_MAKE_NONCOPYABLE(HTMLToken); 46 WTF_MAKE_NONCOPYABLE(HTMLToken);
47 WTF_MAKE_FAST_ALLOCATED; 47 WTF_MAKE_FAST_ALLOCATED;
48 public: 48 public:
49 enum Type { 49 enum Type {
50 Uninitialized, 50 Uninitialized,
51 StartTag, 51 StartTag,
52 EndTag, 52 EndTag,
53 Comment,
54 Character, 53 Character,
55 EndOfFile, 54 EndOfFile,
56 }; 55 };
57 56
58 class Attribute { 57 class Attribute {
59 public: 58 public:
60 class Range { 59 class Range {
61 public: 60 public:
62 int start; 61 int start;
63 int end; 62 int end;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 m_baseOffset = offset; 106 m_baseOffset = offset;
108 } 107 }
109 108
110 void end(int endOffset) 109 void end(int endOffset)
111 { 110 {
112 m_range.end = endOffset - m_baseOffset; 111 m_range.end = endOffset - m_baseOffset;
113 } 112 }
114 113
115 const DataVector& data() const 114 const DataVector& data() const
116 { 115 {
117 ASSERT(m_type == Character || m_type == Comment || m_type == StartTag || m_type == EndTag); 116 ASSERT(m_type == Character || m_type == StartTag || m_type == EndTag);
118 return m_data; 117 return m_data;
119 } 118 }
120 119
121 bool isAll8BitData() const 120 bool isAll8BitData() const
122 { 121 {
123 return (m_orAllData <= 0xff); 122 return (m_orAllData <= 0xff);
124 } 123 }
125 124
126 const DataVector& name() const 125 const DataVector& name() const
127 { 126 {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 m_data.append(character); 290 m_data.append(character);
292 m_orAllData |= character; 291 m_orAllData |= character;
293 } 292 }
294 293
295 void appendToCharacter(const Vector<LChar, 32>& characters) 294 void appendToCharacter(const Vector<LChar, 32>& characters)
296 { 295 {
297 ASSERT(m_type == Character); 296 ASSERT(m_type == Character);
298 m_data.appendVector(characters); 297 m_data.appendVector(characters);
299 } 298 }
300 299
301 /* Comment Tokens */
302
303 const DataVector& comment() const
304 {
305 ASSERT(m_type == Comment);
306 return m_data;
307 }
308
309 void beginComment()
310 {
311 ASSERT(m_type == Uninitialized);
312 m_type = Comment;
313 }
314
315 void appendToComment(UChar character)
316 {
317 ASSERT(character);
318 ASSERT(m_type == Comment);
319 m_data.append(character);
320 m_orAllData |= character;
321 }
322
323 private: 300 private:
324 Type m_type; 301 Type m_type;
325 Attribute::Range m_range; // Always starts at zero. 302 Attribute::Range m_range; // Always starts at zero.
326 int m_baseOffset; 303 int m_baseOffset;
327 DataVector m_data; 304 DataVector m_data;
328 UChar m_orAllData; 305 UChar m_orAllData;
329 306
330 // For StartTag and EndTag 307 // For StartTag and EndTag
331 bool m_selfClosing; 308 bool m_selfClosing;
332 AttributeList m_attributes; 309 AttributeList m_attributes;
333 310
334 // A pointer into m_attributes used during lexing. 311 // A pointer into m_attributes used during lexing.
335 Attribute* m_currentAttribute; 312 Attribute* m_currentAttribute;
336 }; 313 };
337 314
338 } 315 }
339 316
340 #endif 317 #endif
OLDNEW
« no previous file with comments | « sky/engine/core/html/parser/CompactHTMLToken.cpp ('k') | sky/engine/core/html/parser/HTMLTokenizer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698