| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) Research In Motion Limited 2011. All rights reserved. | 2 * Copyright (C) Research In Motion Limited 2011. All rights reserved. |
| 3 * | 3 * |
| 4 * This library is free software; you can redistribute it and/or | 4 * This library is free software; you can redistribute it and/or |
| 5 * modify it under the terms of the GNU Library General Public | 5 * modify it under the terms of the GNU Library General Public |
| 6 * License as published by the Free Software Foundation; either | 6 * License as published by the Free Software Foundation; either |
| 7 * version 2 of the License, or (at your option) any later version. | 7 * version 2 of the License, or (at your option) any later version. |
| 8 * | 8 * |
| 9 * This library is distributed in the hope that it will be useful, | 9 * This library is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 USING_FAST_MALLOC(UTF16TextIterator); | 32 USING_FAST_MALLOC(UTF16TextIterator); |
| 33 WTF_MAKE_NONCOPYABLE(UTF16TextIterator); | 33 WTF_MAKE_NONCOPYABLE(UTF16TextIterator); |
| 34 | 34 |
| 35 public: | 35 public: |
| 36 // The passed in UChar pointer starts at 'offset'. The iterator operates on | 36 // The passed in UChar pointer starts at 'offset'. The iterator operates on |
| 37 // the range [offset, endOffset]. | 37 // the range [offset, endOffset]. |
| 38 // 'length' denotes the maximum length of the UChar array, which might exceed | 38 // 'length' denotes the maximum length of the UChar array, which might exceed |
| 39 // 'endOffset'. | 39 // 'endOffset'. |
| 40 UTF16TextIterator(const UChar*, int length); | 40 UTF16TextIterator(const UChar*, int length); |
| 41 | 41 |
| 42 // FIXME: The offset/endOffset fields are only used by the SimpleShaper, | |
| 43 // remove once HarfBuzz is used for all text. | |
| 44 UTF16TextIterator(const UChar*, int offset, int endOffset, int length); | |
| 45 | |
| 46 inline bool consume(UChar32& character) { | 42 inline bool consume(UChar32& character) { |
| 47 if (m_offset >= m_endOffset) | 43 if (m_offset >= m_length) |
| 48 return false; | 44 return false; |
| 49 | 45 |
| 50 character = *m_characters; | 46 character = *m_characters; |
| 51 m_currentGlyphLength = 1; | 47 m_currentGlyphLength = 1; |
| 52 if (!U16_IS_SURROGATE(character)) | 48 if (!U16_IS_SURROGATE(character)) |
| 53 return true; | 49 return true; |
| 54 | 50 |
| 55 return consumeSurrogatePair(character); | 51 return consumeSurrogatePair(character); |
| 56 } | 52 } |
| 57 | 53 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 68 unsigned glyphLength() const { return m_currentGlyphLength; } | 64 unsigned glyphLength() const { return m_currentGlyphLength; } |
| 69 | 65 |
| 70 private: | 66 private: |
| 71 bool isValidSurrogatePair(UChar32&); | 67 bool isValidSurrogatePair(UChar32&); |
| 72 bool consumeSurrogatePair(UChar32&); | 68 bool consumeSurrogatePair(UChar32&); |
| 73 void consumeMultipleUChar(); | 69 void consumeMultipleUChar(); |
| 74 | 70 |
| 75 const UChar* m_characters; | 71 const UChar* m_characters; |
| 76 const UChar* m_charactersEnd; | 72 const UChar* m_charactersEnd; |
| 77 int m_offset; | 73 int m_offset; |
| 78 int m_endOffset; | 74 int m_length; |
| 79 unsigned m_currentGlyphLength; | 75 unsigned m_currentGlyphLength; |
| 80 }; | 76 }; |
| 81 | 77 |
| 82 } // namespace blink | 78 } // namespace blink |
| 83 | 79 |
| 84 #endif | 80 #endif |
| OLD | NEW |