Reviewed by John.
authordarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Oct 2004 19:01:16 +0000 (19:01 +0000)
committerdarin <darin@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 20 Oct 2004 19:01:16 +0000 (19:01 +0000)
        - fixed <rdar://problem/3317107> text input fields and text areas don't respect background color and text color CSS properties

        * khtml/rendering/render_form.cpp: (RenderFormElement::updateFromElement):
        Create a palette with the background and foreground colors in it and set it on the widget.

        * khtml/rendering/render_style.h: (khtml::StyleVisualData::operator==): No palette to compare
        with APPLE_CHANGES. Removed palette and palette-related function members.
        * khtml/rendering/render_style.cpp:
        (StyleVisualData::StyleVisualData): No palette to initialize with APPLE_CHANGES.
        (RenderStyle::diff): No palette to compare.

        * kwq/KWQLineEdit.h: Added setPalette override. Made text function const.
        * kwq/KWQLineEdit.mm:
        (QLineEdit::setPalette): Added. Sets foreground and background color based on palette.
        (QLineEdit::text): Made const.

        * kwq/KWQTextEdit.h: Added setPalette override.
        * kwq/KWQTextEdit.mm: (QTextEdit::setPalette): Added. Sets foreground and background color
        based on palette.

        * kwq/KWQPalette.h: Removed most things, leaving only background and foreground colors
        per color group, and only a single color group per palette.
        * kwq/KWQColorGroup.mm: Removed.
        * kwq/KWQPalette.mm: Removed.
        * WebCore.pbproj/project.pbxproj: Removed KWQColorGroup.mm and KWQPalette.mm.

        * kwq/KWQApplication.h: Removed unused palette function.
        * kwq/KWQApplication.mm: Ditto.

        * kwq/KWQWidget.h: Removed unsetPalette.
        * kwq/KWQWidget.mm: Ditto.

        - fixed storage leak

        * khtml/html/html_formimpl.cpp: (DOM::HTMLGenericFormElementImpl::~HTMLGenericFormElementImpl):
        Roll in storage leak fix from KDE guys.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@7866 268f45cc-cd09-0410-ab3c-d52691b4dbfc

17 files changed:
WebCore/ChangeLog-2005-08-23
WebCore/WebCore.pbproj/project.pbxproj
WebCore/khtml/html/html_formimpl.cpp
WebCore/khtml/rendering/render_form.cpp
WebCore/khtml/rendering/render_style.cpp
WebCore/khtml/rendering/render_style.h
WebCore/kwq/KWQApplication.h
WebCore/kwq/KWQApplication.mm
WebCore/kwq/KWQColorGroup.mm [deleted file]
WebCore/kwq/KWQLineEdit.h
WebCore/kwq/KWQLineEdit.mm
WebCore/kwq/KWQPalette.h
WebCore/kwq/KWQPalette.mm [deleted file]
WebCore/kwq/KWQTextEdit.h
WebCore/kwq/KWQTextEdit.mm
WebCore/kwq/KWQWidget.h
WebCore/kwq/KWQWidget.mm

index 1401070db1086b9418d5641c5ae7b23087945748..91ae6699b11bb480df762f615c7c3ccbad2c63cb 100644 (file)
@@ -1,3 +1,44 @@
+2004-10-20  Darin Adler  <darin@apple.com>
+
+        Reviewed by John.
+
+        - fixed <rdar://problem/3317107> text input fields and text areas don't respect background color and text color CSS properties
+
+        * khtml/rendering/render_form.cpp: (RenderFormElement::updateFromElement):
+        Create a palette with the background and foreground colors in it and set it on the widget.
+
+        * khtml/rendering/render_style.h: (khtml::StyleVisualData::operator==): No palette to compare
+        with APPLE_CHANGES. Removed palette and palette-related function members.
+        * khtml/rendering/render_style.cpp:
+        (StyleVisualData::StyleVisualData): No palette to initialize with APPLE_CHANGES.
+        (RenderStyle::diff): No palette to compare.
+
+        * kwq/KWQLineEdit.h: Added setPalette override. Made text function const.
+        * kwq/KWQLineEdit.mm:
+        (QLineEdit::setPalette): Added. Sets foreground and background color based on palette.
+        (QLineEdit::text): Made const.
+
+        * kwq/KWQTextEdit.h: Added setPalette override.
+        * kwq/KWQTextEdit.mm: (QTextEdit::setPalette): Added. Sets foreground and background color
+        based on palette.
+
+        * kwq/KWQPalette.h: Removed most things, leaving only background and foreground colors
+        per color group, and only a single color group per palette.
+        * kwq/KWQColorGroup.mm: Removed.
+        * kwq/KWQPalette.mm: Removed.
+        * WebCore.pbproj/project.pbxproj: Removed KWQColorGroup.mm and KWQPalette.mm.
+
+        * kwq/KWQApplication.h: Removed unused palette function.
+        * kwq/KWQApplication.mm: Ditto.
+
+        * kwq/KWQWidget.h: Removed unsetPalette.
+        * kwq/KWQWidget.mm: Ditto.
+
+        - fixed storage leak
+
+        * khtml/html/html_formimpl.cpp: (DOM::HTMLGenericFormElementImpl::~HTMLGenericFormElementImpl):
+        Roll in storage leak fix from KDE guys.
+
 2004-10-19  David Hyatt  <hyatt@apple.com>
 
         Reviewed by kocienda
index 6977b493c9a29069d87637d8e92c6fd59b91566e..4edf388cccff2831ca7078be516f920d39833eed 100644 (file)
                                F587856002DE375901EA4122,
                                F587856102DE375901EA4122,
                                F587856202DE375901EA4122,
-                               F587856302DE375901EA4122,
                                F587856402DE375901EA4122,
                                F587856702DE375901EA4122,
                                F587856802DE375901EA4122,
                                F58785AF02DE375901EA4122,
                                F58785B002DE375901EA4122,
                                F58785B102DE375901EA4122,
-                               F58785B202DE375901EA4122,
                                F58785B302DE375901EA4122,
                                F58785B402DE375901EA4122,
                                F58785B502DE375901EA4122,
                        refType = 4;
                        sourceTree = "<group>";
                };
-               F58784D102DE375901EA4122 = {
-                       fileEncoding = 30;
-                       isa = PBXFileReference;
-                       lastKnownFileType = sourcecode.cpp.objcpp;
-                       path = KWQColorGroup.mm;
-                       refType = 4;
-                       sourceTree = "<group>";
-               };
                F58784D202DE375901EA4122 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
                        refType = 4;
                        sourceTree = "<group>";
                };
-               F587852002DE375901EA4122 = {
-                       fileEncoding = 30;
-                       isa = PBXFileReference;
-                       lastKnownFileType = sourcecode.cpp.objcpp;
-                       path = KWQPalette.mm;
-                       refType = 4;
-                       sourceTree = "<group>";
-               };
                F587852102DE375901EA4122 = {
                        fileEncoding = 30;
                        isa = PBXFileReference;
                        settings = {
                        };
                };
-               F587856302DE375901EA4122 = {
-                       fileRef = F58784D102DE375901EA4122;
-                       isa = PBXBuildFile;
-                       settings = {
-                       };
-               };
                F587856402DE375901EA4122 = {
                        fileRef = F58784D202DE375901EA4122;
                        isa = PBXBuildFile;
                        settings = {
                        };
                };
-               F58785B202DE375901EA4122 = {
-                       fileRef = F587852002DE375901EA4122;
-                       isa = PBXBuildFile;
-                       settings = {
-                       };
-               };
                F58785B302DE375901EA4122 = {
                        fileRef = F587852102DE375901EA4122;
                        isa = PBXBuildFile;
                                F58786A302DE3B8601EA4122,
                                F587851F02DE375901EA4122,
                                F58786A402DE3B8601EA4122,
-                               F58784D102DE375901EA4122,
-                               F587852002DE375901EA4122,
                                F58786A502DE3B8601EA4122,
                                F587852102DE375901EA4122,
                                F58786A602DE3B8601EA4122,
index c457c8bdf114e5ebef7ea726baf4c26bc3e56f97..9a8f049e92cdca5ebc4431a412a0ddce249b633b 100644 (file)
@@ -741,6 +741,7 @@ HTMLGenericFormElementImpl::~HTMLGenericFormElementImpl()
 {
     if (m_form)
         m_form->removeFormElement(this);
+    if (m_name) m_name->deref();
 }
 
 void HTMLGenericFormElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
index 13674be73791eb8e4459de7c417782eb71ed1ea2..d7aadd0211fbdd4bdf3a4c8a93bad3a24955e1cf 100644 (file)
@@ -100,7 +100,7 @@ void RenderFormElement::updateFromElement()
     m_widget->setEnabled(!element()->disabled());
 
 #if APPLE_CHANGES
-    //m_widget->setPalette(QPalette(style()->backgroundColor(), style()->color()));
+    m_widget->setPalette(QPalette(style()->backgroundColor(), style()->color()));
 #else
     QColor color = style()->color();
     QColor backgroundColor = style()->backgroundColor();
index ab268eebb69c52c1c0e7aeba14e021111ecf1d09..809a2cda94ee33ed4d28dd4a31517da4e9d50562 100644 (file)
@@ -86,8 +86,10 @@ bool StyleBoxData::operator==(const StyleBoxData& o) const
 StyleVisualData::StyleVisualData()
       : hasClip(false), 
       textDecoration(RenderStyle::initialTextDecoration()), 
-      colspan( 1 ), counter_increment( 0 ), counter_reset( 0 ),
-      palette( QApplication::palette() )
+      colspan( 1 ), counter_increment( 0 ), counter_reset( 0 )
+#if !APPLE_CHANGES
+      , palette( QApplication::palette() )
+#endif
 {
 }
 
@@ -97,8 +99,10 @@ StyleVisualData::~StyleVisualData() {
 StyleVisualData::StyleVisualData(const StyleVisualData& o )
     : Shared<StyleVisualData>(),
       clip( o.clip ), hasClip( o.hasClip ), textDecoration(o.textDecoration), colspan( o.colspan ),
-      counter_increment( o.counter_increment ), counter_reset( o.counter_reset ),
-      palette( o.palette )
+      counter_increment( o.counter_increment ), counter_reset( o.counter_reset )
+#if !APPLE_CHANGES
+      , palette( o.palette )
+#endif
 {
 }
 
@@ -690,8 +694,10 @@ RenderStyle::Diff RenderStyle::diff( const RenderStyle *other ) const
         !css3InheritedData->shadowDataEquivalent(*other->css3InheritedData.get()) ||
         css3InheritedData->userModify != other->css3InheritedData->userModify ||
         css3NonInheritedData->userSelect != other->css3NonInheritedData->userSelect ||
-        css3NonInheritedData->userDrag != other->css3NonInheritedData->userDrag ||
-        !(visual->palette == other->visual->palette)
+        css3NonInheritedData->userDrag != other->css3NonInheritedData->userDrag
+#if !APPLE_CHANGES
+        || !(visual->palette == other->visual->palette)
+#endif
        )
         return Repaint;
 
@@ -711,11 +717,15 @@ void RenderStyle::cleanup()
 //    SharedData::counter = 0;
 }
 
+#if !APPLE_CHANGES
+
 void RenderStyle::setPaletteColor(QPalette::ColorGroup g, QColorGroup::ColorRole r, const QColor& c)
 {
     visual.access()->palette.setColor(g,r,c);
 }
 
+#endif
+
 void RenderStyle::setClip( Length top, Length right, Length bottom, Length left )
 {
     StyleVisualData *data = visual.access();
index 8801b5f6fcdf563501a1541201f15f9ce86c683c..cd0f62f25fbd5a0fca411945bc34da3f6e89a0cf 100644 (file)
@@ -401,7 +401,10 @@ public:
                 colspan == o.colspan &&
                 counter_increment == o.counter_increment &&
                 counter_reset == o.counter_reset &&
-                palette == o.palette && textDecoration == o.textDecoration);
+#if !APPLE_CHANGES
+                palette == o.palette &&
+#endif
+                 textDecoration == o.textDecoration);
     }
     bool operator!=( const StyleVisualData &o ) const {
         return !(*this == o);
@@ -416,7 +419,9 @@ public:
     short counter_increment; //ok, so these are not visual mode spesific
     short counter_reset;     //can't go to inherited, since these are not inherited
 
+#if !APPLE_CHANGES
     QPalette palette;      //widget styling with IE attributes
+#endif
 };
 
 //------------------------------------------------
@@ -1370,12 +1375,14 @@ public:
     void setTextSizeAdjust(bool b) { SET_VAR(css3InheritedData, textSizeAdjust, b); }
 #endif
 
+#if !APPLE_CHANGES
     QPalette palette() const { return visual->palette; }
     void setPaletteColor(QPalette::ColorGroup g, QColorGroup::ColorRole r, const QColor& c);
     void resetPalette() // Called when the desktop color scheme changes.
     {
         const_cast<StyleVisualData *>(visual.get())->palette = QApplication::palette();
     }
+#endif
 
     ContentData* contentData() { return content; }
     bool contentDataEquivalent(RenderStyle* otherStyle);
index 94220981393a4bdee3f942f94135212c440a3c36..88a28de0d5121a920feb77901d6b3ebe53623fa3 100644 (file)
 #ifndef QAPPLICATION_H_
 #define QAPPLICATION_H_
 
-#include "KWQObject.h"
 #include "KWQWidget.h"
-#include "KWQPalette.h"
-#include "KWQSize.h"
 
 class QDesktopWidget;
 
 class QApplication : public QObject {
 public:
-    static QPalette palette(const QWidget *p = 0);
     static QDesktopWidget *desktop() { return 0; }
     static void setOverrideCursor(const QCursor &);
     static void restoreOverrideCursor();
index 6a4ec4ef761ab71826cbdf8da08084082b6cfa8b..de0d41c52bab70619a23bc906c92ff99416c22cf 100644 (file)
  */
 
 #import "KWQApplication.h"
-#import "KWQLogging.h"
 
 // The NSScreen Cocoa calls in this file should never throw, so
 // there's no need to block exceptions.
 
-QPalette QApplication::palette(const QWidget *p)
-{
-    static QPalette pal;
-    return pal;
-}
-
 int QDesktopWidget::width()
 {
     return (int)[[NSScreen mainScreen] frame].size.width;
diff --git a/WebCore/kwq/KWQColorGroup.mm b/WebCore/kwq/KWQColorGroup.mm
deleted file mode 100644 (file)
index 0d50bff..0000000
+++ /dev/null
@@ -1,140 +0,0 @@
-/*
- * Copyright (C) 2003 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#import "KWQPalette.h"
-
-QColorGroup::QColorGroup()
-{
-#if KWQ_USE_PALETTES
-    brushes[Foreground] = QColor(255,255,255);
-    brushes[Shadow] = QColor(255,255,255);
-    brushes[Light] = QColor(224,224,224);
-    brushes[Midlight] = QColor(192,192,192);
-    brushes[Mid] = QColor(128,128,128);
-    brushes[Dark] = QColor(64,64,64);
-#endif
-    brushes[Base] = QColor(255,255,255);
-#if KWQ_USE_PALETTES
-    brushes[ButtonText] = QColor(0,0,0);
-    brushes[Button] = QColor(192,192,192);
-    brushes[Background] = QColor(255,255,255);
-    brushes[Text] = QColor(0,0,0);
-    brushes[Highlight] = QColor(64,64,64);
-    brushes[HighlightedText] = QColor(0,0,0);
-#endif
-}
-
-const QBrush &QColorGroup::brush(ColorRole cr) const
-{
-    return brushes[cr];
-}
-
-const QColor &QColorGroup::color(ColorRole cr) const
-{
-    return brushes[cr].color();
-}
-
-void QColorGroup::setColor(QColorGroup::ColorRole cr, const QColor &color)
-{
-    brushes[cr].setColor(color);
-}
-
-#if KWQ_USE_PALETTES
-
-const QColor &QColorGroup::foreground() const
-{
-    return brushes[Foreground].color();
-}
-
-const QColor &QColorGroup::shadow() const
-{
-    return brushes[Shadow].color();
-}
-
-const QColor &QColorGroup::light() const
-{
-    return brushes[Light].color();
-}
-
-const QColor &QColorGroup::midlight() const
-{
-    return brushes[Midlight].color();
-}
-
-const QColor &QColorGroup::dark() const
-{
-    return brushes[Dark].color();
-}
-
-#endif
-
-const QColor &QColorGroup::base() const
-{
-    return brushes[Base].color();
-}
-
-#if KWQ_USE_PALETTES
-
-const QColor &QColorGroup::buttonText() const
-{
-    return brushes[ButtonText].color();
-}
-
-const QColor &QColorGroup::button() const
-{
-    return brushes[Button].color();
-}
-
-const QColor &QColorGroup::text() const
-{
-    return brushes[Text].color();
-}
-
-const QColor &QColorGroup::background() const
-{
-    return brushes[Background].color();
-}
-
-const QColor &QColorGroup::highlight() const
-{
-    return brushes[Highlight].color();
-}
-
-const QColor &QColorGroup::highlightedText() const
-{
-    return brushes[HighlightedText].color();
-}
-
-#endif
-
-bool QColorGroup::operator==(const QColorGroup &other) const
-{
-    for (int i = 0; i < NColorRoles; i++) {
-        if (brushes[i] != other.brushes[i]) {
-           return false;
-       }
-    }
-    return true;
-}
index ef187ac5626074974d838d2f3d3a3af30f509c9e..ff3789ffb5df20796c27dd6a51580d803ee4fcd5 100644 (file)
@@ -41,6 +41,9 @@ public:
 
     QLineEdit(Type);
     ~QLineEdit();
+
+    virtual void setPalette(const QPalette &);
+
     void setAlignment(AlignmentFlags);
 
     void setCursorPosition(int);
@@ -49,7 +52,7 @@ public:
     void setEdited(bool);
     bool edited() const;
 
-    void setFont(const QFont &font);
+    void setFont(const QFont &);
     
     void setMaxLength(int);
     int maxLength() const;
@@ -58,7 +61,7 @@ public:
     bool isReadOnly() const;
 
     void setText(const QString &);
-    QString text();
+    QString text() const;
 
     void setWritingDirection(QPainter::TextDirection);
     
index 8d032b6635dd6f6e671961b5978136afc997df54..5394aaf54250289ace73af7bfe2a417ecb11f264 100644 (file)
@@ -103,6 +103,24 @@ void QLineEdit::setFont(const QFont &font)
     }
 }
 
+void QLineEdit::setPalette(const QPalette &palette)
+{
+    QWidget::setPalette(palette);
+
+    NSTextField *textField = (NSTextField *)getView();
+
+    KWQ_BLOCK_EXCEPTIONS;
+
+    [textField setTextColor:palette.foreground().getNSColor()];
+
+    QColor background = palette.background();
+    if (!background.isValid())
+        background = Qt::white;
+    [textField setBackgroundColor:background.getNSColor()];
+
+    KWQ_UNBLOCK_EXCEPTIONS;
+}
+
 void QLineEdit::setText(const QString &s)
 {
     NSTextField *textField = (NSTextField *)getView();
@@ -111,7 +129,7 @@ void QLineEdit::setText(const QString &s)
     KWQ_UNBLOCK_EXCEPTIONS;
 }
 
-QString QLineEdit::text()
+QString QLineEdit::text() const
 {
     NSTextField *textField = (NSTextField *)getView();
 
index c9d97370a33e9d3022b3a704e37a295952a6d0b5..38c52f5036af6b01c369cadf095b6a09ab27ff83 100644 (file)
 #ifndef QPALETTE_H_
 #define QPALETTE_H_
 
-#include "KWQColor.h"
 #include "KWQBrush.h"
 
-// We don't colorize widgets, so we don't need palettes.
-// And copying the palettes was taking a measurable amount of time.
-#define KWQ_USE_PALETTES 0
-
-class QColorGroupPrivate;
-class QPalettePrivate;
-
 class QColorGroup {
 public:
     enum ColorRole { 
-#if KWQ_USE_PALETTES
-        Foreground,
-        Shadow,
-        Light,
-        Midlight,
-        Mid,
-        Dark,
-#endif
-        Base,
-#if KWQ_USE_PALETTES
-        ButtonText,
-        Button,
         Background,
-        Text,
-        Highlight,
-        HighlightedText,
-#endif
-        NColorRoles
+        Foreground,
+        NColorRoles,
+        Base = Background
     };
 
-    QColorGroup();
+    QColorGroup() : m_background(Qt::white) { }
+    QColorGroup(const QColor &b, const QColor &f) : m_background(b), m_foreground(f) { }
 
-    const QBrush &brush(ColorRole) const;
+    const QBrush &brush(ColorRole role) const { return role == Background ? m_background : m_foreground; }
 
-    const QColor &color(ColorRole) const;
-    void setColor(ColorRole, const QColor &);
+    const QColor &color(ColorRole role) const { return brush(role).color(); }
+    void setColor(ColorRole role, const QColor &color)
+        { (role == Background ? m_background : m_foreground).setColor(color); }
 
-#if KWQ_USE_PALETTES
-    const QColor &foreground() const;
-    const QColor &shadow() const;
-    const QColor &light() const;
-    const QColor &midlight() const;
-    const QColor &dark() const;
-#endif
-    const QColor &base() const;
-#if KWQ_USE_PALETTES
-    const QColor &buttonText() const;
-    const QColor &button() const;
-    const QColor &text() const;
-    const QColor &background() const;
-    const QColor &highlight() const;
-    const QColor &highlightedText() const;
-#endif
+    const QColor &background() const { return m_background.color(); }
+    const QColor &foreground() const { return m_foreground.color(); }
 
-    bool operator==(const QColorGroup &) const;
+    const QColor &base() const { return background(); }
+
+    bool operator==(const QColorGroup &other) const
+        { return m_background == other.m_background && m_foreground == other.m_foreground; }
 
 private:
-    QBrush brushes[NColorRoles];
+    QBrush m_background;
+    QBrush m_foreground;
 };
 
 
 class QPalette {
 public:
-    enum ColorGroup { 
-        Active, 
-#if KWQ_USE_PALETTES
-        Inactive, 
-        Disabled,
-#endif
-        NColorGroups
-    };
-
-    const QColor &color(ColorGroup, QColorGroup::ColorRole) const;
-    void setColor(ColorGroup, QColorGroup::ColorRole, const QColor &);
+    QPalette() { }
+    QPalette(const QColor &b, const QColor &f) : m_active(b, f) { }
 
     const QColorGroup &active() const { return m_active; }
-#if KWQ_USE_PALETTES
-    const QColorGroup &inactive() const { return m_inactive; }
-    const QColorGroup &disabled() const { return m_disabled; }
-    const QColorGroup &normal() const { return m_active; }
-#endif
 
-    bool operator==(const QPalette &) const;
+    const QColor &background() const { return m_active.background(); }
+    const QColor &foreground() const { return m_active.foreground(); }
+
+    bool operator==(const QPalette &other) const { return m_active == other.m_active; }
 
 private:
-    QColorGroup m_active;  
-#if KWQ_USE_PALETTES
-    QColorGroup m_inactive;  
-    QColorGroup m_disabled;  
-#endif
+    QColorGroup m_active;
 };
 
 #endif
diff --git a/WebCore/kwq/KWQPalette.mm b/WebCore/kwq/KWQPalette.mm
deleted file mode 100644 (file)
index e48db80..0000000
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
- * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR
- * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
- * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
- * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
- * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
- * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
- */
-
-#import "KWQPalette.h"
-
-#import "KWQAssertions.h"
-
-const QColor& QPalette::color(ColorGroup cg, QColorGroup::ColorRole role) const
-{
-    switch (cg) {
-    case NColorGroups:
-        break;
-    case Active:
-        return m_active.color(role);
-#if KWQ_USE_PALETTES
-    case Inactive:
-        return m_inactive.color(role);
-    case Disabled:
-        return m_disabled.color(role);
-#endif
-    }
-    ASSERT(false);
-    return m_active.color(QColorGroup::Base);
-}
-
-void QPalette::setColor(ColorGroup cg, QColorGroup::ColorRole role, const QColor &color)
-{
-    switch (cg) {
-    case Active:
-        m_active.setColor(role, color);
-        break;
-#if KWQ_USE_PALETTES
-    case Inactive:
-        m_inactive.setColor(role, color);
-        break;
-    case Disabled:
-        m_disabled.setColor(role, color);
-        break;
-#endif
-    case NColorGroups:
-        ASSERT(false);
-        break;
-    }
-}
-
-bool QPalette::operator==(QPalette const &other) const
-{
-    return m_active == other.m_active
-#if KWQ_USE_PALETTES
-        && m_inactive == other.m_inactive && m_disabled == other.m_disabled
-#endif
-        ;
-}
index 37cde4a1aafbb602be859d9b4c4ef0432d5e945b..49716db2c1854bcbb5a32d4b94f2b496be487e8f 100644 (file)
@@ -44,6 +44,8 @@ class QTextEdit : public QScrollView
 
     QTextEdit(QWidget *parent);
 
+    virtual void setPalette(const QPalette &);
+
     void setAlignment(AlignmentFlags);
 
     void setCursorPosition(int, int);
index da880788b8fb0d75276e356a7e6ee417691b789b..5b5f63597b8fa7ad34654adb2cea8bd7e11be157 100644 (file)
@@ -218,3 +218,21 @@ bool QTextEdit::checksDescendantsForFocus() const
 {
     return true;
 }
+
+void QTextEdit::setPalette(const QPalette &palette)
+{
+    QWidget::setPalette(palette);
+
+    KWQTextArea *textArea = getView();
+
+    KWQ_BLOCK_EXCEPTIONS;
+
+    [textArea setTextColor:palette.foreground().getNSColor()];
+
+    QColor background = palette.background();
+    if (!background.isValid())
+        background = Qt::white;
+    [textArea setBackgroundColor:background.getNSColor()];
+
+    KWQ_UNBLOCK_EXCEPTIONS;
+}
index fd2b3125f56e1d676419b61c5cea3a9d14793787..42bad5c4775b3728c430aad2d9fceffbb7a65cb6 100644 (file)
@@ -109,7 +109,6 @@ public:
 
     const QPalette& palette() const;
     virtual void setPalette(const QPalette &);
-    void unsetPalette();
     
     QStyle &style() const;
     void setStyle(QStyle *);
index 94dd5fece6dbe7b5e7f4db0419199d3e9d7bb492..022dbfd6682402d026c68d923e6b6f4e55300d92 100644 (file)
@@ -281,12 +281,6 @@ void QWidget::setPalette(const QPalette &palette)
     data->pal = palette;
 }
 
-void QWidget::unsetPalette()
-{
-    // Only called by RenderFormElement::layout, which I suspect will
-    // have to be rewritten.  Do nothing.
-}
-
 QStyle &QWidget::style() const
 {
     return *data->style;