| 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 |
| 61 uint16_t length = endIndex - startIndex; |
| 62 ASSERT(static_cast<unsigned>(startIndex + length) <= normalizedBufferLength)
; |
| 63 TextBreakIterator* cursorPosIterator = cursorMovementIterator(&normalizedBuf
fer[startIndex], normalizedBufferLength); |
| 64 |
| 65 int cursorPos = cursorPosIterator->current(); |
| 66 unsigned numGraphemes = 0; |
| 67 while (cursorPos < length) { |
| 68 cursorPos = cursorPosIterator->next(); |
| 69 if (cursorPos == TextBreakDone) |
| 70 return ClusterData(numGraphemes, normalizedBufferLength); |
| 71 |
| 72 numGraphemes++; |
| 73 } |
| 74 |
| 75 return ClusterData(numGraphemes, cursorPos); |
| 76 } |
| 53 | 77 |
| 54 static inline bool isBreakableSpace(UChar ch) | 78 static inline bool isBreakableSpace(UChar ch) |
| 55 { | 79 { |
| 56 switch (ch) { | 80 switch (ch) { |
| 57 case ' ': | 81 case ' ': |
| 58 case '\n': | 82 case '\n': |
| 59 case '\t': | 83 case '\t': |
| 60 return true; | 84 return true; |
| 61 default: | 85 default: |
| 62 return false; | 86 return false; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 287 } | 311 } |
| 288 | 312 |
| 289 int LazyLineBreakIterator::nextBreakablePositionKeepAll(int pos) | 313 int LazyLineBreakIterator::nextBreakablePositionKeepAll(int pos) |
| 290 { | 314 { |
| 291 if (m_string.is8Bit()) | 315 if (m_string.is8Bit()) |
| 292 return nextBreakablePosition<LChar>(*this, m_string.characters8(), m_str
ing.length(), pos); | 316 return nextBreakablePosition<LChar>(*this, m_string.characters8(), m_str
ing.length(), pos); |
| 293 return nextBreakablePositionKeepAllInternal(*this, m_string.characters16(),
m_string.length(), pos); | 317 return nextBreakablePositionKeepAllInternal(*this, m_string.characters16(),
m_string.length(), pos); |
| 294 } | 318 } |
| 295 | 319 |
| 296 } // namespace blink | 320 } // namespace blink |
| OLD | NEW |