| 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() |
| 59 virtual ots::TableAction GetTableAction(uint32_t tag) | 69 : m_errorString("") |
| 60 { | 70 { |
| 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)))) | 71 } |
| 62 | 72 |
| 63 const uint32_t cbdtTag = TABLE_TAG('C', 'B', 'D', 'T'); | 73 virtual void Message(int level, const char *format, ...); |
| 64 const uint32_t cblcTag = TABLE_TAG('C', 'B', 'L', 'C'); | 74 virtual ots::TableAction GetTableAction(uint32_t tag); |
| 65 const uint32_t colrTag = TABLE_TAG('C', 'O', 'L', 'R'); | 75 String getErrorString() const { return static_cast<String>(m_errorString
); } |
| 66 const uint32_t cpalTag = TABLE_TAG('C', 'P', 'A', 'L'); | 76 private: |
| 67 | 77 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 }; | 78 }; |
| 82 | 79 |
| 83 } // namespace blink | 80 } // namespace blink |
| 84 | 81 |
| 85 #endif // OpenTypeSanitizer_h | 82 #endif // OpenTypeSanitizer_h |
| OLD | NEW |