Chromium Code Reviews| 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::update(DOMURLUtils* impl) | |
| 35 { | |
| 36 KURL url = impl->url(); | |
|
Inactive
2014/01/21 15:25:58
We should probably ASSERT to make sure impl is not
sof
2014/01/21 21:16:47
When the context makes it unmistakably clear that
| |
| 37 setSearchParams(impl, url.query()); | |
| 38 } | |
| 39 | |
| 34 void DOMURLUtils::setHref(DOMURLUtils* impl, const String& value) | 40 void DOMURLUtils::setHref(DOMURLUtils* impl, const String& value) |
| 35 { | 41 { |
| 36 impl->setInput(value); | 42 impl->setInput(value); |
| 37 } | 43 } |
| 38 | 44 |
| 39 void DOMURLUtils::setProtocol(DOMURLUtils* impl, const String& value) | 45 void DOMURLUtils::setProtocol(DOMURLUtils* impl, const String& value) |
| 40 { | 46 { |
| 41 KURL url = impl->url(); | 47 KURL url = impl->url(); |
| 42 if (url.isNull()) | 48 if (url.isNull()) |
| 43 return; | 49 return; |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 115 url.setPath(value); | 121 url.setPath(value); |
| 116 impl->setURL(url); | 122 impl->setURL(url); |
| 117 } | 123 } |
| 118 | 124 |
| 119 void DOMURLUtils::setSearch(DOMURLUtils* impl, const String& value) | 125 void DOMURLUtils::setSearch(DOMURLUtils* impl, const String& value) |
| 120 { | 126 { |
| 121 KURL url = impl->url(); | 127 KURL url = impl->url(); |
| 122 if (!url.isValid()) | 128 if (!url.isValid()) |
| 123 return; | 129 return; |
| 124 url.setQuery(value); | 130 url.setQuery(value); |
| 131 | |
| 132 if (!value.isEmpty() && value[0] == '?') | |
| 133 setSearchParams(impl, value.substring(1)); | |
| 134 else | |
| 135 setSearchParams(impl, value); | |
| 136 | |
| 125 impl->setURL(url); | 137 impl->setURL(url); |
| 126 } | 138 } |
| 127 | 139 |
| 128 void DOMURLUtils::setHash(DOMURLUtils* impl, const String& value) | 140 void DOMURLUtils::setHash(DOMURLUtils* impl, const String& value) |
| 129 { | 141 { |
| 130 KURL url = impl->url(); | 142 KURL url = impl->url(); |
| 131 if (url.isNull()) | 143 if (url.isNull()) |
| 132 return; | 144 return; |
| 133 | 145 |
| 134 if (value[0] == '#') | 146 if (value[0] == '#') |
| 135 url.setFragmentIdentifier(value.substring(1)); | 147 url.setFragmentIdentifier(value.substring(1)); |
| 136 else | 148 else |
| 137 url.setFragmentIdentifier(value); | 149 url.setFragmentIdentifier(value); |
| 138 | 150 |
| 139 impl->setURL(url); | 151 impl->setURL(url); |
| 140 } | 152 } |
| 141 | 153 |
| 154 DOMURLSearchParams* DOMURLUtils::searchParams(DOMURLUtils* impl, bool& isNull) | |
| 155 { | |
| 156 if (!impl->m_searchParams) | |
| 157 createSearchParams(impl, impl->url().query()); | |
| 158 isNull = false; | |
| 159 return impl->m_searchParams.get(); | |
| 160 } | |
| 161 | |
| 162 void DOMURLUtils::createSearchParams(DOMURLUtils* impl, const String& queryStrin g) | |
| 163 { | |
| 164 if (!impl->m_searchParams) { | |
| 165 impl->m_searchParams = adoptPtr(DOMURLSearchParams::create(queryString). get()); | |
| 166 impl->m_searchParams->setURLObject(impl); | |
| 167 } else { | |
| 168 setSearchParams(impl, queryString); | |
| 169 } | |
| 170 } | |
| 171 | |
| 172 void DOMURLUtils::setSearchParams(DOMURLUtils* impl, const String& queryString) | |
| 173 { | |
| 174 if (!impl->m_searchParams) | |
| 175 return; | |
| 176 | |
| 177 ASSERT(impl->m_searchParams->urlObject() == impl); | |
| 178 impl->m_searchParams->setInput(queryString); | |
| 179 } | |
| 180 | |
| 181 void DOMURLUtils::setSearchParams(DOMURLUtils* impl, DOMURLSearchParams* searchP arams) | |
| 182 { | |
| 183 if (!searchParams) | |
| 184 return; | |
| 185 | |
| 186 if (searchParams->urlObject()) | |
| 187 impl->m_searchParams = adoptPtr(DOMURLSearchParams::create(searchParams) .get()); | |
| 188 else | |
| 189 impl->m_searchParams = adoptPtr(searchParams); | |
| 190 | |
| 191 ASSERT(!impl->m_searchParams->urlObject()); | |
| 192 impl->m_searchParams->setURLObject(impl); | |
| 193 } | |
| 194 | |
| 142 } // namespace WebCore | 195 } // namespace WebCore |
| OLD | NEW |