| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 Google Inc. All rights reserved. | 2 * Copyright (c) 2012 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. | 3 * Copyright (C) 2013 BlackBerry Limited. All rights reserved. |
| 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 are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 #include "wtf/text/Unicode.h" | 46 #include "wtf/text/Unicode.h" |
| 47 | 47 |
| 48 #include <algorithm> | 48 #include <algorithm> |
| 49 #include <hb.h> | 49 #include <hb.h> |
| 50 #include <unicode/normlzr.h> | 50 #include <unicode/normlzr.h> |
| 51 #include <unicode/uchar.h> | 51 #include <unicode/uchar.h> |
| 52 #include <unicode/uscript.h> | 52 #include <unicode/uscript.h> |
| 53 | 53 |
| 54 namespace blink { | 54 namespace blink { |
| 55 | 55 |
| 56 template<typename T> | |
| 57 class HarfBuzzScopedPtr { | |
| 58 STACK_ALLOCATED(); | |
| 59 WTF_MAKE_NONCOPYABLE(HarfBuzzScopedPtr); | |
| 60 public: | |
| 61 typedef void (*DestroyFunction)(T*); | |
| 62 | |
| 63 HarfBuzzScopedPtr(T* ptr, DestroyFunction destroy) | |
| 64 : m_ptr(ptr) | |
| 65 , m_destroy(destroy) | |
| 66 { | |
| 67 ASSERT(m_destroy); | |
| 68 } | |
| 69 ~HarfBuzzScopedPtr() | |
| 70 { | |
| 71 if (m_ptr) | |
| 72 (*m_destroy)(m_ptr); | |
| 73 } | |
| 74 | |
| 75 T* get() { return m_ptr; } | |
| 76 void set(T* ptr) { m_ptr = ptr; } | |
| 77 private: | |
| 78 T* m_ptr; | |
| 79 DestroyFunction m_destroy; | |
| 80 }; | |
| 81 | |
| 82 static inline float harfBuzzPositionToFloat(hb_position_t value) | 56 static inline float harfBuzzPositionToFloat(hb_position_t value) |
| 83 { | 57 { |
| 84 return static_cast<float>(value) / (1 << 16); | 58 return static_cast<float>(value) / (1 << 16); |
| 85 } | 59 } |
| 86 | 60 |
| 87 static void normalizeCharacters(const TextRun& run, unsigned length, UChar* dest
ination, unsigned* destinationLength) | 61 static void normalizeCharacters(const TextRun& run, unsigned length, UChar* dest
ination, unsigned* destinationLength) |
| 88 { | 62 { |
| 89 unsigned position = 0; | 63 unsigned position = 0; |
| 90 bool error = false; | 64 bool error = false; |
| 91 const UChar* source; | 65 const UChar* source; |
| (...skipping 705 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 797 } | 771 } |
| 798 | 772 |
| 799 // Don't need to check m_textRun.allowsTrailingExpansion() since it's covere
d by !m_expansionOpportunityCount above | 773 // Don't need to check m_textRun.allowsTrailingExpansion() since it's covere
d by !m_expansionOpportunityCount above |
| 800 spacing += nextExpansionPerOpportunity(); | 774 spacing += nextExpansionPerOpportunity(); |
| 801 m_isAfterExpansion = true; | 775 m_isAfterExpansion = true; |
| 802 return spacing; | 776 return spacing; |
| 803 } | 777 } |
| 804 | 778 |
| 805 | 779 |
| 806 } // namespace blink | 780 } // namespace blink |
| OLD | NEW |