OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) | 4 * (C) 2001 Dirk Mueller ( mueller@kde.org ) |
5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r
ights reserved. | 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All r
ights reserved. |
6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) | 6 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) |
7 * | 7 * |
8 * This library is free software; you can redistribute it and/or | 8 * This library is free software; you can redistribute it and/or |
9 * modify it under the terms of the GNU Library General Public | 9 * modify it under the terms of the GNU Library General Public |
10 * License as published by the Free Software Foundation; either | 10 * License as published by the Free Software Foundation; either |
(...skipping 955 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
966 return data.release(); | 966 return data.release(); |
967 } | 967 } |
968 | 968 |
969 PassRefPtr<StringImpl> StringImpl::removeCharacters(CharacterMatchFunctionPtr fi
ndMatch) | 969 PassRefPtr<StringImpl> StringImpl::removeCharacters(CharacterMatchFunctionPtr fi
ndMatch) |
970 { | 970 { |
971 if (is8Bit()) | 971 if (is8Bit()) |
972 return removeCharacters(characters8(), findMatch); | 972 return removeCharacters(characters8(), findMatch); |
973 return removeCharacters(characters16(), findMatch); | 973 return removeCharacters(characters16(), findMatch); |
974 } | 974 } |
975 | 975 |
| 976 PassRefPtr<StringImpl> StringImpl::remove(unsigned start, unsigned lengthToRemov
e) |
| 977 { |
| 978 if (lengthToRemove <= 0) |
| 979 return this; |
| 980 if (start >= m_length) |
| 981 return this; |
| 982 |
| 983 lengthToRemove = std::min(m_length - start, lengthToRemove); |
| 984 unsigned removedEnd = start + lengthToRemove; |
| 985 |
| 986 if (is8Bit()) { |
| 987 StringBuffer<LChar> buffer(m_length - lengthToRemove); |
| 988 copyChars(buffer.characters(), characters8(), start); |
| 989 copyChars(buffer.characters() + start, characters8() + removedEnd, m_len
gth - removedEnd); |
| 990 return buffer.release(); |
| 991 } |
| 992 StringBuffer<UChar> buffer(m_length - lengthToRemove); |
| 993 copyChars(buffer.characters(), characters16(), start); |
| 994 copyChars(buffer.characters() + start, characters16() + removedEnd, m_length
- removedEnd); |
| 995 return buffer.release(); |
| 996 } |
| 997 |
976 template <typename CharType, class UCharPredicate> | 998 template <typename CharType, class UCharPredicate> |
977 inline PassRefPtr<StringImpl> StringImpl::simplifyMatchedCharactersToSpace(UChar
Predicate predicate, StripBehavior stripBehavior) | 999 inline PassRefPtr<StringImpl> StringImpl::simplifyMatchedCharactersToSpace(UChar
Predicate predicate, StripBehavior stripBehavior) |
978 { | 1000 { |
979 StringBuffer<CharType> data(m_length); | 1001 StringBuffer<CharType> data(m_length); |
980 | 1002 |
981 const CharType* from = getCharacters<CharType>(); | 1003 const CharType* from = getCharacters<CharType>(); |
982 const CharType* fromend = from + m_length; | 1004 const CharType* fromend = from + m_length; |
983 int outc = 0; | 1005 int outc = 0; |
984 bool changedToSpace = false; | 1006 bool changedToSpace = false; |
985 | 1007 |
(...skipping 1018 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2004 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { | 2026 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { |
2005 // TODO(rob.buis) implement upper-casing rules for lt | 2027 // TODO(rob.buis) implement upper-casing rules for lt |
2006 // like in StringImpl::upper(locale). | 2028 // like in StringImpl::upper(locale). |
2007 } | 2029 } |
2008 } | 2030 } |
2009 | 2031 |
2010 return toUpper(c); | 2032 return toUpper(c); |
2011 } | 2033 } |
2012 | 2034 |
2013 } // namespace WTF | 2035 } // namespace WTF |
OLD | NEW |