Mostly reviewed by Ken, some bits reviewed by John.

	- fixed 3188781 -- eliminate globally initialized objects from WebCore

        * kwq/KWQString.h: Change QChar::null to be a char constant, and QString::null to be a const char *.
        In the cases where the code still compiles after these changes, everything works fine. A few cases
        that didn't compile are fixed below.
        * kwq/KWQString.mm: Remove QString::null.
        (QString::mid): Return QString() instead of null.
        * kwq/KWQChar.mm: Remove the definition of QChar::null.

        * khtml/css/css_base.cpp: (CSSSelector::extractPseudoType): Use DOMString explicitly in one place
        where the code said QString::null. The trick where QString::null is really a const char * does not
        work in this case.
        * khtml/khtml_part.cpp: (KHTMLPart::reparseConfiguration): Use QString() instead of QString::null
        in one place. The trick where QString::null is really a const char * does not work in this case.
        * kwq/KWQKHTMLSettings.h: Use QString() for settingsToCSS, the trick where QString::null is really
        a const char * does not work in this case.
        * khtml/rendering/render_list.cpp: (RenderListMarker::paintObject): Use an isEmpty check here instead
        of comparing with QString::null. Not sure this change was strictly required, but it is simpler and
        may also make the code slightly faster.

        * kwq/KWQKFileDialog.h: Removed. This used QString::null in a way that is incompatible with the new
        "0" hack, but was not used any more.
        * kwq/KWQKFileDialog.mm: Removed.
        * ForwardingHeaders/kfiledialog.h: Empty this out, since there is no KWQKFileDialog.h any more.
        * WebCore.pbproj/project.pbxproj: Removed KWQKFileDialog.h and .mm.

        * khtml/html/htmltokenizer.cpp: Change the commentStart global array to be an array of char instead
        of QChar to avoid the static constructor; the code works fine with char anyway.
        * khtml/html/html_formimpl.cpp: Change the global constants in this file to be char instead of QChar.
        It works this way (and faster for KWQ), and avoids the static constructor.

        * khtml/rendering/bidi.h: Change BidiIterator from a class with constructors into a plain struct.
        The copy construct and assignment operator weren't needed anyway since they simply duplicated default
        assignment, and if we have a constructor then we can't use it as a global object, since we want to
        avoid static constructors. Do the same with BidiStatus, and also stop using bit fields. It's silly to
        use bit fields for something when we have only one global instance of it; just makes extra code size
        and saves a few bytes.
        * khtml/rendering/bidi.cpp:
        (BidiIterator::current): Move the non-breaking space global inside this function.
        (appendRunsForObject): Initialize BidiIterator object using brace notation.
        (buildCompactRuns): Initialize BidiIterator objects using brace notation and assignment.
        (RenderBlock::layoutInlineChildren): Initialize BidiStatus fields separately. Initialize BidiIterator
        objects using brace notation and assignment.
        (RenderBlock::findNextLineBreak): Initialize BidiIterator objects using brace notation and assignment.

        * khtml/rendering/render_frames.cpp: Removed an include of <iostream.h>. This pulled the entire
        C++ I/O library in, with lots of static constructors. Elsewhere, we are careful not to use the C++
        I/O library in WebCore except in Development versions. And this file didn't actually use the library,
        just included the header.

        * kwq/KWQNamespace.h: Remove all the color globals except for the ones used in KHTML: black, white,
        darkGray, gray, and lightGray. And for those, make the globals RGB constants instead of QColor objects.
        This gets rid of the global objects with constructors and works without any KHTML code changes.
        * kwq/KWQColor.mm: Remove the definition of the QColor constants from the Qt class.

        * kwq/KWQPainter.h: Add overloads for setPen and setBrush so they work with the "color" constants
        from Qt that are now RGB constants rather than QColor objects.
        * kwq/KWQPainter.mm:
        (QPainter::setPen): Set style to solid line and width to 0 when the parameter is an RGB constant.
        This is just like what you'd get if you constructed a QPen.
        (QPainter::setBrush): Set style to solid pattern when the parameter is an RGB constant.
        This is just like what you'd get if you constructed a QBrush.

        * khtml/misc/loader.h: Change m_LRULists to be a global pointer instead of a global array, so
        we don't have to statically construct LRUList objects.
        * khtml/misc/loader.cpp: (Cache::getLRUListFor): Allocate the global array the first time we
        pass through here.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@4208 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index 6d00abd..04d7884 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,5 +1,77 @@
 2003-04-29  Darin Adler  <darin@apple.com>
 
+        Mostly reviewed by Ken, some bits reviewed by John.
+
+	- fixed 3188781 -- eliminate globally initialized objects from WebCore
+
+        * kwq/KWQString.h: Change QChar::null to be a char constant, and QString::null to be a const char *.
+        In the cases where the code still compiles after these changes, everything works fine. A few cases
+        that didn't compile are fixed below.
+        * kwq/KWQString.mm: Remove QString::null.
+        (QString::mid): Return QString() instead of null.
+        * kwq/KWQChar.mm: Remove the definition of QChar::null.
+
+        * khtml/css/css_base.cpp: (CSSSelector::extractPseudoType): Use DOMString explicitly in one place
+        where the code said QString::null. The trick where QString::null is really a const char * does not
+        work in this case.
+        * khtml/khtml_part.cpp: (KHTMLPart::reparseConfiguration): Use QString() instead of QString::null
+        in one place. The trick where QString::null is really a const char * does not work in this case.
+        * kwq/KWQKHTMLSettings.h: Use QString() for settingsToCSS, the trick where QString::null is really
+        a const char * does not work in this case.
+        * khtml/rendering/render_list.cpp: (RenderListMarker::paintObject): Use an isEmpty check here instead
+        of comparing with QString::null. Not sure this change was strictly required, but it is simpler and
+        may also make the code slightly faster.
+
+        * kwq/KWQKFileDialog.h: Removed. This used QString::null in a way that is incompatible with the new
+        "0" hack, but was not used any more.
+        * kwq/KWQKFileDialog.mm: Removed.
+        * ForwardingHeaders/kfiledialog.h: Empty this out, since there is no KWQKFileDialog.h any more.
+        * WebCore.pbproj/project.pbxproj: Removed KWQKFileDialog.h and .mm.
+       
+        * khtml/html/htmltokenizer.cpp: Change the commentStart global array to be an array of char instead
+        of QChar to avoid the static constructor; the code works fine with char anyway.
+        * khtml/html/html_formimpl.cpp: Change the global constants in this file to be char instead of QChar.
+        It works this way (and faster for KWQ), and avoids the static constructor.
+
+        * khtml/rendering/bidi.h: Change BidiIterator from a class with constructors into a plain struct.
+        The copy construct and assignment operator weren't needed anyway since they simply duplicated default
+        assignment, and if we have a constructor then we can't use it as a global object, since we want to
+        avoid static constructors. Do the same with BidiStatus, and also stop using bit fields. It's silly to
+        use bit fields for something when we have only one global instance of it; just makes extra code size
+        and saves a few bytes.
+        * khtml/rendering/bidi.cpp:
+        (BidiIterator::current): Move the non-breaking space global inside this function.
+        (appendRunsForObject): Initialize BidiIterator object using brace notation.
+        (buildCompactRuns): Initialize BidiIterator objects using brace notation and assignment.
+        (RenderBlock::layoutInlineChildren): Initialize BidiStatus fields separately. Initialize BidiIterator
+        objects using brace notation and assignment.
+        (RenderBlock::findNextLineBreak): Initialize BidiIterator objects using brace notation and assignment.
+
+        * khtml/rendering/render_frames.cpp: Removed an include of <iostream.h>. This pulled the entire
+        C++ I/O library in, with lots of static constructors. Elsewhere, we are careful not to use the C++
+        I/O library in WebCore except in Development versions. And this file didn't actually use the library,
+        just included the header.
+
+        * kwq/KWQNamespace.h: Remove all the color globals except for the ones used in KHTML: black, white,
+        darkGray, gray, and lightGray. And for those, make the globals RGB constants instead of QColor objects.
+        This gets rid of the global objects with constructors and works without any KHTML code changes.
+        * kwq/KWQColor.mm: Remove the definition of the QColor constants from the Qt class.
+
+        * kwq/KWQPainter.h: Add overloads for setPen and setBrush so they work with the "color" constants
+        from Qt that are now RGB constants rather than QColor objects.
+        * kwq/KWQPainter.mm:
+        (QPainter::setPen): Set style to solid line and width to 0 when the parameter is an RGB constant.
+        This is just like what you'd get if you constructed a QPen.
+        (QPainter::setBrush): Set style to solid pattern when the parameter is an RGB constant.
+        This is just like what you'd get if you constructed a QBrush.
+        
+        * khtml/misc/loader.h: Change m_LRULists to be a global pointer instead of a global array, so
+        we don't have to statically construct LRUList objects.
+        * khtml/misc/loader.cpp: (Cache::getLRUListFor): Allocate the global array the first time we
+        pass through here.
+
+2003-04-29  Darin Adler  <darin@apple.com>
+
         Reviewed by Ken.
 
 	- fixed 3242460 -- crash in NSPopUpButtonCell at acheter-moins-cher.com
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 6d00abd..04d7884 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,5 +1,77 @@
 2003-04-29  Darin Adler  <darin@apple.com>
 
+        Mostly reviewed by Ken, some bits reviewed by John.
+
+	- fixed 3188781 -- eliminate globally initialized objects from WebCore
+
+        * kwq/KWQString.h: Change QChar::null to be a char constant, and QString::null to be a const char *.
+        In the cases where the code still compiles after these changes, everything works fine. A few cases
+        that didn't compile are fixed below.
+        * kwq/KWQString.mm: Remove QString::null.
+        (QString::mid): Return QString() instead of null.
+        * kwq/KWQChar.mm: Remove the definition of QChar::null.
+
+        * khtml/css/css_base.cpp: (CSSSelector::extractPseudoType): Use DOMString explicitly in one place
+        where the code said QString::null. The trick where QString::null is really a const char * does not
+        work in this case.
+        * khtml/khtml_part.cpp: (KHTMLPart::reparseConfiguration): Use QString() instead of QString::null
+        in one place. The trick where QString::null is really a const char * does not work in this case.
+        * kwq/KWQKHTMLSettings.h: Use QString() for settingsToCSS, the trick where QString::null is really
+        a const char * does not work in this case.
+        * khtml/rendering/render_list.cpp: (RenderListMarker::paintObject): Use an isEmpty check here instead
+        of comparing with QString::null. Not sure this change was strictly required, but it is simpler and
+        may also make the code slightly faster.
+
+        * kwq/KWQKFileDialog.h: Removed. This used QString::null in a way that is incompatible with the new
+        "0" hack, but was not used any more.
+        * kwq/KWQKFileDialog.mm: Removed.
+        * ForwardingHeaders/kfiledialog.h: Empty this out, since there is no KWQKFileDialog.h any more.
+        * WebCore.pbproj/project.pbxproj: Removed KWQKFileDialog.h and .mm.
+       
+        * khtml/html/htmltokenizer.cpp: Change the commentStart global array to be an array of char instead
+        of QChar to avoid the static constructor; the code works fine with char anyway.
+        * khtml/html/html_formimpl.cpp: Change the global constants in this file to be char instead of QChar.
+        It works this way (and faster for KWQ), and avoids the static constructor.
+
+        * khtml/rendering/bidi.h: Change BidiIterator from a class with constructors into a plain struct.
+        The copy construct and assignment operator weren't needed anyway since they simply duplicated default
+        assignment, and if we have a constructor then we can't use it as a global object, since we want to
+        avoid static constructors. Do the same with BidiStatus, and also stop using bit fields. It's silly to
+        use bit fields for something when we have only one global instance of it; just makes extra code size
+        and saves a few bytes.
+        * khtml/rendering/bidi.cpp:
+        (BidiIterator::current): Move the non-breaking space global inside this function.
+        (appendRunsForObject): Initialize BidiIterator object using brace notation.
+        (buildCompactRuns): Initialize BidiIterator objects using brace notation and assignment.
+        (RenderBlock::layoutInlineChildren): Initialize BidiStatus fields separately. Initialize BidiIterator
+        objects using brace notation and assignment.
+        (RenderBlock::findNextLineBreak): Initialize BidiIterator objects using brace notation and assignment.
+
+        * khtml/rendering/render_frames.cpp: Removed an include of <iostream.h>. This pulled the entire
+        C++ I/O library in, with lots of static constructors. Elsewhere, we are careful not to use the C++
+        I/O library in WebCore except in Development versions. And this file didn't actually use the library,
+        just included the header.
+
+        * kwq/KWQNamespace.h: Remove all the color globals except for the ones used in KHTML: black, white,
+        darkGray, gray, and lightGray. And for those, make the globals RGB constants instead of QColor objects.
+        This gets rid of the global objects with constructors and works without any KHTML code changes.
+        * kwq/KWQColor.mm: Remove the definition of the QColor constants from the Qt class.
+
+        * kwq/KWQPainter.h: Add overloads for setPen and setBrush so they work with the "color" constants
+        from Qt that are now RGB constants rather than QColor objects.
+        * kwq/KWQPainter.mm:
+        (QPainter::setPen): Set style to solid line and width to 0 when the parameter is an RGB constant.
+        This is just like what you'd get if you constructed a QPen.
+        (QPainter::setBrush): Set style to solid pattern when the parameter is an RGB constant.
+        This is just like what you'd get if you constructed a QBrush.
+        
+        * khtml/misc/loader.h: Change m_LRULists to be a global pointer instead of a global array, so
+        we don't have to statically construct LRUList objects.
+        * khtml/misc/loader.cpp: (Cache::getLRUListFor): Allocate the global array the first time we
+        pass through here.
+
+2003-04-29  Darin Adler  <darin@apple.com>
+
         Reviewed by Ken.
 
 	- fixed 3242460 -- crash in NSPopUpButtonCell at acheter-moins-cher.com
diff --git a/WebCore/ForwardingHeaders/kfiledialog.h b/WebCore/ForwardingHeaders/kfiledialog.h
index 694336d..e69de29 100644
--- a/WebCore/ForwardingHeaders/kfiledialog.h
+++ b/WebCore/ForwardingHeaders/kfiledialog.h
@@ -1 +0,0 @@
-#include "KWQKFileDialog.h"
diff --git a/WebCore/WebCore.pbproj/project.pbxproj b/WebCore/WebCore.pbproj/project.pbxproj
index 25e8821..71b6048 100644
--- a/WebCore/WebCore.pbproj/project.pbxproj
+++ b/WebCore/WebCore.pbproj/project.pbxproj
@@ -362,7 +362,6 @@
 				F587858002DE375901EA4122,
 				F587862902DE398401EA4122,
 				F587860A02DE382001EA4122,
-				F587863102DE39E601EA4122,
 				F587865702DE3A9A01EA4122,
 				F587860B02DE382001EA4122,
 				F587860C02DE382001EA4122,
@@ -541,7 +540,6 @@
 				F587857F02DE375901EA4122,
 				F587858102DE375901EA4122,
 				F587858202DE375901EA4122,
-				F587858402DE375901EA4122,
 				F587858502DE375901EA4122,
 				F587858602DE375901EA4122,
 				F587858702DE375901EA4122,
@@ -5141,12 +5139,6 @@
 			path = KWQKCursor.mm;
 			refType = 4;
 		};
-		F58784F202DE375901EA4122 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = KWQKFileDialog.mm;
-			refType = 4;
-		};
 		F58784F302DE375901EA4122 = {
 			fileEncoding = 30;
 			isa = PBXFileReference;
@@ -5879,12 +5871,6 @@
 			settings = {
 			};
 		};
-		F587858402DE375901EA4122 = {
-			fileRef = F58784F202DE375901EA4122;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
 		F587858502DE375901EA4122 = {
 			fileRef = F58784F302DE375901EA4122;
 			isa = PBXBuildFile;
@@ -6435,7 +6421,6 @@
 				F587861C02DE382201EA4122,
 				F587862F02DE398601EA4122,
 				F58785EF02DE37DE01EA4122,
-				F587863202DE39E701EA4122,
 				F587865F02DE3A9C01EA4122,
 				F587867502DE3B3301EA4122,
 				F587864302DE3A1601EA4122,
@@ -6841,28 +6826,6 @@
 			path = "";
 			refType = 4;
 		};
-		F587863002DE39E601EA4122 = {
-			fileEncoding = 30;
-			isa = PBXFileReference;
-			path = KWQKFileDialog.h;
-			refType = 4;
-		};
-		F587863102DE39E601EA4122 = {
-			fileRef = F587863002DE39E601EA4122;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
-		F587863202DE39E701EA4122 = {
-			children = (
-				F587863002DE39E601EA4122,
-				F58784F202DE375901EA4122,
-			);
-			isa = PBXGroup;
-			name = kfile;
-			path = "";
-			refType = 4;
-		};
 		F587863302DE3A1401EA4122 = {
 			fileEncoding = 30;
 			isa = PBXFileReference;
diff --git a/WebCore/khtml/css/css_base.cpp b/WebCore/khtml/css/css_base.cpp
index fcfcc6e..ef4527f 100644
--- a/WebCore/khtml/css/css_base.cpp
+++ b/WebCore/khtml/css/css_base.cpp
@@ -230,7 +230,7 @@
         }
     }
 
-    value = QString::null;
+    value = DOMString();
 }
 
 
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index efed1a6..3e0dfd6 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -851,10 +851,10 @@
 
 // Special chars used to encode form state strings.
 // We pick chars that are unlikely to be used in an HTML attr, so we rarely have to really encode.
-const QChar stateSeparator = '&';
-const QChar stateEscape = '<';
-const QString stateSeparatorMarker = "<A";
-const QString stateEscapeMarker = "<<";
+const char stateSeparator = '&';
+const char stateEscape = '<';
+static const char stateSeparatorMarker[] = "<A";
+static const char stateEscapeMarker[] = "<<";
 
 // Encode an element name so we can put it in a state string without colliding
 // with our separator char.
diff --git a/WebCore/khtml/html/htmltokenizer.cpp b/WebCore/khtml/html/htmltokenizer.cpp
index fb87600..7af628a 100644
--- a/WebCore/khtml/html/htmltokenizer.cpp
+++ b/WebCore/khtml/html/htmltokenizer.cpp
@@ -65,8 +65,7 @@
 
 using namespace khtml;
 
-static const QChar commentStart [] = { '<','!','-','-', QChar::null };
-
+static const char commentStart [] = "<!--";
 static const char scriptEnd [] = "</script";
 static const char xmpEnd [] = "</xmp";
 static const char styleEnd [] =  "</style";
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index d92574d..b45dfac 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -4039,7 +4039,7 @@
   if ( !userStyleSheet.isEmpty() )
     setUserStyleSheet( KURL( userStyleSheet ) );
   else
-    setUserStyleSheet( QString::null );
+    setUserStyleSheet( QString() );
 
 #if !APPLE_CHANGES
   QApplication::setOverrideCursor( waitCursor );
diff --git a/WebCore/khtml/misc/loader.cpp b/WebCore/khtml/misc/loader.cpp
index 456753d..003434e 100644
--- a/WebCore/khtml/misc/loader.cpp
+++ b/WebCore/khtml/misc/loader.cpp
@@ -1408,7 +1408,7 @@
 CachedObject *Cache::m_headOfUncacheableList = 0;
 int Cache::m_totalSizeOfLRULists = 0;
 int Cache::m_countOfLRUAndUncacheableLists;
-LRUList Cache::m_LRULists[MAX_LRU_LISTS];
+LRUList *Cache::m_LRULists = 0;
 
 void Cache::init()
 {
@@ -1872,6 +1872,9 @@
         if (queueIndex >= MAX_LRU_LISTS)
             queueIndex = MAX_LRU_LISTS-1;
     }
+    if (m_LRULists == 0) {
+        m_LRULists = new LRUList [MAX_LRU_LISTS];
+    }
     return &m_LRULists[queueIndex];
 }
 
diff --git a/WebCore/khtml/misc/loader.h b/WebCore/khtml/misc/loader.h
index a66d3e6..2ae07af 100644
--- a/WebCore/khtml/misc/loader.h
+++ b/WebCore/khtml/misc/loader.h
@@ -585,7 +585,7 @@
     
         static void moveToHeadOfLRUList(CachedObject *);
     
-        static LRUList m_LRULists[];
+        static LRUList *m_LRULists;
         static int m_totalSizeOfLRULists;
             
         static CachedObject *m_headOfUncacheableList;
diff --git a/WebCore/khtml/rendering/bidi.cpp b/WebCore/khtml/rendering/bidi.cpp
index b24ba26..20c4935 100644
--- a/WebCore/khtml/rendering/bidi.cpp
+++ b/WebCore/khtml/rendering/bidi.cpp
@@ -41,7 +41,7 @@
 static BidiIterator last;
 static BidiIterator current;
 static BidiContext *context;
-static BidiStatus status;
+static BidiStatus status = { QChar::DirON, QChar::DirON, QChar::DirON };
 
 // Used to track a list of chained bidi runs.
 static BidiRun* sFirstBidiRun = 0;
@@ -281,42 +281,6 @@
     return o;
 }
 
-BidiIterator::BidiIterator()
-{
-    par = 0;
-    obj = 0;
-    pos = 0;
-}
-
-BidiIterator::BidiIterator(RenderBlock *_par)
-{
-    par = _par;
-    obj = first( par );
-    pos = 0;
-}
-
-BidiIterator::BidiIterator(const BidiIterator &it)
-{
-    par = it.par;
-    obj = it.obj;
-    pos = it.pos;
-}
-
-BidiIterator::BidiIterator(RenderBlock *_par, RenderObject *_obj, int _pos)
-{
-    par = _par;
-    obj = _obj;
-    pos = _pos;
-}
-
-BidiIterator &BidiIterator::operator = (const BidiIterator &it)
-{
-    obj = it.obj;
-    pos = it.pos;
-    par = it.par;
-    return *this;
-}
-
 inline void BidiIterator::operator ++ ()
 {
     if(!obj) return;
@@ -338,11 +302,12 @@
     return false;
 }
 
-static const QChar nbsp = QChar(0xA0);
-
-inline const QChar &BidiIterator::current() const
+const QChar &BidiIterator::current() const
 {
-    if( !obj || !obj->isText()) return nbsp; // non breaking space
+    if( !obj || !obj->isText()) {
+      static QChar nonBreakingSpace(0xA0);
+      return nonBreakingSpace;
+    }
     return static_cast<RenderText *>(obj)->text()[pos];
 }
 
@@ -437,7 +402,7 @@
         return;
 
     bool haveNextMidpoint = (smidpoints && sCurrMidpoint < sNumMidpoints);
-    BidiIterator nextMidpoint;
+    BidiIterator nextMidpoint = { 0, 0, 0 };
     if (haveNextMidpoint)
         nextMidpoint = smidpoints->at(sCurrMidpoint);
     if (betweenMidpoints) {
@@ -1198,9 +1163,9 @@
         // the little compact and then reorder them for bidi.
         RenderBlock* compactBlock = static_cast<RenderBlock*>(compactObj);
         adjustEmbeddding = true;
-        BidiIterator start(compactBlock);
+        BidiIterator start = { compactBlock, first(compactBlock), 0 };
         adjustEmbeddding = false;
-        BidiIterator end(compactBlock);
+        BidiIterator end = start;
     
         betweenMidpoints = false;
         isLineEmpty = true;
@@ -1266,7 +1231,6 @@
         }
 
         BidiContext *startEmbed;
-        status = BidiStatus();
         if( style()->direction() == LTR ) {
             startEmbed = new BidiContext( 0, QChar::DirL );
             status.eor = QChar::DirL;
@@ -1276,11 +1240,14 @@
         }
         startEmbed->ref();
 
+	status.lastStrong = QChar::DirON;
+	status.last = QChar::DirON;
+
         context = startEmbed;
         adjustEmbeddding = true;
-        BidiIterator start(this);
+        BidiIterator start = { this, first(this), 0 };
         adjustEmbeddding = false;
-        BidiIterator end(this);
+        BidiIterator end = start;
 
         m_firstLine = true;
         
@@ -1503,9 +1470,7 @@
 
             tmpW += o->width()+o->marginLeft()+o->marginRight()+inlineWidth(o);
             if (ignoringSpaces) {
-                BidiIterator startMid;
-                startMid.obj = o;
-                startMid.pos = 0;
+                BidiIterator startMid = { 0, o, 0 };
                 addMidpoint(startMid);
             }
             isLineEmpty = false;
@@ -1527,9 +1492,7 @@
                       static_cast<RenderText*>(next)->text()[0] == '\n')) {
                     currentCharacterIsSpace = true;
                     ignoringSpaces = true;
-                    BidiIterator endMid;
-                    endMid.obj = o;
-                    endMid.pos = 0;
+                    BidiIterator endMid = { 0, o, 0 };
                     addMidpoint(endMid);
                 }
             }
@@ -1568,9 +1531,7 @@
                         if (!currentCharacterIsSpace) {
                             // Stop ignoring spaces and begin at this
                             // new point.
-                            BidiIterator startMid;
-                            startMid.obj = o;
-                            startMid.pos = pos;
+                            BidiIterator startMid = { 0, o, pos };
                             addMidpoint(startMid);
                             ignoringSpaces = false;
                         }
@@ -1655,12 +1616,7 @@
                             // We just entered a mode where we are ignoring
                             // spaces. Create a midpoint to terminate the run
                             // before the second space. 
-                            BidiIterator endMid;
-                            if (trailingSpaceObject)
-                                endMid.obj = trailingSpaceObject;
-                            else
-                                endMid.obj = o;
-                            endMid.pos = lastSpacePos;
+                            BidiIterator endMid = { 0, trailingSpaceObject ? trailingSpaceObject : o, lastSpacePos };
                             addMidpoint(endMid);
                             lastSpace = pos;
                         }
@@ -1672,9 +1628,7 @@
                     ignoringSpaces = false;
                     lastSpacePos = 0;
                     lastSpace = pos; // e.g., "Foo    goo", don't add in any of the ignored spaces.
-                    BidiIterator startMid;
-                    startMid.obj = o;
-                    startMid.pos = pos;
+                    BidiIterator startMid = { 0, o, pos };
                     addMidpoint(startMid);
                 }
                 
@@ -1837,10 +1791,9 @@
         //    lBreak.pos--;
         else if (lBreak.obj == 0 && trailingSpaceObject->isText()) {
             // Add a new end midpoint that stops right at the very end.
-            BidiIterator endMid;
-            endMid.obj = trailingSpaceObject;
             RenderText* text = static_cast<RenderText *>(trailingSpaceObject);
-            endMid.pos = text->length() >=2 ? text->length() - 2 : UINT_MAX;
+            unsigned pos = text->length() >=2 ? text->length() - 2 : UINT_MAX;
+            BidiIterator endMid = { 0, trailingSpaceObject, pos };
             addMidpoint(endMid);
         }
     }
diff --git a/WebCore/khtml/rendering/bidi.h b/WebCore/khtml/rendering/bidi.h
index 6595cda..be0f0e4 100644
--- a/WebCore/khtml/rendering/bidi.h
+++ b/WebCore/khtml/rendering/bidi.h
@@ -100,16 +100,8 @@
     };
 
     // an iterator which goes through a BidiParagraph
-    class BidiIterator
+    struct BidiIterator
     {
-    public:
-	BidiIterator();
-	BidiIterator(RenderBlock *par);
-	BidiIterator(RenderBlock *par, RenderObject *_obj, int _pos = 0);
-
-	BidiIterator(const BidiIterator &it);
-	BidiIterator &operator = (const BidiIterator &it);
-
 	void operator ++ ();
 
 	bool atEnd() const;
@@ -117,22 +109,15 @@
 	const QChar &current() const;
 	QChar::Direction direction() const;
 
-public:
 	RenderBlock *par;
 	RenderObject *obj;
 	unsigned int pos;
-
     };
 
     struct BidiStatus {
-	BidiStatus() {
-	    eor = QChar::DirON;
-	    lastStrong = QChar::DirON;
-	    last = QChar:: DirON;
-	}
-	QChar::Direction eor 		: 5;
-	QChar::Direction lastStrong 	: 5;
-	QChar::Direction last		: 5;
+	QChar::Direction eor;
+	QChar::Direction lastStrong;
+	QChar::Direction last;
     };
 
 };
diff --git a/WebCore/khtml/rendering/render_frames.cpp b/WebCore/khtml/rendering/render_frames.cpp
index c02324d..32f1bb3 100644
--- a/WebCore/khtml/rendering/render_frames.cpp
+++ b/WebCore/khtml/rendering/render_frames.cpp
@@ -46,8 +46,6 @@
 #include <qtimer.h>
 #include <qpainter.h>
 
-#include <assert.h>
-#include <iostream.h>
 using namespace khtml;
 using namespace DOM;
 
diff --git a/WebCore/khtml/rendering/render_list.cpp b/WebCore/khtml/rendering/render_list.cpp
index 401414b..eda51be 100644
--- a/WebCore/khtml/rendering/render_list.cpp
+++ b/WebCore/khtml/rendering/render_list.cpp
@@ -456,7 +456,7 @@
     case LNONE:
         return;
     default:
-        if (m_item != QString::null) {
+        if (!m_item.isEmpty()) {
 #if APPLE_CHANGES
             // Text should be drawn on the baseline, so we add in the ascent of the font. 
             // For some inexplicable reason, this works in Konqueror.  I'm not sure why.
diff --git a/WebCore/kwq/KWQChar.mm b/WebCore/kwq/KWQChar.mm
index 6c5d930..aae812a 100644
--- a/WebCore/kwq/KWQChar.mm
+++ b/WebCore/kwq/KWQChar.mm
@@ -39,8 +39,6 @@
     return s;
 }
 
-const QChar QChar::null;
-
 bool QChar::isDigit() const
 {
     static CFCharacterSetRef set = CFCharacterSetGetPredefined(kCFCharacterSetDecimalDigit);
diff --git a/WebCore/kwq/KWQColor.mm b/WebCore/kwq/KWQColor.mm
index 8ae2edb..61bbda8 100644
--- a/WebCore/kwq/KWQColor.mm
+++ b/WebCore/kwq/KWQColor.mm
@@ -35,18 +35,6 @@
 #import "KWQColorData.c"
 #undef __inline
 
-const QColor Qt::black    (0x00, 0x00, 0x00);
-const QColor Qt::white    (0xFF, 0xFF, 0xFF);
-const QColor Qt::darkGray (0x80, 0x80, 0x80);
-const QColor Qt::gray     (0xA0, 0xA0, 0xA0);
-const QColor Qt::lightGray(0xC0, 0xC0, 0xC0);
-const QColor Qt::red      (0xFF, 0x00, 0x00);
-const QColor Qt::green    (0x00, 0xFF, 0x00);
-const QColor Qt::blue     (0x00, 0x00, 0xFF);
-const QColor Qt::cyan     (0x00, 0xFF, 0xFF);
-const QColor Qt::magenta  (0xFF, 0x00, 0xFF);
-const QColor Qt::yellow   (0xFF, 0xFF, 0x00);
-
 QRgb qRgb(int r, int g, int b)
 {
     if (r < 0) r = 0; else if (r > 255) r = 255;
diff --git a/WebCore/kwq/KWQKFileDialog.h b/WebCore/kwq/KWQKFileDialog.h
deleted file mode 100644
index 65ddecf..0000000
--- a/WebCore/kwq/KWQKFileDialog.h
+++ /dev/null
@@ -1,39 +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. 
- */
-
-#ifndef KFILEDIALOG_H_
-#define KFILEDIALOG_H_
-
-#include "KWQString.h"
-#include "KWQWidget.h"
-
-class KFileDialog {
-public:
-    static QString getOpenFileName(const QString &startDir=QString::null, 
-        const QString &filter=QString::null, QWidget *parent=0, 
-        const QString &caption=QString::null);
-};
-
-#endif
diff --git a/WebCore/kwq/KWQKFileDialog.mm b/WebCore/kwq/KWQKFileDialog.mm
deleted file mode 100644
index f81ea24..0000000
--- a/WebCore/kwq/KWQKFileDialog.mm
+++ /dev/null
@@ -1,34 +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 "KWQKFileDialog.h"
-#import "KWQLogging.h"
-
-QString KFileDialog::getOpenFileName(const QString &startDir, 
-    const QString &filter, QWidget *parent, const QString &caption)
-{
-    ERROR("not yet implemented");
-    return QString();
-}
diff --git a/WebCore/kwq/KWQKHTMLSettings.h b/WebCore/kwq/KWQKHTMLSettings.h
index 2ac34de..8cd5cbe 100644
--- a/WebCore/kwq/KWQKHTMLSettings.h
+++ b/WebCore/kwq/KWQKHTMLSettings.h
@@ -49,7 +49,7 @@
     const QString &cursiveFontName() const { return _cursiveFontName; }
     const QString &fantasyFontName() const { return _fantasyFontName; }
     
-    static const QString &settingsToCSS() { return QString::null; }
+    static QString settingsToCSS() { return QString(); }
 
     int minFontSize() const { return _minimumFontSize; }
     int mediumFontSize() const { return _defaultFontSize; }
diff --git a/WebCore/kwq/KWQNamespace.h b/WebCore/kwq/KWQNamespace.h
index 2b3e5e8..3d9dfae 100644
--- a/WebCore/kwq/KWQNamespace.h
+++ b/WebCore/kwq/KWQNamespace.h
@@ -226,17 +226,11 @@
         XorROP,
     };
 
-    static const QColor black;
-    static const QColor white;
-    static const QColor darkGray;
-    static const QColor gray;
-    static const QColor lightGray;
-    static const QColor red;
-    static const QColor green;
-    static const QColor blue;
-    static const QColor cyan;
-    static const QColor magenta;
-    static const QColor yellow;
+    static const unsigned black = 0x000000;
+    static const unsigned white = 0xFFFFFF;
+    static const unsigned darkGray = 0x808080;
+    static const unsigned gray = 0xA0A0A0;
+    static const unsigned lightGray = 0xC0C0C0;
 
 };
 
diff --git a/WebCore/kwq/KWQPainter.h b/WebCore/kwq/KWQPainter.h
index 6ab7d2a..9590311 100644
--- a/WebCore/kwq/KWQPainter.h
+++ b/WebCore/kwq/KWQPainter.h
@@ -59,10 +59,12 @@
     const QPen &pen() const;
     void setPen(const QPen &);
     void setPen(PenStyle);
+    void setPen(QRgb);
     
     const QBrush &QPainter::brush() const;
     void setBrush(const QBrush &);
     void setBrush(BrushStyle);
+    void setBrush(QRgb);
 
     QRect xForm(const QRect &) const;
 
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index a9bcf4c..b6182cd 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -109,6 +109,13 @@
     data->state.pen.setWidth(0);
 }
 
+void QPainter::setPen(QRgb rgb)
+{
+    data->state.pen.setStyle(SolidLine);
+    data->state.pen.setColor(rgb);
+    data->state.pen.setWidth(0);
+}
+
 void QPainter::setBrush(const QBrush &brush)
 {
     data->state.brush = brush;
@@ -120,6 +127,12 @@
     data->state.brush.setColor(Qt::black);
 }
 
+void QPainter::setBrush(QRgb rgb)
+{
+    data->state.brush.setStyle(SolidPattern);
+    data->state.brush.setColor(rgb);
+}
+
 const QBrush &QPainter::brush() const
 {
     return data->state.brush;
diff --git a/WebCore/kwq/KWQString.h b/WebCore/kwq/KWQString.h
index eaed4f5..6fb2bdb 100644
--- a/WebCore/kwq/KWQString.h
+++ b/WebCore/kwq/KWQString.h
@@ -50,7 +50,7 @@
         DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN
     };
 
-    static const QChar null;
+    static const char null = 0; // not a QChar as in Qt (can't have static constructor), but close enough to be compatible in most cases
 
     QChar();
     QChar(char);
@@ -332,7 +332,7 @@
 
 class QString {
 public:
-    static const QString null;
+    static const char * const null = 0; // not a QString as in Qt (can't have static constructor), but close enough to be compatible in most cases
 
     QString();
     QString(QChar);
diff --git a/WebCore/kwq/KWQString.mm b/WebCore/kwq/KWQString.mm
index 151c753..6d34ae9 100644
--- a/WebCore/kwq/KWQString.mm
+++ b/WebCore/kwq/KWQString.mm
@@ -690,8 +690,6 @@
     return nil;
 }
 
-const QString QString::null;
-
 inline void QString::detachIfInternal()
 {
     KWQStringData *oldData = *dataHandle;
@@ -1698,7 +1696,7 @@
     }
     
     // degenerate case
-    return null;
+    return QString();
 }