| OLD | NEW |
| 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "webkit/glue/glue_util.h" | 8 #include "webkit/glue/glue_util.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/gfx/rect.h" | 10 #include "base/gfx/rect.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 72 | 72 |
| 73 // URL conversions ------------------------------------------------------------- | 73 // URL conversions ------------------------------------------------------------- |
| 74 | 74 |
| 75 GURL KURLToGURL(const WebCore::KURL& url) { | 75 GURL KURLToGURL(const WebCore::KURL& url) { |
| 76 #ifdef USE_GOOGLE_URL_LIBRARY | 76 #ifdef USE_GOOGLE_URL_LIBRARY |
| 77 const WebCore::CString& spec = url.utf8String(); | 77 const WebCore::CString& spec = url.utf8String(); |
| 78 if (spec.isNull() || 0 == spec.length()) | 78 if (spec.isNull() || 0 == spec.length()) |
| 79 return GURL(); | 79 return GURL(); |
| 80 return GURL(spec.data(), spec.length(), url.parsed(), url.isValid()); | 80 return GURL(spec.data(), spec.length(), url.parsed(), url.isValid()); |
| 81 #else | 81 #else |
| 82 const WebCore::String& spec = url.string(); | 82 return StringToGURL(url.string()); |
| 83 return GURL(WideToUTF8(StringToStdWString(spec))); | |
| 84 #endif | 83 #endif |
| 85 } | 84 } |
| 86 | 85 |
| 87 WebCore::KURL GURLToKURL(const GURL& url) { | 86 WebCore::KURL GURLToKURL(const GURL& url) { |
| 88 const std::string& spec = url.possibly_invalid_spec(); | 87 const std::string& spec = url.possibly_invalid_spec(); |
| 89 #ifdef USE_GOOGLE_URL_LIBRARY | 88 #ifdef USE_GOOGLE_URL_LIBRARY |
| 90 // Convert using the internal structures to avoid re-parsing. | 89 // Convert using the internal structures to avoid re-parsing. |
| 91 return WebCore::KURL(spec.c_str(), static_cast<int>(spec.length()), | 90 return WebCore::KURL(spec.c_str(), static_cast<int>(spec.length()), |
| 92 url.parsed_for_possibly_invalid_spec(), url.is_valid()); | 91 url.parsed_for_possibly_invalid_spec(), url.is_valid()); |
| 93 #else | 92 #else |
| 94 return WebCore::KURL(StdWStringToString(UTF8ToWide(spec))); | 93 return WebCore::KURL(StdWStringToString(UTF8ToWide(spec))); |
| 95 #endif | 94 #endif |
| 96 } | 95 } |
| 97 | 96 |
| 97 GURL StringToGURL(const WebCore::String& spec) { |
| 98 return GURL(WideToUTF8(StringToStdWString(spec))); |
| 99 } |
| 100 |
| 98 // Rect conversions ------------------------------------------------------------ | 101 // Rect conversions ------------------------------------------------------------ |
| 99 | 102 |
| 100 gfx::Rect FromIntRect(const WebCore::IntRect& r) { | 103 gfx::Rect FromIntRect(const WebCore::IntRect& r) { |
| 101 return gfx::Rect(r.x(), r.y(), r.width(), r.height()); | 104 return gfx::Rect(r.x(), r.y(), r.width(), r.height()); |
| 102 } | 105 } |
| 103 | 106 |
| 104 WebCore::IntRect ToIntRect(const gfx::Rect& r) { | 107 WebCore::IntRect ToIntRect(const gfx::Rect& r) { |
| 105 return WebCore::IntRect(r.x(), r.y(), r.width(), r.height()); | 108 return WebCore::IntRect(r.x(), r.y(), r.width(), r.height()); |
| 106 } | 109 } |
| 107 | 110 |
| 108 } // namespace webkit_glue | 111 } // namespace webkit_glue |
| 109 | 112 |
| OLD | NEW |