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


The following commit has been merged in the debian/unstable branch:
commit 85a35cfb3e3395af0aa0baa5ca8107c03e8c97b6
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Wed Aug 21 17:15:09 2002 +0000

    	Implemented baseline alignment for form elements. We decided that this was better
    	than what we're currently doing. But it will look even better when the font of the
    	text field matches the font of the surrounding text, so we should consider that.
    
    	I also nudged the text down one pixel in popup menus, to match buttons. I think we
    	probably should suggest that this be done in Aqua by default (buttons and popup menus
    	already match in the normal size; this is the small size).
    
            * khtml/rendering/render_form.h: Remove some APPLE_CHANGES.
            * khtml/rendering/render_form.cpp:
            (RenderFormElement::baselinePosition): Use the widget's concept of the baseline
    	position (the new QWidget::baselinePosition function).
            (RenderButton::baselinePosition): Just call the inherited version.
            (RenderSubmitButton::baselinePosition): Remove our ifdef because we want what the
    	original code said, which was just calling the inherited version.
    	(RenderLineEdit::baselinePosition): Removed our added method since we want to just
    	call the inherited version.
            (RenderSelect::baselinePosition): Just call the inherited version for the pop up
    	menu case. For the list box, just left the old code alone until someone can take
    	a look at it.
    
            * kwq/qt/qwidget.h: Added new virtual baselinePosition function.
            * kwq/KWQWidget.mm: (QWidget::baselinePosition): Default for baseline is the bottom.
    
            * kwq/qt/qlineedit.h:
            * kwq/KWQLineEdit.mm:
            (QLineEdit::baselinePosition): Compute the baseline based on how NSTextField does it.
    	Compared to the other widgets this was easy, because the cell's drawingRectForBounds
    	gives you the place where the top of the line is. It does use defaultLineHeightForFont,
    	which is not used by other widgets, but that's no real problem.
    
            * kwq/qt/qbutton.h:
            * kwq/KWQButton.mm: Moved all the code that's push-button specific into QPushButton.
    
            * kwq/qt/qpushbutton.h:
            * kwq/KWQPushButton.mm:
            (QPushButton::QPushButton): Set the bezel style of the button.
            (QPushButton::sizeHint): Moved here from QButton.
            (QPushButton::frameGeometry): Moved here from QButton.
            (QPushButton::setFrameGeometry): Moved here from QButton.
            (QPushButton::baselinePosition): Compute the baseline based on how NSButton does it.
    	The rule for the style of button we use is "centered vertically in the available space,
    	offset by kThemePushButtonSmallTextOffset", so I had to hardcode the value of
    	kThemePushButtonSmallTextOffset; I called it VERTICAL_FUDGE_FACTOR (2).
    
            * kwq/qt/qcombobox.h:
            * kwq/KWQComboBox.mm:
            (-[KWQPopUpButtonCell drawInteriorWithFrame:inView:]): Custom cell class that nudges
    	the text down one pixel.
            (QComboBox::QComboBox): Attach the custom cell class.
            (QComboBox::baselinePosition): Compute the baseline based on how NSPopUpButton does it.
    	The rule for the style of pop-up button we use is "CELLOFFSET pixels down from the top",
    	so I had to hardcode the value of CELLOFFSET; I called it VERTICAL_FUDGE_FACTOR (2).
    
            * force-clean-timestamp: Yes, again.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@1889 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2002-12-03 b/WebCore/ChangeLog-2002-12-03
index 57f9dc4..c603eb4 100644
--- a/WebCore/ChangeLog-2002-12-03
+++ b/WebCore/ChangeLog-2002-12-03
@@ -1,3 +1,61 @@
+2002-08-21  Darin Adler  <darin at apple.com>
+
+	Implemented baseline alignment for form elements. We decided that this was better
+	than what we're currently doing. But it will look even better when the font of the
+	text field matches the font of the surrounding text, so we should consider that.
+
+	I also nudged the text down one pixel in popup menus, to match buttons. I think we
+	probably should suggest that this be done in Aqua by default (buttons and popup menus
+	already match in the normal size; this is the small size).
+
+        * khtml/rendering/render_form.h: Remove some APPLE_CHANGES.
+        * khtml/rendering/render_form.cpp:
+        (RenderFormElement::baselinePosition): Use the widget's concept of the baseline
+	position (the new QWidget::baselinePosition function).
+        (RenderButton::baselinePosition): Just call the inherited version.
+        (RenderSubmitButton::baselinePosition): Remove our ifdef because we want what the
+	original code said, which was just calling the inherited version.
+	(RenderLineEdit::baselinePosition): Removed our added method since we want to just
+	call the inherited version.
+        (RenderSelect::baselinePosition): Just call the inherited version for the pop up
+	menu case. For the list box, just left the old code alone until someone can take
+	a look at it.
+
+        * kwq/qt/qwidget.h: Added new virtual baselinePosition function.
+        * kwq/KWQWidget.mm: (QWidget::baselinePosition): Default for baseline is the bottom.
+
+        * kwq/qt/qlineedit.h:
+        * kwq/KWQLineEdit.mm:
+        (QLineEdit::baselinePosition): Compute the baseline based on how NSTextField does it.
+	Compared to the other widgets this was easy, because the cell's drawingRectForBounds
+	gives you the place where the top of the line is. It does use defaultLineHeightForFont,
+	which is not used by other widgets, but that's no real problem.
+
+        * kwq/qt/qbutton.h:
+        * kwq/KWQButton.mm: Moved all the code that's push-button specific into QPushButton.
+
+        * kwq/qt/qpushbutton.h:
+        * kwq/KWQPushButton.mm:
+        (QPushButton::QPushButton): Set the bezel style of the button.
+        (QPushButton::sizeHint): Moved here from QButton.
+        (QPushButton::frameGeometry): Moved here from QButton.
+        (QPushButton::setFrameGeometry): Moved here from QButton.
+        (QPushButton::baselinePosition): Compute the baseline based on how NSButton does it.
+	The rule for the style of button we use is "centered vertically in the available space,
+	offset by kThemePushButtonSmallTextOffset", so I had to hardcode the value of
+	kThemePushButtonSmallTextOffset; I called it VERTICAL_FUDGE_FACTOR (2).
+
+        * kwq/qt/qcombobox.h:
+        * kwq/KWQComboBox.mm:
+        (-[KWQPopUpButtonCell drawInteriorWithFrame:inView:]): Custom cell class that nudges
+	the text down one pixel.
+        (QComboBox::QComboBox): Attach the custom cell class.
+        (QComboBox::baselinePosition): Compute the baseline based on how NSPopUpButton does it.
+	The rule for the style of pop-up button we use is "CELLOFFSET pixels down from the top",
+	so I had to hardcode the value of CELLOFFSET; I called it VERTICAL_FUDGE_FACTOR (2).
+
+        * force-clean-timestamp: Yes, again.
+
 2002-08-20  Darin Adler  <darin at apple.com>
 
 	- fix 3028936 -- fields are not submitting the correct data if they are selected
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 57f9dc4..c603eb4 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,61 @@
+2002-08-21  Darin Adler  <darin at apple.com>
+
+	Implemented baseline alignment for form elements. We decided that this was better
+	than what we're currently doing. But it will look even better when the font of the
+	text field matches the font of the surrounding text, so we should consider that.
+
+	I also nudged the text down one pixel in popup menus, to match buttons. I think we
+	probably should suggest that this be done in Aqua by default (buttons and popup menus
+	already match in the normal size; this is the small size).
+
+        * khtml/rendering/render_form.h: Remove some APPLE_CHANGES.
+        * khtml/rendering/render_form.cpp:
+        (RenderFormElement::baselinePosition): Use the widget's concept of the baseline
+	position (the new QWidget::baselinePosition function).
+        (RenderButton::baselinePosition): Just call the inherited version.
+        (RenderSubmitButton::baselinePosition): Remove our ifdef because we want what the
+	original code said, which was just calling the inherited version.
+	(RenderLineEdit::baselinePosition): Removed our added method since we want to just
+	call the inherited version.
+        (RenderSelect::baselinePosition): Just call the inherited version for the pop up
+	menu case. For the list box, just left the old code alone until someone can take
+	a look at it.
+
+        * kwq/qt/qwidget.h: Added new virtual baselinePosition function.
+        * kwq/KWQWidget.mm: (QWidget::baselinePosition): Default for baseline is the bottom.
+
+        * kwq/qt/qlineedit.h:
+        * kwq/KWQLineEdit.mm:
+        (QLineEdit::baselinePosition): Compute the baseline based on how NSTextField does it.
+	Compared to the other widgets this was easy, because the cell's drawingRectForBounds
+	gives you the place where the top of the line is. It does use defaultLineHeightForFont,
+	which is not used by other widgets, but that's no real problem.
+
+        * kwq/qt/qbutton.h:
+        * kwq/KWQButton.mm: Moved all the code that's push-button specific into QPushButton.
+
+        * kwq/qt/qpushbutton.h:
+        * kwq/KWQPushButton.mm:
+        (QPushButton::QPushButton): Set the bezel style of the button.
+        (QPushButton::sizeHint): Moved here from QButton.
+        (QPushButton::frameGeometry): Moved here from QButton.
+        (QPushButton::setFrameGeometry): Moved here from QButton.
+        (QPushButton::baselinePosition): Compute the baseline based on how NSButton does it.
+	The rule for the style of button we use is "centered vertically in the available space,
+	offset by kThemePushButtonSmallTextOffset", so I had to hardcode the value of
+	kThemePushButtonSmallTextOffset; I called it VERTICAL_FUDGE_FACTOR (2).
+
+        * kwq/qt/qcombobox.h:
+        * kwq/KWQComboBox.mm:
+        (-[KWQPopUpButtonCell drawInteriorWithFrame:inView:]): Custom cell class that nudges
+	the text down one pixel.
+        (QComboBox::QComboBox): Attach the custom cell class.
+        (QComboBox::baselinePosition): Compute the baseline based on how NSPopUpButton does it.
+	The rule for the style of pop-up button we use is "CELLOFFSET pixels down from the top",
+	so I had to hardcode the value of CELLOFFSET; I called it VERTICAL_FUDGE_FACTOR (2).
+
+        * force-clean-timestamp: Yes, again.
+
 2002-08-20  Darin Adler  <darin at apple.com>
 
 	- fix 3028936 -- fields are not submitting the correct data if they are selected
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 57f9dc4..c603eb4 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,61 @@
+2002-08-21  Darin Adler  <darin at apple.com>
+
+	Implemented baseline alignment for form elements. We decided that this was better
+	than what we're currently doing. But it will look even better when the font of the
+	text field matches the font of the surrounding text, so we should consider that.
+
+	I also nudged the text down one pixel in popup menus, to match buttons. I think we
+	probably should suggest that this be done in Aqua by default (buttons and popup menus
+	already match in the normal size; this is the small size).
+
+        * khtml/rendering/render_form.h: Remove some APPLE_CHANGES.
+        * khtml/rendering/render_form.cpp:
+        (RenderFormElement::baselinePosition): Use the widget's concept of the baseline
+	position (the new QWidget::baselinePosition function).
+        (RenderButton::baselinePosition): Just call the inherited version.
+        (RenderSubmitButton::baselinePosition): Remove our ifdef because we want what the
+	original code said, which was just calling the inherited version.
+	(RenderLineEdit::baselinePosition): Removed our added method since we want to just
+	call the inherited version.
+        (RenderSelect::baselinePosition): Just call the inherited version for the pop up
+	menu case. For the list box, just left the old code alone until someone can take
+	a look at it.
+
+        * kwq/qt/qwidget.h: Added new virtual baselinePosition function.
+        * kwq/KWQWidget.mm: (QWidget::baselinePosition): Default for baseline is the bottom.
+
+        * kwq/qt/qlineedit.h:
+        * kwq/KWQLineEdit.mm:
+        (QLineEdit::baselinePosition): Compute the baseline based on how NSTextField does it.
+	Compared to the other widgets this was easy, because the cell's drawingRectForBounds
+	gives you the place where the top of the line is. It does use defaultLineHeightForFont,
+	which is not used by other widgets, but that's no real problem.
+
+        * kwq/qt/qbutton.h:
+        * kwq/KWQButton.mm: Moved all the code that's push-button specific into QPushButton.
+
+        * kwq/qt/qpushbutton.h:
+        * kwq/KWQPushButton.mm:
+        (QPushButton::QPushButton): Set the bezel style of the button.
+        (QPushButton::sizeHint): Moved here from QButton.
+        (QPushButton::frameGeometry): Moved here from QButton.
+        (QPushButton::setFrameGeometry): Moved here from QButton.
+        (QPushButton::baselinePosition): Compute the baseline based on how NSButton does it.
+	The rule for the style of button we use is "centered vertically in the available space,
+	offset by kThemePushButtonSmallTextOffset", so I had to hardcode the value of
+	kThemePushButtonSmallTextOffset; I called it VERTICAL_FUDGE_FACTOR (2).
+
+        * kwq/qt/qcombobox.h:
+        * kwq/KWQComboBox.mm:
+        (-[KWQPopUpButtonCell drawInteriorWithFrame:inView:]): Custom cell class that nudges
+	the text down one pixel.
+        (QComboBox::QComboBox): Attach the custom cell class.
+        (QComboBox::baselinePosition): Compute the baseline based on how NSPopUpButton does it.
+	The rule for the style of pop-up button we use is "CELLOFFSET pixels down from the top",
+	so I had to hardcode the value of CELLOFFSET; I called it VERTICAL_FUDGE_FACTOR (2).
+
+        * force-clean-timestamp: Yes, again.
+
 2002-08-20  Darin Adler  <darin at apple.com>
 
 	- fix 3028936 -- fields are not submitting the correct data if they are selected
diff --git a/WebCore/force-clean-timestamp b/WebCore/force-clean-timestamp
index 419d07e..f10a0c9 100644
--- a/WebCore/force-clean-timestamp
+++ b/WebCore/force-clean-timestamp
@@ -1 +1 @@
-QString rewrite 8/19
+widget change 8/20
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index 5dc4347..52a5eb7 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -70,7 +70,7 @@ RenderFormElement::~RenderFormElement()
 short RenderFormElement::baselinePosition( bool f ) const
 {
 #ifdef APPLE_CHANGES
-    return RenderWidget::baselinePosition( f ) - 6 - style()->fontMetrics().descent();
+    return marginTop() + widget()->baselinePosition();
 #else
     return RenderWidget::baselinePosition( f ) - 2 - style()->fontMetrics().descent();
 #endif
@@ -201,9 +201,7 @@ RenderButton::RenderButton(HTMLGenericFormElementImpl *element)
 short RenderButton::baselinePosition( bool f ) const
 {
 #if APPLE_CHANGES
-    // 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() - 2;
+    return RenderFormElement::baselinePosition( f );
 #else
     return RenderWidget::baselinePosition( f ) - 2;
 #endif
@@ -374,11 +372,7 @@ QString RenderSubmitButton::defaultLabel() {
 
 short RenderSubmitButton::baselinePosition( bool f ) const
 {
-#ifdef APPLE_CHANGES
-    return RenderButton::baselinePosition( f );
-#else
     return RenderFormElement::baselinePosition( f );
-#endif
 }
 
 // -------------------------------------------------------------------------------
@@ -483,16 +477,6 @@ RenderLineEdit::RenderLineEdit(HTMLInputElementImpl *element)
     setQWidget(edit);
 }
 
-#ifdef APPLE_CHANGES
-short RenderLineEdit::baselinePosition( bool f ) const
-{
-    // 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
-
 void RenderLineEdit::slotReturnPressed()
 {
     // don't submit the form when return was pressed in a completion-popup
@@ -873,9 +857,7 @@ void RenderSelect::updateFromElement()
 short RenderSelect::baselinePosition( bool f ) const
 {
     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() - 2;
+        return RenderFormElement::baselinePosition( f );
     } else {
         return RenderWidget::baselinePosition( f ) - 7;
     }
diff --git a/WebCore/khtml/rendering/render_form.h b/WebCore/khtml/rendering/render_form.h
index 4327774..8b6a8fe 100644
--- a/WebCore/khtml/rendering/render_form.h
+++ b/WebCore/khtml/rendering/render_form.h
@@ -234,9 +234,6 @@ public:
     virtual void updateFromElement();
 
     void select();
-#ifdef APPLE_CHANGES
-    short baselinePosition( bool f ) const;
-#endif
 
     KLineEdit *widget() const { return static_cast<KLineEdit*>(m_widget); }
     DOM::HTMLInputElementImpl* element() const
diff --git a/WebCore/kwq/KWQButton.h b/WebCore/kwq/KWQButton.h
index ad2449d..7407836 100644
--- a/WebCore/kwq/KWQButton.h
+++ b/WebCore/kwq/KWQButton.h
@@ -44,10 +44,6 @@ public:
     virtual void setText(const QString &);
     QString text() const;
     
-    QSize sizeHint() const;
-    QRect frameGeometry() const;
-    void setFrameGeometry(const QRect &);
-    
     virtual void clicked();
 
 private:
diff --git a/WebCore/kwq/KWQButton.mm b/WebCore/kwq/KWQButton.mm
index d8e945a..a942634 100644
--- a/WebCore/kwq/KWQButton.mm
+++ b/WebCore/kwq/KWQButton.mm
@@ -27,13 +27,6 @@
 
 #import <qcheckbox.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
-
 @interface KWQButtonAdapter : NSObject
 {
     QButton *button;
@@ -54,7 +47,6 @@ QButton::QButton()
     [button setAction:@selector(action:)];
 
     [button setTitle:@""];
-    [button setBezelStyle:NSRoundedBezelStyle];
     [[button cell] setControlSize:NSSmallControlSize];
     [button setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
 
@@ -68,28 +60,6 @@ QButton::~QButton()
     [m_adapter release];
 }
 
-QSize QButton::sizeHint() const 
-{
-    NSButton *button = (NSButton *)getView();
-    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)
 {
     NSButton *button = (NSButton *)getView();
diff --git a/WebCore/kwq/KWQComboBox.h b/WebCore/kwq/KWQComboBox.h
index 116fb30..21a2160 100644
--- a/WebCore/kwq/KWQComboBox.h
+++ b/WebCore/kwq/KWQComboBox.h
@@ -52,6 +52,7 @@ public:
     QSize sizeHint() const;
     QRect frameGeometry() const;
     void setFrameGeometry(const QRect &);
+    int baselinePosition() const;
 
     bool eventFilter(QObject *object, QEvent *event) { return false; }
 
diff --git a/WebCore/kwq/KWQComboBox.mm b/WebCore/kwq/KWQComboBox.mm
index 3d3d561..013c10a 100644
--- a/WebCore/kwq/KWQComboBox.mm
+++ b/WebCore/kwq/KWQComboBox.mm
@@ -34,6 +34,11 @@
 #define LEFT_MARGIN 3
 #define RIGHT_MARGIN 3
 
+#define TEXT_VERTICAL_NUDGE 1
+
+// This is the 2-pixel CELLOFFSET for bordered cells from NSCell.
+#define VERTICAL_FUDGE_FACTOR 2
+
 @interface KWQComboBoxAdapter : NSObject
 {
     QComboBox *box;
@@ -44,11 +49,31 @@
 
 @end
 
+ at interface KWQPopUpButtonCell : NSPopUpButtonCell
+{
+}
+ at end
+
+ at implementation KWQPopUpButtonCell
+
+- (void)drawInteriorWithFrame:(NSRect)cellFrame inView:(NSView *)controlView
+{
+    cellFrame.origin.y += TEXT_VERTICAL_NUDGE;
+    cellFrame.size.height -= TEXT_VERTICAL_NUDGE;
+    [super drawInteriorWithFrame:cellFrame inView:controlView];
+}
+
+ at end
+
 QComboBox::QComboBox()
     : m_activated(this, SIGNAL(activated(int)))
     , m_adapter([[KWQComboBoxAdapter alloc] initWithQComboBox:this])
 {
     NSPopUpButton *button = [[NSPopUpButton alloc] init];
+    
+    KWQPopUpButtonCell *cell = [[KWQPopUpButtonCell alloc] init];
+    [button setCell:cell];
+    [cell release];
 
     [button setTarget:m_adapter];
     [button setAction:@selector(action:)];
@@ -100,9 +125,17 @@ QRect QComboBox::frameGeometry() const
 
 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));
+    QWidget::setFrameGeometry(QRect(-LEFT_MARGIN + r.x(), -TOP_MARGIN + r.y(),
+        LEFT_MARGIN + r.width() + RIGHT_MARGIN,
+        TOP_MARGIN + r.height() + BOTTOM_MARGIN));
+}
+
+int QComboBox::baselinePosition() const
+{
+    // Menu text is at the top.
+    NSPopUpButton *button = (NSButton *)getView();
+    return (int)ceil(-TOP_MARGIN + VERTICAL_FUDGE_FACTOR
+        + TEXT_VERTICAL_NUDGE + [[button font] ascender]);
 }
 
 void QComboBox::clear()
diff --git a/WebCore/kwq/KWQLineEdit.h b/WebCore/kwq/KWQLineEdit.h
index bbe84bd..dc002b5 100644
--- a/WebCore/kwq/KWQLineEdit.h
+++ b/WebCore/kwq/KWQLineEdit.h
@@ -57,6 +57,7 @@ public:
     QSize sizeForCharacterWidth(int numCharacters) const;
     QRect frameGeometry() const;
     void setFrameGeometry(const QRect &);
+    int baselinePosition() const;
     
     void returnPressed() { m_returnPressed.call(); }
     void textChanged() { m_textChanged.call(text()); }
diff --git a/WebCore/kwq/KWQLineEdit.mm b/WebCore/kwq/KWQLineEdit.mm
index cf02632..4e2eeda 100644
--- a/WebCore/kwq/KWQLineEdit.mm
+++ b/WebCore/kwq/KWQLineEdit.mm
@@ -29,6 +29,9 @@
 #import <kwqdebug.h>
 #import <WebCoreTextRendererFactory.h>
 
+// This replicates constants from [NSTextFieldCell drawingRectForBounds].
+#define VERTICAL_FUDGE_FACTOR 3
+
 QLineEdit::QLineEdit()
     : m_returnPressed(this, SIGNAL(returnPressed()))
     , m_textChanged(this, SIGNAL(textChanged(const QString &)))
@@ -156,3 +159,12 @@ 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));
 }
+
+int QLineEdit::baselinePosition() const
+{
+    KWQNSTextField *textField = (KWQNSTextField *)getView();
+    NSRect bounds = [textField bounds];
+    NSFont *font = [textField font];
+    return (int)ceil([[textField cell] drawingRectForBounds:bounds].origin.y - bounds.origin.y
+        + [font defaultLineHeightForFont] + [font descender]);
+}
diff --git a/WebCore/kwq/KWQPushButton.h b/WebCore/kwq/KWQPushButton.h
index 29044d1..48808cd 100644
--- a/WebCore/kwq/KWQPushButton.h
+++ b/WebCore/kwq/KWQPushButton.h
@@ -30,8 +30,13 @@
 
 class QPushButton : public QButton {
 public:
-    QPushButton(QWidget *parent) { }
+    QPushButton(QWidget *parent);
     QPushButton(const QString &text, QWidget *parent);
+
+    QSize sizeHint() const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
+    int baselinePosition() const;
 };
 
 #endif
diff --git a/WebCore/kwq/KWQPushButton.mm b/WebCore/kwq/KWQPushButton.mm
index d540748..a10aee4 100644
--- a/WebCore/kwq/KWQPushButton.mm
+++ b/WebCore/kwq/KWQPushButton.mm
@@ -25,7 +25,60 @@
 
 #import <qpushbutton.h>
 
-QPushButton::QPushButton(const QString &text, QWidget *parent)
+// 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
+
+// AppKit calls this kThemePushButtonSmallTextOffset.
+#define VERTICAL_FUDGE_FACTOR 2
+
+QPushButton::QPushButton(QWidget *)
+{
+    NSButton *button = (NSButton *)getView();
+    [button setBezelStyle:NSRoundedBezelStyle];
+}
+
+QPushButton::QPushButton(const QString &text, QWidget *)
 {
+    NSButton *button = (NSButton *)getView();
+    [button setBezelStyle:NSRoundedBezelStyle];
+
     setText(text);
 }
+
+QSize QPushButton::sizeHint() const 
+{
+    NSButton *button = (NSButton *)getView();
+    return QSize((int)[[button cell] cellSize].width - (LEFT_MARGIN + RIGHT_MARGIN),
+        (int)[[button cell] cellSize].height - (TOP_MARGIN + BOTTOM_MARGIN));
+}
+
+QRect QPushButton::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 QPushButton::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));
+}
+
+int QPushButton::baselinePosition() const
+{
+    // Button text is centered vertically, with a fudge factor to account for the shadow.
+    NSButton *button = (NSButton *)getView();
+    NSFont *font = [button font];
+    float ascender = [font ascender];
+    float descender = [font descender];
+    return (int)ceil(-TOP_MARGIN
+        + ((height() + TOP_MARGIN + BOTTOM_MARGIN) - (ascender - descender)) / 2.0
+        + ascender - VERTICAL_FUDGE_FACTOR);
+}
diff --git a/WebCore/kwq/KWQWidget.h b/WebCore/kwq/KWQWidget.h
index 795a903..62f2322 100644
--- a/WebCore/kwq/KWQWidget.h
+++ b/WebCore/kwq/KWQWidget.h
@@ -90,6 +90,8 @@ public:
     virtual QRect frameGeometry() const;
     virtual void setFrameGeometry(const QRect &);
 
+    virtual int baselinePosition() const; // relative to the top of the widget
+
     virtual QWidget *topLevelWidget() const;
 
     virtual QPoint mapToGlobal(const QPoint &) const;
diff --git a/WebCore/kwq/KWQWidget.mm b/WebCore/kwq/KWQWidget.mm
index 9ac6ede..31666b1 100644
--- a/WebCore/kwq/KWQWidget.mm
+++ b/WebCore/kwq/KWQWidget.mm
@@ -151,6 +151,11 @@ QRect QWidget::frameGeometry() const
     return QRect((int)vFrame.origin.x, (int)vFrame.origin.y, (int)vFrame.size.width, (int)vFrame.size.height);
 }
 
+int QWidget::baselinePosition() const
+{
+    return height();
+}
+
 QWidget *QWidget::topLevelWidget() const 
 {
     NSWindow *window = nil;
diff --git a/WebCore/kwq/qt/qbutton.h b/WebCore/kwq/qt/qbutton.h
index ad2449d..7407836 100644
--- a/WebCore/kwq/qt/qbutton.h
+++ b/WebCore/kwq/qt/qbutton.h
@@ -44,10 +44,6 @@ public:
     virtual void setText(const QString &);
     QString text() const;
     
-    QSize sizeHint() const;
-    QRect frameGeometry() const;
-    void setFrameGeometry(const QRect &);
-    
     virtual void clicked();
 
 private:
diff --git a/WebCore/kwq/qt/qcombobox.h b/WebCore/kwq/qt/qcombobox.h
index 116fb30..21a2160 100644
--- a/WebCore/kwq/qt/qcombobox.h
+++ b/WebCore/kwq/qt/qcombobox.h
@@ -52,6 +52,7 @@ public:
     QSize sizeHint() const;
     QRect frameGeometry() const;
     void setFrameGeometry(const QRect &);
+    int baselinePosition() const;
 
     bool eventFilter(QObject *object, QEvent *event) { return false; }
 
diff --git a/WebCore/kwq/qt/qlineedit.h b/WebCore/kwq/qt/qlineedit.h
index bbe84bd..dc002b5 100644
--- a/WebCore/kwq/qt/qlineedit.h
+++ b/WebCore/kwq/qt/qlineedit.h
@@ -57,6 +57,7 @@ public:
     QSize sizeForCharacterWidth(int numCharacters) const;
     QRect frameGeometry() const;
     void setFrameGeometry(const QRect &);
+    int baselinePosition() const;
     
     void returnPressed() { m_returnPressed.call(); }
     void textChanged() { m_textChanged.call(text()); }
diff --git a/WebCore/kwq/qt/qpushbutton.h b/WebCore/kwq/qt/qpushbutton.h
index 29044d1..48808cd 100644
--- a/WebCore/kwq/qt/qpushbutton.h
+++ b/WebCore/kwq/qt/qpushbutton.h
@@ -30,8 +30,13 @@
 
 class QPushButton : public QButton {
 public:
-    QPushButton(QWidget *parent) { }
+    QPushButton(QWidget *parent);
     QPushButton(const QString &text, QWidget *parent);
+
+    QSize sizeHint() const;
+    QRect frameGeometry() const;
+    void setFrameGeometry(const QRect &);
+    int baselinePosition() const;
 };
 
 #endif
diff --git a/WebCore/kwq/qt/qwidget.h b/WebCore/kwq/qt/qwidget.h
index 795a903..62f2322 100644
--- a/WebCore/kwq/qt/qwidget.h
+++ b/WebCore/kwq/qt/qwidget.h
@@ -90,6 +90,8 @@ public:
     virtual QRect frameGeometry() const;
     virtual void setFrameGeometry(const QRect &);
 
+    virtual int baselinePosition() const; // relative to the top of the widget
+
     virtual QWidget *topLevelWidget() const;
 
     virtual QPoint mapToGlobal(const QPoint &) const;

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list