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

Side by Side Diff: third_party/WebKit/Source/wtf/text/TextCodec.h

Issue 1709293002: Add support for CSS unicod encoding to the text codec. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add a unit test Created 4 years, 7 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved. 2 * Copyright (C) 2004, 2006 Apple Computer, Inc. All rights reserved.
3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com> 3 * Copyright (C) 2006 Alexey Proskuryakov <ap@nypop.com>
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 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 // Substitutes the replacement character "?". 43 // Substitutes the replacement character "?".
44 QuestionMarksForUnencodables, 44 QuestionMarksForUnencodables,
45 45
46 // Encodes the character as an XML entity. For example, U+06DE 46 // Encodes the character as an XML entity. For example, U+06DE
47 // would be "&#1758;" (0x6DE = 1758 in octal). 47 // would be "&#1758;" (0x6DE = 1758 in octal).
48 EntitiesForUnencodables, 48 EntitiesForUnencodables,
49 49
50 // Encodes the character as en entity as above, but escaped 50 // Encodes the character as en entity as above, but escaped
51 // non-alphanumeric characters. This is used in URLs. 51 // non-alphanumeric characters. This is used in URLs.
52 // For example, U+6DE would be "%26%231758%3B". 52 // For example, U+6DE would be "%26%231758%3B".
53 URLEncodedEntitiesForUnencodables 53 URLEncodedEntitiesForUnencodables,
54
55 // Encodes the character as a CSS entity. For example U+06DE
56 // would be \06de. See: https://www.w3.org/TR/css-syntax-3/#escaping
57 CSSEncodedEntitiesForUnencodables,
54 }; 58 };
55 59
56 typedef char UnencodableReplacementArray[32]; 60 typedef char UnencodableReplacementArray[32];
57 61
58 enum FlushBehavior { 62 enum FlushBehavior {
59 // More bytes are coming, don't flush the codec. 63 // More bytes are coming, don't flush the codec.
60 DoNotFlush = 0, 64 DoNotFlush = 0,
61 65
62 // A fetch has hit EOF. Some codecs handle fetches differently, for compat r easons. 66 // A fetch has hit EOF. Some codecs handle fetches differently, for compat r easons.
63 FetchEOF, 67 FetchEOF,
64 68
65 // Do a full flush of the codec. 69 // Do a full flush of the codec.
66 DataEOF 70 DataEOF
67 }; 71 };
68 72
69 static_assert(!DoNotFlush, "DoNotFlush should be falsy"); 73 static_assert(!DoNotFlush, "DoNotFlush should be falsy");
70 static_assert(FetchEOF, "FetchEOF should be truthy"); 74 static_assert(FetchEOF, "FetchEOF should be truthy");
71 static_assert(DataEOF, "DataEOF should be truthy"); 75 static_assert(DataEOF, "DataEOF should be truthy");
72 76
73 77 class WTF_EXPORT TextCodec {
74 class TextCodec {
75 WTF_MAKE_NONCOPYABLE(TextCodec); USING_FAST_MALLOC(TextCodec); 78 WTF_MAKE_NONCOPYABLE(TextCodec); USING_FAST_MALLOC(TextCodec);
76 public: 79 public:
77 TextCodec() { } 80 TextCodec() { }
78 virtual ~TextCodec(); 81 virtual ~TextCodec();
79 82
80 String decode(const char* str, size_t length, FlushBehavior flush = DoNotFlu sh) 83 String decode(const char* str, size_t length, FlushBehavior flush = DoNotFlu sh)
81 { 84 {
82 bool ignored; 85 bool ignored;
83 return decode(str, length, flush, false, ignored); 86 return decode(str, length, flush, false, ignored);
84 } 87 }
(...skipping 11 matching lines...) Expand all
96 typedef void (*EncodingNameRegistrar)(const char* alias, const char* name); 99 typedef void (*EncodingNameRegistrar)(const char* alias, const char* name);
97 100
98 typedef PassOwnPtr<TextCodec> (*NewTextCodecFunction)(const TextEncoding&, const void* additionalData); 101 typedef PassOwnPtr<TextCodec> (*NewTextCodecFunction)(const TextEncoding&, const void* additionalData);
99 typedef void (*TextCodecRegistrar)(const char* name, NewTextCodecFunction, const void* additionalData); 102 typedef void (*TextCodecRegistrar)(const char* name, NewTextCodecFunction, const void* additionalData);
100 103
101 } // namespace WTF 104 } // namespace WTF
102 105
103 using WTF::TextCodec; 106 using WTF::TextCodec;
104 107
105 #endif // TextCodec_h 108 #endif // TextCodec_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/frame/FrameSerializer.cpp ('k') | third_party/WebKit/Source/wtf/text/TextCodec.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698