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

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

Issue 678073002: Parse Sky entities according to the spec (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/HTMLEntityParser.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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2010 Google, Inc. All Rights Reserved. 3 * Copyright (C) 2010 Google, Inc. All Rights Reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 13 matching lines...) Expand all
24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 24 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
25 */ 25 */
26 26
27 #ifndef HTMLEntityParser_h 27 #ifndef HTMLEntityParser_h
28 #define HTMLEntityParser_h 28 #define HTMLEntityParser_h
29 29
30 #include "platform/text/SegmentedString.h" 30 #include "platform/text/SegmentedString.h"
31 31
32 namespace blink { 32 namespace blink {
33 33
34 class DecodedHTMLEntity { 34 class HTMLEntityParser {
35 public:
36 typedef Vector<UChar, 32> OutputBuffer;
37
38 HTMLEntityParser();
39 ~HTMLEntityParser();
40
41 void reset();
42 bool parse(SegmentedString&);
43
44 const OutputBuffer& result() const { return m_buffer; }
45
35 private: 46 private:
36 // HTML entities contain at most four UTF-16 code units. 47 enum EntityState {
37 static const unsigned kMaxLength = 4; 48 Initial,
49 Numeric,
50 PossiblyHex,
51 Hex,
52 Decimal,
53 Named
54 };
38 55
39 public: 56 void finalizeNumericEntity();
40 DecodedHTMLEntity() : length(0) { } 57 void finalizeNamedEntity();
41 58
42 bool isEmpty() const { return !length; } 59 EntityState m_state;
43 60 UChar32 m_result;
44 void append(UChar c) 61 OutputBuffer m_buffer;
45 {
46 RELEASE_ASSERT(length < kMaxLength);
47 data[length++] = c;
48 }
49
50 void append(UChar32 c)
51 {
52 if (U_IS_BMP(c)) {
53 append(static_cast<UChar>(c));
54 return;
55 }
56 append(U16_LEAD(c));
57 append(U16_TRAIL(c));
58 }
59
60 unsigned length;
61 UChar data[kMaxLength];
62 }; 62 };
63 63
64 bool consumeHTMLEntity(SegmentedString&, DecodedHTMLEntity& decodedEntity, bool& notEnoughCharacters, UChar additionalAllowedCharacter = '\0');
65
66 // Used by the XML parser. Not suitable for use in HTML parsing. Use consumeHT MLEntity instead.
67 size_t decodeNamedEntityToUCharArray(const char*, UChar result[4]);
68
69 } 64 }
70 65
71 #endif 66 #endif
OLDNEW
« no previous file with comments | « no previous file | sky/engine/core/html/parser/HTMLEntityParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698