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

Unified Diff: public/platform/WebString.h

Issue 15866003: Teach WebString about 8 bit strings (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Update to base Created 7 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « public/platform/WebCommon.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: public/platform/WebString.h
diff --git a/public/platform/WebString.h b/public/platform/WebString.h
index b8bc939db832b32cb9635e47f1f686331144002f..3552e4b30cc119c9912c18b8ca73ec6809a26afa 100644
--- a/public/platform/WebString.h
+++ b/public/platform/WebString.h
@@ -38,6 +38,7 @@
#else
#include <base/nullable_string16.h>
#include <base/string16.h>
+#include <base/strings/latin1_string_conversions.h>
#endif
namespace WebKit {
@@ -76,6 +77,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;
// Caller must check bounds.
@@ -124,8 +126,7 @@ public:
operator string16() const
{
- size_t len = length();
- return len ? string16(data(), len) : string16();
+ return base::Latin1OrUTF16ToUTF16(length(), data8(), data16());
}
WebString(const NullableString16& s) : m_private(0)
@@ -147,10 +148,7 @@ public:
operator NullableString16() const
{
- if (!m_private)
- return NullableString16(string16(), true);
- size_t len = length();
- return NullableString16(len ? string16(data(), len) : string16(), false);
+ return NullableString16(operator string16(), !m_private);
}
template <class UTF8String>
@@ -161,6 +159,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;
« no previous file with comments | « public/platform/WebCommon.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698