OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * 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 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 15 matching lines...) Expand all Loading... | |
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
29 */ | 29 */ |
30 | 30 |
31 #ifndef OpenTypeSanitizer_h | 31 #ifndef OpenTypeSanitizer_h |
32 #define OpenTypeSanitizer_h | 32 #define OpenTypeSanitizer_h |
33 | 33 |
34 #include "opentype-sanitiser.h" | 34 #include "opentype-sanitiser.h" |
35 #include "wtf/Forward.h" | 35 #include "wtf/Forward.h" |
36 #include "wtf/text/WTFString.h" | |
36 | 37 |
37 namespace blink { | 38 namespace blink { |
38 | 39 |
39 class SharedBuffer; | 40 class SharedBuffer; |
40 | 41 |
41 class OpenTypeSanitizer { | 42 class OpenTypeSanitizer { |
42 public: | 43 public: |
43 explicit OpenTypeSanitizer(SharedBuffer* buffer) | 44 explicit OpenTypeSanitizer(SharedBuffer* buffer) |
44 : m_buffer(buffer) | 45 : m_buffer(buffer) |
46 , m_otsErrorString("") | |
45 { | 47 { |
46 } | 48 } |
47 | 49 |
48 PassRefPtr<SharedBuffer> sanitize(); | 50 PassRefPtr<SharedBuffer> sanitize(); |
49 | 51 |
50 static bool supportsFormat(const String&); | 52 static bool supportsFormat(const String&); |
53 String getErrorString() const { return static_cast<String>(m_otsErrorString) ; } | |
54 | |
55 void setErrorString(const String& errorString) { m_otsErrorString = errorStr ing; } | |
56 | |
57 bool isParsingError() const { return m_parsingError; } | |
58 void setParsingError(bool parsingError) { m_parsingError = parsingError; } | |
51 | 59 |
52 private: | 60 private: |
53 SharedBuffer* const m_buffer; | 61 SharedBuffer* const m_buffer; |
62 String m_otsErrorString; | |
63 bool m_parsingError; | |
54 }; | 64 }; |
55 | 65 |
56 class BlinkOTSContext: public ots::OTSContext { | 66 class BlinkOTSContext: public ots::OTSContext { |
57 public: | 67 public: |
58 // TODO: Implement "Message" to support user friendly messages | 68 BlinkOTSContext() |
69 : m_errorString("") | |
70 { | |
71 } | |
72 | |
73 virtual void Message(int level, const char *format, ...) | |
jungshik at Google
2015/05/12 20:22:48
Just wondering if there's a reason to have this in
h.joshi
2015/05/14 04:52:15
Moved methods to CPP file, normally all methods we
| |
74 { | |
75 va_list args; | |
76 va_start(args, format); | |
77 | |
78 #if COMPILER(MSVC) | |
79 int result = _vscprintf(format, args); | |
80 #else | |
81 char ch; | |
82 int result = vsnprintf(&ch, 1, format, args); | |
83 #endif | |
84 va_end(args); | |
85 | |
86 if (result <= 0) { | |
87 m_errorString = String("OTS Error"); | |
88 } else { | |
89 Vector<char, 256> buffer; | |
90 unsigned len = result; | |
91 buffer.grow(len + 1); | |
92 | |
93 va_start(args, format); | |
94 vsnprintf(buffer.data(), buffer.size(), format, args); | |
95 va_end(args); | |
96 m_errorString = StringImpl::create(reinterpret_cast<const LChar* >(buffer.data()), len); | |
97 } | |
98 } | |
99 | |
59 virtual ots::TableAction GetTableAction(uint32_t tag) | 100 virtual ots::TableAction GetTableAction(uint32_t tag) |
60 { | 101 { |
61 #define TABLE_TAG(c1, c2, c3, c4) ((uint32_t)((((uint8_t)(c1)) << 24) | (((uint8 _t)(c2)) << 16) | (((uint8_t)(c3)) << 8) | ((uint8_t)(c4)))) | 102 #define TABLE_TAG(c1, c2, c3, c4) ((uint32_t)((((uint8_t)(c1)) << 24) | (((uint8 _t)(c2)) << 16) | (((uint8_t)(c3)) << 8) | ((uint8_t)(c4)))) |
62 | 103 |
63 const uint32_t cbdtTag = TABLE_TAG('C', 'B', 'D', 'T'); | 104 const uint32_t cbdtTag = TABLE_TAG('C', 'B', 'D', 'T'); |
64 const uint32_t cblcTag = TABLE_TAG('C', 'B', 'L', 'C'); | 105 const uint32_t cblcTag = TABLE_TAG('C', 'B', 'L', 'C'); |
65 const uint32_t colrTag = TABLE_TAG('C', 'O', 'L', 'R'); | 106 const uint32_t colrTag = TABLE_TAG('C', 'O', 'L', 'R'); |
66 const uint32_t cpalTag = TABLE_TAG('C', 'P', 'A', 'L'); | 107 const uint32_t cpalTag = TABLE_TAG('C', 'P', 'A', 'L'); |
67 | 108 |
68 switch (tag) { | 109 switch (tag) { |
69 // Google Color Emoji Tables | 110 // Google Color Emoji Tables |
70 case cbdtTag: | 111 case cbdtTag: |
71 case cblcTag: | 112 case cblcTag: |
72 // Windows Color Emoji Tables | 113 // Windows Color Emoji Tables |
73 case colrTag: | 114 case colrTag: |
74 case cpalTag: | 115 case cpalTag: |
75 return ots::TABLE_ACTION_PASSTHRU; | 116 return ots::TABLE_ACTION_PASSTHRU; |
76 default: | 117 default: |
77 return ots::TABLE_ACTION_DEFAULT; | 118 return ots::TABLE_ACTION_DEFAULT; |
78 } | 119 } |
79 #undef TABLE_TAG | 120 #undef TABLE_TAG |
80 } | 121 } |
122 | |
123 String getErrorString() const { return static_cast<String>(m_errorString ); } | |
124 private: | |
125 String m_errorString; | |
81 }; | 126 }; |
82 | 127 |
83 } // namespace blink | 128 } // namespace blink |
84 | 129 |
85 #endif // OpenTypeSanitizer_h | 130 #endif // OpenTypeSanitizer_h |
OLD | NEW |