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; } |
51 | 56 |
52 private: | 57 private: |
53 SharedBuffer* const m_buffer; | 58 SharedBuffer* const m_buffer; |
| 59 String m_otsErrorString; |
54 }; | 60 }; |
55 | 61 |
56 class BlinkOTSContext: public ots::OTSContext { | 62 class BlinkOTSContext: public ots::OTSContext { |
57 public: | 63 public: |
58 // TODO: Implement "Message" to support user friendly messages | 64 BlinkOTSContext() |
59 virtual ots::TableAction GetTableAction(uint32_t tag) | 65 : m_errorString("") |
60 { | 66 { |
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)))) | 67 } |
62 | 68 |
63 const uint32_t cbdtTag = TABLE_TAG('C', 'B', 'D', 'T'); | 69 virtual void Message(int level, const char *format, ...); |
64 const uint32_t cblcTag = TABLE_TAG('C', 'B', 'L', 'C'); | 70 virtual ots::TableAction GetTableAction(uint32_t tag); |
65 const uint32_t colrTag = TABLE_TAG('C', 'O', 'L', 'R'); | 71 String getErrorString() const { return static_cast<String>(m_errorString
); } |
66 const uint32_t cpalTag = TABLE_TAG('C', 'P', 'A', 'L'); | 72 private: |
67 | 73 String m_errorString; |
68 switch (tag) { | |
69 // Google Color Emoji Tables | |
70 case cbdtTag: | |
71 case cblcTag: | |
72 // Windows Color Emoji Tables | |
73 case colrTag: | |
74 case cpalTag: | |
75 return ots::TABLE_ACTION_PASSTHRU; | |
76 default: | |
77 return ots::TABLE_ACTION_DEFAULT; | |
78 } | |
79 #undef TABLE_TAG | |
80 } | |
81 }; | 74 }; |
82 | 75 |
83 } // namespace blink | 76 } // namespace blink |
84 | 77 |
85 #endif // OpenTypeSanitizer_h | 78 #endif // OpenTypeSanitizer_h |
OLD | NEW |