Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(44)

Side by Side Diff: third_party/WebKit/Source/wtf/text/StringImpl.cpp

Issue 2723053002: Use the correct case converter for |localName| and |tagName| (Closed)
Patch Set: Oops... Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 5 * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009, 2013 Apple Inc. All
6 * rights reserved. 6 * rights reserved.
7 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net) 7 * Copyright (C) 2006 Andrew Wellington (proton@wiretapped.net)
8 * 8 *
9 * This library is free software; you can redistribute it and/or 9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Library General Public 10 * modify it under the terms of the GNU Library General Public
(...skipping 785 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 Unicode::toUpper(data16, length, source16, m_length, &error); 796 Unicode::toUpper(data16, length, source16, m_length, &error);
797 if (!error && realLength == length) 797 if (!error && realLength == length)
798 return newImpl; 798 return newImpl;
799 newImpl = createUninitialized(realLength, data16); 799 newImpl = createUninitialized(realLength, data16);
800 Unicode::toUpper(data16, realLength, source16, m_length, &error); 800 Unicode::toUpper(data16, realLength, source16, m_length, &error);
801 if (error) 801 if (error)
802 return this; 802 return this;
803 return newImpl.release(); 803 return newImpl.release();
804 } 804 }
805 805
806 PassRefPtr<StringImpl> StringImpl::upperASCII() {
807 if (is8Bit()) {
808 LChar* data8;
809 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data8);
810
811 for (unsigned i = 0; i < m_length; ++i) {
812 LChar c = characters8()[i];
813 data8[i] = isASCIILower(c) ? toASCIIUpper(c) : c;
814 }
815 return newImpl.release();
816 }
817
818 UChar* data16;
819 RefPtr<StringImpl> newImpl = createUninitialized(m_length, data16);
820
821 for (unsigned i = 0; i < m_length; ++i) {
822 UChar c = characters16()[i];
823 data16[i] = isASCIILower(c) ? toASCIIUpper(c) : c;
824 }
825 return newImpl.release();
826 }
827
806 static inline bool localeIdMatchesLang(const AtomicString& localeId, 828 static inline bool localeIdMatchesLang(const AtomicString& localeId,
807 const StringView& lang) { 829 const StringView& lang) {
808 RELEASE_ASSERT(lang.length() >= 2 && lang.length() <= 3); 830 RELEASE_ASSERT(lang.length() >= 2 && lang.length() <= 3);
809 if (!localeId.impl() || !localeId.impl()->startsWithIgnoringCase(lang)) 831 if (!localeId.impl() || !localeId.impl()->startsWithIgnoringCase(lang))
810 return false; 832 return false;
811 if (localeId.impl()->length() == lang.length()) 833 if (localeId.impl()->length() == lang.length())
812 return true; 834 return true;
813 const UChar maybeDelimiter = (*localeId.impl())[lang.length()]; 835 const UChar maybeDelimiter = (*localeId.impl())[lang.length()];
814 return maybeDelimiter == '-' || maybeDelimiter == '_' || 836 return maybeDelimiter == '-' || maybeDelimiter == '_' ||
815 maybeDelimiter == '@'; 837 maybeDelimiter == '@';
(...skipping 1397 matching lines...) Expand 10 before | Expand all | Expand 10 after
2213 } else if (localeIdMatchesLang(localeIdentifier, "lt")) { 2235 } else if (localeIdMatchesLang(localeIdentifier, "lt")) {
2214 // TODO(rob.buis) implement upper-casing rules for lt 2236 // TODO(rob.buis) implement upper-casing rules for lt
2215 // like in StringImpl::upper(locale). 2237 // like in StringImpl::upper(locale).
2216 } 2238 }
2217 } 2239 }
2218 2240
2219 return toUpper(c); 2241 return toUpper(c);
2220 } 2242 }
2221 2243
2222 } // namespace WTF 2244 } // namespace WTF
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.h ('k') | third_party/WebKit/Source/wtf/text/StringImplTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698