Commit fee685df authored by benjamin@webkit.org's avatar benjamin@webkit.org
Browse files

Remove WTFURL from WebKit

https://bugs.webkit.org/show_bug.cgi?id=113994

Patch by Benjamin Poulain <bpoulain@apple.com> on 2013-04-05
Reviewed by Ryosuke Niwa.

.: 

* Source/cmake/WebKitFeatures.cmake:
* Source/cmakeconfig.h.cmake:

Source/WebCore: 

* GNUmakefile.list.am:
* WebCore.exp.in:
* WebCore.xcodeproj/project.pbxproj:
* platform/KURL.cpp:
(WebCore):
(WebCore::KURL::reportMemoryUsage):
(WebCore::KURL::isSafeToSendToAnotherThread):
* platform/KURL.h:
(KURL):
(WebCore):
* platform/KURLWTFURL.cpp: Removed.
* platform/KURLWTFURLImpl.h: Removed.
* platform/cf/KURLCFNet.cpp:
(WebCore::KURL::KURL):
(WebCore::KURL::createCFURL):
(WebCore):
* platform/mac/KURLMac.mm:
(WebCore::KURL::KURL):
(WebCore::KURL::createCFURL):

Source/WebKit/blackberry: 

* WebCoreSupport/AboutDataUseFeatures.in:

Source/WTF: 

Painful, but that is for the best now :(

* GNUmakefile.list.am:
* WTF.xcodeproj/project.pbxproj:
* wtf/MemoryInstrumentationParsedURL.h: Removed.
* wtf/url/api/ParsedURL.cpp: Removed.
* wtf/url/api/ParsedURL.h: Removed.
* wtf/url/api/URLBuffer.h: Removed.
* wtf/url/api/URLQueryCharsetConverter.h: Removed.
* wtf/url/api/URLString.cpp: Removed.
* wtf/url/api/URLString.h: Removed.
* wtf/url/src/RawURLBuffer.h: Removed.
* wtf/url/src/URLCanon.h: Removed.
* wtf/url/src/URLCanonEtc.cpp: Removed.
* wtf/url/src/URLCanonFilesystemurl.cpp: Removed.
* wtf/url/src/URLCanonFileurl.cpp: Removed.
* wtf/url/src/URLCanonHost.cpp: Removed.
* wtf/url/src/URLCanonICU.cpp: Removed.
* wtf/url/src/URLCanonIP.cpp: Removed.
* wtf/url/src/URLCanonInternal.cpp: Removed.
* wtf/url/src/URLCanonInternal.h: Removed.
* wtf/url/src/URLCanonMailto.cpp: Removed.
* wtf/url/src/URLCanonPath.cpp: Removed.
* wtf/url/src/URLCanonPathurl.cpp: Removed.
* wtf/url/src/URLCanonQuery.cpp: Removed.
* wtf/url/src/URLCanonRelative.cpp: Removed.
* wtf/url/src/URLCanonStdURL.cpp: Removed.
* wtf/url/src/URLCharacterTypes.cpp: Removed.
* wtf/url/src/URLCharacterTypes.h: Removed.
* wtf/url/src/URLComponent.h: Removed.
* wtf/url/src/URLFile.h: Removed.
* wtf/url/src/URLParse.cpp: Removed.
* wtf/url/src/URLParse.h: Removed.
* wtf/url/src/URLParseFile.cpp: Removed.
* wtf/url/src/URLParseInternal.h: Removed.
* wtf/url/src/URLSegments.cpp: Removed.
* wtf/url/src/URLSegments.h: Removed.
* wtf/url/src/URLUtil.cpp: Removed.
* wtf/url/src/URLUtil.h: Removed.
* wtf/url/src/URLUtilInternal.h: Removed.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@147715 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 1dca84ef
2013-04-05 Benjamin Poulain <bpoulain@apple.com>
Remove WTFURL from WebKit
https://bugs.webkit.org/show_bug.cgi?id=113994
Reviewed by Ryosuke Niwa.
* Source/cmake/WebKitFeatures.cmake:
* Source/cmakeconfig.h.cmake:
2013-04-04 Ryosuke Niwa <rniwa@webkit.org>
Remove the top level gyp directory and Platform/chromium
......
2013-04-05 Benjamin Poulain <bpoulain@apple.com>
Remove WTFURL from WebKit
https://bugs.webkit.org/show_bug.cgi?id=113994
Reviewed by Ryosuke Niwa.
Painful, but that is for the best now :(
* GNUmakefile.list.am:
* WTF.xcodeproj/project.pbxproj:
* wtf/MemoryInstrumentationParsedURL.h: Removed.
* wtf/url/api/ParsedURL.cpp: Removed.
* wtf/url/api/ParsedURL.h: Removed.
* wtf/url/api/URLBuffer.h: Removed.
* wtf/url/api/URLQueryCharsetConverter.h: Removed.
* wtf/url/api/URLString.cpp: Removed.
* wtf/url/api/URLString.h: Removed.
* wtf/url/src/RawURLBuffer.h: Removed.
* wtf/url/src/URLCanon.h: Removed.
* wtf/url/src/URLCanonEtc.cpp: Removed.
* wtf/url/src/URLCanonFilesystemurl.cpp: Removed.
* wtf/url/src/URLCanonFileurl.cpp: Removed.
* wtf/url/src/URLCanonHost.cpp: Removed.
* wtf/url/src/URLCanonICU.cpp: Removed.
* wtf/url/src/URLCanonIP.cpp: Removed.
* wtf/url/src/URLCanonInternal.cpp: Removed.
* wtf/url/src/URLCanonInternal.h: Removed.
* wtf/url/src/URLCanonMailto.cpp: Removed.
* wtf/url/src/URLCanonPath.cpp: Removed.
* wtf/url/src/URLCanonPathurl.cpp: Removed.
* wtf/url/src/URLCanonQuery.cpp: Removed.
* wtf/url/src/URLCanonRelative.cpp: Removed.
* wtf/url/src/URLCanonStdURL.cpp: Removed.
* wtf/url/src/URLCharacterTypes.cpp: Removed.
* wtf/url/src/URLCharacterTypes.h: Removed.
* wtf/url/src/URLComponent.h: Removed.
* wtf/url/src/URLFile.h: Removed.
* wtf/url/src/URLParse.cpp: Removed.
* wtf/url/src/URLParse.h: Removed.
* wtf/url/src/URLParseFile.cpp: Removed.
* wtf/url/src/URLParseInternal.h: Removed.
* wtf/url/src/URLSegments.cpp: Removed.
* wtf/url/src/URLSegments.h: Removed.
* wtf/url/src/URLUtil.cpp: Removed.
* wtf/url/src/URLUtil.h: Removed.
* wtf/url/src/URLUtilInternal.h: Removed.
2013-04-04 Geoffrey Garen <ggaren@apple.com>
 
Nixed the defunct chromium folder from WTF
......
......@@ -93,7 +93,6 @@ wtf_sources += \
Source/WTF/wtf/MemoryInstrumentationHashMap.h \
Source/WTF/wtf/MemoryInstrumentationHashSet.h \
Source/WTF/wtf/MemoryInstrumentationListHashSet.h \
Source/WTF/wtf/MemoryInstrumentationParsedURL.h \
Source/WTF/wtf/MemoryInstrumentationSequence.h \
Source/WTF/wtf/MemoryInstrumentationString.h \
Source/WTF/wtf/MemoryInstrumentationVector.h \
......@@ -267,39 +266,4 @@ wtf_sources += \
Source/WTF/wtf/unicode/UnicodeMacrosFromICU.h \
Source/WTF/wtf/unicode/icu/CollatorICU.cpp \
Source/WTF/wtf/unicode/icu/UnicodeIcu.h \
Source/WTF/wtf/url/api/ParsedURL.cpp \
Source/WTF/wtf/url/api/ParsedURL.h \
Source/WTF/wtf/url/api/URLBuffer.h \
Source/WTF/wtf/url/api/URLQueryCharsetConverter.h \
Source/WTF/wtf/url/api/URLString.cpp \
Source/WTF/wtf/url/api/URLString.h \
Source/WTF/wtf/url/src/RawURLBuffer.h \
Source/WTF/wtf/url/src/URLCanonEtc.cpp \
Source/WTF/wtf/url/src/URLCanonFilesystemurl.cpp \
Source/WTF/wtf/url/src/URLCanonFileurl.cpp \
Source/WTF/wtf/url/src/URLCanonHost.cpp \
Source/WTF/wtf/url/src/URLCanonICU.cpp \
Source/WTF/wtf/url/src/URLCanonInternal.cpp \
Source/WTF/wtf/url/src/URLCanonInternal.h \
Source/WTF/wtf/url/src/URLCanonIP.cpp \
Source/WTF/wtf/url/src/URLCanonMailto.cpp \
Source/WTF/wtf/url/src/URLCanonPath.cpp \
Source/WTF/wtf/url/src/URLCanonPathurl.cpp \
Source/WTF/wtf/url/src/URLCanonQuery.cpp \
Source/WTF/wtf/url/src/URLCanonRelative.cpp \
Source/WTF/wtf/url/src/URLCanonStdURL.cpp \
Source/WTF/wtf/url/src/URLCanon.h \
Source/WTF/wtf/url/src/URLCharacterTypes.cpp \
Source/WTF/wtf/url/src/URLCharacterTypes.h \
Source/WTF/wtf/url/src/URLComponent.h \
Source/WTF/wtf/url/src/URLFile.h \
Source/WTF/wtf/url/src/URLParse.cpp \
Source/WTF/wtf/url/src/URLParseFile.cpp \
Source/WTF/wtf/url/src/URLParseInternal.h \
Source/WTF/wtf/url/src/URLParse.h \
Source/WTF/wtf/url/src/URLSegments.cpp \
Source/WTF/wtf/url/src/URLSegments.h \
Source/WTF/wtf/url/src/URLUtil.cpp \
Source/WTF/wtf/url/src/URLUtil.h \
Source/WTF/wtf/url/src/URLUtilInternal.h \
Source/WTF/wtf/win/OwnPtrWin.cpp
......@@ -95,7 +95,6 @@ HEADERS += \
MemoryInstrumentationHashMap.h \
MemoryInstrumentationHashSet.h \
MemoryInstrumentationListHashSet.h \
MemoryInstrumentationParsedURL.h \
MemoryInstrumentationSequence.h \
MemoryInstrumentationString.h \
MemoryInstrumentationVector.h \
......
......@@ -171,7 +171,6 @@
<ClInclude Include="..\wtf\MemoryInstrumentationHashMap.h" />
<ClInclude Include="..\wtf\MemoryInstrumentationHashSet.h" />
<ClInclude Include="..\wtf\MemoryInstrumentationListHashSet.h" />
<ClInclude Include="..\wtf\MemoryInstrumentationParsedURL.h" />
<ClInclude Include="..\wtf\MemoryInstrumentationSequence.h" />
<ClInclude Include="..\wtf\MemoryInstrumentationString.h" />
<ClInclude Include="..\wtf\MemoryInstrumentationVector.h" />
......
......@@ -521,9 +521,6 @@
<ClInclude Include="..\wtf\MemoryInstrumentationListHashSet.h">
<Filter>wtf</Filter>
</ClInclude>
<ClInclude Include="..\wtf\MemoryInstrumentationParsedURL.h">
<Filter>wtf</Filter>
</ClInclude>
<ClInclude Include="..\wtf\MemoryInstrumentationSequence.h">
<Filter>wtf</Filter>
</ClInclude>
......
This diff is collapsed.
......@@ -54,7 +54,6 @@ set(WTF_HEADERS
MemoryInstrumentationHashMap.h
MemoryInstrumentationHashSet.h
MemoryInstrumentationListHashSet.h
MemoryInstrumentationParsedURL.h
MemoryInstrumentationSequence.h
MemoryInstrumentationString.h
MemoryInstrumentationVector.h
......
/*
* Copyright (C) 2012 Google Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
* met:
*
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above
* copyright notice, this list of conditions and the following disclaimer
* in the documentation and/or other materials provided with the
* distribution.
* * Neither the name of Google Inc. nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef MemoryInstrumentationParsedURL_h
#define MemoryInstrumentationParsedURL_h
#include <wtf/MemoryInstrumentation.h>
#include <wtf/MemoryInstrumentationString.h>
#include <wtf/url/api/ParsedURL.h>
namespace WTF {
inline void reportMemoryUsage(const URLString* urlString, MemoryObjectInfo* memoryObjectInfo)
{
MemoryClassInfo info(memoryObjectInfo, urlString);
info.addMember(urlString->string());
}
inline void reportMemoryUsage(const ParsedURL* parsedURL, MemoryObjectInfo* memoryObjectInfo)
{
MemoryClassInfo info(memoryObjectInfo, parsedURL);
info.addMember(parsedURL->spec());
}
}
#endif // !defined(MemoryInstrumentationiParsedURL_h)
/*
* Copyright (C) 2010 Google, Inc. All Rights Reserved.
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "config.h"
#include "ParsedURL.h"
#if USE(WTFURL)
#include <wtf/DataLog.h>
#include <wtf/text/CString.h>
#include <wtf/text/StringImpl.h>
#include <wtf/url/src/RawURLBuffer.h>
#include <wtf/url/src/URLComponent.h>
#include <wtf/url/src/URLUtil.h>
namespace WTF {
ParsedURL::ParsedURL(const String& urlString, ParsedURLStringTag)
{
unsigned urlStringLength = urlString.length();
if (!urlStringLength)
return; // FIXME: we should ASSERT on this, but people use KURL incorrectly with ParsedURLStringTag :(.
RawURLBuffer<char> outputBuffer;
String base;
const CString& baseStr = base.utf8();
bool isValid = false;
URLSegments baseSegments;
// FIXME: we should take shortcuts here! We do not have to resolve the relative part.
if (urlString.is8Bit())
isValid = URLUtilities::resolveRelative(baseStr.data(), baseSegments,
reinterpret_cast<const char*>(urlString.characters8()), urlStringLength,
/* charsetConverter */ 0,
outputBuffer, &m_segments);
else
isValid = URLUtilities::resolveRelative(baseStr.data(), baseSegments,
urlString.characters16(), urlStringLength,
/* charsetConverter */ 0,
outputBuffer, &m_segments);
// FIXME: we should ASSERT on isValid, but people use KURL incorrectly with ParsedURLStringTag :(.
if (isValid)
m_spec = URLString(String(outputBuffer.data(), outputBuffer.length()));
}
ParsedURL::ParsedURL(const String& urlString, URLQueryCharsetConverter* queryCharsetConverter)
{
unsigned urlStringLength = urlString.length();
if (!urlStringLength)
return;
RawURLBuffer<char> outputBuffer;
String base;
const CString& baseStr = base.utf8();
bool isValid = false;
URLSegments baseSegments;
// FIXME: we should take shortcuts here! We do not have to resolve the relative part.
if (urlString.is8Bit())
isValid = URLUtilities::resolveRelative(baseStr.data(), baseSegments,
reinterpret_cast<const char*>(urlString.characters8()), urlStringLength,
queryCharsetConverter,
outputBuffer, &m_segments);
else
isValid = URLUtilities::resolveRelative(baseStr.data(), baseSegments,
urlString.characters16(), urlStringLength,
queryCharsetConverter,
outputBuffer, &m_segments);
if (isValid)
m_spec = URLString(String(outputBuffer.data(), outputBuffer.length()));
}
ParsedURL::ParsedURL(const ParsedURL& base, const String& relative, URLQueryCharsetConverter* queryCharsetConverter)
{
if (!base.isValid())
return;
unsigned relativeLength = relative.length();
if (!relativeLength) {
*this = base.withoutFragment();
return;
}
RawURLBuffer<char> outputBuffer;
const CString& baseStr = base.m_spec.m_string.utf8();
bool isValid = false;
if (relative.is8Bit())
isValid = URLUtilities::resolveRelative(baseStr.data(), base.m_segments,
reinterpret_cast<const char*>(relative.characters8()), relativeLength,
queryCharsetConverter,
outputBuffer, &m_segments);
else
isValid = URLUtilities::resolveRelative(baseStr.data(), base.m_segments,
relative.characters16(), relativeLength,
queryCharsetConverter,
outputBuffer, &m_segments);
if (isValid)
m_spec = URLString(String(outputBuffer.data(), outputBuffer.length()));
}
ParsedURL ParsedURL::isolatedCopy() const
{
ParsedURL copy;
copy.m_segments = this->m_segments;
copy.m_spec = URLString(this->m_spec.string().isolatedCopy());
return copy;
}
String ParsedURL::scheme() const
{
return segment(m_segments.scheme);
}
bool ParsedURL::hasStandardScheme() const
{
ASSERT(m_segments.scheme.isValid());
const String& urlStringSpec = m_spec.m_string;
if (urlStringSpec.is8Bit())
return URLUtilities::isStandard(urlStringSpec.characters8(), m_segments.scheme);
return URLUtilities::isStandard(urlStringSpec.characters16(), m_segments.scheme);
}
String ParsedURL::username() const
{
return segment(m_segments.username);
}
String ParsedURL::password() const
{
return segment(m_segments.password);
}
String ParsedURL::host() const
{
return segment(m_segments.host);
}
bool ParsedURL::hasPort() const
{
return m_segments.port.isNonEmpty();
}
String ParsedURL::port() const
{
return segment(m_segments.port);
}
template<typename CharacterType>
static inline String generateNewSpecWithPort(const String& spec, unsigned newSpecLength, unsigned portDelimiterPosition, const LChar* portString, unsigned portStringLength, unsigned postPortPositionInSource)
{
ASSERT(newSpecLength == portDelimiterPosition + 1 + portStringLength + (spec.length() - postPortPositionInSource));
CharacterType* buffer;
String newSpec = StringImpl::createUninitialized(newSpecLength, buffer);
// Copy everything prior to the port posisiton.
ASSERT(buffer + portDelimiterPosition < buffer + newSpecLength);
StringImpl::copyChars(buffer, spec.getCharacters<CharacterType>(), portDelimiterPosition);
// Add the new port from the position.
buffer[portDelimiterPosition] = ':';
unsigned portPosition = portDelimiterPosition + 1;
ASSERT(buffer + portPosition + portStringLength <= buffer + newSpecLength);
StringImpl::copyChars(buffer + portPosition, portString, portStringLength);
// Copy the character post-port from the source.
unsigned remainingComponentsPositionInDestination = portPosition + portStringLength;
ASSERT(buffer + remainingComponentsPositionInDestination + (spec.length() - postPortPositionInSource) == buffer + newSpecLength);
StringImpl::copyChars(buffer + remainingComponentsPositionInDestination, &(spec.getCharacters<CharacterType>()[postPortPositionInSource]), spec.length() - postPortPositionInSource);
return newSpec;
}
static inline void replacePortWithString(String& spec, URLSegments& segments, const LChar* portString, unsigned portStringLength)
{
// Compute the new spec length.
int lengthDifference;
const URLComponent oldPortComponent = segments.port;
if (oldPortComponent.isValid())
lengthDifference = portStringLength - oldPortComponent.length();
else
lengthDifference = 1 + portStringLength;
unsigned newLength = spec.length() + lengthDifference;
// Find the substring positions for the generator template.
int portDelimiterPosition = segments.charactersBefore(URLSegments::Port, URLSegments::DelimiterIncluded);
ASSERT(portDelimiterPosition > 0);
unsigned postPortPositionInSource;
if (oldPortComponent.isValid())
postPortPositionInSource = oldPortComponent.end();
else
postPortPositionInSource = portDelimiterPosition;
// Create the new spec with portString.
if (spec.is8Bit())
spec = generateNewSpecWithPort<LChar>(spec, newLength, static_cast<unsigned>(portDelimiterPosition), portString, portStringLength, postPortPositionInSource);
else
spec = generateNewSpecWithPort<UChar>(spec, newLength, static_cast<unsigned>(portDelimiterPosition), portString, portStringLength, postPortPositionInSource);
// Update the URL components.
unsigned portPosition = portDelimiterPosition + 1;
segments.port.setBegin(portPosition);
segments.port.setLength(portStringLength);
segments.moveFromComponentBy(URLSegments::Path, lengthDifference);
}
void ParsedURL::replacePort(unsigned short newPort)
{
ASSERT(hasStandardScheme());
// Generate a char* string for the port number.
LChar buf[5];
LChar* end = buf + WTF_ARRAY_LENGTH(buf);
LChar* p = end;
do {
*--p = static_cast<LChar>((newPort % 10) + '0');
newPort /= 10;
} while (newPort);
const unsigned portStringLength = end - p;
replacePortWithString(m_spec.m_string, m_segments, p, portStringLength);
}
void ParsedURL::removePort()
{
if (!hasPort())
return;
// 1) Remove the port from the spec, including the delimiter.
String newSpec;
int beginning = m_segments.port.begin() - 1;
unsigned length = m_segments.port.length() + 1;
String newSpecString = m_spec.string();
newSpecString.remove(beginning, length);
m_spec = URLString(newSpecString);
// 2) Update the components positions.
m_segments.port.reset();
m_segments.moveFromComponentBy(URLSegments::Path, -length);
}
String ParsedURL::path() const
{
return segment(m_segments.path);
}
String ParsedURL::query() const
{
return segment(m_segments.query);
}
bool ParsedURL::hasFragment() const
{
return m_segments.fragment.isValid();
}
String ParsedURL::fragment() const
{
return segment(m_segments.fragment);
}
ParsedURL ParsedURL::withoutFragment() const
{
if (!hasFragment())
return *this;
ParsedURL newURL;
int charactersBeforeFragemnt = m_segments.charactersBefore(URLSegments::Fragment, URLSegments::DelimiterExcluded);
newURL.m_spec = URLString(m_spec.string().substringSharingImpl(0, charactersBeforeFragemnt));
newURL.m_segments = m_segments;
newURL.m_segments.fragment = URLComponent();
return newURL;
}
String ParsedURL::baseAsString() const
{
// FIXME: Add WTFURL Implementation.
return String();
}
String ParsedURL::segment(const URLComponent& component) const
{
ASSERT(isValid());
if (!component.isValid())
return String();
String segment = m_spec.string().substring(component.begin(), component.length());
// FIXME: GoogleURL create empty segments. This happen for the fragment for the test fast/url/segments.html
// ASSERT_WITH_MESSAGE(!segment.isEmpty(), "A valid URL component should not be empty.");
return segment;
}
#ifndef NDEBUG
#define SHOW_COMPONENT(parsedURL, componentName) \
if (!parsedURL->componentName().isNull()) { \
dataLog(" " #componentName " = "); \
parsedURL->componentName().show(); \
}
void ParsedURL::print() const
{
if (!isValid()) {
dataLog("Invalid ParsedURL.\n");
return;
}
dataLog("Valid ParsedURL with:\n");
dataLog(" m_spec = ");
m_spec.print();
SHOW_COMPONENT(this, scheme);
SHOW_COMPONENT(this, username);
SHOW_COMPONENT(this, password);
SHOW_COMPONENT(this, host);
SHOW_COMPONENT(this, port);
SHOW_COMPONENT(this, path);
SHOW_COMPONENT(this, query);
SHOW_COMPONENT(this, fragment);
}
#endif
}
#endif // USE(WTFURL)
/*
* Copyright (C) 2010 Google, Inc. All Rights Reserved.
* Copyright (C) 2012 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#ifndef ParsedURL_h
#define ParsedURL_h
#if USE(WTFURL)
#include <wtf/url/api/URLString.h>
#include <wtf/url/src/URLSegments.h>
namespace WTF {
class URLComponent;