OLD | NEW |
1 /* | 1 /* |
2 * (C) 1999 Lars Knoll (knoll@kde.org) | 2 * (C) 1999 Lars Knoll (knoll@kde.org) |
3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv
ed. | 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2010 Apple Inc. All rights reserv
ed. |
4 * Copyright (C) 2007-2009 Torch Mobile, Inc. | 4 * Copyright (C) 2007-2009 Torch Mobile, Inc. |
5 * Copyright (C) 2011 Google Inc. All rights reserved. | 5 * Copyright (C) 2011 Google Inc. All rights reserved. |
6 * | 6 * |
7 * This library is free software; you can redistribute it and/or | 7 * This library is free software; you can redistribute it and/or |
8 * modify it under the terms of the GNU Library General Public | 8 * modify it under the terms of the GNU Library General Public |
9 * License as published by the Free Software Foundation; either | 9 * License as published by the Free Software Foundation; either |
10 * version 2 of the License, or (at your option) any later version. | 10 * version 2 of the License, or (at your option) any later version. |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 NonSharedCharacterBreakIterator it(string); | 43 NonSharedCharacterBreakIterator it(string); |
44 if (!it) | 44 if (!it) |
45 return stringLength; | 45 return stringLength; |
46 | 46 |
47 unsigned num = 0; | 47 unsigned num = 0; |
48 while (it.next() != TextBreakDone) | 48 while (it.next() != TextBreakDone) |
49 ++num; | 49 ++num; |
50 return num; | 50 return num; |
51 } | 51 } |
52 | 52 |
| 53 ClusterData countCharactersAndGraphemesInCluster(const UChar* normalizedBuffer,
unsigned normalizedBufferLength, uint16_t startIndex, uint16_t endIndex) |
| 54 { |
| 55 if (startIndex > endIndex) { |
| 56 uint16_t tempIndex = startIndex; |
| 57 startIndex = endIndex; |
| 58 endIndex = tempIndex; |
| 59 } |
| 60 uint16_t length = endIndex - startIndex; |
| 61 ASSERT(static_cast<unsigned>(startIndex + length) <= normalizedBufferLength)
; |
| 62 TextBreakIterator* cursorPosIterator = cursorMovementIterator(&normalizedBuf
fer[startIndex], length); |
| 63 |
| 64 int cursorPos = cursorPosIterator->current(); |
| 65 int numGraphemes = -1; |
| 66 while (0 <= cursorPos) { |
| 67 cursorPos = cursorPosIterator->next(); |
| 68 numGraphemes++; |
| 69 } |
| 70 |
| 71 return ClusterData(std::max(numGraphemes, 0), cursorPosIterator->current()); |
| 72 } |
53 | 73 |
54 static inline bool isBreakableSpace(UChar ch) | 74 static inline bool isBreakableSpace(UChar ch) |
55 { | 75 { |
56 switch (ch) { | 76 switch (ch) { |
57 case ' ': | 77 case ' ': |
58 case '\n': | 78 case '\n': |
59 case '\t': | 79 case '\t': |
60 return true; | 80 return true; |
61 default: | 81 default: |
62 return false; | 82 return false; |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 } | 307 } |
288 | 308 |
289 int LazyLineBreakIterator::nextBreakablePositionKeepAll(int pos) | 309 int LazyLineBreakIterator::nextBreakablePositionKeepAll(int pos) |
290 { | 310 { |
291 if (m_string.is8Bit()) | 311 if (m_string.is8Bit()) |
292 return nextBreakablePosition<LChar>(*this, m_string.characters8(), m_str
ing.length(), pos); | 312 return nextBreakablePosition<LChar>(*this, m_string.characters8(), m_str
ing.length(), pos); |
293 return nextBreakablePositionKeepAllInternal(*this, m_string.characters16(),
m_string.length(), pos); | 313 return nextBreakablePositionKeepAllInternal(*this, m_string.characters16(),
m_string.length(), pos); |
294 } | 314 } |
295 | 315 |
296 } // namespace blink | 316 } // namespace blink |
OLD | NEW |