| Index: third_party/WebKit/Source/platform/exported/WebString.cpp
|
| diff --git a/third_party/WebKit/Source/platform/exported/WebString.cpp b/third_party/WebKit/Source/platform/exported/WebString.cpp
|
| index 2ad8fa96244c93585fd797059fa56f6723b6a1a5..8e1c81c3d8a1f084d2e545c4ef50af47de77a96e 100644
|
| --- a/third_party/WebKit/Source/platform/exported/WebString.cpp
|
| +++ b/third_party/WebKit/Source/platform/exported/WebString.cpp
|
| @@ -30,6 +30,8 @@
|
|
|
| #include "public/platform/WebString.h"
|
|
|
| +#include "base/strings/string_util.h"
|
| +#include "wtf/text/ASCIIFastPath.h"
|
| #include "wtf/text/AtomicString.h"
|
| #include "wtf/text/CString.h"
|
| #include "wtf/text/StringUTF8Adaptor.h"
|
| @@ -97,6 +99,30 @@ WebString WebString::fromLatin1(const WebLChar* data, size_t length) {
|
| return String(data, length);
|
| }
|
|
|
| +std::string WebString::ascii() const {
|
| + DCHECK(containsOnlyASCII());
|
| +
|
| + if (isEmpty())
|
| + return std::string();
|
| +
|
| + if (m_private->is8Bit()) {
|
| + return std::string(reinterpret_cast<const char*>(m_private->characters8()),
|
| + m_private->length());
|
| + }
|
| +
|
| + return std::string(m_private->characters16(),
|
| + m_private->characters16() + m_private->length());
|
| +}
|
| +
|
| +bool WebString::containsOnlyASCII() const {
|
| + return String(m_private.get()).containsOnlyASCII();
|
| +}
|
| +
|
| +WebString WebString::fromASCII(const std::string& s) {
|
| + DCHECK(base::IsStringASCII(s));
|
| + return fromLatin1(s);
|
| +}
|
| +
|
| bool WebString::equals(const WebString& s) const {
|
| return equal(m_private.get(), s.m_private.get());
|
| }
|
|
|