[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677
mjs
mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 05:55:46 UTC 2009
The following commit has been merged in the debian/unstable branch:
commit 268fa340055c0157b164bcb626ca39d05e42d4d4
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sun Feb 17 07:17:54 2002 +0000
Top level:
* borrowed-classes.txt, configure.in: Stop borring KURL.
Gajillions of test cases for KURL:
* Tests/Makefile.am:
* Tests/kde/.cvsignore:
* Tests/kde/Makefile.am:
* Tests/kde/kurl-test.chk:
* Tests/kde/kurl-test.cpp: (testURL), (main):
* Tests/kde/objc-dummy.mm: (objective_c_hack):
* Tests/test.list:
WebCore:
Reimplement KURL in terms of CFURL (many workarounds needed to
account for differing semantics).
* src/kwq/kdecore/kurl.h:
* src/kwq/KWQKURL.mm: (KURL::KWQKURLPrivate::KWQKURLPrivate),
(KURL::KWQKURLPrivate::~KWQKURLPrivate), (KURL::KWQKURLPrivate::init),
(KURL::KWQKURLPrivate::makeRef), (CFStringToQString), (escapeQString),
(pathEndsWithSlash), (KWQCFURLCopyEscapedPath),
(KURL::KWQKURLPrivate::decompose), (KURL::KWQKURLPrivate::compose), (KURL::KURL),
(KURL::~KURL), (KURL::isEmpty), (KURL::isMalformed), (KURL::hasPath),
(KURL::url), (KURL::protocol), (KURL::host), (KURL::port), (KURL::pass),
(KURL::user), (KURL::ref), (KURL::query), (KURL::path), (KURL::setProtocol),
(KURL::setHost), (KURL::setPort), (KURL::setRef), (KURL::setQuery),
(KURL::setPath), (KURL::prettyURL), (KURL::operator=), (KURL::decode_string),
(KURL::copyOnWrite):
* src/kwq/Makefile.am: Add new file to build.
* src/kwq/KWQKHTMLPart.mm: (KHTMLPart::begin,
KHTMLPart::submitForm): Don't
Minor tweaks to make it all build:
* src/kwq/kde/_kurl.cpp:
* src/kwq/qt/_qurl.cpp:
* src/kwq/qt/_qurl.h:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@632 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index bbba9e8..fe01e67 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,31 @@
+2002-02-16 Maciej Stachowiak <mjs at apple.com>
+
+ Reimplement KURL in terms of CFURL (many workarounds needed to
+ account for differing semantics).
+
+ * src/kwq/kdecore/kurl.h:
+ * src/kwq/KWQKURL.mm: (KURL::KWQKURLPrivate::KWQKURLPrivate),
+ (KURL::KWQKURLPrivate::~KWQKURLPrivate), (KURL::KWQKURLPrivate::init),
+ (KURL::KWQKURLPrivate::makeRef), (CFStringToQString), (escapeQString),
+ (pathEndsWithSlash), (KWQCFURLCopyEscapedPath),
+ (KURL::KWQKURLPrivate::decompose), (KURL::KWQKURLPrivate::compose), (KURL::KURL),
+ (KURL::~KURL), (KURL::isEmpty), (KURL::isMalformed), (KURL::hasPath),
+ (KURL::url), (KURL::protocol), (KURL::host), (KURL::port), (KURL::pass),
+ (KURL::user), (KURL::ref), (KURL::query), (KURL::path), (KURL::setProtocol),
+ (KURL::setHost), (KURL::setPort), (KURL::setRef), (KURL::setQuery),
+ (KURL::setPath), (KURL::prettyURL), (KURL::operator=), (KURL::decode_string),
+ (KURL::copyOnWrite):
+ * src/kwq/Makefile.am: Add new file to build.
+
+ * src/kwq/KWQKHTMLPart.mm: (KHTMLPart::begin,
+ KHTMLPart::submitForm): Don't
+
+ Minor tweaks to make it all build:
+
+ * src/kwq/kde/_kurl.cpp:
+ * src/kwq/qt/_qurl.cpp:
+ * src/kwq/qt/_qurl.h:
+
2002-02-16 Richard Williamson <rjw at apple.com>
Fixed problem with default text not showing up in text area.
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index bbba9e8..fe01e67 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,31 @@
+2002-02-16 Maciej Stachowiak <mjs at apple.com>
+
+ Reimplement KURL in terms of CFURL (many workarounds needed to
+ account for differing semantics).
+
+ * src/kwq/kdecore/kurl.h:
+ * src/kwq/KWQKURL.mm: (KURL::KWQKURLPrivate::KWQKURLPrivate),
+ (KURL::KWQKURLPrivate::~KWQKURLPrivate), (KURL::KWQKURLPrivate::init),
+ (KURL::KWQKURLPrivate::makeRef), (CFStringToQString), (escapeQString),
+ (pathEndsWithSlash), (KWQCFURLCopyEscapedPath),
+ (KURL::KWQKURLPrivate::decompose), (KURL::KWQKURLPrivate::compose), (KURL::KURL),
+ (KURL::~KURL), (KURL::isEmpty), (KURL::isMalformed), (KURL::hasPath),
+ (KURL::url), (KURL::protocol), (KURL::host), (KURL::port), (KURL::pass),
+ (KURL::user), (KURL::ref), (KURL::query), (KURL::path), (KURL::setProtocol),
+ (KURL::setHost), (KURL::setPort), (KURL::setRef), (KURL::setQuery),
+ (KURL::setPath), (KURL::prettyURL), (KURL::operator=), (KURL::decode_string),
+ (KURL::copyOnWrite):
+ * src/kwq/Makefile.am: Add new file to build.
+
+ * src/kwq/KWQKHTMLPart.mm: (KHTMLPart::begin,
+ KHTMLPart::submitForm): Don't
+
+ Minor tweaks to make it all build:
+
+ * src/kwq/kde/_kurl.cpp:
+ * src/kwq/qt/_qurl.cpp:
+ * src/kwq/qt/_qurl.h:
+
2002-02-16 Richard Williamson <rjw at apple.com>
Fixed problem with default text not showing up in text area.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index bbba9e8..fe01e67 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,31 @@
+2002-02-16 Maciej Stachowiak <mjs at apple.com>
+
+ Reimplement KURL in terms of CFURL (many workarounds needed to
+ account for differing semantics).
+
+ * src/kwq/kdecore/kurl.h:
+ * src/kwq/KWQKURL.mm: (KURL::KWQKURLPrivate::KWQKURLPrivate),
+ (KURL::KWQKURLPrivate::~KWQKURLPrivate), (KURL::KWQKURLPrivate::init),
+ (KURL::KWQKURLPrivate::makeRef), (CFStringToQString), (escapeQString),
+ (pathEndsWithSlash), (KWQCFURLCopyEscapedPath),
+ (KURL::KWQKURLPrivate::decompose), (KURL::KWQKURLPrivate::compose), (KURL::KURL),
+ (KURL::~KURL), (KURL::isEmpty), (KURL::isMalformed), (KURL::hasPath),
+ (KURL::url), (KURL::protocol), (KURL::host), (KURL::port), (KURL::pass),
+ (KURL::user), (KURL::ref), (KURL::query), (KURL::path), (KURL::setProtocol),
+ (KURL::setHost), (KURL::setPort), (KURL::setRef), (KURL::setQuery),
+ (KURL::setPath), (KURL::prettyURL), (KURL::operator=), (KURL::decode_string),
+ (KURL::copyOnWrite):
+ * src/kwq/Makefile.am: Add new file to build.
+
+ * src/kwq/KWQKHTMLPart.mm: (KHTMLPart::begin,
+ KHTMLPart::submitForm): Don't
+
+ Minor tweaks to make it all build:
+
+ * src/kwq/kde/_kurl.cpp:
+ * src/kwq/qt/_qurl.cpp:
+ * src/kwq/qt/_qurl.h:
+
2002-02-16 Richard Williamson <rjw at apple.com>
Fixed problem with default text not showing up in text area.
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 042a113..fee83b6 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -601,6 +601,9 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset)
if (!d->m_workingURL.isEmpty())
{
+ // We're not planning to support the KDE chained URL feature, AFAIK
+#define KDE_CHAINED_URIS 0
+#if KDE_CHAINED_URIS
KURL::List lst = KURL::split( d->m_workingURL );
KURL baseurl;
if ( !lst.isEmpty() )
@@ -609,6 +612,9 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset)
// We prefer m_baseURL over m_url because m_url changes when we are
// about to load a new page.
setBaseURL(baseurl);
+#else
+ setBaseURL(d->m_workingURL);
+#endif
}
//FIXME: do we need this?
@@ -1554,7 +1560,7 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
KURL u = completeURL( url, target );
- if ( !u.isValid() )
+ if ( u.isMalformed() )
{
// ### ERROR HANDLING!
return;
@@ -1562,7 +1568,7 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
QString urlstring = u.url();
- if ( urlstring.find( QString::fromLatin1( "javascript:" ), 0, false ) == 0 ) {
+ if ( urlstring.find( u.protocol() == "javascript" ) == 0 ) {
urlstring = KURL::decode_string(urlstring);
executeScript( urlstring.right( urlstring.length() - 11) );
return;
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.mm b/WebCore/kwq/KWQKHTMLPartImpl.mm
index 042a113..fee83b6 100644
--- a/WebCore/kwq/KWQKHTMLPartImpl.mm
+++ b/WebCore/kwq/KWQKHTMLPartImpl.mm
@@ -601,6 +601,9 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset)
if (!d->m_workingURL.isEmpty())
{
+ // We're not planning to support the KDE chained URL feature, AFAIK
+#define KDE_CHAINED_URIS 0
+#if KDE_CHAINED_URIS
KURL::List lst = KURL::split( d->m_workingURL );
KURL baseurl;
if ( !lst.isEmpty() )
@@ -609,6 +612,9 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset)
// We prefer m_baseURL over m_url because m_url changes when we are
// about to load a new page.
setBaseURL(baseurl);
+#else
+ setBaseURL(d->m_workingURL);
+#endif
}
//FIXME: do we need this?
@@ -1554,7 +1560,7 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
KURL u = completeURL( url, target );
- if ( !u.isValid() )
+ if ( u.isMalformed() )
{
// ### ERROR HANDLING!
return;
@@ -1562,7 +1568,7 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
QString urlstring = u.url();
- if ( urlstring.find( QString::fromLatin1( "javascript:" ), 0, false ) == 0 ) {
+ if ( urlstring.find( u.protocol() == "javascript" ) == 0 ) {
urlstring = KURL::decode_string(urlstring);
executeScript( urlstring.right( urlstring.length() - 11) );
return;
diff --git a/WebCore/kwq/KWQKURL.h b/WebCore/kwq/KWQKURL.h
index 823da9e..c3aec6b 100644
--- a/WebCore/kwq/KWQKURL.h
+++ b/WebCore/kwq/KWQKURL.h
@@ -39,6 +39,7 @@
#else
#include <qstring.h>
+#include <KWQRefPtr.h>
// FIXME: this clever hack may need to be moved into KWQDef.h or elsewhere
#define Fixed MacFixed
@@ -60,10 +61,12 @@ public:
// constants ---------------------------------------------------------------
// static member functions -------------------------------------------------
+ static QString decode_string(const QString &urlString);
+
// constructors, copy constructors, and destructors ------------------------
KURL();
- KURL(const char *url, int encoding_hint=0);
+ KURL(const char *, int encoding_hint=0);
KURL(const KURL &, const QString &);
KURL(const QString &, int encoding_hint=0);
KURL(const KURL &);
@@ -103,22 +106,11 @@ public:
// private ---------------------------------------------------------------------
private:
-
- void init();
-
- CFURLRef urlRef;
- bool malformed;
- QString sURL;
- QString sProtocol;
- QString sHost;
- unsigned short int iPort;
- QString sPass;
- QString sUser;
- QString sRef;
- QString sQuery;
- QString sPath;
+ void copyOnWrite();
+ class KWQKURLPrivate;
+ KWQRefPtr<KWQKURLPrivate> d;
}; // class KURL ===============================================================
#endif
diff --git a/WebCore/kwq/KWQKURL.mm b/WebCore/kwq/KWQKURL.mm
new file mode 100644
index 0000000..1d2869c
--- /dev/null
+++ b/WebCore/kwq/KWQKURL.mm
@@ -0,0 +1,525 @@
+/*
+ * Copyright (C) 2001 Apple Computer, 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 COMPUTER, 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 COMPUTER, 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 <kurl.h>
+#include <kwqdebug.h>
+
+#ifndef USING_BORROWED_KURL
+
+#import <Foundation/NSURLPathUtilities.h>
+
+class KURL::KWQKURLPrivate
+{
+public:
+ KWQKURLPrivate(const QString &url);
+ KWQKURLPrivate(const KWQKURLPrivate &other);
+ ~KWQKURLPrivate();
+
+ void init(const QString &);
+ void makeRef();
+ void decompose();
+ void compose();
+
+ CFURLRef urlRef;
+ QString sURL;
+ QString sProtocol;
+ QString sHost;
+ unsigned short int iPort;
+ QString sPass;
+ QString sUser;
+ QString sRef;
+ QString sQuery;
+ QString sPath;
+ QString escapedPath;
+ bool addedSlash;
+
+ int refCount;
+};
+
+
+KURL::KWQKURLPrivate::KWQKURLPrivate(const QString &url) :
+ urlRef(nil),
+ iPort(0),
+ addedSlash(false),
+ refCount(0)
+{
+ init(url);
+}
+
+KURL::KWQKURLPrivate::KWQKURLPrivate(const KWQKURLPrivate &other) :
+ urlRef(other.urlRef != NULL ? CFRetain(other.urlRef) : NULL),
+ sURL(other.sURL),
+ sProtocol(other.sProtocol),
+ sHost(other.sHost),
+ iPort(other.iPort),
+ sPass(other.sPass),
+ sUser(other.sUser),
+ sRef(other.sRef),
+ sQuery(other.sQuery),
+ sPath(other.sPath),
+ escapedPath(other.escapedPath),
+ addedSlash(other.addedSlash)
+{
+}
+
+KURL::KWQKURLPrivate::~KWQKURLPrivate()
+{
+ if (urlRef != NULL) {
+ CFRelease(urlRef);
+ }
+}
+
+void KURL::KWQKURLPrivate::init(const QString &s)
+{
+ // Save original string
+ sURL = s;
+
+ decompose();
+}
+
+void KURL::KWQKURLPrivate::makeRef()
+{
+ // Not a path and no scheme, so bail out, because CFURL considers such
+ // things valid URLs for some reason.
+ if (!sURL.contains(':') && (sURL.length() == 0 || sURL[0] != '/') || sURL == "file:" || sURL == "file://") {
+ urlRef = NULL;
+ return;
+ }
+
+ // Create CFURLRef object
+ if (sURL.length() > 0 && sURL[0] == '/') {
+ sURL = (QString("file://")) + sURL;
+ } else if (sURL.startsWith("file:/") && !sURL.startsWith("file://")) {
+ sURL = (QString("file:///") + sURL.mid(6));
+ }
+
+ QString sURLMaybeAddSlash;
+ int colonPos = sURL.find(':');
+ int slashSlashPos = sURL.find("//", colonPos);
+ if (slashSlashPos != -1 && sURL.find('/', slashSlashPos + 2) == -1) {
+ sURLMaybeAddSlash = sURL + "/";
+ addedSlash = true;
+ } else {
+ sURLMaybeAddSlash = sURL;
+ addedSlash = false;
+ }
+
+ urlRef = CFURLCreateWithString(NULL, sURLMaybeAddSlash.getCFMutableString(), NULL);
+}
+
+static inline QString CFStringToQString(CFStringRef cfs)
+{
+ QString qs;
+
+ if (cfs != NULL) {
+ qs = QString::fromCFString(cfs);
+ CFRelease(cfs);
+ } else {
+ qs = QString();
+ }
+
+ return qs;
+}
+
+static inline QString escapeQString(QString str)
+{
+ return CFStringToQString(CFURLCreateStringByAddingPercentEscapes(NULL, str.getCFMutableString(), NULL, NULL, kCFStringEncodingUTF8));
+}
+
+static bool pathEndsWithSlash(QString sURL)
+{
+ int endOfPath = sURL.findRev('?', sURL.findRev('#'));
+ if (endOfPath == -1) {
+ endOfPath = sURL.length();
+ }
+ if (sURL[endOfPath-1] == '/') {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+
+CFStringRef KWQCFURLCopyEscapedPath(CFURLRef anURL)
+{
+ NSRange path;
+ CFStringRef urlString = CFURLGetString(anURL);
+
+ _NSParseStringToGenericURLComponents((NSString *)urlString, NULL, NULL, NULL, NULL, NULL, &path, NULL, NULL, NULL);
+
+ return CFStringCreateWithSubstring(NULL, urlString, CFRangeMake(path.location, path.length));
+}
+
+void KURL::KWQKURLPrivate::decompose()
+{
+ makeRef();
+
+ if (urlRef == NULL) {
+ // failed to parse
+ return;
+ }
+
+ // decompose into parts
+
+ sProtocol = CFStringToQString(CFURLCopyScheme(urlRef));
+
+ QString hostName = CFStringToQString(CFURLCopyHostName(urlRef));
+ if (sProtocol != "file") {
+ sHost = hostName;
+ }
+
+ SInt32 portNumber = CFURLGetPortNumber(urlRef);
+ if (portNumber < 0) {
+ iPort = 0;
+ } else {
+ iPort = portNumber;
+ }
+
+ sPass = CFStringToQString(CFURLCopyPassword(urlRef));
+ sUser = CFStringToQString(CFURLCopyUserName(urlRef));
+ sRef = CFStringToQString(CFURLCopyFragment(urlRef, NULL));
+
+ sQuery = CFStringToQString(CFURLCopyQueryString(urlRef, NULL));
+ if (!sQuery.isEmpty()) {
+ sQuery = QString("?") + sQuery;
+ }
+
+ if (CFURLCanBeDecomposed(urlRef)) {
+ if (addedSlash) {
+ sPath = "";
+ escapedPath = "";
+ } else {
+ sPath = CFStringToQString(CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle));
+ escapedPath = CFStringToQString(KWQCFURLCopyEscapedPath(urlRef));
+ }
+ QString param = CFStringToQString(CFURLCopyParameterString(urlRef, CFSTR("")));
+ if (!param.isEmpty()) {
+ sPath += ";" + param;
+ QString escapedParam = CFStringToQString(CFURLCopyParameterString(urlRef, NULL));
+
+ escapedPath += ";" + escapedParam;
+ }
+
+ if (pathEndsWithSlash(sURL) && sPath.right(1) != "/") {
+ sPath += "/";
+ }
+ } else {
+ sPath = CFStringToQString(CFURLCopyResourceSpecifier(urlRef));
+ escapedPath = sPath;
+ }
+
+ if (sProtocol == "file" && !hostName.isEmpty() && hostName != "localhost") {
+ sPath = QString("//") + hostName + sPath;
+ escapedPath = QString("//") + hostName + escapedPath;
+ }
+
+ // could lead to poor performance - perhaps compose manually in ::url?
+ if (sURL != "file://localhost") {
+ compose();
+ }
+}
+
+void KURL::KWQKURLPrivate::compose()
+{
+ if (!sProtocol.isEmpty()) {
+ QString result = escapeQString(sProtocol) + ":";
+
+ if (!sHost.isEmpty()) {
+ result += "//";
+ if (!sUser.isEmpty()) {
+ result += escapeQString(sUser);
+ if (!sPass.isEmpty()) {
+ result += ":" + escapeQString(sPass);
+ }
+ result += "@";
+ }
+ result += escapeQString(sHost);
+ if (iPort != 0) {
+ result += ":" + QString::number(iPort);
+ }
+ }
+
+ result += escapedPath + sQuery;
+
+ if (!sRef.isEmpty()) {
+ result += "#" + sRef;
+ }
+
+ if (urlRef != NULL) {
+ CFRelease(urlRef);
+ }
+
+ sURL = result;
+
+ makeRef();
+ }
+}
+
+// KURL
+
+KURL::KURL() :
+ d(new KURL::KWQKURLPrivate(QString()))
+{
+}
+
+KURL::KURL(const char *url, int encoding_hint=0) :
+ d(new KURL::KWQKURLPrivate(url))
+{
+}
+
+KURL::KURL(const QString &url, int encoding_hint=0) :
+ d(new KURL::KWQKURLPrivate(url))
+{
+}
+
+KURL::KURL(const KURL &base, const QString &relative)
+{
+ if (relative.isEmpty()) {
+ d = base.d;
+ } else {
+ CFURLRef relativeURL = CFURLCreateWithString(NULL, relative.getCFMutableString(), base.d->urlRef);
+ if (relativeURL == NULL) {
+ d = base.d;
+ copyOnWrite();
+ setPath(d->sPath + relative);
+ } else {
+ CFURLRef absoluteURL = CFURLCopyAbsoluteURL(relativeURL);
+
+ d = KWQRefPtr<KURL::KWQKURLPrivate>(new KURL::KWQKURLPrivate(QString::fromCFString(CFURLGetString(absoluteURL))));
+
+ CFRelease (relativeURL);
+ CFRelease (absoluteURL);
+ }
+ }
+}
+
+KURL::KURL(const KURL &other) :
+ d(other.d)
+{
+}
+
+KURL::~KURL()
+{
+}
+
+bool KURL::isEmpty() const
+{
+ return d->sURL.isEmpty();
+}
+
+bool KURL::isMalformed() const
+{
+ return (d->urlRef == NULL);
+}
+
+bool KURL::hasPath() const
+{
+ return !d->sPath.isEmpty();
+}
+
+QString KURL::url() const
+{
+ if (d->urlRef == NULL) {
+ return d->sURL;
+ }
+
+ QString qurl = QString::fromCFString(CFURLGetString(d->urlRef));
+
+ // Special handling for file: URLs
+ if (qurl.startsWith("file:///")) {
+ qurl = QString("file:/") + qurl.mid(8);
+ } else if (d->sURL == "file://localhost") {
+ qurl = QString("file:/");
+ } else if (qurl.startsWith("file://localhost/")) {
+ qurl = QString("file:/") + qurl.mid(17);
+ }
+
+ if (d->addedSlash) {
+ qurl = qurl.left(qurl.length()-1);
+ }
+
+ return qurl;
+}
+
+QString KURL::protocol() const
+{
+ return d->sProtocol;
+}
+
+QString KURL::host() const
+{
+ return d->sHost;
+}
+
+unsigned short int KURL::port() const
+{
+ return d->iPort;
+}
+
+QString KURL::pass() const
+{
+ return d->sPass;
+}
+
+QString KURL::user() const
+{
+ return d->sUser;
+}
+
+QString KURL::ref() const
+{
+ return d->sRef;
+}
+
+QString KURL::query() const
+{
+ return d->sQuery;
+}
+
+QString KURL::path() const
+{
+ return d->sPath;
+}
+
+void KURL::setProtocol(const QString &s)
+{
+ copyOnWrite();
+ d->sProtocol = s;
+ d->compose();
+}
+
+void KURL::setHost(const QString &s)
+{
+ copyOnWrite();
+ d->sHost = s;
+ d->compose();
+}
+
+void KURL::setPort(unsigned short i)
+{
+ copyOnWrite();
+ d->iPort = i;
+ d->compose();
+}
+
+void KURL::setRef(const QString &s)
+{
+ copyOnWrite();
+ d->sRef = s;
+ d->compose();
+}
+
+void KURL::setQuery(const QString &s, int encoding_hint=0)
+{
+ copyOnWrite();
+ d->sQuery = s;
+ d->compose();
+}
+
+void KURL::setPath(const QString &s)
+{
+ copyOnWrite();
+ d->sPath = s;
+ d->escapedPath = escapeQString(s);
+ d->compose();
+}
+
+QString KURL::prettyURL(int trailing=0) const
+{
+ if (d->urlRef == NULL) {
+ return d->sURL;
+ }
+
+ QString result = d->sProtocol + ":";
+
+ if (!d->sHost.isEmpty()) {
+ result += "//";
+ if (!d->sUser.isEmpty()) {
+ result += d->sUser;
+ result += "@";
+ }
+ result += d->sHost;
+ if (d->iPort != 0) {
+ result += ":";
+ result += QString::number(d->iPort);
+ }
+ }
+
+ QString path = d->sPath;
+
+ if (trailing == 1) {
+ if (path.right(1) != "/" && !path.isEmpty()) {
+ path += "/";
+ }
+ } else if (trailing == -1) {
+ if (path.right(1) == "/" && path.length() > 1) {
+ path = path.left(path.length()-1);
+ }
+ }
+
+ result += path;
+ result += d->sQuery;
+
+ if (!d->sRef.isEmpty()) {
+ result += "#" + d->sRef;
+ }
+
+ return result;
+}
+
+
+KURL &KURL::operator=(const KURL &other)
+{
+ KURL tmp(other);
+ KWQRefPtr<KURL::KWQKURLPrivate> tmpD = tmp.d;
+
+ tmp.d = d;
+ d = tmpD;
+
+ return *this;
+}
+
+
+
+QString KURL::decode_string(const QString &urlString)
+{
+ CFStringRef unescaped = CFURLCreateStringByReplacingPercentEscapes(NULL, urlString.getCFMutableString(), CFSTR(""));
+ QString qUnescaped = QString::fromCFString(unescaped);
+ CFRelease(unescaped);
+
+ return qUnescaped;
+}
+
+
+void KURL::copyOnWrite()
+{
+ if (d->refCount > 1) {
+ d = KWQRefPtr<KURL::KWQKURLPrivate>(new KURL::KWQKURLPrivate(*d));
+ }
+}
+
+
+#endif
+
diff --git a/WebCore/kwq/Makefile.am b/WebCore/kwq/Makefile.am
index f34950e..8d73785 100644
--- a/WebCore/kwq/Makefile.am
+++ b/WebCore/kwq/Makefile.am
@@ -79,6 +79,7 @@ libkwq_o_SOURCES = \
KWQKScheduler.mm \
KWQKSimpleConfig.mm \
KWQKStringHandler.mm \
+ KWQKURL.mm \
KWQKWin.mm \
KWQKWinModule.mm \
KWQKjobclasses.mm \
diff --git a/WebCore/kwq/kde/_kurl.cpp b/WebCore/kwq/kde/_kurl.cpp
index d0181e1..10c728d 100644
--- a/WebCore/kwq/kde/_kurl.cpp
+++ b/WebCore/kwq/kde/_kurl.cpp
@@ -17,7 +17,8 @@
Boston, MA 02111-1307, USA.
*/
-#include "_kurl.h"
+#include <kurl.h>
+
#include <kdebug.h>
#include <kglobal.h>
diff --git a/WebCore/kwq/kdecore/kurl.h b/WebCore/kwq/kdecore/kurl.h
index 823da9e..c3aec6b 100644
--- a/WebCore/kwq/kdecore/kurl.h
+++ b/WebCore/kwq/kdecore/kurl.h
@@ -39,6 +39,7 @@
#else
#include <qstring.h>
+#include <KWQRefPtr.h>
// FIXME: this clever hack may need to be moved into KWQDef.h or elsewhere
#define Fixed MacFixed
@@ -60,10 +61,12 @@ public:
// constants ---------------------------------------------------------------
// static member functions -------------------------------------------------
+ static QString decode_string(const QString &urlString);
+
// constructors, copy constructors, and destructors ------------------------
KURL();
- KURL(const char *url, int encoding_hint=0);
+ KURL(const char *, int encoding_hint=0);
KURL(const KURL &, const QString &);
KURL(const QString &, int encoding_hint=0);
KURL(const KURL &);
@@ -103,22 +106,11 @@ public:
// private ---------------------------------------------------------------------
private:
-
- void init();
-
- CFURLRef urlRef;
- bool malformed;
- QString sURL;
- QString sProtocol;
- QString sHost;
- unsigned short int iPort;
- QString sPass;
- QString sUser;
- QString sRef;
- QString sQuery;
- QString sPath;
+ void copyOnWrite();
+ class KWQKURLPrivate;
+ KWQRefPtr<KWQKURLPrivate> d;
}; // class KURL ===============================================================
#endif
diff --git a/WebCore/kwq/qt/_qurl.cpp b/WebCore/kwq/qt/_qurl.cpp
index a82de3c..28efc96 100644
--- a/WebCore/kwq/qt/_qurl.cpp
+++ b/WebCore/kwq/qt/_qurl.cpp
@@ -36,6 +36,9 @@
**********************************************************************/
#include "_qurl.h"
+#include <config.h>
+
+#ifdef USING_BORROWED_KURL
#ifndef QT_NO_DIR
@@ -1165,3 +1168,6 @@ bool QUrl::cdUp()
}
#endif // QT_NO_NETWORKPROTOCOL
+
+#endif USING_BORROWED_KURL
+
diff --git a/WebCore/kwq/qt/_qurl.h b/WebCore/kwq/qt/_qurl.h
index 3b212aa..1a1d951 100644
--- a/WebCore/kwq/qt/_qurl.h
+++ b/WebCore/kwq/qt/_qurl.h
@@ -38,6 +38,10 @@
#ifndef QURL_H
#define QURL_H
+#include <config.h>
+
+#ifdef USING_BORROWED_KURL
+
#ifndef QT_H
#include "qstring.h"
#include "_qdir.h"
@@ -120,4 +124,6 @@ private:
};
+#endif USING_BORROWED_URL
+
#endif
diff --git a/WebCore/src/kwq/KWQKHTMLPart.mm b/WebCore/src/kwq/KWQKHTMLPart.mm
index 042a113..fee83b6 100644
--- a/WebCore/src/kwq/KWQKHTMLPart.mm
+++ b/WebCore/src/kwq/KWQKHTMLPart.mm
@@ -601,6 +601,9 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset)
if (!d->m_workingURL.isEmpty())
{
+ // We're not planning to support the KDE chained URL feature, AFAIK
+#define KDE_CHAINED_URIS 0
+#if KDE_CHAINED_URIS
KURL::List lst = KURL::split( d->m_workingURL );
KURL baseurl;
if ( !lst.isEmpty() )
@@ -609,6 +612,9 @@ void KHTMLPart::begin( const KURL &url, int xOffset, int yOffset)
// We prefer m_baseURL over m_url because m_url changes when we are
// about to load a new page.
setBaseURL(baseurl);
+#else
+ setBaseURL(d->m_workingURL);
+#endif
}
//FIXME: do we need this?
@@ -1554,7 +1560,7 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
KURL u = completeURL( url, target );
- if ( !u.isValid() )
+ if ( u.isMalformed() )
{
// ### ERROR HANDLING!
return;
@@ -1562,7 +1568,7 @@ void KHTMLPart::submitForm( const char *action, const QString &url, const QByteA
QString urlstring = u.url();
- if ( urlstring.find( QString::fromLatin1( "javascript:" ), 0, false ) == 0 ) {
+ if ( urlstring.find( u.protocol() == "javascript" ) == 0 ) {
urlstring = KURL::decode_string(urlstring);
executeScript( urlstring.right( urlstring.length() - 11) );
return;
diff --git a/WebCore/src/kwq/KWQKURL.mm b/WebCore/src/kwq/KWQKURL.mm
new file mode 100644
index 0000000..1d2869c
--- /dev/null
+++ b/WebCore/src/kwq/KWQKURL.mm
@@ -0,0 +1,525 @@
+/*
+ * Copyright (C) 2001 Apple Computer, 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 COMPUTER, 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 COMPUTER, 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 <kurl.h>
+#include <kwqdebug.h>
+
+#ifndef USING_BORROWED_KURL
+
+#import <Foundation/NSURLPathUtilities.h>
+
+class KURL::KWQKURLPrivate
+{
+public:
+ KWQKURLPrivate(const QString &url);
+ KWQKURLPrivate(const KWQKURLPrivate &other);
+ ~KWQKURLPrivate();
+
+ void init(const QString &);
+ void makeRef();
+ void decompose();
+ void compose();
+
+ CFURLRef urlRef;
+ QString sURL;
+ QString sProtocol;
+ QString sHost;
+ unsigned short int iPort;
+ QString sPass;
+ QString sUser;
+ QString sRef;
+ QString sQuery;
+ QString sPath;
+ QString escapedPath;
+ bool addedSlash;
+
+ int refCount;
+};
+
+
+KURL::KWQKURLPrivate::KWQKURLPrivate(const QString &url) :
+ urlRef(nil),
+ iPort(0),
+ addedSlash(false),
+ refCount(0)
+{
+ init(url);
+}
+
+KURL::KWQKURLPrivate::KWQKURLPrivate(const KWQKURLPrivate &other) :
+ urlRef(other.urlRef != NULL ? CFRetain(other.urlRef) : NULL),
+ sURL(other.sURL),
+ sProtocol(other.sProtocol),
+ sHost(other.sHost),
+ iPort(other.iPort),
+ sPass(other.sPass),
+ sUser(other.sUser),
+ sRef(other.sRef),
+ sQuery(other.sQuery),
+ sPath(other.sPath),
+ escapedPath(other.escapedPath),
+ addedSlash(other.addedSlash)
+{
+}
+
+KURL::KWQKURLPrivate::~KWQKURLPrivate()
+{
+ if (urlRef != NULL) {
+ CFRelease(urlRef);
+ }
+}
+
+void KURL::KWQKURLPrivate::init(const QString &s)
+{
+ // Save original string
+ sURL = s;
+
+ decompose();
+}
+
+void KURL::KWQKURLPrivate::makeRef()
+{
+ // Not a path and no scheme, so bail out, because CFURL considers such
+ // things valid URLs for some reason.
+ if (!sURL.contains(':') && (sURL.length() == 0 || sURL[0] != '/') || sURL == "file:" || sURL == "file://") {
+ urlRef = NULL;
+ return;
+ }
+
+ // Create CFURLRef object
+ if (sURL.length() > 0 && sURL[0] == '/') {
+ sURL = (QString("file://")) + sURL;
+ } else if (sURL.startsWith("file:/") && !sURL.startsWith("file://")) {
+ sURL = (QString("file:///") + sURL.mid(6));
+ }
+
+ QString sURLMaybeAddSlash;
+ int colonPos = sURL.find(':');
+ int slashSlashPos = sURL.find("//", colonPos);
+ if (slashSlashPos != -1 && sURL.find('/', slashSlashPos + 2) == -1) {
+ sURLMaybeAddSlash = sURL + "/";
+ addedSlash = true;
+ } else {
+ sURLMaybeAddSlash = sURL;
+ addedSlash = false;
+ }
+
+ urlRef = CFURLCreateWithString(NULL, sURLMaybeAddSlash.getCFMutableString(), NULL);
+}
+
+static inline QString CFStringToQString(CFStringRef cfs)
+{
+ QString qs;
+
+ if (cfs != NULL) {
+ qs = QString::fromCFString(cfs);
+ CFRelease(cfs);
+ } else {
+ qs = QString();
+ }
+
+ return qs;
+}
+
+static inline QString escapeQString(QString str)
+{
+ return CFStringToQString(CFURLCreateStringByAddingPercentEscapes(NULL, str.getCFMutableString(), NULL, NULL, kCFStringEncodingUTF8));
+}
+
+static bool pathEndsWithSlash(QString sURL)
+{
+ int endOfPath = sURL.findRev('?', sURL.findRev('#'));
+ if (endOfPath == -1) {
+ endOfPath = sURL.length();
+ }
+ if (sURL[endOfPath-1] == '/') {
+ return true;
+ } else {
+ return false;
+ }
+}
+
+
+CFStringRef KWQCFURLCopyEscapedPath(CFURLRef anURL)
+{
+ NSRange path;
+ CFStringRef urlString = CFURLGetString(anURL);
+
+ _NSParseStringToGenericURLComponents((NSString *)urlString, NULL, NULL, NULL, NULL, NULL, &path, NULL, NULL, NULL);
+
+ return CFStringCreateWithSubstring(NULL, urlString, CFRangeMake(path.location, path.length));
+}
+
+void KURL::KWQKURLPrivate::decompose()
+{
+ makeRef();
+
+ if (urlRef == NULL) {
+ // failed to parse
+ return;
+ }
+
+ // decompose into parts
+
+ sProtocol = CFStringToQString(CFURLCopyScheme(urlRef));
+
+ QString hostName = CFStringToQString(CFURLCopyHostName(urlRef));
+ if (sProtocol != "file") {
+ sHost = hostName;
+ }
+
+ SInt32 portNumber = CFURLGetPortNumber(urlRef);
+ if (portNumber < 0) {
+ iPort = 0;
+ } else {
+ iPort = portNumber;
+ }
+
+ sPass = CFStringToQString(CFURLCopyPassword(urlRef));
+ sUser = CFStringToQString(CFURLCopyUserName(urlRef));
+ sRef = CFStringToQString(CFURLCopyFragment(urlRef, NULL));
+
+ sQuery = CFStringToQString(CFURLCopyQueryString(urlRef, NULL));
+ if (!sQuery.isEmpty()) {
+ sQuery = QString("?") + sQuery;
+ }
+
+ if (CFURLCanBeDecomposed(urlRef)) {
+ if (addedSlash) {
+ sPath = "";
+ escapedPath = "";
+ } else {
+ sPath = CFStringToQString(CFURLCopyFileSystemPath(urlRef, kCFURLPOSIXPathStyle));
+ escapedPath = CFStringToQString(KWQCFURLCopyEscapedPath(urlRef));
+ }
+ QString param = CFStringToQString(CFURLCopyParameterString(urlRef, CFSTR("")));
+ if (!param.isEmpty()) {
+ sPath += ";" + param;
+ QString escapedParam = CFStringToQString(CFURLCopyParameterString(urlRef, NULL));
+
+ escapedPath += ";" + escapedParam;
+ }
+
+ if (pathEndsWithSlash(sURL) && sPath.right(1) != "/") {
+ sPath += "/";
+ }
+ } else {
+ sPath = CFStringToQString(CFURLCopyResourceSpecifier(urlRef));
+ escapedPath = sPath;
+ }
+
+ if (sProtocol == "file" && !hostName.isEmpty() && hostName != "localhost") {
+ sPath = QString("//") + hostName + sPath;
+ escapedPath = QString("//") + hostName + escapedPath;
+ }
+
+ // could lead to poor performance - perhaps compose manually in ::url?
+ if (sURL != "file://localhost") {
+ compose();
+ }
+}
+
+void KURL::KWQKURLPrivate::compose()
+{
+ if (!sProtocol.isEmpty()) {
+ QString result = escapeQString(sProtocol) + ":";
+
+ if (!sHost.isEmpty()) {
+ result += "//";
+ if (!sUser.isEmpty()) {
+ result += escapeQString(sUser);
+ if (!sPass.isEmpty()) {
+ result += ":" + escapeQString(sPass);
+ }
+ result += "@";
+ }
+ result += escapeQString(sHost);
+ if (iPort != 0) {
+ result += ":" + QString::number(iPort);
+ }
+ }
+
+ result += escapedPath + sQuery;
+
+ if (!sRef.isEmpty()) {
+ result += "#" + sRef;
+ }
+
+ if (urlRef != NULL) {
+ CFRelease(urlRef);
+ }
+
+ sURL = result;
+
+ makeRef();
+ }
+}
+
+// KURL
+
+KURL::KURL() :
+ d(new KURL::KWQKURLPrivate(QString()))
+{
+}
+
+KURL::KURL(const char *url, int encoding_hint=0) :
+ d(new KURL::KWQKURLPrivate(url))
+{
+}
+
+KURL::KURL(const QString &url, int encoding_hint=0) :
+ d(new KURL::KWQKURLPrivate(url))
+{
+}
+
+KURL::KURL(const KURL &base, const QString &relative)
+{
+ if (relative.isEmpty()) {
+ d = base.d;
+ } else {
+ CFURLRef relativeURL = CFURLCreateWithString(NULL, relative.getCFMutableString(), base.d->urlRef);
+ if (relativeURL == NULL) {
+ d = base.d;
+ copyOnWrite();
+ setPath(d->sPath + relative);
+ } else {
+ CFURLRef absoluteURL = CFURLCopyAbsoluteURL(relativeURL);
+
+ d = KWQRefPtr<KURL::KWQKURLPrivate>(new KURL::KWQKURLPrivate(QString::fromCFString(CFURLGetString(absoluteURL))));
+
+ CFRelease (relativeURL);
+ CFRelease (absoluteURL);
+ }
+ }
+}
+
+KURL::KURL(const KURL &other) :
+ d(other.d)
+{
+}
+
+KURL::~KURL()
+{
+}
+
+bool KURL::isEmpty() const
+{
+ return d->sURL.isEmpty();
+}
+
+bool KURL::isMalformed() const
+{
+ return (d->urlRef == NULL);
+}
+
+bool KURL::hasPath() const
+{
+ return !d->sPath.isEmpty();
+}
+
+QString KURL::url() const
+{
+ if (d->urlRef == NULL) {
+ return d->sURL;
+ }
+
+ QString qurl = QString::fromCFString(CFURLGetString(d->urlRef));
+
+ // Special handling for file: URLs
+ if (qurl.startsWith("file:///")) {
+ qurl = QString("file:/") + qurl.mid(8);
+ } else if (d->sURL == "file://localhost") {
+ qurl = QString("file:/");
+ } else if (qurl.startsWith("file://localhost/")) {
+ qurl = QString("file:/") + qurl.mid(17);
+ }
+
+ if (d->addedSlash) {
+ qurl = qurl.left(qurl.length()-1);
+ }
+
+ return qurl;
+}
+
+QString KURL::protocol() const
+{
+ return d->sProtocol;
+}
+
+QString KURL::host() const
+{
+ return d->sHost;
+}
+
+unsigned short int KURL::port() const
+{
+ return d->iPort;
+}
+
+QString KURL::pass() const
+{
+ return d->sPass;
+}
+
+QString KURL::user() const
+{
+ return d->sUser;
+}
+
+QString KURL::ref() const
+{
+ return d->sRef;
+}
+
+QString KURL::query() const
+{
+ return d->sQuery;
+}
+
+QString KURL::path() const
+{
+ return d->sPath;
+}
+
+void KURL::setProtocol(const QString &s)
+{
+ copyOnWrite();
+ d->sProtocol = s;
+ d->compose();
+}
+
+void KURL::setHost(const QString &s)
+{
+ copyOnWrite();
+ d->sHost = s;
+ d->compose();
+}
+
+void KURL::setPort(unsigned short i)
+{
+ copyOnWrite();
+ d->iPort = i;
+ d->compose();
+}
+
+void KURL::setRef(const QString &s)
+{
+ copyOnWrite();
+ d->sRef = s;
+ d->compose();
+}
+
+void KURL::setQuery(const QString &s, int encoding_hint=0)
+{
+ copyOnWrite();
+ d->sQuery = s;
+ d->compose();
+}
+
+void KURL::setPath(const QString &s)
+{
+ copyOnWrite();
+ d->sPath = s;
+ d->escapedPath = escapeQString(s);
+ d->compose();
+}
+
+QString KURL::prettyURL(int trailing=0) const
+{
+ if (d->urlRef == NULL) {
+ return d->sURL;
+ }
+
+ QString result = d->sProtocol + ":";
+
+ if (!d->sHost.isEmpty()) {
+ result += "//";
+ if (!d->sUser.isEmpty()) {
+ result += d->sUser;
+ result += "@";
+ }
+ result += d->sHost;
+ if (d->iPort != 0) {
+ result += ":";
+ result += QString::number(d->iPort);
+ }
+ }
+
+ QString path = d->sPath;
+
+ if (trailing == 1) {
+ if (path.right(1) != "/" && !path.isEmpty()) {
+ path += "/";
+ }
+ } else if (trailing == -1) {
+ if (path.right(1) == "/" && path.length() > 1) {
+ path = path.left(path.length()-1);
+ }
+ }
+
+ result += path;
+ result += d->sQuery;
+
+ if (!d->sRef.isEmpty()) {
+ result += "#" + d->sRef;
+ }
+
+ return result;
+}
+
+
+KURL &KURL::operator=(const KURL &other)
+{
+ KURL tmp(other);
+ KWQRefPtr<KURL::KWQKURLPrivate> tmpD = tmp.d;
+
+ tmp.d = d;
+ d = tmpD;
+
+ return *this;
+}
+
+
+
+QString KURL::decode_string(const QString &urlString)
+{
+ CFStringRef unescaped = CFURLCreateStringByReplacingPercentEscapes(NULL, urlString.getCFMutableString(), CFSTR(""));
+ QString qUnescaped = QString::fromCFString(unescaped);
+ CFRelease(unescaped);
+
+ return qUnescaped;
+}
+
+
+void KURL::copyOnWrite()
+{
+ if (d->refCount > 1) {
+ d = KWQRefPtr<KURL::KWQKURLPrivate>(new KURL::KWQKURLPrivate(*d));
+ }
+}
+
+
+#endif
+
diff --git a/WebCore/src/kwq/Makefile.am b/WebCore/src/kwq/Makefile.am
index f34950e..8d73785 100644
--- a/WebCore/src/kwq/Makefile.am
+++ b/WebCore/src/kwq/Makefile.am
@@ -79,6 +79,7 @@ libkwq_o_SOURCES = \
KWQKScheduler.mm \
KWQKSimpleConfig.mm \
KWQKStringHandler.mm \
+ KWQKURL.mm \
KWQKWin.mm \
KWQKWinModule.mm \
KWQKjobclasses.mm \
diff --git a/WebCore/src/kwq/kde/_kurl.cpp b/WebCore/src/kwq/kde/_kurl.cpp
index d0181e1..10c728d 100644
--- a/WebCore/src/kwq/kde/_kurl.cpp
+++ b/WebCore/src/kwq/kde/_kurl.cpp
@@ -17,7 +17,8 @@
Boston, MA 02111-1307, USA.
*/
-#include "_kurl.h"
+#include <kurl.h>
+
#include <kdebug.h>
#include <kglobal.h>
diff --git a/WebCore/src/kwq/kdecore/kurl.h b/WebCore/src/kwq/kdecore/kurl.h
index 823da9e..c3aec6b 100644
--- a/WebCore/src/kwq/kdecore/kurl.h
+++ b/WebCore/src/kwq/kdecore/kurl.h
@@ -39,6 +39,7 @@
#else
#include <qstring.h>
+#include <KWQRefPtr.h>
// FIXME: this clever hack may need to be moved into KWQDef.h or elsewhere
#define Fixed MacFixed
@@ -60,10 +61,12 @@ public:
// constants ---------------------------------------------------------------
// static member functions -------------------------------------------------
+ static QString decode_string(const QString &urlString);
+
// constructors, copy constructors, and destructors ------------------------
KURL();
- KURL(const char *url, int encoding_hint=0);
+ KURL(const char *, int encoding_hint=0);
KURL(const KURL &, const QString &);
KURL(const QString &, int encoding_hint=0);
KURL(const KURL &);
@@ -103,22 +106,11 @@ public:
// private ---------------------------------------------------------------------
private:
-
- void init();
-
- CFURLRef urlRef;
- bool malformed;
- QString sURL;
- QString sProtocol;
- QString sHost;
- unsigned short int iPort;
- QString sPass;
- QString sUser;
- QString sRef;
- QString sQuery;
- QString sPath;
+ void copyOnWrite();
+ class KWQKURLPrivate;
+ KWQRefPtr<KWQKURLPrivate> d;
}; // class KURL ===============================================================
#endif
diff --git a/WebCore/src/kwq/qt/_qurl.cpp b/WebCore/src/kwq/qt/_qurl.cpp
index a82de3c..28efc96 100644
--- a/WebCore/src/kwq/qt/_qurl.cpp
+++ b/WebCore/src/kwq/qt/_qurl.cpp
@@ -36,6 +36,9 @@
**********************************************************************/
#include "_qurl.h"
+#include <config.h>
+
+#ifdef USING_BORROWED_KURL
#ifndef QT_NO_DIR
@@ -1165,3 +1168,6 @@ bool QUrl::cdUp()
}
#endif // QT_NO_NETWORKPROTOCOL
+
+#endif USING_BORROWED_KURL
+
diff --git a/WebCore/src/kwq/qt/_qurl.h b/WebCore/src/kwq/qt/_qurl.h
index 3b212aa..1a1d951 100644
--- a/WebCore/src/kwq/qt/_qurl.h
+++ b/WebCore/src/kwq/qt/_qurl.h
@@ -38,6 +38,10 @@
#ifndef QURL_H
#define QURL_H
+#include <config.h>
+
+#ifdef USING_BORROWED_KURL
+
#ifndef QT_H
#include "qstring.h"
#include "_qdir.h"
@@ -120,4 +124,6 @@ private:
};
+#endif USING_BORROWED_URL
+
#endif
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list