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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 WTF::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 WTF::String::fromUTF8(data); |
97 } | 97 } |
98 | 98 |
99 std::string WebString::latin1() const | |
100 { | |
101 String string(m_private.get()); | |
102 | |
103 if (string.is8Bit()) | |
abarth-chromium
2013/09/03 15:46:40
You need to handle the isEmpty() case as well. Yo
davidben
2013/09/03 17:58:25
Done.
| |
104 return std::string(reinterpret_cast<const char*>(string.characters8()), string.length()); | |
105 | |
106 WebCString latin1 = string.latin1(); | |
107 return std::string(latin1.data(), latin1.length()); | |
108 } | |
109 | |
110 WebString WebString::fromLatin1(const char* data, size_t length) | |
111 { | |
112 return String(data, length); | |
113 } | |
114 | |
99 bool WebString::equals(const WebString& s) const | 115 bool WebString::equals(const WebString& s) const |
100 { | 116 { |
101 return equal(m_private.get(), s.m_private.get()); | 117 return equal(m_private.get(), s.m_private.get()); |
102 } | 118 } |
103 | 119 |
104 WebString::WebString(const WTF::String& s) | 120 WebString::WebString(const WTF::String& s) |
105 { | 121 { |
106 m_private = s.impl(); | 122 m_private = s.impl(); |
107 } | 123 } |
108 | 124 |
(...skipping 23 matching lines...) Expand all Loading... | |
132 { | 148 { |
133 return WTF::AtomicString(m_private.get()); | 149 return WTF::AtomicString(m_private.get()); |
134 } | 150 } |
135 | 151 |
136 void WebString::assign(WTF::StringImpl* p) | 152 void WebString::assign(WTF::StringImpl* p) |
137 { | 153 { |
138 m_private = p; | 154 m_private = p; |
139 } | 155 } |
140 | 156 |
141 } // namespace WebKit | 157 } // namespace WebKit |
OLD | NEW |