Chromium Code Reviews| 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 unsigned numCharactersInGraphemeClusters(const String& string, unsigned numGraph emeClusters) | |
|
eae
2015/05/14 23:52:48
We already have an implementation of this in HarfB
changseok
2015/05/15 17:08:56
Sorry, I can't follow this meaning. Do you want an
| |
| 54 { | |
| 55 unsigned stringLength = string.length(); | |
| 56 | |
| 57 if (!stringLength) | |
| 58 return 0; | |
| 59 | |
| 60 // The only Latin-1 Extended Grapheme Cluster is CR LF | |
| 61 if (string.is8Bit() && !string.contains('\r')) | |
| 62 return std::min(stringLength, numGraphemeClusters); | |
| 63 | |
| 64 NonSharedCharacterBreakIterator it(string); | |
| 65 if (!it) | |
| 66 return std::min(stringLength, numGraphemeClusters); | |
| 67 | |
| 68 for (unsigned i = 0; i < numGraphemeClusters; ++i) { | |
| 69 if (it.next() == TextBreakDone) | |
| 70 return stringLength; | |
| 71 } | |
| 72 return it.current(); | |
| 73 } | |
| 53 | 74 |
| 54 static inline bool isBreakableSpace(UChar ch) | 75 static inline bool isBreakableSpace(UChar ch) |
| 55 { | 76 { |
| 56 switch (ch) { | 77 switch (ch) { |
| 57 case ' ': | 78 case ' ': |
| 58 case '\n': | 79 case '\n': |
| 59 case '\t': | 80 case '\t': |
| 60 return true; | 81 return true; |
| 61 default: | 82 default: |
| 62 return false; | 83 return false; |
| (...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 287 } | 308 } |
| 288 | 309 |
| 289 int LazyLineBreakIterator::nextBreakablePositionKeepAll(int pos) | 310 int LazyLineBreakIterator::nextBreakablePositionKeepAll(int pos) |
| 290 { | 311 { |
| 291 if (m_string.is8Bit()) | 312 if (m_string.is8Bit()) |
| 292 return nextBreakablePosition<LChar>(*this, m_string.characters8(), m_str ing.length(), pos); | 313 return nextBreakablePosition<LChar>(*this, m_string.characters8(), m_str ing.length(), pos); |
| 293 return nextBreakablePositionKeepAllInternal(*this, m_string.characters16(), m_string.length(), pos); | 314 return nextBreakablePositionKeepAllInternal(*this, m_string.characters16(), m_string.length(), pos); |
| 294 } | 315 } |
| 295 | 316 |
| 296 } // namespace blink | 317 } // namespace blink |
| OLD | NEW |