| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 Google Inc. All rights reserved. |
| 3 * Copyright (C) 2012 Motorola Mobility Inc. | 3 * Copyright (C) 2012 Motorola Mobility Inc. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions | 6 * modification, are permitted provided that the following conditions |
| 7 * are met: | 7 * are met: |
| 8 * | 8 * |
| 9 * 1. Redistributions of source code must retain the above copyright | 9 * 1. Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 25 */ | 25 */ |
| 26 | 26 |
| 27 #include "config.h" | 27 #include "config.h" |
| 28 #include "core/dom/DOMURLUtils.h" | 28 #include "core/dom/DOMURLUtils.h" |
| 29 | 29 |
| 30 #include "platform/weborigin/KnownPorts.h" | 30 #include "platform/weborigin/KnownPorts.h" |
| 31 | 31 |
| 32 namespace WebCore { | 32 namespace WebCore { |
| 33 | 33 |
| 34 void DOMURLUtils::setHref(DOMURLUtils* impl, const String& value) | 34 void DOMURLUtils::setHref(DOMURLUtils& impl, const String& value) |
| 35 { | 35 { |
| 36 impl->setInput(value); | 36 impl.setInput(value); |
| 37 } | 37 } |
| 38 | 38 |
| 39 void DOMURLUtils::setProtocol(DOMURLUtils* impl, const String& value) | 39 void DOMURLUtils::setProtocol(DOMURLUtils& impl, const String& value) |
| 40 { | 40 { |
| 41 KURL url = impl->url(); | 41 KURL url = impl.url(); |
| 42 if (url.isNull()) | 42 if (url.isNull()) |
| 43 return; | 43 return; |
| 44 url.setProtocol(value); | 44 url.setProtocol(value); |
| 45 impl->setURL(url); | 45 impl.setURL(url); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void DOMURLUtils::setUsername(DOMURLUtils* impl, const String& value) | 48 void DOMURLUtils::setUsername(DOMURLUtils& impl, const String& value) |
| 49 { | 49 { |
| 50 KURL url = impl->url(); | 50 KURL url = impl.url(); |
| 51 if (url.isNull()) | 51 if (url.isNull()) |
| 52 return; | 52 return; |
| 53 url.setUser(value); | 53 url.setUser(value); |
| 54 impl->setURL(url); | 54 impl.setURL(url); |
| 55 } | 55 } |
| 56 | 56 |
| 57 void DOMURLUtils::setPassword(DOMURLUtils* impl, const String& value) | 57 void DOMURLUtils::setPassword(DOMURLUtils& impl, const String& value) |
| 58 { | 58 { |
| 59 KURL url = impl->url(); | 59 KURL url = impl.url(); |
| 60 if (url.isNull()) | 60 if (url.isNull()) |
| 61 return; | 61 return; |
| 62 url.setPass(value); | 62 url.setPass(value); |
| 63 impl->setURL(url); | 63 impl.setURL(url); |
| 64 } | 64 } |
| 65 | 65 |
| 66 void DOMURLUtils::setHost(DOMURLUtils* impl, const String& value) | 66 void DOMURLUtils::setHost(DOMURLUtils& impl, const String& value) |
| 67 { | 67 { |
| 68 if (value.isEmpty()) | 68 if (value.isEmpty()) |
| 69 return; | 69 return; |
| 70 | 70 |
| 71 KURL url = impl->url(); | 71 KURL url = impl.url(); |
| 72 if (!url.canSetHostOrPort()) | 72 if (!url.canSetHostOrPort()) |
| 73 return; | 73 return; |
| 74 | 74 |
| 75 url.setHostAndPort(value); | 75 url.setHostAndPort(value); |
| 76 impl->setURL(url); | 76 impl.setURL(url); |
| 77 } | 77 } |
| 78 | 78 |
| 79 void DOMURLUtils::setHostname(DOMURLUtils* impl, const String& value) | 79 void DOMURLUtils::setHostname(DOMURLUtils& impl, const String& value) |
| 80 { | 80 { |
| 81 KURL url = impl->url(); | 81 KURL url = impl.url(); |
| 82 if (!url.canSetHostOrPort()) | 82 if (!url.canSetHostOrPort()) |
| 83 return; | 83 return; |
| 84 | 84 |
| 85 // Before setting new value: | 85 // Before setting new value: |
| 86 // Remove all leading U+002F SOLIDUS ("/") characters. | 86 // Remove all leading U+002F SOLIDUS ("/") characters. |
| 87 unsigned i = 0; | 87 unsigned i = 0; |
| 88 unsigned hostLength = value.length(); | 88 unsigned hostLength = value.length(); |
| 89 while (value[i] == '/') | 89 while (value[i] == '/') |
| 90 i++; | 90 i++; |
| 91 | 91 |
| 92 if (i == hostLength) | 92 if (i == hostLength) |
| 93 return; | 93 return; |
| 94 | 94 |
| 95 url.setHost(value.substring(i)); | 95 url.setHost(value.substring(i)); |
| 96 | 96 |
| 97 impl->setURL(url); | 97 impl.setURL(url); |
| 98 } | 98 } |
| 99 | 99 |
| 100 void DOMURLUtils::setPort(DOMURLUtils* impl, const String& value) | 100 void DOMURLUtils::setPort(DOMURLUtils& impl, const String& value) |
| 101 { | 101 { |
| 102 KURL url = impl->url(); | 102 KURL url = impl.url(); |
| 103 if (!url.canSetHostOrPort()) | 103 if (!url.canSetHostOrPort()) |
| 104 return; | 104 return; |
| 105 | 105 |
| 106 url.setPort(value); | 106 url.setPort(value); |
| 107 impl->setURL(url); | 107 impl.setURL(url); |
| 108 } | 108 } |
| 109 | 109 |
| 110 void DOMURLUtils::setPathname(DOMURLUtils* impl, const String& value) | 110 void DOMURLUtils::setPathname(DOMURLUtils& impl, const String& value) |
| 111 { | 111 { |
| 112 KURL url = impl->url(); | 112 KURL url = impl.url(); |
| 113 if (!url.canSetPathname()) | 113 if (!url.canSetPathname()) |
| 114 return; | 114 return; |
| 115 url.setPath(value); | 115 url.setPath(value); |
| 116 impl->setURL(url); | 116 impl.setURL(url); |
| 117 } | 117 } |
| 118 | 118 |
| 119 void DOMURLUtils::setSearch(DOMURLUtils* impl, const String& value) | 119 void DOMURLUtils::setSearch(DOMURLUtils& impl, const String& value) |
| 120 { | 120 { |
| 121 KURL url = impl->url(); | 121 KURL url = impl.url(); |
| 122 if (!url.isValid()) | 122 if (!url.isValid()) |
| 123 return; | 123 return; |
| 124 url.setQuery(value); | 124 url.setQuery(value); |
| 125 impl->setURL(url); | 125 impl.setURL(url); |
| 126 } | 126 } |
| 127 | 127 |
| 128 void DOMURLUtils::setHash(DOMURLUtils* impl, const String& value) | 128 void DOMURLUtils::setHash(DOMURLUtils& impl, const String& value) |
| 129 { | 129 { |
| 130 KURL url = impl->url(); | 130 KURL url = impl.url(); |
| 131 if (url.isNull()) | 131 if (url.isNull()) |
| 132 return; | 132 return; |
| 133 | 133 |
| 134 if (value[0] == '#') | 134 if (value[0] == '#') |
| 135 url.setFragmentIdentifier(value.substring(1)); | 135 url.setFragmentIdentifier(value.substring(1)); |
| 136 else | 136 else |
| 137 url.setFragmentIdentifier(value); | 137 url.setFragmentIdentifier(value); |
| 138 | 138 |
| 139 impl->setURL(url); | 139 impl.setURL(url); |
| 140 } | 140 } |
| 141 | 141 |
| 142 } // namespace WebCore | 142 } // namespace WebCore |
| OLD | NEW |