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


The following commit has been merged in the debian/unstable branch:
commit 9f156db6c3de489199067a82e62172eb3f7c3bd6
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Aug 16 00:09:49 2002 +0000

    	- fixed 3017376 -- button height is too tall
    
    	Reworked how widget sizing and positioning is done for a few of the most important
    	widget types.
    
            * khtml/rendering/render_form.h: Remove more of the performAction hackery.
            * khtml/rendering/render_form.cpp:
            (RenderCheckBox::calcMinMaxWidth): Get size from widget.
            (RenderRadioButton::calcMinMaxWidth): Get size from widget.
            (RenderSubmitButton::RenderSubmitButton): Remove old unneeded APPLE_CHANGES.
            (RenderSubmitButton::baselinePosition): Put the bottom of the button on the
    	baseline without any magic numbers.
            (RenderLineEdit::baselinePosition): Put the bottom of the text field two pixels
    	below the baseline without any other magic numbers.
            (RenderLineEdit::calcMinMaxWidth): Get size from widget.
            (RenderSelect::baselinePosition): Put the bottom of the menu on the
    	baseline without any magic numbers. List box case is untouched for now.
    
            * kwq/qt/qbutton.h:
            * kwq/KWQButton.mm:
            (QButton::QButton): Move most of the setup into KWQNSButton.
            (QButton::sizeHint): Use cellSize, account for margins.
            (QButton::frameGeometry): Adjust for margins.
            (QButton::setFrameGeometry): Adjust for margins.
            * kwq/qt/qcheckbox.h:
            * kwq/KWQCheckBox.mm:
            (QCheckBox::QCheckBox): QButton takes care of most of the setup now.
            (QCheckBox::sizeHint): Added.
            (QCheckBox::frameGeometry): Adjust for margins.
            (QCheckBox::setFrameGeometry): Adjust for margins.
            * kwq/qt/qcombobox.h:
            * kwq/KWQComboBox.mm:
            (QComboBox::init): KWQNSComboBox takes care of most of the setup now.
            (QComboBox::sizeHint): Adjust for margins.
            (QComboBox::frameGeometry): Adjust for margins.
            (QComboBox::setFrameGeometry): Adjust for margins.
            * kwq/qt/qlineedit.h:
            * kwq/KWQLineEdit.mm:
            (QLineEdit::sizeForCharacterWidth): Added.
            (QLineEdit::frameGeometry): Adjust for margins.
            (QLineEdit::setFrameGeometry): Adjust for margins.
            * kwq/qt/qradiobutton.h:
            * kwq/KWQRadioButton.mm:
            (QRadioButton::QRadioButton): QButton takes care of most of the setup now.
            (QRadioButton::sizeHint): Added.
            (QRadioButton::frameGeometry): Adjust for margins.
            (QRadioButton::setFrameGeometry): Adjust for margins.
    
            * kwq/qt/qwidget.h:
            * kwq/KWQWidget.mm:
            (QWidget::setFrameGeometry): New name for internalSetGeometry, now public.
    
    	- fixed 3010695 -- Slashdot.org starts with password field focused, but shouldn't
    
    	Added KWQSecureTextField to work around the bug.
    
            * kwq/KWQNSTextField.h: Made formatter and other details private.
            * kwq/KWQNSTextField.mm:
            (+[KWQNSTextField initialize]): Set up custom cell class that works around focus border.
            (-[KWQNSTextField initWithFrame:]): Put the work in here, since this is NSView's designated
    	initializer.
            (-[KWQNSTextField initWithWidget:]): Now just calls [init] which calls [initWithFrame],
    	and then sets the widget.
            (-[KWQNSTextField action:]): Use the returnPressed signal instead of ACTION_TEXT_FIELD.
            (-[KWQNSTextField controlTextDidEndEditing:]): Use textChanged signal instead of
    	ACTION_TEXT_FIELD_END_EDITING.
            (-[KWQNSTextField dealloc]): Release the secureField (was a leak).
            (-[KWQNSTextField updateSecureFieldFrame]): Added. Used to keep secure field in the right
    	place.
            (-[KWQNSTextField setFrameSize:]): Added. Calls updateSecureFieldFrame.
            (-[KWQNSTextField setPasswordMode:]): Change all the details, but this does the same
    	thing it used to.
            (-[KWQNSTextField selectText:]): Only call selectText on one of the two field, since it
    	causes the field to grab focus and we don't want to do that twice.
            (-[KWQNSTextField setStringValue:]): Set the string value in both fields any time someone
    	gives us a new value.
            (-[KWQNSTextField setFont:]): Set the font in both fields any time someone gives us a new
    	font.
            (-[KWQTextFieldCell cellSizeForBounds:]): Add space for focus border.
            (-[KWQTextFieldCell drawWithFrame:inView:]): Inset by focus border.
            (-[KWQTextFieldCell editWithFrame:inView:editor:delegate:event:]): Inset by focus border.
            (-[KWQTextFieldCell selectWithFrame:inView:editor:delegate:start:length:]): Inset by focus border.
            (-[KWQSecureTextField selectText:]): Override to do nothing while in setFrameSize to work around
    	bug in AppKit.
            (-[KWQSecureTextField setFrameSize:]): Set flag to trigger selectText check.
    
    	- fixed 3025166 -- check boxes and radio buttons on google.com's preferences pages
    	are not "linked"
    
    	We were not emitting onClicked for check boxes.
    
            * kwq/KWQView.h: No need to pass frames any more. Default is empty.
            * kwq/KWQView.mm:
            (-[KWQView initWithFrame:]): Do most of the work in here.
            (-[KWQView initWithWidget:]): Just call [init] and set up widget.
            (-[KWQNSButton initWithFrame:]): Do most of the work in here. Remove the special
    	cell class, and always use a small control with the small system font.
            (-[KWQNSButton initWithWidget:]): Just call [init] and set up widget.
            (-[KWQNSButton action:]): Call the clicked() signal instead of ACTION_BUTTON_CLICKED.
            (-[KWQNSButton stateChanged:]): Call the stateChanged() signal instead of
    	ACTION_CHECKBOX_CLICKED.
            (-[KWQNSComboBox initWithFrame:]): Do most of the work in here.
            (-[KWQNSComboBox initWithWidget:]): Just call [init] and set up widget.
            (-[KWQNSScrollView initWithWidget:]): Just call [init] and set up widget.
    
    	- fixed 3025211 -- find person in Apple directory never displays person information
    
    	When I enabled the code to wait and not redirect until loads are complete, that
    	broke this case, because we didn't have enough hooked up to notice loads completing.
    	I hooked everything up and its working now.
    
            * khtml/khtml_part.h: Add started().
            * khtml/khtml_part.cpp:
            (KHTMLPart::restoreURL): Un-ifdef emission of started().
            (KHTMLPart::openURL): Un-ifdef emission of started().
            (KHTMLPart::end): Don't do an explicit call to slotFinishedParsing().
    	We actually hook up a signal for this now.
            (KHTMLPart::slotChildCompleted): Un-ifdef the rest of the code here.
    
            * khtml/xml/dom_docimpl.h:
            * khtml/xml/dom_docimpl.cpp: (DocumentImpl::DocumentImpl):
            * khtml/xml/xml_tokenizer.h:
    	Do the necessary setup so we can use KWQSignal for finishedParsing.
    
            * kwq/KWQKHTMLPartImpl.mm:
            (KHTMLPart::started): Added. Calls slotChildStarted on parent.
            (KHTMLPart::completed): Added slotParentCompleted calls.
    
            * kwq/qt/qobject.h: Add sender() and KWQObjectSenderScope.
            * kwq/KWQObject.mm:
            (KWQObjectSenderScope::KWQObjectSenderScope): Added. Sets sender() and saves the old value.
            (KWQObjectSenderScope::~KWQObjectSenderScope): Added. Resets sender().
    
            * kwq/KWQSignal.h:
            * kwq/KWQSlot.h:
            * kwq/KWQSignal.mm: (KWQSignal::call): Added overloads for calling signals with int and
    	QString parameters. Also set up sender() using KWQObjectSenderScope.
    
            * kwq/KWQSlot.mm: (KWQSlot::KWQSlot), (KWQSlot::call): Add support for one signal
    	(calls through to whatever is connected to that signal's slot) and six new slots.
    
            * kwq/KWQsignals.mm:
            (Tokenizer::Tokenizer): Construct the finishedParsing signal.
            (Tokenizer::finishedParsing): Emit the finishedParsing signal.
    
    	- fixed 3025170 -- right sides of borders placed incorrectly around table cells
    
    	There was some silly code that I just removed.
    
            * khtml/rendering/render_table.cpp:
            (RenderTable::addColInfo): Turn off the half-assed collapse borders stuff here.
    
    	- other changes
    
            * force-clean-timestamp: Big changes; full rebuild needed.
    
            * khtml/khtmlview.cpp: (KHTMLView::~KHTMLView): Make the code to kill
    	the timers be unconditional, just in case.
    
            * kwq/KWQCharsets.mm: (buildDictionaries): Remove UTF-16 special case since it's now
    	in the character sets table.
    
            * kwq/qt/qpoint.h:
            * kwq/KWQPoint.mm:
            (QPoint::QPoint): Converts from NSPoint.
            (QPoint::operator NSPoint): Converts to NSPoint.
            * kwq/qt/qrect.h:
            * kwq/KWQRect.mm:
            (QRect::QRect): Converts from NSRect.
            (QRect::isEmpty): Fix backwards logic.
            (QRect::operator NSRect): Converts to NSRect.
            * kwq/qt/qsize.h:
            * kwq/KWQSize.mm:
            (QSize::QSize): Converts from NSSize.
            (QSize::operator NSSize): Converts to NSSize.
    
            * kwq/qt/qpushbutton.h:
            * kwq/KWQPushButton.mm: Removed unused methods.
    
            * kwq/KWQRegion.mm: Use new QPoint/NSPoint/QRect/NSRect functions.
    
            * kwq/KWQScrollView.mm: (QScrollView::addChild): Update comment.
    
            * kwq/KWQTextArea.h:
            * kwq/KWQTextArea.mm:
            (-[KWQTextArea initWithFrame:]): Do most of the work in here.
            (-[KWQTextArea initWithWidget:]): Just call [init] and set up widget.
    
            * kwq/KWQTextEdit.mm: (QTextEdit::QTextEdit): Don't pass an empty frame any more.
    
            * kwq/KWQWindowWidget.h:
            * kwq/KWQWindowWidget.mm: Update for name change.
    
            * kwq/WebCoreTestController.h: Placeholder for the feature I should be working on.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1834 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 04ac4ba..7979428 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,200 @@
+2002-08-15  Darin Adler  <darin at apple.com>
+
+	- fixed 3017376 -- button height is too tall
+
+	Reworked how widget sizing and positioning is done for a few of the most important
+	widget types.
+
+        * khtml/rendering/render_form.h: Remove more of the performAction hackery.
+        * khtml/rendering/render_form.cpp:
+        (RenderCheckBox::calcMinMaxWidth): Get size from widget.
+        (RenderRadioButton::calcMinMaxWidth): Get size from widget.
+        (RenderSubmitButton::RenderSubmitButton): Remove old unneeded APPLE_CHANGES.
+        (RenderSubmitButton::baselinePosition): Put the bottom of the button on the
+	baseline without any magic numbers.
+        (RenderLineEdit::baselinePosition): Put the bottom of the text field two pixels
+	below the baseline without any other magic numbers.
+        (RenderLineEdit::calcMinMaxWidth): Get size from widget.
+        (RenderSelect::baselinePosition): Put the bottom of the menu on the
+	baseline without any magic numbers. List box case is untouched for now.
+
+        * kwq/qt/qbutton.h:
+        * kwq/KWQButton.mm:
+        (QButton::QButton): Move most of the setup into KWQNSButton.
+        (QButton::sizeHint): Use cellSize, account for margins.
+        (QButton::frameGeometry): Adjust for margins.
+        (QButton::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qcheckbox.h:
+        * kwq/KWQCheckBox.mm:
+        (QCheckBox::QCheckBox): QButton takes care of most of the setup now.
+        (QCheckBox::sizeHint): Added.
+        (QCheckBox::frameGeometry): Adjust for margins.
+        (QCheckBox::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qcombobox.h:
+        * kwq/KWQComboBox.mm:
+        (QComboBox::init): KWQNSComboBox takes care of most of the setup now.
+        (QComboBox::sizeHint): Adjust for margins.
+        (QComboBox::frameGeometry): Adjust for margins.
+        (QComboBox::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qlineedit.h:
+        * kwq/KWQLineEdit.mm:
+        (QLineEdit::sizeForCharacterWidth): Added.
+        (QLineEdit::frameGeometry): Adjust for margins.
+        (QLineEdit::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qradiobutton.h:
+        * kwq/KWQRadioButton.mm:
+        (QRadioButton::QRadioButton): QButton takes care of most of the setup now.
+        (QRadioButton::sizeHint): Added.
+        (QRadioButton::frameGeometry): Adjust for margins.
+        (QRadioButton::setFrameGeometry): Adjust for margins.
+
+        * kwq/qt/qwidget.h:
+        * kwq/KWQWidget.mm:
+        (QWidget::setFrameGeometry): New name for internalSetGeometry, now public.
+
+	- fixed 3010695 -- Slashdot.org starts with password field focused, but shouldn't
+
+	Added KWQSecureTextField to work around the bug.
+
+        * kwq/KWQNSTextField.h: Made formatter and other details private.
+        * kwq/KWQNSTextField.mm:
+        (+[KWQNSTextField initialize]): Set up custom cell class that works around focus border.
+        (-[KWQNSTextField initWithFrame:]): Put the work in here, since this is NSView's designated
+	initializer.
+        (-[KWQNSTextField initWithWidget:]): Now just calls [init] which calls [initWithFrame],
+	and then sets the widget.
+        (-[KWQNSTextField action:]): Use the returnPressed signal instead of ACTION_TEXT_FIELD.
+        (-[KWQNSTextField controlTextDidEndEditing:]): Use textChanged signal instead of
+	ACTION_TEXT_FIELD_END_EDITING.
+        (-[KWQNSTextField dealloc]): Release the secureField (was a leak).
+        (-[KWQNSTextField updateSecureFieldFrame]): Added. Used to keep secure field in the right
+	place.
+        (-[KWQNSTextField setFrameSize:]): Added. Calls updateSecureFieldFrame.
+        (-[KWQNSTextField setPasswordMode:]): Change all the details, but this does the same
+	thing it used to.
+        (-[KWQNSTextField selectText:]): Only call selectText on one of the two field, since it
+	causes the field to grab focus and we don't want to do that twice.
+        (-[KWQNSTextField setStringValue:]): Set the string value in both fields any time someone
+	gives us a new value.
+        (-[KWQNSTextField setFont:]): Set the font in both fields any time someone gives us a new
+	font.
+        (-[KWQTextFieldCell cellSizeForBounds:]): Add space for focus border.
+        (-[KWQTextFieldCell drawWithFrame:inView:]): Inset by focus border.
+        (-[KWQTextFieldCell editWithFrame:inView:editor:delegate:event:]): Inset by focus border.
+        (-[KWQTextFieldCell selectWithFrame:inView:editor:delegate:start:length:]): Inset by focus border.
+        (-[KWQSecureTextField selectText:]): Override to do nothing while in setFrameSize to work around
+	bug in AppKit.
+        (-[KWQSecureTextField setFrameSize:]): Set flag to trigger selectText check.
+
+	- fixed 3025166 -- check boxes and radio buttons on google.com's preferences pages
+	are not "linked"
+
+	We were not emitting onClicked for check boxes.
+
+        * kwq/KWQView.h: No need to pass frames any more. Default is empty.
+        * kwq/KWQView.mm:
+        (-[KWQView initWithFrame:]): Do most of the work in here.
+        (-[KWQView initWithWidget:]): Just call [init] and set up widget.
+        (-[KWQNSButton initWithFrame:]): Do most of the work in here. Remove the special
+	cell class, and always use a small control with the small system font.
+        (-[KWQNSButton initWithWidget:]): Just call [init] and set up widget.
+        (-[KWQNSButton action:]): Call the clicked() signal instead of ACTION_BUTTON_CLICKED.
+        (-[KWQNSButton stateChanged:]): Call the stateChanged() signal instead of
+	ACTION_CHECKBOX_CLICKED.
+        (-[KWQNSComboBox initWithFrame:]): Do most of the work in here.
+        (-[KWQNSComboBox initWithWidget:]): Just call [init] and set up widget.
+        (-[KWQNSScrollView initWithWidget:]): Just call [init] and set up widget.
+
+	- fixed 3025211 -- find person in Apple directory never displays person information
+
+	When I enabled the code to wait and not redirect until loads are complete, that
+	broke this case, because we didn't have enough hooked up to notice loads completing.
+	I hooked everything up and its working now.
+
+        * khtml/khtml_part.h: Add started().
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::restoreURL): Un-ifdef emission of started().
+        (KHTMLPart::openURL): Un-ifdef emission of started().
+        (KHTMLPart::end): Don't do an explicit call to slotFinishedParsing().
+	We actually hook up a signal for this now.
+        (KHTMLPart::slotChildCompleted): Un-ifdef the rest of the code here.
+
+        * khtml/xml/dom_docimpl.h:
+        * khtml/xml/dom_docimpl.cpp: (DocumentImpl::DocumentImpl):
+        * khtml/xml/xml_tokenizer.h:
+	Do the necessary setup so we can use KWQSignal for finishedParsing.
+
+        * kwq/KWQKHTMLPartImpl.mm:
+        (KHTMLPart::started): Added. Calls slotChildStarted on parent.
+        (KHTMLPart::completed): Added slotParentCompleted calls.
+
+        * kwq/qt/qobject.h: Add sender() and KWQObjectSenderScope.
+        * kwq/KWQObject.mm:
+        (KWQObjectSenderScope::KWQObjectSenderScope): Added. Sets sender() and saves the old value.
+        (KWQObjectSenderScope::~KWQObjectSenderScope): Added. Resets sender().
+
+        * kwq/KWQSignal.h:
+        * kwq/KWQSlot.h:
+        * kwq/KWQSignal.mm: (KWQSignal::call): Added overloads for calling signals with int and
+	QString parameters. Also set up sender() using KWQObjectSenderScope.
+
+        * kwq/KWQSlot.mm: (KWQSlot::KWQSlot), (KWQSlot::call): Add support for one signal
+	(calls through to whatever is connected to that signal's slot) and six new slots.
+
+        * kwq/KWQsignals.mm:
+        (Tokenizer::Tokenizer): Construct the finishedParsing signal.
+        (Tokenizer::finishedParsing): Emit the finishedParsing signal.
+
+	- fixed 3025170 -- right sides of borders placed incorrectly around table cells
+
+	There was some silly code that I just removed.
+
+        * khtml/rendering/render_table.cpp:
+        (RenderTable::addColInfo): Turn off the half-assed collapse borders stuff here.
+
+	- other changes
+
+        * force-clean-timestamp: Big changes; full rebuild needed.
+
+        * khtml/khtmlview.cpp: (KHTMLView::~KHTMLView): Make the code to kill
+	the timers be unconditional, just in case.
+
+        * kwq/KWQCharsets.mm: (buildDictionaries): Remove UTF-16 special case since it's now
+	in the character sets table.
+
+        * kwq/qt/qpoint.h:
+        * kwq/KWQPoint.mm:
+        (QPoint::QPoint): Converts from NSPoint.
+        (QPoint::operator NSPoint): Converts to NSPoint.
+        * kwq/qt/qrect.h:
+        * kwq/KWQRect.mm:
+        (QRect::QRect): Converts from NSRect.
+        (QRect::isEmpty): Fix backwards logic.
+        (QRect::operator NSRect): Converts to NSRect.
+        * kwq/qt/qsize.h:
+        * kwq/KWQSize.mm:
+        (QSize::QSize): Converts from NSSize.
+        (QSize::operator NSSize): Converts to NSSize.
+
+        * kwq/qt/qpushbutton.h:
+        * kwq/KWQPushButton.mm: Removed unused methods.
+
+        * kwq/KWQRegion.mm: Use new QPoint/NSPoint/QRect/NSRect functions.
+
+        * kwq/KWQScrollView.mm: (QScrollView::addChild): Update comment.
+
+        * kwq/KWQTextArea.h:
+        * kwq/KWQTextArea.mm:
+        (-[KWQTextArea initWithFrame:]): Do most of the work in here.
+        (-[KWQTextArea initWithWidget:]): Just call [init] and set up widget.
+
+        * kwq/KWQTextEdit.mm: (QTextEdit::QTextEdit): Don't pass an empty frame any more.
+
+        * kwq/KWQWindowWidget.h:
+        * kwq/KWQWindowWidget.mm: Update for name change.
+
+        * kwq/WebCoreTestController.h: Placeholder for the feature I should be working on.
+
 === Alexander-19 ===
 
 === Alexander-18 ===
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 04ac4ba..7979428 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,200 @@
+2002-08-15  Darin Adler  <darin at apple.com>
+
+	- fixed 3017376 -- button height is too tall
+
+	Reworked how widget sizing and positioning is done for a few of the most important
+	widget types.
+
+        * khtml/rendering/render_form.h: Remove more of the performAction hackery.
+        * khtml/rendering/render_form.cpp:
+        (RenderCheckBox::calcMinMaxWidth): Get size from widget.
+        (RenderRadioButton::calcMinMaxWidth): Get size from widget.
+        (RenderSubmitButton::RenderSubmitButton): Remove old unneeded APPLE_CHANGES.
+        (RenderSubmitButton::baselinePosition): Put the bottom of the button on the
+	baseline without any magic numbers.
+        (RenderLineEdit::baselinePosition): Put the bottom of the text field two pixels
+	below the baseline without any other magic numbers.
+        (RenderLineEdit::calcMinMaxWidth): Get size from widget.
+        (RenderSelect::baselinePosition): Put the bottom of the menu on the
+	baseline without any magic numbers. List box case is untouched for now.
+
+        * kwq/qt/qbutton.h:
+        * kwq/KWQButton.mm:
+        (QButton::QButton): Move most of the setup into KWQNSButton.
+        (QButton::sizeHint): Use cellSize, account for margins.
+        (QButton::frameGeometry): Adjust for margins.
+        (QButton::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qcheckbox.h:
+        * kwq/KWQCheckBox.mm:
+        (QCheckBox::QCheckBox): QButton takes care of most of the setup now.
+        (QCheckBox::sizeHint): Added.
+        (QCheckBox::frameGeometry): Adjust for margins.
+        (QCheckBox::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qcombobox.h:
+        * kwq/KWQComboBox.mm:
+        (QComboBox::init): KWQNSComboBox takes care of most of the setup now.
+        (QComboBox::sizeHint): Adjust for margins.
+        (QComboBox::frameGeometry): Adjust for margins.
+        (QComboBox::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qlineedit.h:
+        * kwq/KWQLineEdit.mm:
+        (QLineEdit::sizeForCharacterWidth): Added.
+        (QLineEdit::frameGeometry): Adjust for margins.
+        (QLineEdit::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qradiobutton.h:
+        * kwq/KWQRadioButton.mm:
+        (QRadioButton::QRadioButton): QButton takes care of most of the setup now.
+        (QRadioButton::sizeHint): Added.
+        (QRadioButton::frameGeometry): Adjust for margins.
+        (QRadioButton::setFrameGeometry): Adjust for margins.
+
+        * kwq/qt/qwidget.h:
+        * kwq/KWQWidget.mm:
+        (QWidget::setFrameGeometry): New name for internalSetGeometry, now public.
+
+	- fixed 3010695 -- Slashdot.org starts with password field focused, but shouldn't
+
+	Added KWQSecureTextField to work around the bug.
+
+        * kwq/KWQNSTextField.h: Made formatter and other details private.
+        * kwq/KWQNSTextField.mm:
+        (+[KWQNSTextField initialize]): Set up custom cell class that works around focus border.
+        (-[KWQNSTextField initWithFrame:]): Put the work in here, since this is NSView's designated
+	initializer.
+        (-[KWQNSTextField initWithWidget:]): Now just calls [init] which calls [initWithFrame],
+	and then sets the widget.
+        (-[KWQNSTextField action:]): Use the returnPressed signal instead of ACTION_TEXT_FIELD.
+        (-[KWQNSTextField controlTextDidEndEditing:]): Use textChanged signal instead of
+	ACTION_TEXT_FIELD_END_EDITING.
+        (-[KWQNSTextField dealloc]): Release the secureField (was a leak).
+        (-[KWQNSTextField updateSecureFieldFrame]): Added. Used to keep secure field in the right
+	place.
+        (-[KWQNSTextField setFrameSize:]): Added. Calls updateSecureFieldFrame.
+        (-[KWQNSTextField setPasswordMode:]): Change all the details, but this does the same
+	thing it used to.
+        (-[KWQNSTextField selectText:]): Only call selectText on one of the two field, since it
+	causes the field to grab focus and we don't want to do that twice.
+        (-[KWQNSTextField setStringValue:]): Set the string value in both fields any time someone
+	gives us a new value.
+        (-[KWQNSTextField setFont:]): Set the font in both fields any time someone gives us a new
+	font.
+        (-[KWQTextFieldCell cellSizeForBounds:]): Add space for focus border.
+        (-[KWQTextFieldCell drawWithFrame:inView:]): Inset by focus border.
+        (-[KWQTextFieldCell editWithFrame:inView:editor:delegate:event:]): Inset by focus border.
+        (-[KWQTextFieldCell selectWithFrame:inView:editor:delegate:start:length:]): Inset by focus border.
+        (-[KWQSecureTextField selectText:]): Override to do nothing while in setFrameSize to work around
+	bug in AppKit.
+        (-[KWQSecureTextField setFrameSize:]): Set flag to trigger selectText check.
+
+	- fixed 3025166 -- check boxes and radio buttons on google.com's preferences pages
+	are not "linked"
+
+	We were not emitting onClicked for check boxes.
+
+        * kwq/KWQView.h: No need to pass frames any more. Default is empty.
+        * kwq/KWQView.mm:
+        (-[KWQView initWithFrame:]): Do most of the work in here.
+        (-[KWQView initWithWidget:]): Just call [init] and set up widget.
+        (-[KWQNSButton initWithFrame:]): Do most of the work in here. Remove the special
+	cell class, and always use a small control with the small system font.
+        (-[KWQNSButton initWithWidget:]): Just call [init] and set up widget.
+        (-[KWQNSButton action:]): Call the clicked() signal instead of ACTION_BUTTON_CLICKED.
+        (-[KWQNSButton stateChanged:]): Call the stateChanged() signal instead of
+	ACTION_CHECKBOX_CLICKED.
+        (-[KWQNSComboBox initWithFrame:]): Do most of the work in here.
+        (-[KWQNSComboBox initWithWidget:]): Just call [init] and set up widget.
+        (-[KWQNSScrollView initWithWidget:]): Just call [init] and set up widget.
+
+	- fixed 3025211 -- find person in Apple directory never displays person information
+
+	When I enabled the code to wait and not redirect until loads are complete, that
+	broke this case, because we didn't have enough hooked up to notice loads completing.
+	I hooked everything up and its working now.
+
+        * khtml/khtml_part.h: Add started().
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::restoreURL): Un-ifdef emission of started().
+        (KHTMLPart::openURL): Un-ifdef emission of started().
+        (KHTMLPart::end): Don't do an explicit call to slotFinishedParsing().
+	We actually hook up a signal for this now.
+        (KHTMLPart::slotChildCompleted): Un-ifdef the rest of the code here.
+
+        * khtml/xml/dom_docimpl.h:
+        * khtml/xml/dom_docimpl.cpp: (DocumentImpl::DocumentImpl):
+        * khtml/xml/xml_tokenizer.h:
+	Do the necessary setup so we can use KWQSignal for finishedParsing.
+
+        * kwq/KWQKHTMLPartImpl.mm:
+        (KHTMLPart::started): Added. Calls slotChildStarted on parent.
+        (KHTMLPart::completed): Added slotParentCompleted calls.
+
+        * kwq/qt/qobject.h: Add sender() and KWQObjectSenderScope.
+        * kwq/KWQObject.mm:
+        (KWQObjectSenderScope::KWQObjectSenderScope): Added. Sets sender() and saves the old value.
+        (KWQObjectSenderScope::~KWQObjectSenderScope): Added. Resets sender().
+
+        * kwq/KWQSignal.h:
+        * kwq/KWQSlot.h:
+        * kwq/KWQSignal.mm: (KWQSignal::call): Added overloads for calling signals with int and
+	QString parameters. Also set up sender() using KWQObjectSenderScope.
+
+        * kwq/KWQSlot.mm: (KWQSlot::KWQSlot), (KWQSlot::call): Add support for one signal
+	(calls through to whatever is connected to that signal's slot) and six new slots.
+
+        * kwq/KWQsignals.mm:
+        (Tokenizer::Tokenizer): Construct the finishedParsing signal.
+        (Tokenizer::finishedParsing): Emit the finishedParsing signal.
+
+	- fixed 3025170 -- right sides of borders placed incorrectly around table cells
+
+	There was some silly code that I just removed.
+
+        * khtml/rendering/render_table.cpp:
+        (RenderTable::addColInfo): Turn off the half-assed collapse borders stuff here.
+
+	- other changes
+
+        * force-clean-timestamp: Big changes; full rebuild needed.
+
+        * khtml/khtmlview.cpp: (KHTMLView::~KHTMLView): Make the code to kill
+	the timers be unconditional, just in case.
+
+        * kwq/KWQCharsets.mm: (buildDictionaries): Remove UTF-16 special case since it's now
+	in the character sets table.
+
+        * kwq/qt/qpoint.h:
+        * kwq/KWQPoint.mm:
+        (QPoint::QPoint): Converts from NSPoint.
+        (QPoint::operator NSPoint): Converts to NSPoint.
+        * kwq/qt/qrect.h:
+        * kwq/KWQRect.mm:
+        (QRect::QRect): Converts from NSRect.
+        (QRect::isEmpty): Fix backwards logic.
+        (QRect::operator NSRect): Converts to NSRect.
+        * kwq/qt/qsize.h:
+        * kwq/KWQSize.mm:
+        (QSize::QSize): Converts from NSSize.
+        (QSize::operator NSSize): Converts to NSSize.
+
+        * kwq/qt/qpushbutton.h:
+        * kwq/KWQPushButton.mm: Removed unused methods.
+
+        * kwq/KWQRegion.mm: Use new QPoint/NSPoint/QRect/NSRect functions.
+
+        * kwq/KWQScrollView.mm: (QScrollView::addChild): Update comment.
+
+        * kwq/KWQTextArea.h:
+        * kwq/KWQTextArea.mm:
+        (-[KWQTextArea initWithFrame:]): Do most of the work in here.
+        (-[KWQTextArea initWithWidget:]): Just call [init] and set up widget.
+
+        * kwq/KWQTextEdit.mm: (QTextEdit::QTextEdit): Don't pass an empty frame any more.
+
+        * kwq/KWQWindowWidget.h:
+        * kwq/KWQWindowWidget.mm: Update for name change.
+
+        * kwq/WebCoreTestController.h: Placeholder for the feature I should be working on.
+
 === Alexander-19 ===
 
 === Alexander-18 ===
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 04ac4ba..7979428 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,200 @@
+2002-08-15  Darin Adler  <darin at apple.com>
+
+	- fixed 3017376 -- button height is too tall
+
+	Reworked how widget sizing and positioning is done for a few of the most important
+	widget types.
+
+        * khtml/rendering/render_form.h: Remove more of the performAction hackery.
+        * khtml/rendering/render_form.cpp:
+        (RenderCheckBox::calcMinMaxWidth): Get size from widget.
+        (RenderRadioButton::calcMinMaxWidth): Get size from widget.
+        (RenderSubmitButton::RenderSubmitButton): Remove old unneeded APPLE_CHANGES.
+        (RenderSubmitButton::baselinePosition): Put the bottom of the button on the
+	baseline without any magic numbers.
+        (RenderLineEdit::baselinePosition): Put the bottom of the text field two pixels
+	below the baseline without any other magic numbers.
+        (RenderLineEdit::calcMinMaxWidth): Get size from widget.
+        (RenderSelect::baselinePosition): Put the bottom of the menu on the
+	baseline without any magic numbers. List box case is untouched for now.
+
+        * kwq/qt/qbutton.h:
+        * kwq/KWQButton.mm:
+        (QButton::QButton): Move most of the setup into KWQNSButton.
+        (QButton::sizeHint): Use cellSize, account for margins.
+        (QButton::frameGeometry): Adjust for margins.
+        (QButton::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qcheckbox.h:
+        * kwq/KWQCheckBox.mm:
+        (QCheckBox::QCheckBox): QButton takes care of most of the setup now.
+        (QCheckBox::sizeHint): Added.
+        (QCheckBox::frameGeometry): Adjust for margins.
+        (QCheckBox::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qcombobox.h:
+        * kwq/KWQComboBox.mm:
+        (QComboBox::init): KWQNSComboBox takes care of most of the setup now.
+        (QComboBox::sizeHint): Adjust for margins.
+        (QComboBox::frameGeometry): Adjust for margins.
+        (QComboBox::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qlineedit.h:
+        * kwq/KWQLineEdit.mm:
+        (QLineEdit::sizeForCharacterWidth): Added.
+        (QLineEdit::frameGeometry): Adjust for margins.
+        (QLineEdit::setFrameGeometry): Adjust for margins.
+        * kwq/qt/qradiobutton.h:
+        * kwq/KWQRadioButton.mm:
+        (QRadioButton::QRadioButton): QButton takes care of most of the setup now.
+        (QRadioButton::sizeHint): Added.
+        (QRadioButton::frameGeometry): Adjust for margins.
+        (QRadioButton::setFrameGeometry): Adjust for margins.
+
+        * kwq/qt/qwidget.h:
+        * kwq/KWQWidget.mm:
+        (QWidget::setFrameGeometry): New name for internalSetGeometry, now public.
+
+	- fixed 3010695 -- Slashdot.org starts with password field focused, but shouldn't
+
+	Added KWQSecureTextField to work around the bug.
+
+        * kwq/KWQNSTextField.h: Made formatter and other details private.
+        * kwq/KWQNSTextField.mm:
+        (+[KWQNSTextField initialize]): Set up custom cell class that works around focus border.
+        (-[KWQNSTextField initWithFrame:]): Put the work in here, since this is NSView's designated
+	initializer.
+        (-[KWQNSTextField initWithWidget:]): Now just calls [init] which calls [initWithFrame],
+	and then sets the widget.
+        (-[KWQNSTextField action:]): Use the returnPressed signal instead of ACTION_TEXT_FIELD.
+        (-[KWQNSTextField controlTextDidEndEditing:]): Use textChanged signal instead of
+	ACTION_TEXT_FIELD_END_EDITING.
+        (-[KWQNSTextField dealloc]): Release the secureField (was a leak).
+        (-[KWQNSTextField updateSecureFieldFrame]): Added. Used to keep secure field in the right
+	place.
+        (-[KWQNSTextField setFrameSize:]): Added. Calls updateSecureFieldFrame.
+        (-[KWQNSTextField setPasswordMode:]): Change all the details, but this does the same
+	thing it used to.
+        (-[KWQNSTextField selectText:]): Only call selectText on one of the two field, since it
+	causes the field to grab focus and we don't want to do that twice.
+        (-[KWQNSTextField setStringValue:]): Set the string value in both fields any time someone
+	gives us a new value.
+        (-[KWQNSTextField setFont:]): Set the font in both fields any time someone gives us a new
+	font.
+        (-[KWQTextFieldCell cellSizeForBounds:]): Add space for focus border.
+        (-[KWQTextFieldCell drawWithFrame:inView:]): Inset by focus border.
+        (-[KWQTextFieldCell editWithFrame:inView:editor:delegate:event:]): Inset by focus border.
+        (-[KWQTextFieldCell selectWithFrame:inView:editor:delegate:start:length:]): Inset by focus border.
+        (-[KWQSecureTextField selectText:]): Override to do nothing while in setFrameSize to work around
+	bug in AppKit.
+        (-[KWQSecureTextField setFrameSize:]): Set flag to trigger selectText check.
+
+	- fixed 3025166 -- check boxes and radio buttons on google.com's preferences pages
+	are not "linked"
+
+	We were not emitting onClicked for check boxes.
+
+        * kwq/KWQView.h: No need to pass frames any more. Default is empty.
+        * kwq/KWQView.mm:
+        (-[KWQView initWithFrame:]): Do most of the work in here.
+        (-[KWQView initWithWidget:]): Just call [init] and set up widget.
+        (-[KWQNSButton initWithFrame:]): Do most of the work in here. Remove the special
+	cell class, and always use a small control with the small system font.
+        (-[KWQNSButton initWithWidget:]): Just call [init] and set up widget.
+        (-[KWQNSButton action:]): Call the clicked() signal instead of ACTION_BUTTON_CLICKED.
+        (-[KWQNSButton stateChanged:]): Call the stateChanged() signal instead of
+	ACTION_CHECKBOX_CLICKED.
+        (-[KWQNSComboBox initWithFrame:]): Do most of the work in here.
+        (-[KWQNSComboBox initWithWidget:]): Just call [init] and set up widget.
+        (-[KWQNSScrollView initWithWidget:]): Just call [init] and set up widget.
+
+	- fixed 3025211 -- find person in Apple directory never displays person information
+
+	When I enabled the code to wait and not redirect until loads are complete, that
+	broke this case, because we didn't have enough hooked up to notice loads completing.
+	I hooked everything up and its working now.
+
+        * khtml/khtml_part.h: Add started().
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::restoreURL): Un-ifdef emission of started().
+        (KHTMLPart::openURL): Un-ifdef emission of started().
+        (KHTMLPart::end): Don't do an explicit call to slotFinishedParsing().
+	We actually hook up a signal for this now.
+        (KHTMLPart::slotChildCompleted): Un-ifdef the rest of the code here.
+
+        * khtml/xml/dom_docimpl.h:
+        * khtml/xml/dom_docimpl.cpp: (DocumentImpl::DocumentImpl):
+        * khtml/xml/xml_tokenizer.h:
+	Do the necessary setup so we can use KWQSignal for finishedParsing.
+
+        * kwq/KWQKHTMLPartImpl.mm:
+        (KHTMLPart::started): Added. Calls slotChildStarted on parent.
+        (KHTMLPart::completed): Added slotParentCompleted calls.
+
+        * kwq/qt/qobject.h: Add sender() and KWQObjectSenderScope.
+        * kwq/KWQObject.mm:
+        (KWQObjectSenderScope::KWQObjectSenderScope): Added. Sets sender() and saves the old value.
+        (KWQObjectSenderScope::~KWQObjectSenderScope): Added. Resets sender().
+
+        * kwq/KWQSignal.h:
+        * kwq/KWQSlot.h:
+        * kwq/KWQSignal.mm: (KWQSignal::call): Added overloads for calling signals with int and
+	QString parameters. Also set up sender() using KWQObjectSenderScope.
+
+        * kwq/KWQSlot.mm: (KWQSlot::KWQSlot), (KWQSlot::call): Add support for one signal
+	(calls through to whatever is connected to that signal's slot) and six new slots.
+
+        * kwq/KWQsignals.mm:
+        (Tokenizer::Tokenizer): Construct the finishedParsing signal.
+        (Tokenizer::finishedParsing): Emit the finishedParsing signal.
+
+	- fixed 3025170 -- right sides of borders placed incorrectly around table cells
+
+	There was some silly code that I just removed.
+
+        * khtml/rendering/render_table.cpp:
+        (RenderTable::addColInfo): Turn off the half-assed collapse borders stuff here.
+
+	- other changes
+
+        * force-clean-timestamp: Big changes; full rebuild needed.
+
+        * khtml/khtmlview.cpp: (KHTMLView::~KHTMLView): Make the code to kill
+	the timers be unconditional, just in case.
+
+        * kwq/KWQCharsets.mm: (buildDictionaries): Remove UTF-16 special case since it's now
+	in the character sets table.
+
+        * kwq/qt/qpoint.h:
+        * kwq/KWQPoint.mm:
+        (QPoint::QPoint): Converts from NSPoint.
+        (QPoint::operator NSPoint): Converts to NSPoint.
+        * kwq/qt/qrect.h:
+        * kwq/KWQRect.mm:
+        (QRect::QRect): Converts from NSRect.
+        (QRect::isEmpty): Fix backwards logic.
+        (QRect::operator NSRect): Converts to NSRect.
+        * kwq/qt/qsize.h:
+        * kwq/KWQSize.mm:
+        (QSize::QSize): Converts from NSSize.
+        (QSize::operator NSSize): Converts to NSSize.
+
+        * kwq/qt/qpushbutton.h:
+        * kwq/KWQPushButton.mm: Removed unused methods.
+
+        * kwq/KWQRegion.mm: Use new QPoint/NSPoint/QRect/NSRect functions.
+
+        * kwq/KWQScrollView.mm: (QScrollView::addChild): Update comment.
+
+        * kwq/KWQTextArea.h:
+        * kwq/KWQTextArea.mm:
+        (-[KWQTextArea initWithFrame:]): Do most of the work in here.
+        (-[KWQTextArea initWithWidget:]): Just call [init] and set up widget.
+
+        * kwq/KWQTextEdit.mm: (QTextEdit::QTextEdit): Don't pass an empty frame any more.
+
+        * kwq/KWQWindowWidget.h:
+        * kwq/KWQWindowWidget.mm: Update for name change.
+
+        * kwq/WebCoreTestController.h: Placeholder for the feature I should be working on.
+
 === Alexander-19 ===
 
 === Alexander-18 ===
diff --git a/WebCore/force-clean-timestamp b/WebCore/force-clean-timestamp
index 0fd0543..55442bd 100644
--- a/WebCore/force-clean-timestamp
+++ b/WebCore/force-clean-timestamp
@@ -1 +1 @@
-JavaScriptCore changes 8/15 - mjs
\ No newline at end of file
+widget changes 8/15
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 192720c..de006b2 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -337,9 +337,7 @@ bool KHTMLPart::restoreURL( const KURL &url )
 
   KHTMLPageCache::self()->fetchData( d->m_cacheId, this, SLOT(slotRestoreData(const QByteArray &)));
 
-#ifndef APPLE_CHANGES
   emit started( 0L );
-#endif
 
   return true;
 }
@@ -484,9 +482,9 @@ bool KHTMLPart::openURL( const KURL &url )
 
   connect( d->m_job, SIGNAL( percent( KIO::Job*, unsigned long ) ),
            this, SLOT( slotJobPercent( KIO::Job*, unsigned long ) ) );
+#endif // APPLE_CHANGES
 
   emit started( 0L );
-#endif // APPLE_CHANGES
 
   return true;
 }
@@ -1456,10 +1454,6 @@ void KHTMLPart::end()
 
 #ifdef APPLE_CHANGES
     KURL::clearCaches();
-
-    // FIXME: Would be better if we could just count on the signal instead of doing this.
-    if (d->m_doc)
-        slotFinishedParsing();
 #endif
 }
 
@@ -3157,8 +3151,6 @@ void KHTMLPart::popupMenu( const QString &linkUrl )
 #endif
 }
 
-#ifndef APPLE_CHANGES
-
 void KHTMLPart::slotParentCompleted()
 {
   if ( !d->m_redirectURL.isEmpty() && !d->m_redirectionTimer.isActive() )
@@ -3190,8 +3182,6 @@ void KHTMLPart::slotChildStarted( KIO::Job *job )
   }
 }
 
-#endif
-
 void KHTMLPart::slotChildCompleted()
 {
   slotChildCompleted( false );
@@ -3199,14 +3189,12 @@ void KHTMLPart::slotChildCompleted()
 
 void KHTMLPart::slotChildCompleted( bool complete )
 {
-#ifndef APPLE_CHANGES
   khtml::ChildFrame *child = frame( sender() );
 
   assert( child );
 
   child->m_bCompleted = true;
   child->m_args = KParts::URLArgs();
-#endif
   if ( parentPart() == 0 )
     d->m_bPendingChildRedirection = (d->m_bPendingChildRedirection || complete);
 
@@ -4394,7 +4382,7 @@ void KHTMLPart::slotSelectAll()
     static_cast<KHTMLPart *>(part)->selectAll();
 }
 
-#endif
+#endif // APPLE_CHANGES
 
 void KHTMLPart::startAutoScroll()
 {
diff --git a/WebCore/khtml/khtml_part.h b/WebCore/khtml/khtml_part.h
index 961eb79..9639369 100644
--- a/WebCore/khtml/khtml_part.h
+++ b/WebCore/khtml/khtml_part.h
@@ -743,6 +743,7 @@ signals:
 #ifdef APPLE_CHANGES
   void completed();
   void completed(bool);
+  void started(KIO::Job *);
 #endif
 
 protected:
diff --git a/WebCore/khtml/khtmlview.cpp b/WebCore/khtml/khtmlview.cpp
index 43ae568..e8b993c 100644
--- a/WebCore/khtml/khtmlview.cpp
+++ b/WebCore/khtml/khtmlview.cpp
@@ -241,13 +241,17 @@ KHTMLView::~KHTMLView()
             doc->detach();
 
 #ifdef APPLE_CHANGES
-        killTimer(d->timerId);
-        killTimer(d->repaintTimerId);
-        d->timerId = 0;
-        d->repaintTimerId = 0;
         m_part->deref();
 #endif
     }
+
+#ifdef APPLE_CHANGES
+    killTimer(d->timerId);
+    killTimer(d->repaintTimerId);
+    d->timerId = 0;
+    d->repaintTimerId = 0;
+#endif
+
     delete d; d = 0;
 }
 
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index 9beadb6..658aaf8 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -181,17 +181,6 @@ void RenderFormElement::layout()
         setLayouted();
 }
 
-#ifdef APPLE_CHANGES
-void RenderFormElement::performAction(Actions action)
-{
-    if (m_widget)
-        m_widget->endEditing();
-        
-    if (action == ACTION_BUTTON_CLICKED)
-        slotClicked();
-}
-#endif /* APPLE_CHANGES */
-
 void RenderFormElement::slotClicked()
 {
     ref();
@@ -239,9 +228,14 @@ void RenderCheckBox::calcMinMaxWidth()
 {
     KHTMLAssert( !minMaxKnown() );
 
+#ifdef APPLE_CHANGES
+    // Let the widget tell us how big it wants to be.
+    QSize s(widget()->sizeHint());
+#else
     QCheckBox *cb = static_cast<QCheckBox *>( m_widget );
     QSize s( cb->style().pixelMetric( QStyle::PM_IndicatorWidth ),
              cb->style().pixelMetric( QStyle::PM_IndicatorHeight ) );
+#endif
     setIntrinsicWidth( s.width() );
     setIntrinsicHeight( s.height() );
 
@@ -255,16 +249,6 @@ void RenderCheckBox::updateFromElement()
     RenderButton::updateFromElement();
 }
 
-#ifdef APPLE_CHANGES
-void RenderCheckBox::performAction(Actions action)
-{
-    QCheckBox* cb = static_cast<QCheckBox*>( m_widget );
-
-    if (action == ACTION_CHECKBOX_CLICKED)
-        slotStateChanged(cb->isChecked() ? 2 : 0);
-}
-#endif /* APPLE_CHANGES */
-
 // From the Qt documentation:
 // state is 2 if the button is on, 1 if it is in the "no change" state or 0 if the button is off. 
 void RenderCheckBox::slotStateChanged(int state)
@@ -311,9 +295,14 @@ void RenderRadioButton::calcMinMaxWidth()
 {
     KHTMLAssert( !minMaxKnown() );
 
+#ifdef APPLE_CHANGES
+    // Let the widget tell us how big it wants to be.
+    QSize s(widget()->sizeHint());
+#else
     QRadioButton *rb = static_cast<QRadioButton *>( m_widget );
     QSize s( rb->style().pixelMetric( QStyle::PM_ExclusiveIndicatorWidth ),
              rb->style().pixelMetric( QStyle::PM_ExclusiveIndicatorHeight ) );
+#endif
     setIntrinsicWidth( s.width() );
     setIntrinsicHeight( s.height() );
 
@@ -331,12 +320,6 @@ RenderSubmitButton::RenderSubmitButton(HTMLInputElementImpl *element)
     p->setAutoMask(true);
     p->setMouseTracking(true);
     connect(p, SIGNAL(clicked()), this, SLOT(slotClicked()));
-#ifdef APPLE_CHANGES
-    // Need to store a reference to this object and then invoke slotClicked on it.
-    //p->setAction(&RenderFormElement::slotClicked);
-    //p->setRenderObject(this);
-    //p->setTarget(this);
-#endif
 }
 
 QString RenderSubmitButton::rawText()
@@ -356,9 +339,12 @@ void RenderSubmitButton::calcMinMaxWidth()
 {
     KHTMLAssert( !minMaxKnown() );
 
-#ifndef APPLE_CHANGES
-    // Don't use the CSS font metrics.  Don't rely on the button sizing quirks that they
-    // have to use because of scalable button fonts. -dwh
+#ifdef APPLE_CHANGES
+    // Let the widget tell us how big it wants to be.
+    QSize s(widget()->sizeHint());
+    setIntrinsicWidth(s.width());
+    setIntrinsicHeight(s.height());
+#else
     QString raw = rawText();
     QPushButton* pb = static_cast<QPushButton*>(m_widget);
     pb->setText(raw);
@@ -375,12 +361,6 @@ void RenderSubmitButton::calcMinMaxWidth()
     
     setIntrinsicWidth( s.width() - margin / 2 );
     setIntrinsicHeight( s.height() - margin / 2);
-#else
-    // Instead treat a button as fully replaced.  Let it use its own system UI font
-    // and tell us exactly how big it wants to be.
-    QSize s(m_widget->sizeHint());
-    setIntrinsicWidth( s.width() );
-    setIntrinsicHeight( s.height() );
 #endif
 
     RenderButton::calcMinMaxWidth();
@@ -405,7 +385,9 @@ QString RenderSubmitButton::defaultLabel() {
 short RenderSubmitButton::baselinePosition( bool f ) const
 {
 #ifdef APPLE_CHANGES
-    return RenderWidget::baselinePosition( f ) - 7;
+    // We  put the bottoms of buttons on the baseline,
+    // This looks better than trying to line up the button text's baseline.
+    return height() + marginTop();
 #else
     return RenderFormElement::baselinePosition( f );
 #endif
@@ -514,11 +496,12 @@ RenderLineEdit::RenderLineEdit(HTMLInputElementImpl *element)
 }
 
 #ifdef APPLE_CHANGES
-// We override the baseline position to get the textfield border and padding (before  we hit
-// the font descent) taken into account.
 short RenderLineEdit::baselinePosition( bool f ) const
 {
-    return RenderWidget::baselinePosition( f ) - 4;
+    // We arbitrarily put the bottoms of line edits 2 pixels below the baseline.
+    // This looks better than trying to line up the baseline of the text inside
+    // and also matches WinIE.
+    return height() + marginTop() - 2;
 }
 #endif
 
@@ -551,6 +534,11 @@ void RenderLineEdit::calcMinMaxWidth()
 {
     KHTMLAssert( !minMaxKnown() );
 
+#ifdef APPLE_CHANGES
+    // Let the widget tell us how big it wants to be.
+    int size = element()->size();
+    QSize s(widget()->sizeForCharacterWidth(size > 0 ? size : 17));
+#else
     const QFontMetrics &fm = style()->fontMetrics();
     QSize s;
 
@@ -561,6 +549,7 @@ void RenderLineEdit::calcMinMaxWidth()
     s = QSize(w + 2 + 2*widget()->frameWidth(),
               QMAX(h, 14) + 2 + 2*widget()->frameWidth())
         .expandedTo(QApplication::globalStrut());
+#endif
 
     setIntrinsicWidth( s.width() );
     setIntrinsicHeight( s.height() );
@@ -591,18 +580,6 @@ void RenderLineEdit::updateFromElement()
     RenderFormElement::updateFromElement();
 }
 
-#ifdef APPLE_CHANGES
-void RenderLineEdit::performAction(Actions action)
-{
-    KLineEdit *edit = static_cast<KLineEdit*>(m_widget);
-
-    if (action == ACTION_TEXT_FIELD_END_EDITING)
-        slotTextChanged(edit->text());
-    else if (action == ACTION_TEXT_FIELD)
-        slotReturnPressed();
-}
-#endif /* APPLE_CHANGES */
-
 void RenderLineEdit::slotTextChanged(const QString &string)
 {
     // don't use setValue here!
@@ -911,7 +888,13 @@ void RenderSelect::updateFromElement()
 // Override to deal with our widget.
 short RenderSelect::baselinePosition( bool f ) const
 {
-    return RenderWidget::baselinePosition( f ) - 7;
+    if (!m_useListBox) {
+        // We put the bottoms of menus on the baseline,
+        // This looks better than trying to line up the button text's baseline.
+        return height() + marginTop();
+    } else {
+        return RenderWidget::baselinePosition( f ) - 7;
+    }
 }
 #endif
 
diff --git a/WebCore/khtml/rendering/render_form.h b/WebCore/khtml/rendering/render_form.h
index b4f0d4c..65f12f0 100644
--- a/WebCore/khtml/rendering/render_form.h
+++ b/WebCore/khtml/rendering/render_form.h
@@ -87,9 +87,6 @@ public:
 
     DOM::HTMLGenericFormElementImpl *element() const
     { return static_cast<DOM::HTMLGenericFormElementImpl*>(RenderObject::element()); }
-#ifdef APPLE_CHANGES
-    void performAction(QObject::Actions action);
-#endif /* APPLE_CHANGES */
 
 public slots:
     virtual void slotClicked();
@@ -141,9 +138,8 @@ public:
 
     QCheckBox *widget() const { return static_cast<QCheckBox*>(m_widget); }
 #ifdef APPLE_CHANGES
-    void performAction(QObject::Actions action);
     short baselinePosition( bool f ) const;
-#endif /* APPLE_CHANGES */
+#endif
 
 public slots:
     virtual void slotStateChanged(int state);
@@ -246,9 +242,8 @@ public:
 
     void select();
 #ifdef APPLE_CHANGES
-    void performAction(QObject::Actions action);
     short baselinePosition( bool f ) const;
-#endif /* APPLE_CHANGES */
+#endif
 
     KLineEdit *widget() const { return static_cast<KLineEdit*>(m_widget); }
     DOM::HTMLInputElementImpl* element() const
@@ -381,7 +376,7 @@ public:
     void updateSelection();
 #ifdef APPLE_CHANGES
     void performAction(QObject::Actions action);
-#endif /* APPLE_CHANGES */
+#endif
 
     DOM::HTMLSelectElementImpl *element() const
     { return static_cast<DOM::HTMLSelectElementImpl*>(RenderObject::element()); }
diff --git a/WebCore/khtml/rendering/render_table.cpp b/WebCore/khtml/rendering/render_table.cpp
index 3c48d8b..791b859 100644
--- a/WebCore/khtml/rendering/render_table.cpp
+++ b/WebCore/khtml/rendering/render_table.cpp
@@ -315,21 +315,18 @@ void RenderTable::addColumns( int num )
 
     int newCols = totalCols + num;
     // resize the col structs to the number of columns
-    // The memsets that used to be here are unnecessary, since entries
-    // are nulled out when a vector is grown (according to the Qt docs)
-    // -dwh
     columnPos.resize(newCols+1);
     memset( columnPos.data() + totalCols + 1, 0, num*sizeof(int));
     colMaxWidth.resize(newCols);
-    memset( colMaxWidth.data() + totalCols, 0, num*sizeof(int));
+    memset( colMaxWidth.data() + totalCols , 0, num*sizeof(int));
     colMinWidth.resize(newCols);
-    memset( colMinWidth.data() + totalCols, 0, num*sizeof(int));
+    memset( colMinWidth.data() + totalCols , 0, num*sizeof(int));
     colValue.resize(newCols);
-    memset( colValue.data() + totalCols, 0, num*sizeof(int));
+    memset( colValue.data() + totalCols , 0, num*sizeof(int));
     colType.resize(newCols);
-    memset( colType.data() + totalCols, 0, num*sizeof(LengthType));
+    memset( colType.data() + totalCols , 0, num*sizeof(LengthType));
     actColWidth.resize(newCols);
-    memset( actColWidth.data() + totalCols, 0, num*sizeof(LengthType));
+    memset( actColWidth.data() + totalCols , 0, num*sizeof(LengthType));
 
     for ( unsigned int r = 0; r < allocRows; r++ )
     {
@@ -459,12 +456,17 @@ void RenderTable::addColInfo(RenderTableCell *cell, bool allowRecalc)
     int _minSize = cell->minWidth();
     int _maxSize = cell->maxWidth();
 
+#if 0
+    // We do need to implement "collapse borders", but just doing this
+    // fudge on the calculation of the column widths is not enough to do so.
+    // This alone simply makes borders draw incorrectly.
     if (collapseBorders)
     {
         int bw = cell->borderLeft() + cell->borderRight();
         _minSize -= bw;
         _maxSize -= bw;
     }
+#endif
 
     Length _width = cell->style()->width();
     addColInfo(_startCol, _colSpan, _minSize, _maxSize, _width ,cell, allowRecalc);
@@ -1707,7 +1709,7 @@ void RenderTable::calcMinMaxWidth()
     KHTMLAssert( !minMaxKnown() );
 
     if ( needsCellsRecalc )
-        recalcCells();
+       recalcCells();
 #ifdef DEBUG_LAYOUT
     kdDebug( 6040 ) << renderName() << "(Table " << this << ")::calcMinMaxWidth()" <<  endl;
 #endif
@@ -1717,8 +1719,8 @@ void RenderTable::calcMinMaxWidth()
      * Max width for percent cols are still not accurate, but as they don't
      * influence the total max width of the table we don't care.
      */
-    calcColMinMax();
- 
+     calcColMinMax();
+
     setMinMaxKnown();
 #ifdef DEBUG_LAYOUT
     kdDebug( 6040 ) << renderName() << "END: (Table " << this << ")::calcMinMaxWidth() min = " << m_minWidth << " max = " << m_maxWidth <<  endl;
@@ -2116,7 +2118,7 @@ void RenderTableCell::calcMinMaxWidth()
     // nowrap is enabled on any cell in the column.  - dwh
     if(nWrap)
         m_minWidth = m_maxWidth;
-    
+
     if (m_minWidth!=oldMin || m_maxWidth!=oldMax) {
         m_table->addColInfo(this);
     }
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 914db6d..e4520a2 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -224,6 +224,9 @@ QPtrList<DocumentImpl> * DocumentImpl::changedDocuments = 0;
 // KHTMLView might be 0
 DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v)
     : NodeBaseImpl( new DocumentPtr() )
+#if APPLE_CHANGES
+    , m_finishedParsing(this, SIGNAL(finishedParsing()))
+#endif
 {
     document->doc = this;
 
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index facb218..e17acc6 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -36,6 +36,10 @@
 
 #include <kurl.h>
 
+#if APPLE_CHANGES
+#include <KWQSignal.h>
+#endif
+
 class QPaintDevice;
 class QPaintDeviceMetrics;
 class KHTMLView;
@@ -393,6 +397,11 @@ public:
 signals:
     void finishedParsing();
 
+#if APPLE_CHANGES
+public:
+    KWQSignal m_finishedParsing;
+#endif
+
 protected:
     khtml::CSSStyleSelector *m_styleSelector;
     KHTMLView *m_view;
diff --git a/WebCore/khtml/xml/xml_tokenizer.h b/WebCore/khtml/xml/xml_tokenizer.h
index bf8e3f6..3de8004 100644
--- a/WebCore/khtml/xml/xml_tokenizer.h
+++ b/WebCore/khtml/xml/xml_tokenizer.h
@@ -28,6 +28,10 @@
 #include <qobject.h>
 #include "misc/loader_client.h"
 
+#if APPLE_CHANGES
+#include <KWQSignal.h>
+#endif
+
 class KHTMLView;
 
 namespace khtml {
@@ -116,6 +120,13 @@ public:
 
 signals:
     void finishedParsing();
+
+#if APPLE_CHANGES
+public:
+    Tokenizer();
+private:
+    KWQSignal m_finishedParsing;
+#endif
 };
 
 class XMLTokenizer : public Tokenizer, public khtml::CachedObjectClient
diff --git a/WebCore/kwq/KWQButton.h b/WebCore/kwq/KWQButton.h
index 57e35b4..57da053 100644
--- a/WebCore/kwq/KWQButton.h
+++ b/WebCore/kwq/KWQButton.h
@@ -28,6 +28,7 @@
 
 #include <qwidget.h>
 #include <qstring.h>
+#include <KWQSignal.h>
     
 class QButton : public QWidget {
 public:
@@ -37,6 +38,13 @@ public:
     QString text() const;
     
     QSize sizeHint() const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
+    
+    void clicked() { m_clicked.call(); }
+
+private:
+    KWQSignal m_clicked;
 };
 
 #endif
diff --git a/WebCore/kwq/KWQButton.mm b/WebCore/kwq/KWQButton.mm
index 9e0c923..02d362e 100644
--- a/WebCore/kwq/KWQButton.mm
+++ b/WebCore/kwq/KWQButton.mm
@@ -27,24 +27,41 @@
 
 #import <KWQView.h>
 
+// We empirically determined that buttons have these extra pixels on all
+// sides. It would be better to get this info from AppKit somehow.
+#define TOP_MARGIN 4
+#define BOTTOM_MARGIN 6
+#define LEFT_MARGIN 5
+#define RIGHT_MARGIN 5
+
 QButton::QButton(QWidget *parent)
+    : m_clicked(this, SIGNAL(clicked()))
 {
-    KWQNSButton *button = [[KWQNSButton alloc] initWithFrame:NSMakeRect (0,0,0,0) widget:this];
+    KWQNSButton *button = [[KWQNSButton alloc] initWithWidget:this];
     setView(button);
     [button release];
-    
-     // Use the small system font.
-    [button setFont: [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
 }
 
 QSize QButton::sizeHint() const 
 {
     KWQNSButton *button = (KWQNSButton *)getView();
-    
-    [button sizeToFit];
-    
-    NSRect vFrame = [button frame];
-    return QSize((int)vFrame.size.width,(int)vFrame.size.height);
+    return QSize((int)[[button cell] cellSize].width - (LEFT_MARGIN + RIGHT_MARGIN),
+        (int)[[button cell] cellSize].height - (TOP_MARGIN + BOTTOM_MARGIN));
+}
+
+QRect QButton::frameGeometry() const
+{
+    QRect r = QWidget::frameGeometry();
+    return QRect(r.x() + LEFT_MARGIN, r.y() + TOP_MARGIN,
+        r.width() - (LEFT_MARGIN + RIGHT_MARGIN),
+        r.height() - (TOP_MARGIN + BOTTOM_MARGIN));
+}
+
+void QButton::setFrameGeometry(const QRect &r)
+{
+    QWidget::setFrameGeometry(QRect(r.x() - LEFT_MARGIN, r.y() - TOP_MARGIN,
+        r.width() + LEFT_MARGIN + RIGHT_MARGIN,
+        r.height() + TOP_MARGIN + BOTTOM_MARGIN));
 }
 
 void QButton::setText(const QString &s)
diff --git a/WebCore/kwq/KWQCharsets.mm b/WebCore/kwq/KWQCharsets.mm
index b1db770..6c74243 100644
--- a/WebCore/kwq/KWQCharsets.mm
+++ b/WebCore/kwq/KWQCharsets.mm
@@ -65,11 +65,6 @@ static void buildDictionaries (void)
       CFDictionarySetValue(encodingToMIB, (void *) table[i].encoding, (void *) table[i].mib);
     }
   }
-  
-  // Add special bogus entry to make UTF-16 mean UTF-8.
-  // We do this because Internet Explorere does, and because web pages say UTF-16 and mean UTF-8.
-  // See bug 2969378 and http://zingermans.com/ for a concrete example.
-  CFDictionarySetValue(nameToEncoding, CFSTR("utf-16"), (void *) kCFStringEncodingUTF8);
 }
 
 CFStringEncoding KWQCFStringEncodingFromIANACharsetName(CFStringRef charsetName)
diff --git a/WebCore/kwq/KWQCheckBox.h b/WebCore/kwq/KWQCheckBox.h
index 0a19bda..8112da4 100644
--- a/WebCore/kwq/KWQCheckBox.h
+++ b/WebCore/kwq/KWQCheckBox.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
@@ -34,6 +34,15 @@ public:
 
     void setChecked(bool);
     bool isChecked();
+
+    QSize sizeHint() const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
+
+    void stateChanged() { m_stateChanged.call(isChecked() ? 2 : 0); }
+
+private:
+    KWQSignal m_stateChanged;
 };
 
 #endif
diff --git a/WebCore/kwq/KWQCheckBox.mm b/WebCore/kwq/KWQCheckBox.mm
index 1e9453a..4d11159 100644
--- a/WebCore/kwq/KWQCheckBox.mm
+++ b/WebCore/kwq/KWQCheckBox.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
@@ -27,43 +27,38 @@
 
 #import <KWQView.h>
 
-#import <kwqdebug.h>
-
-QCheckBox::QCheckBox(QWidget *w) : QButton (w)
+QCheckBox::QCheckBox(QWidget *w)
+    : QButton(w)
+    , m_stateChanged(this, SIGNAL(stateChanged(int)))
 {
-    KWQNSButton *button;
-    
-    button = (KWQNSButton *)getView();
+    KWQNSButton *button = (KWQNSButton *)getView();
     [button setButtonType: NSSwitchButton];
-    [button setAction: @selector(stateChanged:)];
-    setView (button);
-    
-    // Use the small control size.
-    [[button cell] setControlSize: NSSmallControlSize];
+    [button setAction:@selector(stateChanged:)];
 }
 
+QSize QCheckBox::sizeHint() const 
+{
+    return QSize(22, 22);
+}
 
-void QCheckBox::setChecked(bool isChecked)
+QRect QCheckBox::frameGeometry() const
 {
-    KWQNSButton *button;
-    
-    button = (KWQNSButton *)getView();
-    if (isChecked)
-        [button setState: NSOnState];
-    else
-        [button setState: NSOffState];
+    return QWidget::frameGeometry();
 }
 
+void QCheckBox::setFrameGeometry(const QRect &r)
+{
+    QWidget::setFrameGeometry(r);
+}
 
-bool QCheckBox::isChecked()
+void QCheckBox::setChecked(bool isChecked)
 {
-    KWQNSButton *button;
-    int state;
-    
-    button = (KWQNSButton *)getView();
-    state = [button state];
-    if (state == NSOffState)
-        return 0;
-    return 1;
+    KWQNSButton *button = (KWQNSButton *)getView();
+    [button setState:isChecked ? NSOnState : NSOffState];
 }
 
+bool QCheckBox::isChecked()
+{
+    KWQNSButton *button = (KWQNSButton *)getView();
+    return [button state] == NSOnState;
+}
diff --git a/WebCore/kwq/KWQComboBox.h b/WebCore/kwq/KWQComboBox.h
index 9b5de69..ef36e1b 100644
--- a/WebCore/kwq/KWQComboBox.h
+++ b/WebCore/kwq/KWQComboBox.h
@@ -50,8 +50,11 @@ public:
     int currentItem() const;
 
     int indexOfCurrentItem();
-    virtual void setCurrentItem(int);
+    void setCurrentItem(int);
+    
     QSize sizeHint() const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
 
     NSMutableArray *items;
 
diff --git a/WebCore/kwq/KWQComboBox.mm b/WebCore/kwq/KWQComboBox.mm
index b33b4be..a29ed0d 100644
--- a/WebCore/kwq/KWQComboBox.mm
+++ b/WebCore/kwq/KWQComboBox.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,81 +22,69 @@
  * (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 <qcombobox.h>
 
 #import <KWQView.h>
 
 #import <kwqdebug.h>
 
+// We empirically determined that combo boxes have these extra pixels on all
+// sides. It would be better to get this info from AppKit somehow.
+#define TOP_MARGIN 1
+#define BOTTOM_MARGIN 3
+#define LEFT_MARGIN 3
+#define RIGHT_MARGIN 3
 
 QComboBox::QComboBox(QWidget *parent, const char *name)
 {
-    init(FALSE);
+    init(false);
 }
 
-
 QComboBox::QComboBox(bool rw, QWidget *parent, const char *name)
 {
     init(rw);
 }
 
-
 void QComboBox::init(bool isEditable)
 {
-    KWQNSComboBox *comboBox;
-    
-    comboBox = [[KWQNSComboBox alloc] initWithFrame:NSMakeRect(0,0,0,0) widget:this];
-    //if (isEditable == FALSE)
-    //    [comboBox setEditable: NO];
+    KWQNSComboBox *comboBox = [[KWQNSComboBox alloc] initWithWidget:this];
     setView(comboBox);
     [comboBox release];
     
     items = [[NSMutableArray alloc] init];
-
-    // Use the small system font.
-    [comboBox setFont: [NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
 }
 
-
 QComboBox::~QComboBox()
 {
     [items release];
 }
 
-
 int QComboBox::count() const
 {
     KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
-    
     return [comboBox numberOfItems];
 }
 
-
 QListBox *QComboBox::listBox() const
 {
-    _logNotYetImplemented();
-    return 0L;
+    return 0;
 }
 
-
 void QComboBox::popup()
 {
-    _logNotYetImplemented();
 }
 
-
 bool QComboBox::eventFilter(QObject *object, QEvent *event)
 {
     _logNotYetImplemented();
     return FALSE;
 }
 
-
 void QComboBox::insertItem(const QString &text, int index)
 {
     NSString *string;
     int numItems = [items count];
-    
     string = [text.getNSString() copy];
     if (index < 0 || index == numItems) {
         [items addObject:string];
@@ -110,22 +98,31 @@ void QComboBox::insertItem(const QString &text, int index)
     [string release];
 }
 
-
 QSize QComboBox::sizeHint() const 
 {
     KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
-    
-    [comboBox sizeToFit];
-    
-    NSRect vFrame = [comboBox frame];
-    return QSize((int)vFrame.size.width,(int)vFrame.size.height);
+    return QSize((int)[[comboBox cell] cellSize].width - (LEFT_MARGIN + RIGHT_MARGIN),
+        (int)[[comboBox cell] cellSize].height - (TOP_MARGIN + BOTTOM_MARGIN));
 }
 
+QRect QComboBox::frameGeometry() const
+{
+    QRect r = QWidget::frameGeometry();
+    return QRect(r.x() + LEFT_MARGIN, r.y() + TOP_MARGIN,
+        r.width() - (LEFT_MARGIN + RIGHT_MARGIN),
+        r.height() - (TOP_MARGIN + BOTTOM_MARGIN));
+}
+
+void QComboBox::setFrameGeometry(const QRect &r)
+{
+    QWidget::setFrameGeometry(QRect(r.x() - LEFT_MARGIN, r.y() - TOP_MARGIN,
+        r.width() + LEFT_MARGIN + RIGHT_MARGIN,
+        r.height() + TOP_MARGIN + BOTTOM_MARGIN));
+}
 
 void QComboBox::clear()
 {
     KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
-    
     [comboBox removeAllItems];
 }
 
@@ -140,16 +137,13 @@ void QComboBox::setCurrentItem(int index)
     KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
     int num = [comboBox numberOfItems];
     if (num != 0 && index < num)
-        [comboBox selectItemAtIndex: index];
+        [comboBox selectItemAtIndex:index];
     else
-        KWQDEBUG ("Error, index = %d, numberOfItems = %d", index, num);
+        KWQDEBUG("Error, index = %d, numberOfItems = %d", index, num);
 }
 
 int QComboBox::currentItem() const
 {
     KWQNSComboBox *comboBox = (KWQNSComboBox *)getView();
-
     return [comboBox indexOfSelectedItem];
 }
-
-
diff --git a/WebCore/kwq/KWQKHTMLPart.mm b/WebCore/kwq/KWQKHTMLPart.mm
index 40b1fa9..328af61 100644
--- a/WebCore/kwq/KWQKHTMLPart.mm
+++ b/WebCore/kwq/KWQKHTMLPart.mm
@@ -49,6 +49,8 @@ using khtml::RenderPart;
 using khtml::RenderText;
 using khtml::RenderWidget;
 
+using KIO::Job;
+
 using KParts::URLArgs;
 
 void KHTMLPart::onURL(const QString &)
@@ -70,22 +72,36 @@ static void redirectionTimerMonitor(void *context)
     impl->redirectionTimerStartedOrStopped();
 }
 
-void KHTMLPart::completed()
+void KHTMLPart::started(Job *j)
 {
+    KWQObjectSenderScope senderScope(this);
+    
     if (parentPart()) {
-	KWQ_ASSERT(parentPart()->frame(this));
-	parentPart()->frame(this)->m_bCompleted = true;
-	parentPart()->slotChildCompleted();
+	parentPart()->slotChildStarted(j);
     }
 }
 
+void KHTMLPart::completed()
+{
+    completed(false);
+}
+
 void KHTMLPart::completed(bool arg)
 {
+    KWQObjectSenderScope senderScope(this);
+    
     if (parentPart()) {
-	KWQ_ASSERT(parentPart()->frame(this));
-	parentPart()->frame(this)->m_bCompleted = true;
 	parentPart()->slotChildCompleted(arg);
     }
+    
+    QValueList<ChildFrame>::ConstIterator it = d->m_frames.begin();
+    QValueList<ChildFrame>::ConstIterator end = d->m_frames.end();
+    for (; it != end; ++it ) {
+        KHTMLPart *part = dynamic_cast<KHTMLPart *>((*it).m_part.pointer());
+        if (part) {
+            part->slotParentCompleted();
+        }
+    }
 }
 
 KWQKHTMLPartImpl::KWQKHTMLPartImpl(KHTMLPart *p)
@@ -515,4 +531,3 @@ RenderObject *KWQKHTMLPartImpl::getRenderer()
     DocumentImpl *doc = part->xmlDocImpl();
     return doc ? doc->renderer() : 0;
 }
-
diff --git a/WebCore/kwq/KWQKHTMLPartImpl.mm b/WebCore/kwq/KWQKHTMLPartImpl.mm
index 40b1fa9..328af61 100644
--- a/WebCore/kwq/KWQKHTMLPartImpl.mm
+++ b/WebCore/kwq/KWQKHTMLPartImpl.mm
@@ -49,6 +49,8 @@ using khtml::RenderPart;
 using khtml::RenderText;
 using khtml::RenderWidget;
 
+using KIO::Job;
+
 using KParts::URLArgs;
 
 void KHTMLPart::onURL(const QString &)
@@ -70,22 +72,36 @@ static void redirectionTimerMonitor(void *context)
     impl->redirectionTimerStartedOrStopped();
 }
 
-void KHTMLPart::completed()
+void KHTMLPart::started(Job *j)
 {
+    KWQObjectSenderScope senderScope(this);
+    
     if (parentPart()) {
-	KWQ_ASSERT(parentPart()->frame(this));
-	parentPart()->frame(this)->m_bCompleted = true;
-	parentPart()->slotChildCompleted();
+	parentPart()->slotChildStarted(j);
     }
 }
 
+void KHTMLPart::completed()
+{
+    completed(false);
+}
+
 void KHTMLPart::completed(bool arg)
 {
+    KWQObjectSenderScope senderScope(this);
+    
     if (parentPart()) {
-	KWQ_ASSERT(parentPart()->frame(this));
-	parentPart()->frame(this)->m_bCompleted = true;
 	parentPart()->slotChildCompleted(arg);
     }
+    
+    QValueList<ChildFrame>::ConstIterator it = d->m_frames.begin();
+    QValueList<ChildFrame>::ConstIterator end = d->m_frames.end();
+    for (; it != end; ++it ) {
+        KHTMLPart *part = dynamic_cast<KHTMLPart *>((*it).m_part.pointer());
+        if (part) {
+            part->slotParentCompleted();
+        }
+    }
 }
 
 KWQKHTMLPartImpl::KWQKHTMLPartImpl(KHTMLPart *p)
@@ -515,4 +531,3 @@ RenderObject *KWQKHTMLPartImpl::getRenderer()
     DocumentImpl *doc = part->xmlDocImpl();
     return doc ? doc->renderer() : 0;
 }
-
diff --git a/WebCore/kwq/KWQLineEdit.h b/WebCore/kwq/KWQLineEdit.h
index 45f1d54..aa789f6 100644
--- a/WebCore/kwq/KWQLineEdit.h
+++ b/WebCore/kwq/KWQLineEdit.h
@@ -29,6 +29,7 @@
 #include <qwidget.h>
 #include <qevent.h>
 #include <qstring.h>
+#include <KWQSignal.h>
 
 class QLineEdit : public QWidget {
 public:
@@ -52,6 +53,17 @@ public:
     void setEdited(bool);
     
     void setFont(const QFont &font);
+    
+    QSize sizeForCharacterWidth(int numCharacters) const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
+    
+    void returnPressed() { m_returnPressed.call(); }
+    void textChanged() { m_textChanged.call(text()); }
+
+private:
+    KWQSignal m_returnPressed;
+    KWQSignal m_textChanged;
 };
 
 #endif
diff --git a/WebCore/kwq/KWQLineEdit.mm b/WebCore/kwq/KWQLineEdit.mm
index 61c08b5..968db77 100644
--- a/WebCore/kwq/KWQLineEdit.mm
+++ b/WebCore/kwq/KWQLineEdit.mm
@@ -30,8 +30,10 @@
 #import <WebCoreTextRendererFactory.h>
 
 QLineEdit::QLineEdit(QWidget *parent)
+    : m_returnPressed(this, SIGNAL(returnPressed()))
+    , m_textChanged(this, SIGNAL(textChanged(const QString &)))
 {
-    NSView *view = [[KWQNSTextField alloc] initWithFrame:NSMakeRect(0,0,0,0) widget:this];
+    NSView *view = [[KWQNSTextField alloc] initWithWidget:this];
     setView(view);
     [view release];
 }
@@ -57,10 +59,10 @@ void QLineEdit::setFont(const QFont &font)
 {
     QWidget::setFont(font);
     KWQNSTextField *textField = (KWQNSTextField *)getView();
-    [textField setFont: [[WebCoreTextRendererFactory sharedFactory] 
-            fontWithFamily: font.getNSFamily()
-            traits: font.getNSTraits() 
-            size: font.getNSSize()]];
+    [textField setFont:[[WebCoreTextRendererFactory sharedFactory] 
+        fontWithFamily:font.getNSFamily()
+                traits:font.getNSTraits() 
+                  size:font.getNSSize()]];
 }
 
 void QLineEdit::setText(const QString &s)
@@ -122,3 +124,35 @@ void QLineEdit::setEdited(bool flag)
     KWQNSTextField *textField = (KWQNSTextField *)getView();
     return [textField setEdited:flag];
 }
+
+QSize QLineEdit::sizeForCharacterWidth(int numCharacters) const
+{
+    NSMutableString *nominalWidthString = [NSMutableString stringWithCapacity:numCharacters];
+    for (int i = 0; i < numCharacters; ++i) {
+        [nominalWidthString appendString:@"x"];
+    }
+        
+    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    NSString *value = [textField stringValue];
+    [textField setStringValue:nominalWidthString];
+    NSSize size = [[textField cell] cellSize];
+    [textField setStringValue:value];
+    
+    size.width -= FOCUS_BORDER_SIZE * 2;
+    size.height -= FOCUS_BORDER_SIZE * 2;
+    
+    return QSize(size);
+}
+
+QRect QLineEdit::frameGeometry() const
+{
+    QRect r = QWidget::frameGeometry();
+    return QRect(r.x() + FOCUS_BORDER_SIZE, r.y() + FOCUS_BORDER_SIZE,
+        r.width() - FOCUS_BORDER_SIZE * 2, r.height() - FOCUS_BORDER_SIZE * 2);
+}
+
+void QLineEdit::setFrameGeometry(const QRect &r)
+{
+    QWidget::setFrameGeometry(QRect(r.x() - FOCUS_BORDER_SIZE, r.y() - FOCUS_BORDER_SIZE,
+        r.width() + FOCUS_BORDER_SIZE * 2, r.height() + FOCUS_BORDER_SIZE * 2));
+}
diff --git a/WebCore/kwq/KWQNSTextField.h b/WebCore/kwq/KWQNSTextField.h
index 17b1c43..ee906c7 100644
--- a/WebCore/kwq/KWQNSTextField.h
+++ b/WebCore/kwq/KWQNSTextField.h
@@ -22,44 +22,31 @@
  * (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 <Cocoa/Cocoa.h>
 
 class QWidget;
 
- at interface KWQNSTextFieldFormatter : NSFormatter
-{
-    int maxLength;
-    bool isPassword;
-}
-
-- (void)setPasswordMode: (bool)flag;
-- (bool)passwordMode;
-- (void)setMaximumLength: (int)len;
-- (int)maximumLength;
-- (NSString *)stringForObjectValue:(id)anObject;
-- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString  **)error;
-- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error;
-- (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes;
+ at class KWQTextFieldFormatter;
 
- at end
+#define FOCUS_BORDER_SIZE 3
 
 @interface KWQNSTextField : NSTextField
 {
 @private
-    NSSecureTextField *secureField;
+    NSTextField *secureField;
     QWidget *widget;
-    KWQNSTextFieldFormatter *formatter;
-    bool edited;
+    KWQTextFieldFormatter *formatter;
+    BOOL edited;
 }
 
-- initWithFrame: (NSRect)r widget: (QWidget *)w;
-- (KWQNSTextFieldFormatter *)formatter;
-- (void)setPasswordMode: (bool)flag;
-- (bool)passwordMode;
-- (void)setMaximumLength: (int)len;
+- initWithWidget:(QWidget *)widget;
+
+- (void)setPasswordMode:(BOOL)flag;
+- (BOOL)passwordMode;
+- (void)setMaximumLength:(int)len;
 - (int)maximumLength;
-- (bool)edited;
-- (void)setEdited:(bool)ed;
+- (BOOL)edited;
+- (void)setEdited:(BOOL)edited;
 
 @end
-
diff --git a/WebCore/kwq/KWQNSTextField.mm b/WebCore/kwq/KWQNSTextField.mm
index 792bbfe..c04ab8b 100644
--- a/WebCore/kwq/KWQNSTextField.mm
+++ b/WebCore/kwq/KWQNSTextField.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,205 +22,272 @@
  * (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 <qwidget.h>
 
 #import <KWQNSTextField.h>
 
+#import <qlineedit.h>
+
+// KWQTextFieldCell is larger than a normal text field cell, so it includes
+// the focus border as well as the rest of the text field.
+
+ at interface KWQTextFieldCell : NSTextFieldCell
+{
+}
+ at end
+
+// KWQTextFieldFormatter enforces a maximum length.
+
+ at interface KWQTextFieldFormatter : NSFormatter
+{
+    int maxLength;
+}
+
+- (void)setMaximumLength:(int)len;
+- (int)maximumLength;
+
+ at end
+
+// KWQSecureTextField is a workaround for bug 3024443.
+
+ at interface KWQSecureTextField : NSSecureTextField
+{
+    BOOL inSetFrameSize;
+}
+ at end
 
 @implementation KWQNSTextField
 
-- initWithFrame: (NSRect) r widget: (QWidget *)w 
++ (void)initialize
 {
-    [super initWithFrame: r];
-    formatter = [[KWQNSTextFieldFormatter alloc] init];
-    [self setFormatter: formatter];
-    widget = w;
+    if (self == [KWQNSTextField class]) {
+        [self setCellClass:[KWQTextFieldCell class]];
+    }
+}
 
-    [self setTarget: self];
-    [self setAction: @selector(action:)];
+- initWithFrame:(NSRect)frame
+{
+    [super initWithFrame:frame];
+    
+    formatter = [[KWQTextFieldFormatter alloc] init];
+    [self setFormatter:formatter];
+
+    [self setTarget:self];
+    [self setAction:@selector(action:)];
 
-    [self setDelegate: self];
+    [self setDelegate:self];
 
-    [[self cell] setScrollable: YES];
+    [[self cell] setScrollable:YES];
     
     return self;
 }
 
-- (void)action: sender
+- initWithWidget:(QWidget *)w 
+{
+    [super init];
+    widget = w;
+    return self;
+}
+
+- (void)action:sender
 {
-    if (widget)
-        widget->emitAction(QObject::ACTION_TEXT_FIELD);
+    QLineEdit *edit = dynamic_cast<QLineEdit *>(widget);
+    if (edit) {
+        edit->returnPressed();
+    }
 }
 
 - (void)controlTextDidEndEditing:(NSNotification *)aNotification
 {
-    if (widget)
-        widget->emitAction(QObject::ACTION_TEXT_FIELD_END_EDITING);
+    QLineEdit *edit = dynamic_cast<QLineEdit *>(widget);
+    if (edit) {
+        edit->textChanged();
+    }
 }
 
 - (void)dealloc
 {
+    [secureField release];
     [formatter release];
     [super dealloc];
 }
 
-
-- (KWQNSTextFieldFormatter *)formatter
+- (KWQTextFieldFormatter *)formatter
 {
     return formatter;
 }
 
+- (void)updateSecureFieldFrame
+{
+    [secureField setFrame:NSInsetRect([self bounds], FOCUS_BORDER_SIZE, FOCUS_BORDER_SIZE)];
+}
+
+- (void)setFrameSize:(NSSize)size
+{
+    [super setFrameSize:size];
+    [self updateSecureFieldFrame];
+}
 
-- (void)setPasswordMode: (bool)flag
+- (void)setPasswordMode:(BOOL)flag
 {
-    if (flag != [formatter passwordMode]){
-        if (flag == NO){
-            [self setStringValue: @""];
-            [secureField removeFromSuperview];
-        } else {
-            if (secureField == nil){
-                secureField = [[NSSecureTextField alloc] initWithFrame: [self bounds]];
-                [secureField setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
-                [secureField setFormatter: formatter];
-            } else {
-                [secureField setBounds: [self bounds]];
-            }
-            [secureField setStringValue: @""];
+    if (!flag == ![secureField superview]) {
+        return;
+    }
+    
+    [self setStringValue:@""];
+    if (!flag) {
+        [secureField removeFromSuperview];
+    } else {
+        if (secureField == nil) {
+            secureField = [[KWQSecureTextField alloc] init];
             [secureField setDelegate:self];
-            [self addSubview: secureField];
+            [secureField setFormatter:formatter];
+            [secureField setFont:[self font]];
+            [self updateSecureFieldFrame];
         }
-        [formatter setPasswordMode: flag];
+        [self addSubview:secureField];
     }
+    [self setStringValue:@""];
 }
 
-
 - (void)setEditable:(BOOL)flag
 {
-    if (secureField != nil)
-        [secureField setEditable: flag];
-    [super setEditable: flag];
+    [secureField setEditable:flag];
+    [super setEditable:flag];
 }
 
-
 - (void)selectText:(id)sender
 {
-    if ([self passwordMode])
-        [secureField selectText: sender];
+    if ([self passwordMode]) {
+        [secureField selectText:sender];
+        return;
+    }
+    [super selectText:sender];
 }
 
-
 - (BOOL)isEditable
 {
     return [super isEditable];
 }
 
-
-- (bool)passwordMode
+- (BOOL)passwordMode
 {
-    return [formatter passwordMode];
+    return [secureField superview] != nil;
 }
 
-
-- (void)setMaximumLength: (int)len
+- (void)setMaximumLength:(int)len
 {
-    NSString *oldValue, *truncatedValue;
-    
-    oldValue = [self stringValue];
+    NSString *oldValue = [self stringValue];
     if ((int)[oldValue length] > len){
-        truncatedValue = [oldValue substringToIndex: len];
-        [self setStringValue: truncatedValue];
-        [secureField setStringValue: truncatedValue];
+        [self setStringValue:[oldValue substringToIndex:len]];
     }
-    [formatter setMaximumLength: len];
+    [formatter setMaximumLength:len];
 }
 
-
 - (int)maximumLength
 {
     return [formatter maximumLength];
 }
 
-
-- (bool)edited
+- (BOOL)edited
 {
     return edited;
 }
 
-- (void)setEdited:(bool)ed
+- (void)setEdited:(BOOL)ed
 {
     edited = ed;
 }
 
--(void)textDidChange:(NSNotification *)aNotification
+- (void)textDidChange:(NSNotification *)aNotification
 {
     edited = true;
 }
 
--(NSString *)stringValue
+- (NSString *)stringValue
 {
-    NSString *result;
-    
-    if ([self passwordMode]) {
-        result = [secureField stringValue];
-    }
-    else {
-        result = [super stringValue];
+    if ([secureField superview]) {
+        return [secureField stringValue];
     }
+    return [super stringValue];
+}
+
+- (void)setStringValue:(NSString *)string
+{
+    [secureField setStringValue:string];
+    [super setStringValue:string];
+}
 
-    return result;
+- (void)setFont:(NSFont *)font
+{
+    [secureField setFont:font];
+    [super setFont:font];
 }
 
 @end
 
+// This cell is used so that our frame includes the place where the focus rectangle is drawn.
+// If that makes the widget too big for layout, we'll account for that at the QWidget level.
 
- at implementation KWQNSTextFieldFormatter
+ at implementation KWQTextFieldCell
 
-- init {
-    maxLength = 2147483647;
-    isPassword = NO;
-    return [super init];
+- (NSSize)cellSizeForBounds:(NSRect)bounds
+{
+    NSSize size = [super cellSizeForBounds:bounds];
+    size.width += FOCUS_BORDER_SIZE * 2;
+    size.height += FOCUS_BORDER_SIZE * 2;
+    return size;
 }
 
-- (void)setPasswordMode: (bool)flag
+- (void)drawWithFrame:(NSRect)frame inView:(NSView *)view
 {
-    isPassword = flag;
+    [super drawWithFrame:NSInsetRect(frame, FOCUS_BORDER_SIZE, FOCUS_BORDER_SIZE) inView:view];
 }
 
+- (void)editWithFrame:(NSRect)frame inView:(NSView *)view editor:(NSText *)editor delegate:(id)delegate event:(NSEvent *)event
+{
+    [super editWithFrame:NSInsetRect(frame, FOCUS_BORDER_SIZE, FOCUS_BORDER_SIZE) inView:view editor:editor delegate:delegate event:event];
+}
 
-- (bool)passwordMode
+- (void)selectWithFrame:(NSRect)frame inView:(NSView *)view editor:(NSText *)editor delegate:(id)delegate start:(int)start length:(int)length
 {
-    return isPassword;
+    [super selectWithFrame:NSInsetRect(frame, FOCUS_BORDER_SIZE, FOCUS_BORDER_SIZE) inView:view editor:editor delegate:delegate start:start length:length];
 }
 
+ at end
+
+ at implementation KWQTextFieldFormatter
 
-- (void)setMaximumLength: (int)len
+- init
 {
-    maxLength = len;
+    [super init];
+    maxLength = INT_MAX;
+    return self;
 }
 
+- (void)setMaximumLength:(int)len
+{
+    maxLength = len;
+}
 
 - (int)maximumLength
 {
     return maxLength;
 }
 
-
-- (NSString *)stringForObjectValue:(id)anObject
+- (NSString *)stringForObjectValue:(id)object
 {
-    return (NSString *)anObject;
+    return (NSString *)object;
 }
 
-
-- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString  **)error
+- (BOOL)getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error
 {
-    *obj = string;
+    *object = string;
     return YES;
 }
 
-
 - (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
 {
-    if ((int)[partialString length] > maxLength){
+    if ((int)[partialString length] > maxLength) {
         *newString = nil;
         return NO;
     }
@@ -228,13 +295,28 @@
     return YES;
 }
 
-
 - (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes
 {
     return nil;
 }
 
+ at end
 
+ at implementation KWQSecureTextField
 
- at end
+- (void)selectText:(id)sender
+{
+    if (sender == self && inSetFrameSize) {
+        return;
+    }
+    [super selectText:sender];
+}
 
+- (void)setFrameSize:(NSSize)size
+{
+    inSetFrameSize = YES;
+    [super setFrameSize:size];
+    inSetFrameSize = NO;
+}
+
+ at end
diff --git a/WebCore/kwq/KWQObject.h b/WebCore/kwq/KWQObject.h
index da9a0ea..3617bfc 100644
--- a/WebCore/kwq/KWQObject.h
+++ b/WebCore/kwq/KWQObject.h
@@ -70,21 +70,8 @@ class QObject : public Qt {
 public:
 
     enum Actions {
-        // Standard button action, maps to RenderFormElement::slotClicked
-        ACTION_BUTTON_CLICKED = 1,
-        
-        // Checkbox button action, maps to RenderCheckBox::slotStateChanged
-        ACTION_CHECKBOX_CLICKED = 2,
-        
-        // Text field actions, map to RenderLineEdit::slotReturnPressed and
-        // RenderLineEdit::slotTextChanged
-        ACTION_TEXT_FIELD = 3,  // corresponds to [NSTextField action]
-        ACTION_TEXT_FIELD_END_EDITING = 4, // corresponds to NSTextField's delegate textDidEndEditing:
-
-        ACTION_TEXT_AREA_END_EDITING = 5,
-        
+        ACTION_TEXT_AREA_END_EDITING = 5,        
         ACTION_LISTBOX_CLICKED = 6,
-        
         ACTION_COMBOBOX_CLICKED = 7
     };
 
@@ -113,6 +100,8 @@ public:
 
     void emitAction(Actions action);
     virtual void performAction(Actions action);
+    
+    static const QObject *sender() { return m_sender; }
 
 private:
     // no copying or assignment
@@ -125,9 +114,22 @@ private:
     QPtrList<QObject> guardedPtrDummyList;
     mutable KWQSignal *m_signalListHead;
     bool m_signalsBlocked;
+    
+    static const QObject *m_sender;
 
     friend class KWQGuardedPtrBase;
     friend class KWQSignal;
+    friend class KWQObjectSenderScope;
+};
+
+class KWQObjectSenderScope
+{
+public:
+    KWQObjectSenderScope(const QObject *);
+    ~KWQObjectSenderScope();
+
+private:
+    const QObject *m_savedSender;
 };
 
 #endif
diff --git a/WebCore/kwq/KWQObject.mm b/WebCore/kwq/KWQObject.mm
index 2561c12..2b1aacf 100644
--- a/WebCore/kwq/KWQObject.mm
+++ b/WebCore/kwq/KWQObject.mm
@@ -29,6 +29,9 @@
 #import <qguardedptr.h>
 #import <kwqdebug.h>
 #import <KWQSignal.h>
+#import <KWQSlot.h>
+
+const QObject *QObject::m_sender;
 
 KWQSignal *QObject::findSignal(const char *signalName) const
 {
@@ -43,8 +46,9 @@ KWQSignal *QObject::findSignal(const char *signalName) const
 void QObject::connect(const QObject *sender, const char *signalName, const QObject *receiver, const char *member)
 {
     // FIXME: Assert that sender is not NULL rather than doing the if statement.
-    if (!sender)
+    if (!sender) {
         return;
+    }
     
     // FIXME: Do away with this after we change clients to use the KWQSignal scheme.
     sender->target = const_cast<QObject *>(receiver);
@@ -71,6 +75,17 @@ void QObject::disconnect(const QObject *sender, const char *signalName, const QO
     signal->disconnect(KWQSlot(const_cast<QObject *>(receiver), member));
 }
 
+KWQObjectSenderScope::KWQObjectSenderScope(const QObject *o)
+    : m_savedSender(QObject::m_sender)
+{
+    QObject::m_sender = o;
+}
+
+KWQObjectSenderScope::~KWQObjectSenderScope()
+{
+    QObject::m_sender = m_savedSender;
+}
+
 void QObject::emitAction(QObject::Actions action)
 {
     if (target)
diff --git a/WebCore/kwq/KWQPoint.mm b/WebCore/kwq/KWQPoint.mm
index eccaf24..4c838c1 100644
--- a/WebCore/kwq/KWQPoint.mm
+++ b/WebCore/kwq/KWQPoint.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
@@ -33,11 +33,20 @@ QPoint::QPoint(int xIn, int yIn) : xCoord(xIn), yCoord(yIn)
 {
 }
 
+QPoint::QPoint(const NSPoint &p) : xCoord((int)p.x), yCoord((int)p.y)
+{
+}
+
 int QPoint::manhattanLength() const
 {
     return abs(xCoord) + abs(yCoord);
 }
 
+QPoint::operator NSPoint() const
+{
+    return NSMakePoint(xCoord, yCoord);
+}
+
 QPoint operator+(const QPoint &a, const QPoint &b)
 {
     return QPoint(a.xCoord + b.xCoord, a.yCoord + b.yCoord);
diff --git a/WebCore/kwq/KWQPointArray.h b/WebCore/kwq/KWQPointArray.h
index 38c96d7..191679c 100644
--- a/WebCore/kwq/KWQPointArray.h
+++ b/WebCore/kwq/KWQPointArray.h
@@ -34,11 +34,13 @@
 
 #include "qarray.h"
 
+typedef struct _NSPoint NSPoint;
+
 class QPoint {
 public:
-
     QPoint();
     QPoint(int, int);
+    explicit QPoint(const NSPoint &); // don't do this implicitly since it's lossy
 
     int x() const { return xCoord; }
     int y() const { return yCoord; }
@@ -47,25 +49,24 @@ public:
     
     friend QPoint operator+(const QPoint &, const QPoint &);
     friend QPoint operator-(const QPoint &, const QPoint &);
+    
+    operator NSPoint() const;
 
 private:
-
     int xCoord;
     int yCoord;
-
 };
 
 class QPointArray : public QMemArray<QPoint> {
 public:
-
-    QPointArray() {}
-    QPointArray(int size) : QMemArray<QPoint>(size) {}
+    QPointArray() { }
+    QPointArray(int size) : QMemArray<QPoint>(size) { }
 
     QPointArray(int, const int *);
 
     void setPoint(uint, int, int);
 #if 0
-    // FIXME: Workaround for Radar 2921061
+    // FIXME: Workaround for Radar 2921061.
     bool setPoints(int, int, int, ...);
 #else
     bool setPoints(int, int, int, int, int, int, int, int, int);
diff --git a/WebCore/kwq/KWQPushButton.h b/WebCore/kwq/KWQPushButton.h
index 997ccd7..292cfe7 100644
--- a/WebCore/kwq/KWQPushButton.h
+++ b/WebCore/kwq/KWQPushButton.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
@@ -27,17 +27,11 @@
 #define QPUSHBUTTON_H_
 
 #include <qbutton.h>
-#include <qwidget.h>
-#include <qstring.h>
 
 class QPushButton : public QButton {
 public:
     QPushButton(QWidget *w) : QButton(w) { }
     QPushButton(const QString &text, QWidget *parent);
-    
-    // This could be in QWidget, but if we put it here we don't need a
-    // fully general implementation, and it's currently used only for this case.
-    QFontMetrics fontMetrics() const;
 };
 
 #endif
diff --git a/WebCore/kwq/KWQPushButton.mm b/WebCore/kwq/KWQPushButton.mm
index 2e4da68..f9f7cf4 100644
--- a/WebCore/kwq/KWQPushButton.mm
+++ b/WebCore/kwq/KWQPushButton.mm
@@ -29,19 +29,3 @@ QPushButton::QPushButton(const QString &text, QWidget *parent) : QButton(parent)
 {
     setText(text);
 }
-
-static QFontMetrics buttonFontMetrics()
-{
-    NSFont *nsfont = [NSFont systemFontOfSize:13];
-    QFont font;
-    font.setFamily(QString::fromNSString([nsfont familyName]));
-    font.setPixelSize(13);
-    return font;
-}
-
-QFontMetrics QPushButton::fontMetrics() const
-{
-    // Buttons use the system font at 13 point, not the font from the widget.
-    static QFontMetrics metrics = buttonFontMetrics();
-    return metrics;
-}
diff --git a/WebCore/kwq/KWQRadioButton.h b/WebCore/kwq/KWQRadioButton.h
index 2ac9e86..c53be3a 100644
--- a/WebCore/kwq/KWQRadioButton.h
+++ b/WebCore/kwq/KWQRadioButton.h
@@ -34,7 +34,10 @@ public:
 
     void setChecked(bool);
     bool isChecked() const;
+
+    QSize sizeHint() const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
 };
 
 #endif
-
diff --git a/WebCore/kwq/KWQRadioButton.mm b/WebCore/kwq/KWQRadioButton.mm
index b79b61d..b9b776a 100644
--- a/WebCore/kwq/KWQRadioButton.mm
+++ b/WebCore/kwq/KWQRadioButton.mm
@@ -31,11 +31,21 @@ QRadioButton::QRadioButton(QWidget *w) : QButton(w)
 {
     KWQNSButton *button = (KWQNSButton *)getView();
     [button setButtonType: NSRadioButton];
-    
-    // Use the small control size.
-    [[button cell] setControlSize: NSSmallControlSize];
-    
-    [button sizeToFit];
+}
+
+QSize QRadioButton::sizeHint() const 
+{
+    return QSize(22, 22);
+}
+
+QRect QRadioButton::frameGeometry() const
+{
+    return QWidget::frameGeometry();
+}
+
+void QRadioButton::setFrameGeometry(const QRect &r)
+{
+    QWidget::setFrameGeometry(r);
 }
 
 void QRadioButton::setChecked(bool isChecked)
diff --git a/WebCore/kwq/KWQRect.h b/WebCore/kwq/KWQRect.h
index 8ef3256..8ae969b 100644
--- a/WebCore/kwq/KWQRect.h
+++ b/WebCore/kwq/KWQRect.h
@@ -29,11 +29,14 @@
 #include <qsize.h>
 #include <qpoint.h>
 
+typedef struct _NSRect NSRect;
+
 class QRect {
 public:
     QRect();
     QRect(QPoint p, QSize s);
     QRect(int, int, int, int);
+    explicit QRect(const NSRect &); // don't do this implicitly since it's lossy
 
     bool isNull() const;
     bool isValid() const;
@@ -58,6 +61,8 @@ public:
     
     inline QRect operator&(const QRect &r) const { return intersect(r); }
 
+    operator NSRect() const;
+
 #ifdef _KWQ_IOSTREAM_
     friend std::ostream &operator<<(std::ostream &, const QRect &);
 #endif
diff --git a/WebCore/kwq/KWQRect.mm b/WebCore/kwq/KWQRect.mm
index 1712cc4..2932433 100644
--- a/WebCore/kwq/KWQRect.mm
+++ b/WebCore/kwq/KWQRect.mm
@@ -42,6 +42,10 @@ QRect::QRect(QPoint p, QSize s) : xp(p.x()), yp(p.y()), w(s.width()), h(s.height
 {
 }
 
+QRect::QRect(const NSRect &r) : xp((int)r.origin.x), yp((int)r.origin.y), w((int)r.size.width), h((int)r.size.height)
+{
+}
+
 bool QRect::isNull() const
 {
     return w == 0 && h == 0;
@@ -54,7 +58,7 @@ bool QRect::isValid() const
 
 bool QRect::isEmpty() const
 {
-    return w > 1 && h > 1;
+    return w <= 0 || h <= 0;
 }
 
 int QRect::right() const
@@ -126,6 +130,11 @@ QRect QRect::intersect(const QRect &r) const
     return QRect(nx, ny, nw, nh);
 }
 
+QRect::operator NSRect() const
+{
+    return NSMakeRect(xp, yp, w, h);
+}
+
 bool operator==(const QRect &a, const QRect &b)
 {
     return a.xp == b.xp && a.yp == b.yp && a.w == b.w && a.h == b.h;
diff --git a/WebCore/kwq/KWQRegion.mm b/WebCore/kwq/KWQRegion.mm
index e206c7c..cac8b7c 100644
--- a/WebCore/kwq/KWQRegion.mm
+++ b/WebCore/kwq/KWQRegion.mm
@@ -27,38 +27,13 @@
 
 #import <kwqdebug.h>
 
-// FIXME: Find some header to put these inline functions in, because they are widely useful.
-
-inline NSPoint NSMakePoint(const QPoint &qp)
-{
-    NSPoint p;
-    p.x = qp.x();
-    p.y = qp.y();
-    return p;
-}
-
-inline NSRect NSMakeRect(const QRect &qr)
-{
-    NSRect r;
-    r.origin.x = qr.x();
-    r.origin.y = qr.y();
-    r.size.width = qr.width();
-    r.size.height = qr.height();
-    return r;
-}
-
-inline QRect MakeQRect(const NSRect &r)
-{
-    return QRect((int)r.origin.x, (int)r.origin.y, (int)r.size.width, (int)r.size.height);
-}
-
 QRegion::QRegion()
     : paths([[NSArray alloc] init])
 {
 }
 
 QRegion::QRegion(const QRect &rect)
-    : paths([[NSArray arrayWithObject:[NSBezierPath bezierPathWithRect:NSMakeRect(rect)]] retain])
+    : paths([[NSArray arrayWithObject:[NSBezierPath bezierPathWithRect:rect]] retain])
 {
 }
 
@@ -74,9 +49,9 @@ QRegion::QRegion(int x, int y, int w, int h, RegionType t)
 QRegion::QRegion(const QPointArray &arr)
 {
     NSBezierPath *path = [[NSBezierPath alloc] init];
-    [path moveToPoint:NSMakePoint(arr[0])];
+    [path moveToPoint:arr[0]];
     for (uint i = 1; i < arr.count(); ++i) {
-        [path lineToPoint:NSMakePoint(arr[i])];
+        [path lineToPoint:arr[i]];
     }
     paths = [[NSArray arrayWithObject:path] retain];
     [path release];
@@ -119,7 +94,7 @@ bool QRegion::contains(const QPoint &point) const
     NSEnumerator *e = [paths objectEnumerator];
     NSBezierPath *path;
     while ((path = [e nextObject])) {
-        if (![path containsPoint:NSMakePoint(point.x(), point.y())]) {
+        if (![path containsPoint:point]) {
             return false;
         }
     }
@@ -167,7 +142,7 @@ QRect QRegion::boundingRect() const
     while ((path = [e nextObject])) {
         bounds = NSIntersectionRect(bounds, [path bounds]);
     }
-    return MakeQRect(bounds);
+    return QRect(bounds);
 }
 
 void QRegion::setClip() const
diff --git a/WebCore/kwq/KWQScrollView.mm b/WebCore/kwq/KWQScrollView.mm
index cbcfb25..8c1fdae 100644
--- a/WebCore/kwq/KWQScrollView.mm
+++ b/WebCore/kwq/KWQScrollView.mm
@@ -204,7 +204,7 @@ void QScrollView::addChild(QWidget* child, int x, int y)
 
     // It's a bit of a hack, but when we are asked to add the widget for the top level of
     // a frame, we need to instead add the containing frame widget. See also the similar
-    // code in QWidget::internalSetGeometry.
+    // code in QWidget::setFrameGeometry.
     if ([subview conformsToProtocol:@protocol(WebCoreFrameView)]) {
         subview = [subview superview];
     }
diff --git a/WebCore/kwq/KWQSignal.h b/WebCore/kwq/KWQSignal.h
index c1a3c7a..0943095 100644
--- a/WebCore/kwq/KWQSignal.h
+++ b/WebCore/kwq/KWQSignal.h
@@ -37,6 +37,8 @@ public:
     void disconnect(const KWQSlot &);
     
     void call() const; // should be "emit"; can't be due to define in qobject.h
+    void call(int) const;
+    void call(const QString &) const;
 
 private:
     // forbid copying and assignment
diff --git a/WebCore/kwq/KWQSignal.mm b/WebCore/kwq/KWQSignal.mm
index 36c9370..9babbfb 100644
--- a/WebCore/kwq/KWQSignal.mm
+++ b/WebCore/kwq/KWQSignal.mm
@@ -67,6 +67,23 @@ void KWQSignal::disconnect(const KWQSlot &slot)
 void KWQSignal::call() const
 {
     if (!m_object->m_signalsBlocked) {
+        KWQObjectSenderScope senderScope(m_object);
         m_slot.call();
     }
 }
+
+void KWQSignal::call(int i) const
+{
+    if (!m_object->m_signalsBlocked) {
+        KWQObjectSenderScope senderScope(m_object);
+        m_slot.call(i);
+    }
+}
+
+void KWQSignal::call(const QString &s) const
+{
+    if (!m_object->m_signalsBlocked) {
+        KWQObjectSenderScope senderScope(m_object);
+        m_slot.call(s);
+    }
+}
diff --git a/WebCore/kwq/KWQSignalStubs.mm b/WebCore/kwq/KWQSignalStubs.mm
index b01a46b..56e202d 100644
--- a/WebCore/kwq/KWQSignalStubs.mm
+++ b/WebCore/kwq/KWQSignalStubs.mm
@@ -28,6 +28,16 @@
 #import <xml_tokenizer.h>
 
 void KHTMLView::cleared() { }
+
 void khtml::Loader::requestDone(khtml::DocLoader *, khtml::CachedObject *) { }
 void khtml::Loader::requestFailed(khtml::DocLoader *, khtml::CachedObject *) { }
-void Tokenizer::finishedParsing() { }
+
+Tokenizer::Tokenizer()
+    : m_finishedParsing(this, SIGNAL(finishedParsing()))
+{
+}
+
+void Tokenizer::finishedParsing()
+{
+    m_finishedParsing.call();
+}
diff --git a/WebCore/kwq/KWQSize.h b/WebCore/kwq/KWQSize.h
index ac050f7..adae534 100644
--- a/WebCore/kwq/KWQSize.h
+++ b/WebCore/kwq/KWQSize.h
@@ -32,10 +32,13 @@
 #include <iosfwd>
 #endif
 
+typedef struct _NSSize NSSize;
+
 class QSize {
 public:
     QSize();
     QSize(int,int);
+    explicit QSize(const NSSize &);
 
     bool isValid() const;
     int width() const { return w; }
@@ -43,6 +46,8 @@ public:
     void setWidth(int width) { w = width; }
     void setHeight(int height) { h = height; }
     QSize expandedTo(const QSize &) const;
+    
+    operator NSSize() const;
 
     friend QSize operator+(const QSize &, const QSize &);
     friend bool operator==(const QSize &, const QSize &);
diff --git a/WebCore/kwq/KWQSize.mm b/WebCore/kwq/KWQSize.mm
index 19d4f20..9ef796c 100644
--- a/WebCore/kwq/KWQSize.mm
+++ b/WebCore/kwq/KWQSize.mm
@@ -33,6 +33,10 @@ QSize::QSize(int width, int height) : w(width), h(height)
 {
 }
 
+QSize::QSize(const NSSize &s) : w((int)s.width), h((int)s.height)
+{
+}
+
 bool QSize::isValid() const
 {
     return w >= 0 && h >= 0;
@@ -43,6 +47,11 @@ QSize QSize::expandedTo(const QSize &o) const
     return QSize(w > o.w ? w : o.w, h > o.h ? h : o.h);
 }
 
+QSize::operator NSSize() const
+{
+    return NSMakeSize(w, h);
+}
+
 QSize operator+(const QSize &a, const QSize &b)
 {
     return QSize(a.w + b.w, a.h + b.h);
diff --git a/WebCore/kwq/KWQSlot.h b/WebCore/kwq/KWQSlot.h
index 64ffa15..9295f7b 100644
--- a/WebCore/kwq/KWQSlot.h
+++ b/WebCore/kwq/KWQSlot.h
@@ -40,6 +40,8 @@ public:
     void clear() { m_object = 0; }
     
     void call() const;
+    void call(int) const;
+    void call(const QString &) const;
     
     friend bool operator==(const KWQSlot &, const KWQSlot &);
 
diff --git a/WebCore/kwq/KWQSlot.mm b/WebCore/kwq/KWQSlot.mm
index 883d77b..250ba9b 100644
--- a/WebCore/kwq/KWQSlot.mm
+++ b/WebCore/kwq/KWQSlot.mm
@@ -26,26 +26,61 @@
 #import "KWQSlot.h"
 
 #import <kwqdebug.h>
+
+#import <dom_docimpl.h>
 #import <khtml_part.h>
 #import <render_form.h>
 
+using DOM::DocumentImpl;
+using khtml::RenderCheckBox;
+using khtml::RenderFileButton;
+using khtml::RenderFormElement;
+using khtml::RenderLineEdit;
 using khtml::RenderTextArea;
 
 enum FunctionNumber {
+    signalFinishedParsing,
+    slotAutoScroll,
+    slotClicked,
+    slotFinishedParsing,
     slotRedirect,
-    slotTextChanged
+    slotReturnPressed,
+    slotStateChanged,
+    slotTextChanged,
+    slotTextChangedWithString
 };
 
 KWQSlot::KWQSlot(QObject *object, const char *member) : m_object(0)
 {
-    if (KWQNamesMatch(member, SLOT(slotRedirect()))) {
+    if (KWQNamesMatch(member, SIGNAL(finishedParsing()))) {
+        KWQ_ASSERT(dynamic_cast<DocumentImpl *>(object));
+        m_function = signalFinishedParsing;
+    } else if (KWQNamesMatch(member, SLOT(slotAutoScroll()))) {
+        KWQ_ASSERT(dynamic_cast<KHTMLPart *>(object));
+        m_function = slotAutoScroll;
+    } else if (KWQNamesMatch(member, SLOT(slotClicked()))) {
+        KWQ_ASSERT(dynamic_cast<RenderFormElement *>(object));
+        m_function = slotClicked;
+    } else if (KWQNamesMatch(member, SLOT(slotFinishedParsing()))) {
+        KWQ_ASSERT(dynamic_cast<KHTMLPart *>(object));
+        m_function = slotFinishedParsing;
+    } else if (KWQNamesMatch(member, SLOT(slotRedirect()))) {
         KWQ_ASSERT(dynamic_cast<KHTMLPart *>(object));
         m_function = slotRedirect;
+    } else if (KWQNamesMatch(member, SLOT(slotReturnPressed()))) {
+        KWQ_ASSERT(dynamic_cast<RenderLineEdit *>(object) || dynamic_cast<RenderFileButton *>(object));
+        m_function = slotReturnPressed;
+    } else if (KWQNamesMatch(member, SLOT(slotStateChanged(int)))) {
+        KWQ_ASSERT(dynamic_cast<RenderCheckBox *>(object));
+        m_function = slotStateChanged;
     } else if (KWQNamesMatch(member, SLOT(slotTextChanged()))) {
         KWQ_ASSERT(dynamic_cast<RenderTextArea *>(object));
         m_function = slotTextChanged;
+    } else if (KWQNamesMatch(member, SLOT(slotTextChanged(const QString &)))) {
+        KWQ_ASSERT(dynamic_cast<RenderLineEdit *>(object) || dynamic_cast<RenderFileButton *>(object));
+        m_function = slotTextChangedWithString;
     } else {
-        // ERROR
+        NSLog(@"trying to create a slot for unknown member %s", member);
         return;
     }
     m_object = object;
@@ -58,6 +93,34 @@ void KWQSlot::call() const
     }
     
     switch (m_function) {
+        case signalFinishedParsing: {
+            DocumentImpl *doc = dynamic_cast<DocumentImpl *>(m_object.pointer());
+            if (doc) {
+                doc->m_finishedParsing.call();
+            }
+            return;
+        }
+        case slotAutoScroll: {
+            KHTMLPart *part = dynamic_cast<KHTMLPart *>(m_object.pointer());
+            if (part) {
+                part->slotAutoScroll();
+            }
+            return;
+        }
+        case slotClicked: {
+            RenderFormElement *element = dynamic_cast<RenderFormElement *>(m_object.pointer());
+            if (element) {
+                element->slotClicked();
+            }
+            return;
+        }
+        case slotFinishedParsing: {
+            KHTMLPart *part = dynamic_cast<KHTMLPart *>(m_object.pointer());
+            if (part) {
+                part->slotFinishedParsing();
+            }
+            return;
+        }
         case slotRedirect: {
             KHTMLPart *part = dynamic_cast<KHTMLPart *>(m_object.pointer());
             if (part) {
@@ -65,6 +128,17 @@ void KWQSlot::call() const
             }
             return;
         }
+        case slotReturnPressed: {
+            RenderLineEdit *edit = dynamic_cast<RenderLineEdit *>(m_object.pointer());
+            if (edit) {
+                edit->slotReturnPressed();
+            }
+            RenderFileButton *button = dynamic_cast<RenderFileButton *>(m_object.pointer());
+            if (button) {
+                edit->slotReturnPressed();
+            }
+            return;
+        }
         case slotTextChanged: {
             RenderTextArea *area = dynamic_cast<RenderTextArea *>(m_object.pointer());
             if (area) {
@@ -73,7 +147,48 @@ void KWQSlot::call() const
             return;
         }
     }
-    // ERROR
+}
+
+void KWQSlot::call(int i) const
+{
+    if (!m_object) {
+        return;
+    }
+    
+    switch (m_function) {
+        case slotStateChanged: {
+            RenderCheckBox *checkBox = dynamic_cast<RenderCheckBox *>(m_object.pointer());
+            if (checkBox) {
+                checkBox->slotStateChanged(i);
+            }
+            return;
+        }
+    }
+    
+    call();
+}
+
+void KWQSlot::call(const QString &string) const
+{
+    if (!m_object) {
+        return;
+    }
+    
+    switch (m_function) {
+        case slotTextChangedWithString: {
+            RenderLineEdit *edit = dynamic_cast<RenderLineEdit *>(m_object.pointer());
+            if (edit) {
+                edit->slotTextChanged(string);
+            }
+            RenderFileButton *button = dynamic_cast<RenderFileButton *>(m_object.pointer());
+            if (button) {
+                edit->slotTextChanged(string);
+            }
+            return;
+        }
+    }
+    
+    call();
 }
 
 bool operator==(const KWQSlot &a, const KWQSlot &b)
diff --git a/WebCore/kwq/KWQTextArea.h b/WebCore/kwq/KWQTextArea.h
index e7605f9..2885fe5 100644
--- a/WebCore/kwq/KWQTextArea.h
+++ b/WebCore/kwq/KWQTextArea.h
@@ -33,7 +33,7 @@ class QWidget;
     QWidget *widget;
     BOOL wrap;
 }
-- initWithFrame:(NSRect)r widget:(QWidget *)w; 
+- initWithWidget:(QWidget *)w; 
 
 // The following methods corresponds to methods required by KDE.
 - (void)setWordWrap:(BOOL)wrap;
diff --git a/WebCore/kwq/KWQTextArea.mm b/WebCore/kwq/KWQTextArea.mm
index 0c77a55..00f3b9f 100644
--- a/WebCore/kwq/KWQTextArea.mm
+++ b/WebCore/kwq/KWQTextArea.mm
@@ -52,11 +52,6 @@
 
 const float LargeNumberForText = 1.0e7;
 
-- initWithFrame:(NSRect)r
-{
-    return [self initWithFrame:r widget:0];
-}
-
 - (void)_createTextView
 {
     NSDictionary *attr;
@@ -89,19 +84,25 @@ const float LargeNumberForText = 1.0e7;
     [self setDocumentView:textView];
 }
 
-- initWithFrame:(NSRect)r widget:(QWidget *)w 
+- initWithFrame:(NSRect)frame
 {
-    [super initWithFrame:r];
-
+    [super initWithFrame:frame];
+    
     [self setHasVerticalScroller:YES];
     [self setHasHorizontalScroller:NO];
     [self setBorderType:NSLineBorder];
-
-    //if (r.size.width > 0 && r.size.height > 0)
-        [self _createTextView];
     
-    widget = w;
+    [self _createTextView];
     
+    widget = 0;
+    
+    return self;
+}
+
+- initWithWidget:(QWidget *)w 
+{
+    [super init];
+    widget = w;
     return self;
 }
 
diff --git a/WebCore/kwq/KWQTextEdit.mm b/WebCore/kwq/KWQTextEdit.mm
index b38f57e..c923e57 100644
--- a/WebCore/kwq/KWQTextEdit.mm
+++ b/WebCore/kwq/KWQTextEdit.mm
@@ -30,7 +30,7 @@
 QTextEdit::QTextEdit(QWidget *parent)
     : m_textChanged(this, SIGNAL(textChanged()))
 {
-    KWQTextArea *textView = [[KWQTextArea alloc] initWithFrame:NSMakeRect(0,0,0,0) widget:this];
+    KWQTextArea *textView = [[KWQTextArea alloc] initWithWidget:this];
     setView(textView);
     [textView release];
 }
diff --git a/WebCore/kwq/KWQTextField.h b/WebCore/kwq/KWQTextField.h
index 17b1c43..ee906c7 100644
--- a/WebCore/kwq/KWQTextField.h
+++ b/WebCore/kwq/KWQTextField.h
@@ -22,44 +22,31 @@
  * (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 <Cocoa/Cocoa.h>
 
 class QWidget;
 
- at interface KWQNSTextFieldFormatter : NSFormatter
-{
-    int maxLength;
-    bool isPassword;
-}
-
-- (void)setPasswordMode: (bool)flag;
-- (bool)passwordMode;
-- (void)setMaximumLength: (int)len;
-- (int)maximumLength;
-- (NSString *)stringForObjectValue:(id)anObject;
-- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString  **)error;
-- (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error;
-- (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes;
+ at class KWQTextFieldFormatter;
 
- at end
+#define FOCUS_BORDER_SIZE 3
 
 @interface KWQNSTextField : NSTextField
 {
 @private
-    NSSecureTextField *secureField;
+    NSTextField *secureField;
     QWidget *widget;
-    KWQNSTextFieldFormatter *formatter;
-    bool edited;
+    KWQTextFieldFormatter *formatter;
+    BOOL edited;
 }
 
-- initWithFrame: (NSRect)r widget: (QWidget *)w;
-- (KWQNSTextFieldFormatter *)formatter;
-- (void)setPasswordMode: (bool)flag;
-- (bool)passwordMode;
-- (void)setMaximumLength: (int)len;
+- initWithWidget:(QWidget *)widget;
+
+- (void)setPasswordMode:(BOOL)flag;
+- (BOOL)passwordMode;
+- (void)setMaximumLength:(int)len;
 - (int)maximumLength;
-- (bool)edited;
-- (void)setEdited:(bool)ed;
+- (BOOL)edited;
+- (void)setEdited:(BOOL)edited;
 
 @end
-
diff --git a/WebCore/kwq/KWQTextField.mm b/WebCore/kwq/KWQTextField.mm
index 792bbfe..c04ab8b 100644
--- a/WebCore/kwq/KWQTextField.mm
+++ b/WebCore/kwq/KWQTextField.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,205 +22,272 @@
  * (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 <qwidget.h>
 
 #import <KWQNSTextField.h>
 
+#import <qlineedit.h>
+
+// KWQTextFieldCell is larger than a normal text field cell, so it includes
+// the focus border as well as the rest of the text field.
+
+ at interface KWQTextFieldCell : NSTextFieldCell
+{
+}
+ at end
+
+// KWQTextFieldFormatter enforces a maximum length.
+
+ at interface KWQTextFieldFormatter : NSFormatter
+{
+    int maxLength;
+}
+
+- (void)setMaximumLength:(int)len;
+- (int)maximumLength;
+
+ at end
+
+// KWQSecureTextField is a workaround for bug 3024443.
+
+ at interface KWQSecureTextField : NSSecureTextField
+{
+    BOOL inSetFrameSize;
+}
+ at end
 
 @implementation KWQNSTextField
 
-- initWithFrame: (NSRect) r widget: (QWidget *)w 
++ (void)initialize
 {
-    [super initWithFrame: r];
-    formatter = [[KWQNSTextFieldFormatter alloc] init];
-    [self setFormatter: formatter];
-    widget = w;
+    if (self == [KWQNSTextField class]) {
+        [self setCellClass:[KWQTextFieldCell class]];
+    }
+}
 
-    [self setTarget: self];
-    [self setAction: @selector(action:)];
+- initWithFrame:(NSRect)frame
+{
+    [super initWithFrame:frame];
+    
+    formatter = [[KWQTextFieldFormatter alloc] init];
+    [self setFormatter:formatter];
+
+    [self setTarget:self];
+    [self setAction:@selector(action:)];
 
-    [self setDelegate: self];
+    [self setDelegate:self];
 
-    [[self cell] setScrollable: YES];
+    [[self cell] setScrollable:YES];
     
     return self;
 }
 
-- (void)action: sender
+- initWithWidget:(QWidget *)w 
+{
+    [super init];
+    widget = w;
+    return self;
+}
+
+- (void)action:sender
 {
-    if (widget)
-        widget->emitAction(QObject::ACTION_TEXT_FIELD);
+    QLineEdit *edit = dynamic_cast<QLineEdit *>(widget);
+    if (edit) {
+        edit->returnPressed();
+    }
 }
 
 - (void)controlTextDidEndEditing:(NSNotification *)aNotification
 {
-    if (widget)
-        widget->emitAction(QObject::ACTION_TEXT_FIELD_END_EDITING);
+    QLineEdit *edit = dynamic_cast<QLineEdit *>(widget);
+    if (edit) {
+        edit->textChanged();
+    }
 }
 
 - (void)dealloc
 {
+    [secureField release];
     [formatter release];
     [super dealloc];
 }
 
-
-- (KWQNSTextFieldFormatter *)formatter
+- (KWQTextFieldFormatter *)formatter
 {
     return formatter;
 }
 
+- (void)updateSecureFieldFrame
+{
+    [secureField setFrame:NSInsetRect([self bounds], FOCUS_BORDER_SIZE, FOCUS_BORDER_SIZE)];
+}
+
+- (void)setFrameSize:(NSSize)size
+{
+    [super setFrameSize:size];
+    [self updateSecureFieldFrame];
+}
 
-- (void)setPasswordMode: (bool)flag
+- (void)setPasswordMode:(BOOL)flag
 {
-    if (flag != [formatter passwordMode]){
-        if (flag == NO){
-            [self setStringValue: @""];
-            [secureField removeFromSuperview];
-        } else {
-            if (secureField == nil){
-                secureField = [[NSSecureTextField alloc] initWithFrame: [self bounds]];
-                [secureField setAutoresizingMask: NSViewWidthSizable | NSViewHeightSizable];
-                [secureField setFormatter: formatter];
-            } else {
-                [secureField setBounds: [self bounds]];
-            }
-            [secureField setStringValue: @""];
+    if (!flag == ![secureField superview]) {
+        return;
+    }
+    
+    [self setStringValue:@""];
+    if (!flag) {
+        [secureField removeFromSuperview];
+    } else {
+        if (secureField == nil) {
+            secureField = [[KWQSecureTextField alloc] init];
             [secureField setDelegate:self];
-            [self addSubview: secureField];
+            [secureField setFormatter:formatter];
+            [secureField setFont:[self font]];
+            [self updateSecureFieldFrame];
         }
-        [formatter setPasswordMode: flag];
+        [self addSubview:secureField];
     }
+    [self setStringValue:@""];
 }
 
-
 - (void)setEditable:(BOOL)flag
 {
-    if (secureField != nil)
-        [secureField setEditable: flag];
-    [super setEditable: flag];
+    [secureField setEditable:flag];
+    [super setEditable:flag];
 }
 
-
 - (void)selectText:(id)sender
 {
-    if ([self passwordMode])
-        [secureField selectText: sender];
+    if ([self passwordMode]) {
+        [secureField selectText:sender];
+        return;
+    }
+    [super selectText:sender];
 }
 
-
 - (BOOL)isEditable
 {
     return [super isEditable];
 }
 
-
-- (bool)passwordMode
+- (BOOL)passwordMode
 {
-    return [formatter passwordMode];
+    return [secureField superview] != nil;
 }
 
-
-- (void)setMaximumLength: (int)len
+- (void)setMaximumLength:(int)len
 {
-    NSString *oldValue, *truncatedValue;
-    
-    oldValue = [self stringValue];
+    NSString *oldValue = [self stringValue];
     if ((int)[oldValue length] > len){
-        truncatedValue = [oldValue substringToIndex: len];
-        [self setStringValue: truncatedValue];
-        [secureField setStringValue: truncatedValue];
+        [self setStringValue:[oldValue substringToIndex:len]];
     }
-    [formatter setMaximumLength: len];
+    [formatter setMaximumLength:len];
 }
 
-
 - (int)maximumLength
 {
     return [formatter maximumLength];
 }
 
-
-- (bool)edited
+- (BOOL)edited
 {
     return edited;
 }
 
-- (void)setEdited:(bool)ed
+- (void)setEdited:(BOOL)ed
 {
     edited = ed;
 }
 
--(void)textDidChange:(NSNotification *)aNotification
+- (void)textDidChange:(NSNotification *)aNotification
 {
     edited = true;
 }
 
--(NSString *)stringValue
+- (NSString *)stringValue
 {
-    NSString *result;
-    
-    if ([self passwordMode]) {
-        result = [secureField stringValue];
-    }
-    else {
-        result = [super stringValue];
+    if ([secureField superview]) {
+        return [secureField stringValue];
     }
+    return [super stringValue];
+}
+
+- (void)setStringValue:(NSString *)string
+{
+    [secureField setStringValue:string];
+    [super setStringValue:string];
+}
 
-    return result;
+- (void)setFont:(NSFont *)font
+{
+    [secureField setFont:font];
+    [super setFont:font];
 }
 
 @end
 
+// This cell is used so that our frame includes the place where the focus rectangle is drawn.
+// If that makes the widget too big for layout, we'll account for that at the QWidget level.
 
- at implementation KWQNSTextFieldFormatter
+ at implementation KWQTextFieldCell
 
-- init {
-    maxLength = 2147483647;
-    isPassword = NO;
-    return [super init];
+- (NSSize)cellSizeForBounds:(NSRect)bounds
+{
+    NSSize size = [super cellSizeForBounds:bounds];
+    size.width += FOCUS_BORDER_SIZE * 2;
+    size.height += FOCUS_BORDER_SIZE * 2;
+    return size;
 }
 
-- (void)setPasswordMode: (bool)flag
+- (void)drawWithFrame:(NSRect)frame inView:(NSView *)view
 {
-    isPassword = flag;
+    [super drawWithFrame:NSInsetRect(frame, FOCUS_BORDER_SIZE, FOCUS_BORDER_SIZE) inView:view];
 }
 
+- (void)editWithFrame:(NSRect)frame inView:(NSView *)view editor:(NSText *)editor delegate:(id)delegate event:(NSEvent *)event
+{
+    [super editWithFrame:NSInsetRect(frame, FOCUS_BORDER_SIZE, FOCUS_BORDER_SIZE) inView:view editor:editor delegate:delegate event:event];
+}
 
-- (bool)passwordMode
+- (void)selectWithFrame:(NSRect)frame inView:(NSView *)view editor:(NSText *)editor delegate:(id)delegate start:(int)start length:(int)length
 {
-    return isPassword;
+    [super selectWithFrame:NSInsetRect(frame, FOCUS_BORDER_SIZE, FOCUS_BORDER_SIZE) inView:view editor:editor delegate:delegate start:start length:length];
 }
 
+ at end
+
+ at implementation KWQTextFieldFormatter
 
-- (void)setMaximumLength: (int)len
+- init
 {
-    maxLength = len;
+    [super init];
+    maxLength = INT_MAX;
+    return self;
 }
 
+- (void)setMaximumLength:(int)len
+{
+    maxLength = len;
+}
 
 - (int)maximumLength
 {
     return maxLength;
 }
 
-
-- (NSString *)stringForObjectValue:(id)anObject
+- (NSString *)stringForObjectValue:(id)object
 {
-    return (NSString *)anObject;
+    return (NSString *)object;
 }
 
-
-- (BOOL)getObjectValue:(id *)obj forString:(NSString *)string errorDescription:(NSString  **)error
+- (BOOL)getObjectValue:(id *)object forString:(NSString *)string errorDescription:(NSString **)error
 {
-    *obj = string;
+    *object = string;
     return YES;
 }
 
-
 - (BOOL)isPartialStringValid:(NSString *)partialString newEditingString:(NSString **)newString errorDescription:(NSString **)error
 {
-    if ((int)[partialString length] > maxLength){
+    if ((int)[partialString length] > maxLength) {
         *newString = nil;
         return NO;
     }
@@ -228,13 +295,28 @@
     return YES;
 }
 
-
 - (NSAttributedString *)attributedStringForObjectValue:(id)anObject withDefaultAttributes:(NSDictionary *)attributes
 {
     return nil;
 }
 
+ at end
 
+ at implementation KWQSecureTextField
 
- at end
+- (void)selectText:(id)sender
+{
+    if (sender == self && inSetFrameSize) {
+        return;
+    }
+    [super selectText:sender];
+}
 
+- (void)setFrameSize:(NSSize)size
+{
+    inSetFrameSize = YES;
+    [super setFrameSize:size];
+    inSetFrameSize = NO;
+}
+
+ at end
diff --git a/WebCore/kwq/KWQView.h b/WebCore/kwq/KWQView.h
index 913acff..bea4bca 100644
--- a/WebCore/kwq/KWQView.h
+++ b/WebCore/kwq/KWQView.h
@@ -32,7 +32,7 @@ class QWidget;
     QWidget *widget;
     bool isFlipped;
 }
-- initWithFrame:(NSRect)r widget:(QWidget *)w; 
+- initWithWidget:(QWidget *)w; 
 - (void)setIsFlipped:(bool)flag;
 @end
 
@@ -40,19 +40,19 @@ class QWidget;
 {
     QWidget *widget;
 }
-- initWithFrame:(NSRect)r widget:(QWidget *)w; 
+- initWithWidget:(QWidget *)w; 
 @end
 
 @interface KWQNSComboBox : NSPopUpButton
 {
     QWidget *widget;
 }
-- initWithFrame:(NSRect)r widget:(QWidget *)w; 
+- initWithWidget:(QWidget *)w; 
 @end
 
 @interface KWQNSScrollView : NSScrollView
 {
     QWidget *widget;
 }
-- initWithFrame:(NSRect)r widget:(QWidget *)w; 
+- initWithWidget:(QWidget *)w; 
 @end
diff --git a/WebCore/kwq/KWQView.mm b/WebCore/kwq/KWQView.mm
index b3402f9..881424a 100644
--- a/WebCore/kwq/KWQView.mm
+++ b/WebCore/kwq/KWQView.mm
@@ -24,18 +24,24 @@
  */
 
 #import "KWQView.h"
-#import <qwidget.h>
+#import <qcheckbox.h>
 
 @implementation KWQView
 
-- initWithFrame:(NSRect)r widget:(QWidget *)w 
+- initWithFrame:(NSRect)frame
 {
-    [super initWithFrame:r];
-    widget = w;
+    [super initWithFrame:frame];
     isFlipped = YES;
     return self;
 }
 
+- initWithWidget:(QWidget *)w 
+{
+    [super init];
+    widget = w;
+    return self;
+}
+
 - (void)setIsFlipped:(bool)flag
 {
     isFlipped = flag;
@@ -48,73 +54,73 @@
 
 @end
 
- at interface  NSButtonCell (Whacky)
-- (NSRect)_insetRect:(NSRect)theRect;
-- (NSSize)_titleSizeWithSize:(NSSize)maxSize;
- at end
-
- at interface KWQNSButtonCell : NSButtonCell
- at end
-
- at implementation KWQNSButtonCell
+ at implementation KWQNSButton
 
-// cellSizeForBounds is a sizeToFit !
-- (NSSize)cellSizeForBounds:(NSRect)theRect
+- initWithFrame:(NSRect)frame 
 {
-// XXX Find a way to get these from the system? -dwh
-#define	kPushButtonBorderSize			 4
-#define kThemePushButtonTextOffset		 4
-#define kPushButtonInset			 1
-
-    // XXX This is going to get way more complex before I'm done here. :(
-    // -dwh
-    NSSize theSize = [super cellSizeForBounds:theRect];
-    theSize.height -= (kPushButtonBorderSize)*2.0;
-    return theSize;
-}
+    [super initWithFrame:frame];
 
- at end
+    [self setTarget:self];
+    [self setAction:@selector(action:)];
 
- at implementation KWQNSButton
+    [self setTitle:@""];
+    [self setBezelStyle:NSRoundedBezelStyle];
+    [[self cell] setControlSize:NSSmallControlSize];
+    [self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
 
-+ (void)initialize {
-    if (self == [KWQNSButton class]) {
-        [self setCellClass:[KWQNSButtonCell class]];
-    }
+    return self;
 }
 
-- initWithFrame:(NSRect)r widget:(QWidget *)w 
+- initWithWidget:(QWidget *)w 
 {
-    [super initWithFrame:r];
-    [self setBordered:YES];
-    [self setBezelStyle:NSRoundedBezelStyle];
+    [super init];
     widget = w;
-    
-    [self setTarget:self];
-    [self setAction:@selector(action:)];
     return self;
 }
 
 - (void)action:(id)sender
 {
-    widget->emitAction(QObject::ACTION_BUTTON_CLICKED);
+    QButton *button = dynamic_cast<QButton *>(widget);
+    if (button) {
+        button->clicked();
+    }
 }
 
 - (void)stateChanged:(id)sender
 {
-    widget->emitAction(QObject::ACTION_CHECKBOX_CLICKED);
+    // Note that it's important to give the stateChanged signal before
+    // the clicked signal so that the corresponding JavaScript messages
+    // go in the right order. A test for this at the time of this writing
+    // was the languages radio buttons and check boxes at google.com prefs.
+    
+    QCheckBox *checkBox = dynamic_cast<QCheckBox *>(widget);
+    if (checkBox) {
+        checkBox->stateChanged();
+    }
+    [self action:sender];
 }
 
 @end
 
 @implementation KWQNSComboBox
 
-- initWithFrame:(NSRect)r widget:(QWidget *)w 
+- initWithFrame:(NSRect)frame
 {
-    [super initWithFrame:r];
-    widget = w;
+    [super initWithFrame:frame];
+
     [self setTarget:self];
     [self setAction:@selector(action:)];
+
+    [[self cell] setControlSize:NSSmallControlSize];
+    [self setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
+
+    return self;
+}
+
+- initWithWidget:(QWidget *)w 
+{
+    [super init];
+    widget = w;
     return self;
 }
 
@@ -127,9 +133,9 @@
 
 @implementation KWQNSScrollView
 
-- initWithFrame:(NSRect)r widget:(QWidget *)w 
+- initWithWidget:(QWidget *)w 
 {
-    [super initWithFrame:r];
+    [super init];
     widget = w;
     return self;
 }
diff --git a/WebCore/kwq/KWQWidget.h b/WebCore/kwq/KWQWidget.h
index 659f2e8..27a2614 100644
--- a/WebCore/kwq/KWQWidget.h
+++ b/WebCore/kwq/KWQWidget.h
@@ -62,10 +62,11 @@ public:
         WheelFocus = 0x7
     };
 
-    QWidget(QWidget *parent = 0, const char *name = 0, int f = 0);
+    QWidget(QWidget *parent = 0, const char *name = 0, int flags = 0);
     virtual ~QWidget();
 
     virtual QSize sizeHint() const;
+    
     virtual void setEnabled(bool);
     
     void setActiveWindow();
@@ -86,6 +87,7 @@ public:
     void move(const QPoint &);
 
     virtual QRect frameGeometry() const;
+    virtual void setFrameGeometry(const QRect &);
 
     virtual QWidget *topLevelWidget() const;
 
@@ -145,9 +147,6 @@ public:
     
     virtual void endEditing();
 
-protected:
-    virtual void internalSetGeometry( int x, int y, int w, int h );
-
 private:
     QWidgetPrivate *data;
 };
diff --git a/WebCore/kwq/KWQWidget.mm b/WebCore/kwq/KWQWidget.mm
index 7e9a5ef..ddc3339 100644
--- a/WebCore/kwq/KWQWidget.mm
+++ b/WebCore/kwq/KWQWidget.mm
@@ -53,7 +53,7 @@ QWidget::QWidget(QWidget *parent, const char *name, int f)
     static QStyle defaultStyle;
     
     data = new QWidgetPrivate;
-    data->view = [[KWQView alloc] initWithFrame:NSMakeRect(0,0,0,0) widget:this];
+    data->view = [[KWQView alloc] initWithWidget:this];
     data->style = &defaultStyle;
 }
 
@@ -71,7 +71,7 @@ QSize QWidget::sizeHint() const
 
 void QWidget::resize(int w, int h) 
 {
-    internalSetGeometry(pos().x(), pos().y(), w, h);
+    setFrameGeometry(QRect(pos().x(), pos().y(), w, h));
 }
 
 void QWidget::setActiveWindow() 
@@ -125,8 +125,7 @@ QPoint QWidget::pos() const
 
 void QWidget::move(int x, int y) 
 {
-    //KWQDEBUG ("%p %s to x %d y %d\n", getView(), [[[getView() class] className] cString], x, y);
-    internalSetGeometry(x, y, width(), height());
+    setFrameGeometry(QRect(x, y, width(), height()));
 }
 
 void QWidget::move(const QPoint &p) 
@@ -137,7 +136,6 @@ void QWidget::move(const QPoint &p)
 QRect QWidget::frameGeometry() const
 {
     NSView *view = getView();
-    
     if ([view conformsToProtocol:@protocol(WebCoreFrameView)]) {
         view = [view superview];
     }
@@ -289,7 +287,7 @@ bool QWidget::hasMouseTracking() const
     return true;
 }
 
-void QWidget::internalSetGeometry(int x, int y, int w, int h)
+void QWidget::setFrameGeometry(const QRect &rect)
 {
     NSView *view = getView();
     
@@ -304,14 +302,14 @@ void QWidget::internalSetGeometry(int x, int y, int w, int h)
         KWQ_ASSERT(view);
     }
     
-    [view setFrame:NSMakeRect(x, y, w, h)];
+    [view setFrame:rect];
 }
 
 QPoint QWidget::mapFromGlobal(const QPoint &p) const
 {
     NSPoint bp;
-    bp = [[data->view window] convertScreenToBase:[data->view convertPoint:NSMakePoint(p.x(), p.y()) toView:nil]];
-    return QPoint((int)bp.x, (int)bp.y);
+    bp = [[data->view window] convertScreenToBase:[data->view convertPoint:p toView:nil]];
+    return QPoint(bp);
 }
 
 NSView *QWidget::getView() const
@@ -342,25 +340,21 @@ void QWidget::endEditing()
     }
 }
 
-
 void QWidget::lockDrawingFocus()
 {
     [getView() lockFocus];
 }
 
-
 void QWidget::unlockDrawingFocus()
 {
     [getView() unlockFocus];
 }
 
-
 void QWidget::flushDrawing()
 {
     [[getView() window] flushWindow];
 }
 
-
 void QWidget::enableFlushDrawing()
 {
     [[getView() window] enableFlushWindow];
@@ -372,7 +366,6 @@ void QWidget::disableFlushDrawing()
     [[getView() window] disableFlushWindow];
 }
 
-
 void QWidget::setDrawingAlpha(float alpha)
 {
     CGContextRef cgContext;
@@ -384,5 +377,3 @@ void QWidget::displayRect(int x, int y, int w, int h)
 {
     [getView() displayRect: NSMakeRect (x,y,w,h)];
 }
-
-
diff --git a/WebCore/kwq/KWQWindowWidget.h b/WebCore/kwq/KWQWindowWidget.h
index 8d5b973..109e786 100644
--- a/WebCore/kwq/KWQWindowWidget.h
+++ b/WebCore/kwq/KWQWindowWidget.h
@@ -45,14 +45,12 @@ class KWQWindowWidget : public QWidget
 
     virtual QSize sizeHint() const;
     virtual QRect frameGeometry() const;
+    virtual void setFrameGeometry(const QRect &);
 
     virtual QWidget *topLevelWidget() const;
     virtual QPoint mapToGlobal(const QPoint &) const;
     virtual QPoint mapFromGlobal(const QPoint &) const;
 
- protected:
-    virtual void internalSetGeometry( int x, int y, int w, int h );
-
  private:
     KWQWindowWidget();
     KWQWindowWidget(NSWindow *window);
diff --git a/WebCore/kwq/KWQWindowWidget.mm b/WebCore/kwq/KWQWindowWidget.mm
index fa8a141..5b32f8d 100644
--- a/WebCore/kwq/KWQWindowWidget.mm
+++ b/WebCore/kwq/KWQWindowWidget.mm
@@ -108,8 +108,8 @@ QPoint KWQWindowWidget::mapFromGlobal(const QPoint &p) const
     return QPoint((int)windowPoint.x, (int)([d->window frame].size.height - windowPoint.y));
 }
 
-void KWQWindowWidget::internalSetGeometry(int x, int y, int w, int h)
+void KWQWindowWidget::setFrameGeometry(const QRect &r)
 {
     // FIXME: should try to avoid saving changes
-    [d->window setFrame:NSMakeRect(x, NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - y - h, w, h) display:NO];
+    [d->window setFrame:NSMakeRect(r.x(), NSMaxY([[[NSScreen screens] objectAtIndex:0] frame]) - r.y() - r.height(), r.width(), r.height()) display:NO];
 }
diff --git a/WebCore/kwq/KWQsignals.mm b/WebCore/kwq/KWQsignals.mm
index b01a46b..56e202d 100644
--- a/WebCore/kwq/KWQsignals.mm
+++ b/WebCore/kwq/KWQsignals.mm
@@ -28,6 +28,16 @@
 #import <xml_tokenizer.h>
 
 void KHTMLView::cleared() { }
+
 void khtml::Loader::requestDone(khtml::DocLoader *, khtml::CachedObject *) { }
 void khtml::Loader::requestFailed(khtml::DocLoader *, khtml::CachedObject *) { }
-void Tokenizer::finishedParsing() { }
+
+Tokenizer::Tokenizer()
+    : m_finishedParsing(this, SIGNAL(finishedParsing()))
+{
+}
+
+void Tokenizer::finishedParsing()
+{
+    m_finishedParsing.call();
+}
diff --git a/WebCore/kwq/WebCoreTestController.h b/WebCore/kwq/WebCoreTestController.h
index d7efdb2..5239289 100644
--- a/WebCore/kwq/WebCoreTestController.h
+++ b/WebCore/kwq/WebCoreTestController.h
@@ -26,6 +26,12 @@
 #import <Foundation/Foundation.h>
 
 @protocol WebCoreDrawingObserver <NSObject>
+- (void)filledRect:(NSRect)r;
+- (void)strokedRect:(NSRect)r;
+- (void)filledOval:(NSRect)r;
+- (void)strokedOval:(NSRect)r;
+- (void)strokedArcWithCenter:(NSPoint)p radius:(float)radius startAngle:(float)startAngle endAngle:(float)endAngle;
+- (void)drewLineFrom:(NSPoint)p1 to:(NSPoint)p2 width:(float)width;
 @end
 
 @interface WebCoreTestController : NSObject
diff --git a/WebCore/kwq/qt/qbutton.h b/WebCore/kwq/qt/qbutton.h
index 57e35b4..57da053 100644
--- a/WebCore/kwq/qt/qbutton.h
+++ b/WebCore/kwq/qt/qbutton.h
@@ -28,6 +28,7 @@
 
 #include <qwidget.h>
 #include <qstring.h>
+#include <KWQSignal.h>
     
 class QButton : public QWidget {
 public:
@@ -37,6 +38,13 @@ public:
     QString text() const;
     
     QSize sizeHint() const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
+    
+    void clicked() { m_clicked.call(); }
+
+private:
+    KWQSignal m_clicked;
 };
 
 #endif
diff --git a/WebCore/kwq/qt/qcheckbox.h b/WebCore/kwq/qt/qcheckbox.h
index 0a19bda..8112da4 100644
--- a/WebCore/kwq/qt/qcheckbox.h
+++ b/WebCore/kwq/qt/qcheckbox.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
@@ -34,6 +34,15 @@ public:
 
     void setChecked(bool);
     bool isChecked();
+
+    QSize sizeHint() const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
+
+    void stateChanged() { m_stateChanged.call(isChecked() ? 2 : 0); }
+
+private:
+    KWQSignal m_stateChanged;
 };
 
 #endif
diff --git a/WebCore/kwq/qt/qcombobox.h b/WebCore/kwq/qt/qcombobox.h
index 9b5de69..ef36e1b 100644
--- a/WebCore/kwq/qt/qcombobox.h
+++ b/WebCore/kwq/qt/qcombobox.h
@@ -50,8 +50,11 @@ public:
     int currentItem() const;
 
     int indexOfCurrentItem();
-    virtual void setCurrentItem(int);
+    void setCurrentItem(int);
+    
     QSize sizeHint() const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
 
     NSMutableArray *items;
 
diff --git a/WebCore/kwq/qt/qlineedit.h b/WebCore/kwq/qt/qlineedit.h
index 45f1d54..aa789f6 100644
--- a/WebCore/kwq/qt/qlineedit.h
+++ b/WebCore/kwq/qt/qlineedit.h
@@ -29,6 +29,7 @@
 #include <qwidget.h>
 #include <qevent.h>
 #include <qstring.h>
+#include <KWQSignal.h>
 
 class QLineEdit : public QWidget {
 public:
@@ -52,6 +53,17 @@ public:
     void setEdited(bool);
     
     void setFont(const QFont &font);
+    
+    QSize sizeForCharacterWidth(int numCharacters) const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
+    
+    void returnPressed() { m_returnPressed.call(); }
+    void textChanged() { m_textChanged.call(text()); }
+
+private:
+    KWQSignal m_returnPressed;
+    KWQSignal m_textChanged;
 };
 
 #endif
diff --git a/WebCore/kwq/qt/qobject.h b/WebCore/kwq/qt/qobject.h
index da9a0ea..3617bfc 100644
--- a/WebCore/kwq/qt/qobject.h
+++ b/WebCore/kwq/qt/qobject.h
@@ -70,21 +70,8 @@ class QObject : public Qt {
 public:
 
     enum Actions {
-        // Standard button action, maps to RenderFormElement::slotClicked
-        ACTION_BUTTON_CLICKED = 1,
-        
-        // Checkbox button action, maps to RenderCheckBox::slotStateChanged
-        ACTION_CHECKBOX_CLICKED = 2,
-        
-        // Text field actions, map to RenderLineEdit::slotReturnPressed and
-        // RenderLineEdit::slotTextChanged
-        ACTION_TEXT_FIELD = 3,  // corresponds to [NSTextField action]
-        ACTION_TEXT_FIELD_END_EDITING = 4, // corresponds to NSTextField's delegate textDidEndEditing:
-
-        ACTION_TEXT_AREA_END_EDITING = 5,
-        
+        ACTION_TEXT_AREA_END_EDITING = 5,        
         ACTION_LISTBOX_CLICKED = 6,
-        
         ACTION_COMBOBOX_CLICKED = 7
     };
 
@@ -113,6 +100,8 @@ public:
 
     void emitAction(Actions action);
     virtual void performAction(Actions action);
+    
+    static const QObject *sender() { return m_sender; }
 
 private:
     // no copying or assignment
@@ -125,9 +114,22 @@ private:
     QPtrList<QObject> guardedPtrDummyList;
     mutable KWQSignal *m_signalListHead;
     bool m_signalsBlocked;
+    
+    static const QObject *m_sender;
 
     friend class KWQGuardedPtrBase;
     friend class KWQSignal;
+    friend class KWQObjectSenderScope;
+};
+
+class KWQObjectSenderScope
+{
+public:
+    KWQObjectSenderScope(const QObject *);
+    ~KWQObjectSenderScope();
+
+private:
+    const QObject *m_savedSender;
 };
 
 #endif
diff --git a/WebCore/kwq/qt/qpoint.h b/WebCore/kwq/qt/qpoint.h
index 38c96d7..191679c 100644
--- a/WebCore/kwq/qt/qpoint.h
+++ b/WebCore/kwq/qt/qpoint.h
@@ -34,11 +34,13 @@
 
 #include "qarray.h"
 
+typedef struct _NSPoint NSPoint;
+
 class QPoint {
 public:
-
     QPoint();
     QPoint(int, int);
+    explicit QPoint(const NSPoint &); // don't do this implicitly since it's lossy
 
     int x() const { return xCoord; }
     int y() const { return yCoord; }
@@ -47,25 +49,24 @@ public:
     
     friend QPoint operator+(const QPoint &, const QPoint &);
     friend QPoint operator-(const QPoint &, const QPoint &);
+    
+    operator NSPoint() const;
 
 private:
-
     int xCoord;
     int yCoord;
-
 };
 
 class QPointArray : public QMemArray<QPoint> {
 public:
-
-    QPointArray() {}
-    QPointArray(int size) : QMemArray<QPoint>(size) {}
+    QPointArray() { }
+    QPointArray(int size) : QMemArray<QPoint>(size) { }
 
     QPointArray(int, const int *);
 
     void setPoint(uint, int, int);
 #if 0
-    // FIXME: Workaround for Radar 2921061
+    // FIXME: Workaround for Radar 2921061.
     bool setPoints(int, int, int, ...);
 #else
     bool setPoints(int, int, int, int, int, int, int, int, int);
diff --git a/WebCore/kwq/qt/qpushbutton.h b/WebCore/kwq/qt/qpushbutton.h
index 997ccd7..292cfe7 100644
--- a/WebCore/kwq/qt/qpushbutton.h
+++ b/WebCore/kwq/qt/qpushbutton.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
@@ -27,17 +27,11 @@
 #define QPUSHBUTTON_H_
 
 #include <qbutton.h>
-#include <qwidget.h>
-#include <qstring.h>
 
 class QPushButton : public QButton {
 public:
     QPushButton(QWidget *w) : QButton(w) { }
     QPushButton(const QString &text, QWidget *parent);
-    
-    // This could be in QWidget, but if we put it here we don't need a
-    // fully general implementation, and it's currently used only for this case.
-    QFontMetrics fontMetrics() const;
 };
 
 #endif
diff --git a/WebCore/kwq/qt/qradiobutton.h b/WebCore/kwq/qt/qradiobutton.h
index 2ac9e86..c53be3a 100644
--- a/WebCore/kwq/qt/qradiobutton.h
+++ b/WebCore/kwq/qt/qradiobutton.h
@@ -34,7 +34,10 @@ public:
 
     void setChecked(bool);
     bool isChecked() const;
+
+    QSize sizeHint() const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
 };
 
 #endif
-
diff --git a/WebCore/kwq/qt/qrect.h b/WebCore/kwq/qt/qrect.h
index 8ef3256..8ae969b 100644
--- a/WebCore/kwq/qt/qrect.h
+++ b/WebCore/kwq/qt/qrect.h
@@ -29,11 +29,14 @@
 #include <qsize.h>
 #include <qpoint.h>
 
+typedef struct _NSRect NSRect;
+
 class QRect {
 public:
     QRect();
     QRect(QPoint p, QSize s);
     QRect(int, int, int, int);
+    explicit QRect(const NSRect &); // don't do this implicitly since it's lossy
 
     bool isNull() const;
     bool isValid() const;
@@ -58,6 +61,8 @@ public:
     
     inline QRect operator&(const QRect &r) const { return intersect(r); }
 
+    operator NSRect() const;
+
 #ifdef _KWQ_IOSTREAM_
     friend std::ostream &operator<<(std::ostream &, const QRect &);
 #endif
diff --git a/WebCore/kwq/qt/qsize.h b/WebCore/kwq/qt/qsize.h
index ac050f7..adae534 100644
--- a/WebCore/kwq/qt/qsize.h
+++ b/WebCore/kwq/qt/qsize.h
@@ -32,10 +32,13 @@
 #include <iosfwd>
 #endif
 
+typedef struct _NSSize NSSize;
+
 class QSize {
 public:
     QSize();
     QSize(int,int);
+    explicit QSize(const NSSize &);
 
     bool isValid() const;
     int width() const { return w; }
@@ -43,6 +46,8 @@ public:
     void setWidth(int width) { w = width; }
     void setHeight(int height) { h = height; }
     QSize expandedTo(const QSize &) const;
+    
+    operator NSSize() const;
 
     friend QSize operator+(const QSize &, const QSize &);
     friend bool operator==(const QSize &, const QSize &);
diff --git a/WebCore/kwq/qt/qwidget.h b/WebCore/kwq/qt/qwidget.h
index 659f2e8..27a2614 100644
--- a/WebCore/kwq/qt/qwidget.h
+++ b/WebCore/kwq/qt/qwidget.h
@@ -62,10 +62,11 @@ public:
         WheelFocus = 0x7
     };
 
-    QWidget(QWidget *parent = 0, const char *name = 0, int f = 0);
+    QWidget(QWidget *parent = 0, const char *name = 0, int flags = 0);
     virtual ~QWidget();
 
     virtual QSize sizeHint() const;
+    
     virtual void setEnabled(bool);
     
     void setActiveWindow();
@@ -86,6 +87,7 @@ public:
     void move(const QPoint &);
 
     virtual QRect frameGeometry() const;
+    virtual void setFrameGeometry(const QRect &);
 
     virtual QWidget *topLevelWidget() const;
 
@@ -145,9 +147,6 @@ public:
     
     virtual void endEditing();
 
-protected:
-    virtual void internalSetGeometry( int x, int y, int w, int h );
-
 private:
     QWidgetPrivate *data;
 };

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list