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

Unified 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, 2 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | sky/engine/core/html/parser/HTMLEntityParser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: sky/engine/core/html/parser/HTMLEntityParser.h
diff --git a/sky/engine/core/html/parser/HTMLEntityParser.h b/sky/engine/core/html/parser/HTMLEntityParser.h
index 42df842aa564d2d9afc6bc43552e77dc6aa7b30d..e146c4ec6ff1e60f94cedc844a5db865f90df61e 100644
--- a/sky/engine/core/html/parser/HTMLEntityParser.h
+++ b/sky/engine/core/html/parser/HTMLEntityParser.h
@@ -31,40 +31,35 @@
namespace blink {
-class DecodedHTMLEntity {
-private:
- // HTML entities contain at most four UTF-16 code units.
- static const unsigned kMaxLength = 4;
-
+class HTMLEntityParser {
public:
- DecodedHTMLEntity() : length(0) { }
+ typedef Vector<UChar, 32> OutputBuffer;
- bool isEmpty() const { return !length; }
+ HTMLEntityParser();
+ ~HTMLEntityParser();
- void append(UChar c)
- {
- RELEASE_ASSERT(length < kMaxLength);
- data[length++] = c;
- }
+ void reset();
+ bool parse(SegmentedString&);
- void append(UChar32 c)
- {
- if (U_IS_BMP(c)) {
- append(static_cast<UChar>(c));
- return;
- }
- append(U16_LEAD(c));
- append(U16_TRAIL(c));
- }
+ const OutputBuffer& result() const { return m_buffer; }
- unsigned length;
- UChar data[kMaxLength];
-};
+private:
+ enum EntityState {
+ Initial,
+ Numeric,
+ PossiblyHex,
+ Hex,
+ Decimal,
+ Named
+ };
-bool consumeHTMLEntity(SegmentedString&, DecodedHTMLEntity& decodedEntity, bool& notEnoughCharacters, UChar additionalAllowedCharacter = '\0');
+ void finalizeNumericEntity();
+ void finalizeNamedEntity();
-// Used by the XML parser. Not suitable for use in HTML parsing. Use consumeHTMLEntity instead.
-size_t decodeNamedEntityToUCharArray(const char*, UChar result[4]);
+ EntityState m_state;
+ UChar32 m_result;
+ OutputBuffer m_buffer;
+};
}
« 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