2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2012 Motorola Mobility Inc.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
15 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
16 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
17 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
18 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
19 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
20 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
22 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
23 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
24 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 #include "core/dom/DOMURLUtils.h"
30 #include "platform/weborigin/KnownPorts.h"
34 void DOMURLUtils::setHref(DOMURLUtils& impl, const String& value)
39 void DOMURLUtils::setProtocol(DOMURLUtils& impl, const String& value)
41 KURL url = impl.url();
44 url.setProtocol(value);
48 void DOMURLUtils::setUsername(DOMURLUtils& impl, const String& value)
50 KURL url = impl.url();
57 void DOMURLUtils::setPassword(DOMURLUtils& impl, const String& value)
59 KURL url = impl.url();
66 void DOMURLUtils::setHost(DOMURLUtils& impl, const String& value)
71 KURL url = impl.url();
72 if (!url.canSetHostOrPort())
75 url.setHostAndPort(value);
79 void DOMURLUtils::setHostname(DOMURLUtils& impl, const String& value)
81 KURL url = impl.url();
82 if (!url.canSetHostOrPort())
85 // Before setting new value:
86 // Remove all leading U+002F SOLIDUS ("/") characters.
88 unsigned hostLength = value.length();
89 while (value[i] == '/')
95 url.setHost(value.substring(i));
100 void DOMURLUtils::setPort(DOMURLUtils& impl, const String& value)
102 KURL url = impl.url();
103 if (!url.canSetHostOrPort())
110 void DOMURLUtils::setPathname(DOMURLUtils& impl, const String& value)
112 KURL url = impl.url();
113 if (!url.canSetPathname())
119 void DOMURLUtils::setSearch(DOMURLUtils& impl, const String& value)
121 KURL url = impl.url();
128 void DOMURLUtils::setHash(DOMURLUtils& impl, const String& value)
130 KURL url = impl.url();
135 url.setFragmentIdentifier(value.substring(1));
137 url.setFragmentIdentifier(value);
142 } // namespace WebCore