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

Side by Side Diff: third_party/WebKit/public/platform/WebString.h

Issue 2655013004: Make WebString::equal take the length for const char* too (Closed)
Patch Set: null crash fix Created 3 years, 10 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/platform/exported/WebString.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 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 WebString& operator=(const WebString& s) { 105 WebString& operator=(const WebString& s) {
106 assign(s); 106 assign(s);
107 return *this; 107 return *this;
108 } 108 }
109 109
110 BLINK_COMMON_EXPORT void reset(); 110 BLINK_COMMON_EXPORT void reset();
111 BLINK_COMMON_EXPORT void assign(const WebString&); 111 BLINK_COMMON_EXPORT void assign(const WebString&);
112 BLINK_COMMON_EXPORT void assign(const WebUChar* data, size_t len); 112 BLINK_COMMON_EXPORT void assign(const WebUChar* data, size_t len);
113 113
114 BLINK_COMMON_EXPORT bool equals(const WebString&) const; 114 BLINK_COMMON_EXPORT bool equals(const WebString&) const;
115 BLINK_COMMON_EXPORT bool equals(const char* characters) const; 115 BLINK_COMMON_EXPORT bool equals(const char* characters, size_t len) const;
116 116
117 BLINK_COMMON_EXPORT size_t length() const; 117 BLINK_COMMON_EXPORT size_t length() const;
118 118
119 bool isEmpty() const { return !length(); } 119 bool isEmpty() const { return !length(); }
120 bool isNull() const { return m_private.isNull(); } 120 bool isNull() const { return m_private.isNull(); }
121 121
122 BLINK_COMMON_EXPORT std::string utf8( 122 BLINK_COMMON_EXPORT std::string utf8(
123 UTF8ConversionMode = UTF8ConversionMode::kLenient) const; 123 UTF8ConversionMode = UTF8ConversionMode::kLenient) const;
124 124
125 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data, 125 BLINK_COMMON_EXPORT static WebString fromUTF8(const char* data,
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 BLINK_COMMON_EXPORT bool is8Bit() const; 222 BLINK_COMMON_EXPORT bool is8Bit() const;
223 BLINK_COMMON_EXPORT const WebLChar* data8() const; 223 BLINK_COMMON_EXPORT const WebLChar* data8() const;
224 BLINK_COMMON_EXPORT const WebUChar* data16() const; 224 BLINK_COMMON_EXPORT const WebUChar* data16() const;
225 225
226 BLINK_COMMON_EXPORT void assign(WTF::StringImpl*); 226 BLINK_COMMON_EXPORT void assign(WTF::StringImpl*);
227 227
228 WebPrivatePtr<WTF::StringImpl> m_private; 228 WebPrivatePtr<WTF::StringImpl> m_private;
229 }; 229 };
230 230
231 inline bool operator==(const WebString& a, const char* b) { 231 inline bool operator==(const WebString& a, const char* b) {
232 return a.equals(b); 232 return a.equals(b, b ? strlen(b) : 0);
233 } 233 }
234 234
235 inline bool operator!=(const WebString& a, const char* b) { 235 inline bool operator!=(const WebString& a, const char* b) {
236 return !(a == b); 236 return !(a == b);
237 } 237 }
238 238
239 inline bool operator==(const char* a, const WebString& b) { 239 inline bool operator==(const char* a, const WebString& b) {
240 return b.equals(a); 240 return b == a;
241 } 241 }
242 242
243 inline bool operator!=(const char* a, const WebString& b) { 243 inline bool operator!=(const char* a, const WebString& b) {
244 return !(a == b); 244 return !(b == a);
245 } 245 }
246 246
247 inline bool operator==(const WebString& a, const WebString& b) { 247 inline bool operator==(const WebString& a, const WebString& b) {
248 return a.equals(b); 248 return a.equals(b);
249 } 249 }
250 250
251 inline bool operator!=(const WebString& a, const WebString& b) { 251 inline bool operator!=(const WebString& a, const WebString& b) {
252 return !(a == b); 252 return !(a == b);
253 } 253 }
254 254
255 } // namespace blink 255 } // namespace blink
256 256
257 #endif 257 #endif
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/platform/exported/WebString.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698