Chromium Code Reviews| Index: public/platform/WebString.h |
| diff --git a/public/platform/WebString.h b/public/platform/WebString.h |
| index c336dd113dcd61aefae52a9808b6c57275f3b9df..d85c10b5be16b0921510ea2d84b6ed467b6c8b80 100644 |
| --- a/public/platform/WebString.h |
| +++ b/public/platform/WebString.h |
| @@ -76,6 +76,7 @@ public: |
| WEBKIT_EXPORT bool equals(const WebString& s) const; |
| WEBKIT_EXPORT size_t length() const; |
| + // Deprecated: This function will be removed once all its callers are gone. |
| WEBKIT_EXPORT const WebUChar* data() const; |
| bool isEmpty() const { return !length(); } |
| @@ -122,7 +123,14 @@ public: |
| operator string16() const |
| { |
| size_t len = length(); |
|
darin (slow to review)
2013/05/24 06:12:53
nit: this seems like a lot of code to inline into
|
| - return len ? string16(data(), len) : string16(); |
| + if (!len) |
| + return string16(); |
| + if (is8Bit()) { |
| + const WebLChar* data = this->data8(); |
| + return string16(data, data + len); |
| + } |
| + const WebUChar* data = this->data16(); |
| + return string16(data, data + len); |
| } |
| WebString(const NullableString16& s) : m_private(0) |
| @@ -146,8 +154,7 @@ public: |
| { |
| if (!m_private) |
| return NullableString16(string16(), true); |
| - size_t len = length(); |
| - return NullableString16(len ? string16(data(), len) : string16(), false); |
| + return NullableString16(operator string16(), false); |
|
darin (slow to review)
2013/05/24 06:12:53
nit: You could reduce this code down to just:
r
abarth-chromium
2013/05/24 06:17:44
Good idea.
|
| } |
| template <class UTF8String> |
| @@ -158,6 +165,10 @@ public: |
| #endif |
| private: |
| + WEBKIT_EXPORT bool is8Bit() const; |
| + WEBKIT_EXPORT const WebLChar* data8() const; |
| + WEBKIT_EXPORT const WebUChar* data16() const; |
| + |
| void assign(WebStringPrivate*); |
| WebStringPrivate* m_private; |
| }; |