[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

darin darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 06:24:21 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 5f8949c69fb1d859976ba1755b8e8a13859e8f69
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Sun Jul 14 23:49:53 2002 +0000

    WebCore:
    
    	Changes to WebCore that allow WebKit to work through Objective C without going
    	straight to the KHTML headers. Also remove a bunch of unused stuff, especially
    	in QPainter.
    
            * WebCore.exp: Export the new classes WebCoreCache and WebCoreJavaScript.
    	Don't export any C++ symbols at all.
    
            * WebCore.pbproj/project.pbxproj: Remove KWQWMatrix.mm, add WebCoreCache.*
    	and WebCoreJavaScript.*.
    
            * khtml/khtml_part.cpp: Put more unused code inside ifndef APPLE_CHANGES.
            * khtml/khtmlview.cpp: Put unused code inside #ifndef APPLE_CHANGES
            * khtml/khtmlview.h: Put unused virtual functions inside #ifndef APPLE_CHANGES.
            * khtml/misc/loader.cpp: (CachedImage::tiled_pixmap): Change this so it
    	always returns pixmap(). Handling it at this level is better than changing
    	all the callers for now.
            * khtml/rendering/render_box.cpp: (RenderBox::printBackground): Took out the
    	APPLE_CHANGES now that tiled_pixmap() always just returns pixmap().
            * khtml/rendering/render_frames.cpp: (RenderFrameSet::userResize): Put some
    	unused code inside APPLE_CHANGES.
    
            * kwq/KWQKHTMLPart.mm:
            (KWQKHTMLPartImpl::requestFrame): Made it get the view using the bridge, since we
    	don't have a [widget] method on the frame any more.
            (KWQKHTMLPartImpl::findFrame): Used committedBridge instead of bridge, since
    	I changed bridge to return the provisional if available.
            (KWQKHTMLPartImpl::frames): Used committedBridge instead of bridge, since
    	I changed bridge to return the provisional if available.
    
            * kwq/qt/qpixmap.h: Put an empty version of QWMatrix in here. We don't actually ever
    	need a real matrix, just a class to let us compile.
    
            * kwq/qt/qpainter.h: Moved QWMatrix into qpixmap.h. Removed constructors that take
    	QPixmap and QWidget. Removed unused variants of drawText. Removed unused setClipping,
    	setClipRect, hasClipping, translate, scale, begin, end, and device functions.
            * kwq/KWQPainter.mm:
            (QPainter::QPainter): Remove the constructors that take a paint device, widget,
    	or pixmap. We can get away without them.
            (QPainter::save): Simplify. Also remove the optimization for painters without
    	stacks, since having an empty stack is very inexpensive.
            (QPainter::restore): Simplify.
            (QPainter::_drawPoints): Move paintingDisabled check in here.
            (QPainter::drawText): Removed many unused drawText variants.
    
            * kwq/KWQView.h: Tweaked.
            * kwq/KWQView.mm: Removed [KWQView drawRect:].
    
            * kwq/KWQWMatrix.mm: Removed.
    
            * kwq/qt/qwidget.h: Removed paint() virtual function.
            * kwq/KWQWidget.mm: Removed QWidget::paint().
    
            * kwq/WebCoreBridge.h: Added new methods installInFrame:, removeFromFrame,
    	mouseDown:, mouseUp:, mouseMoved:, mouseDragged:, copyDOMTree:, and copyRenderTree:.
    
            * kwq/WebCoreBridge.mm:
            (-[WebCoreBridge dealloc]): Call removeFromFrame.
            (-[WebCoreBridge createKHTMLViewWithNSView:width:height:marginWidth:marginHeight:]):
    	Don't return the view any more, also set bridgeOwnsKHTMLView to YES.
            (-[WebCoreBridge copyDOMNode:DOM::copier:]): Added helper method for copyDOMTree.
            (-[WebCoreBridge copyDOMTree:]): Added method to be used by IFDOMNode to get at DOM
    	tree without using C++.
            (-[WebCoreBridge copyRenderNode:khtml::copier:]): Added helper method for copyRenderTree.
            (-[WebCoreBridge copyRenderTree:]): Added method to be used by IFRenderNode to get at
    	render tree without using C++.
            (-[WebCoreBridge removeFromFrame]): Added. Deletes the view if we own it. We don't want
    	to wait for dealloc time to do this, since a lingering view might be visible.
            (-[WebCoreBridge installInFrame:]): Added. Does a set of things we need to do at the
    	time we commit a provisional data source.
            (-[WebCoreBridge addModifiers:toState:]): Moved here from IFHTMLView.
            (-[WebCoreBridge mouseUp:]): Added. Used to get a mouse up event to the KHTMLView.
            (-[WebCoreBridge mouseDown:]): Added. Used to get a mouse down event to the KHTMLView.
            (-[WebCoreBridge mouseMoved:]): Added. Used to get a mouse moved event to the KHTMLView.
            (-[WebCoreBridge mouseDragged:]): Added. Used to get a mouse moved event to the KHTMLView
    	in the case where we are dragging -- perhaps could be merged with mouseMoved.
    
            * kwq/WebCoreCache.h: Added. Allows control of the WebCore cache; previously done directly
    	in IFCache in WebKit.
            * kwq/WebCoreCache.mm: Added.
    
            * kwq/WebCoreFrame.h: Remove widget method. Change semantics of bridge method to return
    	provisional bridge if available, which corresponds to what the widget method did before.
    	Added a committedBridge method that has the semantics that bridge did before.
    
            * kwq/WebCoreJavaScript.h: Added. Returns statistics about the state of JavaScript objects;
    	previously done directly in IFCache in WebKit.
            * kwq/WebCoreJavaScript.mm: Added.
    
    WebKit:
    
    	Wean WebKit completely from getting at the C++ parts of WebCore.
    	We probably don't need to use C++ at all for WebKit any more.
    
            * WebKit.pbproj/project.pbxproj: Remove all the header search paths; we don't need any
    	special ones now.
    
            * WebKitPrefix.h: Remove <config.h>; we don't need it any more.
    
            * Misc.subproj/IFCache.h: Rename getStatistics to statistics.
            * Misc.subproj/IFCache.mm:
            (+[IFCache statistics]):
            (+[IFCache empty]):
            (+[IFCache setDisabled:]):
    	Call through WebCoreCache instead of going directly to khtml::Cache.
            (+[IFCache javaScriptObjectsCount]):
            (+[IFCache javaScriptInterpretersCount]):
            (+[IFCache javaScriptNoGCAllowedObjectsCount]):
            (+[IFCache javaScriptReferencedObjectsCount]):
            (+[IFCache garbageCollectJavaScriptObjects]):
    	Call through WebCoreJavaScript instead of going directly to kjs::Collector.
    
            * WebCoreSupport.subproj/IFWebCoreFrame.m:
            (-[IFWebCoreFrame bridge]): Change to return bridge from the provisional data
    	source if it exists.
            (-[IFWebCoreFrame committedBridge]): Do what [bridge] used to do, always returning
    	the bridge from the committed data source and never the provisional one.
    
            * WebView.subproj/IFHTMLView.mm:
            (-[IFHTMLView provisionalDataSourceChanged:]): Don't store the provisional widget.
    	It's stored in the bridge for the provisional data source.
            (-[IFHTMLView provisionalDataSourceCommitted:]): Use the bridge method installInFrame:
    	to do most of the work that used to be here. The rest is don in removeFromFrame which
    	is called elsewhere.
            (-[IFHTMLView mouseUp:]): Use the bridge's mouseUp method.
            (-[IFHTMLView mouseDown:]): Use the bridge's mouseDown method.
            (-[IFHTMLView mouseMovedNotification:]): Use the bridge's mouseMoved method.
            (-[IFHTMLView mouseDragged:]): Use the bridge's mouseDragged method.
    
            * WebView.subproj/IFHTMLViewPrivate.h: Remove the widget, widgetOwned, and
    	provisionalWidget instance variables, and the _widget and _provisionalWidget methods.
            * WebView.subproj/IFHTMLViewPrivate.mm:
            (-[IFHTMLView _reset]): Remove the code that deleted the widget and the provisional widget.
    	This is now handled elsewhere.
    
            * WebView.subproj/IFDOMNode.mm: Redo to use the copyDOMTree feature of the bridge.
            * WebView.subproj/IFRenderNode.mm: Redo to use the copyRenderTree feature of the bridge.
    
            * WebView.subproj/IFRenderNode.h: Use an NSRect instead of four integers
    	(the switch to floating point is OK).
    
            * WebView.subproj/IFWebDataSourcePrivate.h: Add private _removeFromFrame method.
            * WebView.subproj/IFWebDataSourcePrivate.mm:
            (-[IFWebDataSource _removeFromFrame]): Set the controller and location change handler
    	references to nil, and also call [WebCoreBridge removeFromFrame].
            * WebView.subproj/IFWebFramePrivate.mm:
            (-[IFWebFramePrivate setDataSource:]): Use _removeFromFrame where we formerly would
    	set the controller and location change handler references to nil.
    
            * WebCoreSupport.subproj/IFWebCoreBridge.h: Tweak.
    
    WebBrowser:
    
            * Debug/CacheController.m:
            (-[CacheController refreshWebCoreStatisticsMatrix]):
    	Change name of method from getStatistics to statistics.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1554 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 402e9e9..28e0c9a 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,93 @@
+2002-07-14  Darin Adler  <darin at apple.com>
+
+	Changes to WebCore that allow WebKit to work through Objective C without going
+	straight to the KHTML headers. Also remove a bunch of unused stuff, especially
+	in QPainter.
+
+        * WebCore.exp: Export the new classes WebCoreCache and WebCoreJavaScript.
+	Don't export any C++ symbols at all.
+
+        * WebCore.pbproj/project.pbxproj: Remove KWQWMatrix.mm, add WebCoreCache.*
+	and WebCoreJavaScript.*.
+
+        * khtml/khtml_part.cpp: Put more unused code inside ifndef APPLE_CHANGES.
+        * khtml/khtmlview.cpp: Put unused code inside #ifndef APPLE_CHANGES
+        * khtml/khtmlview.h: Put unused virtual functions inside #ifndef APPLE_CHANGES.
+        * khtml/misc/loader.cpp: (CachedImage::tiled_pixmap): Change this so it
+	always returns pixmap(). Handling it at this level is better than changing
+	all the callers for now.
+        * khtml/rendering/render_box.cpp: (RenderBox::printBackground): Took out the
+	APPLE_CHANGES now that tiled_pixmap() always just returns pixmap().
+        * khtml/rendering/render_frames.cpp: (RenderFrameSet::userResize): Put some
+	unused code inside APPLE_CHANGES.
+
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPartImpl::requestFrame): Made it get the view using the bridge, since we
+	don't have a [widget] method on the frame any more.
+        (KWQKHTMLPartImpl::findFrame): Used committedBridge instead of bridge, since
+	I changed bridge to return the provisional if available.
+        (KWQKHTMLPartImpl::frames): Used committedBridge instead of bridge, since
+	I changed bridge to return the provisional if available.
+
+        * kwq/qt/qpixmap.h: Put an empty version of QWMatrix in here. We don't actually ever
+	need a real matrix, just a class to let us compile.
+
+        * kwq/qt/qpainter.h: Moved QWMatrix into qpixmap.h. Removed constructors that take
+	QPixmap and QWidget. Removed unused variants of drawText. Removed unused setClipping,
+	setClipRect, hasClipping, translate, scale, begin, end, and device functions.
+        * kwq/KWQPainter.mm:
+        (QPainter::QPainter): Remove the constructors that take a paint device, widget,
+	or pixmap. We can get away without them.
+        (QPainter::save): Simplify. Also remove the optimization for painters without
+	stacks, since having an empty stack is very inexpensive.
+        (QPainter::restore): Simplify.
+        (QPainter::_drawPoints): Move paintingDisabled check in here.
+        (QPainter::drawText): Removed many unused drawText variants.
+
+        * kwq/KWQView.h: Tweaked.
+        * kwq/KWQView.mm: Removed [KWQView drawRect:].
+
+        * kwq/KWQWMatrix.mm: Removed.
+
+        * kwq/qt/qwidget.h: Removed paint() virtual function.
+        * kwq/KWQWidget.mm: Removed QWidget::paint().
+
+        * kwq/WebCoreBridge.h: Added new methods installInFrame:, removeFromFrame,
+	mouseDown:, mouseUp:, mouseMoved:, mouseDragged:, copyDOMTree:, and copyRenderTree:.
+
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge dealloc]): Call removeFromFrame.
+        (-[WebCoreBridge createKHTMLViewWithNSView:width:height:marginWidth:marginHeight:]):
+	Don't return the view any more, also set bridgeOwnsKHTMLView to YES.
+        (-[WebCoreBridge copyDOMNode:DOM::copier:]): Added helper method for copyDOMTree.
+        (-[WebCoreBridge copyDOMTree:]): Added method to be used by IFDOMNode to get at DOM
+	tree without using C++.
+        (-[WebCoreBridge copyRenderNode:khtml::copier:]): Added helper method for copyRenderTree.
+        (-[WebCoreBridge copyRenderTree:]): Added method to be used by IFRenderNode to get at
+	render tree without using C++.
+        (-[WebCoreBridge removeFromFrame]): Added. Deletes the view if we own it. We don't want
+	to wait for dealloc time to do this, since a lingering view might be visible.
+        (-[WebCoreBridge installInFrame:]): Added. Does a set of things we need to do at the
+	time we commit a provisional data source.
+        (-[WebCoreBridge addModifiers:toState:]): Moved here from IFHTMLView.
+        (-[WebCoreBridge mouseUp:]): Added. Used to get a mouse up event to the KHTMLView.
+        (-[WebCoreBridge mouseDown:]): Added. Used to get a mouse down event to the KHTMLView.
+        (-[WebCoreBridge mouseMoved:]): Added. Used to get a mouse moved event to the KHTMLView.
+        (-[WebCoreBridge mouseDragged:]): Added. Used to get a mouse moved event to the KHTMLView
+	in the case where we are dragging -- perhaps could be merged with mouseMoved.
+
+        * kwq/WebCoreCache.h: Added. Allows control of the WebCore cache; previously done directly
+	in IFCache in WebKit.
+        * kwq/WebCoreCache.mm: Added.
+
+        * kwq/WebCoreFrame.h: Remove widget method. Change semantics of bridge method to return
+	provisional bridge if available, which corresponds to what the widget method did before.
+	Added a committedBridge method that has the semantics that bridge did before.
+
+        * kwq/WebCoreJavaScript.h: Added. Returns statistics about the state of JavaScript objects;
+	previously done directly in IFCache in WebKit.
+        * kwq/WebCoreJavaScript.mm: Added.
+
 2002-07-13  Darin Adler  <darin at apple.com>
 
         * WebCore.pbproj/project.pbxproj: Add a few files that are sources
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 402e9e9..28e0c9a 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,93 @@
+2002-07-14  Darin Adler  <darin at apple.com>
+
+	Changes to WebCore that allow WebKit to work through Objective C without going
+	straight to the KHTML headers. Also remove a bunch of unused stuff, especially
+	in QPainter.
+
+        * WebCore.exp: Export the new classes WebCoreCache and WebCoreJavaScript.
+	Don't export any C++ symbols at all.
+
+        * WebCore.pbproj/project.pbxproj: Remove KWQWMatrix.mm, add WebCoreCache.*
+	and WebCoreJavaScript.*.
+
+        * khtml/khtml_part.cpp: Put more unused code inside ifndef APPLE_CHANGES.
+        * khtml/khtmlview.cpp: Put unused code inside #ifndef APPLE_CHANGES
+        * khtml/khtmlview.h: Put unused virtual functions inside #ifndef APPLE_CHANGES.
+        * khtml/misc/loader.cpp: (CachedImage::tiled_pixmap): Change this so it
+	always returns pixmap(). Handling it at this level is better than changing
+	all the callers for now.
+        * khtml/rendering/render_box.cpp: (RenderBox::printBackground): Took out the
+	APPLE_CHANGES now that tiled_pixmap() always just returns pixmap().
+        * khtml/rendering/render_frames.cpp: (RenderFrameSet::userResize): Put some
+	unused code inside APPLE_CHANGES.
+
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPartImpl::requestFrame): Made it get the view using the bridge, since we
+	don't have a [widget] method on the frame any more.
+        (KWQKHTMLPartImpl::findFrame): Used committedBridge instead of bridge, since
+	I changed bridge to return the provisional if available.
+        (KWQKHTMLPartImpl::frames): Used committedBridge instead of bridge, since
+	I changed bridge to return the provisional if available.
+
+        * kwq/qt/qpixmap.h: Put an empty version of QWMatrix in here. We don't actually ever
+	need a real matrix, just a class to let us compile.
+
+        * kwq/qt/qpainter.h: Moved QWMatrix into qpixmap.h. Removed constructors that take
+	QPixmap and QWidget. Removed unused variants of drawText. Removed unused setClipping,
+	setClipRect, hasClipping, translate, scale, begin, end, and device functions.
+        * kwq/KWQPainter.mm:
+        (QPainter::QPainter): Remove the constructors that take a paint device, widget,
+	or pixmap. We can get away without them.
+        (QPainter::save): Simplify. Also remove the optimization for painters without
+	stacks, since having an empty stack is very inexpensive.
+        (QPainter::restore): Simplify.
+        (QPainter::_drawPoints): Move paintingDisabled check in here.
+        (QPainter::drawText): Removed many unused drawText variants.
+
+        * kwq/KWQView.h: Tweaked.
+        * kwq/KWQView.mm: Removed [KWQView drawRect:].
+
+        * kwq/KWQWMatrix.mm: Removed.
+
+        * kwq/qt/qwidget.h: Removed paint() virtual function.
+        * kwq/KWQWidget.mm: Removed QWidget::paint().
+
+        * kwq/WebCoreBridge.h: Added new methods installInFrame:, removeFromFrame,
+	mouseDown:, mouseUp:, mouseMoved:, mouseDragged:, copyDOMTree:, and copyRenderTree:.
+
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge dealloc]): Call removeFromFrame.
+        (-[WebCoreBridge createKHTMLViewWithNSView:width:height:marginWidth:marginHeight:]):
+	Don't return the view any more, also set bridgeOwnsKHTMLView to YES.
+        (-[WebCoreBridge copyDOMNode:DOM::copier:]): Added helper method for copyDOMTree.
+        (-[WebCoreBridge copyDOMTree:]): Added method to be used by IFDOMNode to get at DOM
+	tree without using C++.
+        (-[WebCoreBridge copyRenderNode:khtml::copier:]): Added helper method for copyRenderTree.
+        (-[WebCoreBridge copyRenderTree:]): Added method to be used by IFRenderNode to get at
+	render tree without using C++.
+        (-[WebCoreBridge removeFromFrame]): Added. Deletes the view if we own it. We don't want
+	to wait for dealloc time to do this, since a lingering view might be visible.
+        (-[WebCoreBridge installInFrame:]): Added. Does a set of things we need to do at the
+	time we commit a provisional data source.
+        (-[WebCoreBridge addModifiers:toState:]): Moved here from IFHTMLView.
+        (-[WebCoreBridge mouseUp:]): Added. Used to get a mouse up event to the KHTMLView.
+        (-[WebCoreBridge mouseDown:]): Added. Used to get a mouse down event to the KHTMLView.
+        (-[WebCoreBridge mouseMoved:]): Added. Used to get a mouse moved event to the KHTMLView.
+        (-[WebCoreBridge mouseDragged:]): Added. Used to get a mouse moved event to the KHTMLView
+	in the case where we are dragging -- perhaps could be merged with mouseMoved.
+
+        * kwq/WebCoreCache.h: Added. Allows control of the WebCore cache; previously done directly
+	in IFCache in WebKit.
+        * kwq/WebCoreCache.mm: Added.
+
+        * kwq/WebCoreFrame.h: Remove widget method. Change semantics of bridge method to return
+	provisional bridge if available, which corresponds to what the widget method did before.
+	Added a committedBridge method that has the semantics that bridge did before.
+
+        * kwq/WebCoreJavaScript.h: Added. Returns statistics about the state of JavaScript objects;
+	previously done directly in IFCache in WebKit.
+        * kwq/WebCoreJavaScript.mm: Added.
+
 2002-07-13  Darin Adler  <darin at apple.com>
 
         * WebCore.pbproj/project.pbxproj: Add a few files that are sources
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 402e9e9..28e0c9a 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,93 @@
+2002-07-14  Darin Adler  <darin at apple.com>
+
+	Changes to WebCore that allow WebKit to work through Objective C without going
+	straight to the KHTML headers. Also remove a bunch of unused stuff, especially
+	in QPainter.
+
+        * WebCore.exp: Export the new classes WebCoreCache and WebCoreJavaScript.
+	Don't export any C++ symbols at all.
+
+        * WebCore.pbproj/project.pbxproj: Remove KWQWMatrix.mm, add WebCoreCache.*
+	and WebCoreJavaScript.*.
+
+        * khtml/khtml_part.cpp: Put more unused code inside ifndef APPLE_CHANGES.
+        * khtml/khtmlview.cpp: Put unused code inside #ifndef APPLE_CHANGES
+        * khtml/khtmlview.h: Put unused virtual functions inside #ifndef APPLE_CHANGES.
+        * khtml/misc/loader.cpp: (CachedImage::tiled_pixmap): Change this so it
+	always returns pixmap(). Handling it at this level is better than changing
+	all the callers for now.
+        * khtml/rendering/render_box.cpp: (RenderBox::printBackground): Took out the
+	APPLE_CHANGES now that tiled_pixmap() always just returns pixmap().
+        * khtml/rendering/render_frames.cpp: (RenderFrameSet::userResize): Put some
+	unused code inside APPLE_CHANGES.
+
+        * kwq/KWQKHTMLPart.mm:
+        (KWQKHTMLPartImpl::requestFrame): Made it get the view using the bridge, since we
+	don't have a [widget] method on the frame any more.
+        (KWQKHTMLPartImpl::findFrame): Used committedBridge instead of bridge, since
+	I changed bridge to return the provisional if available.
+        (KWQKHTMLPartImpl::frames): Used committedBridge instead of bridge, since
+	I changed bridge to return the provisional if available.
+
+        * kwq/qt/qpixmap.h: Put an empty version of QWMatrix in here. We don't actually ever
+	need a real matrix, just a class to let us compile.
+
+        * kwq/qt/qpainter.h: Moved QWMatrix into qpixmap.h. Removed constructors that take
+	QPixmap and QWidget. Removed unused variants of drawText. Removed unused setClipping,
+	setClipRect, hasClipping, translate, scale, begin, end, and device functions.
+        * kwq/KWQPainter.mm:
+        (QPainter::QPainter): Remove the constructors that take a paint device, widget,
+	or pixmap. We can get away without them.
+        (QPainter::save): Simplify. Also remove the optimization for painters without
+	stacks, since having an empty stack is very inexpensive.
+        (QPainter::restore): Simplify.
+        (QPainter::_drawPoints): Move paintingDisabled check in here.
+        (QPainter::drawText): Removed many unused drawText variants.
+
+        * kwq/KWQView.h: Tweaked.
+        * kwq/KWQView.mm: Removed [KWQView drawRect:].
+
+        * kwq/KWQWMatrix.mm: Removed.
+
+        * kwq/qt/qwidget.h: Removed paint() virtual function.
+        * kwq/KWQWidget.mm: Removed QWidget::paint().
+
+        * kwq/WebCoreBridge.h: Added new methods installInFrame:, removeFromFrame,
+	mouseDown:, mouseUp:, mouseMoved:, mouseDragged:, copyDOMTree:, and copyRenderTree:.
+
+        * kwq/WebCoreBridge.mm:
+        (-[WebCoreBridge dealloc]): Call removeFromFrame.
+        (-[WebCoreBridge createKHTMLViewWithNSView:width:height:marginWidth:marginHeight:]):
+	Don't return the view any more, also set bridgeOwnsKHTMLView to YES.
+        (-[WebCoreBridge copyDOMNode:DOM::copier:]): Added helper method for copyDOMTree.
+        (-[WebCoreBridge copyDOMTree:]): Added method to be used by IFDOMNode to get at DOM
+	tree without using C++.
+        (-[WebCoreBridge copyRenderNode:khtml::copier:]): Added helper method for copyRenderTree.
+        (-[WebCoreBridge copyRenderTree:]): Added method to be used by IFRenderNode to get at
+	render tree without using C++.
+        (-[WebCoreBridge removeFromFrame]): Added. Deletes the view if we own it. We don't want
+	to wait for dealloc time to do this, since a lingering view might be visible.
+        (-[WebCoreBridge installInFrame:]): Added. Does a set of things we need to do at the
+	time we commit a provisional data source.
+        (-[WebCoreBridge addModifiers:toState:]): Moved here from IFHTMLView.
+        (-[WebCoreBridge mouseUp:]): Added. Used to get a mouse up event to the KHTMLView.
+        (-[WebCoreBridge mouseDown:]): Added. Used to get a mouse down event to the KHTMLView.
+        (-[WebCoreBridge mouseMoved:]): Added. Used to get a mouse moved event to the KHTMLView.
+        (-[WebCoreBridge mouseDragged:]): Added. Used to get a mouse moved event to the KHTMLView
+	in the case where we are dragging -- perhaps could be merged with mouseMoved.
+
+        * kwq/WebCoreCache.h: Added. Allows control of the WebCore cache; previously done directly
+	in IFCache in WebKit.
+        * kwq/WebCoreCache.mm: Added.
+
+        * kwq/WebCoreFrame.h: Remove widget method. Change semantics of bridge method to return
+	provisional bridge if available, which corresponds to what the widget method did before.
+	Added a committedBridge method that has the semantics that bridge did before.
+
+        * kwq/WebCoreJavaScript.h: Added. Returns statistics about the state of JavaScript objects;
+	previously done directly in IFCache in WebKit.
+        * kwq/WebCoreJavaScript.mm: Added.
+
 2002-07-13  Darin Adler  <darin at apple.com>
 
         * WebCore.pbproj/project.pbxproj: Add a few files that are sources
diff --git a/WebCore/WebCore.exp b/WebCore/WebCore.exp
index 5490a9e..f6fcef8 100644
--- a/WebCore/WebCore.exp
+++ b/WebCore/WebCore.exp
@@ -1,27 +1,8 @@
 .objc_class_name_WebCoreBridge
+.objc_class_name_WebCoreCache
 .objc_class_name_WebCoreCookieAdapter
 .objc_class_name_WebCoreFrame
 .objc_class_name_WebCoreImageRendererFactory
+.objc_class_name_WebCoreJavaScript
 .objc_class_name_WebCoreTextRendererFactory
 .objc_class_name_WebCoreViewFactory
-__ZN11QMouseEventC1EN6QEvent4TypeERK6QPointii
-__ZN3DOM12DocumentImpl19updateStyleSelectorEv
-__ZN3DOM9DOMStringD1Ev
-__ZN4KURLC1EPKci
-__ZN4KURLD1Ev
-__ZN5khtml5Cache13getStatisticsEv
-__ZN5khtml5Cache16setCacheDisabledEb
-__ZN5khtml5Cache8flushAllEv
-__ZN6QEventD2Ev
-__ZN6QPointC1Eii
-__ZN7QString12fromNSStringEP8NSString
-__ZN7QStringD1Ev
-__ZN7QWidget7setViewEP6NSView
-__ZN8QPainterC1EP7QWidget
-__ZN8QPainterD1Ev
-__ZN9KHTMLView6layoutEv
-__ZN9QKeyEventC1EN6QEvent4TypeEiiiRK7QStringbt
-__ZNK3DOM8NodeImpl16recursive_toHTMLEb
-__ZNK3DOM9DOMString6stringEv
-__ZNK7QWidget7getViewEv
-__ZNK9KHTMLPart10xmlDocImplEv
diff --git a/WebCore/WebCore.pbproj/project.pbxproj b/WebCore/WebCore.pbproj/project.pbxproj
index 8f1fa8a..cc2b0fd 100644
--- a/WebCore/WebCore.pbproj/project.pbxproj
+++ b/WebCore/WebCore.pbproj/project.pbxproj
@@ -485,6 +485,8 @@
 				F523D32002DE4476018635CA,
 				F523D32202DE4476018635CA,
 				F505847602E0934D018635CE,
+				F5B2A4FE02E2220F018635CB,
+				F5B2A52D02E22573018635CB,
 			);
 			isa = PBXHeadersBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -603,7 +605,6 @@
 				F58785D302DE375901EA4122,
 				F58785D402DE375901EA4122,
 				F58785D602DE375901EA4122,
-				F58785D702DE375901EA4122,
 				F58785D802DE375901EA4122,
 				F58785DA02DE375901EA4122,
 				F58785DC02DE375901EA4122,
@@ -708,6 +709,8 @@
 				F523D32102DE4476018635CA,
 				F52CA71002DFACBD018635CA,
 				F550D71002E132BB018635CA,
+				F5B2A4FF02E2220F018635CB,
+				F5B2A52E02E22573018635CB,
 			);
 			isa = PBXSourcesBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -4565,12 +4568,6 @@
 			path = kwq/KWQWindowWidget.mm;
 			refType = 4;
 		};
-		F587854502DE375901EA4122 = {
-			isa = PBXFileReference;
-			name = KWQWMatrix.mm;
-			path = kwq/KWQWMatrix.mm;
-			refType = 4;
-		};
 		F587854602DE375901EA4122 = {
 			isa = PBXFileReference;
 			name = KWQxml.mm;
@@ -5417,12 +5414,6 @@
 			settings = {
 			};
 		};
-		F58785D702DE375901EA4122 = {
-			fileRef = F587854502DE375901EA4122;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
 		F58785D802DE375901EA4122 = {
 			fileRef = F587854602DE375901EA4122;
 			isa = PBXBuildFile;
@@ -5569,6 +5560,8 @@
 			children = (
 				F587854702DE375901EA4122,
 				F587854802DE375901EA4122,
+				F5B2A4FC02E2220F018635CB,
+				F5B2A4FD02E2220F018635CB,
 				F587854902DE375901EA4122,
 				F587854A02DE375901EA4122,
 				F587854B02DE375901EA4122,
@@ -5577,6 +5570,8 @@
 				F587854D02DE375901EA4122,
 				F587854E02DE375901EA4122,
 				F587854F02DE375901EA4122,
+				F5B2A52B02E22573018635CB,
+				F5B2A52C02E22573018635CB,
 				F587855002DE375901EA4122,
 				F587855102DE375901EA4122,
 				F587855202DE375901EA4122,
@@ -7601,7 +7596,6 @@
 				F58786A202DE3B8601EA4122,
 				F587851E02DE375901EA4122,
 				F58786A302DE3B8601EA4122,
-				F587854502DE375901EA4122,
 				F587851F02DE375901EA4122,
 				F58786A402DE3B8601EA4122,
 				F58784D102DE375901EA4122,
@@ -7726,6 +7720,60 @@
 			settings = {
 			};
 		};
+		F5B2A4FC02E2220F018635CB = {
+			isa = PBXFileReference;
+			name = WebCoreCache.h;
+			path = kwq/WebCoreCache.h;
+			refType = 4;
+		};
+		F5B2A4FD02E2220F018635CB = {
+			isa = PBXFileReference;
+			name = WebCoreCache.mm;
+			path = kwq/WebCoreCache.mm;
+			refType = 4;
+		};
+		F5B2A4FE02E2220F018635CB = {
+			fileRef = F5B2A4FC02E2220F018635CB;
+			isa = PBXBuildFile;
+			settings = {
+				ATTRIBUTES = (
+					Private,
+				);
+			};
+		};
+		F5B2A4FF02E2220F018635CB = {
+			fileRef = F5B2A4FD02E2220F018635CB;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		F5B2A52B02E22573018635CB = {
+			isa = PBXFileReference;
+			name = WebCoreJavaScript.h;
+			path = kwq/WebCoreJavaScript.h;
+			refType = 4;
+		};
+		F5B2A52C02E22573018635CB = {
+			isa = PBXFileReference;
+			name = WebCoreJavaScript.mm;
+			path = kwq/WebCoreJavaScript.mm;
+			refType = 4;
+		};
+		F5B2A52D02E22573018635CB = {
+			fileRef = F5B2A52B02E22573018635CB;
+			isa = PBXBuildFile;
+			settings = {
+				ATTRIBUTES = (
+					Private,
+				);
+			};
+		};
+		F5B2A52E02E22573018635CB = {
+			fileRef = F5B2A52C02E22573018635CB;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		F5C2869302846DCD018635CA = {
 			isa = PBXFrameworkReference;
 			name = ApplicationServices.framework;
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 456d125..18a0662 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -1472,12 +1472,16 @@ void KHTMLPart::end()
 }
 
 
+#ifndef APPLE_CHANGES
+
 void KHTMLPart::paint(QPainter *p, const QRect &rc, int yOff, bool *more)
 {
     if (!d->m_view) return;
     d->m_view->paint(p, rc, yOff, more);
 }
 
+#endif
+
 void KHTMLPart::stopAnimations()
 {
 #ifndef APPLE_CHANGES
diff --git a/WebCore/khtml/khtmlview.cpp b/WebCore/khtml/khtmlview.cpp
index d42e918..5aeab75 100644
--- a/WebCore/khtml/khtmlview.cpp
+++ b/WebCore/khtml/khtmlview.cpp
@@ -331,6 +331,8 @@ void KHTMLView::resizeEvent (QResizeEvent* e)
     KApplication::sendPostedEvents(viewport(), QEvent::Paint);
 }
 
+#ifndef APPLE_CHANGES
+
 // this is to get rid of a compiler virtual overload mismatch warning. do not remove
 void KHTMLView::drawContents( QPainter*)
 {
@@ -371,6 +373,8 @@ void KHTMLView::drawContents( QPainter *p, int ex, int ey, int ew, int eh )
 
 }
 
+#endif // !APPLE_CHANGES
+
 void KHTMLView::setMarginWidth(int w)
 {
     // make it update the rendering area when set
@@ -991,6 +995,7 @@ QString KHTMLView::mediaType() const
 }
 
 #ifndef APPLE_CHANGES
+
 void KHTMLView::print()
 {
     if(!m_part->xmlDocImpl()) return;
@@ -1090,7 +1095,6 @@ void KHTMLView::print()
     }
     delete printer;
 }
-#endif // !APPLE_CHANGES
 
 void KHTMLView::slotPaletteChanged()
 {
@@ -1134,6 +1138,7 @@ void KHTMLView::paint(QPainter *p, const QRect &rc, int yOff, bool *more)
     m_part->xmlDocImpl()->setPaintDevice( this );
 }
 
+#endif // !APPLE_CHANGES
 
 void KHTMLView::useSlowRepaints()
 {
diff --git a/WebCore/khtml/khtmlview.h b/WebCore/khtml/khtmlview.h
index 96d6f29..a3ed144 100644
--- a/WebCore/khtml/khtmlview.h
+++ b/WebCore/khtml/khtmlview.h
@@ -153,13 +153,15 @@ protected:
 
 #ifdef APPLE_CHANGES
 public:
-#endif /* APPLE_CHANGES */
+#endif
     virtual void resizeEvent ( QResizeEvent * event );
     virtual void showEvent ( QShowEvent * );
     virtual void hideEvent ( QHideEvent *);
     virtual bool focusNextPrevChild( bool next );
+#ifndef APPLE_CHANGES
     virtual void drawContents ( QPainter * p, int clipx, int clipy, int clipw, int cliph );
     virtual void drawContents( QPainter* );
+#endif
 
     virtual void viewportMousePressEvent( QMouseEvent * );
     virtual void focusOutEvent( QFocusEvent * );
@@ -193,6 +195,7 @@ private:
 
     void scheduleRepaint(int x, int y, int w, int h);
 
+#ifndef APPLE_CHANGES
     /**
      * Paints the HTML document to a QPainter.
      * The document will be scaled to match the width of
@@ -202,6 +205,7 @@ private:
      * beyond the rc or false if everything below yOff was painted.
      **/
     void paint(QPainter *p, const QRect &rc, int yOff = 0, bool *more = 0);
+#endif
 
     /**
      * Get/set the CSS Media Type.
diff --git a/WebCore/khtml/misc/loader.cpp b/WebCore/khtml/misc/loader.cpp
index e12ec42..9c6a3f5 100644
--- a/WebCore/khtml/misc/loader.cpp
+++ b/WebCore/khtml/misc/loader.cpp
@@ -515,6 +515,9 @@ void CachedImage::deref( CachedObjectClient *c )
 
 const QPixmap &CachedImage::tiled_pixmap(const QColor& newc)
 {
+#ifdef APPLE_CHANGES
+    return pixmap();
+#else
     static QRgb bgTransparant = qRgba( 0, 0, 0, 0xFF );
     if ( (bgColor != bgTransparant) && (bgColor != newc.rgb()) ) {
         delete bg; bg = 0;
@@ -550,7 +553,6 @@ const QPixmap &CachedImage::tiled_pixmap(const QColor& newc)
             QPainter p(bg);
             if(isvalid) p.fillRect(0, 0, w, r.height(), newc);
             p.drawTiledPixmap(0, 0, w, r.height(), pix);
-#ifndef APPLE_CHANGES
             if(!isvalid && pix.mask())
             {
                 // unfortunately our anti-transparency trick doesn't work here
@@ -562,7 +564,6 @@ const QPixmap &CachedImage::tiled_pixmap(const QColor& newc)
                 bgColor = bgTransparant;
             }
             else
-#endif
                 bgColor= newc.rgb();
             pix = *bg;
         }
@@ -573,7 +574,6 @@ const QPixmap &CachedImage::tiled_pixmap(const QColor& newc)
             QPainter p(bg);
             if(isvalid) p.fillRect(0, 0, w, h, newc);
             p.drawTiledPixmap(0, 0, w, h, pix);
-#ifndef APPLE_CHANGES
             if(!isvalid && pix.mask())
             {
                 // unfortunately our anti-transparency trick doesn't work here
@@ -585,13 +585,13 @@ const QPixmap &CachedImage::tiled_pixmap(const QColor& newc)
                 bgColor = bgTransparant;
             }
             else
-#endif
                 bgColor= newc.rgb();
         }
         return *bg;
     }
 
     return r;
+#endif
 }
 
 const QPixmap &CachedImage::pixmap( ) const
diff --git a/WebCore/khtml/rendering/render_box.cpp b/WebCore/khtml/rendering/render_box.cpp
index a553da1..0e17df9 100644
--- a/WebCore/khtml/rendering/render_box.cpp
+++ b/WebCore/khtml/rendering/render_box.cpp
@@ -262,13 +262,7 @@ void RenderBox::printBackground(QPainter *p, const QColor &c, CachedImage *bg, i
 //        kdDebug() << "cx="<<cx << " cy="<<cy<< " cw="<<cw << " ch="<<ch << " sx="<<sx << " sy="<<sy << endl;
 
         if (cw>0 && ch>0)
-#ifdef APPLE_CHANGES
-            // This is a change in behavior. The difference is that we 
-            // do not do a fill of the passed in color before tiling.
-            p->drawTiledPixmap(cx, cy, cw, ch, bg->pixmap(), sx, sy);
-#else /* APPLE_CHANGES not defined */
             p->drawTiledPixmap(cx, cy, cw, ch, bg->tiled_pixmap(c), sx, sy);
-#endif /* APPLE_CHANGES not defined */
     }
 }
 
diff --git a/WebCore/khtml/rendering/render_frames.cpp b/WebCore/khtml/rendering/render_frames.cpp
index ef73e43..122e4b5 100644
--- a/WebCore/khtml/rendering/render_frames.cpp
+++ b/WebCore/khtml/rendering/render_frames.cpp
@@ -436,6 +436,7 @@ bool RenderFrameSet::userResize( MouseEventImpl *evt )
     setLayouted(false);
   }
 
+#ifndef APPLE_CHANGES
   if (m_resizing || evt->id() == EventImpl::MOUSEUP_EVENT) {
       QPainter paint( root()->view() );
       paint.setPen( Qt::gray );
@@ -460,6 +461,7 @@ bool RenderFrameSet::userResize( MouseEventImpl *evt )
       }
       m_oldpos = p;
   }
+#endif
 
   return res;
 }
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 1381af0..7d0b138 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -430,7 +430,7 @@ bool KWQKHTMLPartImpl::requestFrame( khtml::RenderPart *frame, const QString &ur
     WebCoreFrame *wcFrame = [bridge childFrameNamed:name];
     if (wcFrame) {
         KWQDEBUGLEVEL(KWQ_LOG_FRAMES, "found %s\n", DEBUG_OBJECT(name));
-        frame->setWidget([wcFrame widget]);
+        frame->setWidget([[wcFrame bridge] part]->impl->getView());
     }
     else {
         KWQDEBUGLEVEL(KWQ_LOG_FRAMES, "creating %s\n", DEBUG_OBJECT(name));
@@ -592,7 +592,7 @@ bool KWQKHTMLPartImpl::frameExists( const QString &frameName )
 
 KHTMLPart *KWQKHTMLPartImpl::findFrame(const QString &frameName)
 {
-    return [[[bridge frameNamed:frameName.getNSString()] bridge] part];
+    return [[[bridge frameNamed:frameName.getNSString()] committedBridge] part];
 }
 
 QPtrList<KParts::ReadOnlyPart> KWQKHTMLPartImpl::frames() const
@@ -601,7 +601,7 @@ QPtrList<KParts::ReadOnlyPart> KWQKHTMLPartImpl::frames() const
     NSEnumerator *e = [[bridge childFrames] objectEnumerator];
     WebCoreFrame *childFrame;
     while ((childFrame = [e nextObject])) {
-        KHTMLPart *childPart = [[childFrame bridge] part];
+        KHTMLPart *childPart = [[childFrame committedBridge] part];
         if (childPart)
             parts.append(childPart);
     }
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.mm b/WebCore/kwq/KWQKHTMLPartImpl.mm
index 1381af0..7d0b138 100644
--- a/WebCore/kwq/KWQKHTMLPartImpl.mm
+++ b/WebCore/kwq/KWQKHTMLPartImpl.mm
@@ -430,7 +430,7 @@ bool KWQKHTMLPartImpl::requestFrame( khtml::RenderPart *frame, const QString &ur
     WebCoreFrame *wcFrame = [bridge childFrameNamed:name];
     if (wcFrame) {
         KWQDEBUGLEVEL(KWQ_LOG_FRAMES, "found %s\n", DEBUG_OBJECT(name));
-        frame->setWidget([wcFrame widget]);
+        frame->setWidget([[wcFrame bridge] part]->impl->getView());
     }
     else {
         KWQDEBUGLEVEL(KWQ_LOG_FRAMES, "creating %s\n", DEBUG_OBJECT(name));
@@ -592,7 +592,7 @@ bool KWQKHTMLPartImpl::frameExists( const QString &frameName )
 
 KHTMLPart *KWQKHTMLPartImpl::findFrame(const QString &frameName)
 {
-    return [[[bridge frameNamed:frameName.getNSString()] bridge] part];
+    return [[[bridge frameNamed:frameName.getNSString()] committedBridge] part];
 }
 
 QPtrList<KParts::ReadOnlyPart> KWQKHTMLPartImpl::frames() const
@@ -601,7 +601,7 @@ QPtrList<KParts::ReadOnlyPart> KWQKHTMLPartImpl::frames() const
     NSEnumerator *e = [[bridge childFrames] objectEnumerator];
     WebCoreFrame *childFrame;
     while ((childFrame = [e nextObject])) {
-        KHTMLPart *childPart = [[childFrame bridge] part];
+        KHTMLPart *childPart = [[childFrame committedBridge] part];
         if (childPart)
             parts.append(childPart);
     }
diff --git a/WebCore/kwq/KWQPainter.h b/WebCore/kwq/KWQPainter.h
index 6911692..2fcde27 100644
--- a/WebCore/kwq/KWQPainter.h
+++ b/WebCore/kwq/KWQPainter.h
@@ -42,34 +42,21 @@ class QPixmap;
 class QWidget;
 class QPainterPrivate;
 
-class QWMatrix {
-friend class QPainter;
-friend class QPixmap;
-public:
-    QWMatrix();
-    QWMatrix &scale(double, double);
-
-private:
-    bool empty;
-    double sx;
-    double sy;
-};
-
 class QPainter : public Qt {
 public:
     typedef enum { RTL, LTR } TextDirection;
 
     QPainter();
-    QPainter(QPixmap *);
-    QPainter(QWidget *);
     ~QPainter();
     
     const QFont &font() const;
     void setFont(const QFont &);
     QFontMetrics fontMetrics() const;
+    
     const QPen &pen() const;
     void setPen(const QPen &);
     void setPen(PenStyle);
+    
     const QBrush &QPainter::brush() const;
     void setBrush(const QBrush &);
     void setBrush(BrushStyle);
@@ -85,54 +72,34 @@ public:
     void drawEllipse(int, int, int, int);
     void drawArc(int, int, int, int, int, int);
     void drawPolyline(const QPointArray &, int index=0, int npoints=-1);
-    void drawPolygon(const QPointArray &, bool winding=FALSE, int index=0,
-        int npoints=-1);
+    void drawPolygon(const QPointArray &, bool winding=FALSE, int index=0, int npoints=-1);
+    void drawConvexPolygon(const QPointArray &);
+
+    void fillRect(int, int, int, int, const QBrush &);
+
     void drawPixmap(const QPoint &, const QPixmap &);
     void drawPixmap(const QPoint &, const QPixmap &, const QRect &);
     void drawPixmap( int x, int y, const QPixmap &,
 			    int sx=0, int sy=0, int sw=-1, int sh=-1 );
     void drawTiledPixmap(int, int, int, int, const QPixmap &, int sx=0, int sy=0);
-    void drawText(int x, int y, const QString &, int len=-1);
-    void drawText(int, int, int, int, int flags, const QString&, int len=-1, 
-        QRect *br=0, char **internal=0);
-    void drawText(int, int, const QString &, int, TextDirection);
-    void drawText(int, int, const QString &, int, int, TextDirection);
-    void drawText(int, int, const QString &, int, int, const QColor& backgroundColor);
 
-    void fillRect(int, int, int, int, const QBrush &);
-    void drawConvexPolygon(const QPointArray &);
-
-    void setClipping(bool);
     void setClipRegion(const QRegion &);
-    void setClipRect(const QRect &);
-    void setClipRect(int,int,int,int);
     const QRegion &clipRegion() const;
-    bool hasClipping() const;
+
     RasterOp rasterOp() const;
     void setRasterOp(RasterOp);
 
-    void translate(double dx, double dy);
-    void scale(double dx, double dy);
-
-    void begin(QPixmap *) { }
-    void end() { }
-    QPaintDevice *device() const { return 0; }
-
-    void drawUnderlineForText(int x, int y, const QString &, int len=-1);
-
+    void drawText(int x, int y, const QString &, int from, int to, const QColor& backgroundColor);
+    void drawUnderlineForText(int x, int y, const QString &);
     static QColor selectedTextBackgroundColor();
     
     void setPaintingDisabled(bool f);
     
 private:
     // no copying or assignment
-    // note that these are "standard" (no pendantic stuff needed)
     QPainter(const QPainter &);
     QPainter &operator=(const QPainter &);
 
-    void _lockFocus();
-    void _unlockFocus();
-
     void _setColorFromBrush();
     void _setColorFromPen();
 
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index 6dd00eb..1d620af 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -37,39 +37,21 @@
 #import <WebCoreImageRenderer.h>
 
 struct QPState {				// painter state
-    QPState() : compositingOperation(NSCompositeCopy),paintingDisabled(0) { }
+    QPState() : exclusiveOrMode(false), paintingDisabled(false) { }
     QFont font;
     QPen pen;
     QBrush brush;
-    NSCompositingOperation compositingOperation;
+    QRegion clip;
+    bool exclusiveOrMode;
     bool paintingDisabled;
 };
 
-typedef QPtrStack<QPState> QPStateStack;
-
-
 struct QPainterPrivate {
-    QPainterPrivate(QWidget *widget = 0) : ps_stack(0) { }
     QPState state;
-    QPStateStack *ps_stack;
+    QPtrStack<QPState> stack;
 };
 
-
-QPainter::QPainter()
-    : data(new QPainterPrivate)
-{
-}
-
-
-QPainter::QPainter(QPixmap *)
-{
-    _logNeverImplemented();
-}
-
-
-//  How do we handle ownership of widget?
-QPainter::QPainter(QWidget *widget)
-    : data(new QPainterPrivate(widget))
+QPainter::QPainter() : data(new QPainterPrivate)
 {
 }
 
@@ -83,16 +65,14 @@ const QFont &QPainter::font() const
     return data->state.font;
 }
 
-
 void QPainter::setFont(const QFont &aFont)
 {
     data->state.font = aFont;
 }
 
-
 QFontMetrics QPainter::fontMetrics() const
 {
-    return QFontMetrics( data->state.font );
+    return data->state.font;
 }
 
 const QPen &QPainter::pen() const
@@ -100,13 +80,11 @@ const QPen &QPainter::pen() const
     return data->state.pen;
 }
 
-
 void QPainter::setPen(const QPen &pen)
 {
     data->state.pen = pen;
 }
 
-
 void QPainter::setPen(PenStyle style)
 {
     data->state.pen.setStyle(style);
@@ -114,7 +92,6 @@ void QPainter::setPen(PenStyle style)
     data->state.pen.setWidth(0);
 }
 
-
 void QPainter::setBrush(const QBrush &brush)
 {
     data->state.brush = brush;
@@ -137,50 +114,28 @@ QRect QPainter::xForm(const QRect &) const
     return QRect();
 }
 
-
 void QPainter::save()
 {
-    QPStateStack *pss = data->ps_stack;
-    if ( pss == 0 ) {
-	pss = new QPStateStack;
-	data->ps_stack = pss;
-    }
-    
-    QPState *ps = new QPState;
-
-    *ps = data->state;
-    pss->push( ps );
+    data->stack.push(new QPState(data->state));
 }
 
-
 void QPainter::restore()
 {
-    QPStateStack *pss = data->ps_stack;
-    if ( pss == 0 || pss->isEmpty() ) {
+    if (data->stack.isEmpty()) {
         KWQDEBUG("ERROR void QPainter::restore() stack is empty\n");
 	return;
     }
-    QPState *ps = pss->pop();
-
-    if ( ps->font != data->state.font )
-	setFont( ps->font );
-    if ( ps->pen != data->state.pen )
-	setPen( ps->pen );
-    if ( ps->brush != data->state.brush )
-	setBrush( ps->brush );
-    ps->compositingOperation = data->state.compositingOperation;
-
+    QPState *ps = data->stack.pop();
+    data->state = *ps;
     delete ps;
 }
 
-
 // Draws a filled rectangle with a stroked border.
 void QPainter::drawRect(int x, int y, int w, int h)
 {
     if (data->state.paintingDisabled)
         return;
         
-    _lockFocus();
     if (data->state.brush.style() != NoBrush) {
         _setColorFromBrush();
         [NSBezierPath fillRect:NSMakeRect(x, y, w, h)];
@@ -189,22 +144,18 @@ void QPainter::drawRect(int x, int y, int w, int h)
         _setColorFromPen();
         [NSBezierPath strokeRect:NSMakeRect(x, y, w, h)];
     }
-    _unlockFocus();
 }
 
-
 void QPainter::_setColorFromBrush()
 {
     [data->state.brush.color().getNSColor() set];
 }
 
-
 void QPainter::_setColorFromPen()
 {
     [data->state.pen.color().getNSColor() set];
 }
 
-
 // This is only used to draw borders around text, and lines over text.
 void QPainter::drawLine(int x1, int y1, int x2, int y2)
 {
@@ -253,10 +204,8 @@ void QPainter::drawLine(int x1, int y1, int x2, int y2)
     [path lineToPoint:p2];
     [path closePath];
 
-    _lockFocus();
     _setColorFromPen();
     [path stroke];
-    _unlockFocus();
 }
 
 
@@ -266,11 +215,8 @@ void QPainter::drawEllipse(int x, int y, int w, int h)
     if (data->state.paintingDisabled)
         return;
         
-    NSBezierPath *path;
-    
-    path = [NSBezierPath bezierPathWithOvalInRect: NSMakeRect (x, y, w, h)];
+    NSBezierPath *path = [NSBezierPath bezierPathWithOvalInRect: NSMakeRect (x, y, w, h)];
     
-    _lockFocus();
     if (data->state.brush.style() != NoBrush) {
         _setColorFromBrush();
         [path fill];
@@ -279,7 +225,6 @@ void QPainter::drawEllipse(int x, int y, int w, int h)
         _setColorFromPen();
         [path stroke];
     }
-    _unlockFocus();
 }
 
 
@@ -289,30 +234,22 @@ void QPainter::drawArc (int x, int y, int w, int h, int a, int alen)
     if (data->state.paintingDisabled)
         return;
         
-    if (data->state.pen.style() != NoPen){
-
-        NSBezierPath *path;
-        float fa, falen;
-    
-        if (w != h){
+    if (data->state.pen.style() != NoPen) {
+        if (w != h) {
             KWQDEBUG("ERROR (INCOMPLETE IMPLEMENTATION) void QPainter::drawArc (int x, int y, int w, int h, int a, int alen)\nOnly supports drawing arcs on a circle.\n");
         }
         
-        path = [[[NSBezierPath alloc] init] autorelease];
-        fa = (float)(a/16);
-        falen =  fa + (float)(alen/16);
-        [path appendBezierPathWithArcWithCenter: NSMakePoint(x + w/2, y + h/2) 
-                    radius: (float)(w/2) 
-                    startAngle: -fa
-                    endAngle: -falen
-                    clockwise: YES];
-    
-        _lockFocus();
+        NSBezierPath *path = [[[NSBezierPath alloc] init] autorelease];
+        float fa = (float)a / 16;
+        float falen =  fa + (float)alen / 16;
+        [path appendBezierPathWithArcWithCenter:NSMakePoint(x + w / 2, y + h / 2) 
+                                         radius:(float)w / 2 
+                                     startAngle:-fa
+                                       endAngle:-falen
+                                      clockwise:YES];
     
         _setColorFromPen();
         [path stroke];
-    
-        _unlockFocus();
     }
 }
 
@@ -320,89 +257,66 @@ void QPainter::drawLineSegments(const QPointArray &points, int index, int nlines
 {
     if (data->state.paintingDisabled)
         return;
-        
-    _drawPoints (points, 0, index, nlines, FALSE);
+    
+    _drawPoints (points, 0, index, nlines, false);
 }
 
 void QPainter::drawPolyline(const QPointArray &points, int index, int npoints)
 {
-    if (data->state.paintingDisabled)
-        return;
-        
-    _drawPoints (points, 0, index, npoints, FALSE);
+    _drawPoints (points, 0, index, npoints, false);
 }
 
-
 void QPainter::drawPolygon(const QPointArray &points, bool winding, int index, 
     int npoints)
 {
-    if (data->state.paintingDisabled)
-        return;
-        
-    _drawPoints (points, winding, index, npoints, TRUE);
+    _drawPoints (points, winding, index, npoints, true);
 }
 
 void QPainter::drawConvexPolygon(const QPointArray &points)
 {
-    if (data->state.paintingDisabled)
-        return;
-        
-    _drawPoints (points, FALSE, 0, -1, TRUE);
+    _drawPoints (points, false, 0, -1, true);
 }
 
-void QPainter::_drawPoints (const QPointArray &_points, bool winding, int index, 
-    int _npoints, bool fill)
+void QPainter::_drawPoints (const QPointArray &_points, bool winding, int index, int _npoints, bool fill)
 {
-    NSBezierPath *path;
-    int i;
+    if (data->state.paintingDisabled)
+        return;
+        
     int npoints = _npoints != -1 ? _npoints : _points.size()-index;
-
     NSPoint points[npoints];
-    
-    for (i = 0; i < npoints; i++){
+    for (int i = 0; i < npoints; i++) {
         points[i].x = _points[index+i].x();
         points[i].y = _points[index+i].y();
     }
             
-    path = [[[NSBezierPath alloc] init] autorelease];
-    [path appendBezierPathWithPoints: &points[0] count: npoints];
-    [path closePath];	// Qt always closes the path.  Determined empirically.
+    NSBezierPath *path = [[NSBezierPath alloc] init];
+    [path appendBezierPathWithPoints:&points[0] count:npoints];
+    [path closePath]; // Qt always closes the path.  Determined empirically.
     
-    _lockFocus();
-
-    if (fill == TRUE && data->state.brush.style() != NoBrush){
-        if (winding == TRUE)
-            [path setWindingRule: NSNonZeroWindingRule];
-        else
-            [path setWindingRule: NSEvenOddWindingRule];
+    if (fill && data->state.brush.style() != NoBrush) {
+        [path setWindingRule:winding ? NSNonZeroWindingRule : NSEvenOddWindingRule];
         _setColorFromBrush();
         [path fill];
     }
 
-    if (data->state.pen.style() != NoPen){
+    if (data->state.pen.style() != NoPen) {
         _setColorFromPen();
         [path stroke];
     }
     
-    _unlockFocus();
+    [path release];
 }
 
 
 void QPainter::drawPixmap(const QPoint &p, const QPixmap &pix)
-{
-    if (data->state.paintingDisabled)
-        return;
-        
-    drawPixmap (p.x(), p.y(), pix);
+{        
+    drawPixmap(p.x(), p.y(), pix);
 }
 
 
 void QPainter::drawPixmap(const QPoint &p, const QPixmap &pix, const QRect &r)
 {
-    if (data->state.paintingDisabled)
-        return;
-        
-    drawPixmap (p.x(), p.y(), pix, r.x(), r.y(), r.width(), r.height());
+    drawPixmap(p.x(), p.y(), pix, r.x(), r.y(), r.width(), r.height());
 }
 
 void QPainter::drawPixmap( int x, int y, const QPixmap &pixmap,
@@ -411,8 +325,6 @@ void QPainter::drawPixmap( int x, int y, const QPixmap &pixmap,
     if (data->state.paintingDisabled)
         return;
         
-    _lockFocus();
-
     if (sw == -1)
         sw = pixmap.width();
     if (sh == -1)
@@ -420,8 +332,6 @@ void QPainter::drawPixmap( int x, int y, const QPixmap &pixmap,
     
     [pixmap.imageRenderer beginAnimationInRect:NSMakeRect(x, y, sw, sh)
                                       fromRect:NSMakeRect(sx, sy, sw, sh)];
-    
-    _unlockFocus();
 }
 
 void QPainter::drawTiledPixmap( int x, int y, int w, int h,
@@ -429,33 +339,8 @@ void QPainter::drawTiledPixmap( int x, int y, int w, int h,
 {
     if (data->state.paintingDisabled)
         return;
-        
-    [pixmap.imageRenderer tileInRect:NSMakeRect(x, y, w, h) fromPoint:NSMakePoint(sx, sy)];
-}
-
-// y is the baseline
-void QPainter::drawText(int x, int y, const QString &qstring, int len)
-{
-    if (data->state.paintingDisabled)
-        return;
-        
-    _lockFocus();
     
-    if (len == -1)
-        len = qstring.length();
-
-    drawText(x, y, qstring, 0, len, LTR);
-
-    _unlockFocus();
-}
-
-
-void QPainter::drawText(int x, int y, const QString &qstring, int len, TextDirection dir)
-{
-    if (data->state.paintingDisabled)
-        return;
-        
-    drawText(x, y, qstring, 0, len, dir);
+    [pixmap.imageRenderer tileInRect:NSMakeRect(x, y, w, h) fromPoint:NSMakePoint(sx, sy)];
 }
 
 void QPainter::drawText(int x, int y, const QString &qstring, int from, int to, const QColor &backgroundColor)
@@ -463,229 +348,61 @@ void QPainter::drawText(int x, int y, const QString &qstring, int from, int to,
     if (data->state.paintingDisabled)
         return;
         
-    _lockFocus();
-
     [[[WebCoreTextRendererFactory sharedFactory]
         rendererWithFamily:data->state.font.getNSFamily() traits:data->state.font.getNSTraits() size:data->state.font.getNSSize()]
     	drawCharacters:(const UniChar *)qstring.unicode() stringLength:qstring.length()
         fromCharacterPosition:from toCharacterPosition:to atPoint:NSMakePoint(x, y)
         withTextColor:data->state.pen.color().getNSColor() backgroundColor:backgroundColor.isValid() ? backgroundColor.getNSColor() : nil];
-
-    _unlockFocus();
-}
-
-
-void QPainter::drawText(int x, int y, const QString &qstring, int pos, int len, TextDirection dir)
-{
-    if (data->state.paintingDisabled)
-        return;
-        
-    if (dir == RTL) {
-        _logPartiallyImplemented();
-    }
-
-    if (pos != 0)
-        drawText(x, y, qstring.mid(pos, len), len, dir);
-    else
-        drawText(x, y, qstring, len, dir);
-}
-
-
-void QPainter::drawUnderlineForText(int x, int y, const QString &qstring, int len)
-{
-    if (data->state.paintingDisabled)
-        return;
-        
-    NSString *string;
-    
-    _lockFocus();
-    
-    string = qstring.getNSString();
-    if (len != -1) {
-        string = [string substringToIndex:len];
-    }
-
-    [[[WebCoreTextRendererFactory sharedFactory]
-        rendererWithFamily:data->state.font.getNSFamily() traits:data->state.font.getNSTraits() size:data->state.font.getNSSize()]
-        drawUnderlineForString:string atPoint:NSMakePoint(x,y) withColor:data->state.pen.color().getNSColor()];
-
-    _unlockFocus();
 }
 
-
-void QPainter::drawText(int x, int y, int w, int h, int flags, const QString &qstring, int len, 
-    QRect *br, char **internal)
+void QPainter::drawUnderlineForText(int x, int y, const QString &qstring)
 {
     if (data->state.paintingDisabled)
         return;
         
-    NSString *string;
-    NSMutableParagraphStyle *style = [[[NSMutableParagraphStyle alloc] init] autorelease];
-    
-    string = qstring.getNSString();
-    if (len != -1) {
-        string = [string substringToIndex:len];
-    }
-
-    if (flags & Qt::WordBreak) {
-        [style setLineBreakMode: NSLineBreakByWordWrapping];
-    } else {
-        [style setLineBreakMode: NSLineBreakByClipping];
-    }
-    
-    if (flags & Qt::AlignRight) {
-        [style setAlignment: NSRightTextAlignment];
-    }
-    
-    if (flags & Qt::AlignLeft) {
-        [style setAlignment: NSLeftTextAlignment];
-    }
-    
-    _lockFocus();
-    
     [[[WebCoreTextRendererFactory sharedFactory]
         rendererWithFamily:data->state.font.getNSFamily() traits:data->state.font.getNSTraits() size:data->state.font.getNSSize()]
-        drawString:string inRect:NSMakeRect(x, y, w, h) withColor:data->state.pen.color().getNSColor() paragraphStyle:style];
-
-    _unlockFocus();
+        drawUnderlineForString:qstring.getNSString() atPoint:NSMakePoint(x,y) withColor:data->state.pen.color().getNSColor()];
 }
 
 QColor QPainter::selectedTextBackgroundColor()
 {
-    NSColor *color = [NSColor selectedTextBackgroundColor];
-    
-    color = [color colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
-    return QColor ((int)(255 * [color redComponent]), (int)(255 * [color greenComponent]), (int)(255 * [color blueComponent]));
+    NSColor *color = [[NSColor selectedTextBackgroundColor] colorUsingColorSpaceName:NSCalibratedRGBColorSpace];
+    return QColor((int)(255 * [color redComponent]), (int)(255 * [color greenComponent]), (int)(255 * [color blueComponent]));
 }
 
-
-
 void QPainter::fillRect(int x, int y, int w, int h, const QBrush &brush)
 {
     if (data->state.paintingDisabled)
         return;
         
-    _lockFocus();
     if (brush.style() == SolidPattern) {
         [brush.color().getNSColor() set];
         [NSBezierPath fillRect:NSMakeRect(x, y, w, h)];
     }
-    _unlockFocus();
-}
-
-
-void QPainter::setClipping(bool)
-{
-    _logNotYetImplemented();
 }
 
-void QPainter::setClipRegion(const QRegion &)
+void QPainter::setClipRegion(const QRegion &region)
 {
-    _logNotYetImplemented();
+    data->state.clip = region;
 }
 
 const QRegion &QPainter::clipRegion() const
 {
-    _logPartiallyImplemented();
-    static QRegion null;
-    return null;
+    return data->state.clip;
 }
 
-bool QPainter::hasClipping() const
-{
-    _logNotYetImplemented();
-    return false;
-}
-
-void QPainter::setClipRect(const QRect &)
-{
-    _logNotYetImplemented();
-}
-
-
-void QPainter::setClipRect(int,int,int,int)
-{
-    _logNotYetImplemented();
-}
-
-
 Qt::RasterOp QPainter::rasterOp() const
 {
-#ifdef _SUPPORT_RASTER_OP
-    if (data->state.compositingOperation == NSCompositeSourceOver)
-        rerturn OrROP;
-    else if (data->state.compositingOperation == NSCompositeXOR)
-        return XorROP;
-    return CopyROP;
-#else
-    _logNeverImplemented();
-    return CopyROP;
-#endif
+    return data->state.exclusiveOrMode ? XorROP : CopyROP;
 }
 
-
 void QPainter::setRasterOp(RasterOp op)
 {
-#ifdef _SUPPORT_RASTER_OP
-    if (op == OrROP)
-        data->state.compositingOperation = NSCompositeSourceOver;
-    else if (op == XorROP)
-        data->state.compositingOperation = NSCompositeXOR;
-    else
-        data->state.compositingOperation = NSCompositeCopy;
-#else
-     _logNotYetImplemented();
-#endif
-}
-
-void QPainter::translate(double dx, double dy)
-{
-    _logNeverImplemented();
-}
-
-
-void QPainter::scale(double dx, double dy)
-{
-    _logNeverImplemented();
-}
-
-
-void QPainter::_lockFocus()
-{
-#if 0
-    if (data->isFocusLocked == 0){
-        if (data->bufferDevice != 0L){
-            const QPixmap *pixmap = (QPixmap *)(data->bufferDevice);
-            [pixmap->nsimage lockFocus];
-        }
-        else {
-            [data->widget->getView() lockFocus];
-        }
-        data->isFocusLocked = 1;
-    }	
-#endif
-}
-
-void QPainter::_unlockFocus()
-{
-#if 0
-    if (data->isFocusLocked == 1){
-        if (data->bufferDevice != 0L){
-            const QPixmap *pixmap = (QPixmap *)(data->bufferDevice);
-            [pixmap->nsimage unlockFocus];
-        }
-        else  {
-            [data->widget->getView() unlockFocus];
-        }
-        data->isFocusLocked = 0;
-    }	
-#endif
+    data->state.exclusiveOrMode = op == XorROP;
 }
 
 void QPainter::setPaintingDisabled(bool f)
 {
     data->state.paintingDisabled = f;
 }
-
-
-
diff --git a/WebCore/kwq/KWQPixmap.h b/WebCore/kwq/KWQPixmap.h
index a08d6df..3de3c2d 100644
--- a/WebCore/kwq/KWQPixmap.h
+++ b/WebCore/kwq/KWQPixmap.h
@@ -81,4 +81,10 @@ private:
 
 };
 
+class QWMatrix {
+public:
+    QWMatrix() { }
+    QWMatrix &scale(double, double) { return *this; }
+};
+
 #endif
diff --git a/WebCore/kwq/KWQView.h b/WebCore/kwq/KWQView.h
index 4dcc3e7..913acff 100644
--- a/WebCore/kwq/KWQView.h
+++ b/WebCore/kwq/KWQView.h
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2001, 2002 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
@@ -25,41 +25,34 @@
  
 #import <Cocoa/Cocoa.h>
 
-
 class QWidget;
-class KHTMLPart;
 
 @interface KWQView : NSView
 {
     QWidget *widget;
     bool isFlipped;
 }
-- initWithFrame: (NSRect)r widget: (QWidget *)w; 
-- (void)setIsFlipped: (bool)flag;
+- initWithFrame:(NSRect)r widget:(QWidget *)w; 
+- (void)setIsFlipped:(bool)flag;
 @end
 
 @interface KWQNSButton : NSButton
 {
     QWidget *widget;
 }
-- initWithFrame: (NSRect)r widget: (QWidget *)w; 
+- initWithFrame:(NSRect)r widget:(QWidget *)w; 
 @end
 
 @interface KWQNSComboBox : NSPopUpButton
 {
     QWidget *widget;
 }
-- initWithFrame: (NSRect)r widget: (QWidget *)w; 
+- initWithFrame:(NSRect)r widget:(QWidget *)w; 
 @end
 
 @interface KWQNSScrollView : NSScrollView
 {
     QWidget *widget;
 }
-- initWithFrame: (NSRect)r widget: (QWidget *)w; 
+- initWithFrame:(NSRect)r widget:(QWidget *)w; 
 @end
-
-
-
-
-
diff --git a/WebCore/kwq/KWQView.mm b/WebCore/kwq/KWQView.mm
index ceadf50..ac45108 100644
--- a/WebCore/kwq/KWQView.mm
+++ b/WebCore/kwq/KWQView.mm
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2001 Apple Computer, Inc.  All rights reserved.
+ * Copyright (C) 2001, 2002 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
@@ -22,41 +22,25 @@
  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
  */
-#import "KWQView.h"
-
-#import "kwqdebug.h"
 
-#import <khtmlview.h>
-#import <khtml_part.h>
+#import "KWQView.h"
 #import <qwidget.h>
-#import <qpainter.h>
-#import <qevent.h>
-#import <html_documentimpl.h>
-
-
 
 @implementation KWQView
 
-- initWithFrame: (NSRect) r widget: (QWidget *)w 
+- initWithFrame:(NSRect)r widget:(QWidget *)w 
 {
-    [super initWithFrame: r];
+    [super initWithFrame:r];
     widget = w;
     isFlipped = YES;
     return self;
 }
 
-
-// This should eventually be removed.
-- (void)drawRect:(NSRect)rect {
-    widget->paint((void *)0);
-}
-
-- (void)setIsFlipped: (bool)flag
+- (void)setIsFlipped:(bool)flag
 {
     isFlipped = flag;
 }
 
-
 - (BOOL)isFlipped 
 {
     return isFlipped;
@@ -64,58 +48,55 @@
 
 @end
 
-
 @implementation KWQNSButton
 
-- initWithFrame: (NSRect) r widget: (QWidget *)w 
+- initWithFrame:(NSRect)r widget:(QWidget *)w 
 {
-    [super initWithFrame: r];
+    [super initWithFrame:r];
     [self setBordered:YES];
     [self setBezelStyle:NSRoundedBezelStyle];
     widget = w;
     
-    [self setTarget: self];
-    [self setAction: @selector(action:)];
+    [self setTarget:self];
+    [self setAction:@selector(action:)];
     return self;
 }
 
-- (void)action: sender
+- (void)action:(id)sender
 {
     widget->emitAction(QObject::ACTION_BUTTON_CLICKED);
 }
 
-- (void)stateChanged: sender
+- (void)stateChanged:(id)sender
 {
     widget->emitAction(QObject::ACTION_CHECKBOX_CLICKED);
 }
 
 @end
 
-
 @implementation KWQNSComboBox
 
-- initWithFrame: (NSRect) r widget: (QWidget *)w 
+- initWithFrame:(NSRect)r widget:(QWidget *)w 
 {
-    [super initWithFrame: r];
+    [super initWithFrame:r];
     widget = w;
-    [self setTarget: self];
-    [self setAction: @selector(action:)];
+    [self setTarget:self];
+    [self setAction:@selector(action:)];
     return self;
 }
 
-- (void)action: sender
+- (void)action:(id)sender
 {
     widget->emitAction(QObject::ACTION_COMBOBOX_CLICKED);
 }
 
 @end
 
-
 @implementation KWQNSScrollView
 
-- initWithFrame: (NSRect) r widget: (QWidget *)w 
+- initWithFrame:(NSRect)r widget:(QWidget *)w 
 {
-    [super initWithFrame: r];
+    [super initWithFrame:r];
     widget = w;
     return self;
 }
diff --git a/WebCore/kwq/KWQWMatrix.mm b/WebCore/kwq/KWQWMatrix.mm
deleted file mode 100644
index dae5644..0000000
--- a/WebCore/kwq/KWQWMatrix.mm
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * 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. 
- */
-
-#import <kwqdebug.h>
-#import <qpainter.h>
-
-
-// Simple implementation.  Only allows for scaling, and scaling once! 
-// This class is used by khtml to scale images.
-QWMatrix::QWMatrix()
-{
-    empty = TRUE;
-}
-    
-
-QWMatrix &QWMatrix::scale(double _sx, double _sy)
-{
-    if (empty != TRUE){
-        KWQDEBUG("ERROR (INCOMPLETE IMPLEMENTATION) QWMatrix &QWMatrix::scale(double _sx, double _sy) scale may only be called once.\n");
-    }
-    empty = FALSE;
-    sx = _sx;
-    sy = _sy;
-    return *this;
-}
-
diff --git a/WebCore/kwq/KWQWidget.h b/WebCore/kwq/KWQWidget.h
index 2befd39..fd18554 100644
--- a/WebCore/kwq/KWQWidget.h
+++ b/WebCore/kwq/KWQWidget.h
@@ -130,9 +130,7 @@ public:
     void setBackgroundMode(BackgroundMode) { }
 
     void setAcceptDrops(bool) { }
-    
-    virtual void paint(void *);
-    
+        
     NSView *getView() const;
     void setView(NSView *aView);
     
diff --git a/WebCore/kwq/KWQWidget.mm b/WebCore/kwq/KWQWidget.mm
index 1829a42..f58a834 100644
--- a/WebCore/kwq/KWQWidget.mm
+++ b/WebCore/kwq/KWQWidget.mm
@@ -368,10 +368,6 @@ QPoint QWidget::mapFromGlobal(const QPoint &p) const
     return QPoint((int)bp.x, (int)bp.y);
 }
 
-void QWidget::paint(void *)
-{
-}
-
 NSView *QWidget::getView() const
 {
     return data->view;
diff --git a/WebCore/kwq/WebCoreBridge.h b/WebCore/kwq/WebCoreBridge.h
index 334ce47..4c0e1ad 100644
--- a/WebCore/kwq/WebCoreBridge.h
+++ b/WebCore/kwq/WebCoreBridge.h
@@ -49,6 +49,8 @@ typedef khtml::RenderPart KHTMLRenderPart;
 
 @class WebCoreFrame;
 
+ at protocol WebCoreDOMTreeCopier;
+ at protocol WebCoreRenderTreeCopier;
 @protocol WebCoreResourceLoader;
 
 // WebCoreBridge objects are used by WebCore to abstract away operations that need
@@ -63,6 +65,7 @@ typedef khtml::RenderPart KHTMLRenderPart;
 @interface WebCoreBridge : NSObject
 {
     KHTMLPart *part;
+    BOOL bridgeOwnsKHTMLView;
 }
 
 - (KHTMLPart *)part;
@@ -72,13 +75,16 @@ typedef khtml::RenderPart KHTMLRenderPart;
 - (void)closeURL;
 - (void)end;
 
+- (void)installInFrame:(NSView *)view;
+- (void)removeFromFrame;
+
 - (void)setURL:(NSURL *)URL;
 
 - (void)scrollToBaseAnchor;
 
 - (NSString *)documentTextFromDOM;
 
-- (KHTMLView *)createKHTMLViewWithNSView:(NSView *)view
+- (void)createKHTMLViewWithNSView:(NSView *)view
     width:(int)width height:(int)height
     marginWidth:(int)mw marginHeight:(int)mh;
 
@@ -87,9 +93,17 @@ typedef khtml::RenderPart KHTMLRenderPart;
 
 - (void)reapplyStyles;
 - (void)forceLayout;
-- (void)adjustFrames: (NSRect)rect;
+- (void)adjustFrames:(NSRect)rect;
 - (void)drawRect:(NSRect)rect;
 
+- (void)mouseDown:(NSEvent *)event;
+- (void)mouseUp:(NSEvent *)event;
+- (void)mouseMoved:(NSEvent *)event;
+- (void)mouseDragged:(NSEvent *)event;
+
+- (NSObject *)copyDOMTree:(id <WebCoreDOMTreeCopier>)copier;
+- (NSObject *)copyRenderTree:(id <WebCoreRenderTreeCopier>)copier;
+
 @end
 
 // The WebCoreBridge protocol contains methods for use by the WebCore side of the bridge.
@@ -127,10 +141,10 @@ typedef khtml::RenderPart KHTMLRenderPart;
 
 - (void)objectLoadedFromCache:(NSURL *)URL size:(unsigned)bytes;
 
-- (BOOL) openedByScript;
-- (void) setOpenedByScript:(BOOL)openedByScript;
+- (BOOL)openedByScript;
+- (void)setOpenedByScript:(BOOL)openedByScript;
 
-- (void) unfocusWindow;
+- (void)unfocusWindow;
 
 @end
 
@@ -140,3 +154,11 @@ typedef khtml::RenderPart KHTMLRenderPart;
 
 @interface WebCoreBridge (SubclassResponsibility) <WebCoreBridge>
 @end
+
+ at protocol WebCoreDOMTreeCopier <NSObject>
+- (NSObject *)nodeWithName:(NSString *)name value:(NSString *)value source:(NSString *)source children:(NSArray *)children;
+ at end
+
+ at protocol WebCoreRenderTreeCopier <NSObject>
+- (NSObject *)nodeWithName:(NSString *)name rect:(NSRect)rect view:(NSView *)view children:(NSArray *)children;
+ at end
diff --git a/WebCore/kwq/WebCoreBridge.mm b/WebCore/kwq/WebCoreBridge.mm
index de212a5..e673e67 100644
--- a/WebCore/kwq/WebCoreBridge.mm
+++ b/WebCore/kwq/WebCoreBridge.mm
@@ -25,10 +25,12 @@
 
 #import <WebCoreBridge.h>
 
+#import <WebCoreFrame.h>
+
 #import <KWQKHTMLPartImpl.h>
 #import <khtmlview.h>
 #import <dom_docimpl.h>
-#import <render_object.h>
+#import <render_frames.h>
 
 @implementation WebCoreBridge
 
@@ -44,6 +46,8 @@
 
 - (void)dealloc
 {
+    [self removeFromFrame];
+    
     part->deref();
     
     [super dealloc];
@@ -79,11 +83,10 @@
     part->impl->setBaseURL([[URL absoluteString] cString]);
 }
 
-- (KHTMLView *)createKHTMLViewWithNSView:(NSView *)view
+- (void)createKHTMLViewWithNSView:(NSView *)view
     width:(int)width height:(int)height
     marginWidth:(int)mw marginHeight:(int)mh
 {
-    // Nasty! Set up the cross references between the KHTMLView and the KHTMLPart.
     KHTMLView *kview = new KHTMLView(part, 0);
     part->impl->setView(kview);
 
@@ -94,7 +97,7 @@
         kview->setMarginHeight(mh);
     kview->resize(width, height);
     
-    return kview;
+    bridgeOwnsKHTMLView = YES;
 }
 
 - (NSString *)documentTextFromDOM
@@ -149,7 +152,7 @@
     }
 }
 
-- (void)_drawRect:(NSRect)rect withPainter: (QPainter *)p
+- (void)_drawRect:(NSRect)rect withPainter:(QPainter *)p
 {
     DOM::DocumentImpl *doc = part->xmlDocImpl();
     if (doc) {
@@ -163,21 +166,189 @@
 - (void)drawRect:(NSRect)rect
 {
     QPainter p;
-    [self _drawRect:rect withPainter: &p];
+    [self _drawRect:rect withPainter:&p];
 }
 
-- (void)adjustFrames: (NSRect)rect
+- (void)adjustFrames:(NSRect)rect
 {
     // Ick!  khtml sets the frame size during layout and
     // the frame origins during drawing!  So we have to 
     // layout and do a draw with rendering disabled to
-    // correclty adjust the frames.
+    // correctly adjust the frames.
     [self forceLayout];
     QPainter p;
     p.setPaintingDisabled(YES);
-    [self _drawRect:rect withPainter: &p];
+    [self _drawRect:rect withPainter:&p];
+}
+
+- (NSObject *)copyDOMNode:(DOM::NodeImpl *)node copier:(id <WebCoreDOMTreeCopier>)copier
+{
+    NSMutableArray *children = [[NSMutableArray alloc] init];
+    for (DOM::NodeImpl *child = node->firstChild(); child; child = child->nextSibling()) {
+        [children addObject:[self copyDOMNode:child copier:copier]];
+    }
+    NSObject *copiedNode = [copier nodeWithName:node->nodeName().string().getNSString()
+                                          value:node->nodeValue().string().getNSString()
+                                         source:node->recursive_toHTML(1).getNSString()
+                                       children:children];
+    [children release];
+    return copiedNode;
+}
+
+- (NSObject *)copyDOMTree:(id <WebCoreDOMTreeCopier>)copier
+{
+    DOM::DocumentImpl *doc = part->xmlDocImpl();
+    if (!doc) {
+        return nil;
+    }
+    return [self copyDOMNode:doc copier:copier];
 }
 
+- (NSObject *)copyRenderNode:(khtml::RenderObject *)node copier:(id <WebCoreRenderTreeCopier>)copier
+{
+    NSMutableArray *children = [[NSMutableArray alloc] init];
+    for (khtml::RenderObject *child = node->firstChild(); child; child = child->nextSibling()) {
+        [children addObject:[self copyRenderNode:child copier:copier]];
+    }
+    
+    NSString *name = [[NSString alloc] initWithUTF8String:node->renderName()];
+    
+    khtml::RenderPart *renderPart = dynamic_cast<khtml::RenderPart *>(node);
+    QWidget *widget = renderPart ? renderPart->widget() : 0;
+    NSView *view = widget ? widget->getView() : nil;
+    
+    NSObject *copiedNode = [copier nodeWithName:name
+                                           rect:NSMakeRect(node->xPos(), node->yPos(), node->width(), node->height())
+                                           view:view
+                                       children:children];
+    
+    [name release];
+    [children release];
+    
+    return copiedNode;
+}
+
+- (NSObject *)copyRenderTree:(id <WebCoreRenderTreeCopier>)copier
+{
+    DOM::DocumentImpl *doc = part->xmlDocImpl();
+    if (!doc) {
+        return nil;
+    }
+    khtml::RenderObject *renderer = doc->renderer();
+    if (!renderer) {
+        return nil;
+    }
+    return [self copyRenderNode:renderer copier:copier];
+}
+
+- (void)removeFromFrame
+{
+    if (bridgeOwnsKHTMLView) {
+        delete part->impl->getView();
+    }
+    bridgeOwnsKHTMLView = NO;
+}
+
+- (void)installInFrame:(NSView *)view
+{
+    part->impl->getView()->setView(view);
 
+    KHTMLRenderPart *renderPart = [[self frame] renderPart];
+    if (renderPart) {
+        renderPart->setWidget(part->impl->getView());
+        // Now that the render part is holding the widget, we don't own it any more.
+        bridgeOwnsKHTMLView = NO;
+    }
+}
+
+- (void)addModifiers:(unsigned)modifiers toState:(int *)state
+{
+    if (modifiers & NSControlKeyMask)
+        *state |= Qt::ControlButton;
+    if (modifiers & NSShiftKeyMask)
+        *state |= Qt::ShiftButton;
+    if (modifiers & NSAlternateKeyMask)
+        *state |= Qt::AltButton;
+    // Mapping command to meta is slightly questionable
+    if (modifiers & NSCommandKeyMask)
+        *state |= Qt::MetaButton;
+}
+
+- (void)mouseUp:(NSEvent *)event
+{
+    NSPoint p = [event locationInWindow];
+
+    int button, state;
+    switch ([event type]) {
+    case NSRightMouseUp:
+        button = Qt::RightButton;
+        state = Qt::RightButton;
+        break;
+    case NSOtherMouseUp:
+        button = Qt::MidButton;
+        state = Qt::MidButton;
+        break;
+    default:
+        button = Qt::LeftButton;
+        state = Qt::LeftButton;
+        break;
+    }
+    [self addModifiers:[event modifierFlags] toState:&state];
+    
+    QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
+    if (part->impl->getView()) {
+        part->impl->getView()->viewportMouseReleaseEvent(&kEvent);
+    }
+}
+
+- (void)mouseDown:(NSEvent *)event
+{
+    NSPoint p = [event locationInWindow];
+
+    int button, state;     
+    switch ([event type]) {
+    case NSRightMouseUp:
+        button = Qt::RightButton;
+        state = Qt::RightButton;
+        break;
+    case NSOtherMouseUp:
+        button = Qt::MidButton;
+        state = Qt::MidButton;
+        break;
+    default:
+        button = Qt::LeftButton;
+        state = Qt::LeftButton;
+        break;
+    }
+    [self addModifiers:[event modifierFlags] toState:&state];
+    
+    QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
+    if (part->impl->getView()) {
+        part->impl->getView()->viewportMousePressEvent(&kEvent);
+    }
+}
+
+- (void)mouseMoved:(NSEvent *)event
+{
+    NSPoint p = [event locationInWindow];
+    
+    int state = 0;
+    [self addModifiers:[event modifierFlags] toState:&state];
+    
+    QMouseEvent kEvent(QEvent::MouseMove, QPoint((int)p.x, (int)p.y), 0, state);
+    if (part->impl->getView()) {
+        part->impl->getView()->viewportMouseMoveEvent(&kEvent);
+    }
+}
+
+- (void)mouseDragged:(NSEvent *)event
+{
+    NSPoint p = [event locationInWindow];
+    
+    QMouseEvent kEvent(QEvent::MouseMove, QPoint((int)p.x, (int)p.y), Qt::LeftButton, Qt::LeftButton);
+    if (part->impl->getView()) {
+        part->impl->getView()->viewportMouseMoveEvent(&kEvent);
+    }
+}
 
 @end
diff --git a/WebCore/kwq/WebCoreCache.h b/WebCore/kwq/WebCoreCache.h
new file mode 100644
index 0000000..810ed21
--- /dev/null
+++ b/WebCore/kwq/WebCoreCache.h
@@ -0,0 +1,19 @@
+//
+//  WebCoreCache.h
+//  WebCore
+//
+//  Created by Darin Adler on Sun Jul 14 2002.
+//  Copyright (c) 2002 Apple Computer, Inc.. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+ at interface WebCoreCache : NSObject
+{
+}
+
++ (NSArray *)statistics;
++ (void)empty;
++ (void)setDisabled:(BOOL)disabled;
+
+ at end
diff --git a/WebCore/kwq/WebCoreCache.mm b/WebCore/kwq/WebCoreCache.mm
new file mode 100644
index 0000000..5a52135
--- /dev/null
+++ b/WebCore/kwq/WebCoreCache.mm
@@ -0,0 +1,49 @@
+//
+//  WebCoreCache.m
+//  WebCore
+//
+//  Created by Darin Adler on Sun Jul 14 2002.
+//  Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+//
+
+#import "WebCoreCache.h"
+
+#include <loader.h>
+
+using khtml::Cache;
+
+ at implementation WebCoreCache
+
++ (NSArray *)statistics
+{
+    Cache::Statistics s = Cache::getStatistics();
+
+    return [NSArray arrayWithObjects:
+        [NSDictionary dictionaryWithObjectsAndKeys:
+            [NSNumber numberWithInt:s.images.count], @"images",
+            [NSNumber numberWithInt:s.movies.count], @"movies",
+            [NSNumber numberWithInt:s.styleSheets.count], @"style sheets",
+            [NSNumber numberWithInt:s.scripts.count], @"scripts",
+            [NSNumber numberWithInt:s.other.count], @"other",
+            nil],
+        [NSDictionary dictionaryWithObjectsAndKeys:
+            [NSNumber numberWithInt:s.images.size], @"images",
+            [NSNumber numberWithInt:s.movies.size], @"movies",
+            [NSNumber numberWithInt:s.styleSheets.size] ,@"style sheets",
+            [NSNumber numberWithInt:s.scripts.size], @"scripts",
+            [NSNumber numberWithInt:s.other.size], @"other",
+            nil],
+        nil];
+}
+
++ (void)empty
+{
+    Cache::flushAll();
+}
+
++ (void)setDisabled:(BOOL)disabled
+{
+    Cache::setCacheDisabled(disabled);
+}
+
+ at end
diff --git a/WebCore/kwq/WebCoreFrame.h b/WebCore/kwq/WebCoreFrame.h
index 3a2be44..cff1fd1 100644
--- a/WebCore/kwq/WebCoreFrame.h
+++ b/WebCore/kwq/WebCoreFrame.h
@@ -48,9 +48,8 @@
 - (void)loadURL:(NSURL *)URL;
 - (void)postWithURL:(NSURL *)URL data:(NSData *)data;
 
-- (KHTMLView *)widget; // returns provisional widget if present, otherwise committed (avoid calling this for that reason)
-
-- (WebCoreBridge *)bridge; // always returns committed bridge, not provisional (avoid calling this for that reason)
+- (WebCoreBridge *)bridge; // returns provisional bridge if present (avoid calling this for that reason)
+- (WebCoreBridge *)committedBridge; // always returns committed bridge, not provisional (avoid calling this for that reason)
 
 @end
 
diff --git a/WebCore/kwq/WebCoreFrameBridge.h b/WebCore/kwq/WebCoreFrameBridge.h
index 3a2be44..cff1fd1 100644
--- a/WebCore/kwq/WebCoreFrameBridge.h
+++ b/WebCore/kwq/WebCoreFrameBridge.h
@@ -48,9 +48,8 @@
 - (void)loadURL:(NSURL *)URL;
 - (void)postWithURL:(NSURL *)URL data:(NSData *)data;
 
-- (KHTMLView *)widget; // returns provisional widget if present, otherwise committed (avoid calling this for that reason)
-
-- (WebCoreBridge *)bridge; // always returns committed bridge, not provisional (avoid calling this for that reason)
+- (WebCoreBridge *)bridge; // returns provisional bridge if present (avoid calling this for that reason)
+- (WebCoreBridge *)committedBridge; // always returns committed bridge, not provisional (avoid calling this for that reason)
 
 @end
 
diff --git a/WebCore/kwq/WebCoreJavaScript.h b/WebCore/kwq/WebCoreJavaScript.h
new file mode 100644
index 0000000..9481dab
--- /dev/null
+++ b/WebCore/kwq/WebCoreJavaScript.h
@@ -0,0 +1,23 @@
+//
+//  WebCoreJavaScript.h
+//  WebCore
+//
+//  Created by Darin Adler on Sun Jul 14 2002.
+//  Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+//
+
+#import <Foundation/Foundation.h>
+
+ at interface WebCoreJavaScript : NSObject
+{
+}
+
++ (int)interpreterCount;
+
++ (int)objectCount;
++ (int)noGCAllowedObjectCount;
++ (int)referencedObjectCount;
+
++ (void)garbageCollect;
+
+ at end
diff --git a/WebCore/kwq/WebCoreJavaScript.mm b/WebCore/kwq/WebCoreJavaScript.mm
new file mode 100644
index 0000000..55abfe6
--- /dev/null
+++ b/WebCore/kwq/WebCoreJavaScript.mm
@@ -0,0 +1,42 @@
+//
+//  WebCoreJavaScript.m
+//  WebCore
+//
+//  Created by Darin Adler on Sun Jul 14 2002.
+//  Copyright (c) 2002 Apple Computer, Inc. All rights reserved.
+//
+
+#import "WebCoreJavaScript.h"
+
+#import <JavaScriptCore/collector.h>
+
+using KJS::Collector;
+
+ at implementation WebCoreJavaScript
+
++ (int)objectCount
+{
+    return Collector::size();
+}
+
++ (int)interpreterCount
+{
+    return Collector::numInterpreters();
+}
+
++ (int)noGCAllowedObjectCount
+{
+    return Collector::numGCNotAllowedObjects();
+}
+
++ (int)referencedObjectCount
+{
+    return Collector::numReferencedObjects();
+}
+
++ (void)garbageCollect
+{
+    while (Collector::collect()) { }
+}
+
+ at end
diff --git a/WebCore/kwq/qt/qpainter.h b/WebCore/kwq/qt/qpainter.h
index 6911692..2fcde27 100644
--- a/WebCore/kwq/qt/qpainter.h
+++ b/WebCore/kwq/qt/qpainter.h
@@ -42,34 +42,21 @@ class QPixmap;
 class QWidget;
 class QPainterPrivate;
 
-class QWMatrix {
-friend class QPainter;
-friend class QPixmap;
-public:
-    QWMatrix();
-    QWMatrix &scale(double, double);
-
-private:
-    bool empty;
-    double sx;
-    double sy;
-};
-
 class QPainter : public Qt {
 public:
     typedef enum { RTL, LTR } TextDirection;
 
     QPainter();
-    QPainter(QPixmap *);
-    QPainter(QWidget *);
     ~QPainter();
     
     const QFont &font() const;
     void setFont(const QFont &);
     QFontMetrics fontMetrics() const;
+    
     const QPen &pen() const;
     void setPen(const QPen &);
     void setPen(PenStyle);
+    
     const QBrush &QPainter::brush() const;
     void setBrush(const QBrush &);
     void setBrush(BrushStyle);
@@ -85,54 +72,34 @@ public:
     void drawEllipse(int, int, int, int);
     void drawArc(int, int, int, int, int, int);
     void drawPolyline(const QPointArray &, int index=0, int npoints=-1);
-    void drawPolygon(const QPointArray &, bool winding=FALSE, int index=0,
-        int npoints=-1);
+    void drawPolygon(const QPointArray &, bool winding=FALSE, int index=0, int npoints=-1);
+    void drawConvexPolygon(const QPointArray &);
+
+    void fillRect(int, int, int, int, const QBrush &);
+
     void drawPixmap(const QPoint &, const QPixmap &);
     void drawPixmap(const QPoint &, const QPixmap &, const QRect &);
     void drawPixmap( int x, int y, const QPixmap &,
 			    int sx=0, int sy=0, int sw=-1, int sh=-1 );
     void drawTiledPixmap(int, int, int, int, const QPixmap &, int sx=0, int sy=0);
-    void drawText(int x, int y, const QString &, int len=-1);
-    void drawText(int, int, int, int, int flags, const QString&, int len=-1, 
-        QRect *br=0, char **internal=0);
-    void drawText(int, int, const QString &, int, TextDirection);
-    void drawText(int, int, const QString &, int, int, TextDirection);
-    void drawText(int, int, const QString &, int, int, const QColor& backgroundColor);
 
-    void fillRect(int, int, int, int, const QBrush &);
-    void drawConvexPolygon(const QPointArray &);
-
-    void setClipping(bool);
     void setClipRegion(const QRegion &);
-    void setClipRect(const QRect &);
-    void setClipRect(int,int,int,int);
     const QRegion &clipRegion() const;
-    bool hasClipping() const;
+
     RasterOp rasterOp() const;
     void setRasterOp(RasterOp);
 
-    void translate(double dx, double dy);
-    void scale(double dx, double dy);
-
-    void begin(QPixmap *) { }
-    void end() { }
-    QPaintDevice *device() const { return 0; }
-
-    void drawUnderlineForText(int x, int y, const QString &, int len=-1);
-
+    void drawText(int x, int y, const QString &, int from, int to, const QColor& backgroundColor);
+    void drawUnderlineForText(int x, int y, const QString &);
     static QColor selectedTextBackgroundColor();
     
     void setPaintingDisabled(bool f);
     
 private:
     // no copying or assignment
-    // note that these are "standard" (no pendantic stuff needed)
     QPainter(const QPainter &);
     QPainter &operator=(const QPainter &);
 
-    void _lockFocus();
-    void _unlockFocus();
-
     void _setColorFromBrush();
     void _setColorFromPen();
 
diff --git a/WebCore/kwq/qt/qpixmap.h b/WebCore/kwq/qt/qpixmap.h
index a08d6df..3de3c2d 100644
--- a/WebCore/kwq/qt/qpixmap.h
+++ b/WebCore/kwq/qt/qpixmap.h
@@ -81,4 +81,10 @@ private:
 
 };
 
+class QWMatrix {
+public:
+    QWMatrix() { }
+    QWMatrix &scale(double, double) { return *this; }
+};
+
 #endif
diff --git a/WebCore/kwq/qt/qwidget.h b/WebCore/kwq/qt/qwidget.h
index 2befd39..fd18554 100644
--- a/WebCore/kwq/qt/qwidget.h
+++ b/WebCore/kwq/qt/qwidget.h
@@ -130,9 +130,7 @@ public:
     void setBackgroundMode(BackgroundMode) { }
 
     void setAcceptDrops(bool) { }
-    
-    virtual void paint(void *);
-    
+        
     NSView *getView() const;
     void setView(NSView *aView);
     
diff --git a/WebKit/ChangeLog b/WebKit/ChangeLog
index 6e2907c..677b9fb 100644
--- a/WebKit/ChangeLog
+++ b/WebKit/ChangeLog
@@ -1,3 +1,65 @@
+2002-07-14  Darin Adler  <darin at apple.com>
+
+	Wean WebKit completely from getting at the C++ parts of WebCore.
+	We probably don't need to use C++ at all for WebKit any more.
+
+        * WebKit.pbproj/project.pbxproj: Remove all the header search paths; we don't need any
+	special ones now.
+
+        * WebKitPrefix.h: Remove <config.h>; we don't need it any more.
+
+        * Misc.subproj/IFCache.h: Rename getStatistics to statistics.
+        * Misc.subproj/IFCache.mm:
+        (+[IFCache statistics]):
+        (+[IFCache empty]):
+        (+[IFCache setDisabled:]):
+	Call through WebCoreCache instead of going directly to khtml::Cache.
+        (+[IFCache javaScriptObjectsCount]):
+        (+[IFCache javaScriptInterpretersCount]):
+        (+[IFCache javaScriptNoGCAllowedObjectsCount]):
+        (+[IFCache javaScriptReferencedObjectsCount]):
+        (+[IFCache garbageCollectJavaScriptObjects]):
+	Call through WebCoreJavaScript instead of going directly to kjs::Collector.
+
+        * WebCoreSupport.subproj/IFWebCoreFrame.m:
+        (-[IFWebCoreFrame bridge]): Change to return bridge from the provisional data
+	source if it exists.
+        (-[IFWebCoreFrame committedBridge]): Do what [bridge] used to do, always returning
+	the bridge from the committed data source and never the provisional one.
+
+        * WebView.subproj/IFHTMLView.mm:
+        (-[IFHTMLView provisionalDataSourceChanged:]): Don't store the provisional widget.
+	It's stored in the bridge for the provisional data source.
+        (-[IFHTMLView provisionalDataSourceCommitted:]): Use the bridge method installInFrame:
+	to do most of the work that used to be here. The rest is don in removeFromFrame which
+	is called elsewhere.
+        (-[IFHTMLView mouseUp:]): Use the bridge's mouseUp method.
+        (-[IFHTMLView mouseDown:]): Use the bridge's mouseDown method.
+        (-[IFHTMLView mouseMovedNotification:]): Use the bridge's mouseMoved method.
+        (-[IFHTMLView mouseDragged:]): Use the bridge's mouseDragged method.
+
+        * WebView.subproj/IFHTMLViewPrivate.h: Remove the widget, widgetOwned, and
+	provisionalWidget instance variables, and the _widget and _provisionalWidget methods.
+        * WebView.subproj/IFHTMLViewPrivate.mm:
+        (-[IFHTMLView _reset]): Remove the code that deleted the widget and the provisional widget.
+	This is now handled elsewhere.
+
+        * WebView.subproj/IFDOMNode.mm: Redo to use the copyDOMTree feature of the bridge.
+        * WebView.subproj/IFRenderNode.mm: Redo to use the copyRenderTree feature of the bridge.
+
+        * WebView.subproj/IFRenderNode.h: Use an NSRect instead of four integers
+	(the switch to floating point is OK).
+
+        * WebView.subproj/IFWebDataSourcePrivate.h: Add private _removeFromFrame method.
+        * WebView.subproj/IFWebDataSourcePrivate.mm:
+        (-[IFWebDataSource _removeFromFrame]): Set the controller and location change handler
+	references to nil, and also call [WebCoreBridge removeFromFrame].
+        * WebView.subproj/IFWebFramePrivate.mm:
+        (-[IFWebFramePrivate setDataSource:]): Use _removeFromFrame where we formerly would
+	set the controller and location change handler references to nil.
+
+        * WebCoreSupport.subproj/IFWebCoreBridge.h: Tweak.
+
 2002-07-13  Darin Adler  <darin at apple.com>
 
         * Plugins.subproj/IFNullPluginView.mm: (-[IFNullPluginView dealloc]):
diff --git a/WebKit/ChangeLog-2002-12-03 b/WebKit/ChangeLog-2002-12-03
index 6e2907c..677b9fb 100644
--- a/WebKit/ChangeLog-2002-12-03
+++ b/WebKit/ChangeLog-2002-12-03
@@ -1,3 +1,65 @@
+2002-07-14  Darin Adler  <darin at apple.com>
+
+	Wean WebKit completely from getting at the C++ parts of WebCore.
+	We probably don't need to use C++ at all for WebKit any more.
+
+        * WebKit.pbproj/project.pbxproj: Remove all the header search paths; we don't need any
+	special ones now.
+
+        * WebKitPrefix.h: Remove <config.h>; we don't need it any more.
+
+        * Misc.subproj/IFCache.h: Rename getStatistics to statistics.
+        * Misc.subproj/IFCache.mm:
+        (+[IFCache statistics]):
+        (+[IFCache empty]):
+        (+[IFCache setDisabled:]):
+	Call through WebCoreCache instead of going directly to khtml::Cache.
+        (+[IFCache javaScriptObjectsCount]):
+        (+[IFCache javaScriptInterpretersCount]):
+        (+[IFCache javaScriptNoGCAllowedObjectsCount]):
+        (+[IFCache javaScriptReferencedObjectsCount]):
+        (+[IFCache garbageCollectJavaScriptObjects]):
+	Call through WebCoreJavaScript instead of going directly to kjs::Collector.
+
+        * WebCoreSupport.subproj/IFWebCoreFrame.m:
+        (-[IFWebCoreFrame bridge]): Change to return bridge from the provisional data
+	source if it exists.
+        (-[IFWebCoreFrame committedBridge]): Do what [bridge] used to do, always returning
+	the bridge from the committed data source and never the provisional one.
+
+        * WebView.subproj/IFHTMLView.mm:
+        (-[IFHTMLView provisionalDataSourceChanged:]): Don't store the provisional widget.
+	It's stored in the bridge for the provisional data source.
+        (-[IFHTMLView provisionalDataSourceCommitted:]): Use the bridge method installInFrame:
+	to do most of the work that used to be here. The rest is don in removeFromFrame which
+	is called elsewhere.
+        (-[IFHTMLView mouseUp:]): Use the bridge's mouseUp method.
+        (-[IFHTMLView mouseDown:]): Use the bridge's mouseDown method.
+        (-[IFHTMLView mouseMovedNotification:]): Use the bridge's mouseMoved method.
+        (-[IFHTMLView mouseDragged:]): Use the bridge's mouseDragged method.
+
+        * WebView.subproj/IFHTMLViewPrivate.h: Remove the widget, widgetOwned, and
+	provisionalWidget instance variables, and the _widget and _provisionalWidget methods.
+        * WebView.subproj/IFHTMLViewPrivate.mm:
+        (-[IFHTMLView _reset]): Remove the code that deleted the widget and the provisional widget.
+	This is now handled elsewhere.
+
+        * WebView.subproj/IFDOMNode.mm: Redo to use the copyDOMTree feature of the bridge.
+        * WebView.subproj/IFRenderNode.mm: Redo to use the copyRenderTree feature of the bridge.
+
+        * WebView.subproj/IFRenderNode.h: Use an NSRect instead of four integers
+	(the switch to floating point is OK).
+
+        * WebView.subproj/IFWebDataSourcePrivate.h: Add private _removeFromFrame method.
+        * WebView.subproj/IFWebDataSourcePrivate.mm:
+        (-[IFWebDataSource _removeFromFrame]): Set the controller and location change handler
+	references to nil, and also call [WebCoreBridge removeFromFrame].
+        * WebView.subproj/IFWebFramePrivate.mm:
+        (-[IFWebFramePrivate setDataSource:]): Use _removeFromFrame where we formerly would
+	set the controller and location change handler references to nil.
+
+        * WebCoreSupport.subproj/IFWebCoreBridge.h: Tweak.
+
 2002-07-13  Darin Adler  <darin at apple.com>
 
         * Plugins.subproj/IFNullPluginView.mm: (-[IFNullPluginView dealloc]):
diff --git a/WebKit/Misc.subproj/IFCache.h b/WebKit/Misc.subproj/IFCache.h
index 6aa89ff..2b2ab53 100644
--- a/WebKit/Misc.subproj/IFCache.h
+++ b/WebKit/Misc.subproj/IFCache.h
@@ -12,7 +12,7 @@
 {
 }
 
-+ (NSArray *)getStatistics;
++ (NSArray *)statistics;
 + (void)empty;
 + (void)setDisabled:(BOOL)disabled;
 
diff --git a/WebKit/Misc.subproj/IFCache.mm b/WebKit/Misc.subproj/IFCache.mm
index 432e1cb..ec64f32 100644
--- a/WebKit/Misc.subproj/IFCache.mm
+++ b/WebKit/Misc.subproj/IFCache.mm
@@ -8,71 +8,49 @@
 
 #import "IFCache.h"
 
-#ifndef WEBKIT_INDEPENDENT_OF_WEBCORE
-#import "misc/loader.h"
-#import "kjs/collector.h"
-#endif
+#import <WebCore/WebCoreCache.h>
+#import <WebCore/WebCoreJavaScript.h>
 
 @implementation IFCache
 
-+ (NSArray *)getStatistics
++ (NSArray *)statistics
 {
-    khtml::Cache::Statistics s = khtml::Cache::getStatistics();
-
-    NSMutableDictionary *counts =
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            [NSNumber numberWithInt:s.images.count],@"images",
-            [NSNumber numberWithInt:s.movies.count],@"movies",
-            [NSNumber numberWithInt:s.styleSheets.count],@"style sheets",
-            [NSNumber numberWithInt:s.scripts.count],@"scripts",
-            [NSNumber numberWithInt:s.other.count],@"other",
-            nil];
-    
-    NSMutableDictionary *sizes =
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            [NSNumber numberWithInt:s.images.size],@"images",
-            [NSNumber numberWithInt:s.movies.size],@"movies",
-            [NSNumber numberWithInt:s.styleSheets.size],@"style sheets",
-            [NSNumber numberWithInt:s.scripts.size],@"scripts",
-            [NSNumber numberWithInt:s.other.size],@"other",
-            nil];
-        
-    return [NSArray arrayWithObjects:counts, sizes, nil];
+    return [WebCoreCache statistics];
 }
 
 + (void)empty
 {
-    khtml::Cache::flushAll();
+    [WebCoreCache empty];
 }
 
 + (void)setDisabled:(BOOL)disabled
 {
-    khtml::Cache::setCacheDisabled(disabled);
+    [WebCoreCache setDisabled:disabled];
 }
 
 + (int)javaScriptObjectsCount
 {
-    return KJS::Collector::size();
+    return [WebCoreJavaScript objectCount];
 }
 
 + (int)javaScriptInterpretersCount
 {
-    return KJS::Collector::numInterpreters();
+    return [WebCoreJavaScript interpreterCount];
 }
 
 + (int)javaScriptNoGCAllowedObjectsCount
 {
-    return KJS::Collector::numGCNotAllowedObjects();
+    return [WebCoreJavaScript noGCAllowedObjectCount];
 }
 
 + (int)javaScriptReferencedObjectsCount
 {
-    return KJS::Collector::numReferencedObjects();
+    return [WebCoreJavaScript referencedObjectCount];
 }
 
 + (void)garbageCollectJavaScriptObjects
 {
-    while (KJS::Collector::collect()) { }
+    [WebCoreJavaScript garbageCollect];
 }
 
 @end
diff --git a/WebKit/Misc.subproj/WebCoreStatistics.h b/WebKit/Misc.subproj/WebCoreStatistics.h
index 6aa89ff..2b2ab53 100644
--- a/WebKit/Misc.subproj/WebCoreStatistics.h
+++ b/WebKit/Misc.subproj/WebCoreStatistics.h
@@ -12,7 +12,7 @@
 {
 }
 
-+ (NSArray *)getStatistics;
++ (NSArray *)statistics;
 + (void)empty;
 + (void)setDisabled:(BOOL)disabled;
 
diff --git a/WebKit/Misc.subproj/WebCoreStatistics.m b/WebKit/Misc.subproj/WebCoreStatistics.m
index 432e1cb..ec64f32 100644
--- a/WebKit/Misc.subproj/WebCoreStatistics.m
+++ b/WebKit/Misc.subproj/WebCoreStatistics.m
@@ -8,71 +8,49 @@
 
 #import "IFCache.h"
 
-#ifndef WEBKIT_INDEPENDENT_OF_WEBCORE
-#import "misc/loader.h"
-#import "kjs/collector.h"
-#endif
+#import <WebCore/WebCoreCache.h>
+#import <WebCore/WebCoreJavaScript.h>
 
 @implementation IFCache
 
-+ (NSArray *)getStatistics
++ (NSArray *)statistics
 {
-    khtml::Cache::Statistics s = khtml::Cache::getStatistics();
-
-    NSMutableDictionary *counts =
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            [NSNumber numberWithInt:s.images.count],@"images",
-            [NSNumber numberWithInt:s.movies.count],@"movies",
-            [NSNumber numberWithInt:s.styleSheets.count],@"style sheets",
-            [NSNumber numberWithInt:s.scripts.count],@"scripts",
-            [NSNumber numberWithInt:s.other.count],@"other",
-            nil];
-    
-    NSMutableDictionary *sizes =
-        [NSDictionary dictionaryWithObjectsAndKeys:
-            [NSNumber numberWithInt:s.images.size],@"images",
-            [NSNumber numberWithInt:s.movies.size],@"movies",
-            [NSNumber numberWithInt:s.styleSheets.size],@"style sheets",
-            [NSNumber numberWithInt:s.scripts.size],@"scripts",
-            [NSNumber numberWithInt:s.other.size],@"other",
-            nil];
-        
-    return [NSArray arrayWithObjects:counts, sizes, nil];
+    return [WebCoreCache statistics];
 }
 
 + (void)empty
 {
-    khtml::Cache::flushAll();
+    [WebCoreCache empty];
 }
 
 + (void)setDisabled:(BOOL)disabled
 {
-    khtml::Cache::setCacheDisabled(disabled);
+    [WebCoreCache setDisabled:disabled];
 }
 
 + (int)javaScriptObjectsCount
 {
-    return KJS::Collector::size();
+    return [WebCoreJavaScript objectCount];
 }
 
 + (int)javaScriptInterpretersCount
 {
-    return KJS::Collector::numInterpreters();
+    return [WebCoreJavaScript interpreterCount];
 }
 
 + (int)javaScriptNoGCAllowedObjectsCount
 {
-    return KJS::Collector::numGCNotAllowedObjects();
+    return [WebCoreJavaScript noGCAllowedObjectCount];
 }
 
 + (int)javaScriptReferencedObjectsCount
 {
-    return KJS::Collector::numReferencedObjects();
+    return [WebCoreJavaScript referencedObjectCount];
 }
 
 + (void)garbageCollectJavaScriptObjects
 {
-    while (KJS::Collector::collect()) { }
+    [WebCoreJavaScript garbageCollect];
 }
 
 @end
diff --git a/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.h b/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.h
index 6b2935b..3cf699e 100644
--- a/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.h
+++ b/WebKit/WebCoreSupport.subproj/IFWebCoreBridge.h
@@ -16,7 +16,7 @@
 }
 
 - (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource;
-- (void)setDataSource: (IFWebDataSource *)ds;
+- (void)setDataSource:(IFWebDataSource *)ds;
 
 @end
 
diff --git a/WebKit/WebCoreSupport.subproj/IFWebCoreFrame.m b/WebKit/WebCoreSupport.subproj/IFWebCoreFrame.m
index 878b192..f47b6ae 100644
--- a/WebKit/WebCoreSupport.subproj/IFWebCoreFrame.m
+++ b/WebKit/WebCoreSupport.subproj/IFWebCoreFrame.m
@@ -42,16 +42,16 @@
 
 - (WebCoreBridge *)bridge
 {
+    WebCoreBridge *bridge = [[frame provisionalDataSource] _bridge];
+    if (bridge) {
+        return bridge;
+    }
     return [[frame dataSource] _bridge];
 }
 
-- (KHTMLView *)widget
+- (WebCoreBridge *)committedBridge
 {
-    KHTMLView *widget = [[self HTMLView] _provisionalWidget];
-    if (widget) {
-        return widget;
-    }
-    return [[self HTMLView] _widget];
+    return [[frame dataSource] _bridge];
 }
 
 - (void)loadURL:(NSURL *)URL attributes:(NSDictionary *)attributes flags:(unsigned)flags withParent:(IFWebDataSource *)parent
diff --git a/WebKit/WebCoreSupport.subproj/WebBridge.h b/WebKit/WebCoreSupport.subproj/WebBridge.h
index 6b2935b..3cf699e 100644
--- a/WebKit/WebCoreSupport.subproj/WebBridge.h
+++ b/WebKit/WebCoreSupport.subproj/WebBridge.h
@@ -16,7 +16,7 @@
 }
 
 - (void)receivedData:(NSData *)data withDataSource:(IFWebDataSource *)dataSource;
-- (void)setDataSource: (IFWebDataSource *)ds;
+- (void)setDataSource:(IFWebDataSource *)ds;
 
 @end
 
diff --git a/WebKit/WebCoreSupport.subproj/WebFrameBridge.m b/WebKit/WebCoreSupport.subproj/WebFrameBridge.m
index 878b192..f47b6ae 100644
--- a/WebKit/WebCoreSupport.subproj/WebFrameBridge.m
+++ b/WebKit/WebCoreSupport.subproj/WebFrameBridge.m
@@ -42,16 +42,16 @@
 
 - (WebCoreBridge *)bridge
 {
+    WebCoreBridge *bridge = [[frame provisionalDataSource] _bridge];
+    if (bridge) {
+        return bridge;
+    }
     return [[frame dataSource] _bridge];
 }
 
-- (KHTMLView *)widget
+- (WebCoreBridge *)committedBridge
 {
-    KHTMLView *widget = [[self HTMLView] _provisionalWidget];
-    if (widget) {
-        return widget;
-    }
-    return [[self HTMLView] _widget];
+    return [[frame dataSource] _bridge];
 }
 
 - (void)loadURL:(NSURL *)URL attributes:(NSDictionary *)attributes flags:(unsigned)flags withParent:(IFWebDataSource *)parent
diff --git a/WebKit/WebKit.pbproj/project.pbxproj b/WebKit/WebKit.pbproj/project.pbxproj
index 1fe859c..ee6b562 100644
--- a/WebKit/WebKit.pbproj/project.pbxproj
+++ b/WebKit/WebKit.pbproj/project.pbxproj
@@ -135,7 +135,7 @@
 				FRAMEWORK_SEARCH_PATHS = "\"$(SYSTEM_LIBRARY_DIR)/Frameworks/ApplicationServices.framework/Frameworks\" \"$(SYSTEM_LIBRARY_DIR)/Frameworks/Carbon.framework/Frameworks\"";
 				FRAMEWORK_VERSION = A;
 				GCC_TREAT_WARNINGS_AS_ERRORS = YES;
-				HEADER_SEARCH_PATHS = ".. ../JavaScriptCore ../WebCore/khtml ../WebCore/kwq ../WebCore/kwq/kdecore ../WebCore/kwq/khtml ../WebCore/kwq/kparts ../WebCore/kwq/qt";
+				HEADER_SEARCH_PATHS = "";
 				INSTALL_PATH = "$(SYSTEM_LIBRARY_DIR)/PrivateFrameworks";
 				LIBRARY_SEARCH_PATHS = "";
 				OPTIMIZATION_CFLAGS = "-Os";
diff --git a/WebKit/WebKitPrefix.h b/WebKit/WebKitPrefix.h
index f228924..d51e7f0 100644
--- a/WebKit/WebKitPrefix.h
+++ b/WebKit/WebKitPrefix.h
@@ -1,5 +1,3 @@
-#import <config.h>
-
 #import <stddef.h>
 #import <stdio.h>
 #import <fcntl.h>
diff --git a/WebKit/WebView.subproj/IFDOMNode.mm b/WebKit/WebView.subproj/IFDOMNode.mm
index a9cb8fb..a13b83a 100644
--- a/WebKit/WebView.subproj/IFDOMNode.mm
+++ b/WebKit/WebView.subproj/IFDOMNode.mm
@@ -9,47 +9,49 @@
 #import "IFDOMNode.h"
 
 #import <WebKit/IFWebView.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFHTMLViewPrivate.h>
 
-#ifndef WEBKIT_INDEPENDENT_OF_WEBCORE
-#import <khtmlview.h>
-#import <khtml_part.h>
-#import <xml/dom_docimpl.h>
-#endif
+ at interface WebKitDOMTreeCopier : NSObject <WebCoreDOMTreeCopier>
+ at end
 
 @implementation IFDOMNode
 
-- initWithDOMNode:(DOM::NodeImpl *)node
+- initWithName:(NSString *)n value:(NSString *)v source:(NSString *)s children:(NSArray *)c
 {
-    NSMutableArray *collectChildren;
-    
     [super init];
 
-    collectChildren = [NSMutableArray array];
-
-    name = [node->nodeName().string().getNSString() copy];
-    value = [node->nodeValue().string().getNSString() copy];
-    source = [node->recursive_toHTML(1).getNSString() copy];
-   
-    for (DOM::NodeImpl *child = node->firstChild(); child; child = child->nextSibling())
-        [collectChildren addObject:[[[IFDOMNode alloc] initWithDOMNode: child] autorelease]];
-    
-    children = [collectChildren copy];
+    children = [c copy];
+    name = [n copy];
+    value = [v copy];
+    source = [s copy];
     
     return self;
 }
 
 - initWithWebView:(IFWebView *)view
 {
-    return [self initWithDOMNode:[(IFHTMLView *)[view documentView] _widget]->part()->xmlDocImpl()];
+    WebKitDOMTreeCopier *copier;
+    
+    [self dealloc];
+
+    if (![[view documentView] isMemberOfClass:[IFHTMLView class]]) {
+        return nil;
+    }
+    
+    copier = [[WebKitDOMTreeCopier alloc] init];
+    self = [[[(IFHTMLView *)[view documentView] _bridge] copyDOMTree:copier] retain];
+    [copier release];
+    
+    return self;
 }
 
 - (void)dealloc
 {
+    [children release];
     [name release];
     [value release];
     [source release];
-    [children release];
     
     [super dealloc];
 }
@@ -75,3 +77,12 @@
 }
 
 @end
+
+ at implementation WebKitDOMTreeCopier
+
+- (NSObject *)nodeWithName:(NSString *)n value:(NSString *)v source:(NSString *)s children:(NSArray *)c
+{
+    return [[[IFDOMNode alloc] initWithName:n value:v source:s children:c] autorelease];
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/IFHTMLView.mm b/WebKit/WebView.subproj/IFHTMLView.mm
index 49679dd..787c7b8 100644
--- a/WebKit/WebView.subproj/IFHTMLView.mm
+++ b/WebKit/WebView.subproj/IFHTMLView.mm
@@ -3,6 +3,8 @@
 	Copyright 2002, Apple, Inc. All rights reserved.
 */
 
+#import <WebKit/IFHTMLView.h>
+
 #import <WebKit/IFDynamicScrollBarsView.h>
 #import <WebKit/IFException.h>
 #import <WebKit/IFHTMLViewPrivate.h>
@@ -15,14 +17,9 @@
 #import <WebKit/IFWebViewPrivate.h>
 #import <WebKit/WebKitDebug.h>
 
-// Needed for the mouse move notification.
+// Needed for the mouse moved notification.
 #import <AppKit/NSResponder_Private.h>
 
-#ifndef WEBKIT_INDEPENDENT_OF_WEBCORE
-#import <khtmlview.h>
-#import <rendering/render_frames.h>
-#endif
-
 @implementation IFHTMLView
 
 - initWithFrame: (NSRect) frame
@@ -124,7 +121,7 @@
 // the data source is changed.
 - (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource 
 {
-    _private->provisionalWidget = [[dataSource _bridge]
+    [[dataSource _bridge]
         createKHTMLViewWithNSView:[[[dataSource webFrame] webView] documentView]
 	width:(int)[self frame].size.width height:(int)[self frame].size.height
         marginWidth:[[[dataSource webFrame] webView] _marginWidth]
@@ -133,22 +130,7 @@
 
 - (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource 
 {
-    if (_private->widgetOwned) {
-        delete _private->widget;
-    }
-
-    _private->widget = _private->provisionalWidget;
-    _private->widgetOwned = YES;
-    _private->provisionalWidget = 0;
-
-    _private->widget->setView([[self _IF_parentWebView] frameScrollView]);
-
-    KHTMLRenderPart *renderPart = [[[self _bridge] frame] renderPart];
-    if (renderPart) {
-        // Setting the widget will delete the previous KHTMLView associated with the frame.
-        _private->widgetOwned = NO;
-        renderPart->setWidget(_private->widget);
-    }
+    [[self _bridge] installInFrame:[[self _IF_parentWebView] frameScrollView]];
 }
 
 - (void)dataSourceUpdated:(IFWebDataSource *)dataSource
@@ -378,114 +360,30 @@
         [[NSNotificationCenter defaultCenter] removeObserver: self name: NSMouseMovedNotification object: nil];
 }
 
-
-- (void)_addModifiers:(unsigned)modifiers toState:(int *)state
-{
-    if (modifiers & NSControlKeyMask)
-        *state |= Qt::ControlButton;
-    if (modifiers & NSShiftKeyMask)
-        *state |= Qt::ShiftButton;
-    if (modifiers & NSAlternateKeyMask)
-        *state |= Qt::AltButton;
-    // Mapping command to meta is slightly questionable
-    if (modifiers & NSCommandKeyMask)
-        *state |= Qt::MetaButton;
-}
-
 - (void)mouseUp: (NSEvent *)event
 {
-    int button, state;
-     
-    if ([event type] == NSLeftMouseUp){
-        button = Qt::LeftButton;
-        state = Qt::LeftButton;
-    }
-    else if ([event type] == NSRightMouseUp){
-        button = Qt::RightButton;
-        state = Qt::RightButton;
-    }
-    else if ([event type] == NSOtherMouseUp){
-        button = Qt::MidButton;
-        state = Qt::MidButton;
-    }
-    else {
-        [NSException raise:IFRuntimeError format:@"IFWebView::mouseUp: unknown button type"];
-        button = 0; state = 0; // Shutup the compiler.
-    }
-    NSPoint p = [event locationInWindow];
-    
-    [self _addModifiers:[event modifierFlags] toState:&state];
-
-    QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
-    KHTMLView *widget = _private->widget;
-    if (widget) {
-        widget->viewportMouseReleaseEvent(&kEvent);
-    }
+    [[self _bridge] mouseUp:event];
 }
 
 - (void)mouseDown: (NSEvent *)event
 {
-    int button, state;
-     
-    if ([event type] == NSLeftMouseDown){
-        button = Qt::LeftButton;
-        state = Qt::LeftButton;
-    }
-    else if ([event type] == NSRightMouseDown){
-        button = Qt::RightButton;
-        state = Qt::RightButton;
-    }
-    else if ([event type] == NSOtherMouseDown){
-        button = Qt::MidButton;
-        state = Qt::MidButton;
-    }
-    else {
-        [NSException raise:IFRuntimeError format:@"IFWebView::mouseDown: unknown button type"];
-        button = 0; state = 0; // Shutup the compiler.
-    }
-    NSPoint p = [event locationInWindow];
-    
-    [self _addModifiers:[event modifierFlags] toState:&state];
-
-    QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
-    KHTMLView *widget = _private->widget;
-    if (widget) {
-        widget->viewportMousePressEvent(&kEvent);
-    }
+    [[self _bridge] mouseDown:event];
 }
 
-- (void)mouseMovedNotification: (NSNotification *)notification
+- (void)mouseMovedNotification:(NSNotification *)notification
 {
-    NSEvent *event = [(NSDictionary *)[notification userInfo] objectForKey: @"NSEvent"];
-    NSPoint p = [event locationInWindow];
-    NSWindow *thisWindow = [self window];
-    
-    // Only act on the mouse move event if it's inside this view (and
-    // not inside a subview)
-    if ([thisWindow isMainWindow] &&
-        [[[notification userInfo] objectForKey: @"NSEvent"] window] == thisWindow &&
-        [[thisWindow contentView] hitTest:p] == self) {
-	int state = 0;
-	[self _addModifiers:[event modifierFlags] toState:&state];
-        QMouseEvent kEvent(QEvent::MouseMove, QPoint((int)p.x, (int)p.y), 0, state);
-        KHTMLView *widget = _private->widget;
-        if (widget) {
-            widget->viewportMouseMoveEvent(&kEvent);
-        }
+    // Only act on the mouse move event if it's inside this view (and not inside a subview).
+    NSEvent *event = [[notification userInfo] objectForKey:@"NSEvent"];
+    if ([event window] == [self window] && [[self window] isMainWindow]
+            && [[[self window] contentView] hitTest:[event locationInWindow]] == self) {
+        [[self _bridge] mouseMoved:event];
     }
 }
 
-- (void)mouseDragged: (NSEvent *)event
+- (void)mouseDragged:(NSEvent *)event
 {
-    NSPoint p = [event locationInWindow];
-    
-    [self autoscroll: event];
-    
-    QMouseEvent kEvent(QEvent::MouseMove, QPoint((int)p.x, (int)p.y), Qt::LeftButton, Qt::LeftButton);
-    KHTMLView *widget = _private->widget;
-    if (widget) {
-        widget->viewportMouseMoveEvent(&kEvent);
-    }
+    [self autoscroll:event];
+    [[self _bridge] mouseDragged:event];
 }
 
 #if 0
diff --git a/WebKit/WebView.subproj/IFHTMLViewPrivate.h b/WebKit/WebView.subproj/IFHTMLViewPrivate.h
index d477faf..9771538 100644
--- a/WebKit/WebView.subproj/IFHTMLViewPrivate.h
+++ b/WebKit/WebView.subproj/IFHTMLViewPrivate.h
@@ -8,20 +8,11 @@
 
 #import <WebKit/IFHTMLView.h>
 
-#ifdef __cplusplus
-class KHTMLView;
-#else
- at class KHTMLView;
-#endif
-
 @class IFWebCoreBridge;
 
 @interface IFHTMLViewPrivate : NSObject
 {
     IFWebController *controller;
-    KHTMLView *widget;
-    BOOL widgetOwned;
-    KHTMLView *provisionalWidget;
     BOOL needsLayout;
     BOOL needsToApplyStyles;
     BOOL canDragTo;
@@ -30,16 +21,11 @@ class KHTMLView;
     BOOL liveAllowsScrolling;
     BOOL inWindow;
 }
-
 @end
 
 @interface IFHTMLView (IFPrivate)
 - (void)_reset;
-
 - (void)_setController: (IFWebController *)controller;
-
-- (KHTMLView *)_widget;
-- (KHTMLView *)_provisionalWidget;
 - (IFWebCoreBridge *)_bridge;
 - (void)_adjustFrames;
 @end
diff --git a/WebKit/WebView.subproj/IFHTMLViewPrivate.mm b/WebKit/WebView.subproj/IFHTMLViewPrivate.mm
index 7628827..2ed2b65 100644
--- a/WebKit/WebView.subproj/IFHTMLViewPrivate.mm
+++ b/WebKit/WebView.subproj/IFHTMLViewPrivate.mm
@@ -5,9 +5,10 @@
         in WebCore.  Instances of this class are referenced by _private in 
         NSWebPageView.
 */
-#import <WebKit/WebKitDebug.h>
 
 #import <WebKit/IFHTMLViewPrivate.h>
+
+#import <WebKit/WebKitDebug.h>
 #import <WebKit/IFImageRenderer.h>
 #import <WebKit/IFNSViewExtras.h>
 #import <WebKit/IFPluginView.h>
@@ -16,10 +17,6 @@
 #import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/IFWebViewPrivate.h>
 
-#ifndef WEBKIT_INDEPENDENT_OF_WEBCORE
-#import <khtmlview.h>
-#endif
-
 @interface NSView (IFHTMLViewPrivate)
 - (void)_IF_stopIfPluginView;
 @end
@@ -52,7 +49,7 @@
     // the frame origins during drawing!  So we have to 
     // layout and do a draw with rendering disabled to
     // correclty adjust the frames.
-    [[self _bridge] adjustFrames: [self frame]];
+    [[self _bridge] adjustFrames:[self frame]];
 }
 
 
@@ -62,37 +59,20 @@
     [subviews makeObjectsPerformSelector:@selector(_IF_stopIfPluginView)];
     [subviews release];
 
-    [IFImageRenderer stopAnimationsInView: self];
-    
-    delete _private->provisionalWidget;
-    _private->provisionalWidget = 0;
-    if (_private->widgetOwned)
-        delete _private->widget;
-    _private->widget = 0;
-    _private->widgetOwned = NO;
+    [IFImageRenderer stopAnimationsInView:self];
 }
 
-- (void)_setController: (IFWebController *)controller
+- (void)_setController:(IFWebController *)controller
 {
     // Not retained; the controller owns the view.
     _private->controller = controller;    
 }
 
-- (KHTMLView *)_widget
-{
-    return _private->widget;    
-}
-
-- (KHTMLView *)_provisionalWidget
-{
-    return _private->provisionalWidget;    
-}
-
 // Required so view can access the part's selection.
 - (IFWebCoreBridge *)_bridge
 {
     IFWebView *webView = [self _IF_parentWebView];
-    IFWebFrame *webFrame = [[webView _controller] frameForView: webView];
+    IFWebFrame *webFrame = [[webView _controller] frameForView:webView];
     return [[webFrame dataSource] _bridge];
 }
 
diff --git a/WebKit/WebView.subproj/IFRenderNode.h b/WebKit/WebView.subproj/IFRenderNode.h
index 2c64132..d1f22f4 100644
--- a/WebKit/WebView.subproj/IFRenderNode.h
+++ b/WebKit/WebView.subproj/IFRenderNode.h
@@ -13,19 +13,17 @@
 @interface IFRenderNode : NSObject
 {
     NSArray *children;
-    int x, y;
-    int width;
-    int height;
     NSString *name;
+    NSRect rect;
 }
 
 - initWithWebView:(IFWebView *)view;
 
 - (NSArray *)children;
 
+- (NSString *)name;
 - (NSString *)positionString;
 - (NSString *)widthString;
 - (NSString *)heightString;
-- (NSString *)name;
 
 @end
diff --git a/WebKit/WebView.subproj/IFRenderNode.mm b/WebKit/WebView.subproj/IFRenderNode.mm
index 1aa61ae..e77046e 100644
--- a/WebKit/WebView.subproj/IFRenderNode.mm
+++ b/WebKit/WebView.subproj/IFRenderNode.mm
@@ -8,65 +8,62 @@
 
 #import "IFRenderNode.h"
 
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFWebView.h>
 #import <WebKit/IFHTMLViewPrivate.h>
 
-#ifndef WEBKIT_INDEPENDENT_OF_WEBCORE
-
-#import <khtmlview.h>
-#import <khtml_part.h>
-#import <xml/dom_docimpl.h>
-#import <rendering/render_frames.h>
-
-#endif
+ at interface WebKitRenderTreeCopier : NSObject <WebCoreRenderTreeCopier>
+ at end
 
 @implementation IFRenderNode
 
-- initWithRenderObject:(khtml::RenderObject *)node
+- initWithName:(NSString *)n rect:(NSRect)r view:(NSView *)view children:(NSArray *)c
 {
     NSMutableArray *collectChildren;
     
     [super init];
 
-    collectChildren = [NSMutableArray array];
+    collectChildren = [c mutableCopy];
 
-    name = [[NSString stringWithCString:node->renderName()] retain];
-    x = node->xPos();
-    y = node->yPos();
-    width = node->width();
-    height = node->height();
+    name = [n retain];
+    rect = r;
 
-    for (khtml::RenderObject *child = node->firstChild(); child; child = child->nextSibling()) {
-        [collectChildren addObject:[[[IFRenderNode alloc] initWithRenderObject: child] autorelease]];
+    if ([view isKindOfClass:[NSScrollView class]]) {
+        NSScrollView *scrollView = (NSScrollView *)view;
+        view = [scrollView superview];
     }
-
-    khtml::RenderPart *part = dynamic_cast<khtml::RenderPart *>(node);
-    if (part) {
-        NSView *view = part->widget()->getView();
-        if ([view isKindOfClass:[NSScrollView class]]) {
-            NSScrollView *scrollView = (NSScrollView *)view;
-            view = [scrollView superview];
-        }
-        if ([view isKindOfClass:[IFWebView class]]) {
-            IFWebView *webView = (IFWebView *)view;
-            [collectChildren addObject:[[[IFRenderNode alloc] initWithWebView:webView] autorelease]];
-        }
+    if ([view isKindOfClass:[IFWebView class]]) {
+        IFWebView *webView = (IFWebView *)view;
+        [collectChildren addObject:[[[IFRenderNode alloc] initWithWebView:webView] autorelease]];
     }
     
     children = [collectChildren copy];
+    [collectChildren release];
     
     return self;
 }
 
 - initWithWebView:(IFWebView *)view
 {
-    return [self initWithRenderObject:[(IFHTMLView *)[view documentView] _widget]->part()->xmlDocImpl()->renderer()];
+    WebKitRenderTreeCopier *copier;
+    
+    [self dealloc];
+
+    if (![[view documentView] isMemberOfClass:[IFHTMLView class]]) {
+        return nil;
+    }
+    
+    copier = [[WebKitRenderTreeCopier alloc] init];
+    self = [[[(IFHTMLView *)[view documentView] _bridge] copyRenderTree:copier] retain];
+    [copier release];
+    
+    return self;
 }
 
 - (void)dealloc
 {
-    [name release];
     [children release];
+    [name release];
     [super dealloc];
 }
 
@@ -82,17 +79,26 @@
 
 - (NSString *)positionString
 {
-    return [NSString stringWithFormat:@"(%d, %d)", x, y];
+    return [NSString stringWithFormat:@"(%.0f, %.0f)", rect.origin.x, rect.origin.y];
 }
 
 - (NSString *)widthString
 {
-    return [NSString stringWithFormat:@"%d", width];
+    return [NSString stringWithFormat:@"%.0f", rect.size.width];
 }
 
 - (NSString *)heightString
 {
-    return [NSString stringWithFormat:@"%d", height];
+    return [NSString stringWithFormat:@"%.0f", rect.size.height];
+}
+
+ at end
+
+ at implementation WebKitRenderTreeCopier
+
+- (NSObject *)nodeWithName:(NSString *)name rect:(NSRect)rect view:(NSView *)view children:(NSArray *)children
+{
+    return [[[IFRenderNode alloc] initWithName:name rect:rect view:view children:children] autorelease];
 }
 
 @end
diff --git a/WebKit/WebView.subproj/IFWebControllerPrivate.mm b/WebKit/WebView.subproj/IFWebControllerPrivate.mm
index 08822ea..be66e24 100644
--- a/WebKit/WebView.subproj/IFWebControllerPrivate.mm
+++ b/WebKit/WebView.subproj/IFWebControllerPrivate.mm
@@ -127,8 +127,6 @@
 
     [[self resourceProgressHandler] receivedError: error forResourceHandle: resourceHandle partialProgress: progress fromDataSource: dataSource];
 
-    WEBKIT_ASSERT (frame != nil);
-
     [dataSource _addError: error forResource:
         (resourceHandle != nil ? [[resourceHandle url] absoluteString] : [[error failingURL] absoluteString])];
     
@@ -142,8 +140,6 @@
 
     [[self resourceProgressHandler] receivedError: error forResourceHandle: resourceHandle partialProgress: progress fromDataSource: dataSource];
     
-    WEBKIT_ASSERT (frame != nil);
-
     [dataSource _setPrimaryLoadComplete: YES];
 
     [dataSource _setMainDocumentError: error];
diff --git a/WebKit/WebView.subproj/IFWebDataSourcePrivate.h b/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
index 8d82843..65f2d8b 100644
--- a/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/IFWebDataSourcePrivate.h
@@ -97,4 +97,5 @@
 - (void)_addError: (IFError *)error forResource: (NSString *)resourceDescription;
 + (NSMutableDictionary *)_repTypes;
 + (BOOL)_canShowMIMEType:(NSString *)MIMEType;
+- (void)_removeFromFrame;
 @end
diff --git a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
index 3766850..46c82e6 100644
--- a/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebDataSourcePrivate.mm
@@ -389,4 +389,11 @@
     return [[self _repTypes] _IF_objectForMIMEType:MIMEType] != nil;
 }
 
+- (void)_removeFromFrame
+{
+    [[self _bridge] removeFromFrame];
+    [self _setController:nil];
+    [self _setLocationChangeHandler:nil];
+}
+
 @end
diff --git a/WebKit/WebView.subproj/IFWebFramePrivate.mm b/WebKit/WebView.subproj/IFWebFramePrivate.mm
index ec6333d..24cd672 100644
--- a/WebKit/WebView.subproj/IFWebFramePrivate.mm
+++ b/WebKit/WebView.subproj/IFWebFramePrivate.mm
@@ -70,8 +70,7 @@ static const char * const stateNames[6] = {
 - (void)setDataSource: (IFWebDataSource *)d
 {
     if (dataSource != d) {
-        [dataSource _setController: nil];
-        [dataSource _setLocationChangeHandler: nil];
+        [dataSource _removeFromFrame];
         [dataSource autorelease];
         dataSource = [d retain];
     }
diff --git a/WebKit/WebView.subproj/WebControllerPrivate.m b/WebKit/WebView.subproj/WebControllerPrivate.m
index 08822ea..be66e24 100644
--- a/WebKit/WebView.subproj/WebControllerPrivate.m
+++ b/WebKit/WebView.subproj/WebControllerPrivate.m
@@ -127,8 +127,6 @@
 
     [[self resourceProgressHandler] receivedError: error forResourceHandle: resourceHandle partialProgress: progress fromDataSource: dataSource];
 
-    WEBKIT_ASSERT (frame != nil);
-
     [dataSource _addError: error forResource:
         (resourceHandle != nil ? [[resourceHandle url] absoluteString] : [[error failingURL] absoluteString])];
     
@@ -142,8 +140,6 @@
 
     [[self resourceProgressHandler] receivedError: error forResourceHandle: resourceHandle partialProgress: progress fromDataSource: dataSource];
     
-    WEBKIT_ASSERT (frame != nil);
-
     [dataSource _setPrimaryLoadComplete: YES];
 
     [dataSource _setMainDocumentError: error];
diff --git a/WebKit/WebView.subproj/WebDOMNode.m b/WebKit/WebView.subproj/WebDOMNode.m
index a9cb8fb..a13b83a 100644
--- a/WebKit/WebView.subproj/WebDOMNode.m
+++ b/WebKit/WebView.subproj/WebDOMNode.m
@@ -9,47 +9,49 @@
 #import "IFDOMNode.h"
 
 #import <WebKit/IFWebView.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFHTMLViewPrivate.h>
 
-#ifndef WEBKIT_INDEPENDENT_OF_WEBCORE
-#import <khtmlview.h>
-#import <khtml_part.h>
-#import <xml/dom_docimpl.h>
-#endif
+ at interface WebKitDOMTreeCopier : NSObject <WebCoreDOMTreeCopier>
+ at end
 
 @implementation IFDOMNode
 
-- initWithDOMNode:(DOM::NodeImpl *)node
+- initWithName:(NSString *)n value:(NSString *)v source:(NSString *)s children:(NSArray *)c
 {
-    NSMutableArray *collectChildren;
-    
     [super init];
 
-    collectChildren = [NSMutableArray array];
-
-    name = [node->nodeName().string().getNSString() copy];
-    value = [node->nodeValue().string().getNSString() copy];
-    source = [node->recursive_toHTML(1).getNSString() copy];
-   
-    for (DOM::NodeImpl *child = node->firstChild(); child; child = child->nextSibling())
-        [collectChildren addObject:[[[IFDOMNode alloc] initWithDOMNode: child] autorelease]];
-    
-    children = [collectChildren copy];
+    children = [c copy];
+    name = [n copy];
+    value = [v copy];
+    source = [s copy];
     
     return self;
 }
 
 - initWithWebView:(IFWebView *)view
 {
-    return [self initWithDOMNode:[(IFHTMLView *)[view documentView] _widget]->part()->xmlDocImpl()];
+    WebKitDOMTreeCopier *copier;
+    
+    [self dealloc];
+
+    if (![[view documentView] isMemberOfClass:[IFHTMLView class]]) {
+        return nil;
+    }
+    
+    copier = [[WebKitDOMTreeCopier alloc] init];
+    self = [[[(IFHTMLView *)[view documentView] _bridge] copyDOMTree:copier] retain];
+    [copier release];
+    
+    return self;
 }
 
 - (void)dealloc
 {
+    [children release];
     [name release];
     [value release];
     [source release];
-    [children release];
     
     [super dealloc];
 }
@@ -75,3 +77,12 @@
 }
 
 @end
+
+ at implementation WebKitDOMTreeCopier
+
+- (NSObject *)nodeWithName:(NSString *)n value:(NSString *)v source:(NSString *)s children:(NSArray *)c
+{
+    return [[[IFDOMNode alloc] initWithName:n value:v source:s children:c] autorelease];
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.h b/WebKit/WebView.subproj/WebDataSourcePrivate.h
index 8d82843..65f2d8b 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.h
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.h
@@ -97,4 +97,5 @@
 - (void)_addError: (IFError *)error forResource: (NSString *)resourceDescription;
 + (NSMutableDictionary *)_repTypes;
 + (BOOL)_canShowMIMEType:(NSString *)MIMEType;
+- (void)_removeFromFrame;
 @end
diff --git a/WebKit/WebView.subproj/WebDataSourcePrivate.m b/WebKit/WebView.subproj/WebDataSourcePrivate.m
index 3766850..46c82e6 100644
--- a/WebKit/WebView.subproj/WebDataSourcePrivate.m
+++ b/WebKit/WebView.subproj/WebDataSourcePrivate.m
@@ -389,4 +389,11 @@
     return [[self _repTypes] _IF_objectForMIMEType:MIMEType] != nil;
 }
 
+- (void)_removeFromFrame
+{
+    [[self _bridge] removeFromFrame];
+    [self _setController:nil];
+    [self _setLocationChangeHandler:nil];
+}
+
 @end
diff --git a/WebKit/WebView.subproj/WebDebugDOMNode.m b/WebKit/WebView.subproj/WebDebugDOMNode.m
index a9cb8fb..a13b83a 100644
--- a/WebKit/WebView.subproj/WebDebugDOMNode.m
+++ b/WebKit/WebView.subproj/WebDebugDOMNode.m
@@ -9,47 +9,49 @@
 #import "IFDOMNode.h"
 
 #import <WebKit/IFWebView.h>
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFHTMLViewPrivate.h>
 
-#ifndef WEBKIT_INDEPENDENT_OF_WEBCORE
-#import <khtmlview.h>
-#import <khtml_part.h>
-#import <xml/dom_docimpl.h>
-#endif
+ at interface WebKitDOMTreeCopier : NSObject <WebCoreDOMTreeCopier>
+ at end
 
 @implementation IFDOMNode
 
-- initWithDOMNode:(DOM::NodeImpl *)node
+- initWithName:(NSString *)n value:(NSString *)v source:(NSString *)s children:(NSArray *)c
 {
-    NSMutableArray *collectChildren;
-    
     [super init];
 
-    collectChildren = [NSMutableArray array];
-
-    name = [node->nodeName().string().getNSString() copy];
-    value = [node->nodeValue().string().getNSString() copy];
-    source = [node->recursive_toHTML(1).getNSString() copy];
-   
-    for (DOM::NodeImpl *child = node->firstChild(); child; child = child->nextSibling())
-        [collectChildren addObject:[[[IFDOMNode alloc] initWithDOMNode: child] autorelease]];
-    
-    children = [collectChildren copy];
+    children = [c copy];
+    name = [n copy];
+    value = [v copy];
+    source = [s copy];
     
     return self;
 }
 
 - initWithWebView:(IFWebView *)view
 {
-    return [self initWithDOMNode:[(IFHTMLView *)[view documentView] _widget]->part()->xmlDocImpl()];
+    WebKitDOMTreeCopier *copier;
+    
+    [self dealloc];
+
+    if (![[view documentView] isMemberOfClass:[IFHTMLView class]]) {
+        return nil;
+    }
+    
+    copier = [[WebKitDOMTreeCopier alloc] init];
+    self = [[[(IFHTMLView *)[view documentView] _bridge] copyDOMTree:copier] retain];
+    [copier release];
+    
+    return self;
 }
 
 - (void)dealloc
 {
+    [children release];
     [name release];
     [value release];
     [source release];
-    [children release];
     
     [super dealloc];
 }
@@ -75,3 +77,12 @@
 }
 
 @end
+
+ at implementation WebKitDOMTreeCopier
+
+- (NSObject *)nodeWithName:(NSString *)n value:(NSString *)v source:(NSString *)s children:(NSArray *)c
+{
+    return [[[IFDOMNode alloc] initWithName:n value:v source:s children:c] autorelease];
+}
+
+ at end
diff --git a/WebKit/WebView.subproj/WebFramePrivate.m b/WebKit/WebView.subproj/WebFramePrivate.m
index ec6333d..24cd672 100644
--- a/WebKit/WebView.subproj/WebFramePrivate.m
+++ b/WebKit/WebView.subproj/WebFramePrivate.m
@@ -70,8 +70,7 @@ static const char * const stateNames[6] = {
 - (void)setDataSource: (IFWebDataSource *)d
 {
     if (dataSource != d) {
-        [dataSource _setController: nil];
-        [dataSource _setLocationChangeHandler: nil];
+        [dataSource _removeFromFrame];
         [dataSource autorelease];
         dataSource = [d retain];
     }
diff --git a/WebKit/WebView.subproj/WebHTMLView.m b/WebKit/WebView.subproj/WebHTMLView.m
index 49679dd..787c7b8 100644
--- a/WebKit/WebView.subproj/WebHTMLView.m
+++ b/WebKit/WebView.subproj/WebHTMLView.m
@@ -3,6 +3,8 @@
 	Copyright 2002, Apple, Inc. All rights reserved.
 */
 
+#import <WebKit/IFHTMLView.h>
+
 #import <WebKit/IFDynamicScrollBarsView.h>
 #import <WebKit/IFException.h>
 #import <WebKit/IFHTMLViewPrivate.h>
@@ -15,14 +17,9 @@
 #import <WebKit/IFWebViewPrivate.h>
 #import <WebKit/WebKitDebug.h>
 
-// Needed for the mouse move notification.
+// Needed for the mouse moved notification.
 #import <AppKit/NSResponder_Private.h>
 
-#ifndef WEBKIT_INDEPENDENT_OF_WEBCORE
-#import <khtmlview.h>
-#import <rendering/render_frames.h>
-#endif
-
 @implementation IFHTMLView
 
 - initWithFrame: (NSRect) frame
@@ -124,7 +121,7 @@
 // the data source is changed.
 - (void)provisionalDataSourceChanged:(IFWebDataSource *)dataSource 
 {
-    _private->provisionalWidget = [[dataSource _bridge]
+    [[dataSource _bridge]
         createKHTMLViewWithNSView:[[[dataSource webFrame] webView] documentView]
 	width:(int)[self frame].size.width height:(int)[self frame].size.height
         marginWidth:[[[dataSource webFrame] webView] _marginWidth]
@@ -133,22 +130,7 @@
 
 - (void)provisionalDataSourceCommitted:(IFWebDataSource *)dataSource 
 {
-    if (_private->widgetOwned) {
-        delete _private->widget;
-    }
-
-    _private->widget = _private->provisionalWidget;
-    _private->widgetOwned = YES;
-    _private->provisionalWidget = 0;
-
-    _private->widget->setView([[self _IF_parentWebView] frameScrollView]);
-
-    KHTMLRenderPart *renderPart = [[[self _bridge] frame] renderPart];
-    if (renderPart) {
-        // Setting the widget will delete the previous KHTMLView associated with the frame.
-        _private->widgetOwned = NO;
-        renderPart->setWidget(_private->widget);
-    }
+    [[self _bridge] installInFrame:[[self _IF_parentWebView] frameScrollView]];
 }
 
 - (void)dataSourceUpdated:(IFWebDataSource *)dataSource
@@ -378,114 +360,30 @@
         [[NSNotificationCenter defaultCenter] removeObserver: self name: NSMouseMovedNotification object: nil];
 }
 
-
-- (void)_addModifiers:(unsigned)modifiers toState:(int *)state
-{
-    if (modifiers & NSControlKeyMask)
-        *state |= Qt::ControlButton;
-    if (modifiers & NSShiftKeyMask)
-        *state |= Qt::ShiftButton;
-    if (modifiers & NSAlternateKeyMask)
-        *state |= Qt::AltButton;
-    // Mapping command to meta is slightly questionable
-    if (modifiers & NSCommandKeyMask)
-        *state |= Qt::MetaButton;
-}
-
 - (void)mouseUp: (NSEvent *)event
 {
-    int button, state;
-     
-    if ([event type] == NSLeftMouseUp){
-        button = Qt::LeftButton;
-        state = Qt::LeftButton;
-    }
-    else if ([event type] == NSRightMouseUp){
-        button = Qt::RightButton;
-        state = Qt::RightButton;
-    }
-    else if ([event type] == NSOtherMouseUp){
-        button = Qt::MidButton;
-        state = Qt::MidButton;
-    }
-    else {
-        [NSException raise:IFRuntimeError format:@"IFWebView::mouseUp: unknown button type"];
-        button = 0; state = 0; // Shutup the compiler.
-    }
-    NSPoint p = [event locationInWindow];
-    
-    [self _addModifiers:[event modifierFlags] toState:&state];
-
-    QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
-    KHTMLView *widget = _private->widget;
-    if (widget) {
-        widget->viewportMouseReleaseEvent(&kEvent);
-    }
+    [[self _bridge] mouseUp:event];
 }
 
 - (void)mouseDown: (NSEvent *)event
 {
-    int button, state;
-     
-    if ([event type] == NSLeftMouseDown){
-        button = Qt::LeftButton;
-        state = Qt::LeftButton;
-    }
-    else if ([event type] == NSRightMouseDown){
-        button = Qt::RightButton;
-        state = Qt::RightButton;
-    }
-    else if ([event type] == NSOtherMouseDown){
-        button = Qt::MidButton;
-        state = Qt::MidButton;
-    }
-    else {
-        [NSException raise:IFRuntimeError format:@"IFWebView::mouseDown: unknown button type"];
-        button = 0; state = 0; // Shutup the compiler.
-    }
-    NSPoint p = [event locationInWindow];
-    
-    [self _addModifiers:[event modifierFlags] toState:&state];
-
-    QMouseEvent kEvent(QEvent::MouseButtonPress, QPoint((int)p.x, (int)p.y), button, state);
-    KHTMLView *widget = _private->widget;
-    if (widget) {
-        widget->viewportMousePressEvent(&kEvent);
-    }
+    [[self _bridge] mouseDown:event];
 }
 
-- (void)mouseMovedNotification: (NSNotification *)notification
+- (void)mouseMovedNotification:(NSNotification *)notification
 {
-    NSEvent *event = [(NSDictionary *)[notification userInfo] objectForKey: @"NSEvent"];
-    NSPoint p = [event locationInWindow];
-    NSWindow *thisWindow = [self window];
-    
-    // Only act on the mouse move event if it's inside this view (and
-    // not inside a subview)
-    if ([thisWindow isMainWindow] &&
-        [[[notification userInfo] objectForKey: @"NSEvent"] window] == thisWindow &&
-        [[thisWindow contentView] hitTest:p] == self) {
-	int state = 0;
-	[self _addModifiers:[event modifierFlags] toState:&state];
-        QMouseEvent kEvent(QEvent::MouseMove, QPoint((int)p.x, (int)p.y), 0, state);
-        KHTMLView *widget = _private->widget;
-        if (widget) {
-            widget->viewportMouseMoveEvent(&kEvent);
-        }
+    // Only act on the mouse move event if it's inside this view (and not inside a subview).
+    NSEvent *event = [[notification userInfo] objectForKey:@"NSEvent"];
+    if ([event window] == [self window] && [[self window] isMainWindow]
+            && [[[self window] contentView] hitTest:[event locationInWindow]] == self) {
+        [[self _bridge] mouseMoved:event];
     }
 }
 
-- (void)mouseDragged: (NSEvent *)event
+- (void)mouseDragged:(NSEvent *)event
 {
-    NSPoint p = [event locationInWindow];
-    
-    [self autoscroll: event];
-    
-    QMouseEvent kEvent(QEvent::MouseMove, QPoint((int)p.x, (int)p.y), Qt::LeftButton, Qt::LeftButton);
-    KHTMLView *widget = _private->widget;
-    if (widget) {
-        widget->viewportMouseMoveEvent(&kEvent);
-    }
+    [self autoscroll:event];
+    [[self _bridge] mouseDragged:event];
 }
 
 #if 0
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.h b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
index d477faf..9771538 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.h
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.h
@@ -8,20 +8,11 @@
 
 #import <WebKit/IFHTMLView.h>
 
-#ifdef __cplusplus
-class KHTMLView;
-#else
- at class KHTMLView;
-#endif
-
 @class IFWebCoreBridge;
 
 @interface IFHTMLViewPrivate : NSObject
 {
     IFWebController *controller;
-    KHTMLView *widget;
-    BOOL widgetOwned;
-    KHTMLView *provisionalWidget;
     BOOL needsLayout;
     BOOL needsToApplyStyles;
     BOOL canDragTo;
@@ -30,16 +21,11 @@ class KHTMLView;
     BOOL liveAllowsScrolling;
     BOOL inWindow;
 }
-
 @end
 
 @interface IFHTMLView (IFPrivate)
 - (void)_reset;
-
 - (void)_setController: (IFWebController *)controller;
-
-- (KHTMLView *)_widget;
-- (KHTMLView *)_provisionalWidget;
 - (IFWebCoreBridge *)_bridge;
 - (void)_adjustFrames;
 @end
diff --git a/WebKit/WebView.subproj/WebHTMLViewPrivate.m b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
index 7628827..2ed2b65 100644
--- a/WebKit/WebView.subproj/WebHTMLViewPrivate.m
+++ b/WebKit/WebView.subproj/WebHTMLViewPrivate.m
@@ -5,9 +5,10 @@
         in WebCore.  Instances of this class are referenced by _private in 
         NSWebPageView.
 */
-#import <WebKit/WebKitDebug.h>
 
 #import <WebKit/IFHTMLViewPrivate.h>
+
+#import <WebKit/WebKitDebug.h>
 #import <WebKit/IFImageRenderer.h>
 #import <WebKit/IFNSViewExtras.h>
 #import <WebKit/IFPluginView.h>
@@ -16,10 +17,6 @@
 #import <WebKit/IFWebFramePrivate.h>
 #import <WebKit/IFWebViewPrivate.h>
 
-#ifndef WEBKIT_INDEPENDENT_OF_WEBCORE
-#import <khtmlview.h>
-#endif
-
 @interface NSView (IFHTMLViewPrivate)
 - (void)_IF_stopIfPluginView;
 @end
@@ -52,7 +49,7 @@
     // the frame origins during drawing!  So we have to 
     // layout and do a draw with rendering disabled to
     // correclty adjust the frames.
-    [[self _bridge] adjustFrames: [self frame]];
+    [[self _bridge] adjustFrames:[self frame]];
 }
 
 
@@ -62,37 +59,20 @@
     [subviews makeObjectsPerformSelector:@selector(_IF_stopIfPluginView)];
     [subviews release];
 
-    [IFImageRenderer stopAnimationsInView: self];
-    
-    delete _private->provisionalWidget;
-    _private->provisionalWidget = 0;
-    if (_private->widgetOwned)
-        delete _private->widget;
-    _private->widget = 0;
-    _private->widgetOwned = NO;
+    [IFImageRenderer stopAnimationsInView:self];
 }
 
-- (void)_setController: (IFWebController *)controller
+- (void)_setController:(IFWebController *)controller
 {
     // Not retained; the controller owns the view.
     _private->controller = controller;    
 }
 
-- (KHTMLView *)_widget
-{
-    return _private->widget;    
-}
-
-- (KHTMLView *)_provisionalWidget
-{
-    return _private->provisionalWidget;    
-}
-
 // Required so view can access the part's selection.
 - (IFWebCoreBridge *)_bridge
 {
     IFWebView *webView = [self _IF_parentWebView];
-    IFWebFrame *webFrame = [[webView _controller] frameForView: webView];
+    IFWebFrame *webFrame = [[webView _controller] frameForView:webView];
     return [[webFrame dataSource] _bridge];
 }
 
diff --git a/WebKit/WebView.subproj/WebRenderNode.h b/WebKit/WebView.subproj/WebRenderNode.h
index 2c64132..d1f22f4 100644
--- a/WebKit/WebView.subproj/WebRenderNode.h
+++ b/WebKit/WebView.subproj/WebRenderNode.h
@@ -13,19 +13,17 @@
 @interface IFRenderNode : NSObject
 {
     NSArray *children;
-    int x, y;
-    int width;
-    int height;
     NSString *name;
+    NSRect rect;
 }
 
 - initWithWebView:(IFWebView *)view;
 
 - (NSArray *)children;
 
+- (NSString *)name;
 - (NSString *)positionString;
 - (NSString *)widthString;
 - (NSString *)heightString;
-- (NSString *)name;
 
 @end
diff --git a/WebKit/WebView.subproj/WebRenderNode.m b/WebKit/WebView.subproj/WebRenderNode.m
index 1aa61ae..e77046e 100644
--- a/WebKit/WebView.subproj/WebRenderNode.m
+++ b/WebKit/WebView.subproj/WebRenderNode.m
@@ -8,65 +8,62 @@
 
 #import "IFRenderNode.h"
 
+#import <WebKit/IFWebCoreBridge.h>
 #import <WebKit/IFWebView.h>
 #import <WebKit/IFHTMLViewPrivate.h>
 
-#ifndef WEBKIT_INDEPENDENT_OF_WEBCORE
-
-#import <khtmlview.h>
-#import <khtml_part.h>
-#import <xml/dom_docimpl.h>
-#import <rendering/render_frames.h>
-
-#endif
+ at interface WebKitRenderTreeCopier : NSObject <WebCoreRenderTreeCopier>
+ at end
 
 @implementation IFRenderNode
 
-- initWithRenderObject:(khtml::RenderObject *)node
+- initWithName:(NSString *)n rect:(NSRect)r view:(NSView *)view children:(NSArray *)c
 {
     NSMutableArray *collectChildren;
     
     [super init];
 
-    collectChildren = [NSMutableArray array];
+    collectChildren = [c mutableCopy];
 
-    name = [[NSString stringWithCString:node->renderName()] retain];
-    x = node->xPos();
-    y = node->yPos();
-    width = node->width();
-    height = node->height();
+    name = [n retain];
+    rect = r;
 
-    for (khtml::RenderObject *child = node->firstChild(); child; child = child->nextSibling()) {
-        [collectChildren addObject:[[[IFRenderNode alloc] initWithRenderObject: child] autorelease]];
+    if ([view isKindOfClass:[NSScrollView class]]) {
+        NSScrollView *scrollView = (NSScrollView *)view;
+        view = [scrollView superview];
     }
-
-    khtml::RenderPart *part = dynamic_cast<khtml::RenderPart *>(node);
-    if (part) {
-        NSView *view = part->widget()->getView();
-        if ([view isKindOfClass:[NSScrollView class]]) {
-            NSScrollView *scrollView = (NSScrollView *)view;
-            view = [scrollView superview];
-        }
-        if ([view isKindOfClass:[IFWebView class]]) {
-            IFWebView *webView = (IFWebView *)view;
-            [collectChildren addObject:[[[IFRenderNode alloc] initWithWebView:webView] autorelease]];
-        }
+    if ([view isKindOfClass:[IFWebView class]]) {
+        IFWebView *webView = (IFWebView *)view;
+        [collectChildren addObject:[[[IFRenderNode alloc] initWithWebView:webView] autorelease]];
     }
     
     children = [collectChildren copy];
+    [collectChildren release];
     
     return self;
 }
 
 - initWithWebView:(IFWebView *)view
 {
-    return [self initWithRenderObject:[(IFHTMLView *)[view documentView] _widget]->part()->xmlDocImpl()->renderer()];
+    WebKitRenderTreeCopier *copier;
+    
+    [self dealloc];
+
+    if (![[view documentView] isMemberOfClass:[IFHTMLView class]]) {
+        return nil;
+    }
+    
+    copier = [[WebKitRenderTreeCopier alloc] init];
+    self = [[[(IFHTMLView *)[view documentView] _bridge] copyRenderTree:copier] retain];
+    [copier release];
+    
+    return self;
 }
 
 - (void)dealloc
 {
-    [name release];
     [children release];
+    [name release];
     [super dealloc];
 }
 
@@ -82,17 +79,26 @@
 
 - (NSString *)positionString
 {
-    return [NSString stringWithFormat:@"(%d, %d)", x, y];
+    return [NSString stringWithFormat:@"(%.0f, %.0f)", rect.origin.x, rect.origin.y];
 }
 
 - (NSString *)widthString
 {
-    return [NSString stringWithFormat:@"%d", width];
+    return [NSString stringWithFormat:@"%.0f", rect.size.width];
 }
 
 - (NSString *)heightString
 {
-    return [NSString stringWithFormat:@"%d", height];
+    return [NSString stringWithFormat:@"%.0f", rect.size.height];
+}
+
+ at end
+
+ at implementation WebKitRenderTreeCopier
+
+- (NSObject *)nodeWithName:(NSString *)name rect:(NSRect)rect view:(NSView *)view children:(NSArray *)children
+{
+    return [[[IFRenderNode alloc] initWithName:name rect:rect view:view children:children] autorelease];
 }
 
 @end
diff --git a/WebKit/WebView.subproj/WebViewPrivate.m b/WebKit/WebView.subproj/WebViewPrivate.m
index 08822ea..be66e24 100644
--- a/WebKit/WebView.subproj/WebViewPrivate.m
+++ b/WebKit/WebView.subproj/WebViewPrivate.m
@@ -127,8 +127,6 @@
 
     [[self resourceProgressHandler] receivedError: error forResourceHandle: resourceHandle partialProgress: progress fromDataSource: dataSource];
 
-    WEBKIT_ASSERT (frame != nil);
-
     [dataSource _addError: error forResource:
         (resourceHandle != nil ? [[resourceHandle url] absoluteString] : [[error failingURL] absoluteString])];
     
@@ -142,8 +140,6 @@
 
     [[self resourceProgressHandler] receivedError: error forResourceHandle: resourceHandle partialProgress: progress fromDataSource: dataSource];
     
-    WEBKIT_ASSERT (frame != nil);
-
     [dataSource _setPrimaryLoadComplete: YES];
 
     [dataSource _setMainDocumentError: error];

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list