This source file includes following definitions.
- setHref
- setProtocol
- setUsername
- setPassword
- setHost
- setHostname
- setPort
- setPathname
- setSearch
- setHash
#include "config.h"
#include "core/dom/DOMURLUtils.h"
#include "platform/weborigin/KnownPorts.h"
namespace WebCore {
void DOMURLUtils::setHref(DOMURLUtils& impl, const String& value)
{
impl.setInput(value);
}
void DOMURLUtils::setProtocol(DOMURLUtils& impl, const String& value)
{
KURL url = impl.url();
if (url.isNull())
return;
url.setProtocol(value);
impl.setURL(url);
}
void DOMURLUtils::setUsername(DOMURLUtils& impl, const String& value)
{
KURL url = impl.url();
if (url.isNull())
return;
url.setUser(value);
impl.setURL(url);
}
void DOMURLUtils::setPassword(DOMURLUtils& impl, const String& value)
{
KURL url = impl.url();
if (url.isNull())
return;
url.setPass(value);
impl.setURL(url);
}
void DOMURLUtils::setHost(DOMURLUtils& impl, const String& value)
{
if (value.isEmpty())
return;
KURL url = impl.url();
if (!url.canSetHostOrPort())
return;
url.setHostAndPort(value);
impl.setURL(url);
}
void DOMURLUtils::setHostname(DOMURLUtils& impl, const String& value)
{
KURL url = impl.url();
if (!url.canSetHostOrPort())
return;
unsigned i = 0;
unsigned hostLength = value.length();
while (value[i] == '/')
i++;
if (i == hostLength)
return;
url.setHost(value.substring(i));
impl.setURL(url);
}
void DOMURLUtils::setPort(DOMURLUtils& impl, const String& value)
{
KURL url = impl.url();
if (!url.canSetHostOrPort())
return;
url.setPort(value);
impl.setURL(url);
}
void DOMURLUtils::setPathname(DOMURLUtils& impl, const String& value)
{
KURL url = impl.url();
if (!url.canSetPathname())
return;
url.setPath(value);
impl.setURL(url);
}
void DOMURLUtils::setSearch(DOMURLUtils& impl, const String& value)
{
KURL url = impl.url();
if (!url.isValid())
return;
url.setQuery(value);
impl.setURL(url);
}
void DOMURLUtils::setHash(DOMURLUtils& impl, const String& value)
{
KURL url = impl.url();
if (url.isNull())
return;
if (value[0] == '#')
url.setFragmentIdentifier(value.substring(1));
else
url.setFragmentIdentifier(value);
impl.setURL(url);
}
}