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

Side by Side Diff: third_party/WebKit/Source/wtf/text/WTFString.h

Issue 2232083002: Fix incorrect usage of StringImpl::sizeInBytes. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: size_teeee Created 4 years, 4 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
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved. 3 * Copyright (C) 2004, 2005, 2006, 2007, 2008, 2009, 2010, 2012, 2013 Apple Inc. All rights reserved.
4 * 4 *
5 * This library is free software; you can redistribute it and/or 5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Library General Public 6 * modify it under the terms of the GNU Library General Public
7 * License as published by the Free Software Foundation; either 7 * License as published by the Free Software Foundation; either
8 * version 2 of the License, or (at your option) any later version. 8 * version 2 of the License, or (at your option) any later version.
9 * 9 *
10 * This library is distributed in the hope that it will be useful, 10 * This library is distributed in the hope that it will be useful,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 ASSERT(!m_impl->is8Bit()); 131 ASSERT(!m_impl->is8Bit());
132 return m_impl->characters16(); 132 return m_impl->characters16();
133 } 133 }
134 134
135 // Return characters8() or characters16() depending on CharacterType. 135 // Return characters8() or characters16() depending on CharacterType.
136 template <typename CharacterType> 136 template <typename CharacterType>
137 inline const CharacterType* getCharacters() const; 137 inline const CharacterType* getCharacters() const;
138 138
139 bool is8Bit() const { return m_impl->is8Bit(); } 139 bool is8Bit() const { return m_impl->is8Bit(); }
140 140
141 unsigned sizeInBytes() const
142 {
143 if (!m_impl)
144 return 0;
145 return m_impl->length() * (is8Bit() ? sizeof(LChar) : sizeof(UChar));
146 }
147
148 CString ascii() const; 141 CString ascii() const;
149 CString latin1() const; 142 CString latin1() const;
150 CString utf8(UTF8ConversionMode = LenientUTF8Conversion) const; 143 CString utf8(UTF8ConversionMode = LenientUTF8Conversion) const;
151 144
152 UChar operator[](unsigned index) const 145 UChar operator[](unsigned index) const
153 { 146 {
154 if (!m_impl || index >= m_impl->length()) 147 if (!m_impl || index >= m_impl->length())
155 return 0; 148 return 0;
156 return (*m_impl)[index]; 149 return (*m_impl)[index];
157 } 150 }
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 362
370 // Tries to convert the passed in string to UTF-8, but will fall back to 363 // Tries to convert the passed in string to UTF-8, but will fall back to
371 // Latin-1 if the string is not valid UTF-8. 364 // Latin-1 if the string is not valid UTF-8.
372 static String fromUTF8WithLatin1Fallback(const LChar*, size_t); 365 static String fromUTF8WithLatin1Fallback(const LChar*, size_t);
373 static String fromUTF8WithLatin1Fallback(const char* s, size_t length) { ret urn fromUTF8WithLatin1Fallback(reinterpret_cast<const LChar*>(s), length); } 366 static String fromUTF8WithLatin1Fallback(const char* s, size_t length) { ret urn fromUTF8WithLatin1Fallback(reinterpret_cast<const LChar*>(s), length); }
374 367
375 bool containsOnlyASCII() const; 368 bool containsOnlyASCII() const;
376 bool containsOnlyLatin1() const; 369 bool containsOnlyLatin1() const;
377 bool containsOnlyWhitespace() const { return !m_impl || m_impl->containsOnly Whitespace(); } 370 bool containsOnlyWhitespace() const { return !m_impl || m_impl->containsOnly Whitespace(); }
378 371
372 size_t charactersSizeInBytes() const { return m_impl ? m_impl->charactersSiz eInBytes() : 0; }
373
379 // Hash table deleted values, which are only constructed and never copied or 374 // Hash table deleted values, which are only constructed and never copied or
380 // destroyed. 375 // destroyed.
381 String(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue) { } 376 String(WTF::HashTableDeletedValueType) : m_impl(WTF::HashTableDeletedValue) { }
382 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue (); } 377 bool isHashTableDeletedValue() const { return m_impl.isHashTableDeletedValue (); }
383 378
384 #ifndef NDEBUG 379 #ifndef NDEBUG
385 void show() const; 380 void show() const;
386 #endif 381 #endif
387 382
388 private: 383 private:
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
597 using WTF::emptyString16Bit; 592 using WTF::emptyString16Bit;
598 using WTF::append; 593 using WTF::append;
599 using WTF::charactersAreAllASCII; 594 using WTF::charactersAreAllASCII;
600 using WTF::equal; 595 using WTF::equal;
601 using WTF::find; 596 using WTF::find;
602 using WTF::isAllSpecialCharacters; 597 using WTF::isAllSpecialCharacters;
603 using WTF::isSpaceOrNewline; 598 using WTF::isSpaceOrNewline;
604 599
605 #include "wtf/text/AtomicString.h" 600 #include "wtf/text/AtomicString.h"
606 #endif // WTFString_h 601 #endif // WTFString_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/wtf/text/StringImpl.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698