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

Side by Side Diff: Source/core/platform/chromium/support/WebString.cpp

Issue 23456013: Expose latin1 methods in WebString (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: rebase Created 7 years, 3 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 | « LayoutTests/TestExpectations ('k') | public/platform/WebString.h » ('j') | 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } 81 }
82 82
83 std::string WebString::utf8() const 83 std::string WebString::utf8() const
84 { 84 {
85 StringUTF8Adaptor utf8(m_private.get()); 85 StringUTF8Adaptor utf8(m_private.get());
86 return std::string(utf8.data(), utf8.length()); 86 return std::string(utf8.data(), utf8.length());
87 } 87 }
88 88
89 WebString WebString::fromUTF8(const char* data, size_t length) 89 WebString WebString::fromUTF8(const char* data, size_t length)
90 { 90 {
91 return WTF::String::fromUTF8(data, length); 91 return String::fromUTF8(data, length);
92 } 92 }
93 93
94 WebString WebString::fromUTF8(const char* data) 94 WebString WebString::fromUTF8(const char* data)
95 { 95 {
96 return WTF::String::fromUTF8(data); 96 return String::fromUTF8(data);
97 }
98
99 std::string WebString::latin1() const
100 {
101 String string(m_private.get());
102
103 if (string.isEmpty())
104 return std::string();
105
106 if (string.is8Bit())
107 return std::string(reinterpret_cast<const char*>(string.characters8()), string.length());
108
109 WebCString latin1 = string.latin1();
110 return std::string(latin1.data(), latin1.length());
111 }
112
113 WebString WebString::fromLatin1(const WebLChar* data, size_t length)
114 {
115 return String(data, length);
97 } 116 }
98 117
99 bool WebString::equals(const WebString& s) const 118 bool WebString::equals(const WebString& s) const
100 { 119 {
101 return equal(m_private.get(), s.m_private.get()); 120 return equal(m_private.get(), s.m_private.get());
102 } 121 }
103 122
104 WebString::WebString(const WTF::String& s) 123 WebString::WebString(const WTF::String& s)
105 { 124 {
106 m_private = s.impl(); 125 m_private = s.impl();
(...skipping 25 matching lines...) Expand all
132 { 151 {
133 return WTF::AtomicString(m_private.get()); 152 return WTF::AtomicString(m_private.get());
134 } 153 }
135 154
136 void WebString::assign(WTF::StringImpl* p) 155 void WebString::assign(WTF::StringImpl* p)
137 { 156 {
138 m_private = p; 157 m_private = p;
139 } 158 }
140 159
141 } // namespace WebKit 160 } // namespace WebKit
OLDNEW
« no previous file with comments | « LayoutTests/TestExpectations ('k') | public/platform/WebString.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698