| 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 } | |
| 77 | 53 |
| 78 static inline bool isBreakableSpace(UChar ch) | 54 static inline bool isBreakableSpace(UChar ch) |
| 79 { | 55 { |
| 80 switch (ch) { | 56 switch (ch) { |
| 81 case ' ': | 57 case ' ': |
| 82 case '\n': | 58 case '\n': |
| 83 case '\t': | 59 case '\t': |
| 84 return true; | 60 return true; |
| 85 default: | 61 default: |
| 86 return false; | 62 return false; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 311 } | 287 } |
| 312 | 288 |
| 313 int LazyLineBreakIterator::nextBreakablePositionKeepAll(int pos) | 289 int LazyLineBreakIterator::nextBreakablePositionKeepAll(int pos) |
| 314 { | 290 { |
| 315 if (m_string.is8Bit()) | 291 if (m_string.is8Bit()) |
| 316 return nextBreakablePosition<LChar>(*this, m_string.characters8(), m_str
ing.length(), pos); | 292 return nextBreakablePosition<LChar>(*this, m_string.characters8(), m_str
ing.length(), pos); |
| 317 return nextBreakablePositionKeepAllInternal(*this, m_string.characters16(),
m_string.length(), pos); | 293 return nextBreakablePositionKeepAllInternal(*this, m_string.characters16(),
m_string.length(), pos); |
| 318 } | 294 } |
| 319 | 295 |
| 320 } // namespace blink | 296 } // namespace blink |
| OLD | NEW |