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


The following commit has been merged in the debian/unstable branch:
commit 00cd6e397db35676ec970c35c341f6e2e567317c
Author: darin <darin at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Mon Nov 3 23:44:32 2003 +0000

            Reviewed by John.
    
            - fixed 3392543 -- incorrect base writing direction in RTL form controls
            - fixed baseline for list box <select> elements
            - moved style code from updateFromElement to setStyle
    
            * khtml/rendering/render_form.h: Added setStyle function to RenderFormElement, RenderLineEdit,
            RenderSelect, and RenderTextArea. Removed some unused stuff.
            * khtml/rendering/render_form.cpp:
            (RenderFormElement::setStyle): Set the font based on the style.
            (RenderFormElement::updateFromElement): Remove font setting code; moved to setStyle.
            Also ifdef'd out the color-setting code, which belongs in setStyle and is irrelevant
            for KWQ anyway.
            (RenderSubmitButton::setStyle): Set the writing direction based on the style.
            (RenderSubmitButton::updateFromElement): Tiny code cleanup, using a local variable.
            (RenderLineEdit::setStyle): Set the alignment and writing direction based on the style.
            (RenderLineEdit::updateFromElement): Remove alignment setting code; moved to setStyle.
            (RenderFileButton::RenderFileButton): Remove code to set m_focus, a data member that was
            never used.
            (RenderSelect::setWidgetWritingDirection): Added. Helper function.
            (RenderSelect::setStyle): Call setWidgetWritingDirection.
            (RenderSelect::updateFromElement): Call setWidgetWritingDirection if a new widget is created.
            (RenderSelect::baselinePosition): Added a FIXME comment.
            (RenderTextArea::setStyle): Set the alignment and writing direction based on the style.
            (RenderTextArea::updateFromElement): Remove alignment setting code; moved to setStyle.
    
            * kwq/KWQButton.h: Added setWritingDirection function.
            * kwq/KWQButton.mm:
            (+[KWQButton cellClass]): Use KWQButtonCell.
            (-[KWQButtonCell baseWritingDirection:]): Return base writing direction.
            (-[KWQButtonCell setBaseWritingDirection:]): Store base writing direction.
            (-[KWQButtonCell _textAttributes]): Set the base writing direction in the paragraph
            style if it's not already right.
            (QButton::setWritingDirection): Call setBaseWritingDirection: on the cell and do
            setNeedsDisplay: as needed.
    
            * kwq/KWQComboBox.h: Added setWritingDirection function.
            * kwq/KWQComboBox.mm:
            (QComboBox::setWritingDirection): Call setBaseWritingDirection: on the cell and do
            setNeedsDisplay: as needed.
            (-[KWQPopUpButtonCell setBaseWritingDirection:]): Store base writing direction.
            (-[KWQPopUpButtonCell baseWritingDirection:]): Return base writing direction.
            (-[KWQPopUpButtonCell _textAttributes]): Set the base writing direction in the
            paragraph style if it's not already right.
    
            * kwq/KWQLineEdit.h: Added setWritingDirection function.
            * kwq/KWQLineEdit.mm:
            (QLineEdit::setAlignment): Tweaked to match new setWritingDirection in style.
            (QLineEdit::setWritingDirection): Call setBaseWritingDirection: on the KWQTextField.
    
            * kwq/KWQTextField.h: Added setBaseWritingDirection method.
            * kwq/KWQTextField.mm:
            (-[KWQTextField setPasswordMode:]): Set the base writing direction of the secure field's
            cell based on the base writing direction of the parent field's cell, when creating the
            secure field.
            (-[KWQTextField setBaseWritingDirection:]): Added. Sets the base writing direction of
            the field's cell and the secure field's cell, if it exists, and does setNeedsDisplay
            as needed.
            (-[KWQTextFieldCell setBaseWritingDirection:]): Added. Stores the base writing direction.
            (-[KWQTextFieldCell baseWritingDirection]): Added. Returns the base writing direction.
            (-[KWQTextFieldCell _textAttributes]): Set the base writing direction in the paragraph
            style if it's not already right.
            (-[KWQSecureTextFieldCell setBaseWritingDirection:]): Added. Stores the base writing
            direction.
            (-[KWQSecureTextFieldCell _textAttributes]): Set the base writing direction in the
            paragraph style if it's not already right.
    
            * kwq/KWQListBox.h: Added itemIsGroupLabel and setWritingDirection functions, and made
            the private insertItem function take a QString instead of an NSObject.
            (QListBox::insertItem): Changed parameter from unsigned to int to match Qt, and made it
            use an inlne to call the private insertItem function shared with insertGroupLabel.
            (QListBox::insertGroupLabel): Changed parameter from unsigned to int and made it use an
            inline to call the private insertItem function.
            * kwq/KWQListBox.mm:
            (itemFont): Added. Returns a suitable font for individual items.
            (groupLabelFont): Added. Returns a suitable font for group labels.
            (paragraphStyle): Added. Returns a suitable paragraph style for a given writing direction.
            (stringAttributes): Added. Returns a string attributes dictionary for a given writing direction for
            either individual items or group labels.
            (QListBox::insertItem): Use an attributed string to give the item the appropriate font and
            writing direction, calling stringAttributes to get the attributes dictionary, and getting
            the writing direction from the table view.
            (QListBox::endBatchInsert): Tweak for consistency with other nearby methods.
            (QListBox::setSelected): Add an assertion and tweak a bit.
            (QListBox::isSelected): Add an assertion and tweak a bit.
            (QListBox::setWritingDirection): Update the styles for all the attributed strings and call
            reloadData if the writing direction changes. Also store the direction in the table view.
            (QListBox::itemIsGroupLabel): Added. Returns true if a given item is a group label; works
            by checking the font in the attributed string.
            (-[KWQTableView initWithListBox:items:]): Use itemFont() instead of computing the font.
            (-[KWQTableView tableView:shouldSelectRow:]): Use itemIsGroupLabel function instead of
            checking for NSString vs. NSttributedString in the items array; we now use attributed
            strings for all the items.
            (-[KWQTableView setBaseWritingDirection:]): Added. Stores a base writing direction.
            (-[KWQTableView baseWritingDirection]): Added. Returns the stored base writing direction.
    
            * kwq/KWQTextEdit.h: Added setWritingDirection function.
            * kwq/KWQTextEdit.mm:
            (QTextEdit::setAlignment): Removed code to set base writing direction.
            (QTextEdit::setWritingDirection): Added. Sets base writing direction.
    
            * kwq/KWQTextArea.mm: (-[KWQTextArea setBaseWritingDirection:]): Call setNeedsDisplay:YES.
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5373 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 635b0c2..03e2469 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,108 @@
+2003-11-03  Darin Adler  <darin at apple.com>
+
+        Reviewed by John.
+
+        - fixed 3392543 -- incorrect base writing direction in RTL form controls
+        - fixed baseline for list box <select> elements
+        - moved style code from updateFromElement to setStyle
+
+        * khtml/rendering/render_form.h: Added setStyle function to RenderFormElement, RenderLineEdit,
+        RenderSelect, and RenderTextArea. Removed some unused stuff.
+        * khtml/rendering/render_form.cpp:
+        (RenderFormElement::setStyle): Set the font based on the style.
+        (RenderFormElement::updateFromElement): Remove font setting code; moved to setStyle.
+        Also ifdef'd out the color-setting code, which belongs in setStyle and is irrelevant
+        for KWQ anyway.
+        (RenderSubmitButton::setStyle): Set the writing direction based on the style.
+        (RenderSubmitButton::updateFromElement): Tiny code cleanup, using a local variable.
+        (RenderLineEdit::setStyle): Set the alignment and writing direction based on the style.
+        (RenderLineEdit::updateFromElement): Remove alignment setting code; moved to setStyle.
+        (RenderFileButton::RenderFileButton): Remove code to set m_focus, a data member that was
+        never used.
+        (RenderSelect::setWidgetWritingDirection): Added. Helper function.
+        (RenderSelect::setStyle): Call setWidgetWritingDirection.
+        (RenderSelect::updateFromElement): Call setWidgetWritingDirection if a new widget is created.
+        (RenderSelect::baselinePosition): Added a FIXME comment.
+        (RenderTextArea::setStyle): Set the alignment and writing direction based on the style.
+        (RenderTextArea::updateFromElement): Remove alignment setting code; moved to setStyle.
+
+        * kwq/KWQButton.h: Added setWritingDirection function.
+        * kwq/KWQButton.mm:
+        (+[KWQButton cellClass]): Use KWQButtonCell.
+        (-[KWQButtonCell baseWritingDirection:]): Return base writing direction.
+        (-[KWQButtonCell setBaseWritingDirection:]): Store base writing direction.
+        (-[KWQButtonCell _textAttributes]): Set the base writing direction in the paragraph
+        style if it's not already right.
+        (QButton::setWritingDirection): Call setBaseWritingDirection: on the cell and do
+        setNeedsDisplay: as needed.
+
+        * kwq/KWQComboBox.h: Added setWritingDirection function.
+        * kwq/KWQComboBox.mm:
+        (QComboBox::setWritingDirection): Call setBaseWritingDirection: on the cell and do
+        setNeedsDisplay: as needed.
+        (-[KWQPopUpButtonCell setBaseWritingDirection:]): Store base writing direction.
+        (-[KWQPopUpButtonCell baseWritingDirection:]): Return base writing direction.
+        (-[KWQPopUpButtonCell _textAttributes]): Set the base writing direction in the
+        paragraph style if it's not already right.
+
+        * kwq/KWQLineEdit.h: Added setWritingDirection function.
+        * kwq/KWQLineEdit.mm:
+        (QLineEdit::setAlignment): Tweaked to match new setWritingDirection in style.
+        (QLineEdit::setWritingDirection): Call setBaseWritingDirection: on the KWQTextField.
+
+        * kwq/KWQTextField.h: Added setBaseWritingDirection method.
+        * kwq/KWQTextField.mm:
+        (-[KWQTextField setPasswordMode:]): Set the base writing direction of the secure field's
+        cell based on the base writing direction of the parent field's cell, when creating the
+        secure field.
+        (-[KWQTextField setBaseWritingDirection:]): Added. Sets the base writing direction of
+        the field's cell and the secure field's cell, if it exists, and does setNeedsDisplay
+        as needed.
+        (-[KWQTextFieldCell setBaseWritingDirection:]): Added. Stores the base writing direction.
+        (-[KWQTextFieldCell baseWritingDirection]): Added. Returns the base writing direction.
+        (-[KWQTextFieldCell _textAttributes]): Set the base writing direction in the paragraph
+        style if it's not already right.
+        (-[KWQSecureTextFieldCell setBaseWritingDirection:]): Added. Stores the base writing
+        direction.
+        (-[KWQSecureTextFieldCell _textAttributes]): Set the base writing direction in the
+        paragraph style if it's not already right.
+
+        * kwq/KWQListBox.h: Added itemIsGroupLabel and setWritingDirection functions, and made
+        the private insertItem function take a QString instead of an NSObject.
+        (QListBox::insertItem): Changed parameter from unsigned to int to match Qt, and made it
+        use an inlne to call the private insertItem function shared with insertGroupLabel.
+        (QListBox::insertGroupLabel): Changed parameter from unsigned to int and made it use an
+        inline to call the private insertItem function.
+        * kwq/KWQListBox.mm:
+        (itemFont): Added. Returns a suitable font for individual items.
+        (groupLabelFont): Added. Returns a suitable font for group labels.
+        (paragraphStyle): Added. Returns a suitable paragraph style for a given writing direction.
+        (stringAttributes): Added. Returns a string attributes dictionary for a given writing direction for
+        either individual items or group labels.
+        (QListBox::insertItem): Use an attributed string to give the item the appropriate font and
+        writing direction, calling stringAttributes to get the attributes dictionary, and getting
+        the writing direction from the table view.
+        (QListBox::endBatchInsert): Tweak for consistency with other nearby methods.
+        (QListBox::setSelected): Add an assertion and tweak a bit.
+        (QListBox::isSelected): Add an assertion and tweak a bit.
+        (QListBox::setWritingDirection): Update the styles for all the attributed strings and call
+        reloadData if the writing direction changes. Also store the direction in the table view.
+        (QListBox::itemIsGroupLabel): Added. Returns true if a given item is a group label; works
+        by checking the font in the attributed string.
+        (-[KWQTableView initWithListBox:items:]): Use itemFont() instead of computing the font.
+        (-[KWQTableView tableView:shouldSelectRow:]): Use itemIsGroupLabel function instead of
+        checking for NSString vs. NSttributedString in the items array; we now use attributed
+        strings for all the items.
+        (-[KWQTableView setBaseWritingDirection:]): Added. Stores a base writing direction.
+        (-[KWQTableView baseWritingDirection]): Added. Returns the stored base writing direction.
+
+        * kwq/KWQTextEdit.h: Added setWritingDirection function.
+        * kwq/KWQTextEdit.mm:
+        (QTextEdit::setAlignment): Removed code to set base writing direction.
+        (QTextEdit::setWritingDirection): Added. Sets base writing direction.
+
+        * kwq/KWQTextArea.mm: (-[KWQTextArea setBaseWritingDirection:]): Call setNeedsDisplay:YES.
+
 2003-11-03  David Hyatt  <hyatt at apple.com>
 
 	Fix 3472200, media tests fail to parse correctly.  Merging a patch to handle exotic media types
diff --git a/WebCore/khtml/rendering/render_form.cpp b/WebCore/khtml/rendering/render_form.cpp
index 9825853..db80bff 100644
--- a/WebCore/khtml/rendering/render_form.cpp
+++ b/WebCore/khtml/rendering/render_form.cpp
@@ -76,13 +76,28 @@ short RenderFormElement::baselinePosition( bool f, bool isRootLineBox ) const
 #endif
 }
 
-void RenderFormElement::updateFromElement()
+void RenderFormElement::setStyle(RenderStyle* s)
 {
-    m_widget->setEnabled(!element()->disabled());
 #if APPLE_CHANGES
-    m_widget->setFont(style()->font());
+    if (canHaveIntrinsicMargins())
+        addIntrinsicMarginsIfAllowed(s);
+#endif
+
+    RenderWidget::setStyle(s);
+
+#if APPLE_CHANGES
+    // Do not paint a background or border for Aqua form elements
+    setShouldPaintBackgroundOrBorder(false);
 #endif
 
+    m_widget->setFont(style()->font());
+}
+
+void RenderFormElement::updateFromElement()
+{
+    m_widget->setEnabled(!element()->disabled());
+
+#if !APPLE_CHANGES
     QColor color = style()->color();
     QColor backgroundColor = style()->backgroundColor();
 
@@ -144,6 +159,7 @@ void RenderFormElement::updateFromElement()
     }
     else
         m_widget->unsetPalette();
+#endif
 }
 
 void RenderFormElement::layout()
@@ -187,6 +203,7 @@ void RenderFormElement::slotClicked()
 }
 
 #if APPLE_CHANGES
+
 void RenderFormElement::addIntrinsicMarginsIfAllowed(RenderStyle* _style)
 {
     if (_style->width().isVariable()) {
@@ -204,15 +221,6 @@ void RenderFormElement::addIntrinsicMarginsIfAllowed(RenderStyle* _style)
     }
 }
 
-void RenderFormElement::setStyle(RenderStyle* _style)
-{
-    if (canHaveIntrinsicMargins())
-        addIntrinsicMarginsIfAllowed(_style);
-    RenderWidget::setStyle(_style);
-
-    // Do not paint a background or border for Aqua form elements
-    setShouldPaintBackgroundOrBorder(false);
-}
 #endif
 
 // -------------------------------------------------------------------------
@@ -383,11 +391,25 @@ void RenderSubmitButton::calcMinMaxWidth()
     RenderButton::calcMinMaxWidth();
 }
 
+#if APPLE_CHANGES
+
+void RenderSubmitButton::setStyle(RenderStyle *s)
+{
+    RenderButton::setStyle(s);
+    
+    QPushButton *w = static_cast<QPushButton*>(m_widget);
+    w->setWritingDirection(style()->direction() == RTL ? QPainter::RTL : QPainter::LTR);
+}
+
+#endif
+
 void RenderSubmitButton::updateFromElement()
 {
-    QString oldText = static_cast<QPushButton*>(m_widget)->text();
+    QPushButton *w = static_cast<QPushButton*>(m_widget);
+
+    QString oldText = w->text();
     QString newText = rawText();
-    static_cast<QPushButton*>(m_widget)->setText(newText);
+    w->setText(newText);
     if ( oldText != newText )
         setNeedsLayoutAndMinMaxRecalc();
     RenderFormElement::updateFromElement();
@@ -553,6 +575,18 @@ void RenderLineEdit::calcMinMaxWidth()
     RenderFormElement::calcMinMaxWidth();
 }
 
+void RenderLineEdit::setStyle(RenderStyle *s)
+{
+    RenderFormElement::setStyle(s);
+
+    KLineEdit *w = widget();
+
+    w->setAlignment(style()->direction() == RTL ? Qt::AlignRight : Qt::AlignLeft);
+#if APPLE_CHANGES
+    w->setWritingDirection(style()->direction() == RTL ? QPainter::RTL : QPainter::LTR);
+#endif
+}
+
 void RenderLineEdit::updateFromElement()
 {
     KLineEdit *w = widget();
@@ -585,8 +619,6 @@ void RenderLineEdit::updateFromElement()
     }
     w->setReadOnly(element()->readOnly());
     
-    w->setAlignment(style()->direction() == RTL ? Qt::AlignRight : Qt::AlignLeft);
-
     RenderFormElement::updateFromElement();
 }
 
@@ -776,7 +808,6 @@ RenderFileButton::RenderFileButton(HTMLInputElementImpl *element)
     w->setFocusProxy(m_edit);
 
     setQWidget(w);
-    m_haveFocus = false;
 #endif
 }
 
@@ -807,6 +838,8 @@ void RenderFileButton::calcMinMaxWidth()
     RenderFormElement::calcMinMaxWidth();
 }
 
+#if !APPLE_CHANGES
+
 void RenderFileButton::handleFocusOut()
 {
     if ( m_edit && m_edit->edited() ) {
@@ -815,6 +848,8 @@ void RenderFileButton::handleFocusOut()
     }
 }
 
+#endif
+
 void RenderFileButton::slotClicked()
 {
 #if APPLE_CHANGES
@@ -952,6 +987,25 @@ RenderSelect::RenderSelect(HTMLSelectElementImpl *element)
         setQWidget(createComboBox());
 }
 
+#if APPLE_CHANGES
+
+void RenderSelect::setWidgetWritingDirection()
+{
+    QPainter::TextDirection d = style()->direction() == RTL ? QPainter::RTL : QPainter::LTR;
+    if (m_useListBox)
+        static_cast<KListBox *>(m_widget)->setWritingDirection(d);
+    else
+        static_cast<ComboBoxWidget *>(m_widget)->setWritingDirection(d);
+}
+
+void RenderSelect::setStyle(RenderStyle *s)
+{
+    RenderFormElement::setStyle(s);
+    setWidgetWritingDirection();
+}
+
+#endif
+
 void RenderSelect::updateFromElement()
 {
     m_ignoreSelectEvents = true;
@@ -974,6 +1028,9 @@ void RenderSelect::updateFromElement()
                 setQWidget(createListBox());
             else
                 setQWidget(createComboBox());
+#if APPLE_CHANGES
+            setWidgetWritingDirection();
+#endif
         }
 
         if (m_useListBox && oldMultiple != m_multiple) {
@@ -1052,22 +1109,23 @@ void RenderSelect::updateFromElement()
         updateSelection();
     }
 
-
     m_ignoreSelectEvents = false;
 
     RenderFormElement::updateFromElement();
 }
 
 #if APPLE_CHANGES
-// Override to deal with our widget.
+
 short RenderSelect::baselinePosition( bool f, bool isRootLineBox ) const
 {
-    if (!m_useListBox) {
-        return RenderFormElement::baselinePosition( f, isRootLineBox );
-    } else {
+    if (m_useListBox) {
+        // FIXME: Should get the hardcoded constant of 7 by calling a QListBox function,
+        // as we do for other widget classes.
         return RenderWidget::baselinePosition( f, isRootLineBox ) - 7;
     }
+    return RenderFormElement::baselinePosition( f, isRootLineBox );
 }
+
 #endif
 
 void RenderSelect::calcMinMaxWidth()
@@ -1378,14 +1436,24 @@ void RenderTextArea::calcMinMaxWidth()
     RenderFormElement::calcMinMaxWidth();
 }
 
+void RenderTextArea::setStyle(RenderStyle *s)
+{
+    RenderFormElement::setStyle(s);
+
+    TextAreaWidget* w = static_cast<TextAreaWidget*>(m_widget);
+    w->setAlignment(style()->direction() == RTL ? Qt::AlignRight : Qt::AlignLeft);
+#if APPLE_CHANGES
+    w->setWritingDirection(style()->direction() == RTL ? QPainter::RTL : QPainter::LTR);
+#endif
+}
+
 void RenderTextArea::updateFromElement()
 {
     TextAreaWidget* w = static_cast<TextAreaWidget*>(m_widget);
     w->setReadOnly(element()->readOnly());
-#ifdef APPLE_CHANGES
+#if APPLE_CHANGES
     w->setDisabled(element()->disabled());
 #endif
-    w->setAlignment(style()->direction() == RTL ? Qt::AlignRight : Qt::AlignLeft);
     
     // Call w->text() before calling element()->value(), because in the case of inline
     // input such as Hiragana, w->text() has a side effect of sending the notification
diff --git a/WebCore/khtml/rendering/render_form.h b/WebCore/khtml/rendering/render_form.h
index 63c306d..38068ea 100644
--- a/WebCore/khtml/rendering/render_form.h
+++ b/WebCore/khtml/rendering/render_form.h
@@ -92,10 +92,9 @@ public:
     void addIntrinsicMarginsIfAllowed(RenderStyle* _style);
     virtual bool canHaveIntrinsicMargins() const { return false; }
     int intrinsicMargin() const { return 2; }
-
-    virtual void setStyle(RenderStyle* _style);
 #endif
 
+    virtual void setStyle(RenderStyle *);
     virtual void updateFromElement();
 
     virtual void layout();
@@ -194,6 +193,10 @@ public:
     virtual void calcMinMaxWidth();
     virtual void updateFromElement();
     virtual short baselinePosition( bool, bool ) const;
+#if APPLE_CHANGES
+    virtual void setStyle(RenderStyle *);
+#endif
+
 private:
     QString rawText();
 };
@@ -247,6 +250,7 @@ public:
 
     virtual const char *renderName() const { return "RenderLineEdit"; }
     virtual void updateFromElement();
+    virtual void setStyle(RenderStyle *);
 
     void select();
 
@@ -319,7 +323,9 @@ public:
     DOM::HTMLInputElementImpl *element() const
     { return static_cast<DOM::HTMLInputElementImpl*>(RenderObject::element()); }
 
+#if !APPLE_CHANGES
     KLineEdit* lineEdit() const { return m_edit; }
+#endif
 
 public slots:
     virtual void slotClicked();
@@ -327,14 +333,14 @@ public slots:
     virtual void slotTextChanged(const QString &string);
 
 protected:
-    virtual void handleFocusOut();
-
     virtual bool isEditable() const { return true; }
 
-    bool m_clicked;
-    bool m_haveFocus;
+#if !APPLE_CHANGES
+    virtual void handleFocusOut();
+
     KLineEdit   *m_edit;
     QPushButton *m_button;
+#endif
 };
 
 
@@ -395,6 +401,9 @@ public:
     bool selectionChanged() { return m_selectionChanged; }
     void setSelectionChanged(bool _selectionChanged) { m_selectionChanged = _selectionChanged; }
     virtual void updateFromElement();
+#if APPLE_CHANGES
+    virtual void setStyle(RenderStyle *);
+#endif
 
     void updateSelection();
 
@@ -404,6 +413,9 @@ public:
 protected:
     KListBox *createListBox();
     ComboBoxWidget *createComboBox();
+#if APPLE_CHANGES
+    void setWidgetWritingDirection();
+#endif
 
     unsigned  m_size;
     bool m_multiple;
@@ -443,6 +455,7 @@ public:
     virtual void calcMinMaxWidth();
     virtual void close ( );
     virtual void updateFromElement();
+    virtual void setStyle(RenderStyle *);
 
     virtual bool isTextArea() const { return true; }
     
diff --git a/WebCore/kwq/KWQButton.h b/WebCore/kwq/KWQButton.h
index 11c8d4f..5e334eb 100644
--- a/WebCore/kwq/KWQButton.h
+++ b/WebCore/kwq/KWQButton.h
@@ -37,13 +37,14 @@ public:
 
     virtual void setText(const QString &);
     QString text() const;
+
+    void setWritingDirection(QPainter::TextDirection);
     
     virtual void clicked();
     virtual void simulateClick();
 
     // QWidget overrides
     virtual void setFont(const QFont &);
-
     virtual FocusPolicy focusPolicy() const;
 
 private:
diff --git a/WebCore/kwq/KWQButton.mm b/WebCore/kwq/KWQButton.mm
index 95bd347..1c33c06 100644
--- a/WebCore/kwq/KWQButton.mm
+++ b/WebCore/kwq/KWQButton.mm
@@ -34,6 +34,10 @@
 
 #import "render_form.h"
 
+ at interface NSCell (KWQButtonKnowsAppKitSecrets)
+- (NSMutableDictionary *)_textAttributes;
+ at end
+
 @interface KWQButton : NSButton
 {
     QButton *button;
@@ -47,8 +51,23 @@
 
 @end
 
+ at interface KWQButtonCell : NSButtonCell
+{
+    NSWritingDirection baseWritingDirection;
+}
+
+- (void)setBaseWritingDirection:(NSWritingDirection)direction;
+- (NSWritingDirection)baseWritingDirection;
+
+ at end
+
 @implementation KWQButton
 
++ (Class)cellClass
+{
+    return [KWQButtonCell class];
+}
+
 - (id)initWithQButton:(QButton *)b
 {
     button = b;
@@ -157,6 +176,34 @@
 
 @end
 
+ at implementation KWQButtonCell
+
+- (NSWritingDirection)baseWritingDirection
+{
+    return baseWritingDirection;
+}
+
+- (void)setBaseWritingDirection:(NSWritingDirection)direction
+{
+    baseWritingDirection = direction;
+}
+
+- (NSMutableDictionary *)_textAttributes
+{
+    NSMutableDictionary *attributes = [super _textAttributes];
+    NSParagraphStyle *style = [attributes objectForKey:NSParagraphStyleAttributeName];
+    ASSERT(style != nil);
+    if ([style baseWritingDirection] != baseWritingDirection) {
+        NSMutableParagraphStyle *mutableStyle = [style mutableCopy];
+        [mutableStyle setBaseWritingDirection:baseWritingDirection];
+        [attributes setObject:mutableStyle forKey:NSParagraphStyleAttributeName];
+        [mutableStyle release];
+    }
+    return attributes;
+}
+
+ at end
+
 QButton::QButton()
     : m_clicked(this, SIGNAL(clicked()))
 {
@@ -287,3 +334,17 @@ QWidget::FocusPolicy QButton::focusPolicy() const
     return QWidget::focusPolicy();
 }
 
+void QButton::setWritingDirection(QPainter::TextDirection direction)
+{
+    KWQ_BLOCK_EXCEPTIONS;
+
+    KWQButton *button = getView();
+    KWQButtonCell *cell = [button cell];
+    NSWritingDirection d = direction == QPainter::RTL ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight;
+    if ([cell baseWritingDirection] != d) {
+        [cell setBaseWritingDirection:d];
+        [button setNeedsDisplay:YES];
+    }
+
+    KWQ_UNBLOCK_EXCEPTIONS;
+}
diff --git a/WebCore/kwq/KWQComboBox.h b/WebCore/kwq/KWQComboBox.h
index 7f51ccf..343c66c 100644
--- a/WebCore/kwq/KWQComboBox.h
+++ b/WebCore/kwq/KWQComboBox.h
@@ -60,6 +60,8 @@ public:
     
     virtual FocusPolicy focusPolicy() const;
 
+    void setWritingDirection(QPainter::TextDirection);
+    
 private:
     bool updateCurrentItem() const;
     const int *dimensions() const;
diff --git a/WebCore/kwq/KWQComboBox.mm b/WebCore/kwq/KWQComboBox.mm
index 0c377c9..2cf9101 100644
--- a/WebCore/kwq/KWQComboBox.mm
+++ b/WebCore/kwq/KWQComboBox.mm
@@ -37,6 +37,10 @@
 
 using khtml::RenderWidget;
 
+ at interface NSCell (KWQComboBoxKnowsAppKitSecrets)
+- (NSMutableDictionary *)_textAttributes;
+ at end
+
 enum {
     topMargin,
     bottomMargin,
@@ -58,8 +62,13 @@ enum {
 @interface KWQPopUpButtonCell : NSPopUpButtonCell <KWQWidgetHolder>
 {
     QWidget *widget;
+    NSWritingDirection baseWritingDirection;
 }
-- initWithWidget:(QWidget *)widget;
+
+- (id)initWithWidget:(QWidget *)widget;
+- (void)setBaseWritingDirection:(NSWritingDirection)direction;
+- (NSWritingDirection)baseWritingDirection;
+
 @end
 
 @interface KWQPopUpButton : NSPopUpButton <KWQWidgetHolder>
@@ -279,6 +288,21 @@ QWidget::FocusPolicy QComboBox::focusPolicy() const
     return QWidget::focusPolicy();
 }
 
+void QComboBox::setWritingDirection(QPainter::TextDirection direction)
+{
+    KWQ_BLOCK_EXCEPTIONS;
+
+    KWQPopUpButton *button = getView();
+    KWQPopUpButtonCell *cell = [button cell];
+    NSWritingDirection d = direction == QPainter::RTL ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight;
+    if ([cell baseWritingDirection] != d) {
+        [cell setBaseWritingDirection:d];
+        [button setNeedsDisplay:YES];
+    }
+
+    KWQ_UNBLOCK_EXCEPTIONS;
+}
+
 @implementation KWQComboBoxAdapter
 
 - initWithQComboBox:(QComboBox *)b
@@ -342,6 +366,30 @@ QWidget::FocusPolicy QComboBox::focusPolicy() const
     return widget;
 }
 
+- (void)setBaseWritingDirection:(NSWritingDirection)direction
+{
+    baseWritingDirection = direction;
+}
+
+- (NSWritingDirection)baseWritingDirection
+{
+    return baseWritingDirection;
+}
+
+- (NSMutableDictionary *)_textAttributes
+{
+    NSMutableDictionary *attributes = [super _textAttributes];
+    NSParagraphStyle *style = [attributes objectForKey:NSParagraphStyleAttributeName];
+    ASSERT(style != nil);
+    if ([style baseWritingDirection] != baseWritingDirection) {
+        NSMutableParagraphStyle *mutableStyle = [style mutableCopy];
+        [mutableStyle setBaseWritingDirection:baseWritingDirection];
+        [attributes setObject:mutableStyle forKey:NSParagraphStyleAttributeName];
+        [mutableStyle release];
+    }
+    return attributes;
+}
+
 @end
 
 @implementation KWQPopUpButton
diff --git a/WebCore/kwq/KWQLineEdit.h b/WebCore/kwq/KWQLineEdit.h
index 58310c5..c80ca8b 100644
--- a/WebCore/kwq/KWQLineEdit.h
+++ b/WebCore/kwq/KWQLineEdit.h
@@ -56,6 +56,8 @@ public:
     void setText(const QString &);
     QString text();
 
+    void setWritingDirection(QPainter::TextDirection);
+    
     void selectAll();
     
     QSize sizeForCharacterWidth(int numCharacters) const;
diff --git a/WebCore/kwq/KWQLineEdit.mm b/WebCore/kwq/KWQLineEdit.mm
index 9af9b70..28e041e 100644
--- a/WebCore/kwq/KWQLineEdit.mm
+++ b/WebCore/kwq/KWQLineEdit.mm
@@ -220,10 +220,22 @@ void QLineEdit::clicked()
 
 void QLineEdit::setAlignment(AlignmentFlags alignment)
 {
+    KWQ_BLOCK_EXCEPTIONS;
+
     ASSERT(alignment == AlignLeft || alignment == AlignRight);
     KWQTextField *textField = getView();
-    KWQ_BLOCK_EXCEPTIONS;
     [textField setAlignment:(alignment == AlignRight ? NSRightTextAlignment : NSLeftTextAlignment)];
+
+    KWQ_UNBLOCK_EXCEPTIONS;
+}
+
+void QLineEdit::setWritingDirection(QPainter::TextDirection direction)
+{
+    KWQ_BLOCK_EXCEPTIONS;
+
+    KWQTextField *textField = getView();
+    [textField setBaseWritingDirection:(direction == QPainter::RTL ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight)];
+
     KWQ_UNBLOCK_EXCEPTIONS;
 }
 
diff --git a/WebCore/kwq/KWQListBox.h b/WebCore/kwq/KWQListBox.h
index b7ab5a1..33ba8b3 100644
--- a/WebCore/kwq/KWQListBox.h
+++ b/WebCore/kwq/KWQListBox.h
@@ -55,14 +55,20 @@ public:
     void setSelectionMode(SelectionMode);
 
     void beginBatchInsert();
-    void insertItem(const QString &, unsigned index);
-    void insertGroupLabel(const QString &, unsigned index);
+    void insertItem(const QString &s, int i) { insertItem(s, i, false); }
+    void insertGroupLabel(const QString &s, int i) { insertItem(s, i, true); }
     void endBatchInsert();
+
     void setSelected(int, bool);
     bool isSelected(int) const;
+
     void setEnabled(bool enabled);
     bool isEnabled();
     
+    bool itemIsGroupLabel(int index) const;
+    
+    void setWritingDirection(QPainter::TextDirection);
+    
     bool changingSelection() { return _changingSelection; }
     void clicked() { _clicked.call(); }
     void selectionChanged() { _selectionChanged.call(); }
@@ -71,7 +77,7 @@ public:
     virtual bool checksDescendantsForFocus() const;
     
 private:
-    void insertItem(NSObject *, unsigned index);
+    void insertItem(const QString &, int index, bool isLabel);
 
     NSMutableArray *_items;
     bool _insertingItems;
diff --git a/WebCore/kwq/KWQListBox.mm b/WebCore/kwq/KWQListBox.mm
index a398a94..5c9a277 100644
--- a/WebCore/kwq/KWQListBox.mm
+++ b/WebCore/kwq/KWQListBox.mm
@@ -45,12 +45,54 @@
     BOOL processingMouseEvent;
     BOOL clickedDuringMouseEvent;
     BOOL inNextValidKeyView;
+    NSWritingDirection _direction;
 }
 - initWithListBox:(QListBox *)b items:(NSArray *)items;
--(void)_KWQ_setKeyboardFocusRingNeedsDisplay;
+- (void)_KWQ_setKeyboardFocusRingNeedsDisplay;
 - (QWidget *)widget;
+- (void)setBaseWritingDirection:(NSWritingDirection)direction;
+- (NSWritingDirection)baseWritingDirection;
 @end
 
+static NSFont *itemFont()
+{
+    static NSFont *font = [[NSFont systemFontOfSize:[NSFont smallSystemFontSize]] retain];
+    return font;
+}
+
+static NSFont *groupLabelFont()
+{
+    static NSFont *font = [[NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]] retain];
+    return font;
+}
+
+static NSParagraphStyle *paragraphStyle(NSWritingDirection direction)
+{
+    static NSParagraphStyle *leftStyle;
+    static NSParagraphStyle *rightStyle;
+    NSParagraphStyle **style = direction == NSWritingDirectionRightToLeft ? &rightStyle : &leftStyle;
+    if (*style == nil) {
+        NSMutableParagraphStyle *mutableStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
+        [mutableStyle setBaseWritingDirection:direction];
+        *style = [mutableStyle copy];
+        [mutableStyle release];
+    }
+    return *style;
+}
+
+static NSDictionary *stringAttributes(NSWritingDirection direction, bool isGroupLabel)
+{
+    static NSDictionary *attributeGlobals[4];
+    NSDictionary **attributes = &attributeGlobals[(direction == NSWritingDirectionRightToLeft ? 0 : 1) + (isGroupLabel ? 0 : 2)];
+    if (*attributes == nil) {
+        *attributes = [[NSDictionary dictionaryWithObjectsAndKeys:
+            isGroupLabel ? groupLabelFont() : itemFont(), NSFontAttributeName,
+            paragraphStyle(direction), NSParagraphStyleAttributeName,
+            nil] retain];
+    }
+    return *attributes;
+}
+
 QListBox::QListBox(QWidget *parent)
     : QScrollView(parent)
     , _insertingItems(false)
@@ -134,49 +176,36 @@ void QListBox::setSelectionMode(SelectionMode mode)
     KWQ_UNBLOCK_EXCEPTIONS;
 }
 
-void QListBox::insertItem(NSObject *o, unsigned index)
+void QListBox::insertItem(const QString &text, int index, bool isLabel)
 {
-    unsigned c = count();
+    ASSERT(index >= 0);
 
     KWQ_BLOCK_EXCEPTIONS;
+
+    NSScrollView *scrollView = getView();
+    KWQTableView *tableView = [scrollView documentView];
+
+    NSAttributedString *s = [[NSAttributedString alloc] initWithString:text.getNSString()
+        attributes:stringAttributes([tableView baseWritingDirection], isLabel)];
+
+    int c = count();
     if (index >= c) {
-        [_items addObject:o];
+        [_items addObject:s];
     } else {
-        [_items replaceObjectAtIndex:index withObject:o];
+        [_items replaceObjectAtIndex:index withObject:s];
     }
+ 
+    [s release];
 
     if (!_insertingItems) {
-        NSScrollView *scrollView = getView();
-        NSTableView *tableView = [scrollView documentView];
         [tableView reloadData];
     }
+
     KWQ_UNBLOCK_EXCEPTIONS;
 
     _widthGood = NO;
 }
 
-void QListBox::insertItem(const QString &text, unsigned index)
-{
-    insertItem(text.getNSString(), index);
-}
-
-void QListBox::insertGroupLabel(const QString &text, unsigned index)
-{
-    static NSDictionary *groupLabelAttributes;
-
-    KWQ_BLOCK_EXCEPTIONS;
-    if (groupLabelAttributes == nil) {
-        groupLabelAttributes = [[NSDictionary dictionaryWithObject:
-            [NSFont boldSystemFontOfSize:[NSFont smallSystemFontSize]] forKey:NSFontAttributeName] retain];
-    }
-
-    NSAttributedString *s = [[NSAttributedString alloc]
-        initWithString:text.getNSString() attributes:groupLabelAttributes];
-    insertItem(s, index);
-    [s release];
-    KWQ_UNBLOCK_EXCEPTIONS;
-}
-
 void QListBox::beginBatchInsert()
 {
     ASSERT(!_insertingItems);
@@ -187,20 +216,24 @@ void QListBox::endBatchInsert()
 {
     ASSERT(_insertingItems);
     _insertingItems = false;
-    NSScrollView *scrollView = getView();
 
     KWQ_BLOCK_EXCEPTIONS;
+
+    NSScrollView *scrollView = getView();
     NSTableView *tableView = [scrollView documentView];
     [tableView reloadData];
+
     KWQ_UNBLOCK_EXCEPTIONS;
 }
 
 void QListBox::setSelected(int index, bool selectIt)
 {
+    ASSERT(index >= 0);
     ASSERT(!_insertingItems);
-    NSScrollView *scrollView = getView();
 
     KWQ_BLOCK_EXCEPTIONS;
+
+    NSScrollView *scrollView = getView();
     NSTableView *tableView = [scrollView documentView];
     _changingSelection = true;
     if (selectIt) {
@@ -209,18 +242,23 @@ void QListBox::setSelected(int index, bool selectIt)
     } else {
         [tableView deselectRow:index];
     }
+
     KWQ_UNBLOCK_EXCEPTIONS;
+
     _changingSelection = false;
 }
 
 bool QListBox::isSelected(int index) const
 {
+    ASSERT(index >= 0);
     ASSERT(!_insertingItems);
-    NSScrollView *scrollView = getView();
 
     KWQ_BLOCK_EXCEPTIONS;
+
+    NSScrollView *scrollView = getView();
     NSTableView *tableView = [scrollView documentView];
     return [tableView isRowSelected:index]; 
+
     KWQ_UNBLOCK_EXCEPTIONS;
 
     return false;
@@ -298,6 +336,44 @@ bool QListBox::checksDescendantsForFocus() const
     return true;
 }
 
+void QListBox::setWritingDirection(QPainter::TextDirection d)
+{
+    KWQ_BLOCK_EXCEPTIONS;
+
+    NSScrollView *scrollView = getView();
+    KWQTableView *tableView = [scrollView documentView];
+    NSWritingDirection direction = d == QPainter::RTL ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight;
+    if ([tableView baseWritingDirection] != direction) {
+        int n = count();
+        for (int i = 0; i < n; i++) {
+            NSAttributedString *o = [_items objectAtIndex:i];
+            NSAttributedString *s = [[NSAttributedString alloc] initWithString:[o string]
+                attributes:stringAttributes([tableView baseWritingDirection], itemIsGroupLabel(i))];
+            [_items replaceObjectAtIndex:i withObject:s];
+            [s release];
+        }
+        [tableView setBaseWritingDirection:direction];
+        [tableView reloadData];
+    }
+
+    KWQ_UNBLOCK_EXCEPTIONS;
+}
+
+bool QListBox::itemIsGroupLabel(int index) const
+{
+    ASSERT(index >= 0);
+
+    KWQ_BLOCK_EXCEPTIONS;
+
+    NSAttributedString *s = [_items objectAtIndex:index];
+    NSFont *f = [s attribute:NSFontAttributeName atIndex:0 effectiveRange:NULL];
+    return f == groupLabelFont();
+
+    KWQ_UNBLOCK_EXCEPTIONS;
+
+    return false;
+}
+
 @implementation KWQListBoxScrollView
 
 - (void)setFrameSize:(NSSize)size
@@ -330,7 +406,7 @@ bool QListBox::checksDescendantsForFocus() const
     NSTableColumn *column = [[NSTableColumn alloc] initWithIdentifier:nil];
 
     [column setEditable:NO];
-    [[column dataCell] setFont:[NSFont systemFontOfSize:[NSFont smallSystemFontSize]]];
+    [[column dataCell] setFont:itemFont()];
 
     [self addTableColumn:column];
 
@@ -456,7 +532,7 @@ bool QListBox::checksDescendantsForFocus() const
 
 - (BOOL)tableView:(NSTableView *)tableView shouldSelectRow:(int)row
 {
-    return [[_items objectAtIndex:row] isKindOfClass:[NSString class]];
+    return !_box->itemIsGroupLabel(row);
 }
 
 - (BOOL)selectionShouldChangeInTableView:(NSTableView *)aTableView
@@ -480,4 +556,14 @@ bool QListBox::checksDescendantsForFocus() const
     return _box;
 }
 
+- (void)setBaseWritingDirection:(NSWritingDirection)direction
+{
+    _direction = direction;
+}
+
+- (NSWritingDirection)baseWritingDirection
+{
+    return _direction;
+}
+
 @end
diff --git a/WebCore/kwq/KWQTextArea.mm b/WebCore/kwq/KWQTextArea.mm
index 47257e3..34375a5 100644
--- a/WebCore/kwq/KWQTextArea.mm
+++ b/WebCore/kwq/KWQTextArea.mm
@@ -495,6 +495,7 @@ static NSRange RangeOfParagraph(NSString *text, int paragraph)
 
     // Set the base writing direction for text.
     [[textView textStorage] _KWQ_setBaseWritingDirection:direction];
+    [textView setNeedsDisplay:YES];
 }
 
 // This is the only one of the display family of calls that we use, and the way we do
diff --git a/WebCore/kwq/KWQTextEdit.h b/WebCore/kwq/KWQTextEdit.h
index 28ac11b..1ed690f 100644
--- a/WebCore/kwq/KWQTextEdit.h
+++ b/WebCore/kwq/KWQTextEdit.h
@@ -68,6 +68,8 @@ class QTextEdit : public QScrollView
 
     void setTabStopWidth(int);
 
+    void setWritingDirection(QPainter::TextDirection);
+    
     void selectAll();
 
     QSize sizeWithColumnsAndRows(int numColumns, int numRows) const;
diff --git a/WebCore/kwq/KWQTextEdit.mm b/WebCore/kwq/KWQTextEdit.mm
index c1aa81c..dd73930 100644
--- a/WebCore/kwq/KWQTextEdit.mm
+++ b/WebCore/kwq/KWQTextEdit.mm
@@ -186,18 +186,26 @@ void QTextEdit::clicked()
 
 void QTextEdit::setAlignment(AlignmentFlags alignment)
 {
-    // The thing we use setAlignment for in WebCore is to set the base writing direction.
-    // Rather than adding a new call for this purpose, we just code it that way.
+    KWQ_BLOCK_EXCEPTIONS;
 
     ASSERT(alignment == AlignLeft || alignment == AlignRight);
     KWQTextArea *textArea = getView();
 
-    KWQ_BLOCK_EXCEPTIONS;
     [textArea setAlignment:(alignment == AlignRight ? NSRightTextAlignment : NSLeftTextAlignment)];
-    [textArea setBaseWritingDirection:(alignment == AlignRight ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight)];
+
     KWQ_UNBLOCK_EXCEPTIONS;
 }
 
+void QTextEdit::setWritingDirection(QPainter::TextDirection direction)
+{
+    KWQ_BLOCK_EXCEPTIONS;
+
+    KWQTextArea *textArea = getView();
+    [textArea setBaseWritingDirection:(direction == QPainter::RTL ? NSWritingDirectionRightToLeft : NSWritingDirectionLeftToRight)];
+
+    KWQ_UNBLOCK_EXCEPTIONS;
+}
+ 
 QSize QTextEdit::sizeWithColumnsAndRows(int numColumns, int numRows) const
 {
     KWQTextArea *textArea = getView();
diff --git a/WebCore/kwq/KWQTextField.h b/WebCore/kwq/KWQTextField.h
index dc96d74..b121b65 100644
--- a/WebCore/kwq/KWQTextField.h
+++ b/WebCore/kwq/KWQTextField.h
@@ -42,13 +42,19 @@ class QLineEdit;
     BOOL inDrawingMachinery;
 }
 
--(id)initWithQLineEdit:(QLineEdit *)widget;
--(void)invalidate;
--(void)setPasswordMode:(BOOL)flag;
--(BOOL)passwordMode;
--(void)setMaximumLength:(int)len;
--(int)maximumLength;
--(void)setEdited:(BOOL)edited;
--(BOOL)edited;
+- (id)initWithQLineEdit:(QLineEdit *)widget;
+
+- (void)invalidate;
+
+- (void)setPasswordMode:(BOOL)flag;
+- (BOOL)passwordMode;
+
+- (void)setMaximumLength:(int)len;
+- (int)maximumLength;
+
+- (void)setEdited:(BOOL)edited;
+- (BOOL)edited;
+
+- (void)setBaseWritingDirection:(NSWritingDirection)direction;
 
 @end
diff --git a/WebCore/kwq/KWQTextField.mm b/WebCore/kwq/KWQTextField.mm
index 662494d..c0f98d5 100644
--- a/WebCore/kwq/KWQTextField.mm
+++ b/WebCore/kwq/KWQTextField.mm
@@ -37,12 +37,22 @@
 - (NSString *)_KWQ_truncateToNumComposedCharacterSequences:(int)num;
 @end
 
+ at interface NSCell (KWQTextFieldKnowsAppKitSecrets)
+- (NSMutableDictionary *)_textAttributes;
+ at end
+
 @interface KWQTextField (KWQInternal)
 - (void)setHasFocus:(BOOL)hasFocus;
 @end
 
-// KWQTextFieldCell allows us to tell when we get focus without an editor subclass.
+// KWQTextFieldCell allows us to tell when we get focus without an editor subclass,
+// and override the base writing direction.
 @interface KWQTextFieldCell : NSTextFieldCell
+{
+    NSWritingDirection baseWritingDirection;
+}
+- (void)setBaseWritingDirection:(NSWritingDirection)direction;
+- (NSWritingDirection)baseWritingDirection;
 @end
 
 // KWQTextFieldFormatter enforces a maximum length.
@@ -64,8 +74,13 @@
 }
 @end
 
-// KWQSecureTextFieldCell allows us to tell when we get focus without an editor subclass.
+// KWQSecureTextFieldCell allows us to tell when we get focus without an editor subclass,
+// and override the base writing direction.
 @interface KWQSecureTextFieldCell : NSSecureTextFieldCell
+{
+    NSWritingDirection baseWritingDirection;
+}
+- (void)setBaseWritingDirection:(NSWritingDirection)direction;
 @end
 
 @implementation KWQTextField
@@ -161,6 +176,7 @@
             [secureField setFont:[self font]];
             [secureField setEditable:[self isEditable]];
             [secureField setSelectable:[self isSelectable]];
+            [[secureField cell] setBaseWritingDirection:[[self cell] baseWritingDirection]];
             [self setUpTextField:secureField];
             [self updateSecureFieldFrame];
         }
@@ -499,6 +515,18 @@
     }
 }
 
+- (void)setBaseWritingDirection:(NSWritingDirection)direction
+{
+    KWQTextFieldCell *cell = [self cell];
+    if ([cell baseWritingDirection] != direction) {
+        [cell setBaseWritingDirection:direction];
+        [[secureField cell] setBaseWritingDirection:direction];
+
+        // One call to setNeedsDisplay will take care of both text fields.
+        [self setNeedsDisplay:YES];
+    }
+}
+
 @end
 
 @implementation KWQTextField (KWQInternal)
@@ -601,6 +629,30 @@
     [(KWQTextField *)delegate setHasFocus:YES];
 }
 
+- (void)setBaseWritingDirection:(NSWritingDirection)direction
+{
+    baseWritingDirection = direction;
+}
+
+- (NSWritingDirection)baseWritingDirection
+{
+    return baseWritingDirection;
+}
+
+- (NSMutableDictionary *)_textAttributes
+{
+    NSMutableDictionary *attributes = [super _textAttributes];
+    NSParagraphStyle *style = [attributes objectForKey:NSParagraphStyleAttributeName];
+    ASSERT(style != nil);
+    if ([style baseWritingDirection] != baseWritingDirection) {
+        NSMutableParagraphStyle *mutableStyle = [style mutableCopy];
+        [mutableStyle setBaseWritingDirection:baseWritingDirection];
+        [attributes setObject:mutableStyle forKey:NSParagraphStyleAttributeName];
+        [mutableStyle release];
+    }
+    return attributes;
+}
+
 @end
 
 @implementation KWQTextFieldFormatter
@@ -784,6 +836,25 @@
     [(KWQTextField *)[delegate delegate] setHasFocus:YES];
 }
 
+- (void)setBaseWritingDirection:(NSWritingDirection)direction
+{
+    baseWritingDirection = direction;
+}
+
+- (NSMutableDictionary *)_textAttributes
+{
+    NSMutableDictionary *attributes = [super _textAttributes];
+    NSParagraphStyle *style = [attributes objectForKey:NSParagraphStyleAttributeName];
+    ASSERT(style != nil);
+    if ([style baseWritingDirection] != baseWritingDirection) {
+        NSMutableParagraphStyle *mutableStyle = [style mutableCopy];
+        [mutableStyle setBaseWritingDirection:baseWritingDirection];
+        [attributes setObject:mutableStyle forKey:NSParagraphStyleAttributeName];
+        [mutableStyle release];
+    }
+    return attributes;
+}
+
 @end
 
 @implementation NSString (KWQTextField)

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list