OLD | NEW |
---|---|
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 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 } | 130 } |
131 | 131 |
132 WebString& operator=(const base::string16& s) | 132 WebString& operator=(const base::string16& s) |
133 { | 133 { |
134 assign(s.data(), s.length()); | 134 assign(s.data(), s.length()); |
135 return *this; | 135 return *this; |
136 } | 136 } |
137 | 137 |
138 operator base::string16() const | 138 operator base::string16() const |
139 { | 139 { |
140 return base::Latin1OrUTF16ToUTF16(length(), data8(), data16()); | 140 return base::Latin1OrUTF16ToUTF16(length(), data8OrNull(), data16OrNull( )); |
141 } | 141 } |
142 | 142 |
143 WebString(const base::NullableString16& s) | 143 WebString(const base::NullableString16& s) |
144 { | 144 { |
145 if (s.is_null()) | 145 if (s.is_null()) |
146 reset(); | 146 reset(); |
147 else | 147 else |
148 assign(s.string().data(), s.string().length()); | 148 assign(s.string().data(), s.string().length()); |
149 } | 149 } |
150 | 150 |
151 WebString& operator=(const base::NullableString16& s) | 151 WebString& operator=(const base::NullableString16& s) |
152 { | 152 { |
153 if (s.is_null()) | 153 if (s.is_null()) |
154 reset(); | 154 reset(); |
155 else | 155 else |
156 assign(s.string().data(), s.string().length()); | 156 assign(s.string().data(), s.string().length()); |
157 return *this; | 157 return *this; |
158 } | 158 } |
159 | 159 |
160 operator base::NullableString16() const | 160 operator base::NullableString16() const |
161 { | 161 { |
162 return base::NullableString16(operator base::string16(), m_private.isNul l()); | 162 return base::NullableString16(operator base::string16(), m_private.isNul l()); |
163 } | 163 } |
164 #endif | 164 #endif |
165 | 165 |
166 BLINK_COMMON_EXPORT bool is8Bit() const; | |
167 | |
168 // Returns the 8- or 16-bit underlying string buffer. If the buffer is not | |
169 // the corresponding type, null will be returned. | |
170 BLINK_COMMON_EXPORT const WebLChar* data8OrNull() const; | |
esprehn
2016/01/07 23:56:23
Yeah I don't want to expose this. All this patch
| |
171 BLINK_COMMON_EXPORT const WebUChar* data16OrNull() const; | |
172 | |
166 private: | 173 private: |
167 BLINK_COMMON_EXPORT bool is8Bit() const; | |
168 BLINK_COMMON_EXPORT const WebLChar* data8() const; | |
169 BLINK_COMMON_EXPORT const WebUChar* data16() const; | |
170 | |
171 BLINK_COMMON_EXPORT void assign(WTF::StringImpl*); | 174 BLINK_COMMON_EXPORT void assign(WTF::StringImpl*); |
172 | 175 |
173 WebPrivatePtr<WTF::StringImpl> m_private; | 176 WebPrivatePtr<WTF::StringImpl> m_private; |
174 }; | 177 }; |
175 | 178 |
176 inline bool operator==(const WebString& a, const char* b) | 179 inline bool operator==(const WebString& a, const char* b) |
177 { | 180 { |
178 return a.equals(b); | 181 return a.equals(b); |
179 } | 182 } |
180 | 183 |
(...skipping 18 matching lines...) Expand all Loading... | |
199 } | 202 } |
200 | 203 |
201 inline bool operator!=(const WebString& a, const WebString& b) | 204 inline bool operator!=(const WebString& a, const WebString& b) |
202 { | 205 { |
203 return !(a == b); | 206 return !(a == b); |
204 } | 207 } |
205 | 208 |
206 } // namespace blink | 209 } // namespace blink |
207 | 210 |
208 #endif | 211 #endif |
OLD | NEW |