| OLD | NEW |
| 1 // Copyright (c) 2008, Google Inc. | 1 // Copyright (c) 2008, Google Inc. |
| 2 // All rights reserved. | 2 // 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 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 } // namespace | 100 } // namespace |
| 101 | 101 |
| 102 // KURL::URLString ------------------------------------------------------------- | 102 // KURL::URLString ------------------------------------------------------------- |
| 103 | 103 |
| 104 KURL::URLString::URLString() | 104 KURL::URLString::URLString() |
| 105 : m_utf8IsASCII(true) | 105 : m_utf8IsASCII(true) |
| 106 , m_stringIsValid(false) | 106 , m_stringIsValid(false) |
| 107 { | 107 { |
| 108 } | 108 } |
| 109 | 109 |
| 110 void KURL::URLString::copyTo(URLString* dest) const |
| 111 { |
| 112 // Don't copy the 16-bit string since that will be regenerated as needed. |
| 113 dest->m_utf8 = CString(m_utf8.data(), m_utf8.length()); |
| 114 dest->m_stringIsValid = false; |
| 115 dest->m_utf8IsASCII = m_utf8IsASCII; |
| 116 } |
| 117 |
| 110 // Setters for the data. Using the ASCII version when you know the | 118 // Setters for the data. Using the ASCII version when you know the |
| 111 // data is ASCII will be slightly more efficient. The UTF-8 version | 119 // data is ASCII will be slightly more efficient. The UTF-8 version |
| 112 // will always be correct if the caller is unsure. | 120 // will always be correct if the caller is unsure. |
| 113 void KURL::URLString::setUtf8(const char* data, int data_len) | 121 void KURL::URLString::setUtf8(const char* data, int data_len) |
| 114 { | 122 { |
| 115 // The m_utf8IsASCII must always be correct since the DeprecatedString | 123 // The m_utf8IsASCII must always be correct since the DeprecatedString |
| 116 // getter must create it with the proper constructor. This test can be | 124 // getter must create it with the proper constructor. This test can be |
| 117 // removed when DeprecatedString is gone, but it still might be a | 125 // removed when DeprecatedString is gone, but it still might be a |
| 118 // performance win. | 126 // performance win. |
| 119 m_utf8IsASCII = true; | 127 m_utf8IsASCII = true; |
| (...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 m_url.setUtf8(output.data(), output.length()); | 328 m_url.setUtf8(output.data(), output.length()); |
| 321 else | 329 else |
| 322 m_url.setAscii(output.data(), output.length()); | 330 m_url.setAscii(output.data(), output.length()); |
| 323 } else { | 331 } else { |
| 324 m_url.setUtf8("", 0); | 332 m_url.setUtf8("", 0); |
| 325 } | 333 } |
| 326 } | 334 } |
| 327 | 335 |
| 328 KURL KURL::copy() const | 336 KURL KURL::copy() const |
| 329 { | 337 { |
| 330 KURL result = *this; | 338 KURL result; |
| 331 // TODO(brettw): http://crbug.com/4975 Make this a deep copy. | 339 m_url.copyTo(&result.m_url); |
| 332 // result.m_string = result.m_string.copy(); | 340 result.m_isValid = m_isValid; |
| 341 result.m_parsed = m_parsed; |
| 333 return result; | 342 return result; |
| 334 } | 343 } |
| 335 | 344 |
| 336 bool KURL::hasPath() const | 345 bool KURL::hasPath() const |
| 337 { | 346 { |
| 338 // Note that http://www.google.com/" has a path, the path is "/". This can | 347 // Note that http://www.google.com/" has a path, the path is "/". This can |
| 339 // return false only for invalid or nonstandard URLs. | 348 // return false only for invalid or nonstandard URLs. |
| 340 return m_parsed.path.len >= 0; | 349 return m_parsed.path.len >= 0; |
| 341 } | 350 } |
| 342 | 351 |
| (...skipping 546 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 #ifndef KURL_DECORATE_GLOBALS | 898 #ifndef KURL_DECORATE_GLOBALS |
| 890 inline bool KURL::protocolIs(const String& string, const char* protocol) | 899 inline bool KURL::protocolIs(const String& string, const char* protocol) |
| 891 { | 900 { |
| 892 return WebCore::protocolIs(string, protocol); | 901 return WebCore::protocolIs(string, protocol); |
| 893 } | 902 } |
| 894 #endif | 903 #endif |
| 895 | 904 |
| 896 } // namespace WebCore | 905 } // namespace WebCore |
| 897 | 906 |
| 898 #endif // USE_GOOGLE_URL_LIBRARY | 907 #endif // USE_GOOGLE_URL_LIBRARY |
| OLD | NEW |