[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:31 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 20320915db9bd218b0876555dfe2aabc2c498954
Author: mjs <mjs at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 12 08:46:37 2002 +0000

    	* borrowed-classes.txt: Stopped borrowing QVector, QList,
    	QCollection and QTL.
    
    	Extended tests for QList, QSortedList (to test QList::sort more
    	thoroughly) and QVector. Especially excercise autodeletion
    	semantics and corner cases more thoroughly.
    
    	* Tests/qt/qlist-test.chk:
    	* Tests/qt/qlist-test.cpp: (operator<<), (main):
    	* Tests/qt/qsortedlist-test.chk:
    	* Tests/qt/qsortedlist-test.cpp: (main):
    	* Tests/qt/qvector-test.chk:
    	* Tests/qt/qvector-test.cpp: (operator<<), (printVectorNullTolerant), (main):
    
    	* Tests/qt/qmap-test.cpp (CheckRedBlackRules): Tweak a bit to
    	violate QMap's abstraction for glass-box testing.
    WebCore:
    	Reimplemented QList, QVector and QCollection from
    	scratch. Implemented copy-on-write optimization for QMap.
    
    	Minimally reimplement QCollection.
    
    	* src/kwq/qt/qcollection.h:
    	* src/kwq/KWQCollection.mm: (QCollection::QCollection), (QCollection::operator=),
    	(QCollection::~QCollection), (QCollection::autoDelete),
    	(QCollection::setAutoDelete):
    
    	* src/kwq/qt/qdict.h, src/kwq/qt/qptrdict.h: Include
    	qcollection.h, not _qcollection.h
    
    	Reimplement QList as a doubly-linked list.
    
    	* src/kwq/qt/qlist.h:
    	* src/kwq/KWQListImpl.h:
    	* src/kwq/KWQListImpl.mm: (KWQListImpl::KWQListPrivate::copyList),
    	(KWQListImpl::KWQListPrivate::KWQListPrivate),
    	(KWQListImpl::KWQListPrivate::~KWQListPrivate),
    	(KWQListIteratorImpl::KWQListIteratorPrivate::KWQListIteratorPrivate),
    	(KWQListImpl::KWQListImpl), (KWQListImpl::~KWQListImpl), (KWQListImpl::isEmpty),
    	(KWQListImpl::count), (KWQListImpl::clear), (KWQListImpl::sort),
    	(KWQListImpl::at), (KWQListImpl::insert), (KWQListImpl::remove),
    	(KWQListImpl::removeFirst), (KWQListImpl::removeLast), (KWQListImpl::removeRef),
    	(KWQListImpl::getLast), (KWQListImpl::current), (KWQListImpl::first),
    	(KWQListImpl::last), (KWQListImpl::next), (KWQListImpl::prev),
    	(KWQListImpl::take), (KWQListImpl::append), (KWQListImpl::prepend),
    	(KWQListImpl::containsRef), (KWQListImpl::assign), (KWQListImpl::addIterator),
    	(KWQListImpl::removeIterator), (KWQListIteratorImpl::KWQListIteratorImpl),
    	(KWQListIteratorImpl::~KWQListIteratorImpl), (KWQListIteratorImpl::count),
    	(KWQListIteratorImpl::toFirst), (KWQListIteratorImpl::toLast),
    	(KWQListIteratorImpl::current), (KWQListIteratorImpl::operator--),
    	(KWQListIteratorImpl::operator++), (KWQListIteratorImpl::operator=):
    
    	Reimplement QVector in terms of CFArray.
    
    	* src/kwq/qt/qvector.h:
    	* src/kwq/KWQVectorImpl.h:
    	* src/kwq/KWQVectorImpl.mm: (KWQVectorImpl::KWQVectorPrivate::KWQVectorPrivate),
    	(KWQVectorImpl::KWQVectorPrivate::~KWQVectorPrivate),
    	(KWQVectorImpl::KWQVectorImpl), (KWQVectorImpl::~KWQVectorImpl),
    	(KWQVectorImpl::clear), (KWQVectorImpl::isEmpty), (KWQVectorImpl::count),
    	(KWQVectorImpl::size), (KWQVectorImpl::remove), (KWQVectorImpl::resize),
    	(KWQVectorImpl::insert), (KWQVectorImpl::at), (KWQVectorImpl::assign),
    	(KWQVectorImpl::KWQVectorImpl::swap):
    
    	Implemented copy-on-write optimization for QMap. This had the
    	pleasant side effect of improving the separation between pointer
    	manipulation and key/value manipulation.
    
    	* src/kwq/qt/qmap.h:
    	* src/kwq/KWQMapImpl.h:
    	* src/kwq/KWQMapImpl.mm: (KWQMapImpl::KWQMapPrivate::KWQMapPrivate),
    	(KWQMapImpl::KWQMapPrivate::~KWQMapPrivate), (KWQMapImpl::KWQMapImpl),
    	(KWQMapImpl::~KWQMapImpl), (KWQMapImpl::copyOnWrite), (KWQMapImpl::copyTree),
    	(KWQMapImpl::rebalanceAfterInsert), (KWQMapImpl::rebalanceAfterRemove),
    	(KWQMapImpl::findInternal), (KWQMapImpl::insertInternal),
    	(KWQMapImpl::removeInternal), (KWQMapImpl::swap), (KWQMapImpl::countInternal),
    	(KWQMapImpl::clearInternal), (KWQMapImpl::beginInternal),
    	(KWQMapImpl::endInternal):
    
    	* src/kwq/Makefile.am: Add new files to build.
    
    	* src/kdelibs/khtml/rendering/render_text.cpp
    	(TextSlaveArray::findFirstMatching): Fix two places where the KDE
    	code was depending on implementation details of QVector.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@612 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index e63f264..3ad7810 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,73 @@
+2002-02-12  Maciej Stachowiak  <mjs at apple.com>
+
+	Reimplemented QList, QVector and QCollection from
+	scratch. Implemented copy-on-write optimization for QMap.
+
+	Minimally reimplement QCollection.
+
+	* src/kwq/qt/qcollection.h:
+	* src/kwq/KWQCollection.mm: (QCollection::QCollection), (QCollection::operator=),
+	(QCollection::~QCollection), (QCollection::autoDelete),
+	(QCollection::setAutoDelete):
+
+	* src/kwq/qt/qdict.h, src/kwq/qt/qptrdict.h: Include
+	qcollection.h, not _qcollection.h
+
+	Reimplement QList as a doubly-linked list.
+	
+	* src/kwq/qt/qlist.h:
+	* src/kwq/KWQListImpl.h:
+	* src/kwq/KWQListImpl.mm: (KWQListImpl::KWQListPrivate::copyList),
+	(KWQListImpl::KWQListPrivate::KWQListPrivate),
+	(KWQListImpl::KWQListPrivate::~KWQListPrivate),
+	(KWQListIteratorImpl::KWQListIteratorPrivate::KWQListIteratorPrivate),
+	(KWQListImpl::KWQListImpl), (KWQListImpl::~KWQListImpl), (KWQListImpl::isEmpty),
+	(KWQListImpl::count), (KWQListImpl::clear), (KWQListImpl::sort),
+	(KWQListImpl::at), (KWQListImpl::insert), (KWQListImpl::remove),
+	(KWQListImpl::removeFirst), (KWQListImpl::removeLast), (KWQListImpl::removeRef),
+	(KWQListImpl::getLast), (KWQListImpl::current), (KWQListImpl::first),
+	(KWQListImpl::last), (KWQListImpl::next), (KWQListImpl::prev),
+	(KWQListImpl::take), (KWQListImpl::append), (KWQListImpl::prepend),
+	(KWQListImpl::containsRef), (KWQListImpl::assign), (KWQListImpl::addIterator),
+	(KWQListImpl::removeIterator), (KWQListIteratorImpl::KWQListIteratorImpl),
+	(KWQListIteratorImpl::~KWQListIteratorImpl), (KWQListIteratorImpl::count),
+	(KWQListIteratorImpl::toFirst), (KWQListIteratorImpl::toLast),
+	(KWQListIteratorImpl::current), (KWQListIteratorImpl::operator--),
+	(KWQListIteratorImpl::operator++), (KWQListIteratorImpl::operator=):
+
+	Reimplement QVector in terms of CFArray.
+	
+	* src/kwq/qt/qvector.h:
+	* src/kwq/KWQVectorImpl.h:
+	* src/kwq/KWQVectorImpl.mm: (KWQVectorImpl::KWQVectorPrivate::KWQVectorPrivate),
+	(KWQVectorImpl::KWQVectorPrivate::~KWQVectorPrivate),
+	(KWQVectorImpl::KWQVectorImpl), (KWQVectorImpl::~KWQVectorImpl),
+	(KWQVectorImpl::clear), (KWQVectorImpl::isEmpty), (KWQVectorImpl::count),
+	(KWQVectorImpl::size), (KWQVectorImpl::remove), (KWQVectorImpl::resize),
+	(KWQVectorImpl::insert), (KWQVectorImpl::at), (KWQVectorImpl::assign),
+	(KWQVectorImpl::KWQVectorImpl::swap):
+
+	Implemented copy-on-write optimization for QMap. This had the
+	pleasant side effect of improving the separation between pointer
+	manipulation and key/value manipulation.
+
+	* src/kwq/qt/qmap.h:
+	* src/kwq/KWQMapImpl.h:
+	* src/kwq/KWQMapImpl.mm: (KWQMapImpl::KWQMapPrivate::KWQMapPrivate),
+	(KWQMapImpl::KWQMapPrivate::~KWQMapPrivate), (KWQMapImpl::KWQMapImpl),
+	(KWQMapImpl::~KWQMapImpl), (KWQMapImpl::copyOnWrite), (KWQMapImpl::copyTree),
+	(KWQMapImpl::rebalanceAfterInsert), (KWQMapImpl::rebalanceAfterRemove),
+	(KWQMapImpl::findInternal), (KWQMapImpl::insertInternal),
+	(KWQMapImpl::removeInternal), (KWQMapImpl::swap), (KWQMapImpl::countInternal),
+	(KWQMapImpl::clearInternal), (KWQMapImpl::beginInternal),
+	(KWQMapImpl::endInternal):
+
+	* src/kwq/Makefile.am: Add new files to build.
+
+	* src/kdelibs/khtml/rendering/render_text.cpp
+	(TextSlaveArray::findFirstMatching): Fix two places where the KDE
+	code was depending on implementation details of QVector.
+
 2002-02-07  Richard Williamson  <rjw at apple.com>
 
     More changes to IFLocationChangeHandler API.
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index e63f264..3ad7810 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,73 @@
+2002-02-12  Maciej Stachowiak  <mjs at apple.com>
+
+	Reimplemented QList, QVector and QCollection from
+	scratch. Implemented copy-on-write optimization for QMap.
+
+	Minimally reimplement QCollection.
+
+	* src/kwq/qt/qcollection.h:
+	* src/kwq/KWQCollection.mm: (QCollection::QCollection), (QCollection::operator=),
+	(QCollection::~QCollection), (QCollection::autoDelete),
+	(QCollection::setAutoDelete):
+
+	* src/kwq/qt/qdict.h, src/kwq/qt/qptrdict.h: Include
+	qcollection.h, not _qcollection.h
+
+	Reimplement QList as a doubly-linked list.
+	
+	* src/kwq/qt/qlist.h:
+	* src/kwq/KWQListImpl.h:
+	* src/kwq/KWQListImpl.mm: (KWQListImpl::KWQListPrivate::copyList),
+	(KWQListImpl::KWQListPrivate::KWQListPrivate),
+	(KWQListImpl::KWQListPrivate::~KWQListPrivate),
+	(KWQListIteratorImpl::KWQListIteratorPrivate::KWQListIteratorPrivate),
+	(KWQListImpl::KWQListImpl), (KWQListImpl::~KWQListImpl), (KWQListImpl::isEmpty),
+	(KWQListImpl::count), (KWQListImpl::clear), (KWQListImpl::sort),
+	(KWQListImpl::at), (KWQListImpl::insert), (KWQListImpl::remove),
+	(KWQListImpl::removeFirst), (KWQListImpl::removeLast), (KWQListImpl::removeRef),
+	(KWQListImpl::getLast), (KWQListImpl::current), (KWQListImpl::first),
+	(KWQListImpl::last), (KWQListImpl::next), (KWQListImpl::prev),
+	(KWQListImpl::take), (KWQListImpl::append), (KWQListImpl::prepend),
+	(KWQListImpl::containsRef), (KWQListImpl::assign), (KWQListImpl::addIterator),
+	(KWQListImpl::removeIterator), (KWQListIteratorImpl::KWQListIteratorImpl),
+	(KWQListIteratorImpl::~KWQListIteratorImpl), (KWQListIteratorImpl::count),
+	(KWQListIteratorImpl::toFirst), (KWQListIteratorImpl::toLast),
+	(KWQListIteratorImpl::current), (KWQListIteratorImpl::operator--),
+	(KWQListIteratorImpl::operator++), (KWQListIteratorImpl::operator=):
+
+	Reimplement QVector in terms of CFArray.
+	
+	* src/kwq/qt/qvector.h:
+	* src/kwq/KWQVectorImpl.h:
+	* src/kwq/KWQVectorImpl.mm: (KWQVectorImpl::KWQVectorPrivate::KWQVectorPrivate),
+	(KWQVectorImpl::KWQVectorPrivate::~KWQVectorPrivate),
+	(KWQVectorImpl::KWQVectorImpl), (KWQVectorImpl::~KWQVectorImpl),
+	(KWQVectorImpl::clear), (KWQVectorImpl::isEmpty), (KWQVectorImpl::count),
+	(KWQVectorImpl::size), (KWQVectorImpl::remove), (KWQVectorImpl::resize),
+	(KWQVectorImpl::insert), (KWQVectorImpl::at), (KWQVectorImpl::assign),
+	(KWQVectorImpl::KWQVectorImpl::swap):
+
+	Implemented copy-on-write optimization for QMap. This had the
+	pleasant side effect of improving the separation between pointer
+	manipulation and key/value manipulation.
+
+	* src/kwq/qt/qmap.h:
+	* src/kwq/KWQMapImpl.h:
+	* src/kwq/KWQMapImpl.mm: (KWQMapImpl::KWQMapPrivate::KWQMapPrivate),
+	(KWQMapImpl::KWQMapPrivate::~KWQMapPrivate), (KWQMapImpl::KWQMapImpl),
+	(KWQMapImpl::~KWQMapImpl), (KWQMapImpl::copyOnWrite), (KWQMapImpl::copyTree),
+	(KWQMapImpl::rebalanceAfterInsert), (KWQMapImpl::rebalanceAfterRemove),
+	(KWQMapImpl::findInternal), (KWQMapImpl::insertInternal),
+	(KWQMapImpl::removeInternal), (KWQMapImpl::swap), (KWQMapImpl::countInternal),
+	(KWQMapImpl::clearInternal), (KWQMapImpl::beginInternal),
+	(KWQMapImpl::endInternal):
+
+	* src/kwq/Makefile.am: Add new files to build.
+
+	* src/kdelibs/khtml/rendering/render_text.cpp
+	(TextSlaveArray::findFirstMatching): Fix two places where the KDE
+	code was depending on implementation details of QVector.
+
 2002-02-07  Richard Williamson  <rjw at apple.com>
 
     More changes to IFLocationChangeHandler API.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index e63f264..3ad7810 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,73 @@
+2002-02-12  Maciej Stachowiak  <mjs at apple.com>
+
+	Reimplemented QList, QVector and QCollection from
+	scratch. Implemented copy-on-write optimization for QMap.
+
+	Minimally reimplement QCollection.
+
+	* src/kwq/qt/qcollection.h:
+	* src/kwq/KWQCollection.mm: (QCollection::QCollection), (QCollection::operator=),
+	(QCollection::~QCollection), (QCollection::autoDelete),
+	(QCollection::setAutoDelete):
+
+	* src/kwq/qt/qdict.h, src/kwq/qt/qptrdict.h: Include
+	qcollection.h, not _qcollection.h
+
+	Reimplement QList as a doubly-linked list.
+	
+	* src/kwq/qt/qlist.h:
+	* src/kwq/KWQListImpl.h:
+	* src/kwq/KWQListImpl.mm: (KWQListImpl::KWQListPrivate::copyList),
+	(KWQListImpl::KWQListPrivate::KWQListPrivate),
+	(KWQListImpl::KWQListPrivate::~KWQListPrivate),
+	(KWQListIteratorImpl::KWQListIteratorPrivate::KWQListIteratorPrivate),
+	(KWQListImpl::KWQListImpl), (KWQListImpl::~KWQListImpl), (KWQListImpl::isEmpty),
+	(KWQListImpl::count), (KWQListImpl::clear), (KWQListImpl::sort),
+	(KWQListImpl::at), (KWQListImpl::insert), (KWQListImpl::remove),
+	(KWQListImpl::removeFirst), (KWQListImpl::removeLast), (KWQListImpl::removeRef),
+	(KWQListImpl::getLast), (KWQListImpl::current), (KWQListImpl::first),
+	(KWQListImpl::last), (KWQListImpl::next), (KWQListImpl::prev),
+	(KWQListImpl::take), (KWQListImpl::append), (KWQListImpl::prepend),
+	(KWQListImpl::containsRef), (KWQListImpl::assign), (KWQListImpl::addIterator),
+	(KWQListImpl::removeIterator), (KWQListIteratorImpl::KWQListIteratorImpl),
+	(KWQListIteratorImpl::~KWQListIteratorImpl), (KWQListIteratorImpl::count),
+	(KWQListIteratorImpl::toFirst), (KWQListIteratorImpl::toLast),
+	(KWQListIteratorImpl::current), (KWQListIteratorImpl::operator--),
+	(KWQListIteratorImpl::operator++), (KWQListIteratorImpl::operator=):
+
+	Reimplement QVector in terms of CFArray.
+	
+	* src/kwq/qt/qvector.h:
+	* src/kwq/KWQVectorImpl.h:
+	* src/kwq/KWQVectorImpl.mm: (KWQVectorImpl::KWQVectorPrivate::KWQVectorPrivate),
+	(KWQVectorImpl::KWQVectorPrivate::~KWQVectorPrivate),
+	(KWQVectorImpl::KWQVectorImpl), (KWQVectorImpl::~KWQVectorImpl),
+	(KWQVectorImpl::clear), (KWQVectorImpl::isEmpty), (KWQVectorImpl::count),
+	(KWQVectorImpl::size), (KWQVectorImpl::remove), (KWQVectorImpl::resize),
+	(KWQVectorImpl::insert), (KWQVectorImpl::at), (KWQVectorImpl::assign),
+	(KWQVectorImpl::KWQVectorImpl::swap):
+
+	Implemented copy-on-write optimization for QMap. This had the
+	pleasant side effect of improving the separation between pointer
+	manipulation and key/value manipulation.
+
+	* src/kwq/qt/qmap.h:
+	* src/kwq/KWQMapImpl.h:
+	* src/kwq/KWQMapImpl.mm: (KWQMapImpl::KWQMapPrivate::KWQMapPrivate),
+	(KWQMapImpl::KWQMapPrivate::~KWQMapPrivate), (KWQMapImpl::KWQMapImpl),
+	(KWQMapImpl::~KWQMapImpl), (KWQMapImpl::copyOnWrite), (KWQMapImpl::copyTree),
+	(KWQMapImpl::rebalanceAfterInsert), (KWQMapImpl::rebalanceAfterRemove),
+	(KWQMapImpl::findInternal), (KWQMapImpl::insertInternal),
+	(KWQMapImpl::removeInternal), (KWQMapImpl::swap), (KWQMapImpl::countInternal),
+	(KWQMapImpl::clearInternal), (KWQMapImpl::beginInternal),
+	(KWQMapImpl::endInternal):
+
+	* src/kwq/Makefile.am: Add new files to build.
+
+	* src/kdelibs/khtml/rendering/render_text.cpp
+	(TextSlaveArray::findFirstMatching): Fix two places where the KDE
+	code was depending on implementation details of QVector.
+
 2002-02-07  Richard Williamson  <rjw at apple.com>
 
     More changes to IFLocationChangeHandler API.
diff --git a/WebCore/khtml/rendering/render_text.cpp b/WebCore/khtml/rendering/render_text.cpp
index 193607b..149311c 100644
--- a/WebCore/khtml/rendering/render_text.cpp
+++ b/WebCore/khtml/rendering/render_text.cpp
@@ -265,7 +265,7 @@ int TextSlaveArray::findFirstMatching(Item d) const
 	if ( (*this)[mid] == 0 )			// null item greater
 	    res = -1;
 	else
-	    res = ((QGVector*)this)->compareItems( d, (*this)[mid] );
+	    res = ((TextSlaveArray*)this)->compareItems( d, (*this)[mid] );
 	if ( res < 0 )
 	    n2 = mid - 1;
 	else if ( res > 0 )
@@ -278,7 +278,7 @@ int TextSlaveArray::findFirstMatching(Item d) const
     /* if ( !found )
 	return -1; */
     // search to first one equal or bigger
-    while ( found && (mid > 0) && !((QGVector*)this)->compareItems(d, (*this)[mid-1]) )
+    while ( found && (mid > 0) && !((TextSlaveArray*)this)->compareItems(d, (*this)[mid-1]) )
 	mid--;
     return mid;
 }
diff --git a/WebCore/src/kwq/qt/_qcollection.h b/WebCore/kwq/KWQCollection.h
similarity index 66%
copy from WebCore/src/kwq/qt/_qcollection.h
copy to WebCore/kwq/KWQCollection.h
index 63d676e..e91b1d7 100644
--- a/WebCore/src/kwq/qt/_qcollection.h
+++ b/WebCore/kwq/KWQCollection.h
@@ -38,37 +38,32 @@
 #ifndef QCOLLECTION_H
 #define QCOLLECTION_H
 
-// KWQ hacks ---------------------------------------------------------------
+#include <config.h>
 
 #include <KWQDef.h>
 
-// -------------------------------------------------------------------------
+#ifdef USING_BORROWED_QCOLLECTION
 
-class QGVector;
-class QGList;
-class QGDict;
+#include <_qcollection.h>
 
-class Q_EXPORT QCollection			// inherited by all collections
-{
-public:
-    bool autoDelete()	const	       { return del_item; }
-    void setAutoDelete( bool enable )  { del_item = enable; }
+#else
 
-    virtual uint  count() const = 0;
-    virtual void  clear() = 0;			// delete all objects
+class QCollection {
+ public:
+    typedef void *Item;
 
-    typedef void *Item;				// generic collection item
-
-protected:
-    QCollection() { del_item = FALSE; }		// no deletion of objects
-    QCollection(const QCollection &) { del_item = FALSE; }
-    virtual ~QCollection() {}
+    bool autoDelete();
+    void setAutoDelete(bool autoDelete);
+ protected:
+    QCollection();
+    QCollection(const QCollection &);
+    QCollection &operator=(const QCollection &);
+    virtual ~QCollection();
 
     bool del_item;				// default FALSE
-
-    virtual Item     newItem( Item );		// create object
-    virtual void     deleteItem( Item );	// delete object
 };
 
+#endif /* USING_BORROWED_QCOLLECTION */
+
+#endif /* QCOLLECTION_H */
 
-#endif // QCOLLECTION_H
diff --git a/WebCore/kwq/KWQFrame.mm b/WebCore/kwq/KWQCollection.mm
similarity index 75%
copy from WebCore/kwq/KWQFrame.mm
copy to WebCore/kwq/KWQCollection.mm
index 292156a..886d0fe 100644
--- a/WebCore/kwq/KWQFrame.mm
+++ b/WebCore/kwq/KWQCollection.mm
@@ -22,44 +22,39 @@
  * (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 <KWQFrame.h>
 
-#include <kwqdebug.h>
+#include <qcollection.h>
 
-QFrame::QFrame()
+#ifndef USING_BORROWED_QCOLLECTION
+
+QCollection::QCollection() :
+    del_item(FALSE)
 {
-    _logNeverImplemented();
 }
 
-
-QFrame::QFrame(QWidget *parent)
+QCollection::QCollection(const QCollection &other) :
+    del_item(FALSE)
 {
-    _logNeverImplemented();
 }
 
-
-void QFrame::setFrameStyle(int)
+QCollection &QCollection::operator=(const QCollection &other)
 {
-    _logNeverImplemented();
+    return *this; // don't copy del_item
 }
 
-
-int QFrame::frameWidth() const
+QCollection::~QCollection()
 {
-    _logNeverImplemented();
-    return 0;
 }
 
-
-QFrame::QFrame(const QFrame &)
+bool QCollection::autoDelete()
 {
-    _logNeverImplemented();
+    return del_item;
 }
 
-
-QFrame &QFrame::operator=(const QFrame &)
+void QCollection::setAutoDelete(bool autoDelete)
 {
-    _logNeverImplemented();
-    return *this;
+    del_item = autoDelete;
 }
 
+#endif
+
diff --git a/WebCore/kwq/KWQDict.h b/WebCore/kwq/KWQDict.h
index a3ee0f4..a496550 100644
--- a/WebCore/kwq/KWQDict.h
+++ b/WebCore/kwq/KWQDict.h
@@ -39,7 +39,7 @@
 #else
 
 
-#include <_qcollection.h>
+#include <qcollection.h>
 #include <qstring.h>
 
 #include <KWQDictImpl.h>
diff --git a/WebCore/kwq/KWQListImpl.h b/WebCore/kwq/KWQListImpl.h
new file mode 100644
index 0000000..8ad0f50
--- /dev/null
+++ b/WebCore/kwq/KWQListImpl.h
@@ -0,0 +1,114 @@
+/*
+ * 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. 
+ */
+
+#ifndef KWQ_LIST_IMPL_H
+#define KWQ_LIST_IMPL_H
+
+#include <config.h>
+#include <KWQDef.h>
+
+#ifndef USING_BORROWED_QLIST
+
+class KWQListIteratorImpl;
+
+class KWQListImpl
+{
+public:
+    
+    KWQListImpl(void (*deleteFunc)(void *));
+    KWQListImpl(const KWQListImpl &impl);
+    ~KWQListImpl();
+     
+    bool isEmpty() const;
+    uint count() const;
+    void clear(bool deleteItems);
+    void sort(int (*compareFunc)(void *a, void *b, void *data), void *data); 
+
+    void *at(uint n);
+
+    bool insert(uint n, const void *item);
+    bool remove(bool deleteItem);
+    bool remove(uint n, bool deleteItem);
+    bool remove(const void *item, bool deleteItem, int (*compareFunc)(void *a, void *b, void *data), void *data);
+    bool removeFirst(bool deleteItem);
+    bool removeLast(bool deleteItem);
+    bool removeRef(const void *item, bool deleteItem);
+
+    void *getLast() const;
+    void *current() const;
+    void *first();
+    void *last();
+    void *next();
+    void *prev();
+    void *take(uint n);
+
+    void append(const void *item);
+    void prepend(const void *item);
+
+    uint containsRef(const void *item) const;
+
+    KWQListImpl &assign(const KWQListImpl &impl, bool deleteItems);
+
+ private:
+    void addIterator(KWQListIteratorImpl *iter) const;
+    void removeIterator(KWQListIteratorImpl *iter) const;
+
+    class KWQListPrivate;
+    KWQListPrivate *d;
+
+    friend class KWQListIteratorImpl;
+}; 
+
+
+class KWQListIteratorImpl {
+public:
+    KWQListIteratorImpl();
+    KWQListIteratorImpl(const KWQListImpl &impl);
+    KWQListIteratorImpl(const KWQListIteratorImpl &impl);
+    ~KWQListIteratorImpl();
+
+    uint count() const;
+    void *toFirst();
+    void *toLast();
+    void *current() const;
+
+    // operators ---------------------------------------------------------------
+
+    void *operator--();
+    void *operator++();
+
+    KWQListIteratorImpl &operator=(const KWQListIteratorImpl &impl);
+
+private:
+    class KWQListIteratorPrivate;
+
+    KWQListIteratorPrivate *d;
+
+    friend class KWQListImpl;
+};
+
+#endif
+
+#endif
diff --git a/WebCore/kwq/KWQListImpl.mm b/WebCore/kwq/KWQListImpl.mm
new file mode 100644
index 0000000..af65c29
--- /dev/null
+++ b/WebCore/kwq/KWQListImpl.mm
@@ -0,0 +1,599 @@
+/*
+ * 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 <KWQListImpl.h>
+
+#ifndef USING_BORROWED_QLIST
+
+#include <cstddef>
+
+#define Fixed MacFixed
+#define Rect MacRect
+#define Boolean MacBoolean
+#include <CoreFoundation/CFArray.h>
+#undef Fixed
+#undef Rect
+#undef Boolean
+
+// KWQListNode
+
+class KWQListNode
+{
+public:
+    KWQListNode() : data(NULL), next(NULL), prev(NULL) {}
+
+    void *data;
+    KWQListNode *next;
+    KWQListNode *prev;
+};
+
+
+// KWQListImpl::KWQListPrivate
+
+class KWQListImpl::KWQListPrivate
+{
+public:
+    KWQListPrivate(void (*deleteFunc)(void *));
+    KWQListPrivate(KWQListPrivate &vp);
+    ~KWQListPrivate();
+    
+    static KWQListNode *copyList(KWQListNode *l);
+
+    KWQListNode *head;
+    // KWQListNode *tail;
+    KWQListNode *current;
+    uint count;
+    void (*deleteItem)(void *);
+    KWQListNode *iterators;
+};
+
+KWQListNode *KWQListImpl::KWQListPrivate::copyList(KWQListNode *l)
+{
+    KWQListNode *node = l;
+    KWQListNode *head = NULL;
+    KWQListNode *last = NULL;
+
+    while (node != NULL) {
+	KWQListNode *copy = new KWQListNode;
+	copy->data = node->data;
+	if (last != NULL) {
+	    last->next = copy;
+	    copy->prev = last;
+	} else {
+	    head = copy;
+	    copy->prev = NULL;
+	}
+	copy->next = NULL;
+	
+	last = copy;
+	node = node->next;
+    }
+
+    return head;
+}
+
+KWQListImpl::KWQListPrivate::KWQListPrivate(void (*deleteFunc)(void *)) :
+    head(NULL),
+    current(NULL),
+    count(0),
+    deleteItem(deleteFunc),
+    iterators(NULL)
+{
+}
+
+KWQListImpl::KWQListPrivate::KWQListPrivate(KWQListPrivate &vp) :
+    head(copyList(vp.head)),
+    current(NULL),
+    count(vp.count),
+    deleteItem(vp.deleteItem),
+    iterators(NULL)
+{
+}
+
+KWQListImpl::KWQListPrivate::~KWQListPrivate()
+{
+    while (head != NULL) {
+	KWQListNode *tmp = head->next;
+	delete head;
+	head = tmp;
+    }
+}
+
+// KWQListIteratorImpl::KWQListIteratorPrivate
+
+class KWQListIteratorImpl::KWQListIteratorPrivate
+{
+public:
+    KWQListIteratorPrivate();
+    KWQListIteratorPrivate(const KWQListImpl &list, KWQListNode *n);
+
+    const KWQListImpl *list;
+    KWQListNode *node;
+};
+
+KWQListIteratorImpl::KWQListIteratorPrivate::KWQListIteratorPrivate() :
+    list(NULL),
+    node(NULL)
+{
+}
+
+KWQListIteratorImpl::KWQListIteratorPrivate::KWQListIteratorPrivate(const KWQListImpl &l, KWQListNode *n) :
+    list(&l),
+    node(n)
+{
+}
+
+
+
+// KWQListImpl
+
+KWQListImpl::KWQListImpl(void (*deleteFunc)(void *)) :
+    d(new KWQListImpl::KWQListPrivate(deleteFunc))
+{
+}
+
+KWQListImpl::KWQListImpl(const KWQListImpl &impl) :
+    d(new KWQListImpl::KWQListPrivate(*impl.d))
+{
+}
+
+KWQListImpl::~KWQListImpl()
+{
+    delete d;
+}
+     
+bool KWQListImpl::isEmpty() const
+{
+    return d->count == 0;
+}
+
+uint KWQListImpl::count() const
+{
+    return d->count;
+}
+
+void KWQListImpl::clear(bool deleteItems)
+{
+    if (deleteItems) {
+	KWQListNode *node = d->head;
+
+	while (node != NULL) {
+	    d->deleteItem(node->data);
+	    node = node->next;
+	}
+    }
+
+    delete d->head;
+    d->head = NULL;
+    d->current = NULL;
+    d->count = 0;
+}
+
+void KWQListImpl::sort(int (*compareFunc)(void *a, void *b, void *data), void *data)
+{
+    CFMutableArrayRef array = CFArrayCreateMutable(NULL, d->count, NULL);
+
+    for (KWQListNode *node = d->head; node != NULL; node = node->next) {
+	CFArrayAppendValue(array, node->data);
+    }
+
+    CFArraySortValues(array, CFRangeMake(0, d->count), (CFComparatorFunction) compareFunc, data);
+
+    int i = 0;
+    for (KWQListNode *node = d->head; node != NULL; node = node->next) {
+	node->data = (void *)CFArrayGetValueAtIndex(array, i);
+	i++;
+    }
+}
+
+void *KWQListImpl::at(uint n)
+{
+    d->current = d->head;
+    uint i = 0; 
+
+    while (i < n && d->current != NULL) {
+	d->current = d->current->next;
+	i++;
+    }
+
+    return d->current->data;
+}
+
+bool KWQListImpl::insert(uint n, const void *item)
+{
+    if (n > d->count) {
+	return false;
+    }
+
+    d->current = new KWQListNode;
+    d->current->data = (void *)item;
+
+    if (n == 0) {
+	// inserting at head
+	d->current->next = d->head;
+	if (d->head != NULL) {
+	    d->head->prev = d->current;
+	}
+	d->head = d->current;
+    } else {
+	// general insertion
+	
+	// iterate to one node before the insertion point, can't be null
+	// since we know n > 0 and n <= d->count
+	KWQListNode *node = d->head;
+
+	for  (unsigned i = 0; i < n - 1; i++) {
+	    node = node->next;
+	}
+	d->current->prev = node;
+	d->current->next = node->next;
+	if (node->next != NULL) {
+	    node->next->prev = d->current;
+	}
+	node->next = d->current;
+    }
+
+    d->count++;
+    return true;
+}
+
+bool KWQListImpl::remove(bool deleteItem)
+{
+    if (d->current == NULL) {
+	return false;
+    }
+
+    if (d->head == d->current) {
+	d->head = d->current->next;
+    } else {
+	d->current->prev->next = d->current->next;
+    }
+
+    if (d->current->next != NULL) {
+	d->current->next->prev = d->current->prev;
+    }
+
+    KWQListNode *detached = d->current;
+    if (detached->next != NULL) {
+	d->current = detached->next;
+    } else {
+	d->current = detached->prev;
+    }
+
+    detached->next = NULL;
+
+    if (deleteItem) {
+	d->deleteItem(detached->data);
+    }
+
+    for (KWQListNode *iterator = d->iterators; iterator != NULL; iterator = iterator->next) {
+	if (((KWQListIteratorImpl *)iterator->data)->d->node == detached) {
+	    ((KWQListIteratorImpl *)iterator->data)->d->node = d->current;
+	}
+    }
+    
+    delete detached;
+    d->count--;
+
+    return true;
+}
+
+bool KWQListImpl::remove(uint n, bool deleteItem)
+{
+    if (n >= d->count) {
+	return false;
+    }
+    
+    d->current = d->head;
+
+    for (uint i = 0; i < n; i++) {
+	d->current = d->current->next;
+    }
+
+    return remove(deleteItem);
+}
+
+bool KWQListImpl::removeFirst(bool deleteItem)
+{
+    return remove((unsigned)0, deleteItem);
+}
+
+bool KWQListImpl::removeLast(bool deleteItem)
+{
+    return remove(d->count - 1, deleteItem);
+}
+
+bool KWQListImpl::remove(const void *item, bool deleteItem, int (*compareFunc)(void *a, void *b, void *data), void *data)
+{
+    KWQListNode *node;
+
+    node = d->head;
+
+    while (node != NULL && compareFunc((void *)item, node->data, data) != 0) {
+	node = node->next;
+    }
+    
+    if (node == NULL) {
+	return false;
+    }
+
+    d->current = node;
+
+    return remove(deleteItem);
+}
+
+bool KWQListImpl::removeRef(const void *item, bool deleteItem)
+{
+    KWQListNode *node;
+
+    node = d->head;
+
+    while (node != NULL && item != node->data) {
+	node = node->next;
+    }
+    
+    if (node == NULL) {
+	return false;
+    }
+
+    d->current = node;
+
+    return remove(deleteItem);
+}
+
+void *KWQListImpl::getLast() const
+{
+    KWQListNode *node = d->head;
+
+    if (node == NULL) {
+	return NULL;
+    } 
+    
+    while (node->next != NULL) {
+	node = node->next;
+    }
+    return node->data;
+}
+
+void *KWQListImpl::current() const
+{
+    if (d->current != NULL) {
+	return d->current->data;
+    } else {
+	return NULL;
+    }
+}
+
+void *KWQListImpl::first()
+{
+    d->current = d->head;
+    return current();
+}
+
+void *KWQListImpl::last()
+{
+    if (d->head != NULL) {
+	d->current = d->head;
+	while (d->current->next != NULL) {
+	    d->current = d->current->next;
+	}
+    }
+    return current();
+}
+
+
+void *KWQListImpl::next()
+{
+    if (d->current != NULL) {
+	d->current = d->current->next;
+    }
+    return current();
+}
+
+void *KWQListImpl::prev()
+{
+    if (d->current != NULL) {
+	d->current = d->current->prev;
+    }
+    return current();
+}
+
+void *KWQListImpl::take(uint n)
+{
+    void *retval = at(n);
+    remove(false);
+    return retval;
+}
+
+void KWQListImpl::append(const void *item)
+{
+    insert(d->count, item);
+}
+
+void KWQListImpl::prepend(const void *item)
+{
+    insert(0, item);
+}
+
+uint KWQListImpl::containsRef(const void *item) const
+{
+    KWQListNode *node = d->head;
+
+    while (node != NULL && item != node->data) {
+	node = node->next;
+    }
+    
+    return node != NULL;
+}
+
+KWQListImpl &KWQListImpl::assign(const KWQListImpl &impl, bool deleteItems)
+{
+    KWQListImpl tmp(impl);
+    KWQListImpl::KWQListPrivate *tmpD = tmp.d;
+
+    tmp.d = d;
+    d = tmpD;
+
+    return *this;
+}
+
+
+void KWQListImpl::addIterator(KWQListIteratorImpl *iter) const
+{
+    KWQListNode *node = new KWQListNode();
+    node->data = iter;
+    node->next = d->iterators;
+    d->iterators = node;
+}
+
+void KWQListImpl::removeIterator(KWQListIteratorImpl *iter) const
+{
+    KWQListNode *node = d->iterators;
+
+    while (node != NULL && node->data != iter) {
+	node = node->next;
+    }
+
+    if (node != NULL) {
+ 	if (node->prev == NULL) {
+	    d->iterators = node->next;
+	} else {
+	    node->prev->next = node->next;
+	}
+
+ 	if (node->next != NULL) {
+	    node->next->prev = node->prev;
+	}
+
+	node->next = NULL;
+	delete node;
+    }
+}
+
+
+
+
+// KWQListIteratorImpl
+
+KWQListIteratorImpl::KWQListIteratorImpl() :
+    d(new KWQListIteratorImpl::KWQListIteratorPrivate())
+{
+}
+
+KWQListIteratorImpl::KWQListIteratorImpl(const KWQListImpl &impl)  :
+    d(new KWQListIteratorImpl::KWQListIteratorPrivate(impl, impl.d->head))
+{
+    d->list->addIterator(this);
+}
+
+KWQListIteratorImpl::~KWQListIteratorImpl()
+{
+    if (d->list != NULL) {
+	d->list->removeIterator(this);
+    }
+    delete d;
+}
+
+KWQListIteratorImpl::KWQListIteratorImpl(const KWQListIteratorImpl &impl) :
+    d(new KWQListIteratorImpl::KWQListIteratorPrivate(*impl.d->list, impl.d->node))
+{
+    d->list->addIterator(this);
+}
+
+uint KWQListIteratorImpl::count() const
+{
+    if (d->list == NULL) {
+	return 0;
+    } else {
+	return d->list->count();
+    }
+}
+
+void *KWQListIteratorImpl::toFirst()
+{
+    d->node = d->list->d->head;
+    return current();
+}
+
+void *KWQListIteratorImpl::toLast()
+{
+    d->node = d->list->d->head;
+    while (d->node != NULL && d->node->next != NULL) {
+	d->node = d->node->next;
+    }
+    return current();
+}
+
+void *KWQListIteratorImpl::current() const
+{
+    if (d->node == NULL) {
+	return NULL;
+    } else {
+	return d->node->data;
+    }
+}
+
+void *KWQListIteratorImpl::operator--()
+{
+    if (d->node != NULL) {
+	d->node = d->node->prev;
+    }
+    return current();
+}
+
+void *KWQListIteratorImpl::operator++()
+{
+    if (d->node != NULL) {
+	d->node = d->node->next;
+    }
+    return current();
+}
+
+KWQListIteratorImpl &KWQListIteratorImpl::operator=(const KWQListIteratorImpl &impl)
+{
+    KWQListIteratorImpl tmp(impl);
+    KWQListIteratorImpl::KWQListIteratorPrivate *tmpD = tmp.d;
+
+    if (d->list != NULL) {
+	d->list->removeIterator(this);
+    }
+    if (tmp.d->list != NULL) {
+	tmp.d->list->removeIterator(&tmp);
+    }
+
+    tmp.d = d;
+    d = tmpD;
+
+    if (tmp.d->list != NULL) {
+	tmp.d->list->addIterator(&tmp);
+    }
+    if (d->list != NULL) {
+	d->list->addIterator(this);
+    }
+
+    return *this;
+}
+
+#endif
diff --git a/WebCore/kwq/KWQMap.h b/WebCore/kwq/KWQMap.h
index 4c8b0dc..8a6c9a4 100644
--- a/WebCore/kwq/KWQMap.h
+++ b/WebCore/kwq/KWQMap.h
@@ -58,37 +58,6 @@ template <class K, class V> class QMapNode : private KWQMapNodeImpl
     // intentionally not defined
     QMapNode(const QMapNode<K,V>&node);
 
-    static QMapNode<K,V> *copyTree(const QMapNode<K,V> *node, 
-				   QMapNode<K,V> *subtreePredecessor, 
-				   QMapNode<K,V> *subtreeSuccessor)
-    {
-	if (node == NULL) {
-	    return NULL;
-	}
-
-	// FIXME: not exception-safe - use auto_ptr?
-	QMapNode<K,V> *copy = new QMapNode<K,V>(node->key, node->value);
-	copy->color = node->color;
-
-	if (node->prevIsChild) {
-	    copy->prevIsChild = true;
-	    copy->prev = copyTree((QMapNode<K,V> *)node->prev, subtreePredecessor, copy);
-	} else {
-	    copy->prevIsChild = false;
-	    copy->prev = subtreePredecessor;
-	}
-
-	if (node->nextIsChild) {
-	    copy->nextIsChild = true;
-	    copy->next = copyTree((QMapNode<K,V> *)node->next, copy, subtreeSuccessor);
-	} else {
-	    copy->nextIsChild = false;
-	    copy->next = subtreeSuccessor;
-	}
-
-	return copy;
-    }
-
     ~QMapNode()
     {
 	delete left();
@@ -230,9 +199,9 @@ public:
     }
 
 private:
-    QMapConstIterator(QMapNode<K,V> *n)
+    QMapConstIterator(const QMapNode<K,V> *n)
     {
-	node = n;
+	node = (KWQMapNodeImpl *)n;
     }
 
     friend class QMap<K,V>;
@@ -257,19 +226,17 @@ public:
 
 
     QMap() : 
-	KWQMapImpl(new QMapNode<K,V>(K(),V()), 0)
+	KWQMapImpl(new QMapNode<K,V>(K(),V()), deleteNode)
     {
     }
 
     QMap(const QMap<K,V>& m) :
-	KWQMapImpl(QMapNode<K,V>::copyTree((QMapNode<K,V> *)m.endInternal(), NULL, NULL), m.count())
+	KWQMapImpl(m)
     {
     }
 
     virtual ~QMap() 
     { 
-	clear();
-	delete endInternal();
     }
     
     // member functions --------------------------------------------------------
@@ -347,21 +314,21 @@ public:
 
 
 protected:
-    virtual void copyNode(KWQMapNodeImpl *isrc, KWQMapNodeImpl *idst) 
+    virtual void copyNode(const KWQMapNodeImpl *isrc, KWQMapNodeImpl *idst) const
     {
  	QMapNode<K,V> *src = (QMapNode<K,V> *)isrc;
  	QMapNode<K,V> *dst = (QMapNode<K,V> *)idst;
 	dst->key = src->key;
 	dst->value = src->value;
     }
-
-    virtual KWQMapNodeImpl *duplicateNode(KWQMapNodeImpl *isrc) 
+    
+    virtual KWQMapNodeImpl *duplicateNode(const KWQMapNodeImpl *isrc) const
     {
  	QMapNode<K,V> *src = (QMapNode<K,V> *)isrc;
 	return new QMapNode<K,V>(src->key, src->value);
     }
 
-    virtual CompareResult compareNodes(KWQMapNodeImpl *ia, KWQMapNodeImpl *ib) const
+    virtual CompareResult compareNodes(const KWQMapNodeImpl *ia, const KWQMapNodeImpl *ib) const
     {
  	QMapNode<K,V> *a = (QMapNode<K,V> *)ia;
  	QMapNode<K,V> *b = (QMapNode<K,V> *)ib;
@@ -375,7 +342,7 @@ protected:
 	}
     }
 
-    virtual void swapNodes(KWQMapNodeImpl *ia, KWQMapNodeImpl *ib)
+    virtual void swapNodes(KWQMapNodeImpl *ia, KWQMapNodeImpl *ib) const
     {
 	QMapNode<K,V> *a = (QMapNode<K,V> *)ia;
 	QMapNode<K,V> *b = (QMapNode<K,V> *)ib;
@@ -388,7 +355,7 @@ protected:
 	b->value = tmpValue;
     }
 
-    virtual void deleteNode(KWQMapNodeImpl *inode)
+    static void deleteNode(KWQMapNodeImpl *inode)
     {
 	delete (QMapNode<K,V> *)inode;
     }
diff --git a/WebCore/kwq/KWQMapImpl.h b/WebCore/kwq/KWQMapImpl.h
index 7c1be09..63e6455 100644
--- a/WebCore/kwq/KWQMapImpl.h
+++ b/WebCore/kwq/KWQMapImpl.h
@@ -33,6 +33,7 @@
 
 #ifndef USING_BORROWED_QMAP
 
+#include <KWQRefPtr.h>
 
 class KWQMapNodeImpl
 {
@@ -76,15 +77,16 @@ protected:
 
 class KWQMapImpl {
  private:
-    // disallow default construction, copy construction and assignment
-    KWQMapImpl();
-    KWQMapImpl(const KWQMapImpl &);
+    // disallow assignment
     KWQMapImpl &operator=(const KWQMapImpl &);
 
  protected:
     typedef enum { Less = -1, Equal = 0, Greater = 1 } CompareResult;
 
-    KWQMapImpl(KWQMapNodeImpl *node, uint count);
+    KWQMapImpl(KWQMapNodeImpl *guard, void (*deleteNode)(KWQMapNodeImpl *));
+    KWQMapImpl(const KWQMapImpl &impl);
+    KWQMapImpl();
+    virtual ~KWQMapImpl();
 
     KWQMapNodeImpl *findInternal(KWQMapNodeImpl *target) const;
     KWQMapNodeImpl *insertInternal(KWQMapNodeImpl *nodeToInsert, bool replaceExisting);
@@ -92,26 +94,32 @@ class KWQMapImpl {
     uint countInternal() const;
     void clearInternal();
     void swap(KWQMapImpl &map);
-    KWQMapNodeImpl *beginInternal() const;
-    KWQMapNodeImpl *endInternal() const;
+    const KWQMapNodeImpl *beginInternal() const;
+    const KWQMapNodeImpl *endInternal() const;
+    KWQMapNodeImpl *beginInternal();
+    KWQMapNodeImpl *endInternal();
 
-    virtual CompareResult compareNodes(KWQMapNodeImpl *a, KWQMapNodeImpl *b) const = 0;
-    virtual void copyNode(KWQMapNodeImpl *src, KWQMapNodeImpl *dst) = 0;
-    virtual KWQMapNodeImpl *duplicateNode(KWQMapNodeImpl *src) = 0;
-    virtual void swapNodes(KWQMapNodeImpl *a, KWQMapNodeImpl *b) = 0;
-    virtual void deleteNode(KWQMapNodeImpl *node) = 0;
+    virtual CompareResult compareNodes(const KWQMapNodeImpl *a, const KWQMapNodeImpl *b) const = 0;
+    virtual void copyNode(const KWQMapNodeImpl *src, KWQMapNodeImpl *dst) const = 0;
+    virtual KWQMapNodeImpl *duplicateNode(const KWQMapNodeImpl *src) const = 0;
+    virtual void swapNodes(KWQMapNodeImpl *a, KWQMapNodeImpl *b) const = 0;
 
  private:
     // can't possibly have a bigger height than this in a balanced tree
     static const int MAX_STACK = 64;
 
+    void copyOnWrite();
+    KWQMapNodeImpl *copyTree(const KWQMapNodeImpl *node, 
+			     KWQMapNodeImpl *subtreePredecessor, 
+			     KWQMapNodeImpl *subtreeSuccessor) const;
     void rebalanceAfterInsert(KWQMapNodeImpl **nodes, bool *wentLeft, int height);
     void rebalanceAfterRemove(KWQMapNodeImpl *nodeToRemove, KWQMapNodeImpl **nodes, bool *wentLeft, int height);
     void rotateRight(KWQMapNodeImpl *node, KWQMapNodeImpl *parent, bool leftParent);
     void rotateLeft(KWQMapNodeImpl *node, KWQMapNodeImpl *parent, bool leftParent);
 
-    KWQMapNodeImpl *guard;
-    uint numNodes;
+    class KWQMapPrivate;
+
+    KWQRefPtr<KWQMapPrivate> d;
 
 #ifdef QMAP_TESTING
     friend bool CheckRedBlackRules(KWQMapImpl *impl);
diff --git a/WebCore/kwq/KWQMapImpl.mm b/WebCore/kwq/KWQMapImpl.mm
index fdea9a4..21dd0bc 100644
--- a/WebCore/kwq/KWQMapImpl.mm
+++ b/WebCore/kwq/KWQMapImpl.mm
@@ -121,15 +121,93 @@ void KWQMapIteratorImpl::incrementInternal()
 }
 
 
+// KWQMapImplPrivate
+
+class KWQMapImpl::KWQMapPrivate
+{
+public:
+    KWQMapPrivate(KWQMapNodeImpl *node,
+		  uint count,
+		  void (*deleteFunc)(KWQMapNodeImpl *));
+
+    ~KWQMapPrivate();
+
+    KWQMapNodeImpl *guard;
+    uint numNodes;
+    int refCount;
+    void (*deleteNode)(KWQMapNodeImpl *);
+    friend class KWQRefPtr<KWQMapImpl::KWQMapPrivate>;
+};
+
+KWQMapImpl::KWQMapPrivate::KWQMapPrivate(KWQMapNodeImpl *node,
+					 uint count,
+					 void (*deleteFunc)(KWQMapNodeImpl *)) :
+    guard(node),
+    numNodes(count),
+    refCount(0),
+    deleteNode(deleteFunc)
+{
+}
+
+KWQMapImpl::KWQMapPrivate::~KWQMapPrivate()
+{
+    deleteNode(guard);
+}
+
 // KWQMapImpl
 
+KWQMapImpl::KWQMapImpl(KWQMapNodeImpl *guard, void (*deleteNode)(KWQMapNodeImpl *)) :
+    d(new KWQMapImpl::KWQMapPrivate(guard,0, deleteNode))
+{
+}
 
-KWQMapImpl::KWQMapImpl(KWQMapNodeImpl *node, uint count) :
-    guard(node),
-    numNodes(count)
+KWQMapImpl::KWQMapImpl(const KWQMapImpl &impl) :
+    d(impl.d)
+{
+}
+
+KWQMapImpl::~KWQMapImpl()
 {
 }
 
+void KWQMapImpl::copyOnWrite()
+{
+    if (d->refCount > 1) {
+	d = KWQRefPtr<KWQMapImpl::KWQMapPrivate>(new KWQMapImpl::KWQMapPrivate(copyTree(d->guard, NULL, NULL), d->numNodes, d->deleteNode));
+    }
+}
+
+KWQMapNodeImpl *KWQMapImpl::copyTree(const KWQMapNodeImpl *node, 
+				     KWQMapNodeImpl *subtreePredecessor, 
+				     KWQMapNodeImpl *subtreeSuccessor) const
+{
+    if (node == NULL) {
+	return NULL;
+    }
+    
+    // FIXME: not exception-safe - use auto_ptr?
+    KWQMapNodeImpl *copy = duplicateNode(node);
+    copy->color = node->color;
+    
+    if (node->prevIsChild) {
+	copy->prevIsChild = true;
+	copy->prev = copyTree(node->prev, subtreePredecessor, copy);
+    } else {
+	copy->prevIsChild = false;
+	copy->prev = subtreePredecessor;
+    }
+    
+    if (node->nextIsChild) {
+	copy->nextIsChild = true;
+	copy->next = copyTree(node->next, copy, subtreeSuccessor);
+    } else {
+	copy->nextIsChild = false;
+	copy->next = subtreeSuccessor;
+    }
+    
+    return copy;
+}
+
 void KWQMapImpl::rotateRight(KWQMapNodeImpl *node, KWQMapNodeImpl *parent, bool leftParent)
 {
     KWQMapNodeImpl *rotationChild = node->left();
@@ -178,7 +256,7 @@ void KWQMapImpl::rebalanceAfterInsert(KWQMapNodeImpl **nodes, bool *wentLeft, in
 {
     nodes[height]->color = KWQMapNodeImpl::Red;
     
-    while (nodes[height] != guard->prev && nodes[height-1]->color == KWQMapNodeImpl::Red) {
+    while (nodes[height] != d->guard->prev && nodes[height-1]->color == KWQMapNodeImpl::Red) {
 	if (wentLeft[height-2]) {
 	    KWQMapNodeImpl *uncle = nodes[height-2]->right();
 	    if (uncle != NULL && uncle->color == KWQMapNodeImpl::Red) {
@@ -229,13 +307,13 @@ void KWQMapImpl::rebalanceAfterInsert(KWQMapNodeImpl **nodes, bool *wentLeft, in
 	}
     }
     
-    guard->prev->color = KWQMapNodeImpl::Black;
+    d->guard->prev->color = KWQMapNodeImpl::Black;
 }
 
 void KWQMapImpl::rebalanceAfterRemove(KWQMapNodeImpl *nodeToRemove, KWQMapNodeImpl **nodes, bool *wentLeft, int height) 
 {
     if (nodeToRemove->color == KWQMapNodeImpl::Black) {
-	while (nodes[height] != guard->prev && (nodes[height]==NULL || nodes[height]->color==KWQMapNodeImpl::Black)) {
+	while (nodes[height] != d->guard->prev && (nodes[height]==NULL || nodes[height]->color==KWQMapNodeImpl::Black)) {
 	    if (wentLeft[height-1]) {
 		KWQMapNodeImpl *sibling = nodes[height-1]->right();
 		if (sibling != NULL && sibling->color == KWQMapNodeImpl::Red) {
@@ -267,7 +345,7 @@ void KWQMapImpl::rebalanceAfterRemove(KWQMapNodeImpl *nodeToRemove, KWQMapNodeIm
 		    sibling->right()->color = KWQMapNodeImpl::Black;
 		    rotateLeft(nodes[height-1], nodes[height-2], wentLeft[height-2]);
 		    
-		    nodes[height] = guard->prev;
+		    nodes[height] = d->guard->prev;
 		}
 	    } else {
 		// same as the other branch, but with left and right swapped
@@ -302,7 +380,7 @@ void KWQMapImpl::rebalanceAfterRemove(KWQMapNodeImpl *nodeToRemove, KWQMapNodeIm
 		    sibling->left()->color = KWQMapNodeImpl::Black;
 		    rotateRight(nodes[height-1], nodes[height-2], wentLeft[height-2]);
 		    
-		    nodes[height] = guard->prev;
+		    nodes[height] = d->guard->prev;
 		}
 	    }
 	}
@@ -315,7 +393,7 @@ void KWQMapImpl::rebalanceAfterRemove(KWQMapNodeImpl *nodeToRemove, KWQMapNodeIm
 
 KWQMapNodeImpl *KWQMapImpl::findInternal(KWQMapNodeImpl *target) const
 {
-    KWQMapNodeImpl *node = guard->left();
+    KWQMapNodeImpl *node = d->guard->left();
     
     while (node != NULL) {
 	CompareResult compare = compareNodes(target,node);
@@ -338,11 +416,13 @@ KWQMapNodeImpl *KWQMapImpl::insertInternal(KWQMapNodeImpl *nodeToInsert, bool re
     bool wentLeftStack[MAX_STACK];
     int height = 0;
     
-    nodeStack[height] = guard;
+    copyOnWrite();
+
+    nodeStack[height] = d->guard;
     wentLeftStack[height] = true;
     height++;
     
-    KWQMapNodeImpl *node = guard->left();
+    KWQMapNodeImpl *node = d->guard->left();
     
     while (node != NULL) {
 	CompareResult compare = compareNodes(nodeToInsert, node);
@@ -395,7 +475,7 @@ KWQMapNodeImpl *KWQMapImpl::insertInternal(KWQMapNodeImpl *nodeToInsert, bool re
     }
     
     rebalanceAfterInsert(nodeStack, wentLeftStack, height);
-    numNodes++;
+    d->numNodes++;
 
     return node;
 }
@@ -406,11 +486,13 @@ void KWQMapImpl::removeInternal(KWQMapNodeImpl *nodeToDelete)
     bool wentLeftStack[MAX_STACK];
     int height = 0;
     
-    nodeStack[height] = guard;
+    copyOnWrite();
+
+    nodeStack[height] = d->guard;
     wentLeftStack[height] = true;
     height++;
     
-    KWQMapNodeImpl *node = guard->left();
+    KWQMapNodeImpl *node = d->guard->left();
     
     while (node != NULL) {
 	CompareResult compare = compareNodes(nodeToDelete, node);
@@ -509,38 +591,55 @@ void KWQMapImpl::removeInternal(KWQMapNodeImpl *nodeToDelete)
     nodeToRemove->next = NULL;
     nodeToRemove->prev = NULL;
     
-    numNodes--;
-    deleteNode(nodeToRemove);
+    d->numNodes--;
+    d->deleteNode(nodeToRemove);
 }
 
 void KWQMapImpl::swap(KWQMapImpl &map)
 {
-    KWQMapNodeImpl *tmp = guard;
-    guard = map.guard;
-    map.guard = tmp;
-    
-    uint tmpNumNodes = numNodes;
-    numNodes = map.numNodes;
-    map.numNodes = tmpNumNodes;
+    KWQRefPtr<KWQMapImpl::KWQMapPrivate> tmp = d;
+    d = map.d;
+    map.d = d;
 }
 
 uint KWQMapImpl::countInternal() const
 {
-    return numNodes;
+    return d->numNodes;
 }
 
 void KWQMapImpl::clearInternal()
 {
-    deleteNode(guard->prev);
-    guard->prev = NULL;
-    numNodes = 0;
+    copyOnWrite();
+
+    d->deleteNode(d->guard->prev);
+    d->guard->prev = NULL;
+    d->numNodes = 0;
+}
+
+const KWQMapNodeImpl *KWQMapImpl::beginInternal() const
+{
+    KWQMapNodeImpl *node;
+    
+    node = d->guard;
+    while (node->left() != NULL) {
+	node = node->left();
+    }
+    
+    return node;
 }
 
-KWQMapNodeImpl *KWQMapImpl::beginInternal() const
+const KWQMapNodeImpl *KWQMapImpl::endInternal() const
+{
+    return d->guard;
+}
+
+KWQMapNodeImpl *KWQMapImpl::beginInternal()
 {
     KWQMapNodeImpl *node;
     
-    node = guard;
+    copyOnWrite();
+
+    node = d->guard;
     while (node->left() != NULL) {
 	node = node->left();
     }
@@ -548,9 +647,12 @@ KWQMapNodeImpl *KWQMapImpl::beginInternal() const
     return node;
 }
 
-KWQMapNodeImpl *KWQMapImpl::endInternal() const
+KWQMapNodeImpl *KWQMapImpl::endInternal()
 {
-    return guard;
+    copyOnWrite();
+    return d->guard;
 }
 
+
+
 #endif
diff --git a/WebCore/kwq/KWQPtrDict.h b/WebCore/kwq/KWQPtrDict.h
index d32c71f..35cf62f 100644
--- a/WebCore/kwq/KWQPtrDict.h
+++ b/WebCore/kwq/KWQPtrDict.h
@@ -37,7 +37,7 @@
 #else
 
 #include <KWQDef.h>
-#include <_qcollection.h>
+#include <qcollection.h>
 
 #include <KWQPtrDictImpl.h>
 
diff --git a/WebCore/kwq/KWQPtrList.h b/WebCore/kwq/KWQPtrList.h
index f0cdb1b..c555eea 100644
--- a/WebCore/kwq/KWQPtrList.h
+++ b/WebCore/kwq/KWQPtrList.h
@@ -36,62 +36,77 @@
 #include <_qlist.h>
 #else
 
+#include <iostream>
+
 #include <KWQDef.h>
-#include <_qcollection.h>
+#include <qcollection.h>
+
+#include <KWQListImpl.h>
 
 // class QList =================================================================
 
+template <class T> class QListIterator;
+
 template <class T> class QList : public QCollection {
 public:
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-    // static member functions -------------------------------------------------
     // constructors, copy constructors, and destructors ------------------------
     
-    QList();
-    QList(const QList<T> &);
-    ~QList(); 
+    QList() : impl(deleteFunc) {}
+    QList(const QList<T> &l) : impl(l.impl) {}
+    ~QList() { if (del_item) { impl.clear(del_item); } }
      
     // member functions --------------------------------------------------------
 
-    bool isEmpty() const;
-    uint count() const;
-    void clear();
-    void sort();
+    bool isEmpty() const { return impl.isEmpty(); }
+    uint count() const { return impl.count(); }
+    void clear() { impl.clear(del_item); }
+    void sort() { impl.sort(compareFunc, this); }
 
-    T *at(uint);
+    T *at(uint n) { return (T *)impl.at(n); }
 
-    void setAutoDelete(bool);
+    bool insert(uint n, const T *item) { return impl.insert(n, item); }
+    bool remove() {return impl.remove(del_item); }
+    bool remove(uint n) {return impl.remove(n, del_item); }
+    bool remove(const T *item) { return impl.remove(item, del_item, compareFunc, this); }
+    bool removeFirst() { return impl.removeFirst(del_item); }
+    bool removeLast() { return impl.removeLast(del_item); }
+    bool removeRef(const T *item) { return impl.removeRef(item, del_item); }
 
-    bool insert(uint i, const T *);
-    bool remove();
-    bool remove(const T *);
-    bool removeFirst();
-    bool removeLast();
-    bool removeRef(const T *);
+    T *getLast() const { return (T *)impl.getLast(); }
+    T *current() const { return (T *)impl.current(); }
+    T *first() { return (T *)impl.first(); }
+    T *last() { return (T *)impl.last(); }
+    T *next() { return (T *)impl.next(); }
+    T *prev() { return (T *)impl.prev(); }
+    T *take(uint n) { return (T *)impl.take(n); }
 
-    T *getLast() const;
-    T *current() const;
-    T *first();
-    T *last();
-    T *next();
-    T *prev();
-    T *take(uint i);
+    void append(const T *item) { impl.append(item); }
+    void prepend(const T *item) { impl.prepend(item); }
 
-    void append(const T *);
-    void prepend(const T *);
+    uint containsRef(const T *item) const { return impl.containsRef(item); }
 
-    uint containsRef(const T *) const;
+    virtual int compareItems(void *a, void *b) { return a != b; }
 
     // operators ---------------------------------------------------------------
 
-    QList<T> &operator=(const QList<T> &);
+    QList<T> &operator=(const QList<T> &l)
+    { impl.assign(l.impl,del_item); QCollection::operator=(l); return *this; }
+
+ private:
+    static void deleteFunc(void *item) {
+	delete (T *)item;
+    }
 
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+    static int compareFunc(void *a, void *b, void *data)
+    {
+	QList<T> *l = (QList<T> *)data;
+	return l->compareItems(a, b);
+    }
 
+    friend class QListIterator<T>;
+
+    KWQListImpl impl;
 }; // class QList ==============================================================
 
 
@@ -100,48 +115,58 @@ public:
 template <class T> class QListIterator {
 public:
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-    // static member functions -------------------------------------------------
-    
     // constructors, copy constructors, and destructors ------------------------
 
-// add no-arg constructor
-#ifdef _KWQ_PEDANTIC_
     QListIterator() {}
-#endif
-
-    QListIterator(const QList<T> &);
-    ~QListIterator();
+    QListIterator(const QList<T> &l) : impl(l.impl) {}
+    ~QListIterator() {}
 
     // member functions --------------------------------------------------------
 
-    uint count() const;
-    T *toFirst();
-    T *toLast();
-    T *current() const;
+    uint count() const { return impl.count(); }
+    T *toFirst() { return (T *)impl.toFirst(); }
+    T *toLast() { return (T *)impl.toLast(); }
+    T *current() const { return (T *)impl.current(); }
 
     // operators ---------------------------------------------------------------
 
-    operator T *() const;
-    T *operator--();
-    T *operator++();
-    QListIterator<T> &operator=(const QListIterator<T> &);
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+    operator T *() const { return (T *)impl.current(); }
+    T *operator--() { return (T *)(--impl); }
+    T *operator++()  { return (T *)(++impl); }
+    QListIterator<T> &operator=(const QListIterator<T> &li) { impl = li.impl; return *this; }
 
 private:
+    QListIterator<T>(const QListIterator<T> &li) {}
 
-// add copy constructor
-// this private declaration prevents copying
-#ifdef _KWQ_PEDANTIC_
-    QListIterator<T>(const QListIterator<T> &);
-#endif
-
+    KWQListIteratorImpl impl;
 }; // class QListIterator ======================================================
 
+
+template<class T>
+inline ostream &operator<<(ostream &stream, const QList<T> &l)
+{
+    QListIterator<T> iter(l);
+    unsigned count = l.count();
+
+    stream << "QList: [size: " << l.count() << "; items: ";
+
+    // print first
+    if (count != 0) {
+	stream << *iter.current();
+	++iter;
+	--count;
+    }
+    
+    // print rest
+    while(count != 0) {
+	stream << ", " << *iter.current();
+	++iter;
+	--count;
+    }
+
+    return stream << "]";
+}
+
 #endif // USING_BORROWED_QLIST
 
 #endif
diff --git a/WebCore/kwq/KWQPtrVector.h b/WebCore/kwq/KWQPtrVector.h
index 6a5cc73..f5e2da5 100644
--- a/WebCore/kwq/KWQPtrVector.h
+++ b/WebCore/kwq/KWQPtrVector.h
@@ -36,79 +36,67 @@
 #include <_qvector.h>
 #else
 
-#include <KWQDef.h>
-#include <_qcollection.h>
+#include <iostream>
 
-typedef void *Item;
+#include <KWQDef.h>
+#include <qcollection.h>
 
-// class QGVector ==============================================================
+#include <KWQVectorImpl.h>
 
-class QGVector : public QCollection {
+// class QVector ===============================================================
+template<class T> class QVector : public QCollection  {
 public:
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-
-    // static member functions -------------------------------------------------
-
-    virtual int compareItems(Item, Item);
-
     // constructors, copy constructors, and destructors ------------------------
-    
-    QGVector();
-    QGVector(const QGVector &);
-    ~QGVector();
-    
-    // member functions --------------------------------------------------------
-    
-    // operators ---------------------------------------------------------------
-
-    QGVector &operator=(const QGVector &);
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
 
-}; // class QGVector ===========================================================
+    QVector() : impl(deleteFunc) {}
+    QVector(uint size) : impl(size, deleteFunc) {}
+    QVector(const QVector<T> &v) : impl(v.impl) {}
+    ~QVector() { if (del_item) { impl.clear(del_item); } }
 
+    // member functions --------------------------------------------------------
 
-// class QVector ===============================================================
+    void clear() { impl.clear(del_item); }
+    bool isEmpty() const { return impl.isEmpty(); }
+    uint count() const { return impl.count(); }
+    uint size() const { return impl.size(); }
+    bool remove(uint n) { return impl.remove(n, del_item); }
+    bool resize(uint size) { return impl.resize(size, del_item); }
+    bool insert(uint n, const T *item) {return impl.insert(n, item, del_item); }
+    T *at(int n) const {return (T *)impl.at(n); }
 
-template<class T> class QVector : public QGVector  {
-public:
+    virtual int compareItems(void *a, void *b) { return a != b; }
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-    // static member functions -------------------------------------------------
+    // operators ---------------------------------------------------------------
 
-    // constructors, copy constructors, and destructors ------------------------
+    T *operator[](int n) const {return (T *)impl.at(n); }
+    QVector &operator=(const QVector &v) 
+    { impl.assign(v.impl,del_item); QCollection::operator=(v); return *this; }
+ private:
+    static void deleteFunc(void *item) {
+	delete (T *)item;
+    }
 
-    QVector();
-    QVector(uint);
-    QVector(const QVector &);
-    ~QVector();
+    KWQVectorImpl impl;
+}; // class QVector ============================================================
 
-    // member functions --------------------------------------------------------
 
-    void clear();
-    bool isEmpty() const;
-    uint count() const;
-    uint size() const;
-    bool remove(uint);
-    bool resize(uint);
-    bool insert(uint, const T *);
-    T *at(int) const;
 
-    // operators ---------------------------------------------------------------
+template<class T>
+inline ostream &operator<<(ostream &stream, const QVector<T> &v)
+{
+    uint i = 0;
+    uint count = v.count();
 
-    T *operator[](int) const;
-    QVector &operator=(const QVector &);
+    stream << "QVector: [size: " << count << "; items: ";
 
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+    while(i < count ) {
+	stream << *v[i] << ", ";
+	++i;
+    }
 
-}; // class QVector ============================================================
+    return stream << "]";
+}
 
 #endif // USING_BORROWED_QVECTOR
 
diff --git a/WebCore/src/kwq/KWQArrayImpl.h b/WebCore/kwq/KWQVectorImpl.h
similarity index 68%
copy from WebCore/src/kwq/KWQArrayImpl.h
copy to WebCore/kwq/KWQVectorImpl.h
index b588a8a..bc74b41 100644
--- a/WebCore/src/kwq/KWQArrayImpl.h
+++ b/WebCore/kwq/KWQVectorImpl.h
@@ -23,41 +23,40 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef KWQ_ARRAY_IMPL_H
-#define KWQ_ARRAY_IMPL_H
+#ifndef KWQ_VECTOR_IMPL_H
+#define KWQ_VECTOR_IMPL_H
 
 #include <config.h>
-#include <KWQRefPtr.h>
 #include <KWQDef.h>
-#include <stddef.h>
 
-#ifndef USING_BORROWED_QARRAY
+#ifndef USING_BORROWED_QVECTOR
 
-class KWQArrayImpl
+class KWQVectorImpl
 {
  public:
-    KWQArrayImpl(size_t itemSize);
-    KWQArrayImpl(size_t itemSize, size_t numItems);
-    KWQArrayImpl(const KWQArrayImpl &);
-    ~KWQArrayImpl();
-    
-    KWQArrayImpl &operator=(const KWQArrayImpl &);
-    
-    void *at(size_t pos) const;
-    void *data() const;
+    KWQVectorImpl(void (*deleteFunc)(void *));
+    KWQVectorImpl(uint size, void (*deleteFunc)(void *));
+    KWQVectorImpl(const KWQVectorImpl &vi);
+    ~KWQVectorImpl();
+
+    void clear(bool delItems);
+    bool isEmpty() const;
+    uint count() const;
     uint size() const;
-    bool resize(size_t size);
-    void duplicate(const void *data, size_t size);
-    bool fill(const void *item, int size = -1);
-    
-    bool operator==(const KWQArrayImpl &) const;
+    bool remove(uint n, bool delItems); 
+    bool resize(uint size, bool delItems);
+    bool insert(uint n, const void *item, bool delItems);
+    void *at(int n) const;
+    KWQVectorImpl &assign (KWQVectorImpl &vi, bool delItems);
+
  private:
-    class KWQArrayPrivate;
+    void KWQVectorImpl::swap(KWQVectorImpl &di);
 
-    KWQRefPtr<KWQArrayPrivate> d;
+    class KWQVectorPrivate;
+    KWQVectorPrivate *d;
 };
 
-#endif
 
 #endif
 
+#endif
diff --git a/WebCore/kwq/KWQVectorImpl.mm b/WebCore/kwq/KWQVectorImpl.mm
new file mode 100644
index 0000000..0186e92
--- /dev/null
+++ b/WebCore/kwq/KWQVectorImpl.mm
@@ -0,0 +1,232 @@
+/*
+ * 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 <KWQVectorImpl.h>
+
+#ifndef USING_BORROWED_QVECTOR
+
+#define Fixed MacFixed
+#define Rect MacRect
+#define Boolean MacBoolean
+#include <CoreFoundation/CFArray.h>
+#undef Fixed
+#undef Rect
+#undef Boolean
+
+#include <new>
+
+class KWQVectorImpl::KWQVectorPrivate
+{
+public:
+    KWQVectorPrivate(int size, void (*deleteFunc)(void *));
+    KWQVectorPrivate(KWQVectorPrivate &vp);
+    ~KWQVectorPrivate();
+    
+    CFMutableArrayRef cfarray;
+    uint size;
+    uint count;
+    uint max;
+    void (*deleteItem)(void *);
+};
+
+KWQVectorImpl::KWQVectorPrivate::KWQVectorPrivate(int sz, void (*deleteFunc)(void *)) :
+    cfarray(CFArrayCreateMutable(NULL, 0, NULL)),
+    size(sz),
+    count(0),
+    max(0),
+    deleteItem(deleteFunc)
+{
+    if (cfarray == NULL) {
+	throw bad_alloc();
+    }
+}
+
+KWQVectorImpl::KWQVectorPrivate::KWQVectorPrivate(KWQVectorPrivate &vp) :
+    cfarray(CFArrayCreateMutableCopy(NULL, 0, vp.cfarray)),
+    size(vp.size),
+    count(vp.count),
+    max(vp.max),
+    deleteItem(vp.deleteItem)
+{
+    if (cfarray == NULL) {
+	throw bad_alloc();
+    }
+}
+
+KWQVectorImpl::KWQVectorPrivate::~KWQVectorPrivate()
+{
+    CFRelease(cfarray);
+}
+
+
+KWQVectorImpl::KWQVectorImpl(void (*deleteFunc)(void *)) :
+    d(new KWQVectorImpl::KWQVectorPrivate(0, deleteFunc))
+{
+}
+
+KWQVectorImpl::KWQVectorImpl(uint size, void (*deleteFunc)(void *)) :
+    d(new KWQVectorImpl::KWQVectorPrivate(size, deleteFunc))
+{
+}
+
+KWQVectorImpl::KWQVectorImpl(const KWQVectorImpl &vi) : 
+    d(new KWQVectorImpl::KWQVectorPrivate(*vi.d))
+{
+}
+
+KWQVectorImpl::~KWQVectorImpl()
+{
+    delete d;
+}
+
+void KWQVectorImpl::clear(bool delItems)
+{
+    if (delItems) {
+	while (d->max > 0) {
+	    d->max--;
+	    void *item = (void *)CFArrayGetValueAtIndex(d->cfarray, d->max);
+	    if (item != NULL) {
+		d->deleteItem(item);
+	    }
+	}
+    }
+
+    CFArrayRemoveAllValues(d->cfarray);
+    d->count = 0;
+    d->max = 0;
+}
+
+bool KWQVectorImpl::isEmpty() const
+{
+    return d->count == 0;
+}
+
+uint KWQVectorImpl::count() const
+{
+    return d->count;
+}
+
+uint KWQVectorImpl::size() const
+{
+    return d->size;
+}
+
+bool KWQVectorImpl::remove(uint n, bool delItems)
+{
+    if (n < d->max) {
+	void *item = (void *)CFArrayGetValueAtIndex(d->cfarray, n);
+	
+	if (item != NULL) {
+	    if (delItems) {
+		d->deleteItem(item);
+	    }
+	    
+	    CFArraySetValueAtIndex(d->cfarray, n, NULL);
+	    
+	    d->count--;
+	}
+	return true;
+    } else {
+	return false;
+    }
+}
+
+bool KWQVectorImpl::resize(uint size, bool delItems)
+{
+    d->size = size;
+
+    while (d->max > size) {
+	d->max--;
+	void *item = (void *)CFArrayGetValueAtIndex(d->cfarray, d->max);
+
+	if (item != NULL) {
+	    if (delItems) {
+		d->deleteItem(item);
+	    }
+	    d->count--;
+	}
+	CFArrayRemoveValueAtIndex(d->cfarray, d->max);
+    }
+
+    return true;
+}
+
+bool KWQVectorImpl::insert(uint n, const void *item, bool delItems)
+{
+    if (n >= d->size) {
+	return false;
+    }
+
+    if (n < d->max) {
+	void *item = (void *)CFArrayGetValueAtIndex(d->cfarray, n);
+	if (item != NULL) {
+	    if (delItems) {
+		d->deleteItem((void *)CFArrayGetValueAtIndex(d->cfarray, n));
+	    }
+	} else {
+	    d->count++;
+	}
+    }  else {
+	while (n > d->max) {
+	    CFArraySetValueAtIndex(d->cfarray, d->max, NULL);
+	    d->max++;
+	}
+	d->max++;
+	d->count++;
+    }
+
+    CFArraySetValueAtIndex(d->cfarray, n, item);
+
+    return true;
+}
+
+void *KWQVectorImpl::at(int n) const
+{
+    if ((unsigned)n >= d->max) {
+	return NULL;
+    }
+
+    return (void *)CFArrayGetValueAtIndex(d->cfarray, n);
+}
+
+KWQVectorImpl &KWQVectorImpl::assign (KWQVectorImpl &vi, bool delItems)
+{
+    KWQVectorImpl tmp(vi);
+
+    swap(tmp);
+
+    return *this;
+}
+
+void KWQVectorImpl::KWQVectorImpl::swap(KWQVectorImpl &di)
+{
+    KWQVectorImpl::KWQVectorPrivate *tmp = d;
+    d = di.d;
+    di.d = tmp;
+}
+
+
+#endif
+
diff --git a/WebCore/kwq/Makefile.am b/WebCore/kwq/Makefile.am
index 75ea1c6..f34950e 100644
--- a/WebCore/kwq/Makefile.am
+++ b/WebCore/kwq/Makefile.am
@@ -20,6 +20,7 @@ libkwq_o_SOURCES = \
 	KWQChar.mm \
 	KWQCharsets.mm \
 	KWQCheckBox.mm \
+	KWQCollection.mm \
 	KWQColor.mm \
 	KWQColorGroup.mm \
 	KWQComboBox.mm \
@@ -87,6 +88,7 @@ libkwq_o_SOURCES = \
 	KWQLabel.mm \
 	KWQLineEdit.mm \
 	KWQListBox.mm \
+	KWQListImpl.mm \
 	KWQMapImpl.mm \
 	KWQMovie.mm \
 	KWQNSTextField.mm \
@@ -113,6 +115,7 @@ libkwq_o_SOURCES = \
 	KWQTimer.mm \
 	KWQToolTip.mm \
 	KWQVariant.mm \
+	KWQVectorImpl.mm \
 	KWQView.mm \
 	KWQWMatrix.mm \
 	KWQWidget.mm \
diff --git a/WebCore/kwq/qt/_qcollection.h b/WebCore/kwq/qt/_qcollection.h
index 63d676e..c8bc9d5 100644
--- a/WebCore/kwq/qt/_qcollection.h
+++ b/WebCore/kwq/qt/_qcollection.h
@@ -35,8 +35,8 @@
 **
 **********************************************************************/
 
-#ifndef QCOLLECTION_H
-#define QCOLLECTION_H
+#ifndef _QCOLLECTION_H
+#define _QCOLLECTION_H
 
 // KWQ hacks ---------------------------------------------------------------
 
@@ -71,4 +71,4 @@ protected:
 };
 
 
-#endif // QCOLLECTION_H
+#endif // _QCOLLECTION_H
diff --git a/WebCore/src/kwq/qt/_qcollection.h b/WebCore/kwq/qt/qcollection.h
similarity index 66%
copy from WebCore/src/kwq/qt/_qcollection.h
copy to WebCore/kwq/qt/qcollection.h
index 63d676e..e91b1d7 100644
--- a/WebCore/src/kwq/qt/_qcollection.h
+++ b/WebCore/kwq/qt/qcollection.h
@@ -38,37 +38,32 @@
 #ifndef QCOLLECTION_H
 #define QCOLLECTION_H
 
-// KWQ hacks ---------------------------------------------------------------
+#include <config.h>
 
 #include <KWQDef.h>
 
-// -------------------------------------------------------------------------
+#ifdef USING_BORROWED_QCOLLECTION
 
-class QGVector;
-class QGList;
-class QGDict;
+#include <_qcollection.h>
 
-class Q_EXPORT QCollection			// inherited by all collections
-{
-public:
-    bool autoDelete()	const	       { return del_item; }
-    void setAutoDelete( bool enable )  { del_item = enable; }
+#else
 
-    virtual uint  count() const = 0;
-    virtual void  clear() = 0;			// delete all objects
+class QCollection {
+ public:
+    typedef void *Item;
 
-    typedef void *Item;				// generic collection item
-
-protected:
-    QCollection() { del_item = FALSE; }		// no deletion of objects
-    QCollection(const QCollection &) { del_item = FALSE; }
-    virtual ~QCollection() {}
+    bool autoDelete();
+    void setAutoDelete(bool autoDelete);
+ protected:
+    QCollection();
+    QCollection(const QCollection &);
+    QCollection &operator=(const QCollection &);
+    virtual ~QCollection();
 
     bool del_item;				// default FALSE
-
-    virtual Item     newItem( Item );		// create object
-    virtual void     deleteItem( Item );	// delete object
 };
 
+#endif /* USING_BORROWED_QCOLLECTION */
+
+#endif /* QCOLLECTION_H */
 
-#endif // QCOLLECTION_H
diff --git a/WebCore/kwq/qt/qdict.h b/WebCore/kwq/qt/qdict.h
index a3ee0f4..a496550 100644
--- a/WebCore/kwq/qt/qdict.h
+++ b/WebCore/kwq/qt/qdict.h
@@ -39,7 +39,7 @@
 #else
 
 
-#include <_qcollection.h>
+#include <qcollection.h>
 #include <qstring.h>
 
 #include <KWQDictImpl.h>
diff --git a/WebCore/kwq/qt/qlist.h b/WebCore/kwq/qt/qlist.h
index f0cdb1b..c555eea 100644
--- a/WebCore/kwq/qt/qlist.h
+++ b/WebCore/kwq/qt/qlist.h
@@ -36,62 +36,77 @@
 #include <_qlist.h>
 #else
 
+#include <iostream>
+
 #include <KWQDef.h>
-#include <_qcollection.h>
+#include <qcollection.h>
+
+#include <KWQListImpl.h>
 
 // class QList =================================================================
 
+template <class T> class QListIterator;
+
 template <class T> class QList : public QCollection {
 public:
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-    // static member functions -------------------------------------------------
     // constructors, copy constructors, and destructors ------------------------
     
-    QList();
-    QList(const QList<T> &);
-    ~QList(); 
+    QList() : impl(deleteFunc) {}
+    QList(const QList<T> &l) : impl(l.impl) {}
+    ~QList() { if (del_item) { impl.clear(del_item); } }
      
     // member functions --------------------------------------------------------
 
-    bool isEmpty() const;
-    uint count() const;
-    void clear();
-    void sort();
+    bool isEmpty() const { return impl.isEmpty(); }
+    uint count() const { return impl.count(); }
+    void clear() { impl.clear(del_item); }
+    void sort() { impl.sort(compareFunc, this); }
 
-    T *at(uint);
+    T *at(uint n) { return (T *)impl.at(n); }
 
-    void setAutoDelete(bool);
+    bool insert(uint n, const T *item) { return impl.insert(n, item); }
+    bool remove() {return impl.remove(del_item); }
+    bool remove(uint n) {return impl.remove(n, del_item); }
+    bool remove(const T *item) { return impl.remove(item, del_item, compareFunc, this); }
+    bool removeFirst() { return impl.removeFirst(del_item); }
+    bool removeLast() { return impl.removeLast(del_item); }
+    bool removeRef(const T *item) { return impl.removeRef(item, del_item); }
 
-    bool insert(uint i, const T *);
-    bool remove();
-    bool remove(const T *);
-    bool removeFirst();
-    bool removeLast();
-    bool removeRef(const T *);
+    T *getLast() const { return (T *)impl.getLast(); }
+    T *current() const { return (T *)impl.current(); }
+    T *first() { return (T *)impl.first(); }
+    T *last() { return (T *)impl.last(); }
+    T *next() { return (T *)impl.next(); }
+    T *prev() { return (T *)impl.prev(); }
+    T *take(uint n) { return (T *)impl.take(n); }
 
-    T *getLast() const;
-    T *current() const;
-    T *first();
-    T *last();
-    T *next();
-    T *prev();
-    T *take(uint i);
+    void append(const T *item) { impl.append(item); }
+    void prepend(const T *item) { impl.prepend(item); }
 
-    void append(const T *);
-    void prepend(const T *);
+    uint containsRef(const T *item) const { return impl.containsRef(item); }
 
-    uint containsRef(const T *) const;
+    virtual int compareItems(void *a, void *b) { return a != b; }
 
     // operators ---------------------------------------------------------------
 
-    QList<T> &operator=(const QList<T> &);
+    QList<T> &operator=(const QList<T> &l)
+    { impl.assign(l.impl,del_item); QCollection::operator=(l); return *this; }
+
+ private:
+    static void deleteFunc(void *item) {
+	delete (T *)item;
+    }
 
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+    static int compareFunc(void *a, void *b, void *data)
+    {
+	QList<T> *l = (QList<T> *)data;
+	return l->compareItems(a, b);
+    }
 
+    friend class QListIterator<T>;
+
+    KWQListImpl impl;
 }; // class QList ==============================================================
 
 
@@ -100,48 +115,58 @@ public:
 template <class T> class QListIterator {
 public:
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-    // static member functions -------------------------------------------------
-    
     // constructors, copy constructors, and destructors ------------------------
 
-// add no-arg constructor
-#ifdef _KWQ_PEDANTIC_
     QListIterator() {}
-#endif
-
-    QListIterator(const QList<T> &);
-    ~QListIterator();
+    QListIterator(const QList<T> &l) : impl(l.impl) {}
+    ~QListIterator() {}
 
     // member functions --------------------------------------------------------
 
-    uint count() const;
-    T *toFirst();
-    T *toLast();
-    T *current() const;
+    uint count() const { return impl.count(); }
+    T *toFirst() { return (T *)impl.toFirst(); }
+    T *toLast() { return (T *)impl.toLast(); }
+    T *current() const { return (T *)impl.current(); }
 
     // operators ---------------------------------------------------------------
 
-    operator T *() const;
-    T *operator--();
-    T *operator++();
-    QListIterator<T> &operator=(const QListIterator<T> &);
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+    operator T *() const { return (T *)impl.current(); }
+    T *operator--() { return (T *)(--impl); }
+    T *operator++()  { return (T *)(++impl); }
+    QListIterator<T> &operator=(const QListIterator<T> &li) { impl = li.impl; return *this; }
 
 private:
+    QListIterator<T>(const QListIterator<T> &li) {}
 
-// add copy constructor
-// this private declaration prevents copying
-#ifdef _KWQ_PEDANTIC_
-    QListIterator<T>(const QListIterator<T> &);
-#endif
-
+    KWQListIteratorImpl impl;
 }; // class QListIterator ======================================================
 
+
+template<class T>
+inline ostream &operator<<(ostream &stream, const QList<T> &l)
+{
+    QListIterator<T> iter(l);
+    unsigned count = l.count();
+
+    stream << "QList: [size: " << l.count() << "; items: ";
+
+    // print first
+    if (count != 0) {
+	stream << *iter.current();
+	++iter;
+	--count;
+    }
+    
+    // print rest
+    while(count != 0) {
+	stream << ", " << *iter.current();
+	++iter;
+	--count;
+    }
+
+    return stream << "]";
+}
+
 #endif // USING_BORROWED_QLIST
 
 #endif
diff --git a/WebCore/kwq/qt/qmap.h b/WebCore/kwq/qt/qmap.h
index 4c8b0dc..8a6c9a4 100644
--- a/WebCore/kwq/qt/qmap.h
+++ b/WebCore/kwq/qt/qmap.h
@@ -58,37 +58,6 @@ template <class K, class V> class QMapNode : private KWQMapNodeImpl
     // intentionally not defined
     QMapNode(const QMapNode<K,V>&node);
 
-    static QMapNode<K,V> *copyTree(const QMapNode<K,V> *node, 
-				   QMapNode<K,V> *subtreePredecessor, 
-				   QMapNode<K,V> *subtreeSuccessor)
-    {
-	if (node == NULL) {
-	    return NULL;
-	}
-
-	// FIXME: not exception-safe - use auto_ptr?
-	QMapNode<K,V> *copy = new QMapNode<K,V>(node->key, node->value);
-	copy->color = node->color;
-
-	if (node->prevIsChild) {
-	    copy->prevIsChild = true;
-	    copy->prev = copyTree((QMapNode<K,V> *)node->prev, subtreePredecessor, copy);
-	} else {
-	    copy->prevIsChild = false;
-	    copy->prev = subtreePredecessor;
-	}
-
-	if (node->nextIsChild) {
-	    copy->nextIsChild = true;
-	    copy->next = copyTree((QMapNode<K,V> *)node->next, copy, subtreeSuccessor);
-	} else {
-	    copy->nextIsChild = false;
-	    copy->next = subtreeSuccessor;
-	}
-
-	return copy;
-    }
-
     ~QMapNode()
     {
 	delete left();
@@ -230,9 +199,9 @@ public:
     }
 
 private:
-    QMapConstIterator(QMapNode<K,V> *n)
+    QMapConstIterator(const QMapNode<K,V> *n)
     {
-	node = n;
+	node = (KWQMapNodeImpl *)n;
     }
 
     friend class QMap<K,V>;
@@ -257,19 +226,17 @@ public:
 
 
     QMap() : 
-	KWQMapImpl(new QMapNode<K,V>(K(),V()), 0)
+	KWQMapImpl(new QMapNode<K,V>(K(),V()), deleteNode)
     {
     }
 
     QMap(const QMap<K,V>& m) :
-	KWQMapImpl(QMapNode<K,V>::copyTree((QMapNode<K,V> *)m.endInternal(), NULL, NULL), m.count())
+	KWQMapImpl(m)
     {
     }
 
     virtual ~QMap() 
     { 
-	clear();
-	delete endInternal();
     }
     
     // member functions --------------------------------------------------------
@@ -347,21 +314,21 @@ public:
 
 
 protected:
-    virtual void copyNode(KWQMapNodeImpl *isrc, KWQMapNodeImpl *idst) 
+    virtual void copyNode(const KWQMapNodeImpl *isrc, KWQMapNodeImpl *idst) const
     {
  	QMapNode<K,V> *src = (QMapNode<K,V> *)isrc;
  	QMapNode<K,V> *dst = (QMapNode<K,V> *)idst;
 	dst->key = src->key;
 	dst->value = src->value;
     }
-
-    virtual KWQMapNodeImpl *duplicateNode(KWQMapNodeImpl *isrc) 
+    
+    virtual KWQMapNodeImpl *duplicateNode(const KWQMapNodeImpl *isrc) const
     {
  	QMapNode<K,V> *src = (QMapNode<K,V> *)isrc;
 	return new QMapNode<K,V>(src->key, src->value);
     }
 
-    virtual CompareResult compareNodes(KWQMapNodeImpl *ia, KWQMapNodeImpl *ib) const
+    virtual CompareResult compareNodes(const KWQMapNodeImpl *ia, const KWQMapNodeImpl *ib) const
     {
  	QMapNode<K,V> *a = (QMapNode<K,V> *)ia;
  	QMapNode<K,V> *b = (QMapNode<K,V> *)ib;
@@ -375,7 +342,7 @@ protected:
 	}
     }
 
-    virtual void swapNodes(KWQMapNodeImpl *ia, KWQMapNodeImpl *ib)
+    virtual void swapNodes(KWQMapNodeImpl *ia, KWQMapNodeImpl *ib) const
     {
 	QMapNode<K,V> *a = (QMapNode<K,V> *)ia;
 	QMapNode<K,V> *b = (QMapNode<K,V> *)ib;
@@ -388,7 +355,7 @@ protected:
 	b->value = tmpValue;
     }
 
-    virtual void deleteNode(KWQMapNodeImpl *inode)
+    static void deleteNode(KWQMapNodeImpl *inode)
     {
 	delete (QMapNode<K,V> *)inode;
     }
diff --git a/WebCore/kwq/qt/qptrdict.h b/WebCore/kwq/qt/qptrdict.h
index d32c71f..35cf62f 100644
--- a/WebCore/kwq/qt/qptrdict.h
+++ b/WebCore/kwq/qt/qptrdict.h
@@ -37,7 +37,7 @@
 #else
 
 #include <KWQDef.h>
-#include <_qcollection.h>
+#include <qcollection.h>
 
 #include <KWQPtrDictImpl.h>
 
diff --git a/WebCore/kwq/qt/qvector.h b/WebCore/kwq/qt/qvector.h
index 6a5cc73..f5e2da5 100644
--- a/WebCore/kwq/qt/qvector.h
+++ b/WebCore/kwq/qt/qvector.h
@@ -36,79 +36,67 @@
 #include <_qvector.h>
 #else
 
-#include <KWQDef.h>
-#include <_qcollection.h>
+#include <iostream>
 
-typedef void *Item;
+#include <KWQDef.h>
+#include <qcollection.h>
 
-// class QGVector ==============================================================
+#include <KWQVectorImpl.h>
 
-class QGVector : public QCollection {
+// class QVector ===============================================================
+template<class T> class QVector : public QCollection  {
 public:
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-
-    // static member functions -------------------------------------------------
-
-    virtual int compareItems(Item, Item);
-
     // constructors, copy constructors, and destructors ------------------------
-    
-    QGVector();
-    QGVector(const QGVector &);
-    ~QGVector();
-    
-    // member functions --------------------------------------------------------
-    
-    // operators ---------------------------------------------------------------
-
-    QGVector &operator=(const QGVector &);
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
 
-}; // class QGVector ===========================================================
+    QVector() : impl(deleteFunc) {}
+    QVector(uint size) : impl(size, deleteFunc) {}
+    QVector(const QVector<T> &v) : impl(v.impl) {}
+    ~QVector() { if (del_item) { impl.clear(del_item); } }
 
+    // member functions --------------------------------------------------------
 
-// class QVector ===============================================================
+    void clear() { impl.clear(del_item); }
+    bool isEmpty() const { return impl.isEmpty(); }
+    uint count() const { return impl.count(); }
+    uint size() const { return impl.size(); }
+    bool remove(uint n) { return impl.remove(n, del_item); }
+    bool resize(uint size) { return impl.resize(size, del_item); }
+    bool insert(uint n, const T *item) {return impl.insert(n, item, del_item); }
+    T *at(int n) const {return (T *)impl.at(n); }
 
-template<class T> class QVector : public QGVector  {
-public:
+    virtual int compareItems(void *a, void *b) { return a != b; }
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-    // static member functions -------------------------------------------------
+    // operators ---------------------------------------------------------------
 
-    // constructors, copy constructors, and destructors ------------------------
+    T *operator[](int n) const {return (T *)impl.at(n); }
+    QVector &operator=(const QVector &v) 
+    { impl.assign(v.impl,del_item); QCollection::operator=(v); return *this; }
+ private:
+    static void deleteFunc(void *item) {
+	delete (T *)item;
+    }
 
-    QVector();
-    QVector(uint);
-    QVector(const QVector &);
-    ~QVector();
+    KWQVectorImpl impl;
+}; // class QVector ============================================================
 
-    // member functions --------------------------------------------------------
 
-    void clear();
-    bool isEmpty() const;
-    uint count() const;
-    uint size() const;
-    bool remove(uint);
-    bool resize(uint);
-    bool insert(uint, const T *);
-    T *at(int) const;
 
-    // operators ---------------------------------------------------------------
+template<class T>
+inline ostream &operator<<(ostream &stream, const QVector<T> &v)
+{
+    uint i = 0;
+    uint count = v.count();
 
-    T *operator[](int) const;
-    QVector &operator=(const QVector &);
+    stream << "QVector: [size: " << count << "; items: ";
 
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+    while(i < count ) {
+	stream << *v[i] << ", ";
+	++i;
+    }
 
-}; // class QVector ============================================================
+    return stream << "]";
+}
 
 #endif // USING_BORROWED_QVECTOR
 
diff --git a/WebCore/src/kdelibs/khtml/rendering/render_text.cpp b/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
index 193607b..149311c 100644
--- a/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
+++ b/WebCore/src/kdelibs/khtml/rendering/render_text.cpp
@@ -265,7 +265,7 @@ int TextSlaveArray::findFirstMatching(Item d) const
 	if ( (*this)[mid] == 0 )			// null item greater
 	    res = -1;
 	else
-	    res = ((QGVector*)this)->compareItems( d, (*this)[mid] );
+	    res = ((TextSlaveArray*)this)->compareItems( d, (*this)[mid] );
 	if ( res < 0 )
 	    n2 = mid - 1;
 	else if ( res > 0 )
@@ -278,7 +278,7 @@ int TextSlaveArray::findFirstMatching(Item d) const
     /* if ( !found )
 	return -1; */
     // search to first one equal or bigger
-    while ( found && (mid > 0) && !((QGVector*)this)->compareItems(d, (*this)[mid-1]) )
+    while ( found && (mid > 0) && !((TextSlaveArray*)this)->compareItems(d, (*this)[mid-1]) )
 	mid--;
     return mid;
 }
diff --git a/WebCore/kwq/KWQFrame.mm b/WebCore/src/kwq/KWQCollection.mm
similarity index 75%
copy from WebCore/kwq/KWQFrame.mm
copy to WebCore/src/kwq/KWQCollection.mm
index 292156a..886d0fe 100644
--- a/WebCore/kwq/KWQFrame.mm
+++ b/WebCore/src/kwq/KWQCollection.mm
@@ -22,44 +22,39 @@
  * (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 <KWQFrame.h>
 
-#include <kwqdebug.h>
+#include <qcollection.h>
 
-QFrame::QFrame()
+#ifndef USING_BORROWED_QCOLLECTION
+
+QCollection::QCollection() :
+    del_item(FALSE)
 {
-    _logNeverImplemented();
 }
 
-
-QFrame::QFrame(QWidget *parent)
+QCollection::QCollection(const QCollection &other) :
+    del_item(FALSE)
 {
-    _logNeverImplemented();
 }
 
-
-void QFrame::setFrameStyle(int)
+QCollection &QCollection::operator=(const QCollection &other)
 {
-    _logNeverImplemented();
+    return *this; // don't copy del_item
 }
 
-
-int QFrame::frameWidth() const
+QCollection::~QCollection()
 {
-    _logNeverImplemented();
-    return 0;
 }
 
-
-QFrame::QFrame(const QFrame &)
+bool QCollection::autoDelete()
 {
-    _logNeverImplemented();
+    return del_item;
 }
 
-
-QFrame &QFrame::operator=(const QFrame &)
+void QCollection::setAutoDelete(bool autoDelete)
 {
-    _logNeverImplemented();
-    return *this;
+    del_item = autoDelete;
 }
 
+#endif
+
diff --git a/WebCore/src/kwq/KWQListImpl.h b/WebCore/src/kwq/KWQListImpl.h
new file mode 100644
index 0000000..8ad0f50
--- /dev/null
+++ b/WebCore/src/kwq/KWQListImpl.h
@@ -0,0 +1,114 @@
+/*
+ * 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. 
+ */
+
+#ifndef KWQ_LIST_IMPL_H
+#define KWQ_LIST_IMPL_H
+
+#include <config.h>
+#include <KWQDef.h>
+
+#ifndef USING_BORROWED_QLIST
+
+class KWQListIteratorImpl;
+
+class KWQListImpl
+{
+public:
+    
+    KWQListImpl(void (*deleteFunc)(void *));
+    KWQListImpl(const KWQListImpl &impl);
+    ~KWQListImpl();
+     
+    bool isEmpty() const;
+    uint count() const;
+    void clear(bool deleteItems);
+    void sort(int (*compareFunc)(void *a, void *b, void *data), void *data); 
+
+    void *at(uint n);
+
+    bool insert(uint n, const void *item);
+    bool remove(bool deleteItem);
+    bool remove(uint n, bool deleteItem);
+    bool remove(const void *item, bool deleteItem, int (*compareFunc)(void *a, void *b, void *data), void *data);
+    bool removeFirst(bool deleteItem);
+    bool removeLast(bool deleteItem);
+    bool removeRef(const void *item, bool deleteItem);
+
+    void *getLast() const;
+    void *current() const;
+    void *first();
+    void *last();
+    void *next();
+    void *prev();
+    void *take(uint n);
+
+    void append(const void *item);
+    void prepend(const void *item);
+
+    uint containsRef(const void *item) const;
+
+    KWQListImpl &assign(const KWQListImpl &impl, bool deleteItems);
+
+ private:
+    void addIterator(KWQListIteratorImpl *iter) const;
+    void removeIterator(KWQListIteratorImpl *iter) const;
+
+    class KWQListPrivate;
+    KWQListPrivate *d;
+
+    friend class KWQListIteratorImpl;
+}; 
+
+
+class KWQListIteratorImpl {
+public:
+    KWQListIteratorImpl();
+    KWQListIteratorImpl(const KWQListImpl &impl);
+    KWQListIteratorImpl(const KWQListIteratorImpl &impl);
+    ~KWQListIteratorImpl();
+
+    uint count() const;
+    void *toFirst();
+    void *toLast();
+    void *current() const;
+
+    // operators ---------------------------------------------------------------
+
+    void *operator--();
+    void *operator++();
+
+    KWQListIteratorImpl &operator=(const KWQListIteratorImpl &impl);
+
+private:
+    class KWQListIteratorPrivate;
+
+    KWQListIteratorPrivate *d;
+
+    friend class KWQListImpl;
+};
+
+#endif
+
+#endif
diff --git a/WebCore/src/kwq/KWQListImpl.mm b/WebCore/src/kwq/KWQListImpl.mm
new file mode 100644
index 0000000..af65c29
--- /dev/null
+++ b/WebCore/src/kwq/KWQListImpl.mm
@@ -0,0 +1,599 @@
+/*
+ * 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 <KWQListImpl.h>
+
+#ifndef USING_BORROWED_QLIST
+
+#include <cstddef>
+
+#define Fixed MacFixed
+#define Rect MacRect
+#define Boolean MacBoolean
+#include <CoreFoundation/CFArray.h>
+#undef Fixed
+#undef Rect
+#undef Boolean
+
+// KWQListNode
+
+class KWQListNode
+{
+public:
+    KWQListNode() : data(NULL), next(NULL), prev(NULL) {}
+
+    void *data;
+    KWQListNode *next;
+    KWQListNode *prev;
+};
+
+
+// KWQListImpl::KWQListPrivate
+
+class KWQListImpl::KWQListPrivate
+{
+public:
+    KWQListPrivate(void (*deleteFunc)(void *));
+    KWQListPrivate(KWQListPrivate &vp);
+    ~KWQListPrivate();
+    
+    static KWQListNode *copyList(KWQListNode *l);
+
+    KWQListNode *head;
+    // KWQListNode *tail;
+    KWQListNode *current;
+    uint count;
+    void (*deleteItem)(void *);
+    KWQListNode *iterators;
+};
+
+KWQListNode *KWQListImpl::KWQListPrivate::copyList(KWQListNode *l)
+{
+    KWQListNode *node = l;
+    KWQListNode *head = NULL;
+    KWQListNode *last = NULL;
+
+    while (node != NULL) {
+	KWQListNode *copy = new KWQListNode;
+	copy->data = node->data;
+	if (last != NULL) {
+	    last->next = copy;
+	    copy->prev = last;
+	} else {
+	    head = copy;
+	    copy->prev = NULL;
+	}
+	copy->next = NULL;
+	
+	last = copy;
+	node = node->next;
+    }
+
+    return head;
+}
+
+KWQListImpl::KWQListPrivate::KWQListPrivate(void (*deleteFunc)(void *)) :
+    head(NULL),
+    current(NULL),
+    count(0),
+    deleteItem(deleteFunc),
+    iterators(NULL)
+{
+}
+
+KWQListImpl::KWQListPrivate::KWQListPrivate(KWQListPrivate &vp) :
+    head(copyList(vp.head)),
+    current(NULL),
+    count(vp.count),
+    deleteItem(vp.deleteItem),
+    iterators(NULL)
+{
+}
+
+KWQListImpl::KWQListPrivate::~KWQListPrivate()
+{
+    while (head != NULL) {
+	KWQListNode *tmp = head->next;
+	delete head;
+	head = tmp;
+    }
+}
+
+// KWQListIteratorImpl::KWQListIteratorPrivate
+
+class KWQListIteratorImpl::KWQListIteratorPrivate
+{
+public:
+    KWQListIteratorPrivate();
+    KWQListIteratorPrivate(const KWQListImpl &list, KWQListNode *n);
+
+    const KWQListImpl *list;
+    KWQListNode *node;
+};
+
+KWQListIteratorImpl::KWQListIteratorPrivate::KWQListIteratorPrivate() :
+    list(NULL),
+    node(NULL)
+{
+}
+
+KWQListIteratorImpl::KWQListIteratorPrivate::KWQListIteratorPrivate(const KWQListImpl &l, KWQListNode *n) :
+    list(&l),
+    node(n)
+{
+}
+
+
+
+// KWQListImpl
+
+KWQListImpl::KWQListImpl(void (*deleteFunc)(void *)) :
+    d(new KWQListImpl::KWQListPrivate(deleteFunc))
+{
+}
+
+KWQListImpl::KWQListImpl(const KWQListImpl &impl) :
+    d(new KWQListImpl::KWQListPrivate(*impl.d))
+{
+}
+
+KWQListImpl::~KWQListImpl()
+{
+    delete d;
+}
+     
+bool KWQListImpl::isEmpty() const
+{
+    return d->count == 0;
+}
+
+uint KWQListImpl::count() const
+{
+    return d->count;
+}
+
+void KWQListImpl::clear(bool deleteItems)
+{
+    if (deleteItems) {
+	KWQListNode *node = d->head;
+
+	while (node != NULL) {
+	    d->deleteItem(node->data);
+	    node = node->next;
+	}
+    }
+
+    delete d->head;
+    d->head = NULL;
+    d->current = NULL;
+    d->count = 0;
+}
+
+void KWQListImpl::sort(int (*compareFunc)(void *a, void *b, void *data), void *data)
+{
+    CFMutableArrayRef array = CFArrayCreateMutable(NULL, d->count, NULL);
+
+    for (KWQListNode *node = d->head; node != NULL; node = node->next) {
+	CFArrayAppendValue(array, node->data);
+    }
+
+    CFArraySortValues(array, CFRangeMake(0, d->count), (CFComparatorFunction) compareFunc, data);
+
+    int i = 0;
+    for (KWQListNode *node = d->head; node != NULL; node = node->next) {
+	node->data = (void *)CFArrayGetValueAtIndex(array, i);
+	i++;
+    }
+}
+
+void *KWQListImpl::at(uint n)
+{
+    d->current = d->head;
+    uint i = 0; 
+
+    while (i < n && d->current != NULL) {
+	d->current = d->current->next;
+	i++;
+    }
+
+    return d->current->data;
+}
+
+bool KWQListImpl::insert(uint n, const void *item)
+{
+    if (n > d->count) {
+	return false;
+    }
+
+    d->current = new KWQListNode;
+    d->current->data = (void *)item;
+
+    if (n == 0) {
+	// inserting at head
+	d->current->next = d->head;
+	if (d->head != NULL) {
+	    d->head->prev = d->current;
+	}
+	d->head = d->current;
+    } else {
+	// general insertion
+	
+	// iterate to one node before the insertion point, can't be null
+	// since we know n > 0 and n <= d->count
+	KWQListNode *node = d->head;
+
+	for  (unsigned i = 0; i < n - 1; i++) {
+	    node = node->next;
+	}
+	d->current->prev = node;
+	d->current->next = node->next;
+	if (node->next != NULL) {
+	    node->next->prev = d->current;
+	}
+	node->next = d->current;
+    }
+
+    d->count++;
+    return true;
+}
+
+bool KWQListImpl::remove(bool deleteItem)
+{
+    if (d->current == NULL) {
+	return false;
+    }
+
+    if (d->head == d->current) {
+	d->head = d->current->next;
+    } else {
+	d->current->prev->next = d->current->next;
+    }
+
+    if (d->current->next != NULL) {
+	d->current->next->prev = d->current->prev;
+    }
+
+    KWQListNode *detached = d->current;
+    if (detached->next != NULL) {
+	d->current = detached->next;
+    } else {
+	d->current = detached->prev;
+    }
+
+    detached->next = NULL;
+
+    if (deleteItem) {
+	d->deleteItem(detached->data);
+    }
+
+    for (KWQListNode *iterator = d->iterators; iterator != NULL; iterator = iterator->next) {
+	if (((KWQListIteratorImpl *)iterator->data)->d->node == detached) {
+	    ((KWQListIteratorImpl *)iterator->data)->d->node = d->current;
+	}
+    }
+    
+    delete detached;
+    d->count--;
+
+    return true;
+}
+
+bool KWQListImpl::remove(uint n, bool deleteItem)
+{
+    if (n >= d->count) {
+	return false;
+    }
+    
+    d->current = d->head;
+
+    for (uint i = 0; i < n; i++) {
+	d->current = d->current->next;
+    }
+
+    return remove(deleteItem);
+}
+
+bool KWQListImpl::removeFirst(bool deleteItem)
+{
+    return remove((unsigned)0, deleteItem);
+}
+
+bool KWQListImpl::removeLast(bool deleteItem)
+{
+    return remove(d->count - 1, deleteItem);
+}
+
+bool KWQListImpl::remove(const void *item, bool deleteItem, int (*compareFunc)(void *a, void *b, void *data), void *data)
+{
+    KWQListNode *node;
+
+    node = d->head;
+
+    while (node != NULL && compareFunc((void *)item, node->data, data) != 0) {
+	node = node->next;
+    }
+    
+    if (node == NULL) {
+	return false;
+    }
+
+    d->current = node;
+
+    return remove(deleteItem);
+}
+
+bool KWQListImpl::removeRef(const void *item, bool deleteItem)
+{
+    KWQListNode *node;
+
+    node = d->head;
+
+    while (node != NULL && item != node->data) {
+	node = node->next;
+    }
+    
+    if (node == NULL) {
+	return false;
+    }
+
+    d->current = node;
+
+    return remove(deleteItem);
+}
+
+void *KWQListImpl::getLast() const
+{
+    KWQListNode *node = d->head;
+
+    if (node == NULL) {
+	return NULL;
+    } 
+    
+    while (node->next != NULL) {
+	node = node->next;
+    }
+    return node->data;
+}
+
+void *KWQListImpl::current() const
+{
+    if (d->current != NULL) {
+	return d->current->data;
+    } else {
+	return NULL;
+    }
+}
+
+void *KWQListImpl::first()
+{
+    d->current = d->head;
+    return current();
+}
+
+void *KWQListImpl::last()
+{
+    if (d->head != NULL) {
+	d->current = d->head;
+	while (d->current->next != NULL) {
+	    d->current = d->current->next;
+	}
+    }
+    return current();
+}
+
+
+void *KWQListImpl::next()
+{
+    if (d->current != NULL) {
+	d->current = d->current->next;
+    }
+    return current();
+}
+
+void *KWQListImpl::prev()
+{
+    if (d->current != NULL) {
+	d->current = d->current->prev;
+    }
+    return current();
+}
+
+void *KWQListImpl::take(uint n)
+{
+    void *retval = at(n);
+    remove(false);
+    return retval;
+}
+
+void KWQListImpl::append(const void *item)
+{
+    insert(d->count, item);
+}
+
+void KWQListImpl::prepend(const void *item)
+{
+    insert(0, item);
+}
+
+uint KWQListImpl::containsRef(const void *item) const
+{
+    KWQListNode *node = d->head;
+
+    while (node != NULL && item != node->data) {
+	node = node->next;
+    }
+    
+    return node != NULL;
+}
+
+KWQListImpl &KWQListImpl::assign(const KWQListImpl &impl, bool deleteItems)
+{
+    KWQListImpl tmp(impl);
+    KWQListImpl::KWQListPrivate *tmpD = tmp.d;
+
+    tmp.d = d;
+    d = tmpD;
+
+    return *this;
+}
+
+
+void KWQListImpl::addIterator(KWQListIteratorImpl *iter) const
+{
+    KWQListNode *node = new KWQListNode();
+    node->data = iter;
+    node->next = d->iterators;
+    d->iterators = node;
+}
+
+void KWQListImpl::removeIterator(KWQListIteratorImpl *iter) const
+{
+    KWQListNode *node = d->iterators;
+
+    while (node != NULL && node->data != iter) {
+	node = node->next;
+    }
+
+    if (node != NULL) {
+ 	if (node->prev == NULL) {
+	    d->iterators = node->next;
+	} else {
+	    node->prev->next = node->next;
+	}
+
+ 	if (node->next != NULL) {
+	    node->next->prev = node->prev;
+	}
+
+	node->next = NULL;
+	delete node;
+    }
+}
+
+
+
+
+// KWQListIteratorImpl
+
+KWQListIteratorImpl::KWQListIteratorImpl() :
+    d(new KWQListIteratorImpl::KWQListIteratorPrivate())
+{
+}
+
+KWQListIteratorImpl::KWQListIteratorImpl(const KWQListImpl &impl)  :
+    d(new KWQListIteratorImpl::KWQListIteratorPrivate(impl, impl.d->head))
+{
+    d->list->addIterator(this);
+}
+
+KWQListIteratorImpl::~KWQListIteratorImpl()
+{
+    if (d->list != NULL) {
+	d->list->removeIterator(this);
+    }
+    delete d;
+}
+
+KWQListIteratorImpl::KWQListIteratorImpl(const KWQListIteratorImpl &impl) :
+    d(new KWQListIteratorImpl::KWQListIteratorPrivate(*impl.d->list, impl.d->node))
+{
+    d->list->addIterator(this);
+}
+
+uint KWQListIteratorImpl::count() const
+{
+    if (d->list == NULL) {
+	return 0;
+    } else {
+	return d->list->count();
+    }
+}
+
+void *KWQListIteratorImpl::toFirst()
+{
+    d->node = d->list->d->head;
+    return current();
+}
+
+void *KWQListIteratorImpl::toLast()
+{
+    d->node = d->list->d->head;
+    while (d->node != NULL && d->node->next != NULL) {
+	d->node = d->node->next;
+    }
+    return current();
+}
+
+void *KWQListIteratorImpl::current() const
+{
+    if (d->node == NULL) {
+	return NULL;
+    } else {
+	return d->node->data;
+    }
+}
+
+void *KWQListIteratorImpl::operator--()
+{
+    if (d->node != NULL) {
+	d->node = d->node->prev;
+    }
+    return current();
+}
+
+void *KWQListIteratorImpl::operator++()
+{
+    if (d->node != NULL) {
+	d->node = d->node->next;
+    }
+    return current();
+}
+
+KWQListIteratorImpl &KWQListIteratorImpl::operator=(const KWQListIteratorImpl &impl)
+{
+    KWQListIteratorImpl tmp(impl);
+    KWQListIteratorImpl::KWQListIteratorPrivate *tmpD = tmp.d;
+
+    if (d->list != NULL) {
+	d->list->removeIterator(this);
+    }
+    if (tmp.d->list != NULL) {
+	tmp.d->list->removeIterator(&tmp);
+    }
+
+    tmp.d = d;
+    d = tmpD;
+
+    if (tmp.d->list != NULL) {
+	tmp.d->list->addIterator(&tmp);
+    }
+    if (d->list != NULL) {
+	d->list->addIterator(this);
+    }
+
+    return *this;
+}
+
+#endif
diff --git a/WebCore/src/kwq/KWQMapImpl.h b/WebCore/src/kwq/KWQMapImpl.h
index 7c1be09..63e6455 100644
--- a/WebCore/src/kwq/KWQMapImpl.h
+++ b/WebCore/src/kwq/KWQMapImpl.h
@@ -33,6 +33,7 @@
 
 #ifndef USING_BORROWED_QMAP
 
+#include <KWQRefPtr.h>
 
 class KWQMapNodeImpl
 {
@@ -76,15 +77,16 @@ protected:
 
 class KWQMapImpl {
  private:
-    // disallow default construction, copy construction and assignment
-    KWQMapImpl();
-    KWQMapImpl(const KWQMapImpl &);
+    // disallow assignment
     KWQMapImpl &operator=(const KWQMapImpl &);
 
  protected:
     typedef enum { Less = -1, Equal = 0, Greater = 1 } CompareResult;
 
-    KWQMapImpl(KWQMapNodeImpl *node, uint count);
+    KWQMapImpl(KWQMapNodeImpl *guard, void (*deleteNode)(KWQMapNodeImpl *));
+    KWQMapImpl(const KWQMapImpl &impl);
+    KWQMapImpl();
+    virtual ~KWQMapImpl();
 
     KWQMapNodeImpl *findInternal(KWQMapNodeImpl *target) const;
     KWQMapNodeImpl *insertInternal(KWQMapNodeImpl *nodeToInsert, bool replaceExisting);
@@ -92,26 +94,32 @@ class KWQMapImpl {
     uint countInternal() const;
     void clearInternal();
     void swap(KWQMapImpl &map);
-    KWQMapNodeImpl *beginInternal() const;
-    KWQMapNodeImpl *endInternal() const;
+    const KWQMapNodeImpl *beginInternal() const;
+    const KWQMapNodeImpl *endInternal() const;
+    KWQMapNodeImpl *beginInternal();
+    KWQMapNodeImpl *endInternal();
 
-    virtual CompareResult compareNodes(KWQMapNodeImpl *a, KWQMapNodeImpl *b) const = 0;
-    virtual void copyNode(KWQMapNodeImpl *src, KWQMapNodeImpl *dst) = 0;
-    virtual KWQMapNodeImpl *duplicateNode(KWQMapNodeImpl *src) = 0;
-    virtual void swapNodes(KWQMapNodeImpl *a, KWQMapNodeImpl *b) = 0;
-    virtual void deleteNode(KWQMapNodeImpl *node) = 0;
+    virtual CompareResult compareNodes(const KWQMapNodeImpl *a, const KWQMapNodeImpl *b) const = 0;
+    virtual void copyNode(const KWQMapNodeImpl *src, KWQMapNodeImpl *dst) const = 0;
+    virtual KWQMapNodeImpl *duplicateNode(const KWQMapNodeImpl *src) const = 0;
+    virtual void swapNodes(KWQMapNodeImpl *a, KWQMapNodeImpl *b) const = 0;
 
  private:
     // can't possibly have a bigger height than this in a balanced tree
     static const int MAX_STACK = 64;
 
+    void copyOnWrite();
+    KWQMapNodeImpl *copyTree(const KWQMapNodeImpl *node, 
+			     KWQMapNodeImpl *subtreePredecessor, 
+			     KWQMapNodeImpl *subtreeSuccessor) const;
     void rebalanceAfterInsert(KWQMapNodeImpl **nodes, bool *wentLeft, int height);
     void rebalanceAfterRemove(KWQMapNodeImpl *nodeToRemove, KWQMapNodeImpl **nodes, bool *wentLeft, int height);
     void rotateRight(KWQMapNodeImpl *node, KWQMapNodeImpl *parent, bool leftParent);
     void rotateLeft(KWQMapNodeImpl *node, KWQMapNodeImpl *parent, bool leftParent);
 
-    KWQMapNodeImpl *guard;
-    uint numNodes;
+    class KWQMapPrivate;
+
+    KWQRefPtr<KWQMapPrivate> d;
 
 #ifdef QMAP_TESTING
     friend bool CheckRedBlackRules(KWQMapImpl *impl);
diff --git a/WebCore/src/kwq/KWQMapImpl.mm b/WebCore/src/kwq/KWQMapImpl.mm
index fdea9a4..21dd0bc 100644
--- a/WebCore/src/kwq/KWQMapImpl.mm
+++ b/WebCore/src/kwq/KWQMapImpl.mm
@@ -121,15 +121,93 @@ void KWQMapIteratorImpl::incrementInternal()
 }
 
 
+// KWQMapImplPrivate
+
+class KWQMapImpl::KWQMapPrivate
+{
+public:
+    KWQMapPrivate(KWQMapNodeImpl *node,
+		  uint count,
+		  void (*deleteFunc)(KWQMapNodeImpl *));
+
+    ~KWQMapPrivate();
+
+    KWQMapNodeImpl *guard;
+    uint numNodes;
+    int refCount;
+    void (*deleteNode)(KWQMapNodeImpl *);
+    friend class KWQRefPtr<KWQMapImpl::KWQMapPrivate>;
+};
+
+KWQMapImpl::KWQMapPrivate::KWQMapPrivate(KWQMapNodeImpl *node,
+					 uint count,
+					 void (*deleteFunc)(KWQMapNodeImpl *)) :
+    guard(node),
+    numNodes(count),
+    refCount(0),
+    deleteNode(deleteFunc)
+{
+}
+
+KWQMapImpl::KWQMapPrivate::~KWQMapPrivate()
+{
+    deleteNode(guard);
+}
+
 // KWQMapImpl
 
+KWQMapImpl::KWQMapImpl(KWQMapNodeImpl *guard, void (*deleteNode)(KWQMapNodeImpl *)) :
+    d(new KWQMapImpl::KWQMapPrivate(guard,0, deleteNode))
+{
+}
 
-KWQMapImpl::KWQMapImpl(KWQMapNodeImpl *node, uint count) :
-    guard(node),
-    numNodes(count)
+KWQMapImpl::KWQMapImpl(const KWQMapImpl &impl) :
+    d(impl.d)
+{
+}
+
+KWQMapImpl::~KWQMapImpl()
 {
 }
 
+void KWQMapImpl::copyOnWrite()
+{
+    if (d->refCount > 1) {
+	d = KWQRefPtr<KWQMapImpl::KWQMapPrivate>(new KWQMapImpl::KWQMapPrivate(copyTree(d->guard, NULL, NULL), d->numNodes, d->deleteNode));
+    }
+}
+
+KWQMapNodeImpl *KWQMapImpl::copyTree(const KWQMapNodeImpl *node, 
+				     KWQMapNodeImpl *subtreePredecessor, 
+				     KWQMapNodeImpl *subtreeSuccessor) const
+{
+    if (node == NULL) {
+	return NULL;
+    }
+    
+    // FIXME: not exception-safe - use auto_ptr?
+    KWQMapNodeImpl *copy = duplicateNode(node);
+    copy->color = node->color;
+    
+    if (node->prevIsChild) {
+	copy->prevIsChild = true;
+	copy->prev = copyTree(node->prev, subtreePredecessor, copy);
+    } else {
+	copy->prevIsChild = false;
+	copy->prev = subtreePredecessor;
+    }
+    
+    if (node->nextIsChild) {
+	copy->nextIsChild = true;
+	copy->next = copyTree(node->next, copy, subtreeSuccessor);
+    } else {
+	copy->nextIsChild = false;
+	copy->next = subtreeSuccessor;
+    }
+    
+    return copy;
+}
+
 void KWQMapImpl::rotateRight(KWQMapNodeImpl *node, KWQMapNodeImpl *parent, bool leftParent)
 {
     KWQMapNodeImpl *rotationChild = node->left();
@@ -178,7 +256,7 @@ void KWQMapImpl::rebalanceAfterInsert(KWQMapNodeImpl **nodes, bool *wentLeft, in
 {
     nodes[height]->color = KWQMapNodeImpl::Red;
     
-    while (nodes[height] != guard->prev && nodes[height-1]->color == KWQMapNodeImpl::Red) {
+    while (nodes[height] != d->guard->prev && nodes[height-1]->color == KWQMapNodeImpl::Red) {
 	if (wentLeft[height-2]) {
 	    KWQMapNodeImpl *uncle = nodes[height-2]->right();
 	    if (uncle != NULL && uncle->color == KWQMapNodeImpl::Red) {
@@ -229,13 +307,13 @@ void KWQMapImpl::rebalanceAfterInsert(KWQMapNodeImpl **nodes, bool *wentLeft, in
 	}
     }
     
-    guard->prev->color = KWQMapNodeImpl::Black;
+    d->guard->prev->color = KWQMapNodeImpl::Black;
 }
 
 void KWQMapImpl::rebalanceAfterRemove(KWQMapNodeImpl *nodeToRemove, KWQMapNodeImpl **nodes, bool *wentLeft, int height) 
 {
     if (nodeToRemove->color == KWQMapNodeImpl::Black) {
-	while (nodes[height] != guard->prev && (nodes[height]==NULL || nodes[height]->color==KWQMapNodeImpl::Black)) {
+	while (nodes[height] != d->guard->prev && (nodes[height]==NULL || nodes[height]->color==KWQMapNodeImpl::Black)) {
 	    if (wentLeft[height-1]) {
 		KWQMapNodeImpl *sibling = nodes[height-1]->right();
 		if (sibling != NULL && sibling->color == KWQMapNodeImpl::Red) {
@@ -267,7 +345,7 @@ void KWQMapImpl::rebalanceAfterRemove(KWQMapNodeImpl *nodeToRemove, KWQMapNodeIm
 		    sibling->right()->color = KWQMapNodeImpl::Black;
 		    rotateLeft(nodes[height-1], nodes[height-2], wentLeft[height-2]);
 		    
-		    nodes[height] = guard->prev;
+		    nodes[height] = d->guard->prev;
 		}
 	    } else {
 		// same as the other branch, but with left and right swapped
@@ -302,7 +380,7 @@ void KWQMapImpl::rebalanceAfterRemove(KWQMapNodeImpl *nodeToRemove, KWQMapNodeIm
 		    sibling->left()->color = KWQMapNodeImpl::Black;
 		    rotateRight(nodes[height-1], nodes[height-2], wentLeft[height-2]);
 		    
-		    nodes[height] = guard->prev;
+		    nodes[height] = d->guard->prev;
 		}
 	    }
 	}
@@ -315,7 +393,7 @@ void KWQMapImpl::rebalanceAfterRemove(KWQMapNodeImpl *nodeToRemove, KWQMapNodeIm
 
 KWQMapNodeImpl *KWQMapImpl::findInternal(KWQMapNodeImpl *target) const
 {
-    KWQMapNodeImpl *node = guard->left();
+    KWQMapNodeImpl *node = d->guard->left();
     
     while (node != NULL) {
 	CompareResult compare = compareNodes(target,node);
@@ -338,11 +416,13 @@ KWQMapNodeImpl *KWQMapImpl::insertInternal(KWQMapNodeImpl *nodeToInsert, bool re
     bool wentLeftStack[MAX_STACK];
     int height = 0;
     
-    nodeStack[height] = guard;
+    copyOnWrite();
+
+    nodeStack[height] = d->guard;
     wentLeftStack[height] = true;
     height++;
     
-    KWQMapNodeImpl *node = guard->left();
+    KWQMapNodeImpl *node = d->guard->left();
     
     while (node != NULL) {
 	CompareResult compare = compareNodes(nodeToInsert, node);
@@ -395,7 +475,7 @@ KWQMapNodeImpl *KWQMapImpl::insertInternal(KWQMapNodeImpl *nodeToInsert, bool re
     }
     
     rebalanceAfterInsert(nodeStack, wentLeftStack, height);
-    numNodes++;
+    d->numNodes++;
 
     return node;
 }
@@ -406,11 +486,13 @@ void KWQMapImpl::removeInternal(KWQMapNodeImpl *nodeToDelete)
     bool wentLeftStack[MAX_STACK];
     int height = 0;
     
-    nodeStack[height] = guard;
+    copyOnWrite();
+
+    nodeStack[height] = d->guard;
     wentLeftStack[height] = true;
     height++;
     
-    KWQMapNodeImpl *node = guard->left();
+    KWQMapNodeImpl *node = d->guard->left();
     
     while (node != NULL) {
 	CompareResult compare = compareNodes(nodeToDelete, node);
@@ -509,38 +591,55 @@ void KWQMapImpl::removeInternal(KWQMapNodeImpl *nodeToDelete)
     nodeToRemove->next = NULL;
     nodeToRemove->prev = NULL;
     
-    numNodes--;
-    deleteNode(nodeToRemove);
+    d->numNodes--;
+    d->deleteNode(nodeToRemove);
 }
 
 void KWQMapImpl::swap(KWQMapImpl &map)
 {
-    KWQMapNodeImpl *tmp = guard;
-    guard = map.guard;
-    map.guard = tmp;
-    
-    uint tmpNumNodes = numNodes;
-    numNodes = map.numNodes;
-    map.numNodes = tmpNumNodes;
+    KWQRefPtr<KWQMapImpl::KWQMapPrivate> tmp = d;
+    d = map.d;
+    map.d = d;
 }
 
 uint KWQMapImpl::countInternal() const
 {
-    return numNodes;
+    return d->numNodes;
 }
 
 void KWQMapImpl::clearInternal()
 {
-    deleteNode(guard->prev);
-    guard->prev = NULL;
-    numNodes = 0;
+    copyOnWrite();
+
+    d->deleteNode(d->guard->prev);
+    d->guard->prev = NULL;
+    d->numNodes = 0;
+}
+
+const KWQMapNodeImpl *KWQMapImpl::beginInternal() const
+{
+    KWQMapNodeImpl *node;
+    
+    node = d->guard;
+    while (node->left() != NULL) {
+	node = node->left();
+    }
+    
+    return node;
 }
 
-KWQMapNodeImpl *KWQMapImpl::beginInternal() const
+const KWQMapNodeImpl *KWQMapImpl::endInternal() const
+{
+    return d->guard;
+}
+
+KWQMapNodeImpl *KWQMapImpl::beginInternal()
 {
     KWQMapNodeImpl *node;
     
-    node = guard;
+    copyOnWrite();
+
+    node = d->guard;
     while (node->left() != NULL) {
 	node = node->left();
     }
@@ -548,9 +647,12 @@ KWQMapNodeImpl *KWQMapImpl::beginInternal() const
     return node;
 }
 
-KWQMapNodeImpl *KWQMapImpl::endInternal() const
+KWQMapNodeImpl *KWQMapImpl::endInternal()
 {
-    return guard;
+    copyOnWrite();
+    return d->guard;
 }
 
+
+
 #endif
diff --git a/WebCore/src/kwq/KWQArrayImpl.h b/WebCore/src/kwq/KWQVectorImpl.h
similarity index 68%
copy from WebCore/src/kwq/KWQArrayImpl.h
copy to WebCore/src/kwq/KWQVectorImpl.h
index b588a8a..bc74b41 100644
--- a/WebCore/src/kwq/KWQArrayImpl.h
+++ b/WebCore/src/kwq/KWQVectorImpl.h
@@ -23,41 +23,40 @@
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
 
-#ifndef KWQ_ARRAY_IMPL_H
-#define KWQ_ARRAY_IMPL_H
+#ifndef KWQ_VECTOR_IMPL_H
+#define KWQ_VECTOR_IMPL_H
 
 #include <config.h>
-#include <KWQRefPtr.h>
 #include <KWQDef.h>
-#include <stddef.h>
 
-#ifndef USING_BORROWED_QARRAY
+#ifndef USING_BORROWED_QVECTOR
 
-class KWQArrayImpl
+class KWQVectorImpl
 {
  public:
-    KWQArrayImpl(size_t itemSize);
-    KWQArrayImpl(size_t itemSize, size_t numItems);
-    KWQArrayImpl(const KWQArrayImpl &);
-    ~KWQArrayImpl();
-    
-    KWQArrayImpl &operator=(const KWQArrayImpl &);
-    
-    void *at(size_t pos) const;
-    void *data() const;
+    KWQVectorImpl(void (*deleteFunc)(void *));
+    KWQVectorImpl(uint size, void (*deleteFunc)(void *));
+    KWQVectorImpl(const KWQVectorImpl &vi);
+    ~KWQVectorImpl();
+
+    void clear(bool delItems);
+    bool isEmpty() const;
+    uint count() const;
     uint size() const;
-    bool resize(size_t size);
-    void duplicate(const void *data, size_t size);
-    bool fill(const void *item, int size = -1);
-    
-    bool operator==(const KWQArrayImpl &) const;
+    bool remove(uint n, bool delItems); 
+    bool resize(uint size, bool delItems);
+    bool insert(uint n, const void *item, bool delItems);
+    void *at(int n) const;
+    KWQVectorImpl &assign (KWQVectorImpl &vi, bool delItems);
+
  private:
-    class KWQArrayPrivate;
+    void KWQVectorImpl::swap(KWQVectorImpl &di);
 
-    KWQRefPtr<KWQArrayPrivate> d;
+    class KWQVectorPrivate;
+    KWQVectorPrivate *d;
 };
 
-#endif
 
 #endif
 
+#endif
diff --git a/WebCore/src/kwq/KWQVectorImpl.mm b/WebCore/src/kwq/KWQVectorImpl.mm
new file mode 100644
index 0000000..0186e92
--- /dev/null
+++ b/WebCore/src/kwq/KWQVectorImpl.mm
@@ -0,0 +1,232 @@
+/*
+ * 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 <KWQVectorImpl.h>
+
+#ifndef USING_BORROWED_QVECTOR
+
+#define Fixed MacFixed
+#define Rect MacRect
+#define Boolean MacBoolean
+#include <CoreFoundation/CFArray.h>
+#undef Fixed
+#undef Rect
+#undef Boolean
+
+#include <new>
+
+class KWQVectorImpl::KWQVectorPrivate
+{
+public:
+    KWQVectorPrivate(int size, void (*deleteFunc)(void *));
+    KWQVectorPrivate(KWQVectorPrivate &vp);
+    ~KWQVectorPrivate();
+    
+    CFMutableArrayRef cfarray;
+    uint size;
+    uint count;
+    uint max;
+    void (*deleteItem)(void *);
+};
+
+KWQVectorImpl::KWQVectorPrivate::KWQVectorPrivate(int sz, void (*deleteFunc)(void *)) :
+    cfarray(CFArrayCreateMutable(NULL, 0, NULL)),
+    size(sz),
+    count(0),
+    max(0),
+    deleteItem(deleteFunc)
+{
+    if (cfarray == NULL) {
+	throw bad_alloc();
+    }
+}
+
+KWQVectorImpl::KWQVectorPrivate::KWQVectorPrivate(KWQVectorPrivate &vp) :
+    cfarray(CFArrayCreateMutableCopy(NULL, 0, vp.cfarray)),
+    size(vp.size),
+    count(vp.count),
+    max(vp.max),
+    deleteItem(vp.deleteItem)
+{
+    if (cfarray == NULL) {
+	throw bad_alloc();
+    }
+}
+
+KWQVectorImpl::KWQVectorPrivate::~KWQVectorPrivate()
+{
+    CFRelease(cfarray);
+}
+
+
+KWQVectorImpl::KWQVectorImpl(void (*deleteFunc)(void *)) :
+    d(new KWQVectorImpl::KWQVectorPrivate(0, deleteFunc))
+{
+}
+
+KWQVectorImpl::KWQVectorImpl(uint size, void (*deleteFunc)(void *)) :
+    d(new KWQVectorImpl::KWQVectorPrivate(size, deleteFunc))
+{
+}
+
+KWQVectorImpl::KWQVectorImpl(const KWQVectorImpl &vi) : 
+    d(new KWQVectorImpl::KWQVectorPrivate(*vi.d))
+{
+}
+
+KWQVectorImpl::~KWQVectorImpl()
+{
+    delete d;
+}
+
+void KWQVectorImpl::clear(bool delItems)
+{
+    if (delItems) {
+	while (d->max > 0) {
+	    d->max--;
+	    void *item = (void *)CFArrayGetValueAtIndex(d->cfarray, d->max);
+	    if (item != NULL) {
+		d->deleteItem(item);
+	    }
+	}
+    }
+
+    CFArrayRemoveAllValues(d->cfarray);
+    d->count = 0;
+    d->max = 0;
+}
+
+bool KWQVectorImpl::isEmpty() const
+{
+    return d->count == 0;
+}
+
+uint KWQVectorImpl::count() const
+{
+    return d->count;
+}
+
+uint KWQVectorImpl::size() const
+{
+    return d->size;
+}
+
+bool KWQVectorImpl::remove(uint n, bool delItems)
+{
+    if (n < d->max) {
+	void *item = (void *)CFArrayGetValueAtIndex(d->cfarray, n);
+	
+	if (item != NULL) {
+	    if (delItems) {
+		d->deleteItem(item);
+	    }
+	    
+	    CFArraySetValueAtIndex(d->cfarray, n, NULL);
+	    
+	    d->count--;
+	}
+	return true;
+    } else {
+	return false;
+    }
+}
+
+bool KWQVectorImpl::resize(uint size, bool delItems)
+{
+    d->size = size;
+
+    while (d->max > size) {
+	d->max--;
+	void *item = (void *)CFArrayGetValueAtIndex(d->cfarray, d->max);
+
+	if (item != NULL) {
+	    if (delItems) {
+		d->deleteItem(item);
+	    }
+	    d->count--;
+	}
+	CFArrayRemoveValueAtIndex(d->cfarray, d->max);
+    }
+
+    return true;
+}
+
+bool KWQVectorImpl::insert(uint n, const void *item, bool delItems)
+{
+    if (n >= d->size) {
+	return false;
+    }
+
+    if (n < d->max) {
+	void *item = (void *)CFArrayGetValueAtIndex(d->cfarray, n);
+	if (item != NULL) {
+	    if (delItems) {
+		d->deleteItem((void *)CFArrayGetValueAtIndex(d->cfarray, n));
+	    }
+	} else {
+	    d->count++;
+	}
+    }  else {
+	while (n > d->max) {
+	    CFArraySetValueAtIndex(d->cfarray, d->max, NULL);
+	    d->max++;
+	}
+	d->max++;
+	d->count++;
+    }
+
+    CFArraySetValueAtIndex(d->cfarray, n, item);
+
+    return true;
+}
+
+void *KWQVectorImpl::at(int n) const
+{
+    if ((unsigned)n >= d->max) {
+	return NULL;
+    }
+
+    return (void *)CFArrayGetValueAtIndex(d->cfarray, n);
+}
+
+KWQVectorImpl &KWQVectorImpl::assign (KWQVectorImpl &vi, bool delItems)
+{
+    KWQVectorImpl tmp(vi);
+
+    swap(tmp);
+
+    return *this;
+}
+
+void KWQVectorImpl::KWQVectorImpl::swap(KWQVectorImpl &di)
+{
+    KWQVectorImpl::KWQVectorPrivate *tmp = d;
+    d = di.d;
+    di.d = tmp;
+}
+
+
+#endif
+
diff --git a/WebCore/src/kwq/Makefile.am b/WebCore/src/kwq/Makefile.am
index 75ea1c6..f34950e 100644
--- a/WebCore/src/kwq/Makefile.am
+++ b/WebCore/src/kwq/Makefile.am
@@ -20,6 +20,7 @@ libkwq_o_SOURCES = \
 	KWQChar.mm \
 	KWQCharsets.mm \
 	KWQCheckBox.mm \
+	KWQCollection.mm \
 	KWQColor.mm \
 	KWQColorGroup.mm \
 	KWQComboBox.mm \
@@ -87,6 +88,7 @@ libkwq_o_SOURCES = \
 	KWQLabel.mm \
 	KWQLineEdit.mm \
 	KWQListBox.mm \
+	KWQListImpl.mm \
 	KWQMapImpl.mm \
 	KWQMovie.mm \
 	KWQNSTextField.mm \
@@ -113,6 +115,7 @@ libkwq_o_SOURCES = \
 	KWQTimer.mm \
 	KWQToolTip.mm \
 	KWQVariant.mm \
+	KWQVectorImpl.mm \
 	KWQView.mm \
 	KWQWMatrix.mm \
 	KWQWidget.mm \
diff --git a/WebCore/src/kwq/qt/_qcollection.h b/WebCore/src/kwq/qt/_qcollection.h
index 63d676e..c8bc9d5 100644
--- a/WebCore/src/kwq/qt/_qcollection.h
+++ b/WebCore/src/kwq/qt/_qcollection.h
@@ -35,8 +35,8 @@
 **
 **********************************************************************/
 
-#ifndef QCOLLECTION_H
-#define QCOLLECTION_H
+#ifndef _QCOLLECTION_H
+#define _QCOLLECTION_H
 
 // KWQ hacks ---------------------------------------------------------------
 
@@ -71,4 +71,4 @@ protected:
 };
 
 
-#endif // QCOLLECTION_H
+#endif // _QCOLLECTION_H
diff --git a/WebCore/src/kwq/qt/_qcollection.h b/WebCore/src/kwq/qt/qcollection.h
similarity index 66%
copy from WebCore/src/kwq/qt/_qcollection.h
copy to WebCore/src/kwq/qt/qcollection.h
index 63d676e..e91b1d7 100644
--- a/WebCore/src/kwq/qt/_qcollection.h
+++ b/WebCore/src/kwq/qt/qcollection.h
@@ -38,37 +38,32 @@
 #ifndef QCOLLECTION_H
 #define QCOLLECTION_H
 
-// KWQ hacks ---------------------------------------------------------------
+#include <config.h>
 
 #include <KWQDef.h>
 
-// -------------------------------------------------------------------------
+#ifdef USING_BORROWED_QCOLLECTION
 
-class QGVector;
-class QGList;
-class QGDict;
+#include <_qcollection.h>
 
-class Q_EXPORT QCollection			// inherited by all collections
-{
-public:
-    bool autoDelete()	const	       { return del_item; }
-    void setAutoDelete( bool enable )  { del_item = enable; }
+#else
 
-    virtual uint  count() const = 0;
-    virtual void  clear() = 0;			// delete all objects
+class QCollection {
+ public:
+    typedef void *Item;
 
-    typedef void *Item;				// generic collection item
-
-protected:
-    QCollection() { del_item = FALSE; }		// no deletion of objects
-    QCollection(const QCollection &) { del_item = FALSE; }
-    virtual ~QCollection() {}
+    bool autoDelete();
+    void setAutoDelete(bool autoDelete);
+ protected:
+    QCollection();
+    QCollection(const QCollection &);
+    QCollection &operator=(const QCollection &);
+    virtual ~QCollection();
 
     bool del_item;				// default FALSE
-
-    virtual Item     newItem( Item );		// create object
-    virtual void     deleteItem( Item );	// delete object
 };
 
+#endif /* USING_BORROWED_QCOLLECTION */
+
+#endif /* QCOLLECTION_H */
 
-#endif // QCOLLECTION_H
diff --git a/WebCore/src/kwq/qt/qdict.h b/WebCore/src/kwq/qt/qdict.h
index a3ee0f4..a496550 100644
--- a/WebCore/src/kwq/qt/qdict.h
+++ b/WebCore/src/kwq/qt/qdict.h
@@ -39,7 +39,7 @@
 #else
 
 
-#include <_qcollection.h>
+#include <qcollection.h>
 #include <qstring.h>
 
 #include <KWQDictImpl.h>
diff --git a/WebCore/src/kwq/qt/qlist.h b/WebCore/src/kwq/qt/qlist.h
index f0cdb1b..c555eea 100644
--- a/WebCore/src/kwq/qt/qlist.h
+++ b/WebCore/src/kwq/qt/qlist.h
@@ -36,62 +36,77 @@
 #include <_qlist.h>
 #else
 
+#include <iostream>
+
 #include <KWQDef.h>
-#include <_qcollection.h>
+#include <qcollection.h>
+
+#include <KWQListImpl.h>
 
 // class QList =================================================================
 
+template <class T> class QListIterator;
+
 template <class T> class QList : public QCollection {
 public:
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-    // static member functions -------------------------------------------------
     // constructors, copy constructors, and destructors ------------------------
     
-    QList();
-    QList(const QList<T> &);
-    ~QList(); 
+    QList() : impl(deleteFunc) {}
+    QList(const QList<T> &l) : impl(l.impl) {}
+    ~QList() { if (del_item) { impl.clear(del_item); } }
      
     // member functions --------------------------------------------------------
 
-    bool isEmpty() const;
-    uint count() const;
-    void clear();
-    void sort();
+    bool isEmpty() const { return impl.isEmpty(); }
+    uint count() const { return impl.count(); }
+    void clear() { impl.clear(del_item); }
+    void sort() { impl.sort(compareFunc, this); }
 
-    T *at(uint);
+    T *at(uint n) { return (T *)impl.at(n); }
 
-    void setAutoDelete(bool);
+    bool insert(uint n, const T *item) { return impl.insert(n, item); }
+    bool remove() {return impl.remove(del_item); }
+    bool remove(uint n) {return impl.remove(n, del_item); }
+    bool remove(const T *item) { return impl.remove(item, del_item, compareFunc, this); }
+    bool removeFirst() { return impl.removeFirst(del_item); }
+    bool removeLast() { return impl.removeLast(del_item); }
+    bool removeRef(const T *item) { return impl.removeRef(item, del_item); }
 
-    bool insert(uint i, const T *);
-    bool remove();
-    bool remove(const T *);
-    bool removeFirst();
-    bool removeLast();
-    bool removeRef(const T *);
+    T *getLast() const { return (T *)impl.getLast(); }
+    T *current() const { return (T *)impl.current(); }
+    T *first() { return (T *)impl.first(); }
+    T *last() { return (T *)impl.last(); }
+    T *next() { return (T *)impl.next(); }
+    T *prev() { return (T *)impl.prev(); }
+    T *take(uint n) { return (T *)impl.take(n); }
 
-    T *getLast() const;
-    T *current() const;
-    T *first();
-    T *last();
-    T *next();
-    T *prev();
-    T *take(uint i);
+    void append(const T *item) { impl.append(item); }
+    void prepend(const T *item) { impl.prepend(item); }
 
-    void append(const T *);
-    void prepend(const T *);
+    uint containsRef(const T *item) const { return impl.containsRef(item); }
 
-    uint containsRef(const T *) const;
+    virtual int compareItems(void *a, void *b) { return a != b; }
 
     // operators ---------------------------------------------------------------
 
-    QList<T> &operator=(const QList<T> &);
+    QList<T> &operator=(const QList<T> &l)
+    { impl.assign(l.impl,del_item); QCollection::operator=(l); return *this; }
+
+ private:
+    static void deleteFunc(void *item) {
+	delete (T *)item;
+    }
 
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+    static int compareFunc(void *a, void *b, void *data)
+    {
+	QList<T> *l = (QList<T> *)data;
+	return l->compareItems(a, b);
+    }
 
+    friend class QListIterator<T>;
+
+    KWQListImpl impl;
 }; // class QList ==============================================================
 
 
@@ -100,48 +115,58 @@ public:
 template <class T> class QListIterator {
 public:
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-    // static member functions -------------------------------------------------
-    
     // constructors, copy constructors, and destructors ------------------------
 
-// add no-arg constructor
-#ifdef _KWQ_PEDANTIC_
     QListIterator() {}
-#endif
-
-    QListIterator(const QList<T> &);
-    ~QListIterator();
+    QListIterator(const QList<T> &l) : impl(l.impl) {}
+    ~QListIterator() {}
 
     // member functions --------------------------------------------------------
 
-    uint count() const;
-    T *toFirst();
-    T *toLast();
-    T *current() const;
+    uint count() const { return impl.count(); }
+    T *toFirst() { return (T *)impl.toFirst(); }
+    T *toLast() { return (T *)impl.toLast(); }
+    T *current() const { return (T *)impl.current(); }
 
     // operators ---------------------------------------------------------------
 
-    operator T *() const;
-    T *operator--();
-    T *operator++();
-    QListIterator<T> &operator=(const QListIterator<T> &);
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+    operator T *() const { return (T *)impl.current(); }
+    T *operator--() { return (T *)(--impl); }
+    T *operator++()  { return (T *)(++impl); }
+    QListIterator<T> &operator=(const QListIterator<T> &li) { impl = li.impl; return *this; }
 
 private:
+    QListIterator<T>(const QListIterator<T> &li) {}
 
-// add copy constructor
-// this private declaration prevents copying
-#ifdef _KWQ_PEDANTIC_
-    QListIterator<T>(const QListIterator<T> &);
-#endif
-
+    KWQListIteratorImpl impl;
 }; // class QListIterator ======================================================
 
+
+template<class T>
+inline ostream &operator<<(ostream &stream, const QList<T> &l)
+{
+    QListIterator<T> iter(l);
+    unsigned count = l.count();
+
+    stream << "QList: [size: " << l.count() << "; items: ";
+
+    // print first
+    if (count != 0) {
+	stream << *iter.current();
+	++iter;
+	--count;
+    }
+    
+    // print rest
+    while(count != 0) {
+	stream << ", " << *iter.current();
+	++iter;
+	--count;
+    }
+
+    return stream << "]";
+}
+
 #endif // USING_BORROWED_QLIST
 
 #endif
diff --git a/WebCore/src/kwq/qt/qmap.h b/WebCore/src/kwq/qt/qmap.h
index 4c8b0dc..8a6c9a4 100644
--- a/WebCore/src/kwq/qt/qmap.h
+++ b/WebCore/src/kwq/qt/qmap.h
@@ -58,37 +58,6 @@ template <class K, class V> class QMapNode : private KWQMapNodeImpl
     // intentionally not defined
     QMapNode(const QMapNode<K,V>&node);
 
-    static QMapNode<K,V> *copyTree(const QMapNode<K,V> *node, 
-				   QMapNode<K,V> *subtreePredecessor, 
-				   QMapNode<K,V> *subtreeSuccessor)
-    {
-	if (node == NULL) {
-	    return NULL;
-	}
-
-	// FIXME: not exception-safe - use auto_ptr?
-	QMapNode<K,V> *copy = new QMapNode<K,V>(node->key, node->value);
-	copy->color = node->color;
-
-	if (node->prevIsChild) {
-	    copy->prevIsChild = true;
-	    copy->prev = copyTree((QMapNode<K,V> *)node->prev, subtreePredecessor, copy);
-	} else {
-	    copy->prevIsChild = false;
-	    copy->prev = subtreePredecessor;
-	}
-
-	if (node->nextIsChild) {
-	    copy->nextIsChild = true;
-	    copy->next = copyTree((QMapNode<K,V> *)node->next, copy, subtreeSuccessor);
-	} else {
-	    copy->nextIsChild = false;
-	    copy->next = subtreeSuccessor;
-	}
-
-	return copy;
-    }
-
     ~QMapNode()
     {
 	delete left();
@@ -230,9 +199,9 @@ public:
     }
 
 private:
-    QMapConstIterator(QMapNode<K,V> *n)
+    QMapConstIterator(const QMapNode<K,V> *n)
     {
-	node = n;
+	node = (KWQMapNodeImpl *)n;
     }
 
     friend class QMap<K,V>;
@@ -257,19 +226,17 @@ public:
 
 
     QMap() : 
-	KWQMapImpl(new QMapNode<K,V>(K(),V()), 0)
+	KWQMapImpl(new QMapNode<K,V>(K(),V()), deleteNode)
     {
     }
 
     QMap(const QMap<K,V>& m) :
-	KWQMapImpl(QMapNode<K,V>::copyTree((QMapNode<K,V> *)m.endInternal(), NULL, NULL), m.count())
+	KWQMapImpl(m)
     {
     }
 
     virtual ~QMap() 
     { 
-	clear();
-	delete endInternal();
     }
     
     // member functions --------------------------------------------------------
@@ -347,21 +314,21 @@ public:
 
 
 protected:
-    virtual void copyNode(KWQMapNodeImpl *isrc, KWQMapNodeImpl *idst) 
+    virtual void copyNode(const KWQMapNodeImpl *isrc, KWQMapNodeImpl *idst) const
     {
  	QMapNode<K,V> *src = (QMapNode<K,V> *)isrc;
  	QMapNode<K,V> *dst = (QMapNode<K,V> *)idst;
 	dst->key = src->key;
 	dst->value = src->value;
     }
-
-    virtual KWQMapNodeImpl *duplicateNode(KWQMapNodeImpl *isrc) 
+    
+    virtual KWQMapNodeImpl *duplicateNode(const KWQMapNodeImpl *isrc) const
     {
  	QMapNode<K,V> *src = (QMapNode<K,V> *)isrc;
 	return new QMapNode<K,V>(src->key, src->value);
     }
 
-    virtual CompareResult compareNodes(KWQMapNodeImpl *ia, KWQMapNodeImpl *ib) const
+    virtual CompareResult compareNodes(const KWQMapNodeImpl *ia, const KWQMapNodeImpl *ib) const
     {
  	QMapNode<K,V> *a = (QMapNode<K,V> *)ia;
  	QMapNode<K,V> *b = (QMapNode<K,V> *)ib;
@@ -375,7 +342,7 @@ protected:
 	}
     }
 
-    virtual void swapNodes(KWQMapNodeImpl *ia, KWQMapNodeImpl *ib)
+    virtual void swapNodes(KWQMapNodeImpl *ia, KWQMapNodeImpl *ib) const
     {
 	QMapNode<K,V> *a = (QMapNode<K,V> *)ia;
 	QMapNode<K,V> *b = (QMapNode<K,V> *)ib;
@@ -388,7 +355,7 @@ protected:
 	b->value = tmpValue;
     }
 
-    virtual void deleteNode(KWQMapNodeImpl *inode)
+    static void deleteNode(KWQMapNodeImpl *inode)
     {
 	delete (QMapNode<K,V> *)inode;
     }
diff --git a/WebCore/src/kwq/qt/qptrdict.h b/WebCore/src/kwq/qt/qptrdict.h
index d32c71f..35cf62f 100644
--- a/WebCore/src/kwq/qt/qptrdict.h
+++ b/WebCore/src/kwq/qt/qptrdict.h
@@ -37,7 +37,7 @@
 #else
 
 #include <KWQDef.h>
-#include <_qcollection.h>
+#include <qcollection.h>
 
 #include <KWQPtrDictImpl.h>
 
diff --git a/WebCore/src/kwq/qt/qvector.h b/WebCore/src/kwq/qt/qvector.h
index 6a5cc73..f5e2da5 100644
--- a/WebCore/src/kwq/qt/qvector.h
+++ b/WebCore/src/kwq/qt/qvector.h
@@ -36,79 +36,67 @@
 #include <_qvector.h>
 #else
 
-#include <KWQDef.h>
-#include <_qcollection.h>
+#include <iostream>
 
-typedef void *Item;
+#include <KWQDef.h>
+#include <qcollection.h>
 
-// class QGVector ==============================================================
+#include <KWQVectorImpl.h>
 
-class QGVector : public QCollection {
+// class QVector ===============================================================
+template<class T> class QVector : public QCollection  {
 public:
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-
-    // static member functions -------------------------------------------------
-
-    virtual int compareItems(Item, Item);
-
     // constructors, copy constructors, and destructors ------------------------
-    
-    QGVector();
-    QGVector(const QGVector &);
-    ~QGVector();
-    
-    // member functions --------------------------------------------------------
-    
-    // operators ---------------------------------------------------------------
-
-    QGVector &operator=(const QGVector &);
-
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
 
-}; // class QGVector ===========================================================
+    QVector() : impl(deleteFunc) {}
+    QVector(uint size) : impl(size, deleteFunc) {}
+    QVector(const QVector<T> &v) : impl(v.impl) {}
+    ~QVector() { if (del_item) { impl.clear(del_item); } }
 
+    // member functions --------------------------------------------------------
 
-// class QVector ===============================================================
+    void clear() { impl.clear(del_item); }
+    bool isEmpty() const { return impl.isEmpty(); }
+    uint count() const { return impl.count(); }
+    uint size() const { return impl.size(); }
+    bool remove(uint n) { return impl.remove(n, del_item); }
+    bool resize(uint size) { return impl.resize(size, del_item); }
+    bool insert(uint n, const T *item) {return impl.insert(n, item, del_item); }
+    T *at(int n) const {return (T *)impl.at(n); }
 
-template<class T> class QVector : public QGVector  {
-public:
+    virtual int compareItems(void *a, void *b) { return a != b; }
 
-    // typedefs ----------------------------------------------------------------
-    // enums -------------------------------------------------------------------
-    // constants ---------------------------------------------------------------
-    // static member functions -------------------------------------------------
+    // operators ---------------------------------------------------------------
 
-    // constructors, copy constructors, and destructors ------------------------
+    T *operator[](int n) const {return (T *)impl.at(n); }
+    QVector &operator=(const QVector &v) 
+    { impl.assign(v.impl,del_item); QCollection::operator=(v); return *this; }
+ private:
+    static void deleteFunc(void *item) {
+	delete (T *)item;
+    }
 
-    QVector();
-    QVector(uint);
-    QVector(const QVector &);
-    ~QVector();
+    KWQVectorImpl impl;
+}; // class QVector ============================================================
 
-    // member functions --------------------------------------------------------
 
-    void clear();
-    bool isEmpty() const;
-    uint count() const;
-    uint size() const;
-    bool remove(uint);
-    bool resize(uint);
-    bool insert(uint, const T *);
-    T *at(int) const;
 
-    // operators ---------------------------------------------------------------
+template<class T>
+inline ostream &operator<<(ostream &stream, const QVector<T> &v)
+{
+    uint i = 0;
+    uint count = v.count();
 
-    T *operator[](int) const;
-    QVector &operator=(const QVector &);
+    stream << "QVector: [size: " << count << "; items: ";
 
-// protected -------------------------------------------------------------------
-// private ---------------------------------------------------------------------
+    while(i < count ) {
+	stream << *v[i] << ", ";
+	++i;
+    }
 
-}; // class QVector ============================================================
+    return stream << "]";
+}
 
 #endif // USING_BORROWED_QVECTOR
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list