| 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 14 matching lines...) Expand all Loading... |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef SKY_ENGINE_PUBLIC_PLATFORM_WEBSTRING_H_ | 31 #ifndef SKY_ENGINE_PUBLIC_PLATFORM_WEBSTRING_H_ |
| 32 #define SKY_ENGINE_PUBLIC_PLATFORM_WEBSTRING_H_ | 32 #define SKY_ENGINE_PUBLIC_PLATFORM_WEBSTRING_H_ |
| 33 | 33 |
| 34 #include <string> | 34 #include <string> |
| 35 #include "sky/engine/public/platform/WebCommon.h" | |
| 36 #include "sky/engine/public/platform/WebPrivatePtr.h" | |
| 37 | 35 |
| 38 #if INSIDE_BLINK | |
| 39 #include "sky/engine/wtf/Forward.h" | |
| 40 #else | |
| 41 #include "base/strings/latin1_string_conversions.h" | 36 #include "base/strings/latin1_string_conversions.h" |
| 42 #include "base/strings/nullable_string16.h" | 37 #include "base/strings/nullable_string16.h" |
| 43 #include "base/strings/string16.h" | 38 #include "base/strings/string16.h" |
| 44 #endif | 39 #include "sky/engine/public/platform/WebCommon.h" |
| 40 #include "sky/engine/public/platform/WebPrivatePtr.h" |
| 41 #include "sky/engine/wtf/Forward.h" |
| 45 | 42 |
| 46 namespace WTF { | 43 namespace WTF { |
| 47 class StringImpl; | 44 class StringImpl; |
| 48 } | 45 } |
| 49 | 46 |
| 50 namespace blink { | 47 namespace blink { |
| 51 | 48 |
| 52 class WebCString; | 49 class WebCString; |
| 53 | 50 |
| 54 // A UTF-16 string container. It is inexpensive to copy a WebString | 51 // A UTF-16 string container. It is inexpensive to copy a WebString |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 { | 109 { |
| 113 assign(fromUTF8(data, N - 1)); | 110 assign(fromUTF8(data, N - 1)); |
| 114 } | 111 } |
| 115 | 112 |
| 116 template <int N> WebString& operator=(const char (&data)[N]) | 113 template <int N> WebString& operator=(const char (&data)[N]) |
| 117 { | 114 { |
| 118 assign(fromUTF8(data, N - 1)); | 115 assign(fromUTF8(data, N - 1)); |
| 119 return *this; | 116 return *this; |
| 120 } | 117 } |
| 121 | 118 |
| 122 #if INSIDE_BLINK | 119 |
| 123 BLINK_COMMON_EXPORT WebString(const WTF::String&); | 120 BLINK_COMMON_EXPORT WebString(const WTF::String&); |
| 124 BLINK_COMMON_EXPORT WebString& operator=(const WTF::String&); | 121 BLINK_COMMON_EXPORT WebString& operator=(const WTF::String&); |
| 125 BLINK_COMMON_EXPORT operator WTF::String() const; | 122 BLINK_COMMON_EXPORT operator WTF::String() const; |
| 126 | 123 |
| 127 BLINK_COMMON_EXPORT WebString(const WTF::AtomicString&); | 124 BLINK_COMMON_EXPORT WebString(const WTF::AtomicString&); |
| 128 BLINK_COMMON_EXPORT WebString& operator=(const WTF::AtomicString&); | 125 BLINK_COMMON_EXPORT WebString& operator=(const WTF::AtomicString&); |
| 129 BLINK_COMMON_EXPORT operator WTF::AtomicString() const; | 126 BLINK_COMMON_EXPORT operator WTF::AtomicString() const; |
| 130 #else | 127 |
| 131 WebString(const base::string16& s) | 128 WebString(const base::string16& s) |
| 132 { | 129 { |
| 133 assign(s.data(), s.length()); | 130 assign(s.data(), s.length()); |
| 134 } | 131 } |
| 135 | 132 |
| 136 WebString& operator=(const base::string16& s) | 133 WebString& operator=(const base::string16& s) |
| 137 { | 134 { |
| 138 assign(s.data(), s.length()); | 135 assign(s.data(), s.length()); |
| 139 return *this; | 136 return *this; |
| 140 } | 137 } |
| (...skipping 17 matching lines...) Expand all Loading... |
| 158 reset(); | 155 reset(); |
| 159 else | 156 else |
| 160 assign(s.string().data(), s.string().length()); | 157 assign(s.string().data(), s.string().length()); |
| 161 return *this; | 158 return *this; |
| 162 } | 159 } |
| 163 | 160 |
| 164 operator base::NullableString16() const | 161 operator base::NullableString16() const |
| 165 { | 162 { |
| 166 return base::NullableString16(operator base::string16(), m_private.isNul
l()); | 163 return base::NullableString16(operator base::string16(), m_private.isNul
l()); |
| 167 } | 164 } |
| 168 #endif | |
| 169 | 165 |
| 170 private: | 166 private: |
| 171 BLINK_COMMON_EXPORT bool is8Bit() const; | 167 BLINK_COMMON_EXPORT bool is8Bit() const; |
| 172 BLINK_COMMON_EXPORT const WebLChar* data8() const; | 168 BLINK_COMMON_EXPORT const WebLChar* data8() const; |
| 173 BLINK_COMMON_EXPORT const WebUChar* data16() const; | 169 BLINK_COMMON_EXPORT const WebUChar* data16() const; |
| 174 | 170 |
| 175 BLINK_COMMON_EXPORT void assign(WTF::StringImpl*); | 171 BLINK_COMMON_EXPORT void assign(WTF::StringImpl*); |
| 176 | 172 |
| 177 WebPrivatePtr<WTF::StringImpl> m_private; | 173 WebPrivatePtr<WTF::StringImpl> m_private; |
| 178 }; | 174 }; |
| 179 | 175 |
| 180 inline bool operator==(const WebString& a, const WebString& b) | 176 inline bool operator==(const WebString& a, const WebString& b) |
| 181 { | 177 { |
| 182 return a.equals(b); | 178 return a.equals(b); |
| 183 } | 179 } |
| 184 | 180 |
| 185 inline bool operator!=(const WebString& a, const WebString& b) | 181 inline bool operator!=(const WebString& a, const WebString& b) |
| 186 { | 182 { |
| 187 return !(a == b); | 183 return !(a == b); |
| 188 } | 184 } |
| 189 | 185 |
| 190 } // namespace blink | 186 } // namespace blink |
| 191 | 187 |
| 192 #endif // SKY_ENGINE_PUBLIC_PLATFORM_WEBSTRING_H_ | 188 #endif // SKY_ENGINE_PUBLIC_PLATFORM_WEBSTRING_H_ |
| OLD | NEW |