[SCM] WebKit Debian packaging branch, debian/unstable, updated. debian/1.1.15-1-40151-g37bb677

hyatt hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Sat Sep 26 07:25:56 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 3905c48acb7062ce1df8b9a4be3e9b68fe2ad935
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 25 20:00:16 2003 +0000

    	The new CSS1 parser, implementation of attr(), improvement of
    	the content property, impl of the :target selector, and new
    	dotted/dashed line drawing code for borders.
    
            Reviewed by darin/gramps
    
            * ForwardingHeaders/css/css_base.h: Added.
            * WebCore.pbproj/project.pbxproj:
            * khtml/css/Makefile.am:
            * khtml/css/css_base.cpp: Added.
            (StyleBaseImpl::checkLoaded):
            (StyleBaseImpl::stylesheet):
            (StyleBaseImpl::baseURL):
            (StyleBaseImpl::setParsedValue):
            (StyleListImpl::~StyleListImpl):
            (CSSSelector::print):
            (CSSSelector::specificity):
            (CSSSelector::extractPseudoType):
            (CSSSelector::operator == ):
            (CSSSelector::selectorText):
            * khtml/css/css_base.h: Added.
            * khtml/css/css_ruleimpl.cpp:
            (CSSRuleImpl::parentRule):
            (CSSImportRuleImpl::CSSImportRuleImpl):
            (CSSImportRuleImpl::~CSSImportRuleImpl):
            (CSSImportRuleImpl::setStyleSheet):
            (CSSImportRuleImpl::init):
            (CSSMediaRuleImpl::CSSMediaRuleImpl):
            (CSSMediaRuleImpl::append):
            (CSSMediaRuleImpl::insertRule):
            (CSSStyleRuleImpl::setDeclaration):
            (CSSStyleRuleImpl::setNonCSSHints):
            * khtml/css/css_ruleimpl.h:
            * khtml/css/css_stylesheetimpl.cpp:
            (CSSStyleSheetImpl::CSSStyleSheetImpl):
            (CSSStyleSheetImpl::insertRule):
            (CSSStyleSheetImpl::cssRules):
            (CSSStyleSheetImpl::parseString):
            (MediaListImpl::deleteMedium):
            * khtml/css/css_stylesheetimpl.h:
            * khtml/css/css_valueimpl.cpp:
            (CSSStyleDeclarationImpl::getPropertyValue):
            (CSSStyleDeclarationImpl::get4Values):
            (CSSStyleDeclarationImpl::getShortHandValue):
            (CSSStyleDeclarationImpl::getPropertyCSSValue):
            (CSSStyleDeclarationImpl::removeProperty):
            (CSSStyleDeclarationImpl::getPropertyPriority):
            (CSSStyleDeclarationImpl::setProperty):
            (CSSStyleDeclarationImpl::setLengthProperty):
            (CSSPrimitiveValueImpl::CSSPrimitiveValueImpl):
            (CSSPrimitiveValueImpl::cleanup):
            (CSSPrimitiveValueImpl::computeLength):
            (CSSPrimitiveValueImpl::computeLengthFloat):
            (CSSPrimitiveValueImpl::setFloatValue):
            (CSSPrimitiveValueImpl::cssText):
            (FontFamilyValueImpl::FontFamilyValueImpl):
            (FontValueImpl::FontValueImpl):
            (FontValueImpl::~FontValueImpl):
            * khtml/css/css_valueimpl.h:
            * khtml/css/cssparser.cpp:
            (qFatal):
            (ValueList::ValueList):
            (ValueList::~ValueList):
            (ValueList::addValue):
            (CSSParser::CSSParser):
            (CSSParser::~CSSParser):
            (CSSParser::parseSheet):
            (CSSParser::parseRule):
            (CSSParser::parseValue):
            (CSSParser::parseDeclaration):
            (CSSParser::addProperty):
            (CSSParser::createStyleDeclaration):
            (CSSParser::clearProperties):
            (CSSParser::document):
            (validUnit):
            (CSSParser::parseShortHand):
            (CSSParser::parse4Values):
            (CSSParser::parseContent):
            (CSSParser::parseShape):
            (CSSParser::parseFont):
            (CSSParser::parseFontFamily):
            (parseColor):
            (CSSParser::parseColor):
            (yyerror):
            (DOM::CSSParser::lex):
            (toHex):
            (DOM::CSSParser::text):
            * khtml/css/cssparser.h:
            * khtml/css/cssproperties.c:
            (findProp):
            * khtml/css/cssproperties.h:
            * khtml/css/cssproperties.in:
            * khtml/css/cssstyleselector.cpp:
            * khtml/css/cssstyleselector.h:
            * khtml/css/cssvalues.c:
            (hash_val):
            (findValue):
            * khtml/css/cssvalues.h:
            * khtml/css/cssvalues.in:
            * khtml/css/html4.css:
            * khtml/css/parser.cpp: Added.
            (DOM::getPropertyID):
            (getValueID):
            (cssyyerror):
            (cssyylex):
            (__yy_memcpy):
            * khtml/css/parser.h: Added.
            * khtml/css/parser.y: Added.
            * khtml/css/quirks.css: Added.
            * khtml/css/tokenizer.cpp: Added.
            * khtml/css/tokenizer.flex: Added.
            * khtml/dom/css_value.h:
            * khtml/dom/html_element.cpp:
            * khtml/ecma/kjs_css.cpp:
            * khtml/html/html_baseimpl.cpp:
            (HTMLBodyElementImpl::parseAttribute):
            * khtml/html/html_blockimpl.cpp:
            (HTMLDivElementImpl::parseAttribute):
            (HTMLHRElementImpl::attach):
            (HTMLParagraphElementImpl::parseAttribute):
            * khtml/html/html_elementimpl.cpp:
            (isHexDigit):
            (toHex):
            (HTMLElementImpl::addHTMLColor):
            * khtml/html/html_elementimpl.h:
            * khtml/html/html_inlineimpl.cpp:
            (HTMLFontElementImpl::parseAttribute):
            * khtml/html/html_tableimpl.cpp:
            (HTMLTableElementImpl::parseAttribute):
            (HTMLTableElementImpl::attach):
            (HTMLTablePartElementImpl::parseAttribute):
            (HTMLTableCellElementImpl::parseAttribute):
            * khtml/khtml_part.cpp:
            (KHTMLPart::gotoAnchor):
            * khtml/misc/helper.h:
            * khtml/rendering/render_body.cpp:
            (RenderBody::setStyle):
            * khtml/rendering/render_list.cpp:
            (RenderListMarker::lineHeight):
            (RenderListMarker::baselinePosition):
            * khtml/rendering/render_style.cpp:
            (RenderStyle::setContent):
            * khtml/rendering/render_style.h:
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::DocumentImpl):
            (DocumentImpl::setFocusNode):
            (DocumentImpl::setCSSTarget):
            (DocumentImpl::getCSSTarget):
            * khtml/xml/dom_docimpl.h:
            * kwq/KWQChar.mm:
            (QChar::upper):
            * kwq/KWQColor.h:
            * kwq/KWQKStandardDirs.mm:
            (locate):
            * kwq/KWQPainter.mm:
            (QPainter::drawLine):
            * kwq/KWQString.h:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@3695 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2003-10-25 b/WebCore/ChangeLog-2003-10-25
index d563a68..f502163 100644
--- a/WebCore/ChangeLog-2003-10-25
+++ b/WebCore/ChangeLog-2003-10-25
@@ -1,3 +1,165 @@
+<<<<<<< ChangeLog
+2003-02-24  David Hyatt  <hyatt at apple.com>
+
+	The new CSS1 parser, implementation of attr(), improvement of
+	the content property, impl of the :target selector, and new
+	dotted/dashed line drawing code for borders.
+	
+        Reviewed by darin/gramps
+
+        * ForwardingHeaders/css/css_base.h: Added.
+        * WebCore.pbproj/project.pbxproj:
+        * khtml/css/Makefile.am:
+        * khtml/css/css_base.cpp: Added.
+        (StyleBaseImpl::checkLoaded):
+        (StyleBaseImpl::stylesheet):
+        (StyleBaseImpl::baseURL):
+        (StyleBaseImpl::setParsedValue):
+        (StyleListImpl::~StyleListImpl):
+        (CSSSelector::print):
+        (CSSSelector::specificity):
+        (CSSSelector::extractPseudoType):
+        (CSSSelector::operator == ):
+        (CSSSelector::selectorText):
+        * khtml/css/css_base.h: Added.
+        * khtml/css/css_ruleimpl.cpp:
+        (CSSRuleImpl::parentRule):
+        (CSSImportRuleImpl::CSSImportRuleImpl):
+        (CSSImportRuleImpl::~CSSImportRuleImpl):
+        (CSSImportRuleImpl::setStyleSheet):
+        (CSSImportRuleImpl::init):
+        (CSSMediaRuleImpl::CSSMediaRuleImpl):
+        (CSSMediaRuleImpl::append):
+        (CSSMediaRuleImpl::insertRule):
+        (CSSStyleRuleImpl::setDeclaration):
+        (CSSStyleRuleImpl::setNonCSSHints):
+        * khtml/css/css_ruleimpl.h:
+        * khtml/css/css_stylesheetimpl.cpp:
+        (CSSStyleSheetImpl::CSSStyleSheetImpl):
+        (CSSStyleSheetImpl::insertRule):
+        (CSSStyleSheetImpl::cssRules):
+        (CSSStyleSheetImpl::parseString):
+        (MediaListImpl::deleteMedium):
+        * khtml/css/css_stylesheetimpl.h:
+        * khtml/css/css_valueimpl.cpp:
+        (CSSStyleDeclarationImpl::getPropertyValue):
+        (CSSStyleDeclarationImpl::get4Values):
+        (CSSStyleDeclarationImpl::getShortHandValue):
+        (CSSStyleDeclarationImpl::getPropertyCSSValue):
+        (CSSStyleDeclarationImpl::removeProperty):
+        (CSSStyleDeclarationImpl::getPropertyPriority):
+        (CSSStyleDeclarationImpl::setProperty):
+        (CSSStyleDeclarationImpl::setLengthProperty):
+        (CSSPrimitiveValueImpl::CSSPrimitiveValueImpl):
+        (CSSPrimitiveValueImpl::cleanup):
+        (CSSPrimitiveValueImpl::computeLength):
+        (CSSPrimitiveValueImpl::computeLengthFloat):
+        (CSSPrimitiveValueImpl::setFloatValue):
+        (CSSPrimitiveValueImpl::cssText):
+        (FontFamilyValueImpl::FontFamilyValueImpl):
+        (FontValueImpl::FontValueImpl):
+        (FontValueImpl::~FontValueImpl):
+        * khtml/css/css_valueimpl.h:
+        * khtml/css/cssparser.cpp:
+        (qFatal):
+        (ValueList::ValueList):
+        (ValueList::~ValueList):
+        (ValueList::addValue):
+        (CSSParser::CSSParser):
+        (CSSParser::~CSSParser):
+        (CSSParser::parseSheet):
+        (CSSParser::parseRule):
+        (CSSParser::parseValue):
+        (CSSParser::parseDeclaration):
+        (CSSParser::addProperty):
+        (CSSParser::createStyleDeclaration):
+        (CSSParser::clearProperties):
+        (CSSParser::document):
+        (validUnit):
+        (CSSParser::parseShortHand):
+        (CSSParser::parse4Values):
+        (CSSParser::parseContent):
+        (CSSParser::parseShape):
+        (CSSParser::parseFont):
+        (CSSParser::parseFontFamily):
+        (parseColor):
+        (CSSParser::parseColor):
+        (yyerror):
+        (DOM::CSSParser::lex):
+        (toHex):
+        (DOM::CSSParser::text):
+        * khtml/css/cssparser.h:
+        * khtml/css/cssproperties.c:
+        (findProp):
+        * khtml/css/cssproperties.h:
+        * khtml/css/cssproperties.in:
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/cssstyleselector.h:
+        * khtml/css/cssvalues.c:
+        (hash_val):
+        (findValue):
+        * khtml/css/cssvalues.h:
+        * khtml/css/cssvalues.in:
+        * khtml/css/html4.css:
+        * khtml/css/parser.cpp: Added.
+        (DOM::getPropertyID):
+        (getValueID):
+        (cssyyerror):
+        (cssyylex):
+        (__yy_memcpy):
+        * khtml/css/parser.h: Added.
+        * khtml/css/parser.y: Added.
+        * khtml/css/quirks.css: Added.
+        * khtml/css/tokenizer.cpp: Added.
+        * khtml/css/tokenizer.flex: Added.
+        * khtml/dom/css_value.h:
+        * khtml/dom/html_element.cpp:
+        * khtml/ecma/kjs_css.cpp:
+        * khtml/html/html_baseimpl.cpp:
+        (HTMLBodyElementImpl::parseAttribute):
+        * khtml/html/html_blockimpl.cpp:
+        (HTMLDivElementImpl::parseAttribute):
+        (HTMLHRElementImpl::attach):
+        (HTMLParagraphElementImpl::parseAttribute):
+        * khtml/html/html_elementimpl.cpp:
+        (isHexDigit):
+        (toHex):
+        (HTMLElementImpl::addHTMLColor):
+        * khtml/html/html_elementimpl.h:
+        * khtml/html/html_inlineimpl.cpp:
+        (HTMLFontElementImpl::parseAttribute):
+        * khtml/html/html_tableimpl.cpp:
+        (HTMLTableElementImpl::parseAttribute):
+        (HTMLTableElementImpl::attach):
+        (HTMLTablePartElementImpl::parseAttribute):
+        (HTMLTableCellElementImpl::parseAttribute):
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::gotoAnchor):
+        * khtml/misc/helper.h:
+        * khtml/rendering/render_body.cpp:
+        (RenderBody::setStyle):
+        * khtml/rendering/render_list.cpp:
+        (RenderListMarker::lineHeight):
+        (RenderListMarker::baselinePosition):
+        * khtml/rendering/render_style.cpp:
+        (RenderStyle::setContent):
+        * khtml/rendering/render_style.h:
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::DocumentImpl):
+        (DocumentImpl::setFocusNode):
+        (DocumentImpl::setCSSTarget):
+        (DocumentImpl::getCSSTarget):
+        * khtml/xml/dom_docimpl.h:
+        * kwq/KWQChar.mm:
+        (QChar::upper):
+        * kwq/KWQColor.h:
+        * kwq/KWQKStandardDirs.mm:
+        (locate):
+        * kwq/KWQPainter.mm:
+        (QPainter::drawLine):
+        * kwq/KWQString.h:
+
+=======
 2003-02-24  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by John.
@@ -9,6 +171,7 @@
         (HTMLDocumentImpl::HTMLDocumentImpl): Added new processingLoadEvent bool.
         (HTMLDocumentImpl::close): Guard against re-entering the load event handler.
 
+>>>>>>> 1.1437
 2003-02-24  Darin Adler  <darin at apple.com>
 
         Reviewed by Ken.
diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index d563a68..f502163 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,165 @@
+<<<<<<< ChangeLog
+2003-02-24  David Hyatt  <hyatt at apple.com>
+
+	The new CSS1 parser, implementation of attr(), improvement of
+	the content property, impl of the :target selector, and new
+	dotted/dashed line drawing code for borders.
+	
+        Reviewed by darin/gramps
+
+        * ForwardingHeaders/css/css_base.h: Added.
+        * WebCore.pbproj/project.pbxproj:
+        * khtml/css/Makefile.am:
+        * khtml/css/css_base.cpp: Added.
+        (StyleBaseImpl::checkLoaded):
+        (StyleBaseImpl::stylesheet):
+        (StyleBaseImpl::baseURL):
+        (StyleBaseImpl::setParsedValue):
+        (StyleListImpl::~StyleListImpl):
+        (CSSSelector::print):
+        (CSSSelector::specificity):
+        (CSSSelector::extractPseudoType):
+        (CSSSelector::operator == ):
+        (CSSSelector::selectorText):
+        * khtml/css/css_base.h: Added.
+        * khtml/css/css_ruleimpl.cpp:
+        (CSSRuleImpl::parentRule):
+        (CSSImportRuleImpl::CSSImportRuleImpl):
+        (CSSImportRuleImpl::~CSSImportRuleImpl):
+        (CSSImportRuleImpl::setStyleSheet):
+        (CSSImportRuleImpl::init):
+        (CSSMediaRuleImpl::CSSMediaRuleImpl):
+        (CSSMediaRuleImpl::append):
+        (CSSMediaRuleImpl::insertRule):
+        (CSSStyleRuleImpl::setDeclaration):
+        (CSSStyleRuleImpl::setNonCSSHints):
+        * khtml/css/css_ruleimpl.h:
+        * khtml/css/css_stylesheetimpl.cpp:
+        (CSSStyleSheetImpl::CSSStyleSheetImpl):
+        (CSSStyleSheetImpl::insertRule):
+        (CSSStyleSheetImpl::cssRules):
+        (CSSStyleSheetImpl::parseString):
+        (MediaListImpl::deleteMedium):
+        * khtml/css/css_stylesheetimpl.h:
+        * khtml/css/css_valueimpl.cpp:
+        (CSSStyleDeclarationImpl::getPropertyValue):
+        (CSSStyleDeclarationImpl::get4Values):
+        (CSSStyleDeclarationImpl::getShortHandValue):
+        (CSSStyleDeclarationImpl::getPropertyCSSValue):
+        (CSSStyleDeclarationImpl::removeProperty):
+        (CSSStyleDeclarationImpl::getPropertyPriority):
+        (CSSStyleDeclarationImpl::setProperty):
+        (CSSStyleDeclarationImpl::setLengthProperty):
+        (CSSPrimitiveValueImpl::CSSPrimitiveValueImpl):
+        (CSSPrimitiveValueImpl::cleanup):
+        (CSSPrimitiveValueImpl::computeLength):
+        (CSSPrimitiveValueImpl::computeLengthFloat):
+        (CSSPrimitiveValueImpl::setFloatValue):
+        (CSSPrimitiveValueImpl::cssText):
+        (FontFamilyValueImpl::FontFamilyValueImpl):
+        (FontValueImpl::FontValueImpl):
+        (FontValueImpl::~FontValueImpl):
+        * khtml/css/css_valueimpl.h:
+        * khtml/css/cssparser.cpp:
+        (qFatal):
+        (ValueList::ValueList):
+        (ValueList::~ValueList):
+        (ValueList::addValue):
+        (CSSParser::CSSParser):
+        (CSSParser::~CSSParser):
+        (CSSParser::parseSheet):
+        (CSSParser::parseRule):
+        (CSSParser::parseValue):
+        (CSSParser::parseDeclaration):
+        (CSSParser::addProperty):
+        (CSSParser::createStyleDeclaration):
+        (CSSParser::clearProperties):
+        (CSSParser::document):
+        (validUnit):
+        (CSSParser::parseShortHand):
+        (CSSParser::parse4Values):
+        (CSSParser::parseContent):
+        (CSSParser::parseShape):
+        (CSSParser::parseFont):
+        (CSSParser::parseFontFamily):
+        (parseColor):
+        (CSSParser::parseColor):
+        (yyerror):
+        (DOM::CSSParser::lex):
+        (toHex):
+        (DOM::CSSParser::text):
+        * khtml/css/cssparser.h:
+        * khtml/css/cssproperties.c:
+        (findProp):
+        * khtml/css/cssproperties.h:
+        * khtml/css/cssproperties.in:
+        * khtml/css/cssstyleselector.cpp:
+        * khtml/css/cssstyleselector.h:
+        * khtml/css/cssvalues.c:
+        (hash_val):
+        (findValue):
+        * khtml/css/cssvalues.h:
+        * khtml/css/cssvalues.in:
+        * khtml/css/html4.css:
+        * khtml/css/parser.cpp: Added.
+        (DOM::getPropertyID):
+        (getValueID):
+        (cssyyerror):
+        (cssyylex):
+        (__yy_memcpy):
+        * khtml/css/parser.h: Added.
+        * khtml/css/parser.y: Added.
+        * khtml/css/quirks.css: Added.
+        * khtml/css/tokenizer.cpp: Added.
+        * khtml/css/tokenizer.flex: Added.
+        * khtml/dom/css_value.h:
+        * khtml/dom/html_element.cpp:
+        * khtml/ecma/kjs_css.cpp:
+        * khtml/html/html_baseimpl.cpp:
+        (HTMLBodyElementImpl::parseAttribute):
+        * khtml/html/html_blockimpl.cpp:
+        (HTMLDivElementImpl::parseAttribute):
+        (HTMLHRElementImpl::attach):
+        (HTMLParagraphElementImpl::parseAttribute):
+        * khtml/html/html_elementimpl.cpp:
+        (isHexDigit):
+        (toHex):
+        (HTMLElementImpl::addHTMLColor):
+        * khtml/html/html_elementimpl.h:
+        * khtml/html/html_inlineimpl.cpp:
+        (HTMLFontElementImpl::parseAttribute):
+        * khtml/html/html_tableimpl.cpp:
+        (HTMLTableElementImpl::parseAttribute):
+        (HTMLTableElementImpl::attach):
+        (HTMLTablePartElementImpl::parseAttribute):
+        (HTMLTableCellElementImpl::parseAttribute):
+        * khtml/khtml_part.cpp:
+        (KHTMLPart::gotoAnchor):
+        * khtml/misc/helper.h:
+        * khtml/rendering/render_body.cpp:
+        (RenderBody::setStyle):
+        * khtml/rendering/render_list.cpp:
+        (RenderListMarker::lineHeight):
+        (RenderListMarker::baselinePosition):
+        * khtml/rendering/render_style.cpp:
+        (RenderStyle::setContent):
+        * khtml/rendering/render_style.h:
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::DocumentImpl):
+        (DocumentImpl::setFocusNode):
+        (DocumentImpl::setCSSTarget):
+        (DocumentImpl::getCSSTarget):
+        * khtml/xml/dom_docimpl.h:
+        * kwq/KWQChar.mm:
+        (QChar::upper):
+        * kwq/KWQColor.h:
+        * kwq/KWQKStandardDirs.mm:
+        (locate):
+        * kwq/KWQPainter.mm:
+        (QPainter::drawLine):
+        * kwq/KWQString.h:
+
+=======
 2003-02-24  Maciej Stachowiak  <mjs at apple.com>
 
         Reviewed by John.
@@ -9,6 +171,7 @@
         (HTMLDocumentImpl::HTMLDocumentImpl): Added new processingLoadEvent bool.
         (HTMLDocumentImpl::close): Guard against re-entering the load event handler.
 
+>>>>>>> 1.1437
 2003-02-24  Darin Adler  <darin at apple.com>
 
         Reviewed by Ken.
diff --git a/WebCore/ForwardingHeaders/css/css_base.h b/WebCore/ForwardingHeaders/css/css_base.h
new file mode 100644
index 0000000..7786d97
--- /dev/null
+++ b/WebCore/ForwardingHeaders/css/css_base.h
@@ -0,0 +1,2 @@
+#include <css_base.h>
+
diff --git a/WebCore/WebCore.pbproj/project.pbxproj b/WebCore/WebCore.pbproj/project.pbxproj
index 2fda5b3..2ab5ab0 100644
--- a/WebCore/WebCore.pbproj/project.pbxproj
+++ b/WebCore/WebCore.pbproj/project.pbxproj
@@ -489,6 +489,8 @@
 				BC7C965303E9EE7000A80004,
 				BC7C965503E9EE7000A80004,
 				BCC60E5903F5055A00A80004,
+				BC8F618D040594BA00A80004,
+				BC8F618E040594BA00A80004,
 			);
 			isa = PBXHeadersBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -499,6 +501,7 @@
 				089C1668FE841158C02AAC07,
 				F5A1B04A02DE8ABA018635CA,
 				F5A1B05402DE8B46018635CA,
+				BC8F629A0405F45600A80004,
 			);
 			isa = PBXResourcesBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -733,6 +736,8 @@
 				BC7C965203E9EE7000A80004,
 				BC7C965403E9EE7000A80004,
 				BCC60E5803F5055A00A80004,
+				BC8F61880405949900A80004,
+				BC8F61890405949900A80004,
 			);
 			isa = PBXSourcesBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -753,6 +758,7 @@
 				089C1666FE841158C02AAC07,
 				F5A1B04902DE8ABA018635CA,
 				F5A1B05302DE8B46018635CA,
+				BC8F62990405F45600A80004,
 			);
 			isa = PBXGroup;
 			name = Resources;
@@ -1530,6 +1536,73 @@
 			settings = {
 			};
 		};
+		BC8F61850405949900A80004 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			path = css_base.cpp;
+			refType = 4;
+		};
+		BC8F61860405949900A80004 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			path = parser.cpp;
+			refType = 4;
+		};
+		BC8F61870405949900A80004 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			path = tokenizer.cpp;
+			refType = 4;
+		};
+		BC8F61880405949900A80004 = {
+			fileRef = BC8F61850405949900A80004;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BC8F61890405949900A80004 = {
+			fileRef = BC8F61860405949900A80004;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BC8F618B040594BA00A80004 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			path = css_base.h;
+			refType = 4;
+		};
+		BC8F618C040594BA00A80004 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			path = parser.h;
+			refType = 4;
+		};
+		BC8F618D040594BA00A80004 = {
+			fileRef = BC8F618B040594BA00A80004;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BC8F618E040594BA00A80004 = {
+			fileRef = BC8F618C040594BA00A80004;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BC8F62990405F45600A80004 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			name = quirks.css;
+			path = khtml/css/quirks.css;
+			refType = 4;
+		};
+		BC8F629A0405F45600A80004 = {
+			fileRef = BC8F62990405F45600A80004;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		BCC60E5603F5055A00A80004 = {
 			fileEncoding = 30;
 			isa = PBXFileReference;
@@ -1970,6 +2043,11 @@
 		};
 		F523D18402DE42E8018635CA = {
 			children = (
+				BC8F61850405949900A80004,
+				BC8F61860405949900A80004,
+				BC8F61870405949900A80004,
+				BC8F618B040594BA00A80004,
+				BC8F618C040594BA00A80004,
 				F523D16402DE42E6018635CA,
 				F523D16502DE42E6018635CA,
 				F523D16602DE42E6018635CA,
diff --git a/WebCore/khtml/css/Makefile.am b/WebCore/khtml/css/Makefile.am
index 3c70612..9ea889e 100644
--- a/WebCore/khtml/css/Makefile.am
+++ b/WebCore/khtml/css/Makefile.am
@@ -1,8 +1,21 @@
 NULL =
 
+YACC=bison
+
+EXTRA_DIST = parser.y
+
+parser: $(srcdir)/parser.y
+	cd $(srcdir); \
+	$(YACC) -d -p cssyy parser.y && mv parser.tab.c parser.cpp; \
+	if test -f parser.tab.h; then \
+	if cmp -s parser.tab.h parser.h; then rm -f parser.tab.h; \
+	else mv parser.tab.h parser.h; fi \
+	else :; fi
+
 noinst_HEADERS = \
 	cssproperties.c \
 	cssvalues.c \
+	parser \
 	$(NULL)
 
 VALUEFILES = \
diff --git a/WebCore/khtml/css/css_base.cpp b/WebCore/khtml/css/css_base.cpp
new file mode 100644
index 0000000..2540a90
--- /dev/null
+++ b/WebCore/khtml/css/css_base.cpp
@@ -0,0 +1,325 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 1999-2003 Lars Knoll (knoll at kde.org)
+ *               1999 Waldo Bastian (bastian at kde.org)
+ *               2001 Andreas Schlapbach (schlpbch at iam.unibe.ch)
+ *               2001-2003 Dirk Mueller (mueller at kde.org)
+ * Copyright (C) 2002 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+//#define CSS_DEBUG
+
+#include "kdebug.h"
+
+#include "css_base.h"
+
+#ifdef CSS_DEBUG
+#include "cssproperties.h"
+#endif
+
+#include "css_stylesheetimpl.h"
+#include "xml/dom_docimpl.h"
+#include "misc/htmlhashes.h"
+#include "css_valueimpl.h"
+using namespace DOM;
+
+void StyleBaseImpl::checkLoaded()
+{
+    if(m_parent) m_parent->checkLoaded();
+}
+
+StyleSheetImpl* StyleBaseImpl::stylesheet()
+{
+    StyleBaseImpl *b = this;
+    while(b && !b->isStyleSheet())
+        b = b->m_parent;
+    return static_cast<StyleSheetImpl *>(b);
+}
+
+DOMString StyleBaseImpl::baseURL()
+{
+    // try to find the style sheet. If found look for its url.
+    // If it has none, look for the parentsheet, or the parentNode and
+    // try to find out about their url
+
+    StyleSheetImpl *sheet = stylesheet();
+
+    if(!sheet) return DOMString();
+
+    if(!sheet->href().isNull())
+        return sheet->href();
+
+    // find parent
+    if(sheet->parent()) return sheet->parent()->baseURL();
+
+    if(!sheet->ownerNode()) return DOMString();
+
+    DocumentImpl *doc = sheet->ownerNode()->getDocument();
+
+    return doc->baseURL();
+}
+
+void StyleBaseImpl::setParsedValue(int propId, const CSSValueImpl *parsedValue,
+				   bool important, bool nonCSSHint, QPtrList<CSSProperty> *propList)
+{
+    QPtrListIterator<CSSProperty> propIt(*propList);
+    propIt.toLast(); // just remove the top one - not sure what should happen if we have multiple instances of the property
+    while (propIt.current() &&
+           ( propIt.current()->m_id != propId || propIt.current()->nonCSSHint != nonCSSHint ||
+             propIt.current()->m_bImportant != important) )
+        --propIt;
+    if (propIt.current())
+        propList->removeRef(propIt.current());
+
+    CSSProperty *prop = new CSSProperty();
+    prop->m_id = propId;
+    prop->setValue((CSSValueImpl *) parsedValue);
+    prop->m_bImportant = important;
+    prop->nonCSSHint = nonCSSHint;
+
+    propList->append(prop);
+#ifdef CSS_DEBUG
+    kdDebug( 6080 ) << "added property: " << getPropertyName(propId).string()
+                    // non implemented yet << ", value: " << parsedValue->cssText().string()
+                    << " important: " << prop->m_bImportant
+                    << " nonCSS: " << prop->nonCSSHint << endl;
+#endif
+}
+
+// ------------------------------------------------------------------------------
+
+StyleListImpl::~StyleListImpl()
+{
+    StyleBaseImpl *n;
+
+    if(!m_lstChildren) return;
+
+    for( n = m_lstChildren->first(); n != 0; n = m_lstChildren->next() )
+    {
+        n->setParent(0);
+        if( !n->refCount() ) delete n;
+    }
+    delete m_lstChildren;
+}
+
+// --------------------------------------------------------------------------------
+
+void CSSSelector::print(void)
+{
+    kdDebug( 6080 ) << "[Selector: tag = " <<       tag << ", attr = \"" << attr << "\", match = \"" << match
+		    << "\" value = \"" << value.string().latin1() << "\" relation = " << (int)relation
+		    << "]" << endl;
+    if ( tagHistory )
+        tagHistory->print();
+    kdDebug( 6080 ) << "    specificity = " << specificity() << endl;
+}
+
+unsigned int CSSSelector::specificity()
+{
+    if ( nonCSSHint )
+        return 0;
+
+    int s = ((tag == -1) ? 0 : 1);
+    switch(match)
+    {
+    case Id:
+	s += 0x10000;
+	break;
+    case Exact:
+    case Set:
+    case List:
+    case Hyphen:
+    case Pseudo:
+    case Contain:
+    case Begin:
+    case End:
+        s += 0x100;
+    case None:
+        break;
+    }
+    if(tagHistory)
+        s += tagHistory->specificity();
+    // make sure it doesn't overflow
+    return s & 0xffffff;
+}
+
+void CSSSelector::extractPseudoType() const
+{
+    if (match != Pseudo)
+        return;
+    _pseudoType = PseudoOther;
+    if (!value.isEmpty()) {
+        switch (value[0]) {
+            case 'a':
+                if (value == "active")
+                    _pseudoType = PseudoActive;
+                else if (value == "after")
+                    _pseudoType = PseudoAfter;
+                break;
+            case 'b':
+                if (value == "before")
+                    _pseudoType = PseudoBefore;
+                break;
+            case 'e':
+                if (value == "empty")
+                    _pseudoType = PseudoEmpty;
+                break;
+            case 'f':
+                if (value == "first-child")
+                    _pseudoType = PseudoFirstChild;
+                else if (value == "first-letter")
+                    _pseudoType = PseudoFirstLetter;
+                else if (value == "first-line")
+                    _pseudoType = PseudoFirstLine;
+                else if (value == "focus")
+                    _pseudoType = PseudoFocus;
+                break;
+            case 'h':
+                if (value == "hover")
+                    _pseudoType = PseudoHover;
+                break;
+            case 'l':
+                if (value == "link")
+                    _pseudoType = PseudoLink;
+                break;
+            case 't':
+                if (value == "target")
+                    _pseudoType = PseudoTarget;
+                break;
+            case 'v':
+                if (value == "visited")
+                    _pseudoType = PseudoVisited;
+                break;
+        }
+    }
+
+    value = QString::null;
+}
+
+
+bool CSSSelector::operator == ( const CSSSelector &other )
+{
+    const CSSSelector *sel1 = this;
+    const CSSSelector *sel2 = &other;
+
+    while ( sel1 && sel2 ) {
+	if ( sel1->tag != sel2->tag || sel1->attr != sel2->attr ||
+	     sel1->relation != sel2->relation || sel1->match != sel2->match ||
+	     sel1->nonCSSHint != sel2->nonCSSHint ||
+	     sel1->value != sel2->value ||
+             sel1->pseudoType() != sel2->pseudoType())
+	    return false;
+	sel1 = sel1->tagHistory;
+	sel2 = sel2->tagHistory;
+    }
+    if ( sel1 || sel2 )
+	return false;
+    return true;
+}
+
+DOMString CSSSelector::selectorText() const
+{
+    DOMString str;
+    const CSSSelector* cs = this;
+    if ( cs->tag == -1 && cs->attr == ATTR_ID && cs->match == CSSSelector::Exact )
+    {
+        str = "#";
+        str += cs->value;
+    }
+    else if ( cs->tag == -1 && cs->attr == ATTR_CLASS && cs->match == CSSSelector::List )
+    {
+        str = ".";
+        str += cs->value;
+    }
+    else if ( cs->tag == -1 && cs->match == CSSSelector::Pseudo )
+    {
+        str = ":";
+        str += cs->value;
+    }
+    else
+    {
+        if ( cs->tag == -1 )
+            str = "*";
+        else
+            str = getTagName( cs->tag );
+        if ( cs->attr == ATTR_ID && cs->match == CSSSelector::Exact )
+        {
+            str += "#";
+            str += cs->value;
+        }
+        else if ( cs->attr == ATTR_CLASS && cs->match == CSSSelector::List )
+        {
+            str += ".";
+            str += cs->value;
+        }
+        else if ( cs->match == CSSSelector::Pseudo )
+        {
+            str += ":";
+            str += cs->value;
+        }
+        // optional attribute
+        if ( cs->attr ) {
+            DOMString attrName = getAttrName( cs->attr );
+            str += "[";
+            str += attrName;
+            switch (cs->match) {
+            case CSSSelector::Exact:
+                str += "=";
+                break;
+            case CSSSelector::Set:
+                str += " "; /// ## correct?
+                       break;
+            case CSSSelector::List:
+                str += "~=";
+                break;
+            case CSSSelector::Hyphen:
+                str += "|=";
+                break;
+            case CSSSelector::Begin:
+                str += "^=";
+                break;
+            case CSSSelector::End:
+                str += "$=";
+                break;
+            case CSSSelector::Contain:
+                str += "*=";
+                break;
+            default:
+                kdWarning(6080) << "Unhandled case in CSSStyleRuleImpl::selectorText : match=" << cs->match << endl;
+            }
+            str += "\"";
+            str += cs->value;
+            str += "\"]";
+        }
+    }
+    if ( cs->tagHistory ) {
+        DOMString tagHistoryText = cs->tagHistory->selectorText();
+        if ( cs->relation == Sibling )
+            str = tagHistoryText + " + " + str;
+        else if ( cs->relation == Child )
+            str = tagHistoryText + " > " + str;
+        else if ( cs->relation == SubSelector )
+            str += tagHistoryText; // the ":" is provided by selectorText()
+        else // Descendant
+            str = tagHistoryText + " " + str;
+    }
+    return str;
+}
+
+// ----------------------------------------------------------------------------
diff --git a/WebCore/khtml/css/css_base.h b/WebCore/khtml/css/css_base.h
new file mode 100644
index 0000000..c95ed1a
--- /dev/null
+++ b/WebCore/khtml/css/css_base.h
@@ -0,0 +1,219 @@
+/*
+ * This file is part of the CSS implementation for KDE.
+ *
+ * Copyright (C) 1999-2003 Lars Knoll (knoll at kde.org)
+ *               1999 Waldo Bastian (bastian at kde.org)
+ * Copyright (C) 2002 Apple Computer, Inc.
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ *
+ * $Id$
+ */
+#ifndef _CSS_BASE_H
+#define _CSS_BASE_H
+
+#include "dom/dom_string.h"
+#include "dom/dom_misc.h"
+#include "misc/shared.h"
+#include <qdatetime.h>
+#include <qptrlist.h>
+
+namespace DOM {
+
+    class StyleSheetImpl;
+    class MediaList;
+
+    class CSSSelector;
+    class CSSProperty;
+    class CSSValueImpl;
+    class CSSPrimitiveValueImpl;
+    class CSSStyleDeclarationImpl;
+    class CSSRuleImpl;
+    class CSSStyleRuleImpl;
+
+    class DocumentImpl;
+
+// this class represents a selector for a StyleRule
+    class CSSSelector
+    {
+    public:
+	CSSSelector()
+	    : tagHistory(0), attr(0), tag(-1), relation( Descendant ),
+	      match( None ), nonCSSHint( false ), pseudoId( 0 ), _pseudoType(PseudoNotParsed) {}
+
+	~CSSSelector() {
+	    delete tagHistory;
+	}
+
+	/**
+	 * Print debug output for this selector
+	 */
+	void print();
+
+	/**
+	 * Re-create selector text from selector's data
+	 */
+	DOMString selectorText() const;
+
+	// checks if the 2 selectors (including sub selectors) agree.
+	bool operator == ( const CSSSelector &other );
+
+	// tag == -1 means apply to all elements (Selector = *)
+
+	unsigned int specificity();
+
+	/* how the attribute value has to match.... Default is Exact */
+	enum Match
+	{
+	    None = 0,
+	    Id,
+	    Exact,
+	    Set,
+	    List,
+	    Hyphen,
+	    Pseudo,
+	    Contain,   // css3: E[foo*="bar"]
+	    Begin,     // css3: E[foo^="bar"]
+	    End        // css3: E[foo$="bar"]
+	};
+
+	enum Relation
+	{
+	    Descendant = 0,
+	    Child,
+	    Sibling,
+	    SubSelector
+	};
+
+	enum PseudoType
+	{
+	    PseudoNotParsed = 0,
+	    PseudoOther,
+	    PseudoEmpty,
+	    PseudoFirstChild,
+	    PseudoFirstLine,
+	    PseudoFirstLetter,
+	    PseudoLink,
+	    PseudoVisited,
+	    PseudoHover,
+	    PseudoFocus,
+	    PseudoActive,
+            PseudoTarget,
+	    PseudoBefore,
+	    PseudoAfter,
+	    PseudoFunction
+	};
+
+	inline PseudoType pseudoType() const
+	    {
+		if (_pseudoType == PseudoNotParsed)
+		    extractPseudoType();
+		return _pseudoType;
+	    }
+
+	mutable DOM::DOMString value;
+	CSSSelector *tagHistory;
+	int          attr;
+	int          tag;
+
+	Relation relation     : 2;
+	Match 	 match         : 4;
+	bool	nonCSSHint : 1;
+	unsigned int pseudoId : 3;
+	mutable PseudoType _pseudoType : 4;
+
+    private:
+	void extractPseudoType() const;
+    };
+
+    // a style class which has a parent (almost all have)
+    class StyleBaseImpl : public khtml::TreeShared<StyleBaseImpl>
+    {
+    public:
+	StyleBaseImpl()  { m_parent = 0; hasInlinedDecl = false; strictParsing = true; multiLength = false; }
+	StyleBaseImpl(StyleBaseImpl *p) {
+	    m_parent = p; hasInlinedDecl = false;
+	    strictParsing = (m_parent ? m_parent->useStrictParsing() : true);
+	    multiLength = false;
+	}
+
+	virtual ~StyleBaseImpl() {}
+
+	// returns the url of the style sheet this object belongs to
+	DOMString baseURL();
+
+	virtual bool isStyleSheet() const { return false; }
+	virtual bool isCSSStyleSheet() const { return false; }
+	virtual bool isStyleSheetList() const { return false; }
+	virtual bool isMediaList() { return false; }
+	virtual bool isRuleList() { return false; }
+	virtual bool isRule() { return false; }
+	virtual bool isStyleRule() { return false; }
+	virtual bool isCharetRule() { return false; }
+	virtual bool isImportRule() { return false; }
+	virtual bool isMediaRule() { return false; }
+	virtual bool isFontFaceRule() { return false; }
+	virtual bool isPageRule() { return false; }
+	virtual bool isUnknownRule() { return false; }
+	virtual bool isStyleDeclaration() { return false; }
+	virtual bool isValue() { return false; }
+	virtual bool isPrimitiveValue() const { return false; }
+	virtual bool isValueList() { return false; }
+	virtual bool isValueCustom() { return false; }
+
+	void setParent(StyleBaseImpl *parent) { m_parent = parent; }
+
+	static void setParsedValue(int propId, const CSSValueImpl *parsedValue,
+				   bool important, bool nonCSSHint, QPtrList<CSSProperty> *propList);
+
+	virtual bool parseString(const DOMString &/*cssString*/, bool = false) { return false; }
+
+	virtual void checkLoaded();
+
+	void setStrictParsing( bool b ) { strictParsing = b; }
+	bool useStrictParsing() const { return strictParsing; }
+
+	StyleSheetImpl* stylesheet();
+
+    protected:
+	bool hasInlinedDecl : 1;
+	bool strictParsing : 1;
+	bool multiLength : 1;
+    };
+
+    // a style class which has a list of children (StyleSheets for example)
+    class StyleListImpl : public StyleBaseImpl
+    {
+    public:
+	StyleListImpl() : StyleBaseImpl() { m_lstChildren = 0; }
+	StyleListImpl(StyleBaseImpl *parent) : StyleBaseImpl(parent) { m_lstChildren = 0; }
+
+	virtual ~StyleListImpl();
+
+	unsigned long length() { return m_lstChildren->count(); }
+	StyleBaseImpl *item(unsigned long num) { return m_lstChildren->at(num); }
+
+	void append(StyleBaseImpl *item) { m_lstChildren->append(item); }
+
+    protected:
+	QPtrList<StyleBaseImpl> *m_lstChildren;
+    };
+
+    int getPropertyID(const char *tagStr, int len);
+
+}
+
+#endif
diff --git a/WebCore/khtml/css/css_ruleimpl.cpp b/WebCore/khtml/css/css_ruleimpl.cpp
index 9c51f47..d8031df 100644
--- a/WebCore/khtml/css/css_ruleimpl.cpp
+++ b/WebCore/khtml/css/css_ruleimpl.cpp
@@ -1,8 +1,9 @@
 /**
  * This file is part of the DOM implementation for KDE.
  *
- * (C) 1999 Lars Knoll (knoll at kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * (C) 1999-2003 Lars Knoll (knoll at kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller at kde.org)
+ * Copyright (C) 2002 Apple Computer, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -38,21 +39,6 @@ using namespace DOM;
 
 #include <kdebug.h>
 
-CSSRuleImpl::CSSRuleImpl(StyleBaseImpl *parent)
-    : StyleBaseImpl(parent)
-{
-    m_type = CSSRule::UNKNOWN_RULE;
-}
-
-CSSRuleImpl::~CSSRuleImpl()
-{
-}
-
-unsigned short CSSRuleImpl::type() const
-{
-    return m_type;
-}
-
 CSSStyleSheetImpl *CSSRuleImpl::parentStyleSheet() const
 {
     return ( m_parent && m_parent->isCSSStyleSheet() )  ?
@@ -61,7 +47,7 @@ CSSStyleSheetImpl *CSSRuleImpl::parentStyleSheet() const
 
 CSSRuleImpl *CSSRuleImpl::parentRule() const
 {
-    return ( m_parent && m_parent->isRule() )  ? 
+    return ( m_parent && m_parent->isRule() )  ?
 	static_cast<CSSRuleImpl *>(m_parent) : 0;
 }
 
@@ -78,18 +64,6 @@ void CSSRuleImpl::setCssText(DOM::DOMString /*str*/)
 
 // ---------------------------------------------------------------------------
 
-CSSCharsetRuleImpl::CSSCharsetRuleImpl(StyleBaseImpl *parent)
-    : CSSRuleImpl(parent), m_encoding()
-{
-    m_type = CSSRule::CHARSET_RULE;
-}
-
-CSSCharsetRuleImpl::~CSSCharsetRuleImpl()
-{
-}
-
-// ---------------------------------------------------------------------------
-
 CSSFontFaceRuleImpl::CSSFontFaceRuleImpl(StyleBaseImpl *parent)
     : CSSRuleImpl(parent)
 {
@@ -102,13 +76,28 @@ CSSFontFaceRuleImpl::~CSSFontFaceRuleImpl()
     if(m_style) m_style->deref();
 }
 
-CSSStyleDeclarationImpl *CSSFontFaceRuleImpl::style() const
+// --------------------------------------------------------------------------
+
+CSSImportRuleImpl::CSSImportRuleImpl( StyleBaseImpl *parent,
+                                      const DOM::DOMString &href,
+                                      MediaListImpl *media )
+    : CSSRuleImpl(parent)
 {
-    return m_style;
-}
+    m_type = CSSRule::IMPORT_RULE;
 
-// --------------------------------------------------------------------------
+    m_lstMedia = media;
+    if ( !m_lstMedia )
+	m_lstMedia = new MediaListImpl( this, DOMString() );
+    m_lstMedia->setParent( this );
+    m_lstMedia->ref();
+
+    m_strHref = href;
+    m_styleSheet = 0;
 
+    m_cachedSheet = 0;
+
+    init();
+}
 CSSImportRuleImpl::CSSImportRuleImpl( StyleBaseImpl *parent,
                                       const DOM::DOMString &href,
                                       const DOM::DOMString &media )
@@ -130,33 +119,23 @@ CSSImportRuleImpl::CSSImportRuleImpl( StyleBaseImpl *parent,
 CSSImportRuleImpl::~CSSImportRuleImpl()
 {
     if( m_lstMedia ) {
-	m_lstMedia->setParent( 0 );
-        m_lstMedia->deref();
+ 	m_lstMedia->setParent( 0 );
+	m_lstMedia->deref();
+    }
+    if(m_styleSheet) {
+        m_styleSheet->setParent(0);
+        m_styleSheet->deref();
     }
-    if(m_styleSheet) m_styleSheet->deref();
-    if(m_cachedSheet) m_cachedSheet->deref(this);
-}
-
-DOMString CSSImportRuleImpl::href() const
-{
-    return m_strHref;
-}
-
-MediaListImpl *CSSImportRuleImpl::media() const
-{
-    return m_lstMedia;
-}
 
-CSSStyleSheetImpl *CSSImportRuleImpl::styleSheet() const
-{
-    return m_styleSheet;
+    if(m_cachedSheet) m_cachedSheet->deref(this);
 }
 
 void CSSImportRuleImpl::setStyleSheet(const DOM::DOMString &url, const DOM::DOMString &sheet)
 {
-    kdDebug( 6080 ) << "CSSImportRule::setStyleSheet()" << endl;
-
-    if ( m_styleSheet ) m_styleSheet->deref();
+    if ( m_styleSheet ) {
+        m_styleSheet->setParent(0);
+        m_styleSheet->deref();
+    }
     m_styleSheet = new CSSStyleSheetImpl(this, url);
     m_styleSheet->ref();
 
@@ -195,93 +174,33 @@ void CSSImportRuleImpl::init()
       absHref = KURL(doc->URL(),m_strHref.string()).url();
     }
 */
-    kdDebug( 6080 ) << "CSSImportRule: requesting sheet " << m_strHref.string() << endl;
-    kdDebug( 6080 ) << "CSSImportRule: requesting absolute url " << absHref.string() << endl;
-
-    // we must have a docLoader !
     // ### pass correct charset here!!
     m_cachedSheet = docLoader->requestStyleSheet(absHref, QString::null);
 
     if (m_cachedSheet)
     {
       m_cachedSheet->ref(this);
-      
+
       // If the imported sheet is in the cache, then setStyleSheet gets called,
       // and the sheet even gets parsed (via parseString).  In this case we have
       // loaded (even if our subresources haven't), so if we have stylesheet after
       // checking the cache, then we've clearly loaded. -dwh
       if (!m_styleSheet)
-          m_loading = true;
+      m_loading = true;
     }
 }
 
 // --------------------------------------------------------------------------
-
-
-CSSQuirksRuleImpl::CSSQuirksRuleImpl(StyleBaseImpl *parent)
+CSSMediaRuleImpl::CSSMediaRuleImpl( StyleBaseImpl *parent, MediaListImpl *mediaList, CSSRuleListImpl *ruleList )
     :   CSSRuleImpl( parent )
 {
-    m_type = CSSRule::QUIRKS_RULE;
-    m_lstCSSRules = new CSSRuleListImpl();
-    m_lstCSSRules->ref();
-}
-
-CSSQuirksRuleImpl::CSSQuirksRuleImpl( StyleBaseImpl *parent, const QChar *&curP,
-                                      const QChar *endP )
-:   CSSRuleImpl( parent )
-{
-    m_type = CSSRule::QUIRKS_RULE;
-    m_lstCSSRules = new CSSRuleListImpl();
+    m_type = CSSRule::MEDIA_RULE;
+    m_lstMedia = mediaList;
+    m_lstMedia->ref();
+    m_lstCSSRules = ruleList;
     m_lstCSSRules->ref();
-
-    // Parse CSS data
-    while( curP < endP )
-    {
-//         kdDebug( 6080 ) << "Style rule: '" << QString( curP, endP - curP )
-//                         << "'" << endl;
-        CSSRuleImpl *rule = parseStyleRule( curP, endP );
-        if ( rule ) {
-            rule->ref();
-            appendRule( rule );
-        }
-        if (!curP) break;
-        while( curP < endP && *curP == QChar( ' ' ) )
-            curP++;
-    }
-}
-
-CSSQuirksRuleImpl::~CSSQuirksRuleImpl()
-{
-    m_lstCSSRules->deref();
 }
 
-CSSRuleListImpl *CSSQuirksRuleImpl::cssRules()
-{
-    return m_lstCSSRules;
-}
-
-unsigned long CSSQuirksRuleImpl::appendRule( CSSRuleImpl *rule )
-{
-    return rule ? m_lstCSSRules->insertRule( rule, m_lstCSSRules->length() ) : 0;
-}
-
-unsigned long CSSQuirksRuleImpl::insertRule( const DOMString &rule,
-                                            unsigned long index )
-{
-    const QChar *curP = rule.unicode();
-    CSSRuleImpl *newRule = parseRule( curP, curP + rule.length() );
-
-    return newRule ? m_lstCSSRules->insertRule( newRule, index ) : 0;
-}
-
-void CSSQuirksRuleImpl::deleteRule( unsigned long index )
-{
-    m_lstCSSRules->deleteRule( index );
-}
-
-// --------------------------------------------------------------------------
-
-
 CSSMediaRuleImpl::CSSMediaRuleImpl(StyleBaseImpl *parent)
     :   CSSRuleImpl( parent )
 {
@@ -291,8 +210,7 @@ CSSMediaRuleImpl::CSSMediaRuleImpl(StyleBaseImpl *parent)
     m_lstCSSRules->ref();
 }
 
-CSSMediaRuleImpl::CSSMediaRuleImpl( StyleBaseImpl *parent, const QChar *&curP,
-                              const QChar *endP, const DOM::DOMString &media )
+CSSMediaRuleImpl::CSSMediaRuleImpl( StyleBaseImpl *parent, const DOM::DOMString &media )
 :   CSSRuleImpl( parent )
 {
     m_type = CSSRule::MEDIA_RULE;
@@ -300,21 +218,6 @@ CSSMediaRuleImpl::CSSMediaRuleImpl( StyleBaseImpl *parent, const QChar *&curP,
     m_lstMedia->ref();
     m_lstCSSRules = new CSSRuleListImpl();
     m_lstCSSRules->ref();
-
-    // Parse CSS data
-    while( curP < endP )
-    {
-//         kdDebug( 6080 ) << "Style rule: '" << QString( curP, endP - curP )
-//                         << "'" << endl;
-        CSSRuleImpl *rule = parseStyleRule( curP, endP );
-        if ( rule ) {
-            rule->ref();
-            appendRule( rule );
-        }
-        if (!curP) break;
-        while( curP < endP && *curP == QChar( ' ' ) )
-            curP++;
-    }
 }
 
 CSSMediaRuleImpl::~CSSMediaRuleImpl()
@@ -326,17 +229,7 @@ CSSMediaRuleImpl::~CSSMediaRuleImpl()
     m_lstCSSRules->deref();
 }
 
-MediaListImpl *CSSMediaRuleImpl::media() const
-{
-    return m_lstMedia;
-}
-
-CSSRuleListImpl *CSSMediaRuleImpl::cssRules()
-{
-    return m_lstCSSRules;
-}
-
-unsigned long CSSMediaRuleImpl::appendRule( CSSRuleImpl *rule )
+unsigned long CSSMediaRuleImpl::append( CSSRuleImpl *rule )
 {
     return rule ? m_lstCSSRules->insertRule( rule, m_lstCSSRules->length() ) : 0;
 }
@@ -344,17 +237,12 @@ unsigned long CSSMediaRuleImpl::appendRule( CSSRuleImpl *rule )
 unsigned long CSSMediaRuleImpl::insertRule( const DOMString &rule,
                                             unsigned long index )
 {
-    const QChar *curP = rule.unicode();
-    CSSRuleImpl *newRule = parseRule( curP, curP + rule.length() );
+    CSSParser p( strictParsing );
+    CSSRuleImpl *newRule = p.parseRule( rule );
 
     return newRule ? m_lstCSSRules->insertRule( newRule, index ) : 0;
 }
 
-void CSSMediaRuleImpl::deleteRule( unsigned long index )
-{
-    m_lstCSSRules->deleteRule( index );
-}
-
 CSSRuleListImpl::~CSSRuleListImpl()
 {
     CSSRuleImpl* rule;
@@ -376,11 +264,6 @@ CSSPageRuleImpl::~CSSPageRuleImpl()
     if(m_style) m_style->deref();
 }
 
-CSSStyleDeclarationImpl *CSSPageRuleImpl::style() const
-{
-    return m_style;
-}
-
 DOM::DOMString CSSPageRuleImpl::selectorText() const
 {
     // ###
@@ -411,11 +294,6 @@ CSSStyleRuleImpl::~CSSStyleRuleImpl()
     delete m_selector;
 }
 
-CSSStyleDeclarationImpl *CSSStyleRuleImpl::style() const
-{
-    return m_style;
-}
-
 DOM::DOMString CSSStyleRuleImpl::selectorText() const
 {
     if ( m_selector && m_selector->first() ) {
@@ -438,17 +316,12 @@ bool CSSStyleRuleImpl::parseString( const DOMString &/*string*/, bool )
     return false;
 }
 
-void CSSStyleRuleImpl::setSelector( QPtrList<CSSSelector> *selector)
-{
-    m_selector = selector;
-}
-
 void CSSStyleRuleImpl::setDeclaration( CSSStyleDeclarationImpl *style)
 {
     if ( m_style != style ) {
-    if(m_style) m_style->deref();
-    m_style = style;
-    if(m_style) m_style->ref();
+        if(m_style) m_style->deref();
+        m_style = style;
+        if(m_style) m_style->ref();
     }
 }
 
@@ -461,34 +334,6 @@ void CSSStyleRuleImpl::setNonCSSHints()
     }
 }
 
-
-// --------------------------------------------------------------------------
-
-CSSUnknownRuleImpl::CSSUnknownRuleImpl(StyleBaseImpl *parent)
-    : CSSRuleImpl(parent)
-{
-}
-
-CSSUnknownRuleImpl::~CSSUnknownRuleImpl()
-{
-}
-
-// --------------------------------------------------------------------------
-
-CSSRuleListImpl::CSSRuleListImpl()
-{
-}
-
-unsigned long CSSRuleListImpl::length() const
-{
-    return m_lstCSSRules.count();
-}
-
-CSSRuleImpl *CSSRuleListImpl::item ( unsigned long index )
-{
-    return m_lstCSSRules.at( index );
-}
-
 void CSSRuleListImpl::deleteRule ( unsigned long index )
 {
     CSSRuleImpl *rule = m_lstCSSRules.take( index );
diff --git a/WebCore/khtml/css/css_ruleimpl.h b/WebCore/khtml/css/css_ruleimpl.h
index da22170..eacd8af 100644
--- a/WebCore/khtml/css/css_ruleimpl.h
+++ b/WebCore/khtml/css/css_ruleimpl.h
@@ -1,8 +1,9 @@
 /*
  * This file is part of the DOM implementation for KDE.
  *
- * (C) 1999 Lars Knoll (knoll at kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * (C) 1999-2003 Lars Knoll (knoll at kde.org)
+ * (C) 2002-2003 Dirk Mueller (mueller at kde.org)
+ * Copyright (C) 2002 Apple Computer, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -19,19 +20,20 @@
  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  *
+ * $Id$
  */
 #ifndef _CSS_css_ruleimpl_h_
 #define _CSS_css_ruleimpl_h_
 
 #include "dom/dom_string.h"
 #include "dom/css_rule.h"
-#include "css/cssparser.h"
+#include "css/css_base.h"
 #include "misc/loader_client.h"
 #include "misc/shared.h"
 
 namespace khtml {
     class CachedCSSStyleSheet;
-};
+}
 
 namespace DOM {
 
@@ -44,13 +46,12 @@ class MediaListImpl;
 class CSSRuleImpl : public StyleBaseImpl
 {
 public:
-    CSSRuleImpl(StyleBaseImpl *parent);
-
-    virtual ~CSSRuleImpl();
+    CSSRuleImpl(StyleBaseImpl *parent)
+        : StyleBaseImpl(parent), m_type(CSSRule::UNKNOWN_RULE) {}
 
     virtual bool isRule() { return true; }
+    unsigned short type() const { return m_type; }
 
-    unsigned short type() const;
     CSSStyleSheetImpl *parentStyleSheet() const;
     CSSRuleImpl *parentRule() const;
 
@@ -66,9 +67,8 @@ protected:
 class CSSCharsetRuleImpl : public CSSRuleImpl
 {
 public:
-    CSSCharsetRuleImpl(StyleBaseImpl *parent);
-
-    virtual ~CSSCharsetRuleImpl();
+    CSSCharsetRuleImpl(StyleBaseImpl *parent)
+        : CSSRuleImpl(parent) { m_type = CSSRule::CHARSET_RULE; }
 
     virtual bool isCharsetRule() { return true; }
 
@@ -87,7 +87,7 @@ public:
 
     virtual ~CSSFontFaceRuleImpl();
 
-    CSSStyleDeclarationImpl *style() const;
+    CSSStyleDeclarationImpl *style() const { return m_style; }
 
     virtual bool isFontFaceRule() { return true; }
 
@@ -101,12 +101,14 @@ class CSSImportRuleImpl : public khtml::CachedObjectClient, public CSSRuleImpl
 public:
     CSSImportRuleImpl( StyleBaseImpl *parent, const DOM::DOMString &href,
                        const DOM::DOMString &media );
+    CSSImportRuleImpl( StyleBaseImpl *parent, const DOM::DOMString &href,
+                       MediaListImpl *media );
 
     virtual ~CSSImportRuleImpl();
 
-    DOM::DOMString href() const;
-    MediaListImpl *media() const;
-    CSSStyleSheetImpl *styleSheet() const;
+    DOM::DOMString href() const { return m_strHref; }
+    MediaListImpl *media() const { return m_lstMedia; }
+    CSSStyleSheetImpl *styleSheet() const { return m_styleSheet; }
 
     virtual bool isImportRule() { return true; }
 
@@ -124,53 +126,50 @@ protected:
     bool m_loading;
 };
 
-class CSSRuleList;
+class MediaList;
 
-class CSSQuirksRuleImpl : public CSSRuleImpl
+class CSSRuleListImpl : public khtml::Shared<CSSRuleListImpl>
 {
 public:
-    CSSQuirksRuleImpl( StyleBaseImpl *parent );
-    CSSQuirksRuleImpl( StyleBaseImpl *parent, const QChar *&curP,
-                      const QChar * endP );
+    CSSRuleListImpl() {}
 
-    virtual ~CSSQuirksRuleImpl();
+    ~CSSRuleListImpl();
 
-    CSSRuleListImpl *cssRules();
-    unsigned long insertRule ( const DOM::DOMString &rule, unsigned long index );
+    unsigned long length() const { return m_lstCSSRules.count(); }
+    CSSRuleImpl *item ( unsigned long index ) { return m_lstCSSRules.at( index ); }
+
+
+    /* not part of the DOM */
+    unsigned long insertRule ( CSSRuleImpl *rule, unsigned long index );
     void deleteRule ( unsigned long index );
 
-    virtual bool isQuirksRule() { return true; }
-    
+    void append( CSSRuleImpl *rule ) { m_lstCSSRules.append( rule ); }
 protected:
-    CSSRuleListImpl *m_lstCSSRules;
-
-    /* Not part of the DOM */
-    unsigned long appendRule( CSSRuleImpl *rule );
+    QPtrList<CSSRuleImpl> m_lstCSSRules;
 };
 
-class MediaList;
-
 class CSSMediaRuleImpl : public CSSRuleImpl
 {
 public:
     CSSMediaRuleImpl( StyleBaseImpl *parent );
-    CSSMediaRuleImpl( StyleBaseImpl *parent, const QChar *&curP,
-                      const QChar * endP, const DOM::DOMString &media );
+    CSSMediaRuleImpl( StyleBaseImpl *parent, const DOM::DOMString &media );
+    CSSMediaRuleImpl( StyleBaseImpl *parent, MediaListImpl *mediaList, CSSRuleListImpl *ruleList );
 
     virtual ~CSSMediaRuleImpl();
 
-    MediaListImpl *media() const;
-    CSSRuleListImpl *cssRules();
+    MediaListImpl *media() const { return m_lstMedia; }
+    CSSRuleListImpl *cssRules() { return m_lstCSSRules; }
+
     unsigned long insertRule ( const DOM::DOMString &rule, unsigned long index );
-    void deleteRule ( unsigned long index );
+    void deleteRule ( unsigned long index ) { m_lstCSSRules->deleteRule( index ); }
 
     virtual bool isMediaRule() { return true; }
+
+    /* Not part of the DOM */
+    unsigned long append( CSSRuleImpl *rule );
 protected:
     MediaListImpl *m_lstMedia;
     CSSRuleListImpl *m_lstCSSRules;
-
-    /* Not part of the DOM */
-    unsigned long appendRule( CSSRuleImpl *rule );
 };
 
 
@@ -181,7 +180,7 @@ public:
 
     virtual ~CSSPageRuleImpl();
 
-    CSSStyleDeclarationImpl *style() const;
+    CSSStyleDeclarationImpl *style() const { return m_style; }
 
     virtual bool isPageRule() { return true; }
 
@@ -200,7 +199,7 @@ public:
 
     virtual ~CSSStyleRuleImpl();
 
-    CSSStyleDeclarationImpl *style() const;
+    CSSStyleDeclarationImpl *style() const { return m_style; }
 
     virtual bool isStyleRule() { return true; }
 
@@ -209,7 +208,7 @@ public:
 
     virtual bool parseString( const DOMString &string, bool = false );
 
-    void setSelector( QPtrList<CSSSelector> *selector);
+    void setSelector( QPtrList<CSSSelector> *selector) { m_selector = selector; }
     void setDeclaration( CSSStyleDeclarationImpl *style);
 
     QPtrList<CSSSelector> *selector() { return m_selector; }
@@ -223,35 +222,15 @@ protected:
 };
 
 
-
 class CSSUnknownRuleImpl : public CSSRuleImpl
 {
 public:
-    CSSUnknownRuleImpl(StyleBaseImpl *parent);
-
-    ~CSSUnknownRuleImpl();
+    CSSUnknownRuleImpl(StyleBaseImpl *parent) : CSSRuleImpl(parent) {}
 
     virtual bool isUnknownRule() { return true; }
 };
 
 
-class CSSRuleListImpl : public khtml::Shared<CSSRuleListImpl>
-{
-public:
-    CSSRuleListImpl();
-    ~CSSRuleListImpl();
-
-    unsigned long length() const;
-    CSSRuleImpl *item ( unsigned long index );
-
-    /* not part of the DOM */
-    unsigned long insertRule ( CSSRuleImpl *rule, unsigned long index );
-    void deleteRule ( unsigned long index );
-
-protected:
-    QPtrList<CSSRuleImpl> m_lstCSSRules;
-};
-
-}; // namespace
+} // namespace
 
 #endif
diff --git a/WebCore/khtml/css/css_stylesheetimpl.cpp b/WebCore/khtml/css/css_stylesheetimpl.cpp
index 0054f6e..be2506d 100644
--- a/WebCore/khtml/css/css_stylesheetimpl.cpp
+++ b/WebCore/khtml/css/css_stylesheetimpl.cpp
@@ -1,7 +1,7 @@
 /**
  * This file is part of the DOM implementation for KDE.
  *
- * (C) 1999 Lars Knoll (knoll at kde.org)
+ * (C) 1999-2003 Lars Knoll (knoll at kde.org)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -18,6 +18,7 @@
  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  *
+ * $Id$
  */
 
 //#define CSS_STYLESHEET_DEBUG
@@ -78,21 +79,6 @@ StyleSheetImpl::~StyleSheetImpl()
     }
 }
 
-bool StyleSheetImpl::disabled() const
-{
-    return m_disabled;
-}
-
-void StyleSheetImpl::setDisabled( bool disabled )
-{
-    m_disabled = disabled;
-}
-
-NodeImpl *StyleSheetImpl::ownerNode() const
-{
-    return m_parentNode;
-}
-
 StyleSheetImpl *StyleSheetImpl::parentStyleSheet() const
 {
     if( !m_parent ) return 0;
@@ -100,21 +86,6 @@ StyleSheetImpl *StyleSheetImpl::parentStyleSheet() const
     return 0;
 }
 
-DOMString StyleSheetImpl::href() const
-{
-    return m_strHref;
-}
-
-DOMString StyleSheetImpl::title() const
-{
-    return m_strTitle;
-}
-
-MediaListImpl *StyleSheetImpl::media() const
-{
-    return m_media;
-}
-
 void StyleSheetImpl::setMedia( MediaListImpl *media )
 {
     if( media )
@@ -168,6 +139,7 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(DOM::NodeImpl *parentNode, CSSStyleSheetImp
 CSSStyleSheetImpl::CSSStyleSheetImpl(CSSRuleImpl *ownerRule, CSSStyleSheetImpl *orig)
     : StyleSheetImpl(ownerRule, orig->m_strHref)
 {
+    // m_lstChildren is deleted in StyleListImpl
     m_lstChildren = new QPtrList<StyleBaseImpl>;
     StyleBaseImpl *rule;
     for ( rule = orig->m_lstChildren->first(); rule != 0; rule = orig->m_lstChildren->next() )
@@ -179,11 +151,6 @@ CSSStyleSheetImpl::CSSStyleSheetImpl(CSSRuleImpl *ownerRule, CSSStyleSheetImpl *
     m_implicit = false;
 }
 
-CSSStyleSheetImpl::~CSSStyleSheetImpl()
-{
-    // m_lstChildren is deleted in StyleListImpl
-}
-
 CSSRuleImpl *CSSStyleSheetImpl::ownerRule() const
 {
     if( !m_parent ) return 0;
@@ -191,11 +158,6 @@ CSSRuleImpl *CSSStyleSheetImpl::ownerRule() const
     return 0;
 }
 
-CSSRuleList CSSStyleSheetImpl::cssRules()
-{
-    return this;
-}
-
 unsigned long CSSStyleSheetImpl::insertRule( const DOMString &rule, unsigned long index, int &exceptioncode )
 {
     exceptioncode = 0;
@@ -203,10 +165,8 @@ unsigned long CSSStyleSheetImpl::insertRule( const DOMString &rule, unsigned lon
         exceptioncode = DOMException::INDEX_SIZE_ERR;
         return 0;
     }
-    const QString preprocessed = preprocess(rule.string());
-    const QChar *curP = preprocessed.unicode();
-    const QChar *endP = preprocessed.unicode() + preprocessed.length();
-    CSSRuleImpl *r = parseRule(curP, endP);
+    CSSParser p( strictParsing );
+    CSSRuleImpl *r = p.parseRule( rule );
 
     if(!r) {
         exceptioncode = CSSException::SYNTAX_ERR + CSSException::_EXCEPTION_OFFSET;
@@ -219,6 +179,11 @@ unsigned long CSSStyleSheetImpl::insertRule( const DOMString &rule, unsigned lon
     return index;
 }
 
+CSSRuleList CSSStyleSheetImpl::cssRules()
+{
+    return this;
+}
+
 void CSSStyleSheetImpl::deleteRule( unsigned long index, int &exceptioncode )
 {
     exceptioncode = 0;
@@ -232,30 +197,13 @@ void CSSStyleSheetImpl::deleteRule( unsigned long index, int &exceptioncode )
 
 bool CSSStyleSheetImpl::parseString(const DOMString &string, bool strict)
 {
-    strictParsing = strict;
-    const QString preprocessed = preprocess(string.string());
-
 #ifdef CSS_STYLESHEET_DEBUG
     kdDebug( 6080 ) << "parsing sheet, len=" << string.length() << ", sheet is " << string.string() << endl;
 #endif
 
-    const QChar *curP = preprocessed.unicode();
-    const QChar *endP = preprocessed.unicode() + preprocessed.length();
-
-#ifdef CSS_STYLESHEET_DEBUG
-    kdDebug( 6080 ) << "preprocessed sheet, len=" << preprocessed.length() << ", sheet is " << preprocessed << endl;
-#endif
-
-    while (curP && (curP < endP))
-    {
-        CSSRuleImpl *rule = parseRule(curP, endP);
-        if(rule)
-        {
-           m_lstChildren->append(rule);
-           rule->setParent(this);
-//           rule->init();
-        }
-    }
+    strictParsing = strict;
+    CSSParser p( strict );
+    p.parseSheet( this, string );
     return true;
 }
 
@@ -309,11 +257,8 @@ khtml::DocLoader *CSSStyleSheetImpl::docLoader()
     return m_doc->docLoader();
 }
 
-// ---------------------------------------------------------------------------------------------
+// ---------------------------------------------------------------------------
 
-StyleSheetListImpl::StyleSheetListImpl()
-{
-}
 
 StyleSheetListImpl::~StyleSheetListImpl()
 {
@@ -363,11 +308,6 @@ StyleSheetImpl *StyleSheetListImpl::item ( unsigned long index )
 
 // --------------------------------------------------------------------------------------------
 
-MediaListImpl::MediaListImpl(CSSStyleSheetImpl *parentSheet)
-    : StyleBaseImpl(parentSheet)
-{
-}
-
 MediaListImpl::MediaListImpl( CSSStyleSheetImpl *parentSheet,
                               const DOMString &media )
     : StyleBaseImpl( parentSheet )
@@ -375,21 +315,12 @@ MediaListImpl::MediaListImpl( CSSStyleSheetImpl *parentSheet,
     setMediaText( media );
 }
 
-MediaListImpl::MediaListImpl(CSSRuleImpl *parentRule)
-    : StyleBaseImpl(parentRule)
-{
-}
-
 MediaListImpl::MediaListImpl( CSSRuleImpl *parentRule, const DOMString &media )
     : StyleBaseImpl(parentRule)
 {
     setMediaText( media );
 }
 
-MediaListImpl::~MediaListImpl()
-{
-}
-
 bool MediaListImpl::contains( const DOMString &medium ) const
 {
     return m_lstMedia.count() == 0 || m_lstMedia.contains( medium ) ||
@@ -408,16 +339,6 @@ CSSRuleImpl *MediaListImpl::parentRule() const
     return 0;
 }
 
-unsigned long MediaListImpl::length() const
-{
-    return m_lstMedia.count();
-}
-
-DOMString MediaListImpl::item( unsigned long index ) const
-{
-    return m_lstMedia[index];
-}
-
 void MediaListImpl::deleteMedium( const DOMString &oldMedium )
 {
     for ( QValueList<DOMString>::Iterator it = m_lstMedia.begin(); it != m_lstMedia.end(); ++it ) {
@@ -428,11 +349,6 @@ void MediaListImpl::deleteMedium( const DOMString &oldMedium )
     }
 }
 
-void MediaListImpl::appendMedium( const DOMString &newMedium )
-{
-    m_lstMedia.append( newMedium );
-}
-
 DOM::DOMString MediaListImpl::mediaText() const
 {
     DOMString text;
diff --git a/WebCore/khtml/css/css_stylesheetimpl.h b/WebCore/khtml/css/css_stylesheetimpl.h
index 199a7c1..78c3bea 100644
--- a/WebCore/khtml/css/css_stylesheetimpl.h
+++ b/WebCore/khtml/css/css_stylesheetimpl.h
@@ -1,7 +1,7 @@
 /*
  * This file is part of the DOM implementation for KDE.
  *
- * (C) 1999 Lars Knoll (knoll at kde.org)
+ * (C) 1999-2003 Lars Knoll (knoll at kde.org)
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -18,6 +18,7 @@
  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  *
+ * $Id$
  */
 #ifndef _CSS_css_stylesheetimpl_h_
 #define _CSS_css_stylesheetimpl_h_
@@ -26,7 +27,7 @@
 #include <qptrlist.h>
 
 #include "dom/dom_string.h"
-#include "css/cssparser.h"
+#include "css/css_base.h"
 #include "misc/loader_client.h"
 
 namespace khtml {
@@ -53,21 +54,20 @@ public:
     StyleSheetImpl(StyleSheetImpl *parentSheet, DOM::DOMString href = DOMString());
     StyleSheetImpl(StyleBaseImpl *owner, DOM::DOMString href  = DOMString());
     StyleSheetImpl(khtml::CachedCSSStyleSheet *cached, DOM::DOMString href  = DOMString());
-
     virtual ~StyleSheetImpl();
 
     virtual bool isStyleSheet() const { return true; }
 
     virtual DOM::DOMString type() const { return DOMString(); }
 
-    bool disabled() const;
-    void setDisabled( bool );
+    bool disabled() const { return m_disabled; }
+    void setDisabled( bool disabled ) { m_disabled = disabled; }
 
-    DOM::NodeImpl *ownerNode() const;
+    DOM::NodeImpl *ownerNode() const { return m_parentNode; }
     StyleSheetImpl *parentStyleSheet() const;
-    DOM::DOMString href() const;
-    DOM::DOMString title() const;
-    MediaListImpl *media() const;
+    DOM::DOMString href() const { return m_strHref; }
+    DOM::DOMString title() const { return m_strTitle; }
+    MediaListImpl *media() const { return m_media; }
     void setMedia( MediaListImpl *media );
 
 protected:
@@ -88,8 +88,6 @@ public:
     CSSStyleSheetImpl(DOM::NodeImpl *parentNode, CSSStyleSheetImpl *orig);
     CSSStyleSheetImpl(CSSRuleImpl *ownerRule, CSSStyleSheetImpl *orig);
 
-    virtual ~CSSStyleSheetImpl();
-
     virtual bool isCSSStyleSheet() const { return true; }
 
     virtual DOM::DOMString type() const { return "text/css"; }
@@ -118,7 +116,7 @@ protected:
 class StyleSheetListImpl : public khtml::Shared<StyleSheetListImpl>
 {
 public:
-    StyleSheetListImpl();
+    StyleSheetListImpl() {}
     ~StyleSheetListImpl();
 
     // the following two ignore implicit stylesheets
@@ -136,22 +134,23 @@ public:
 class MediaListImpl : public StyleBaseImpl
 {
 public:
-    MediaListImpl( CSSStyleSheetImpl *parentSheet );
+    MediaListImpl()
+	: StyleBaseImpl( 0 ) {}
+    MediaListImpl( CSSStyleSheetImpl *parentSheet )
+        : StyleBaseImpl(parentSheet) {}
     MediaListImpl( CSSStyleSheetImpl *parentSheet,
                    const DOM::DOMString &media );
-    MediaListImpl( CSSRuleImpl *parentRule );
+    //MediaListImpl( CSSRuleImpl *parentRule );
     MediaListImpl( CSSRuleImpl *parentRule, const DOM::DOMString &media );
 
-    virtual ~MediaListImpl();
-
     virtual bool isMediaList() { return true; }
 
     CSSStyleSheetImpl *parentStyleSheet() const;
     CSSRuleImpl *parentRule() const;
-    unsigned long length() const;
-    DOM::DOMString item ( unsigned long index ) const;
+    unsigned long length() const { return m_lstMedia.count(); }
+    DOM::DOMString item ( unsigned long index ) const { return m_lstMedia[index]; }
     void deleteMedium ( const DOM::DOMString &oldMedium );
-    void appendMedium ( const DOM::DOMString &newMedium );
+    void appendMedium ( const DOM::DOMString &newMedium ) { m_lstMedia.append(newMedium); }
 
     DOM::DOMString mediaText() const;
     void setMediaText(const DOM::DOMString &value);
diff --git a/WebCore/khtml/css/css_valueimpl.cpp b/WebCore/khtml/css/css_valueimpl.cpp
index 8c8b2c0..dd57650 100644
--- a/WebCore/khtml/css/css_valueimpl.cpp
+++ b/WebCore/khtml/css/css_valueimpl.cpp
@@ -1,8 +1,8 @@
 /**
  * This file is part of the DOM implementation for KDE.
  *
- * (C) 1999 Lars Knoll (knoll at kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * (C) 1999-2003 Lars Knoll (knoll at kde.org)
+ * Copyright (C) 2002 Apple Computer, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -28,6 +28,7 @@
 #include "css/css_ruleimpl.h"
 #include "css/css_stylesheetimpl.h"
 #include "css/cssparser.h"
+#include "css/cssproperties.h"
 #include "css/cssvalues.h"
 
 #include "xml/dom_stringimpl.h"
@@ -87,7 +88,137 @@ CSSStyleDeclarationImpl::~CSSStyleDeclarationImpl()
     // we don't use refcounting for m_node, to avoid cyclic references (see ElementImpl)
 }
 
-CSSValueImpl *CSSStyleDeclarationImpl::getPropertyCSSValue( int propertyID )
+DOMString CSSStyleDeclarationImpl::getPropertyValue( int propertyID ) const
+{
+    if(!m_lstValues) return DOMString();
+
+    CSSValueImpl* value = getPropertyCSSValue( propertyID );
+    if ( value )
+        return value->cssText();
+
+    // Shorthand and 4-values properties
+    switch ( propertyID ) {
+    case CSS_PROP_BACKGROUND_POSITION:
+    {
+        // ## Is this correct? The code in cssparser.cpp is confusing
+        const int properties[2] = { CSS_PROP_BACKGROUND_POSITION_X,
+                                    CSS_PROP_BACKGROUND_POSITION_Y };
+        return getShortHandValue( properties, 2 );
+    }
+    case CSS_PROP_BACKGROUND:
+    {
+        const int properties[5] = { CSS_PROP_BACKGROUND_IMAGE, CSS_PROP_BACKGROUND_REPEAT,
+                                    CSS_PROP_BACKGROUND_ATTACHMENT, CSS_PROP_BACKGROUND_POSITION,
+                                    CSS_PROP_BACKGROUND_COLOR };
+        return getShortHandValue( properties, 5 );
+    }
+    case CSS_PROP_BORDER:
+    {
+        const int properties[3] = { CSS_PROP_BORDER_WIDTH, CSS_PROP_BORDER_STYLE,
+                                    CSS_PROP_BORDER_COLOR };
+        return getShortHandValue( properties, 3 );
+    }
+    case CSS_PROP_BORDER_TOP:
+    {
+        const int properties[3] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_TOP_STYLE,
+                                    CSS_PROP_BORDER_TOP_COLOR};
+        return getShortHandValue( properties, 3 );
+    }
+    case CSS_PROP_BORDER_RIGHT:
+    {
+        const int properties[3] = { CSS_PROP_BORDER_RIGHT_WIDTH, CSS_PROP_BORDER_RIGHT_STYLE,
+                                    CSS_PROP_BORDER_RIGHT_COLOR};
+        return getShortHandValue( properties, 3 );
+    }
+    case CSS_PROP_BORDER_BOTTOM:
+    {
+        const int properties[3] = { CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_BOTTOM_STYLE,
+                                    CSS_PROP_BORDER_BOTTOM_COLOR};
+        return getShortHandValue( properties, 3 );
+    }
+    case CSS_PROP_BORDER_LEFT:
+    {
+        const int properties[3] = { CSS_PROP_BORDER_LEFT_WIDTH, CSS_PROP_BORDER_LEFT_STYLE,
+                                    CSS_PROP_BORDER_LEFT_COLOR};
+        return getShortHandValue( properties, 3 );
+    }
+    case CSS_PROP_OUTLINE:
+    {
+        const int properties[3] = { CSS_PROP_OUTLINE_WIDTH, CSS_PROP_OUTLINE_STYLE,
+                                    CSS_PROP_OUTLINE_COLOR };
+        return getShortHandValue( properties, 3 );
+    }
+    case CSS_PROP_BORDER_COLOR:
+    {
+        const int properties[4] = { CSS_PROP_BORDER_TOP_COLOR, CSS_PROP_BORDER_RIGHT_COLOR,
+                                    CSS_PROP_BORDER_BOTTOM_COLOR, CSS_PROP_BORDER_LEFT_COLOR };
+        return get4Values( properties );
+    }
+    case CSS_PROP_BORDER_WIDTH:
+    {
+        const int properties[4] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_RIGHT_WIDTH,
+                                    CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_LEFT_WIDTH };
+        return get4Values( properties );
+    }
+    case CSS_PROP_BORDER_STYLE:
+    {
+        const int properties[4] = { CSS_PROP_BORDER_TOP_STYLE, CSS_PROP_BORDER_RIGHT_STYLE,
+                                    CSS_PROP_BORDER_BOTTOM_STYLE, CSS_PROP_BORDER_LEFT_STYLE };
+        return get4Values( properties );
+    }
+    case CSS_PROP_MARGIN:
+    {
+        const int properties[4] = { CSS_PROP_MARGIN_TOP, CSS_PROP_MARGIN_RIGHT,
+                                    CSS_PROP_MARGIN_BOTTOM, CSS_PROP_MARGIN_LEFT };
+        return get4Values( properties );
+    }
+    case CSS_PROP_PADDING:
+    {
+        const int properties[4] = { CSS_PROP_PADDING_TOP, CSS_PROP_PADDING_RIGHT,
+                                    CSS_PROP_PADDING_BOTTOM, CSS_PROP_PADDING_LEFT };
+        return get4Values( properties );
+    }
+    case CSS_PROP_LIST_STYLE:
+    {
+        const int properties[3] = { CSS_PROP_LIST_STYLE_TYPE, CSS_PROP_LIST_STYLE_POSITION,
+                                    CSS_PROP_LIST_STYLE_IMAGE };
+        return getShortHandValue( properties, 3 );
+    }
+    }
+    //kdDebug() << k_funcinfo << "property not found:" << propertyID << endl;
+    return DOMString();
+}
+
+DOMString CSSStyleDeclarationImpl::get4Values( const int* properties ) const
+{
+    DOMString res;
+    for ( int i = 0 ; i < 4 ; ++i ) {
+        CSSValueImpl* value = getPropertyCSSValue( properties[i] );
+        if ( !value ) { // apparently all 4 properties must be specified.
+            return DOMString();
+        }
+        if ( i > 0 )
+            res += " ";
+        res += value->cssText();
+    }
+    return res;
+}
+
+DOMString CSSStyleDeclarationImpl::getShortHandValue( const int* properties, int number ) const
+{
+    DOMString res;
+    for ( int i = 0 ; i < number ; ++i ) {
+        CSSValueImpl* value = getPropertyCSSValue( properties[i] );
+        if ( value ) { // TODO provide default value if !value
+            if ( !res.isNull() )
+                res += " ";
+            res += value->cssText();
+        }
+    }
+    return res;
+}
+
+ CSSValueImpl *CSSStyleDeclarationImpl::getPropertyCSSValue( int propertyID ) const
 {
     if(!m_lstValues) return 0;
 
@@ -110,7 +241,7 @@ DOMString CSSStyleDeclarationImpl::removeProperty( int propertyID, bool NonCSSHi
          if (current->m_id == propertyID && NonCSSHint == current->nonCSSHint) {
              value = current->value()->cssText();
              m_lstValues->removeRef(current);
-            setChanged();
+             setChanged();
 	     break;
         }
 
@@ -132,7 +263,7 @@ void CSSStyleDeclarationImpl::setChanged()
         }
 }
 
-bool CSSStyleDeclarationImpl::getPropertyPriority( int propertyID )
+bool CSSStyleDeclarationImpl::getPropertyPriority( int propertyID ) const
 {
     if ( m_lstValues) {
 	QPtrListIterator<CSSProperty> lstValuesIt(*m_lstValues);
@@ -145,7 +276,7 @@ bool CSSStyleDeclarationImpl::getPropertyPriority( int propertyID )
     return false;
 }
 
-void CSSStyleDeclarationImpl::setProperty(int id, const DOMString &value, bool important, bool nonCSSHint)
+bool CSSStyleDeclarationImpl::setProperty(int id, const DOMString &value, bool important, bool nonCSSHint)
 {
     if(!m_lstValues) {
 	m_lstValues = new QPtrList<CSSProperty>;
@@ -153,14 +284,14 @@ void CSSStyleDeclarationImpl::setProperty(int id, const DOMString &value, bool i
     }
     removeProperty(id, nonCSSHint );
 
-    DOMString ppValue = preprocess(value.string(),true);
-    bool success = parseValue(ppValue.unicode(), ppValue.unicode()+ppValue.length(), id, important, nonCSSHint, m_lstValues);
-
+    CSSParser parser( strictParsing );
+    bool success = parser.parseValue( this, id, value, important, nonCSSHint );
     if(!success)
 	kdDebug( 6080 ) << "CSSStyleDeclarationImpl::setProperty invalid property: [" << getPropertyName(id).string()
-					<< "] value: [" << value.string() << "]"<< endl;
+			<< "] value: [" << value.string() << "]"<< endl;
     else
         setChanged();
+    return success;
 }
 
 void CSSStyleDeclarationImpl::setProperty(int id, int value, bool important, bool nonCSSHint)
@@ -178,39 +309,24 @@ void CSSStyleDeclarationImpl::setProperty(int id, int value, bool important, boo
 
 void CSSStyleDeclarationImpl::setProperty ( const DOMString &propertyString)
 {
-    DOMString ppPropertyString = preprocess(propertyString.string(),true);
-    QPtrList<CSSProperty> *props = parseProperties(ppPropertyString.unicode(),
-						ppPropertyString.unicode()+ppPropertyString.length());
-    if(!props || !props->count())
-    {
-	kdDebug( 6080 ) << "no properties returned!" << endl;
-	return;
-    }
-
-    props->setAutoDelete(false);
-
     if(!m_lstValues) {
 	m_lstValues = new QPtrList<CSSProperty>;
 	m_lstValues->setAutoDelete( true );
     }
 
-    CSSProperty *prop = props->first();
-    while( prop ) {
-	removeProperty(prop->m_id, false);
-	m_lstValues->append(prop);
- 	prop = props->next();
-    }
-
-    delete props;
+    CSSParser parser( strictParsing );
+    parser.parseDeclaration( this, propertyString, false );
     setChanged();
 }
 
-void CSSStyleDeclarationImpl::setLengthProperty(int id, const DOM::DOMString &value, bool important, bool nonCSSHint)
+void CSSStyleDeclarationImpl::setLengthProperty(int id, const DOM::DOMString &value, bool important, bool nonCSSHint, bool _multiLength )
 {
     bool parseMode = strictParsing;
     strictParsing = false;
+    multiLength = _multiLength;
     setProperty( id, value, important, nonCSSHint);
     strictParsing = parseMode;
+    multiLength = false;
 }
 
 unsigned long CSSStyleDeclarationImpl::length() const
@@ -322,7 +438,7 @@ CSSPrimitiveValueImpl::CSSPrimitiveValueImpl(int ident)
     m_type = CSSPrimitiveValue::CSS_IDENT;
 }
 
-CSSPrimitiveValueImpl::CSSPrimitiveValueImpl(float num, CSSPrimitiveValue::UnitTypes type)
+CSSPrimitiveValueImpl::CSSPrimitiveValueImpl(double num, CSSPrimitiveValue::UnitTypes type)
 {
     m_value.num = num;
     m_type = type;
@@ -351,15 +467,9 @@ CSSPrimitiveValueImpl::CSSPrimitiveValueImpl( RectImpl *r)
     m_type = CSSPrimitiveValue::CSS_RECT;
 }
 
-CSSPrimitiveValueImpl::CSSPrimitiveValueImpl(const RGBColor &rgb)
+CSSPrimitiveValueImpl::CSSPrimitiveValueImpl(QRgb color)
 {
-    m_value.rgbcolor = new RGBColor(rgb);
-    m_type = CSSPrimitiveValue::CSS_RGBCOLOR;
-}
-
-CSSPrimitiveValueImpl::CSSPrimitiveValueImpl(const QColor &color)
-{
-    m_value.rgbcolor = new RGBColor(color);
+    m_value.rgbcolor = color;
     m_type = CSSPrimitiveValue::CSS_RGBCOLOR;
 }
 
@@ -370,40 +480,55 @@ CSSPrimitiveValueImpl::~CSSPrimitiveValueImpl()
 
 void CSSPrimitiveValueImpl::cleanup()
 {
-    if(m_type == CSSPrimitiveValue::CSS_RGBCOLOR)
-	delete m_value.rgbcolor;
-    else if(m_type < CSSPrimitiveValue::CSS_STRING || m_type == CSSPrimitiveValue::CSS_IDENT)
-    { }
-    else if(m_type < CSSPrimitiveValue::CSS_COUNTER)
-	{ if(m_value.string) m_value.string->deref(); }
-    else if(m_type == CSSPrimitiveValue::CSS_COUNTER)
+    switch(m_type) {
+    case CSSPrimitiveValue::CSS_STRING:
+    case CSSPrimitiveValue::CSS_URI:
+    case CSSPrimitiveValue::CSS_ATTR:
+	if(m_value.string) m_value.string->deref();
+        break;
+    case CSSPrimitiveValue::CSS_COUNTER:
 	m_value.counter->deref();
-    else if(m_type == CSSPrimitiveValue::CSS_RECT)
+        break;
+    case CSSPrimitiveValue::CSS_RECT:
 	m_value.rect->deref();
+    default:
+        break;
+    }
+
     m_type = 0;
 }
 
 int CSSPrimitiveValueImpl::computeLength( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics )
 {
-    return ( int ) computeLengthFloat( style, devMetrics );
+    double result = computeLengthFloat( style, devMetrics );
+    int intResult = (int)result;
+#if APPLE_CHANGES
+    // This conversion is imprecise, often resulting in values of e.g., 44.99998.  We
+    // need to go ahead and round if we're really close to the next integer value.
+    double newResult = (intResult < 0) ? result-0.01 : result+0.01;
+    int secondIntResult = (int)newResult;
+    if (secondIntResult != intResult)
+        return secondIntResult;
+#endif
+    return intResult;
 }
 
-float CSSPrimitiveValueImpl::computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics )
+double CSSPrimitiveValueImpl::computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics )
 {
     unsigned short type = primitiveType();
 
-    float dpiY = 72.; // fallback
+    double dpiY = 72.; // fallback
     if ( devMetrics )
         dpiY = devMetrics->logicalDpiY();
     if ( !khtml::printpainter && dpiY < 96 )
         dpiY = 96.;
 
-    float factor = 1.;
+    double factor = 1.;
     switch(type)
     {
     case CSSPrimitiveValue::CSS_EMS:
-       	factor = style->font().pixelSize();
-		break;
+        factor = style->font().pixelSize();
+        break;
     case CSSPrimitiveValue::CSS_EXS:
 	{
         QFontMetrics fm = style->fontMetrics();
@@ -436,10 +561,11 @@ float CSSPrimitiveValueImpl::computeLengthFloat( khtml::RenderStyle *style, QPai
     default:
         return -1;
     }
+
     return getFloatValue(type)*factor;
 }
 
-void CSSPrimitiveValueImpl::setFloatValue( unsigned short unitType, float floatValue, int &exceptioncode )
+void CSSPrimitiveValueImpl::setFloatValue( unsigned short unitType, double floatValue, int &exceptioncode )
 {
     exceptioncode = 0;
     cleanup();
@@ -571,7 +697,7 @@ DOM::DOMString CSSPrimitiveValueImpl::cssText() const
 	    // ###
 	    break;
 	case CSSPrimitiveValue::CSS_RGBCOLOR:
-	    text = m_value.rgbcolor->color().name();
+	    text = QColor(m_value.rgbcolor).name();
 	    break;
 	default:
 	    break;
@@ -659,7 +785,7 @@ CSSImageValueImpl::~CSSImageValueImpl()
 // ------------------------------------------------------------------------
 
 FontFamilyValueImpl::FontFamilyValueImpl( const QString &string)
-    : CSSPrimitiveValueImpl( DOMString(string), CSSPrimitiveValue::CSS_STRING)
+: CSSPrimitiveValueImpl( DOMString(string), CSSPrimitiveValue::CSS_STRING)
 {
     static const QRegExp parenReg(" \\(.*\\)$");
     static const QRegExp braceReg(" \\[.*\\]$");
@@ -679,76 +805,43 @@ FontFamilyValueImpl::FontFamilyValueImpl( const QString &string)
     // remove [Xft] qualifiers
     face = face.replace(braceReg, "");
     //kdDebug(0) << "searching for face '" << face << "'" << endl;
-    if(face == "serif" ||
-       face == "sans-serif" ||
-       face == "cursive" ||
-       face == "fantasy" ||
-       face == "monospace" ||
-       face == "konq_default") {
-	parsedFontName = face;
-    } else {
-	int pos = available.find( face, 0, false );
-	if( pos == -1 ) {
-	    QString str = face;
-	    int p = face.find(' ');
-	    // Arial Blk --> Arial
-	    // MS Sans Serif --> Sans Serif
-	    if ( p != -1 ) {
-		if(p > 0 && (int)str.length() - p > p + 1)
-		    str = str.mid( p+1 );
-		else
-		    str.truncate( p );
-		pos = available.find( str, 0, false);
-	    }
-	}
 
-	if ( pos != -1 ) {
-	    int pos1 = available.findRev( ',', pos ) + 1;
-	    pos = available.find( ',', pos );
-	    if ( pos == -1 )
-		pos = available.length();
-	    parsedFontName = available.mid( pos1, pos - pos1 );
-	}
+    int pos = available.find( face, 0, false );
+    if( pos == -1 ) {
+        QString str = face;
+        int p = face.find(' ');
+        // Arial Blk --> Arial
+        // MS Sans Serif --> Sans Serif
+        if ( p != -1 ) {
+            if(p > 0 && (int)str.length() - p > p + 1)
+                str = str.mid( p+1 );
+            else
+                str.truncate( p );
+            pos = available.find( str, 0, false);
+        }
+    }
+
+    if ( pos != -1 ) {
+        int pos1 = available.findRev( ',', pos ) + 1;
+        pos = available.find( ',', pos );
+        if ( pos == -1 )
+            pos = available.length();
+        parsedFontName = available.mid( pos1, pos - pos1 );
     }
 #endif // !APPLE_CHANGES
+}
 
-    _genericFamilyType = FontDef::eNone;
-    _isKonqBody = false;
+FontValueImpl::FontValueImpl()
+    : style(0), variant(0), weight(0), size(0), lineHeight(0), family(0)
+{
+}
 
-    if (parsedFontName.isEmpty()) {
-        return;
-    }
-    
-    // Check font names here instead of every time through the CSSStyleSelector.
-    switch (parsedFontName[0]) {
-        case 'c':
-            if (parsedFontName == "cursive") {
-                _genericFamilyType = FontDef::eCursive;
-            }
-            break;
-        case 'f':
-            if (parsedFontName == "fantasy") {
-                _genericFamilyType = FontDef::eFantasy;
-            }
-            break;
-        case 'k':
-            if (parsedFontName == "konq_default") {
-                _genericFamilyType = FontDef::eStandard;
-            } else if (parsedFontName == "konq_body") {
-                _isKonqBody = true;
-            }
-            break;
-        case 'm':
-            if (parsedFontName == "monospace") {
-                _genericFamilyType = FontDef::eMonospace;
-            }
-            break;
-        case 's':
-            if (parsedFontName == "serif") {
-                _genericFamilyType = FontDef::eSerif;
-            } else if (parsedFontName == "sans-serif") {
-                _genericFamilyType = FontDef::eSansSerif;
-            }
-            break;
-    }
+FontValueImpl::~FontValueImpl()
+{
+    delete style;
+    delete variant;
+    delete weight;
+    delete size;
+    delete lineHeight;
+    delete family;
 }
diff --git a/WebCore/khtml/css/css_valueimpl.h b/WebCore/khtml/css/css_valueimpl.h
index 0535e1f..6bbee20 100644
--- a/WebCore/khtml/css/css_valueimpl.h
+++ b/WebCore/khtml/css/css_valueimpl.h
@@ -1,8 +1,8 @@
 /*
  * This file is part of the DOM implementation for KDE.
  *
- * (C) 1999 Lars Knoll (knoll at kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * (C) 1999-2003 Lars Knoll (knoll at kde.org)
+ * Copyright (C) 2002 Apple Computer, Inc.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -19,13 +19,14 @@
  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
  *
+ * $Id$
  */
 #ifndef _CSS_css_valueimpl_h_
 #define _CSS_css_valueimpl_h_
 
 #include "dom/css_value.h"
 #include "dom/dom_string.h"
-#include "css/cssparser.h"
+#include "css/css_base.h"
 #include "misc/loader_client.h"
 #include "misc/shared.h"
 
@@ -34,7 +35,7 @@
 namespace khtml {
     class RenderStyle;
     class CachedImage;
-};
+}
 
 namespace DOM {
 
@@ -56,11 +57,11 @@ public:
     unsigned long length() const;
     CSSRuleImpl *parentRule() const;
     DOM::DOMString removeProperty( int propertyID, bool NonCSSHints = false );
-    void setProperty ( int propertyId, const DOM::DOMString &value, bool important = false, bool nonCSSHint = false);
+    bool setProperty ( int propertyId, const DOM::DOMString &value, bool important = false, bool nonCSSHint = false);
     void setProperty ( int propertyId, int value, bool important = false, bool nonCSSHint = false);
     // this treats integers as pixels!
     // needed for conversion of html attributes
-    void setLengthProperty(int id, const DOM::DOMString &value, bool important, bool nonCSSHint = true);
+    void setLengthProperty(int id, const DOM::DOMString &value, bool important, bool nonCSSHint = true, bool multiLength = false);
 
     // add a whole, unparsed property
     void setProperty ( const DOMString &propertyString);
@@ -73,8 +74,9 @@ public:
 
     virtual bool parseString( const DOMString &string, bool = false );
 
-    CSSValueImpl *getPropertyCSSValue( int propertyID );
-    bool getPropertyPriority( int propertyID );
+    CSSValueImpl *getPropertyCSSValue( int propertyID ) const;
+    DOMString getPropertyValue( int propertyID ) const;
+    bool getPropertyPriority( int propertyID ) const;
 
     QPtrList<CSSProperty> *values() { return m_lstValues; }
     void setNode(NodeImpl *_node) { m_node = _node; }
@@ -82,6 +84,9 @@ public:
     void setChanged();
 
 protected:
+    DOMString getShortHandValue( const int* properties, int number ) const;
+    DOMString get4Values( const int* properties ) const;
+
     QPtrList<CSSProperty> *m_lstValues;
     NodeImpl *m_node;
 
@@ -103,6 +108,7 @@ public:
     void setCssText(DOM::DOMString str);
 
     virtual bool isValue() { return true; }
+    virtual bool isFontValue() { return false; }
 };
 
 class CSSInheritedValueImpl : public CSSValueImpl
@@ -147,12 +153,11 @@ class CSSPrimitiveValueImpl : public CSSValueImpl
 public:
     CSSPrimitiveValueImpl();
     CSSPrimitiveValueImpl(int ident);
-    CSSPrimitiveValueImpl(float num, CSSPrimitiveValue::UnitTypes type);
+    CSSPrimitiveValueImpl(double num, CSSPrimitiveValue::UnitTypes type);
     CSSPrimitiveValueImpl(const DOMString &str, CSSPrimitiveValue::UnitTypes type);
     CSSPrimitiveValueImpl(const Counter &c);
     CSSPrimitiveValueImpl( RectImpl *r);
-    CSSPrimitiveValueImpl(const RGBColor &rgb);
-    CSSPrimitiveValueImpl(const QColor &color);
+    CSSPrimitiveValueImpl(QRgb color);
 
     virtual ~CSSPrimitiveValueImpl();
 
@@ -174,13 +179,12 @@ public:
      */
     int computeLength( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
 
-    float computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
-
+    double computeLengthFloat( khtml::RenderStyle *style, QPaintDeviceMetrics *devMetrics );
 
     // use with care!!!
     void setPrimitiveType(unsigned short type) { m_type = type; }
-    void setFloatValue ( unsigned short unitType, float floatValue, int &exceptioncode );
-    float getFloatValue ( unsigned short/* unitType */) const {
+    void setFloatValue ( unsigned short unitType, double floatValue, int &exceptioncode );
+    double getFloatValue ( unsigned short/* unitType */) const {
 	return m_value.num;
     }
 
@@ -199,7 +203,7 @@ public:
 	return ( m_type != CSSPrimitiveValue::CSS_RECT ? 0 : m_value.rect );
     }
 
-    RGBColor *getRGBColorValue () const {
+    QRgb getRGBColorValue () const {
 	return ( m_type != CSSPrimitiveValue::CSS_RGBCOLOR ? 0 : m_value.rgbcolor );
     }
 
@@ -212,31 +216,31 @@ public:
     virtual DOM::DOMString cssText() const;
 
     virtual bool isQuirkValue() { return false; }
-    
+
 protected:
     int m_type;
     union {
 	int ident;
-	float num;
+	double num;
 	DOM::DOMStringImpl *string;
 	CounterImpl *counter;
 	RectImpl *rect;
-	RGBColor *rgbcolor;
+        QRgb rgbcolor;
     } m_value;
 };
 
 // This value is used to handle quirky margins in reflow roots (body, td, and th) like WinIE.
-// The basic idea is that a stylesheet can use the value _qem (for quirky em) instead of em
+// The basic idea is that a stylesheet can use the value __qem (for quirky em) instead of em
 // in a stylesheet.  When the quirky value is used, if you're in quirks mode, the margin will
 // collapse away inside a table cell.
 class CSSQuirkPrimitiveValueImpl : public CSSPrimitiveValueImpl
 {
 public:
-    CSSQuirkPrimitiveValueImpl(float num, CSSPrimitiveValue::UnitTypes type)
+    CSSQuirkPrimitiveValueImpl(double num, CSSPrimitiveValue::UnitTypes type)
       :CSSPrimitiveValueImpl(num, type) {}
-    
+
     virtual ~CSSQuirkPrimitiveValueImpl() {}
-    
+
     virtual bool isQuirkValue() { return true; }
 };
 
@@ -291,12 +295,28 @@ public:
     FontFamilyValueImpl( const QString &string);
     const QString &fontName() const { return parsedFontName; }
     int genericFamilyType() const { return _genericFamilyType; }
-    bool isKonqBody() const { return _isKonqBody; }
 protected:
     QString parsedFontName;
 private:
     int _genericFamilyType;
-    bool _isKonqBody;
+};
+
+class FontValueImpl : public CSSValueImpl
+{
+public:
+    FontValueImpl();
+    virtual ~FontValueImpl();
+
+    virtual unsigned short cssValueType() const { return CSSValue::CSS_CUSTOM; }
+
+    virtual bool isFontValue() { return true; }
+
+    CSSPrimitiveValueImpl *style;
+    CSSPrimitiveValueImpl *variant;
+    CSSPrimitiveValueImpl *weight;
+    CSSPrimitiveValueImpl *size;
+    CSSPrimitiveValueImpl *lineHeight;
+    CSSValueListImpl *family;
 };
 
 // ------------------------------------------------------------------------------
@@ -343,6 +363,6 @@ protected:
 };
 
 
-}; // namespace
+} // namespace
 
 #endif
diff --git a/WebCore/khtml/css/cssparser.cpp b/WebCore/khtml/css/cssparser.cpp
index 9337fdc..b8c9819 100644
--- a/WebCore/khtml/css/cssparser.cpp
+++ b/WebCore/khtml/css/cssparser.cpp
@@ -1,11 +1,9 @@
 /*
  * This file is part of the DOM implementation for KDE.
  *
- * Copyright (C) 1999 Lars Knoll (knoll at kde.org)
- *               1999 Waldo Bastian (bastian at kde.org)
- *               2001 Andreas Schlapbach (schlpbch at iam.unibe.ch)
- *               2001 Dirk Mueller (mueller at kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * Copyright (C) 2003 Lars Knoll (knoll at kde.org)
+ *
+ * $Id$
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -24,1872 +22,864 @@
  */
 
 //#define CSS_DEBUG
-//#define CSS_AURAL
-//#define CSS_DEBUG_BCKGR
-
-#include <assert.h>
-
-#include "css/css_stylesheetimpl.h"
-#include "css/css_ruleimpl.h"
-#include "css/css_valueimpl.h"
-#include "css/csshelper.h"
-
-#include "dom/css_stylesheet.h"
-#include "dom/css_rule.h"
-#include "dom/dom_string.h"
-#include "dom/dom_exception.h"
-
-#include "xml/dom_nodeimpl.h"
-#include "html/html_documentimpl.h"
-#include "khtml_part.h"
-#include "khtmlview.h"
-
-using namespace DOM;
+// #define TOKEN_DEBUG
+#define YYDEBUG 0
 
 #include <kdebug.h>
-#include <kglobal.h>
-#include <kglobalsettings.h> // For system fonts
-#include <kapplication.h>
-
-#include "misc/htmlhashes.h"
+#include <kurl.h>
+
+#include "cssparser.h"
+#include "css_valueimpl.h"
+#include "css_ruleimpl.h"
+#include "css_stylesheetimpl.h"
+#include "cssproperties.h"
+#include "cssvalues.h"
 #include "misc/helper.h"
+#include "csshelper.h"
+using namespace DOM;
 
-// turn off inlining to void warning with newer gcc
-#undef __inline
-#define __inline
-//
-// The following file defines the function
-//     const struct props *findProp(const char *word, int len)
-//
-// with 'props->id' a CSS property in the range from CSS_PROP_MIN to
-// (and including) CSS_PROP_TOTAL-1
-#include "cssproperties.c"
-#include "cssvalues.c"
-#undef __inline
-
-static QPtrList<CSSProperty>* m_propList = 0;
-static bool m_bImportant = FALSE;
-static bool m_bnonCSSHint = FALSE;
-
-int DOM::getPropertyID(const char *tagStr, int len)
-{
-    const struct props *propsPtr = findProp(tagStr, len);
-    if (!propsPtr)
-        return 0;
-
-    return propsPtr->id;
-}
-
-// ------------------------------------------------------------------------------------------------------
+#include <stdlib.h>
 
-void StyleBaseImpl::checkLoaded()
-{
-    if(m_parent) m_parent->checkLoaded();
-}
+#if APPLE_CHANGES
+void qFatal ( const char * msg ) {}
+#endif
 
-DOMString StyleBaseImpl::baseURL()
+ValueList::ValueList()
 {
-    // try to find the style sheet. If found look for it's url.
-    // If it has none, look for the parentsheet, or the parentNode and
-    // try to find out about their url
-    StyleBaseImpl *b = this;
-    while(b && !b->isStyleSheet())
-        b = b->m_parent;
-
-    if(!b) return DOMString();
-
-    StyleSheetImpl *sheet = static_cast<StyleSheetImpl *>(b);
-    if(!sheet->href().isNull())
-        return sheet->href();
-
-    // find parent
-    if(sheet->parent()) return sheet->parent()->baseURL();
-
-    if(!sheet->ownerNode()) return DOMString();
-
-    DocumentImpl *doc = sheet->ownerNode()->getDocument();
-
-    return doc->baseURL();
+    values = (Value *) malloc( 16 * sizeof ( Value ) );
+    numValues = 0;
+    currentValue = 0;
+    maxValues = 16;
 }
 
-/*
- * parsing functions for stylesheets
- */
-
-const QChar *
-StyleBaseImpl::parseSpace(const QChar *curP, const QChar *endP)
+ValueList::~ValueList()
 {
-  bool sc = false;     // possible start comment?
-  bool ec = false;     // possible end comment?
-  bool ic = false;     // in comment?
-
-  while (curP < endP)
-  {
-      if (ic)
-      {
-          if (ec && (*curP == '/'))
-              ic = false;
-          else if (*curP == '*')
-              ec = true;
-          else
-              ec = false;
-      }
-      else if (sc && (*curP == '*'))
-      {
-          ic = true;
-      }
-      else if (*curP == '/')
-      {
-          sc = true;
-      }
-      //else if (!isspace(*curP))
-      else if (!(curP->isSpace()))
-      {
-          return(curP);
-      }
-      else
-      {
-          sc = false;
-      }
-      curP++;
-  }
-
-  return(0);
+    for ( int i = 0; i < numValues; i++ ) {
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "       value: (unit=" << values[i].unit <<")"<< endl;
+#endif
+	if ( values[i].unit == Value::Function )
+	    delete values[i].function;
+    }
+    free( values );
 }
 
-/*
- * ParseToChar
- *
- * Search for an expected character.  Deals with escaped characters,
- * quoted strings, and pairs of braces/parens/brackets.
- */
-const QChar *
-StyleBaseImpl::parseToChar(const QChar *curP, const QChar *endP, QChar c, bool chkws, bool endAtBlock)
+void ValueList::addValue( const Value &val )
 {
-    //kdDebug( 6080 ) << "parsetochar: \"" << QString(curP, endP-curP) << "\" searching " << c << " ws=" << chkws << endl;
-
-    bool sq = false; /* in single quote? */
-    bool dq = false; /* in double quote? */
-    bool esc = false; /* escape mode? */
-
-    while (curP < endP)
-    {
-        if (esc)
-            esc = false;
-        else if (*curP == '\\')
-            esc = true;
-        else if (!sq && (*curP == '"'))
-            dq = !dq;
-        else if (!dq && (*curP == '\''))
-            sq = !sq;
-        else if (!sq && !dq && *curP == c)
-            return(curP);
-        else if (!sq && !dq && chkws && curP->isSpace())
-            return(curP);
-        else if(!sq && !dq ) {
-            if (*curP == '{') {
-                if(endAtBlock)
-                    return curP;
-                curP = parseToChar(curP + 1, endP, '}', false);
-                if (!curP)
-                    return(0);
-            } else if (*curP == '(') {
-                curP = parseToChar(curP + 1, endP, ')', false);
-                if (!curP)
-                    return(0);
-            } else if (*curP == '[') {
-                curP = parseToChar(curP + 1, endP, ']', false);
-                if (!curP)
-                    return(0);
-            }
-        }
-        curP++;
+    if ( numValues >= maxValues ) {
+	maxValues += 16;
+	values = (Value *) realloc( values, maxValues*sizeof( Value ) );
     }
-
-    return(0);
+    values[numValues++] = val;
 }
 
-CSSRuleImpl *
-StyleBaseImpl::parseAtRule(const QChar *&curP, const QChar *endP)
-{
-    curP++;
-    const QChar *startP = curP;
-    while( *curP != ' ' && *curP != '{' && *curP != '\'')
-        curP++;
-
-    QString rule(startP, curP-startP);
-    rule = rule.lower();
 
-    //kdDebug( 6080 ) << "rule = '" << rule << "'" << endl;
+using namespace DOM;
 
-    if(rule == "import")
-    {
-        // load stylesheet and pass it over
-        curP = parseSpace(curP, endP);
-        if(!curP) return 0;
-        startP = curP++;
-        curP = parseToChar(startP, endP, ';', true);
-        // Do not allow @import statements after explicity inlined
-        // declarations.  They should simply be ignored per CSS-1
-        // specification section 3.0.
-        if( !curP || hasInlinedDecl ) return 0;
-        DOMString url = khtml::parseURL(DOMString(startP, curP - startP));
-        startP = curP;
-        if(*curP != ';')
-            curP = parseToChar(startP, endP, ';', false, true);
-        if(!curP) return 0;
-
-        DOMString mediaList = DOMString( startP, curP - startP);
-        // ### check if at the beginning of the stylesheet (no style rule
-        //     before the import rule)
-#ifdef CSS_DEBUG
-        kdDebug( 6080 ) << "import rule = " << url.string() << ", mediaList = "
-                        << mediaList.string() << endl;
+#if YYDEBUG > 0
+extern int cssyydebug;
 #endif
-        // ignore block following @import rule
-        if( *curP == '{' ) {
-            curP++;
-            curP = parseToChar(curP, endP, '}', false);
-            if(curP)
-                curP++;
-        }
-        if(!this->isCSSStyleSheet()) return 0;
 
-        return new CSSImportRuleImpl( this, url, mediaList );
-    }
-    else if(rule == "charset")
-    {
-        // ### invoke decoder
-        startP = curP++;
-        curP = parseToChar(startP, endP, ';', false);
-#ifdef CSS_DEBUG
-        kdDebug( 6080 ) << "charset = " << QString(startP, curP - startP) << endl;
-#endif
-    }
-    else if(rule == "font-face")
-    {
-        startP = curP++;
-        curP = parseToChar(startP, endP, '{', false);
-        if ( !curP || curP >= endP ) return 0;
-        curP++;
-        curP = parseToChar(curP, endP, '}', false);
-#ifdef CSS_DEBUG
-        kdDebug( 6080 ) << "font rule = " << QString(startP, curP - startP) << endl;
-#endif
-    }
-    else if (rule == "konq-quirks") {
-        startP = curP++;
-        curP = parseToChar(startP, endP, '{', false);
-        curP++;
-        startP = curP;
-        if (curP >= endP) return 0;
-        curP = parseToChar(curP, endP, '}', false);
-        if (!curP || startP >= curP)
-            return 0;
-        return new CSSQuirksRuleImpl(this, startP, curP);
-    }
-    else if(rule == "media")
-    {
-        startP = curP++;
-        curP = parseToChar(startP, endP, '{', false);
-	//qDebug("mediaList = '%s'", mediaList.latin1() );
-        if ( !curP || curP >= endP ) return 0;
-	DOMString mediaList = DOMString( startP, curP - startP);
-        curP++;
-	startP = curP;
-	if ( curP >= endP ) return 0;
-        curP = parseToChar(curP, endP, '}', false);
-	if ( !curP || startP >= curP )
-	    return 0;
+extern int cssyyparse( void * parser );
+
+CSSParser *CSSParser::currentParser = 0;
+
+CSSParser::CSSParser( bool strictParsing )
+{
 #ifdef CSS_DEBUG
-        kdDebug( 6080 ) << "media rule = " << QString(startP, curP - startP)
-                        << ", mediaList = " << mediaList.string() << endl;
+    kdDebug( 6080 ) << "CSSParser::CSSParser this=" << this << endl;
 #endif
-        return new CSSMediaRuleImpl( this, startP, curP, mediaList );
-    }
-    else if(rule == "page")
-    {
-        startP = curP++;
-        curP = parseToChar(startP, endP, '{', false);
-        if ( !curP || curP >= endP ) return 0;
-        curP++;
-        curP = parseToChar(curP, endP, '}', false);
-#ifdef CSS_DEBUG
-        kdDebug( 6080 ) << "page rule = " << QString(startP, curP - startP) << endl;
+    strict = strictParsing;
+
+    parsedProperties = (CSSProperty **) malloc( 32 * sizeof( CSSProperty * ) );
+    numParsedProperties = 0;
+    maxParsedProperties = 32;
+
+    valueList = 0;
+    rule = 0;
+    id = 0;
+    important = false;
+    nonCSSHint = false;
+    inParseShortHand = false;
+    yy_start = 1;
+
+#if YYDEBUG > 0
+    cssyydebug = 1;
 #endif
-    }
-
 
-    return 0;
 }
 
-static DOMString getValue( const QChar *curP, const QChar *endP, const QChar *&endVal)
+CSSParser::~CSSParser()
 {
-    //QString selecString( curP, endP - curP );
-    //kdDebug( 6080 ) << "getValue = \"" << selecString << "\"" << endl;
-    endVal = curP;
-    endVal++; // ignore first char (could be the ':' form the pseudo classes)
-    while( endVal < endP && *endVal != '.' && *endVal != ':' && *endVal != '[' )
-        endVal++;
-    const QChar *end = endVal;
-    if(endVal == endP)
-        endVal = 0;
-    return DOMString( curP, end - curP);
-}
+    if ( numParsedProperties )
+	clearProperties();
+    free( parsedProperties );
 
-CSSSelector *
-StyleBaseImpl::parseSelector2(const QChar *curP, const QChar *endP,
-                              CSSSelector::Relation relation)
-{
-    CSSSelector *cs = new CSSSelector();
-#ifdef CSS_DEBUG
-    QString selecString( curP, endP - curP );
-    kdDebug( 6080 ) << "selectString = \"" << selecString << "\"" << endl;
-#endif
-    const QChar *endVal = 0;
+    delete valueList;
 
-    if (*curP == '#' && (curP < endP && !((*(curP+1)).isDigit())))
-    {
-        cs->tag = -1;
-        cs->attr = ATTR_ID;
-        cs->match = CSSSelector::Exact;
-        cs->value = getValue( curP+1, endP, endVal);
-    }
-    else if (*curP == '.' && curP < endP && !(*(curP+1)).isDigit())
-    {
-        cs->tag = -1;
-        cs->attr = ATTR_CLASS;
-        cs->match = CSSSelector::List;
-        cs->value = getValue( curP+1, endP, endVal);
-    }
-    else if (*curP == ':'  && (curP < endP && !((*(curP+1)).isDigit())))
-    {
-        // pseudo attributes (:link, :hover, ...), they are case insensitive.
-        cs->tag = -1;
-        cs->match = CSSSelector::Pseudo;
-        cs->value = getValue(curP+1, endP, endVal);
-        cs->value = cs->value.implementation()->lower();
-    }
-    else
-    {
-        const QChar *startP = curP;
-        QString tag;
-        while (curP < endP)
-        {
-            if (*curP =='#' && (curP < endP && !((*(curP+1)).isDigit())))
-            {
-                tag = QString( startP, curP-startP );
-                cs->attr = ATTR_ID;
-                cs->match = CSSSelector::Exact;
-                cs->value = getValue(curP+1, endP, endVal);
-                break;
-            }
-            else if (*curP == '.' && curP < endP && ( !strictParsing || !(*(curP+1)).isDigit() ) )
-            {
-                tag = QString( startP, curP - startP );
-                cs->attr = ATTR_CLASS;
-                cs->match = CSSSelector::List;
-                cs->value = getValue(curP+1, endP, endVal);
-                break;
-            }
-            else if (*curP == ':'  && (curP < endP && !((*(curP+1)).isDigit())))
-            {
-                // pseudo attributes (:link, :hover, ...), they are case insensitive.
-                tag = QString( startP, curP - startP );
-                cs->match = CSSSelector::Pseudo;
-                cs->value = getValue(curP+1, endP, endVal);
-                cs->value = cs->value.implementation()->lower();
-                break;
-            }
-            else if (*curP == '[')
-            {
-                tag = QString( startP, curP - startP );
-                curP++;
-                if ( curP >= endP ) {
-                    delete cs;
-                    return 0;
-                }
-#ifdef CSS_DEBUG
-                kdDebug( 6080 ) << "tag = " << tag << endl;
-#endif
-                const QChar *closebracket = parseToChar(curP, endP, ']', false);
-                if (!closebracket)
-                {
-                    kdWarning()<<"error in css: closing bracket not found!"<<endl;
-		    delete cs;
-                    return 0;
-                }
-                QString attr;
-                const QChar *equal = parseToChar(curP, closebracket, '=', false);
-                if(!equal)
-                {
-                    attr = QString( curP, closebracket - curP );
-                    attr = attr.stripWhiteSpace();
 #ifdef CSS_DEBUG
-                    kdDebug( 6080 ) << "attr = '" << attr << "'" << endl;
-#endif
-                    cs->match = CSSSelector::Set;
-                    endVal = closebracket + 1;
-                    // ### fixme we ignore everything after [..]
-                    if( endVal == endP )
-                        endVal = 0;
-                }
-                else
-                {
-                    // check relation: = / ~= / |=
-		    // CSS3: ^= / $= / *=
-                    if(*(equal-1) == '~')
-                    {
-                        attr = QString( curP, equal - curP - 1 );
-                        cs->match = CSSSelector::List;
-                    }
-                    else if(*(equal-1) == '|')
-                    {
-                        attr = QString( curP, equal - curP - 1 );
-                        cs->match = CSSSelector::Hyphen;
-                    }
-                    else if(*(equal-1) == '^')
-                    {
-                        attr = QString( curP, equal - curP - 1);
-                        cs->match = CSSSelector::Begin;
-                    }
-                    else if(*(equal-1) == '$')
-                    {
-                        attr = QString( curP, equal - curP - 1);
-                        cs->match = CSSSelector::End;
-                    }
-                    else if(*(equal-1) == '*')
-                    {
-                        attr = QString( curP, equal - curP - 1);
-                        cs->match = CSSSelector::Contain;
-                    }
-                    else
-                    {
-                        attr = QString(curP, equal - curP );
-                        cs->match = CSSSelector::Exact;
-                    }
-                }
-                {
-                    attr = attr.stripWhiteSpace();
-                    StyleBaseImpl *root = this;
-                    DocumentImpl *doc = 0;
-                    while (root->parent())
-                        root = root->parent();
-                    if (root->isCSSStyleSheet())
-                        doc = static_cast<CSSStyleSheetImpl*>(root)->doc();
-
-                    if ( doc ) {
-                        if (doc->isHTMLDocument())
-                            attr = attr.lower();
-                        const DOMString dattr(attr);
-                        cs->attr = doc->attrId(0, dattr.implementation(), false);
-                    }
-                    else {
-                        cs->attr = khtml::getAttrID(attr.lower().ascii(), attr.length());
-                        // this case should never happen - only when loading
-                        // the default stylesheet - which must not contain unknown attributes
-                        assert(cs->attr);
-                    }
-                    if (!cs->attr) {
-                        delete cs;
-                        return 0;
-                    }
-                }
-                if(equal)
-                {
-                    equal++;
-                    while(equal < endP && *equal == ' ')
-                        equal++;
-                    if(equal >= endP ) {
-                        delete cs;
-                        return 0;
-                    }
-                    endVal = equal;
-                    bool hasQuote = false;
-                    if(*equal == '\'') {
-                        equal++;
-                        endVal++;
-                        while(endVal < endP && *endVal != '\'')
-                            endVal++;
-                        hasQuote = true;
-                    } else if(*equal == '\"') {
-                        equal++;
-                        endVal++;
-                        while(endVal < endP && *endVal != '\"')
-                            endVal++;
-                        hasQuote = true;
-                    } else {
-                      while(endVal < endP && *endVal != ']')
-                        endVal++;
-                    }
-                    cs->value = DOMString(equal, endVal - equal);
-                    if ( hasQuote ) {
-                      while( endVal < endP - 1 && *endVal != ']' )
-                        endVal++;
-                    }
-                    endVal++;
-                    // ### fixme we ignore everything after [..]
-                    if( endVal == endP )
-                        endVal = 0;
-                }
-                break;
-            }
-            else
-            {
-                curP++;
-            }
-        }
-        if (curP == endP)
-        {
-            tag = QString( startP, curP - startP );
-        }
-        if(tag == "*")
-        {
-            //kdDebug( 6080 ) << "found '*' selector" << endl;
-            cs->tag = -1;
-        }
-        else {
-            StyleBaseImpl *root = this;
-            DocumentImpl *doc = 0;
-            while (root->parent())
-                root = root->parent();
-            if (root->isCSSStyleSheet())
-                doc = static_cast<CSSStyleSheetImpl*>(root)->doc();
-
-            if ( doc ) {
-                if (doc->isHTMLDocument())
-                    tag = tag.lower();
-                const DOMString dtag(tag);
-                cs->tag = doc->tagId(0, dtag.implementation(), false);
-            }
-            else {
-                cs->tag = khtml::getTagID(tag.lower().ascii(), tag.length());
-                // this case should never happen - only when loading
-                // the default stylesheet - which must not contain unknown tags
-                assert(cs->tag);
-            }
-            if (!cs->tag) {
-                delete cs;
-                return 0;
-            }
-        }
-   }
-#ifdef CSS_DEBUG
-   kdDebug( 6080 ) << "[Selector: tag=" << cs->tag << " Attribute=" << cs->attr << " match=" << (int)cs->match << " value=" << cs->value.string() << " specificity=" << cs->specificity() << "]" << endl;
+    kdDebug( 6080 ) << "CSSParser::~CSSParser this=" << this << endl;
 #endif
 
+    free( data );
 
-   //stack->print();
-   if( endVal ) {
-       // lets be recursive
-       relation = CSSSelector::SubSelector;
-       CSSSelector *stack = parseSelector2(endVal, endP, relation);
-       cs->tagHistory = stack;
-       cs->relation = relation;
-   }
-
-   return cs;
 }
 
-CSSSelector *
-StyleBaseImpl::parseSelector1(const QChar *curP, const QChar *endP)
+void CSSParser::parseSheet( CSSStyleSheetImpl *sheet, const DOMString &string )
 {
-#ifdef CSS_DEBUG
-    kdDebug( 6080 ) << "selector1 is \'" << QString(curP, endP-curP) << "\'" << endl;
-#endif
+    styleElement = sheet;
+
+    int length = string.length() + 3;
+    data = (unsigned short *)malloc( length *sizeof( unsigned short ) );
+    memcpy( data, string.unicode(), string.length()*sizeof( unsigned short) );
+    data[length-1] = 0;
+    data[length-2] = 0;
+    data[length-3] = ' ';
+    yy_hold_char = 0;
+    yyleng = 0;
+    yytext = yy_c_buf_p = data;
+    yy_hold_char = *yy_c_buf_p;
 
-    CSSSelector *selecStack=0;
-
-    curP = parseSpace(curP, endP);
-    if (!curP)
-        return(0);
-
-    CSSSelector::Relation relation = CSSSelector::Descendant;
-
-    const QChar *startP = curP;
-    while (curP && curP <= endP)
-    {
-        if ((curP == endP) || curP->isSpace() || *curP == '+' || *curP == '>')
-        {
-            CSSSelector *newsel = parseSelector2(startP, curP, relation);
-            if (!newsel) {
-                delete selecStack;
-                return 0;
-            }
-            CSSSelector *end = newsel;
-            while( end->tagHistory )
-                end = end->tagHistory;
-            end->tagHistory = selecStack;
-            end->relation = relation;
-            selecStack = newsel;
-
-            curP = parseSpace(curP, endP);
-            if (!curP) {
 #ifdef CSS_DEBUG
-                kdDebug( 6080 ) << "selector stack is:" << endl;
-                selecStack->print();
-                kdDebug( 6080 ) << endl;
+    kdDebug( 6080 ) << ">>>>>>> start parsing style sheet" << endl;
 #endif
-                return(selecStack);
-            }
-            relation = CSSSelector::Descendant;
-            if(*curP == '+')
-            {
-                relation = CSSSelector::Sibling;
-                curP++;
-                curP = parseSpace(curP, endP);
-            }
-            else if(*curP == '>')
-            {
+    CSSParser *old = currentParser;
+    currentParser = this;
+    cssyyparse( this );
+    currentParser = old;
 #ifdef CSS_DEBUG
-                kdDebug( 6080 ) << "child selector" << endl;
+    kdDebug( 6080 ) << "<<<<<<< done parsing style sheet" << endl;
 #endif
-                relation = CSSSelector::Child;
-                curP++;
-                curP = parseSpace(curP, endP);
-            }
-            //if(selecStack)
-            //    selecStack->print();
-            startP = curP;
-        }
-        else
-        {
-            curP++;
-        }
-    }
-#ifdef CSS_DEBUG
-    selecStack->print();
-#endif
-    return(selecStack);
 }
 
-QPtrList<CSSSelector> *
-StyleBaseImpl::parseSelector(const QChar *curP, const QChar *endP)
+CSSRuleImpl *CSSParser::parseRule( const DOM::DOMString &string )
 {
-#ifdef CSS_DEBUG
-    kdDebug( 6080 ) << "selector is \'" << QString(curP, endP-curP) << "\'" << endl;
-#endif
-
-    QPtrList<CSSSelector> *slist  = 0;
-    const QChar *startP;
-
-    while (curP < endP)
-    {
-        startP = curP;
-        curP = parseToChar(curP, endP, ',', false);
-        if (!curP)
-            curP = endP;
-
-        CSSSelector *selector = parseSelector1(startP, curP);
-        if (selector)
-        {
-            if (!slist)
-            {
-                slist = new QPtrList<CSSSelector>;
-                slist->setAutoDelete(true);
-            }
-            slist->append(selector);
-            if (!sawDescendantRule) {
-                CSSSelector* sel = selector;
-                CSSSelector::Relation relation = sel->relation;
-                while ((sel = sel->tagHistory)) {
-                    if (relation == CSSSelector::Descendant || 
-                        relation == CSSSelector::Child) {
-                        // We encountered a descendant rule.  Get our document and set its
-                        // descendant rule flag to true.
-                        sawDescendantRule = true;
-                        StyleBaseImpl *b = this;
-                        StyleBaseImpl *root = this;
-                        while (b) {
-                            root = b;
-                            b = b->m_parent;
-                        }
-                    
-                        if (root && root->isStyleSheet()) {
-                            StyleSheetImpl *sheet = static_cast<StyleSheetImpl *>(root);
-                            if (sheet->ownerNode()) {
-                                DocumentImpl *doc = sheet->ownerNode()->getDocument();
-                                if (!doc->usesDescendantRules())
-                                    doc->setUsesDescendantRules(true);
-                            }
-                        }
-                        break;
-                    }
-                    relation = sel->relation;
-                }
-            }
-        }
-        else
-        {
-#ifdef CSS_DEBUG
-            kdDebug( 6080 ) << "invalid selector" << endl;
-#endif
-            // invalid selector, delete
-            delete slist;
-            return 0;
-        }
-        curP++;
-    }
-    return slist;
+    const char konq_rule[] = "@-konq-rule{";
+    int length = string.length() + 4 + strlen(konq_rule);
+    data = (unsigned short *)malloc( length *sizeof( unsigned short ) );
+    for ( unsigned int i = 0; i < strlen(konq_rule); i++ )
+	data[i] = konq_rule[i];
+    memcpy( data + strlen( konq_rule ), string.unicode(), string.length()*sizeof( unsigned short) );
+    // qDebug("parse string = '%s'", QConstString( (const QChar *)data, length ).string().latin1() );
+    data[length-1] = 0;
+    data[length-2] = 0;
+    data[length-3] = ' ';
+    data[length-4] = '}';
+    yy_hold_char = 0;
+    yyleng = 0;
+    yytext = yy_c_buf_p = data;
+    yy_hold_char = *yy_c_buf_p;
+
+
+    CSSParser *old = currentParser;
+    currentParser = this;
+    cssyyparse( this );
+    currentParser = old;
+    return rule;
 }
 
-
-void StyleBaseImpl::parseProperty(const QChar *curP, const QChar *endP)
+bool CSSParser::parseValue( DOM::CSSStyleDeclarationImpl *declaration, int _id, const DOM::DOMString &string,
+			    bool _important, bool _nonCSSHint )
 {
-    m_bnonCSSHint = false;
-    m_bImportant = false;
-    // Get rid of space in front of the declaration
-
-    curP = parseSpace(curP, endP);
-    if (!curP)
-        return;
-
-    // Search for the required colon or white space
-    const QChar *colon = parseToChar(curP, endP, ':', true);
-    if (!colon)
-        return;
-
-    const QString propName( curP, colon - curP );
 #ifdef CSS_DEBUG
-    kdDebug( 6080 ) << "Property-name = \"" << propName << "\"" << endl;
+    kdDebug( 6080 ) << "CSSParser::parseValue: id=" << _id << " important=" << _important
+		    << " nonCSSHint=" << _nonCSSHint << " value='" << string.string() << "'" << endl;
 #endif
 
-    // May have only reached white space before
-    if (*colon != ':')
-    {
-        // Search for the required colon
-        colon = parseToChar(curP, endP, ':', false);
-        if (!colon)
-            return;
-    }
-    curP = colon+1;
-    // remove space in front of the value
-    while(curP < endP && *curP == ' ')
-        curP++;
-    if ( curP >= endP )
-        return;
-
-    // search for !important
-    const QChar *exclam = parseToChar(curP, endP, '!', false);
-    if(exclam)
-    {
-        //const QChar *imp = parseSpace(exclam+1, endP);
-        QString s(exclam+1, endP - exclam - 1);
-        s = s.stripWhiteSpace();
-        s = s.lower();
-        if(s != "important")
-            return;
-        m_bImportant = true;
-        endP = exclam;
-#ifdef CSS_DEBUG
-        kdDebug( 6080 ) << "important property!" << endl;
-#endif
-    }
-
-    // remove space after the value;
-    while (endP > curP)
-    {
-        //if (!isspace(*(endP-1)))
-        if (!((endP-1)->isSpace()))
-            break;
-        endP--;
-    }
-
-#ifdef CSS_DEBUG
-    QString propVal( curP , endP - curP );
-    kdDebug( 6080 ) << "Property-value = \"" << propVal.latin1() << "\"" << endl;
-#endif
-
-    const struct props *propPtr = findProp(propName.lower().ascii(), propName.length());
-    if (!propPtr)
-    {
-#ifdef CSS_DEBUG
-        kdDebug( 6080 ) << "Unknown property" << propName << endl;
-#endif
-         return;
-    }
-
-    unsigned int numProps = m_propList->count();
-    if(!parseValue(curP, endP, propPtr->id)) {
-#ifdef CSS_DEBUG
-        kdDebug(6080) << "invalid property, removing added properties from m_propList" << endl;
-#endif
-        while(m_propList->count() > numProps)
-            m_propList->removeLast();
-    }
+    styleElement = declaration->stylesheet();
+
+    const char konq_value[] = "@-konq-value{";
+    int length = string.length() + 4 + strlen(konq_value);
+    data = (unsigned short *)malloc( length *sizeof( unsigned short ) );
+    for ( unsigned int i = 0; i < strlen(konq_value); i++ )
+	data[i] = konq_value[i];
+    memcpy( data + strlen( konq_value ), string.unicode(), string.length()*sizeof( unsigned short) );
+    data[length-1] = 0;
+    data[length-2] = 0;
+    data[length-3] = ' ';
+    data[length-4] = '}';
+    // qDebug("parse string = '%s'", QConstString( (const QChar *)data, length ).string().latin1() );
+    yy_hold_char = 0;
+    yyleng = 0;
+    yytext = yy_c_buf_p = data;
+    yy_hold_char = *yy_c_buf_p;
+
+    id = _id;
+    important = _important;
+    nonCSSHint = _nonCSSHint;
+
+    CSSParser *old = currentParser;
+    currentParser = this;
+    cssyyparse( this );
+    currentParser = old;
+
+    bool ok = false;
+    if ( numParsedProperties ) {
+	ok = true;
+	for ( int i = 0; i < numParsedProperties; i++ ) {
+	    declaration->removeProperty(parsedProperties[i]->m_id, nonCSSHint);
+	    declaration->values()->append( parsedProperties[i] );
+	}
+	numParsedProperties = 0;
+    }
+
+    return ok;
 }
 
-QPtrList<CSSProperty> *StyleBaseImpl::parseProperties(const QChar *curP, const QChar *endP)
+bool CSSParser::parseDeclaration( DOM::CSSStyleDeclarationImpl *declaration, const DOM::DOMString &string,
+				  bool _nonCSSHint )
 {
-    m_propList = new QPtrList<CSSProperty>;
-    m_propList->setAutoDelete(true);
-    while (curP < endP)
-    {
-        const QChar *startP = curP;
-        curP = parseToChar(curP, endP, ';', false);
-        if (!curP)
-            curP = endP;
-
 #ifdef CSS_DEBUG
-        QString propVal( startP , curP - startP );
-        kdDebug( 6080 ) << "Property = \"" << propVal.latin1() << "\"" << endl;
+    kdDebug( 6080 ) << "CSSParser::parseDeclaration: nonCSSHint=" << nonCSSHint
+		    << " value='" << string.string() << "'" << endl;
 #endif
 
-        parseProperty(startP, curP);
-        curP++;
-    }
-    if(!m_propList->isEmpty()) {
-        return m_propList;
-    } else {
-#ifdef CSS_DEBUG
-        kdDebug( 6080 ) << "empty property list" << endl;
-#endif
-        delete m_propList;
-        return 0;
-    }
+    styleElement = declaration->stylesheet();
+
+    const char konq_decls[] = "@-konq-decls{";
+    int length = string.length() + 4 + strlen(konq_decls);
+    data = (unsigned short *)malloc( length *sizeof( unsigned short ) );
+    for ( unsigned int i = 0; i < strlen(konq_decls); i++ )
+	data[i] = konq_decls[i];
+    memcpy( data + strlen( konq_decls ), string.unicode(), string.length()*sizeof( unsigned short) );
+    data[length-1] = 0;
+    data[length-2] = 0;
+    data[length-3] = ' ';
+    data[length-4] = '}';
+    // qDebug("parse string = '%s'", QConstString( (const QChar *)data, length ).string().latin1() );
+    yy_hold_char = 0;
+    yyleng = 0;
+    yytext = yy_c_buf_p = data;
+    yy_hold_char = *yy_c_buf_p;
+
+    nonCSSHint = _nonCSSHint;
+
+    CSSParser *old = currentParser;
+    currentParser = this;
+    cssyyparse( this );
+    currentParser = old;
+
+    bool ok = false;
+    if ( numParsedProperties ) {
+	ok = true;
+	for ( int i = 0; i < numParsedProperties; i++ ) {
+	    declaration->removeProperty(parsedProperties[i]->m_id, false);
+	    declaration->values()->append( parsedProperties[i] );
+	}
+	numParsedProperties = 0;
+    }
+
+    return ok;
 }
 
-static const QChar *getNext( const QChar *curP, const QChar *endP, bool &last )
+void CSSParser::addProperty( int propId, CSSValueImpl *value, bool important )
 {
-    last = false;
-    const QChar *nextP = curP;
-    bool ignoreSpace = false;
-    while(nextP < endP) {
-	if ( *nextP == '(' ) {
-	    ignoreSpace = true;
-	} else if ( *nextP == ')' ) {
-	    ignoreSpace = false;
-	}
-	if ( *nextP == ' ' && !ignoreSpace )
-            return nextP;
-	if ( *nextP == ';')
-            break;
-	nextP++;
-    }
-    last = true;
-    return nextP;
-}
-// ------------------- begin font property ---------------------
-/*
-  Parser for the font property of CSS.  See
-  http://www.w3.org/TR/REC-CSS2/fonts.html#propdef-font for details.
-
-  Written by Jasmin Blanchette (jasmin at trolltech.com) on 2000-08-16.
-*/
-
-class FontParser {
-public:
-    enum { TOK_NONE, TOK_EOI, TOK_SLASH, TOK_COMMA, TOK_STRING, TOK_SYMBOL };
-
-    QChar m_yyChar;
-    QString m_yyIn, m_yyStr;
-    unsigned int m_yyPos;
-    int m_yyTok;
-    bool strictParsing;
-
-    QChar getChar() {
-      return ( m_yyPos == m_yyIn.length() ) ? QChar('\0') : m_yyIn.at(m_yyPos++);
-    }
-
-    void startTokenizer( const QString& str, bool _strictParsing ) {
-      m_yyIn = str.simplifyWhiteSpace();
-#ifdef CSS_DEBUG
-      kdDebug( 6080 ) << "startTokenizer: [" << m_yyIn << "]" << endl;
-#endif
-      m_yyPos = 0;
-      m_yyChar = getChar();
-      strictParsing = _strictParsing;
-      m_yyTok = TOK_NONE;
-    }
-
-    int getToken();
-
-    bool match( int tok )
-    {
-      if ( m_yyTok == tok ) {
-	m_yyTok = getToken();
-	return true;
-      }
-      return false;
-    }
-
-    bool matchFontStyle( QString *fstyle )
-    {
-      if ( m_yyTok == TOK_SYMBOL ) {
-	const struct css_value *cssval = findValue(m_yyStr.latin1(), m_yyStr.length());
-	if (cssval) {
-	  int id = cssval->id;
-	  if ( id == CSS_VAL_NORMAL || id == CSS_VAL_ITALIC ||
-	       id == CSS_VAL_OBLIQUE || id == CSS_VAL_INHERIT ) {
-	    *fstyle = m_yyStr;
-	    m_yyTok = getToken();
-	    return true;
-	  }
-	}
-      }
-      return false;
-    }
-
-    bool matchFontVariant( QString *fvariant )
-    {
-      if ( m_yyTok == TOK_SYMBOL ) {
-	const struct css_value *cssval = findValue(m_yyStr.latin1(), m_yyStr.length());
-	if (cssval) {
-	  int id = cssval->id;
-	  if (id == CSS_VAL_NORMAL || id == CSS_VAL_SMALL_CAPS || id == CSS_VAL_INHERIT) {
-	    *fvariant = m_yyStr;
-	    m_yyTok = getToken();
-	    return true;
-	  }
-        }
-      }
-      return false;
-    }
-
-    bool matchFontWeight( QString *fweight )
-    {
-      if ( m_yyTok == TOK_SYMBOL ) {
-	const struct css_value *cssval = findValue(m_yyStr.latin1(), m_yyStr.length());
-	if (cssval) {
-	  int id = cssval->id;
-	  if ((id >= CSS_VAL_NORMAL && id <= CSS_VAL_900) || id == CSS_VAL_INHERIT ) {
-	    *fweight = m_yyStr;
-	    m_yyTok = getToken();
-	    return true;
-	  }
-	}
-      }
-      return false ;
-    }
-
-    bool matchFontSize( QString *fsize )
-    {
-      if ( m_yyTok == TOK_SYMBOL ) {
-	*fsize = m_yyStr;
-	m_yyTok = getToken();
-	return true;
-      }
-      return false;
-    }
-
-    bool matchLineHeight( QString *lheight )
-    {
-      if ( m_yyTok == TOK_SYMBOL ) {
-	*lheight = m_yyStr;
-	m_yyTok = getToken();
-	return true;
-      }
-      return false;
-    }
+    CSSProperty *prop = new CSSProperty;
+    prop->m_id = propId;
+    prop->setValue( value );
+    prop->m_bImportant = important;
+    prop->nonCSSHint = nonCSSHint;
 
-    bool matchNameFamily( QString *ffamily )
-    {
-#ifdef CSS_DEBUG
-      kdDebug( 6080 ) << "matchNameFamily: [" << *ffamily << "]" << endl;
-#endif
-      bool matched = false;
-      if ( m_yyTok == TOK_SYMBOL || ( m_yyTok == TOK_STRING && !strictParsing ) ) {
-	// accept quoted "serif" only in non strict mode.
-	*ffamily = m_yyStr;
-	// unquoted courier new should return courier new
-	while( (m_yyTok = getToken()) == TOK_SYMBOL ) {
-	  *ffamily += " " + m_yyStr;
-	}
-	matched = true;
-      } else if ( m_yyTok == TOK_STRING ) {
-          //  kdDebug( 6080 ) << "[" << m_yyStr << "]" << endl;
-	const struct css_value *cssval = findValue(m_yyStr.latin1(), m_yyStr.length());
-	if (!cssval || !(cssval->id >= CSS_VAL_SERIF && cssval->id <= CSS_VAL_MONOSPACE)) {
-	  *ffamily = m_yyStr;
-	  m_yyTok = getToken();
-	  matched = true;
-	}
-      }
-      return matched;
+    if ( numParsedProperties >= maxParsedProperties ) {
+	maxParsedProperties += 32;
+	parsedProperties = (CSSProperty **) realloc( parsedProperties,
+						    maxParsedProperties*sizeof( CSSProperty * ) );
     }
+    parsedProperties[numParsedProperties++] = prop;
+}
 
-    bool matchFontFamily( QString *ffamily )
-    {
-#ifdef CSS_DEBUG
-    kdDebug( 6080 ) << "matchFontFamily: [" << *ffamily << "]" << endl;
-#endif
-      QStringList t;
-      if ( !matchFontFamily( &t ) )
-	return false;
+CSSStyleDeclarationImpl *CSSParser::createStyleDeclaration( CSSStyleRuleImpl *rule )
+{
+    QPtrList<CSSProperty> *propList = new QPtrList<CSSProperty>;
+    propList->setAutoDelete( true );
+    for ( int i = 0; i < numParsedProperties; i++ )
+	propList->append( parsedProperties[i] );
 
-      *ffamily = t.join(", ");
-      return TRUE;
-    }
+    numParsedProperties = 0;
+    return new CSSStyleDeclarationImpl(rule, propList);
+}
 
-    bool matchFontFamily ( QStringList *ffamily );
-    bool matchRealFont( QString *fstyle, QString *fvariant, QString *fweight,
-			QString *fsize, QString *lheight, QString *ffamily );
-};
+void CSSParser::clearProperties()
+{
+    for ( int i = 0; i < numParsedProperties; i++ )
+	delete parsedProperties[i];
+    numParsedProperties = 0;
+}
 
-int FontParser::getToken()
+DOM::DocumentImpl *CSSParser::document() const
 {
-    m_yyStr = QString::null;
-
-    if ( m_yyChar == '\0' )
-	return TOK_EOI;
-    if ( m_yyChar == ' ' )
-	m_yyChar = getChar();
-
-    if ( m_yyChar == '/' ) {
-	m_yyChar = getChar();
-	return TOK_SLASH;
-    } else if ( m_yyChar == ',' ) {
-	m_yyChar = getChar();
-	return TOK_COMMA;
-    } else if ( m_yyChar == '"' ) {
-	m_yyChar = getChar();
-	while ( m_yyChar != '"' && m_yyChar != '\0' ) {
-	    m_yyStr += m_yyChar;
-	    m_yyChar = getChar();
-	}
-	m_yyChar = getChar();
-	return TOK_STRING;
-    } else if ( m_yyChar == '\'' ) {
-	m_yyChar = getChar();
-	while ( m_yyChar != '\'' && m_yyChar != '\0' ) {
-	    m_yyStr += m_yyChar;
-	    m_yyChar = getChar();
-	}
-	m_yyChar = getChar();
-	return TOK_STRING;
-    } else {
-	while ( m_yyChar != '/' && m_yyChar != ',' && m_yyChar != '\0' && m_yyChar != ' ') {
-	    m_yyStr += m_yyChar;
-	    m_yyChar = getChar();
-	}
-	return TOK_SYMBOL;
-    }
+    StyleBaseImpl *root = styleElement;
+    DocumentImpl *doc = 0;
+    while (root->parent())
+	root = root->parent();
+    if (root->isCSSStyleSheet())
+	doc = static_cast<CSSStyleSheetImpl*>(root)->doc();
+    return doc;
 }
 
 
-bool FontParser::matchFontFamily ( QStringList *ffamily )
+// defines units allowed for a certain property, used in parseUnit
+enum Units
 {
-      if ( m_yyTok == TOK_NONE )
-	m_yyTok = getToken();
-#if 0
-      // ###
-      if ( m_yyTok == TOK_STRING && m_yyStr == "inherit" ) {
-	ffamily->clear();
-	m_yyTok = getToken();
-	return TRUE;
-      }
-#endif
+    FUnknown   = 0x0000,
+    FInteger   = 0x0001,
+    FNumber    = 0x0002,  // Real Numbers
+    FPercent   = 0x0004,
+    FLength    = 0x0008,
+    FAngle     = 0x0010,
+    FTime      = 0x0020,
+    FFrequency = 0x0040,
+    FRelative  = 0x0100,
+    FNonNeg    = 0x0200
+};
 
-      QString name;
-      do {
-	if ( !matchNameFamily(&name) )
-	  return FALSE;
-	ffamily->append( name );
-      } while ( match(TOK_COMMA) );
+static bool validUnit( Value *value, int unitflags, bool strict )
+{
+    if ( unitflags & FNonNeg && value->fValue < 0 )
+	return false;
 
-      return true;
+    bool b = false;
+    switch( value->unit ) {
+    case CSSPrimitiveValue::CSS_NUMBER:
+	b = (unitflags & FNumber);
+	if ( !b && ( (unitflags & FLength) && (value->fValue == 0 || !strict ) ) ) {
+	    value->unit = CSSPrimitiveValue::CSS_PX;
+	    b = true;
+	}
+	if ( !b && ( unitflags & FInteger ) &&
+	     (value->fValue - (int)value->fValue) < 0.001 )
+	    b = true;
+	break;
+    case CSSPrimitiveValue::CSS_PERCENTAGE:
+	b = (unitflags & FPercent);
+	break;
+    case Value::Q_EMS:
+    case CSSPrimitiveValue::CSS_EMS:
+    case CSSPrimitiveValue::CSS_EXS:
+    case CSSPrimitiveValue::CSS_PX:
+    case CSSPrimitiveValue::CSS_CM:
+    case CSSPrimitiveValue::CSS_MM:
+    case CSSPrimitiveValue::CSS_IN:
+    case CSSPrimitiveValue::CSS_PT:
+    case CSSPrimitiveValue::CSS_PC:
+	b = (unitflags & FLength);
+	break;
+    case CSSPrimitiveValue::CSS_DEG:
+    case CSSPrimitiveValue::CSS_RAD:
+    case CSSPrimitiveValue::CSS_GRAD:
+    case CSSPrimitiveValue::CSS_MS:
+    case CSSPrimitiveValue::CSS_S:
+    case CSSPrimitiveValue::CSS_HZ:
+    case CSSPrimitiveValue::CSS_KHZ:
+    case CSSPrimitiveValue::CSS_DIMENSION:
+    default:
+	break;
+    }
+    return b;
 }
 
-bool FontParser::matchRealFont( QString *fstyle, QString *fvariant, QString *fweight,
-			QString *fsize, QString *lheight, QString *ffamily )
+bool CSSParser::parseValue( int propId, bool important )
 {
-      bool metFstyle = matchFontStyle( fstyle );
-      bool metFvariant = matchFontVariant( fvariant );
-      matchFontWeight( fweight );
-      if ( !metFstyle )
-	metFstyle = matchFontStyle( fstyle );
-      if ( !metFvariant )
-	matchFontVariant( fvariant );
-      if ( !metFstyle )
-	matchFontStyle( fstyle );
-
-      if ( !matchFontSize(fsize) )
-	return FALSE;
-      if ( match(TOK_SLASH) ) {
-	if ( !matchLineHeight(lheight) )
-	  return FALSE;
-      }
-      if ( !matchFontFamily(ffamily) )
-	return FALSE;
-      return true;
-}
+    if ( !valueList ) return false;
 
-bool StyleBaseImpl::parseFont(const QChar *curP, const QChar *endP)
-{
-  QString str( curP, endP - curP );
-  QString fstyle, fvariant, fweight, fsize, lheight, ffamily;
-
-  FontParser fontParser;
-  fontParser.startTokenizer( str, strictParsing );
-
-  //kdDebug( 6080 ) << str << endl;
-  const struct css_value *cssval = findValue(fontParser.m_yyIn.latin1(), fontParser.m_yyIn.length());
-
-  if (cssval) {
-      //kdDebug( 6080 ) << "System fonts requested: [" << str << "]" << endl;
-    QFont sysFont;
-    switch (cssval->id) {
-    case CSS_VAL_MENU:
-      sysFont = KGlobalSettings::menuFont();
-      break;
-    case CSS_VAL_CAPTION:
-      sysFont = KGlobalSettings::windowTitleFont();
-      break;
-    case CSS_VAL_STATUS_BAR:
-    case CSS_VAL_ICON:
-    case CSS_VAL_MESSAGE_BOX:
-    case CSS_VAL_SMALL_CAPTION:
-    default:
-      sysFont = KGlobalSettings::generalFont();
-      break;
-    }
-    if (sysFont.italic()) {
-      fstyle = "italic";
-    } else {
-      fstyle = "normal";
-    }
-    if (sysFont.bold()) {
-      fweight = "bold";
-    } else {
-      fweight = "normal";
-    }
-    fsize = QString::number( sysFont.pixelSize() ) + "px";
-    ffamily = sysFont.family();
+    Value *value = valueList->current();
 
-  } else {
-    fontParser.m_yyTok = fontParser.getToken();
-    if (!(fontParser.matchRealFont(&fstyle, &fvariant, &fweight, &fsize, &lheight, &ffamily)))
-      {
+    if ( !value )
 	return false;
-      }
-  }
-//   kdDebug(6080) << "[" << fstyle << "] [" << fvariant << "] [" << fweight << "] ["
-//   		<< fsize << "] / [" << lheight << "] [" << ffamily << "]" << endl;
-
-  if(!fstyle.isNull())
-    parseValue(fstyle.unicode(), fstyle.unicode()+fstyle.length(), CSS_PROP_FONT_STYLE);
-  if(!fvariant.isNull())
-    parseValue(fvariant.unicode(), fvariant.unicode()+fvariant.length(), CSS_PROP_FONT_VARIANT);
-  if(!fweight.isNull())
-    parseValue(fweight.unicode(), fweight.unicode()+fweight.length(), CSS_PROP_FONT_WEIGHT);
-  if(!fsize.isNull())
-    parseValue(fsize.unicode(), fsize.unicode()+fsize.length(), CSS_PROP_FONT_SIZE);
-  if(!lheight.isNull())
-    parseValue(lheight.unicode(), lheight.unicode()+lheight.length(), CSS_PROP_LINE_HEIGHT);
-  if(!ffamily.isNull())
-    parseValue(ffamily.unicode(), ffamily.unicode()+ffamily.length(), CSS_PROP_FONT_FAMILY);
-  return true;
-}
 
-// ---------------- end font property --------------------------
+    int id = 0;
+    id = value->id;
 
-bool StyleBaseImpl::parseValue( const QChar *curP, const QChar *endP, int propId,
-                                bool important, bool nonCSSHint, QPtrList<CSSProperty> *propList)
-{
-  m_bImportant = important;
-  m_bnonCSSHint = nonCSSHint;
-  m_propList = propList;
-  return parseValue(curP, endP, propId);
-}
+    if ( id == CSS_VAL_INHERIT ) {
+	addProperty( propId, new CSSInheritedValueImpl(), important );
+	return true;
+    }
 
-bool StyleBaseImpl::parseValue( const QChar *curP, const QChar *endP, int propId)
-{
-  if (curP==endP) {return 0; /* e.g.: width="" */}
+    bool valid_primitive = false;
+    CSSValueImpl *parsedValue = 0;
 
-  QString value = QConstString(curP, endP - curP).string().lower().stripWhiteSpace();
-#ifdef CSS_DEBUG
-  kdDebug( 6080 ) << "id [" << getPropertyName(propId).string() << "] parseValue [" << value << "]" << endl;
-#endif
-  int len = value.length();
-  const char *val = value.latin1();
-
-  CSSValueImpl *parsedValue = 0;
-
-  // We are using this so often
-  const struct css_value *cssval = findValue(val, len);
-  if (cssval && cssval->id == CSS_VAL_INHERIT) {
-    parsedValue = new CSSInheritedValueImpl(); // inherited value
-  } else {
-    switch(propId)
-      {
+    switch(propId) {
 	/* The comment to the left defines all valid value of this properties as defined
-     * in CSS 2, Appendix F. Property index
-     */
+	 * in CSS 2, Appendix F. Property index
+	 */
 
 	/* All the CSS properties are not supported by the renderer at the moment.
 	 * Note that all the CSS2 Aural properties are only checked, if CSS_AURAL is defined
 	 * (see parseAuralValues). As we don't support them at all this seems reasonable.
 	 */
 
-      case CSS_PROP_SIZE:                 // <length>{1,2} | auto | portrait | landscape | inherit
-      case CSS_PROP_QUOTES:               // [<string> <string>]+ | none | inherit
-      case CSS_PROP_TEXT_SHADOW:          // none | [<color> || <length> <length> <length>? ,]*
-	//    [<color> || <length> <length> <length>?] | inherit
-
-      case CSS_PROP_UNICODE_BIDI:         // normal | embed | bidi-override | inherit
-      case CSS_PROP_WHITE_SPACE:          // normal | pre | nowrap | -konq-nowrap | inherit
-      case CSS_PROP_FONT_STRETCH:
-        // normal | wider | narrower | ultra-condensed | extra-condensed | condensed |
-        // semi-condensed |  semi-expanded | expanded | extra-expanded | ultra-expanded |
-        // inherit
-      case CSS_PROP_PAGE:                 // <identifier> | auto // ### CHECK
-      case CSS_PROP_PAGE_BREAK_AFTER:     // auto | always | avoid | left | right | inherit
-      case CSS_PROP_PAGE_BREAK_BEFORE:    // auto | always | avoid | left | right | inherit
-      case CSS_PROP_PAGE_BREAK_INSIDE:    // avoid | auto | inherit
-      case CSS_PROP_POSITION:             // static | relative | absolute | fixed | inherit
-      case CSS_PROP_EMPTY_CELLS:          // show | hide | inherit
-      case CSS_PROP_TABLE_LAYOUT:         // auto | fixed | inherit
-	{
-	  const struct css_value *cssval = findValue(val, len);
-	  if (cssval)
-	    {
-	      parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-	    }
-	  // ### To be done
-	  break;
-	}
-
-      case CSS_PROP_CONTENT:              // [ <string> | <uri> | <counter> | attr(X) | open-quote |
+    case CSS_PROP_SIZE:                 // <length>{1,2} | auto | portrait | landscape | inherit
+    case CSS_PROP_QUOTES:               // [<string> <string>]+ | none | inherit
+//     case CSS_PROP_PAGE:                 // <identifier> | auto // ### CHECK
+	// ### To be done
+	if (id)
+	    valid_primitive = true;
+	break;
+    case CSS_PROP_UNICODE_BIDI:         // normal | embed | bidi-override | inherit
+	if ( id == CSS_VAL_NORMAL ||
+	     id == CSS_VAL_EMBED ||
+	     id == CSS_VAL_BIDI_OVERRIDE )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_POSITION:             // static | relative | absolute | fixed | inherit
+	if ( id == CSS_VAL_STATIC ||
+	     id == CSS_VAL_RELATIVE ||
+	     id == CSS_VAL_ABSOLUTE ||
+ 	     id == CSS_VAL_FIXED )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_PAGE_BREAK_AFTER:     // auto | always | avoid | left | right | inherit
+    case CSS_PROP_PAGE_BREAK_BEFORE:    // auto | always | avoid | left | right | inherit
+	if ( id == CSS_VAL_AUTO ||
+	     id == CSS_VAL_ALWAYS ||
+	     id == CSS_VAL_AVOID ||
+ 	     id == CSS_VAL_LEFT ||
+ 	     id == CSS_VAL_RIGHT )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_PAGE_BREAK_INSIDE:    // avoid | auto | inherit
+	if ( id == CSS_VAL_AUTO ||
+	     id == CSS_VAL_AVOID )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_EMPTY_CELLS:          // show | hide | inherit
+	if ( id == CSS_VAL_SHOW ||
+	     id == CSS_VAL_HIDE )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_CONTENT:              // [ <string> | <uri> | <counter> | attr(X) | open-quote |
 	// close-quote | no-open-quote | no-close-quote ]+ | inherit
-        {
-            parsedValue = parseContent(curP,endP);
-        }
+        return parseContent( propId, important );
+        break;
 
-      case CSS_PROP_CLIP:                 // <shape> | auto | inherit
-      {
-	  int i;
-	  if ( cssval && cssval->id == CSS_VAL_AUTO )
-	      parsedValue = new CSSPrimitiveValueImpl( cssval->id );
-	  else {
-	      // only shape in CSS2 is rect( top right bottom left )
-	      QString str(curP, endP - curP);
-	      // the CSS specs are not really clear if there should be commas in here or not. We accept both spaces and commas.
-	      QChar *uc = (QChar *)str.unicode();
-	      int len = str.length();
-	      while( len ) {
-		  if ( *uc == ',' )
-		      *uc = ' ';
-		  uc++;
-		  len--;
-	      }
-	      str = str.simplifyWhiteSpace();
-	      if ( str.find( "rect", 0, false ) != 0 )
-		  break;
-	      int pos = str.find( '(', 4 );
-	      int end = str.findRev( ')' );
-	      if ( end <= pos )
-		  break;
-	      str = str.mid( pos + 1, end - pos - 1 );
-	      str = str.simplifyWhiteSpace();
-	      str += " ";
-	      //qDebug("rect = '%s'", str.latin1() );
-
-	      pos = 0;
-	      RectImpl *rect = new RectImpl();
-	      for ( i = 0; i < 4; i++ ) {
-		  int space;
-		  space = str.find( ' ', pos );
-		  const QChar *start = str.unicode() + pos;
-		  const QChar *end = str.unicode() + space;
-		  //qDebug("part: from=%d, to=%d", pos, space );
-		  if ( start >= end )
-		      goto cleanup;
-		  CSSPrimitiveValueImpl *length = 0;
-		  if ( str.find( "auto", pos, FALSE ) == pos )
-		      length = new CSSPrimitiveValueImpl( CSS_VAL_AUTO );
-		  else
-		      length = parseUnit( start, end, LENGTH );
-		  if ( !length )
-		      goto cleanup;
-		  switch ( i ) {
-		      case 0:
-			  rect->setTop( length );
-			  break;
-		      case 1:
-			  rect->setRight( length );
-			  break;
-		      case 2:
-			  rect->setBottom( length );
-			  break;
-		      case 3:
-			  rect->setLeft( length );
-			  break;
-		  }
-		  pos = space + 1;
-	      }
-	      parsedValue = new CSSPrimitiveValueImpl( rect );
-	      //qDebug(" passed rectangle parsing");
-	      break;
-
-	  cleanup:
-	      //qDebug(" rectangle parsing failed, i=%d", i);
-	      delete rect;
-	  }
-	  break;
-      }
-
-      /* Start of supported CSS properties with validation. This is needed for parseShortHand to work
-       * correctly and allows optimization in khtml::applyRule(..)
-       */
-      case CSS_PROP_CAPTION_SIDE:         // top | bottom | left | right | inherit
-	{
-	  if (cssval) {
-	    int id = cssval->id;
-	    if (id == CSS_VAL_LEFT || id == CSS_VAL_RIGHT || id == CSS_VAL_TOP || id == CSS_VAL_BOTTOM) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	    }
-	  }
-	  break;
-	}
-      case CSS_PROP_BORDER_COLLAPSE:      // collapse | separate | inherit
-	{
-	  if (cssval) {
-	    int id = cssval->id;
-	    if ( id == CSS_VAL_COLLAPSE || id == CSS_VAL_SEPARATE ) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	    }
-	  }
-	  break;
-	}
-      case CSS_PROP_VISIBILITY:           // visible | hidden | collapse | inherit
-	{
-	  if (cssval) {
-	    int id = cssval->id;
-	    if (id == CSS_VAL_VISIBLE || id == CSS_VAL_HIDDEN || id == CSS_VAL_COLLAPSE) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	    }
-	  }
-	  break;
-	}
-      case CSS_PROP_OVERFLOW:             // visible | hidden | scroll | auto | inherit
-	{
-	  if (cssval) {
-	    int id = cssval->id;
-	    if ( id == CSS_VAL_VISIBLE || id == CSS_VAL_HIDDEN || id == CSS_VAL_SCROLL || id == CSS_VAL_AUTO ) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	    }
-	  }
-	  break;
-	}
-      case CSS_PROP_LIST_STYLE_POSITION:  // inside | outside | inherit
-	{
-	  if (cssval) {
-	    int id = cssval->id;
-	    if ( id == CSS_VAL_INSIDE || id == CSS_VAL_OUTSIDE ) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	    }
-	  }
-	  break;
-	}
-      case CSS_PROP_LIST_STYLE_TYPE:
+    case CSS_PROP_WHITE_SPACE:          // normal | pre | nowrap | inherit
+	if ( id == CSS_VAL_NORMAL ||
+	     id == CSS_VAL_PRE ||
+	     id == CSS_VAL_NOWRAP )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_CLIP:                 // <shape> | auto | inherit
+	if ( id == CSS_VAL_AUTO )
+	    valid_primitive = true;
+	else if ( value->unit == Value::Function )
+	    return parseShape( propId, important );
+	break;
+
+    /* Start of supported CSS properties with validation. This is needed for parseShortHand to work
+     * correctly and allows optimization in khtml::applyRule(..)
+     */
+    case CSS_PROP_CAPTION_SIDE:         // top | bottom | left | right | inherit
+	if (id == CSS_VAL_LEFT || id == CSS_VAL_RIGHT ||
+	    id == CSS_VAL_TOP || id == CSS_VAL_BOTTOM)
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_BORDER_COLLAPSE:      // collapse | separate | inherit
+	if ( id == CSS_VAL_COLLAPSE || id == CSS_VAL_SEPARATE )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_VISIBILITY:           // visible | hidden | collapse | inherit
+	if (id == CSS_VAL_VISIBLE || id == CSS_VAL_HIDDEN || id == CSS_VAL_COLLAPSE)
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_OVERFLOW:             // visible | hidden | scroll | auto | inherit
+	if ( id == CSS_VAL_VISIBLE || id == CSS_VAL_HIDDEN || id == CSS_VAL_SCROLL || id == CSS_VAL_AUTO )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_LIST_STYLE_POSITION:  // inside | outside | inherit
+	if ( id == CSS_VAL_INSIDE || id == CSS_VAL_OUTSIDE )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_LIST_STYLE_TYPE:
         // disc | circle | square | decimal | decimal-leading-zero | lower-roman |
         // upper-roman | lower-greek | lower-alpha | lower-latin | upper-alpha |
         // upper-latin | hebrew | armenian | georgian | cjk-ideographic | hiragana |
         // katakana | hiragana-iroha | katakana-iroha | none | inherit
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if ((id >= CSS_VAL_DISC && id <= CSS_VAL_KATAKANA_IROHA) || id == CSS_VAL_NONE) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-            }
-	  }
-	  break;
-	}
-      case CSS_PROP_DISPLAY:
-        // inline | block | list-item | run-in | compact | -konq-ruler | marker | table |
+	if ((id >= CSS_VAL_DISC && id <= CSS_VAL_KATAKANA_IROHA) || id == CSS_VAL_NONE)
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_DISPLAY:
+        // inline | block | list-item | run-in | inline-block | -konq-ruler | table |
         // inline-table | table-row-group | table-header-group | table-footer-group | table-row |
         // table-column-group | table-column | table-cell | table-caption | none | inherit
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if ((id >= CSS_VAL_INLINE && id <= CSS_VAL_TABLE_CAPTION) || id == CSS_VAL_NONE) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-            }
-	  }
-	  break;
-	}
-      case CSS_PROP_DIRECTION:            // ltr | rtl | inherit
-	{
-	  if (cssval) {
-	    int id = cssval->id;
-	    if ( id == CSS_VAL_LTR || id == CSS_VAL_RTL ) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	    }
-	  }
-	  break;
-	}
-      case CSS_PROP_TEXT_TRANSFORM:       // capitalize | uppercase | lowercase | none | inherit
-	{
-	  if (cssval) {
-	    int id = cssval->id;
-	    if ((id >= CSS_VAL_CAPITALIZE && id <= CSS_VAL_LOWERCASE) || id == CSS_VAL_NONE) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	    }
-	  }
-	  break;
-	}
-      case CSS_PROP_FLOAT:                // left | right | none | inherit + center for buggy CSS
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if (id == CSS_VAL_LEFT || id == CSS_VAL_RIGHT
-		|| id == CSS_VAL_NONE || id == CSS_VAL_CENTER) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	    }
-	  }
-	  break;
-	}
-      case CSS_PROP_CLEAR:                // none | left | right | both | inherit
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if (id == CSS_VAL_NONE || id == CSS_VAL_LEFT
-		|| id == CSS_VAL_RIGHT|| id == CSS_VAL_BOTH) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	    }
-	  }
-	  break;
-	}
-      case CSS_PROP_TEXT_ALIGN:
+	if ((id >= CSS_VAL_INLINE && id <= CSS_VAL_TABLE_CAPTION) || id == CSS_VAL_NONE)
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_DIRECTION:            // ltr | rtl | inherit
+	if ( id == CSS_VAL_LTR || id == CSS_VAL_RTL )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_TEXT_TRANSFORM:       // capitalize | uppercase | lowercase | none | inherit
+	if ((id >= CSS_VAL_CAPITALIZE && id <= CSS_VAL_LOWERCASE) || id == CSS_VAL_NONE)
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_FLOAT:                // left | right | none | inherit + center for buggy CSS
+	if ( id == CSS_VAL_LEFT || id == CSS_VAL_RIGHT ||
+	     id == CSS_VAL_NONE || id == CSS_VAL_CENTER)
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_CLEAR:                // none | left | right | both | inherit
+	if ( id == CSS_VAL_NONE || id == CSS_VAL_LEFT ||
+	     id == CSS_VAL_RIGHT|| id == CSS_VAL_BOTH)
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_TEXT_ALIGN:
     	// left | right | center | justify | konq_center | <string> | inherit
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if (id >= CSS_VAL__KONQ_AUTO && id <= CSS_VAL__KONQ_CENTER) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	      break;
-            }
-	  } else {
-            parsedValue = new CSSPrimitiveValueImpl(DOMString(curP, endP - curP),
-			                            CSSPrimitiveValue::CSS_STRING);
-	  }
-	  break;
-	}
-      case CSS_PROP_OUTLINE_STYLE:        // <border-style> | inherit
-      case CSS_PROP_BORDER_TOP_STYLE:     //// <border-style> | inherit
-      case CSS_PROP_BORDER_RIGHT_STYLE:   //   Defined as:    none | hidden | dotted | dashed |
-      case CSS_PROP_BORDER_BOTTOM_STYLE:  //   solid | double | groove | ridge | inset | outset
-      case CSS_PROP_BORDER_LEFT_STYLE:    ////
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if (id >= CSS_VAL_NONE && id <= CSS_VAL_RIDGE) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-            }
-	  }
-	  break;
-	}
-      case CSS_PROP_FONT_WEIGHT:  // normal | bold | bolder | lighter | 100 | 200 | 300 | 400 |
+	if ( ( id >= CSS_VAL__KONQ_AUTO && id <= CSS_VAL__KONQ_CENTER ) ||
+	     value->unit == CSSPrimitiveValue::CSS_STRING )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_OUTLINE_STYLE:        // <border-style> | inherit
+    case CSS_PROP_BORDER_TOP_STYLE:     //// <border-style> | inherit
+    case CSS_PROP_BORDER_RIGHT_STYLE:   //   Defined as:    none | hidden | dotted | dashed |
+    case CSS_PROP_BORDER_BOTTOM_STYLE:  //   solid | double | groove | ridge | inset | outset
+    case CSS_PROP_BORDER_LEFT_STYLE:    ////
+	if (id >= CSS_VAL_NONE && id <= CSS_VAL_RIDGE)
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_FONT_WEIGHT:  // normal | bold | bolder | lighter | 100 | 200 | 300 | 400 |
 	// 500 | 600 | 700 | 800 | 900 | inherit
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if (id) {
-	      if (id >= CSS_VAL_NORMAL && id <= CSS_VAL_LIGHTER) {
-		// Allready correct id
-	      } else if (id >= CSS_VAL_100 && id <= CSS_VAL_500) {
-		id = CSS_VAL_NORMAL;
-	      } else if (id >= CSS_VAL_600 && id <= CSS_VAL_900) {
-		id = CSS_VAL_BOLD;
-	      }
-	      parsedValue = new CSSPrimitiveValueImpl(id);
+	if (id >= CSS_VAL_NORMAL && id <= CSS_VAL_900) {
+	    // Allready correct id
+	    valid_primitive = true;
+	} else if ( validUnit( value, FInteger|FNonNeg, false ) ) {
+	    int weight = (int)value->fValue;
+	    if ( (weight % 100) )
+		break;
+	    weight /= 100;
+	    if ( weight >= 1 && weight <= 9 ) {
+		id = CSS_VAL_100 + weight - 1;
+		valid_primitive = true;
 	    }
-	  }
-	  break;
 	}
-      case CSS_PROP_BACKGROUND_REPEAT:    // repeat | repeat-x | repeat-y | no-repeat | inherit
-	{
-#ifdef CSS_DEBUG_BCKGR
-	  kdDebug( 6080 ) << "CSS_PROP_BACKGROUND_REPEAT: " << val << endl;
-#endif
-	  if (cssval) {
-            int id = cssval->id;
-            if ( id >= CSS_VAL_REPEAT && id <= CSS_VAL_NO_REPEAT ) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-            }
-	  }
-	  break;
-	}
-      case CSS_PROP_BACKGROUND_ATTACHMENT: // scroll | fixed
-	{
-#ifdef CSS_DEBUG_BCKGR
-	  kdDebug( 6080 ) << "CSS_PROP_BACKGROUND_ATTACHEMENT: " << val << endl;
-#endif
-	  if (cssval) {
-            int id = cssval->id;
-            if ( id == CSS_VAL_SCROLL || id == CSS_VAL_FIXED ) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-            }
-	  }
-	  break;
+	break;
+
+    case CSS_PROP_BACKGROUND_REPEAT:    // repeat | repeat-x | repeat-y | no-repeat | inherit
+	if ( id >= CSS_VAL_REPEAT && id <= CSS_VAL_NO_REPEAT )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_BACKGROUND_ATTACHMENT: // scroll | fixed
+	if ( id == CSS_VAL_SCROLL || id == CSS_VAL_FIXED )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_BACKGROUND_POSITION:
+	if ( id ) {
+	    /* Problem: center is ambigous
+	     * In case of 'center' center defines X and Y coords
+	     * In case of 'center top', center defines the Y coord
+	     * in case of 'center left', center defines the X coord
+	     */
+	    int pos[2];
+	    pos[0] = -1;
+	    pos[1] = -1;
+	    bool invalid = false;
+	    switch( id ) {
+	    case CSS_VAL_TOP:
+		pos[1] = 0;
+		break;
+	    case CSS_VAL_BOTTOM:
+		pos[1] = 100;
+		break;
+	    case CSS_VAL_LEFT:
+		pos[0] = 0;
+		break;
+	    case CSS_VAL_RIGHT:
+		pos[0] = 100;
+		break;
+	    case  CSS_VAL_CENTER:
+		break;
+	    default:
+		invalid = true;
+	    }
+	    if ( invalid )
+		break;
+	    value = valueList->next();
+	    if ( value ) {
+	        id = value->id;
+	        switch( id ) {
+	        case CSS_VAL_TOP:
+	            if ( pos[1] != -1 )
+		        invalid = true;
+	            pos[1] = 0;
+	            break;
+	        case CSS_VAL_BOTTOM:
+	            if ( pos[1] != -1 )
+		        invalid = true;
+	            pos[1] = 100;
+	            break;
+	        case CSS_VAL_LEFT:
+	            if ( pos[0] != -1 )
+		        invalid = true;
+	            pos[0] = 0;
+	            break;
+	        case CSS_VAL_RIGHT:
+	            if ( pos[0] != -1 )
+		        invalid = true;
+	            pos[0] = 100;
+	            break;
+	        case  CSS_VAL_CENTER:
+	            break;
+	        default:
+	            invalid = true;
+	        }
+	        if ( !invalid )
+	            value = valueList->next();
+	    }
+	    if ( pos[0] == -1 )
+		pos[0] = 50;
+	    if ( pos[1] == -1 )
+		pos[1] = 50;
+	    addProperty( CSS_PROP_BACKGROUND_POSITION_X,
+			 new CSSPrimitiveValueImpl( pos[0], CSSPrimitiveValue::CSS_PERCENTAGE ),
+			 important );
+	    addProperty( CSS_PROP_BACKGROUND_POSITION_Y,
+			 new CSSPrimitiveValueImpl( pos[1], CSSPrimitiveValue::CSS_PERCENTAGE ),
+			 important );
+	} else {
+	    bool ok = parseValue( CSS_PROP_BACKGROUND_POSITION_X, important );
+	    if ( !ok )
+		break;
+	    value = valueList->current();
+	    if ( value )
+		ok = parseValue( CSS_PROP_BACKGROUND_POSITION_Y, important );
+	    if ( !ok )
+		addProperty( CSS_PROP_BACKGROUND_POSITION_Y,
+			     new CSSPrimitiveValueImpl( 50, CSSPrimitiveValue::CSS_PERCENTAGE ),
+			     important );
 	}
-      case CSS_PROP_BACKGROUND_POSITION:
-	{
-#ifdef CSS_DEBUG_BCKGR
-	  kdDebug( 6080 ) << "CSS_PROP_BACKGROUND_POSITION: " << val << endl;
-#endif
-	  /* Problem: center is ambigous
-	   * In case of 'center' center defines X and Y coords
-	   * In case of 'center top', center defines the Y coord
-	   * in case of 'center left', center defines the X coord
-	   */
-	  bool isLast;
-	  const QChar* nextP = getNext(curP, endP, isLast);
-	  QConstString property1(const_cast<QChar*>( curP ), nextP - curP);
-	  const struct css_value *cssval1 = findValue( property1.string().ascii(),
-						       property1.string().length());
-	  if ( !cssval1 ) {
-            int properties[2] = { CSS_PROP_BACKGROUND_POSITION_X,
-				  CSS_PROP_BACKGROUND_POSITION_Y };
-            return parseShortHand(curP, endP, properties, 2);
-	  }
-	  const struct css_value *cssval2 = 0;
-#ifdef CSS_DEBUG
-	  kdDebug( 6080 ) << "prop 1: [" << property1.string() << "]" << " isLast: " << isLast <<  endl;
-#endif
-	  if ( !isLast) {
-            curP = nextP+1;
-            nextP = getNext(curP, endP, isLast);
-            QConstString property2(const_cast<QChar*>( curP ), nextP - curP);
-            cssval2 = findValue( property2.string().ascii(), property2.string().length());
-#ifdef CSS_DEBUG
-            kdDebug( 6080 ) << "prop 2: [" << property2.string() << "]" << " isLast: " << isLast <<  endl;
-#endif
-	  }
-
-	  int valX = -1;
-	  int valY = -1;
-	  int id1 = cssval1 ? cssval1->id : -1;
-	  int id2 = cssval2 ? cssval2->id : CSS_VAL_CENTER;
-	  // id1 will influence X and id2 will influence Y
-	  if ( id2 == CSS_VAL_LEFT || id2 == CSS_VAL_RIGHT ||
-	       id1 == CSS_VAL_TOP  || id1 == CSS_VAL_BOTTOM) {
-            int h = id1; id1 = id2; id2 = h;
-	  }
-
-	  switch( id1 ) {
-	  case CSS_VAL_LEFT:   valX = 0;   break;
-	  case CSS_VAL_CENTER: valX = 50;  break;
-	  case CSS_VAL_RIGHT:  valX = 100; break;
-	  default: break;
-	  }
-
-	  switch ( id2 ) {
-	  case CSS_VAL_TOP:    valY = 0;   break;
-	  case CSS_VAL_CENTER: valY = 50;  break;
-	  case CSS_VAL_BOTTOM: valY = 100; break;
-	  default: break;
-	  }
+	return true;
 
-#ifdef CSS_DEBUG
-	  kdDebug( 6080 ) << "valX: " << valX << " valY: " << valY <<  endl;
-#endif
-	  /* CSS 14.2
-	   * Keywords cannot be combined with percentage values or length values.
-	   * -> No mix between keywords and other units.
-	   */
-	  if (valX !=-1 && valY !=-1) {
-            setParsedValue( CSS_PROP_BACKGROUND_POSITION_X,
-			    new CSSPrimitiveValueImpl(valX, CSSPrimitiveValue::CSS_PERCENTAGE));
-	    setParsedValue( CSS_PROP_BACKGROUND_POSITION_Y,
-			    new CSSPrimitiveValueImpl(valY, CSSPrimitiveValue::CSS_PERCENTAGE));
-	    return true;
-	  }
-	  break;
-	}
-      case CSS_PROP_BACKGROUND_POSITION_X:
-      case CSS_PROP_BACKGROUND_POSITION_Y:
-	{
-#ifdef CSS_DEBUG
-	  kdDebug( 6080 ) << "CSS_PROP_BACKGROUND_POSITION_{X|Y}: " << val << endl;
-#endif
-	  parsedValue = parseUnit(curP, endP, PERCENT | NUMBER | LENGTH);
-	  break;
-	}
-      case CSS_PROP_BORDER_SPACING:
-	{
-	  // ### should be able to have two values
-	  parsedValue = parseUnit(curP, endP, LENGTH | NONNEGATIVE);
-	  break;
-	}
-      case CSS_PROP_OUTLINE_COLOR:        // <color> | invert | inherit
-	{
-#ifdef CSS_DEBUG
-	  kdDebug( 6080 ) << "CSS_PROP_OUTLINE_COLOR: " << val << endl;
-#endif
-	  // outline has "invert" as additional keyword. we handle
-	  // it as invalid color and add a special case during rendering
-	  if (cssval && cssval->id == CSS_VAL_INVERT) {
-            parsedValue = new CSSPrimitiveValueImpl( QColor() );
+    case CSS_PROP_BACKGROUND_POSITION_X:
+    case CSS_PROP_BACKGROUND_POSITION_Y:
+	valid_primitive = validUnit( value, FPercent|FNumber|FLength, strict&(!nonCSSHint) );
+	break;
+
+    case CSS_PROP_BORDER_SPACING:
+	// ### should be able to have two values
+	valid_primitive = ( validUnit( value, FLength|FNonNeg, strict&(!nonCSSHint) ) );
+	break;
+
+    case CSS_PROP_SCROLLBAR_FACE_COLOR:         // IE5.5
+    case CSS_PROP_SCROLLBAR_SHADOW_COLOR:       // IE5.5
+    case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:    // IE5.5
+    case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR:      // IE5.5
+    case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:   // IE5.5
+    case CSS_PROP_SCROLLBAR_TRACK_COLOR:        // IE5.5
+    case CSS_PROP_SCROLLBAR_ARROW_COLOR:        // IE5.5
+	if ( strict )
+	    break;
+	/* nobreak */
+    case CSS_PROP_OUTLINE_COLOR:        // <color> | invert | inherit
+	// outline has "invert" as additional keyword.
+	if ( propId == CSS_PROP_OUTLINE_COLOR && id == CSS_VAL_INVERT ) {
+	    valid_primitive = true;
             break;
-	  }
-	  // Break is explictly missing, looking for <color>
 	}
-      case CSS_PROP_BACKGROUND_COLOR:     // <color> | transparent | inherit
-	{
-#ifdef CSS_DEBUG_BCKGR
-	  kdDebug( 6080 ) << "CSS_PROP_BACKGROUND_COLOR: " << val << endl;
-#endif
-	  if (cssval && cssval->id == CSS_VAL_TRANSPARENT) {
-            parsedValue = new CSSPrimitiveValueImpl( QColor() );
+	/* nobreak */
+    case CSS_PROP_BACKGROUND_COLOR:     // <color> | transparent | inherit
+	if ( propId == CSS_PROP_BACKGROUND_COLOR && id == CSS_VAL_TRANSPARENT ) {
+            valid_primitive = true;
             break;
-	  }
-	  // Break is explictly missing, looking for <color>
 	}
-      case CSS_PROP_COLOR:                // <color> | inherit
-      case CSS_PROP_BORDER_TOP_COLOR:     // <color> | inherit
-      case CSS_PROP_BORDER_RIGHT_COLOR:   // <color> | inherit
-      case CSS_PROP_BORDER_BOTTOM_COLOR:  // <color> | inherit
-      case CSS_PROP_BORDER_LEFT_COLOR:    // <color> | inherit
-      case CSS_PROP_TEXT_DECORATION_COLOR:        //
-      case CSS_PROP_SCROLLBAR_FACE_COLOR:         // IE5.5
-      case CSS_PROP_SCROLLBAR_SHADOW_COLOR:       // IE5.5
-      case CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR:    // IE5.5
-      case CSS_PROP_SCROLLBAR_3DLIGHT_COLOR:      // IE5.5
-      case CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR:   // IE5.5
-      case CSS_PROP_SCROLLBAR_TRACK_COLOR:        // IE5.5
-      case CSS_PROP_SCROLLBAR_ARROW_COLOR:        // IE5.5
-	{
-	  const QString val2( value.stripWhiteSpace() );
-	  //kdDebug(6080) << "parsing color " << val2 << endl;
-	  QColor c;
-	  khtml::setNamedColor(c, val2);
-	  if(!c.isValid() && (val2 != "transparent" ) && !val2.isEmpty() ) return false;
-	  //kdDebug( 6080 ) << "color is: " << c.red() << ", " << c.green() << ", " << c.blue() << endl;
-	  parsedValue = new CSSPrimitiveValueImpl(c);
-	  break;
-	}
-      case CSS_PROP_BACKGROUND_IMAGE:     // <uri> | none | inherit
-#ifdef CSS_DEBUG_BCKGR
-	{
-	  kdDebug( 6080 ) << "CSS_PROP_BACKGROUND_IMAGE: " << val << endl;
+	/* nobreak */
+    case CSS_PROP_COLOR:                // <color> | inherit
+    case CSS_PROP_BORDER_TOP_COLOR:     // <color> | inherit
+    case CSS_PROP_BORDER_RIGHT_COLOR:   // <color> | inherit
+    case CSS_PROP_BORDER_BOTTOM_COLOR:  // <color> | inherit
+    case CSS_PROP_BORDER_LEFT_COLOR:    // <color> | inherit
+    case CSS_PROP_TEXT_DECORATION_COLOR:
+	if ( id >= CSS_VAL_AQUA && id <= CSS_VAL_WINDOWTEXT || id == CSS_VAL_MENU ||
+	     (id >= CSS_VAL_GREY && id <= CSS_VAL__KONQ_TEXT && (nonCSSHint|!strict)) ) {
+	    valid_primitive = true;
+	} else {
+	    parsedValue = parseColor();
+	    if ( parsedValue )
+		valueList->next();
 	}
-#endif
-      case CSS_PROP_CURSOR:
-    	// [ [<uri> ,]* [ auto | crosshair | default | pointer | move | e-resize | ne-resize |
-	// nw-resize | // n-resize | se-resize | sw-resize | s-resize | w-resize | text |
+	break;
+
+    case CSS_PROP_CURSOR:
+	//  [ auto | crosshair | default | pointer | progress | move | e-resize | ne-resize |
+	// nw-resize | n-resize | se-resize | sw-resize | s-resize | w-resize | text |
 	// wait | help ] ] | inherit
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if (id >= CSS_VAL_AUTO && id <= CSS_VAL_HELP) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	      break;
-	    }
-	  } else {
-	    // Break is explictly missing, looking for <uri>
-	    // ### Only supports parsing the first uri
-	  }
-	}
-      case CSS_PROP_LIST_STYLE_IMAGE:     // <uri> | none | inherit
-	{
-	  if (cssval && cssval->id == CSS_VAL_NONE)
-	    {
-	      parsedValue = new CSSImageValueImpl();
+    // MSIE 5 compatibility :/
+	if ( !strict && id == CSS_VAL_HAND )
+	    valid_primitive = true;
+	else if ( id >= CSS_VAL_AUTO && id <= CSS_VAL_HELP )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_BACKGROUND_IMAGE:     // <uri> | none | inherit
+    case CSS_PROP_LIST_STYLE_IMAGE:     // <uri> | none | inherit
+
+	if ( id == CSS_VAL_NONE ) {
+	    parsedValue = new CSSImageValueImpl();
+	    valueList->next();
 #ifdef CSS_DEBUG
-	      kdDebug( 6080 ) << "empty image " << endl;
+	    kdDebug( 6080 ) << "empty image " << endl;
 #endif
-	    } else {
-	      const QString str(value.stripWhiteSpace()); // ### Optimize
-	      if (str.left(4).lower() == "url(") {
-                  DOMString value(curP, endP - curP);
-                  value = khtml::parseURL(value);
-                  if (!value.isEmpty())
-                    parsedValue = new CSSImageValueImpl(DOMString(KURL(baseURL().string(), value.string()).url()), this);
+	} else if ( value->unit == CSSPrimitiveValue::CSS_URI ) {
+	    // ### allow string in non strict mode?
+	    DOMString uri = khtml::parseURL( domString( value->string ) );
+	    if ( !uri.isEmpty() ) {
+		parsedValue = new CSSImageValueImpl(
+		    DOMString(KURL( styleElement->baseURL().string(), uri.string()).url()),
+		    styleElement );
+		valueList->next();
 #ifdef CSS_DEBUG
-		kdDebug( 6080 ) << "image, url=" << value.string() << " base=" << baseURL().string() << endl;
+		kdDebug( 6080 ) << "image, url=" << uri.string() << " base=" << styleElement->baseURL().string() << endl;
 #endif
-	      }
 	    }
-	  break;
-	}
-      case CSS_PROP_OUTLINE_WIDTH:        // <border-width> | inherit
-      case CSS_PROP_BORDER_TOP_WIDTH:     //// <border-width> | inherit
-      case CSS_PROP_BORDER_RIGHT_WIDTH:   //   Which is defined as
-      case CSS_PROP_BORDER_BOTTOM_WIDTH:  //   thin | medium | thick | <length>
-      case CSS_PROP_BORDER_LEFT_WIDTH:    ////
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if (id == CSS_VAL_THIN || id == CSS_VAL_MEDIUM || id == CSS_VAL_THICK) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-            }
-	  } else {
-            parsedValue = parseUnit(curP, endP, LENGTH|NONNEGATIVE);
-	  }
-	  break;
-	}
-      case CSS_PROP_MARKER_OFFSET:        // <length> | auto | inherit
-	{
-	  if (cssval && cssval->id == CSS_VAL_AUTO) {
-            parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-	  } else {
-            parsedValue = parseUnit(curP, endP, LENGTH);
-	  }
-	  break;
-	}
-      case CSS_PROP_LETTER_SPACING:       // normal | <length> | inherit
-      case CSS_PROP_WORD_SPACING:         // normal | <length> | inherit
-	{
-	  if (cssval) {
-            if (cssval->id == CSS_VAL_NORMAL) {
-	      parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-            }
-	  } else {
-            parsedValue = parseUnit(curP, endP, LENGTH);
-	  }
-	  break;
-	}
-      case CSS_PROP_PADDING_TOP:          //// <padding-width> | inherit
-      case CSS_PROP_PADDING_RIGHT:        //   Which is defined as
-      case CSS_PROP_PADDING_BOTTOM:       //   <length> | <percentage>
-      case CSS_PROP_PADDING_LEFT:         ////
-	{
-	  parsedValue = parseUnit(curP, endP, LENGTH | PERCENT|NONNEGATIVE);
-	  break;
-	}
-      case CSS_PROP_TEXT_INDENT:          // <length> | <percentage> | inherit
-      case CSS_PROP_MIN_HEIGHT:           // <length> | <percentage> | inherit
-      case CSS_PROP_MIN_WIDTH:            // <length> | <percentage> | inherit
-	{
-	  parsedValue = parseUnit(curP, endP, LENGTH | PERCENT);
-	  break;
 	}
-      case CSS_PROP_FONT_SIZE:
+	break;
+
+    case CSS_PROP_OUTLINE_WIDTH:        // <border-width> | inherit
+    case CSS_PROP_BORDER_TOP_WIDTH:     //// <border-width> | inherit
+    case CSS_PROP_BORDER_RIGHT_WIDTH:   //   Which is defined as
+    case CSS_PROP_BORDER_BOTTOM_WIDTH:  //   thin | medium | thick | <length>
+    case CSS_PROP_BORDER_LEFT_WIDTH:    ////
+	if (id == CSS_VAL_THIN || id == CSS_VAL_MEDIUM || id == CSS_VAL_THICK)
+	    valid_primitive = true;
+        else
+            valid_primitive = ( validUnit( value, FLength, strict&(!nonCSSHint) ) );
+	break;
+
+    case CSS_PROP_MARKER_OFFSET:        // <length> | auto | inherit
+	if ( id == CSS_VAL_AUTO )
+	    valid_primitive = true;
+	else
+            valid_primitive = validUnit( value, FLength, strict&(!nonCSSHint) );
+	break;
+
+    case CSS_PROP_LETTER_SPACING:       // normal | <length> | inherit
+    case CSS_PROP_WORD_SPACING:         // normal | <length> | inherit
+	if ( id == CSS_VAL_NORMAL )
+	    valid_primitive = true;
+	else
+            valid_primitive = validUnit( value, FLength, strict&(!nonCSSHint) );
+	break;
+
+    case CSS_PROP_TEXT_INDENT:          // <length> | <percentage> | inherit
+    case CSS_PROP_PADDING_TOP:          //// <padding-width> | inherit
+    case CSS_PROP_PADDING_RIGHT:        //   Which is defined as
+    case CSS_PROP_PADDING_BOTTOM:       //   <length> | <percentage>
+    case CSS_PROP_PADDING_LEFT:         ////
+	valid_primitive = ( !id && validUnit( value, FLength|FPercent, strict&(!nonCSSHint) ) );
+	break;
+
+    case CSS_PROP_MAX_HEIGHT:           // <length> | <percentage> | none | inherit
+    case CSS_PROP_MAX_WIDTH:            // <length> | <percentage> | none | inherit
+	if ( id == CSS_VAL_NONE ) {
+	    valid_primitive = true;
+	    break;
+	}
+	/* nobreak */
+    case CSS_PROP_MIN_HEIGHT:           // <length> | <percentage> | inherit
+    case CSS_PROP_MIN_WIDTH:            // <length> | <percentage> | inherit
+    	valid_primitive = ( !id && validUnit( value, FLength|FPercent|FNonNeg, strict&(!nonCSSHint) ) );
+	break;
+
+    case CSS_PROP_FONT_SIZE:
     	// <absolute-size> | <relative-size> | <length> | <percentage> | inherit
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if (id >= CSS_VAL_XX_SMALL && id <= CSS_VAL_LARGER) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-	      break;
-            }
-	  } else {
-            parsedValue = parseUnit(curP, endP, LENGTH | PERCENT | NONNEGATIVE);
-	  }
-	  break;
-	}
-      case CSS_PROP_FONT_STYLE:           // normal | italic | oblique | inherit
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if ( id == CSS_VAL_NORMAL || id == CSS_VAL_ITALIC || id == CSS_VAL_OBLIQUE) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-            }
-	  }
-	  break;
-	}
-      case CSS_PROP_FONT_VARIANT:         // normal | small-caps | inherit
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if ( id == CSS_VAL_NORMAL || id == CSS_VAL_SMALL_CAPS) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-            }
-	  }
-	  break;
-	}
-      case CSS_PROP_VERTICAL_ALIGN:
+	if (id >= CSS_VAL_XX_SMALL && id <= CSS_VAL_LARGER)
+	    valid_primitive = true;
+	else
+	    valid_primitive = ( validUnit( value, FLength|FPercent, strict&(!nonCSSHint) ) );
+	break;
+
+    case CSS_PROP_FONT_STYLE:           // normal | italic | oblique | inherit
+	if ( id == CSS_VAL_NORMAL || id == CSS_VAL_ITALIC || id == CSS_VAL_OBLIQUE)
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_FONT_VARIANT:         // normal | small-caps | inherit
+	if ( id == CSS_VAL_NORMAL || id == CSS_VAL_SMALL_CAPS)
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP_VERTICAL_ALIGN:
     	// baseline | sub | super | top | text-top | middle | bottom | text-bottom |
 	// <percentage> | <length> | inherit
-	{
-	  if (cssval) {
-            int id = cssval->id;
-            if ( id >= CSS_VAL_BASELINE && id <= CSS_VAL__KONQ_BASELINE_MIDDLE ) {
-	      parsedValue = new CSSPrimitiveValueImpl(id);
-            }
-	  } else {
-            parsedValue = parseUnit(curP, endP, LENGTH | PERCENT );
-	  }
-	  break;
-	}
-      case CSS_PROP_MAX_HEIGHT:           // <length> | <percentage> | none | inherit
-      case CSS_PROP_MAX_WIDTH:            // <length> | <percentage> | none | inherit
-	{
-	  if (cssval && cssval->id == CSS_VAL_NONE) {
-            parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-	  } else {
-            parsedValue = parseUnit(curP, endP, LENGTH | PERCENT );
-	  }
-	  break;
-	}
-      case CSS_PROP_HEIGHT:               // <length> | <percentage> | auto | inherit
-      case CSS_PROP_WIDTH:                // <length> | <percentage> | auto | inherit
-	{
-	  if (cssval && cssval->id == CSS_VAL_AUTO) {
-            parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-	  } else {
-            parsedValue = parseUnit(curP, endP, LENGTH | PERCENT | NONNEGATIVE );
-	  }
-	  break;
-	}
-      case CSS_PROP_BOTTOM:               // <length> | <percentage> | auto | inherit
-      case CSS_PROP_LEFT:                 // <length> | <percentage> | auto | inherit
-      case CSS_PROP_RIGHT:                // <length> | <percentage> | auto | inherit
-      case CSS_PROP_TOP:                  // <length> | <percentage> | auto | inherit
-      case CSS_PROP_MARGIN_TOP:           //// <margin-width> | inherit
-      case CSS_PROP_MARGIN_RIGHT:         //   Which is defined as
-      case CSS_PROP_MARGIN_BOTTOM:        //   <length> | <percentage> | auto | inherit
-      case CSS_PROP_MARGIN_LEFT:          ////
-	{
-	  if (cssval && cssval->id == CSS_VAL_AUTO) {
-            parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-	  } else {
-            // Deal with a quirk case.  We allow a special quirk unit, _qem, to 
-            // denote a margin that is allowed to collapse away in quirks mode
-            // when at the top/bottom of a reflow root like a body, td, or th.
-            // This is a WinIE quirk. -dwh
-            if (propId == CSS_PROP_MARGIN_TOP || propId == CSS_PROP_MARGIN_BOTTOM)
-                parsedValue = parseUnit(curP, endP, LENGTH | PERCENT | COLLAPSIBLE);
-            else
-                parsedValue = parseUnit(curP, endP, LENGTH | PERCENT);
-	  }
-	  break;
-	}
-      case CSS_PROP_FONT_SIZE_ADJUST:     // <number> | none | inherit
-	// ### not supported later on
-	{
-	  if (cssval && cssval->id == CSS_VAL_NONE) {
-            parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-	  } else {
-            parsedValue = parseUnit(curP, endP, NUMBER);
-	  }
-	  break;
-	}
-      case CSS_PROP_Z_INDEX:              // auto | <integer> | inherit
-	{
-	  if (cssval && cssval->id == CSS_VAL_AUTO) {
-            parsedValue = new CSSPrimitiveValueImpl(cssval->id);
+
+	if ( id >= CSS_VAL_BASELINE && id <= CSS_VAL__KONQ_BASELINE_MIDDLE )
+	    valid_primitive = true;
+	else
+	    valid_primitive = ( !id && validUnit( value, FLength|FPercent, strict&(!nonCSSHint) ) );
+	break;
+
+    case CSS_PROP_HEIGHT:               // <length> | <percentage> | auto | inherit
+    case CSS_PROP_WIDTH:                // <length> | <percentage> | auto | inherit
+	if ( id == CSS_VAL_AUTO )
+	    valid_primitive = true;
+	else
+	    // ### handle multilength case where we allow relative units
+	    valid_primitive = ( !id && validUnit( value, FLength|FPercent|FNonNeg, strict&(!nonCSSHint) ) );
+	break;
+
+    case CSS_PROP_BOTTOM:               // <length> | <percentage> | auto | inherit
+    case CSS_PROP_LEFT:                 // <length> | <percentage> | auto | inherit
+    case CSS_PROP_RIGHT:                // <length> | <percentage> | auto | inherit
+    case CSS_PROP_TOP:                  // <length> | <percentage> | auto | inherit
+    case CSS_PROP_MARGIN_TOP:           //// <margin-width> | inherit
+    case CSS_PROP_MARGIN_RIGHT:         //   Which is defined as
+    case CSS_PROP_MARGIN_BOTTOM:        //   <length> | <percentage> | auto | inherit
+    case CSS_PROP_MARGIN_LEFT:          ////
+	if ( id == CSS_VAL_AUTO )
+	    valid_primitive = true;
+	else
+	    valid_primitive = ( !id && validUnit( value, FLength|FPercent, strict&(!nonCSSHint) ) );
+	break;
+
+    case CSS_PROP_Z_INDEX:              // auto | <integer> | inherit
+	// qDebug("parsing z-index: id=%d, fValue=%f", id, value->fValue );
+	if ( id == CSS_VAL_AUTO ) {
+            valid_primitive = true;
             break;
-	  }
-	  // break explicitly missing, looking for <number>
 	}
-      case CSS_PROP_ORPHANS:              // <integer> | inherit
-      case CSS_PROP_WIDOWS:               // <integer> | inherit
+	/* nobreak */
+    case CSS_PROP_ORPHANS:              // <integer> | inherit
+    case CSS_PROP_WIDOWS:               // <integer> | inherit
 	// ### not supported later on
-	{
-	  parsedValue = parseUnit(curP, endP, INTEGER);
-	  break;
-	}
-      case CSS_PROP_LINE_HEIGHT:          // normal | <number> | <length> | <percentage> | inherit
-	{
-	  if (cssval && cssval->id == CSS_VAL_NORMAL) {
-            parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-	  } else {
-            parsedValue = parseUnit(curP, endP, NUMBER | LENGTH | PERCENT | NONNEGATIVE);
-	  }
-	  break;
-	}
-      case CSS_PROP_COUNTER_INCREMENT:    // [ <identifier> <integer>? ]+ | none | inherit
-      case CSS_PROP_COUNTER_RESET:        // [ <identifier> <integer>? ]+ | none | inherit
-	{
-	  if (cssval && cssval->id == CSS_VAL_NONE) {
-            parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-	  } else {
+	valid_primitive = ( !id && validUnit( value, FInteger, false ) );
+	break;
+
+    case CSS_PROP_LINE_HEIGHT:          // normal | <number> | <length> | <percentage> | inherit
+	if ( id == CSS_VAL_NORMAL )
+	    valid_primitive = true;
+	else
+	    valid_primitive = ( !id && validUnit( value, FNumber|FLength|FPercent, strict&(!nonCSSHint) ) );
+	break;
+#if 0
+	// removed from CSS 2.1
+    case CSS_PROP_COUNTER_INCREMENT:    // [ <identifier> <integer>? ]+ | none | inherit
+    case CSS_PROP_COUNTER_RESET:        // [ <identifier> <integer>? ]+ | none | inherit
+	if ( id == CSS_VAL_NONE )
+	    valid_primitive = true;
+	else {
             CSSValueListImpl *list = new CSSValueListImpl;
             int pos=0, pos2;
             while( 1 )
-	      {
+	    {
                 pos2 = value.find(',', pos);
                 QString face = value.mid(pos, pos2-pos);
                 face = face.stripWhiteSpace();
@@ -1901,1363 +891,895 @@ bool StyleBaseImpl::parseValue( const QChar *curP, const QChar *endP, int propId
                 list->append(new CSSPrimitiveValueImpl(DOMString(face), CSSPrimitiveValue::CSS_STRING));
                 pos = pos2 + 1;
                 if(pos2 == -1) break;
-	      }
+	    }
             //kdDebug( 6080 ) << "got " << list->length() << " faces" << endl;
-            if(list->length())
-	      parsedValue = list;
-            else
-	      delete list;
+            if(list->length()) {
+		parsedValue = list;
+		valueList->next();
+            } else
+		delete list;
             break;
-	  }
 	}
-      case CSS_PROP_FONT_FAMILY:
+#endif
+    case CSS_PROP_FONT_FAMILY:
     	// [[ <family-name> | <generic-family> ],]* [<family-name> | <generic-family>] | inherit
-	{
-	  // css2 compatible parsing...
-	  FontParser fp;
-	  fp.startTokenizer( value, strictParsing );
-	  QStringList families;
-	  if ( !fp.matchFontFamily( &families ) )
-            return false;
-          CSSValueListImpl *list = new CSSValueListImpl;
-	  for ( QStringList::Iterator it = families.begin(); it != families.end(); ++it ) {
-            if( *it != QString::null ) {
-	      list->append( new FontFamilyValueImpl(*it) );
-	      //kdDebug() << "StyleBaseImpl::parsefont: family='" << *it << "'" << endl;
-            }
-	  }
-	  //kdDebug( 6080 ) << "got " << list->length() << " faces" << endl;
-	  if(list->length())
-            parsedValue = list;
-	  else
-            delete list;
-	  break;
-	}
-      case CSS_PROP_TEXT_DECORATION:
+    {
+	parsedValue = parseFontFamily();
+	break;
+    }
+
+    case CSS_PROP_TEXT_DECORATION:
     	// none | [ underline || overline || line-through || blink ] | inherit
-	{
-	    if (cssval && cssval->id == CSS_VAL_NONE) {
-	      parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-	    } else {
-	      CSSValueListImpl *list = new CSSValueListImpl;
-	      value.simplifyWhiteSpace();
-	      //kdDebug( 6080 ) << "text-decoration: '" << value << "'" << endl;
-	      int pos=0, pos2;
-	      while( 1 )
-		{
-		  pos2 = value.find(' ', pos);
-		  QString decoration = value.mid(pos, pos2-pos);
-		  decoration = decoration.stripWhiteSpace();
-		  //kdDebug( 6080 ) << "found decoration '" << decoration << "'" << endl;
-		  const struct css_value *cssval = findValue(decoration.lower().ascii(),
-							     decoration.length());
-		  if (cssval) {
-		    list->append(new CSSPrimitiveValueImpl(cssval->id));
-		  }
-		  pos = pos2 + 1;
-		  if(pos2 == -1) break;
+	if (id == CSS_VAL_NONE) {
+	    valid_primitive = true;
+	} else {
+	    CSSValueListImpl *list = new CSSValueListImpl;
+	    bool is_valid = true;
+	    while( is_valid && value ) {
+		switch ( value->id ) {
+		case CSS_VAL_BLINK:
+		    break;
+		case CSS_VAL_UNDERLINE:
+		case CSS_VAL_OVERLINE:
+		case CSS_VAL_LINE_THROUGH:
+		    list->append( new CSSPrimitiveValueImpl( value->id ) );
+		    break;
+		default:
+		    is_valid = false;
 		}
-	      //kdDebug( 6080 ) << "got " << list->length() << "d decorations" << endl;
-	      if(list->length()) {
+		value = valueList->next();
+	    }
+	    //kdDebug( 6080 ) << "got " << list->length() << "d decorations" << endl;
+	    if(list->length() && is_valid) {
                 parsedValue = list;
-	      } else {
+		valueList->next();
+	    } else {
                 delete list;
-	      }
 	    }
-	  break;
 	}
-      case CSS_PROP__KONQ_FLOW_MODE:
-      {
-	  if (cssval->id==CSS_VAL__KONQ_NORMAL || cssval->id==CSS_VAL__KONQ_AROUND_FLOATS)
-              parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-	  break;
-      }
-      /* shorthand properties */
-      case CSS_PROP_BACKGROUND:
+	break;
+
+    case CSS_PROP_TABLE_LAYOUT:         // auto | fixed | inherit
+	if ( id == CSS_VAL_AUTO || id == CSS_VAL_FIXED )
+	    valid_primitive = true;
+	break;
+
+    case CSS_PROP__KONQ_FLOW_MODE:
+	if ( id == CSS_VAL__KONQ_NORMAL || id == CSS_VAL__KONQ_AROUND_FLOATS )
+	    valid_primitive = true;
+	break;
+
+	/* shorthand properties */
+    case CSS_PROP_BACKGROUND:
     	// ['background-color' || 'background-image' ||'background-repeat' ||
 	// 'background-attachment' || 'background-position'] | inherit
-	{
+    {
 #ifdef CSS_DEBUG_BCKGR
-	  kdDebug(6080) << "CSS_PROP_BACKGROUND" << endl;
+	kdDebug(6080) << "CSS_PROP_BACKGROUND" << endl;
 #endif
-	  const int properties[5] = { CSS_PROP_BACKGROUND_IMAGE, CSS_PROP_BACKGROUND_REPEAT,
-                                      CSS_PROP_BACKGROUND_ATTACHMENT, CSS_PROP_BACKGROUND_POSITION,
-                                      CSS_PROP_BACKGROUND_COLOR };
-	  return parseShortHand(curP, endP, properties, 5);
-
-	  //return parseBackground(curP, endP);
-	}
-      case CSS_PROP_BORDER:
+	const int properties[5] = { CSS_PROP_BACKGROUND_IMAGE, CSS_PROP_BACKGROUND_REPEAT,
+				    CSS_PROP_BACKGROUND_ATTACHMENT, CSS_PROP_BACKGROUND_POSITION,
+				    CSS_PROP_BACKGROUND_COLOR };
+	return parseShortHand(properties, 5, important);
+    }
+    case CSS_PROP_BORDER:
  	// [ 'border-width' || 'border-style' || <color> ] | inherit
-	{
-	  const int properties[3] = { CSS_PROP_BORDER_WIDTH, CSS_PROP_BORDER_STYLE,
-				      CSS_PROP_BORDER_COLOR };
-	  return parseShortHand(curP, endP, properties, 3);
-	}
-      case CSS_PROP_BORDER_TOP:
+    {
+	const int properties[3] = { CSS_PROP_BORDER_WIDTH, CSS_PROP_BORDER_STYLE,
+				    CSS_PROP_BORDER_COLOR };
+	return parseShortHand(properties, 3, important);
+    }
+    case CSS_PROP_BORDER_TOP:
     	// [ 'border-top-width' || 'border-style' || <color> ] | inherit
-	{
-	  const int properties[3] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_TOP_STYLE,
-				      CSS_PROP_BORDER_TOP_COLOR};
-	  return parseShortHand(curP, endP, properties, 3);
-	}
-      case CSS_PROP_BORDER_RIGHT:
+    {
+	const int properties[3] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_TOP_STYLE,
+				    CSS_PROP_BORDER_TOP_COLOR};
+	return parseShortHand(properties, 3, important);
+    }
+    case CSS_PROP_BORDER_RIGHT:
     	// [ 'border-right-width' || 'border-style' || <color> ] | inherit
-	{
-	  const int properties[3] = { CSS_PROP_BORDER_RIGHT_WIDTH, CSS_PROP_BORDER_RIGHT_STYLE,
-				      CSS_PROP_BORDER_RIGHT_COLOR };
-	  return parseShortHand(curP, endP, properties, 3);
-	}
-      case CSS_PROP_BORDER_BOTTOM:
-    	// [ 'border-bottom-width' || 'border-style' || <color> ] | inherit
-	{
-	  const int properties[3] = { CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_BOTTOM_STYLE,
-				      CSS_PROP_BORDER_BOTTOM_COLOR };
-	  return parseShortHand(curP, endP, properties, 3);
-	}
-      case CSS_PROP_BORDER_LEFT:
-    	// [ 'border-left-width' || 'border-style' || <color> ] | inherit
-	{
-	  const int properties[3] = { CSS_PROP_BORDER_LEFT_WIDTH, CSS_PROP_BORDER_LEFT_STYLE,
-				      CSS_PROP_BORDER_LEFT_COLOR };
-	  return parseShortHand(curP, endP, properties, 3);
-	}
-      case CSS_PROP_OUTLINE:
-    	// [ 'outline-color' || 'outline-style' || 'outline-width' ] | inherit
-	{
-	  const int properties[3] = { CSS_PROP_OUTLINE_WIDTH, CSS_PROP_OUTLINE_STYLE,
-                                      CSS_PROP_OUTLINE_COLOR };
-	  return parseShortHand(curP, endP, properties, 3);
-	}
-      case CSS_PROP_BORDER_COLOR:
-    	// <color>{1,4} | transparent | inherit
-	{
-	  const struct css_value *cssval = findValue(val, len);
-	  if (cssval && cssval->id == CSS_VAL_TRANSPARENT)
-	    {
-	      // set border colors to invalid
-	      parsedValue = new CSSPrimitiveValueImpl(CSS_VAL_TRANSPARENT);
-	      break;
-	    }
-	  const int properties[4] = { CSS_PROP_BORDER_TOP_COLOR, CSS_PROP_BORDER_RIGHT_COLOR,
-				      CSS_PROP_BORDER_BOTTOM_COLOR, CSS_PROP_BORDER_LEFT_COLOR };
-	  return parse4Values(curP, endP, properties);
-	}
-      case CSS_PROP_BORDER_WIDTH:
-    	// <border-width>{1,4} | inherit
-	{
-	  const int properties[4] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_RIGHT_WIDTH,
-				      CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_LEFT_WIDTH };
-	  return parse4Values(curP, endP, properties);
-	}
-      case CSS_PROP_BORDER_STYLE:
-    	// <border-style>{1,4} | inherit
-	{
-	  const int properties[4] = { CSS_PROP_BORDER_TOP_STYLE, CSS_PROP_BORDER_RIGHT_STYLE,
-				      CSS_PROP_BORDER_BOTTOM_STYLE, CSS_PROP_BORDER_LEFT_STYLE };
-	  return parse4Values(curP, endP, properties);
-	}
-      case CSS_PROP_MARGIN:
-    	// <margin-width>{1,4} | inherit
-	{
-	  const int properties[4] = { CSS_PROP_MARGIN_TOP, CSS_PROP_MARGIN_RIGHT,
-				      CSS_PROP_MARGIN_BOTTOM, CSS_PROP_MARGIN_LEFT };
-	  return parse4Values(curP, endP, properties);
-	}
-      case CSS_PROP_PADDING:
-    	// <padding-width>{1,4} | inherit
-	{
-	  const int properties[4] = { CSS_PROP_PADDING_TOP, CSS_PROP_PADDING_RIGHT,
-				      CSS_PROP_PADDING_BOTTOM, CSS_PROP_PADDING_LEFT };
-	  return parse4Values(curP, endP, properties);
-	}
-      case CSS_PROP_FONT:
-    	// [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]?
-	// 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit
-	{
-	  return parseFont(curP, endP);
-	}
-      case CSS_PROP_LIST_STYLE:
-	{
-	  const int properties[3] = { CSS_PROP_LIST_STYLE_TYPE, CSS_PROP_LIST_STYLE_POSITION,
-				      CSS_PROP_LIST_STYLE_IMAGE };
-	  return  parseShortHand(curP, endP, properties, 3);
-	}
-
-      default:
-	{
-#ifdef CSS_DEBUG
-	  kdDebug( 6080 ) << "illegal or CSS2 Aural property: " << val << endl;
-#endif
-	}
-      }
-  }
-  if ( parsedValue ) {
-    setParsedValue(propId, parsedValue);
-    return true;
-  } else {
-#ifndef CSS_AURAL
-    return false;
-#endif
-#ifdef CSS_AURAL
-    return parseAuralValue(curP, endP, propId);
-#endif
-  }
-}
-
-#ifdef CSS_AURAL
-/* parseAuralValue */
-bool StyleBaseImpl::parseAuralValue( const QChar *curP, const QChar *endP, int propId )
-{
-    QString value(curP, endP - curP);
-    value = value.lower();
-    const char *val = value.ascii();
-
-    CSSValueImpl *parsedValue = 0;
-    kdDebug( 6080 ) << "parseAuralValue: " << value << " val: " << val <<  endl;
-
-    /* AURAL Properies */
-    switch(propId)
     {
-    case CSS_PROP_AZIMUTH:              // <angle> | [[ left-side | far-left | left | center-left | center |
-                                        // center-right | right | far-right | right-side ] || behind ] |
-                                        // leftwards | rightwards | inherit
-    case CSS_PROP_PAUSE_AFTER:          // <time> | <percentage> | inherit
-    case CSS_PROP_PAUSE_BEFORE:         // <time> | <percentage> | inherit
-    case CSS_PROP_PAUSE:                // [ [<time> | <percentage>]{1,2} ] | inherit
-    case CSS_PROP_PLAY_DURING:          // <uri> mix? repeat? | auto | none | inherit
-    case CSS_PROP_VOICE_FAMILY:         // [[<specific-voice> | <generic-voice> ],]*
-                                        // [<specific-voice> | <generic-voice> ] | inherit
+	const int properties[3] = { CSS_PROP_BORDER_RIGHT_WIDTH, CSS_PROP_BORDER_RIGHT_STYLE,
+				    CSS_PROP_BORDER_RIGHT_COLOR };
+	return parseShortHand(properties, 3, important);
+    }
+    case CSS_PROP_BORDER_BOTTOM:
+    	// [ 'border-bottom-width' || 'border-style' || <color> ] | inherit
     {
-      // ### TO BE DONE
-        break;
+	const int properties[3] = { CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_BOTTOM_STYLE,
+				    CSS_PROP_BORDER_BOTTOM_COLOR };
+	return parseShortHand(properties, 3, important);
     }
-    case CSS_PROP_CUE:                  // [ 'cue-before' || 'cue-after' ] | inherit
+    case CSS_PROP_BORDER_LEFT:
+    	// [ 'border-left-width' || 'border-style' || <color> ] | inherit
     {
-        const int properties[2] = {
-                CSS_PROP_CUE_BEFORE,
-                CSS_PROP_CUE_AFTER};
-        return parse2Values(curP, endP, properties);
+	const int properties[3] = { CSS_PROP_BORDER_LEFT_WIDTH, CSS_PROP_BORDER_LEFT_STYLE,
+				    CSS_PROP_BORDER_LEFT_COLOR };
+	return parseShortHand(properties, 3, important);
     }
-    case CSS_PROP_CUE_AFTER:            // <uri> | none | inherit
-    case CSS_PROP_CUE_BEFORE:           // <uri> | none | inherit
+    case CSS_PROP_OUTLINE:
+    	// [ 'outline-color' || 'outline-style' || 'outline-width' ] | inherit
     {
-        const struct css_value *cssval = findValue(val, endP - curP);
-        if (cssval) {
-            if (cssval->id == CSS_VAL_NONE) {
-                parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-            }
-        } else {
-            DOMString value(curP, endP - curP);
-            value = khtml::parseURL(value);
-            parsedValue = new CSSPrimitiveValueImpl(
-                DOMString(KURL(baseURL(), value).url()),
-                CSSPrimitiveValue::CSS_URI);
-        }
-        break;
+	const int properties[3] = { CSS_PROP_OUTLINE_WIDTH, CSS_PROP_OUTLINE_STYLE,
+				    CSS_PROP_OUTLINE_COLOR };
+	return parseShortHand(properties, 3, important);
     }
-    case CSS_PROP_ELEVATION:            // <angle> | below | level | above | higher | lower
-                                        // | inherit
+    case CSS_PROP_BORDER_COLOR:
+    	// <color>{1,4} | transparent | inherit
     {
-        const struct css_value *cssval = findValue(val, endP - curP);
-        if (cssval) {
-            int id = cssval->id;
-            if (id == CSS_VAL_BELOW || id == CSS_VAL_LEVEL || id == CSS_VAL_ABOVE ||
-                id == CSS_VAL_HIGHER || id == CSS_VAL_LOWER) {
-                parsedValue = new CSSPrimitiveValueImpl(id);
-                break;
-            }
-        }
-        parsedValue = parseUnit(curP, endP, ANGLE );
-        break;
+	if ( id == CSS_VAL_TRANSPARENT ) {
+	    // set border colors to invalid
+	    valid_primitive = true;
+	    break;
+	}
+	const int properties[4] = { CSS_PROP_BORDER_TOP_COLOR, CSS_PROP_BORDER_RIGHT_COLOR,
+				    CSS_PROP_BORDER_BOTTOM_COLOR, CSS_PROP_BORDER_LEFT_COLOR };
+	return parse4Values(properties, important);
     }
-    case CSS_PROP_SPEECH_RATE:          // <number> | x-slow | slow | medium | fast |
-                                        // x-fast | faster | slower | inherit
+    case CSS_PROP_BORDER_WIDTH:
+    	// <border-width>{1,4} | inherit
     {
-        const struct css_value *cssval = findValue(val, endP - curP);
-        if (cssval) {
-            int id = cssval->id;
-            if (id == CSS_VAL_X_SLOW || id == CSS_VAL_SLOW || id == CSS_VAL_MEDIUM ||
-                id == CSS_VAL_FAST || id == CSS_VAL_X_FAST || id == CSS_VAL_FASTER ||
-                id == CSS_VAL_SLOWER) {
-                parsedValue = new CSSPrimitiveValueImpl(id);
-                break;
-            }
-        } else {
-          parsedValue = parseUnit(curP, endP, NUMBER );
-        }
-        break;
+	const int properties[4] = { CSS_PROP_BORDER_TOP_WIDTH, CSS_PROP_BORDER_RIGHT_WIDTH,
+				    CSS_PROP_BORDER_BOTTOM_WIDTH, CSS_PROP_BORDER_LEFT_WIDTH };
+	return parse4Values(properties, important);
     }
-    case CSS_PROP_VOLUME:               // <number> | <percentage> | silent | x-soft | soft |
-                                        // medium | loud | x-loud | inherit
+    case CSS_PROP_BORDER_STYLE:
+    	// <border-style>{1,4} | inherit
     {
-        const struct css_value *cssval = findValue(val, endP - curP);
-        if (cssval) {
-            int id = cssval->id;
-            if (id == CSS_VAL_SILENT || id == CSS_VAL_X_SOFT || id == CSS_VAL_SOFT ||
-                id == CSS_VAL_MEDIUM || id == CSS_VAL_X_LOUD || id == CSS_VAL_X_LOUD) {
-                parsedValue = new CSSPrimitiveValueImpl(id);
-            }
-        } else {
-            parsedValue = parseUnit(curP, endP, PERCENT | NUMBER);
-        }
-        break;
+	const int properties[4] = { CSS_PROP_BORDER_TOP_STYLE, CSS_PROP_BORDER_RIGHT_STYLE,
+				    CSS_PROP_BORDER_BOTTOM_STYLE, CSS_PROP_BORDER_LEFT_STYLE };
+	return parse4Values(properties, important);
     }
-    case CSS_PROP_PITCH:                 // <frequency> | x-low | low | medium | high | x-high | inherit
+    case CSS_PROP_MARGIN:
+    	// <margin-width>{1,4} | inherit
     {
-        const struct css_value *cssval = findValue(val, endP - curP);
-        if (cssval) {
-            int id = cssval->id;
-            if (id == CSS_VAL_X_LOW || id == CSS_VAL_LOW || id == CSS_VAL_MEDIUM ||
-                id == CSS_VAL_HIGH || id == CSS_VAL_X_HIGH ) {
-                parsedValue = new CSSPrimitiveValueImpl(id);
-            }
-        } else {
-            parsedValue = parseUnit(curP, endP, FREQUENCY);
-        }
-        break;
+	const int properties[4] = { CSS_PROP_MARGIN_TOP, CSS_PROP_MARGIN_RIGHT,
+				    CSS_PROP_MARGIN_BOTTOM, CSS_PROP_MARGIN_LEFT };
+	return parse4Values(properties, important);
     }
-    case CSS_PROP_SPEAK:                // normal | none | spell-out | inherit
-    case CSS_PROP_SPEAK_HEADER:         // once | always | inherit
-    case CSS_PROP_SPEAK_NUMERAL:        // digits | continuous | inherit
-    case CSS_PROP_SPEAK_PUNCTUATION:    // code | none | inherit
+    case CSS_PROP_PADDING:
+    	// <padding-width>{1,4} | inherit
     {
-        const struct css_value *cssval = findValue(val, endP - curP);
-        if (cssval)
-        {
-            parsedValue = new CSSPrimitiveValueImpl(cssval->id);
-        }
-        break;
+	const int properties[4] = { CSS_PROP_PADDING_TOP, CSS_PROP_PADDING_RIGHT,
+				    CSS_PROP_PADDING_BOTTOM, CSS_PROP_PADDING_LEFT };
+	return parse4Values(properties, important);
     }
-    case CSS_PROP_PITCH_RANGE:          // <number> | inherit
-    case CSS_PROP_RICHNESS:             // <number> | inherit
-    case CSS_PROP_STRESS:               // <number> | inherit
+    case CSS_PROP_FONT:
+    	// [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]?
+	// 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit
+	if ( id >= CSS_VAL_CAPTION && id <= CSS_VAL_STATUS_BAR )
+	    valid_primitive = true;
+	else
+	    return parseFont(important);
+
+    case CSS_PROP_LIST_STYLE:
     {
-        parsedValue = parseUnit(curP, endP, NUMBER);
-        break;
+	const int properties[3] = { CSS_PROP_LIST_STYLE_TYPE, CSS_PROP_LIST_STYLE_POSITION,
+				    CSS_PROP_LIST_STYLE_IMAGE };
+	return parseShortHand(properties, 3, important);
     }
     default:
-    {
-        kdDebug( 6080 ) << "illegal property: " << val << endl;
+// #ifdef CSS_DEBUG
+// 	kdDebug( 6080 ) << "illegal or CSS2 Aural property: " << val << endl;
+// #endif
+	break;
+    }
+
+    if ( valid_primitive ) {
+	if ( id != 0 ) {
+	    // qDebug(" new value: id=%d", id );
+	    parsedValue = new CSSPrimitiveValueImpl( id );
+	} else if ( value->unit == CSSPrimitiveValue::CSS_STRING )
+	    parsedValue = new CSSPrimitiveValueImpl( domString( value->string ),
+						     (CSSPrimitiveValue::UnitTypes) value->unit );
+	else if ( value->unit >= CSSPrimitiveValue::CSS_NUMBER &&
+		  value->unit <= CSSPrimitiveValue::CSS_KHZ ) {
+	    // qDebug(" new value: value=%.2f, unit=%d", value->fValue, value->unit );
+	    parsedValue = new CSSPrimitiveValueImpl( value->fValue,
+						     (CSSPrimitiveValue::UnitTypes) value->unit );
+	} else if ( value->unit >= Value::Q_EMS ) {
+	    // qDebug(" new quirks value: value=%.2f, unit=%d", value->fValue, value->unit );
+	    parsedValue = new CSSQuirkPrimitiveValueImpl( value->fValue, CSSPrimitiveValue::CSS_EMS );
+	}
+	valueList->next();
+    }
+    if ( parsedValue ) {
+	addProperty( propId, parsedValue, important );
+	return true;
     }
-   }
-   if ( parsedValue ) {
-     setParsedValue( propId, parsedValue );
-        return true;
-   }
-   return false;
-}
-#endif
-
-void StyleBaseImpl::setParsedValue(int propId, const CSSValueImpl *parsedValue,
-				   bool important, bool nonCSSHint, QPtrList<CSSProperty> *propList)
-{
-  m_bImportant = important;
-  m_bnonCSSHint = nonCSSHint;
-  m_propList = propList;
-  setParsedValue( propId, parsedValue);
-}
-
-void StyleBaseImpl::setParsedValue( int propId, const CSSValueImpl *parsedValue)
-{
-    QPtrListIterator<CSSProperty> propIt(*m_propList);
-    propIt.toLast(); // just remove the top one - not sure what should happen if we have multiple instances of the property
-    while (propIt.current() &&
-           ( propIt.current()->m_id != propId || propIt.current()->nonCSSHint != m_bnonCSSHint ||
-             propIt.current()->m_bImportant != m_bImportant) )
-        --propIt;
-    if (propIt.current())
-        m_propList->removeRef(propIt.current());
-
-    CSSProperty *prop = new CSSProperty();
-    prop->m_id = propId;
-    prop->setValue((CSSValueImpl *) parsedValue);
-    prop->m_bImportant = m_bImportant;
-    prop->nonCSSHint = m_bnonCSSHint;
-
-    m_propList->append(prop);
-#ifdef CSS_DEBUG
-    kdDebug( 6080 ) << "added property: " << getPropertyName(propId).string()
-                    // non implemented yet << ", value: " << parsedValue->cssText().string()
-                    << " important: " << prop->m_bImportant
-                    << " nonCSS: " << prop->nonCSSHint << endl;
-#endif
+    return false;
 }
 
-bool StyleBaseImpl::parseShortHand(const QChar *curP, const QChar *endP, const int *properties, int num)
+bool CSSParser::parseShortHand( const int *properties, int numProperties, bool important )
 {
     /* We try to match as many properties as possible
      * We setup an array of booleans to mark which property has been found,
      * and we try to search for properties until it makes no longer any sense
      */
+    inParseShortHand = true;
 
-    bool isLast = false;
-    bool foundAnything = false;
+    bool found = false;
     bool fnd[6]; //Trust me ;)
-    for( int i = 0; i < num; i++ )
+    for( int i = 0; i < numProperties; i++ )
     	fnd[i] = false;
 
 #ifdef CSS_DEBUG
-    kdDebug(6080) << "PSH: parsing \"" << QString(curP, endP - curP) << "\" num=" << num << endl;
+    kdDebug(6080) << "PSH: numProperties=" << numProperties << endl;
 #endif
 
-    for (int j = 0; j < num; ++j) {
-        const QChar *nextP = getNext( curP, endP, isLast );
-        //kdDebug(6080) << "in PSH: \"" << QString(curP, nextP - curP) << "\"" << endl;
-        foundAnything = false;
-        for (int propIndex = 0; propIndex < num; ++propIndex) {
+    while ( valueList->current() ) {
+        found = false;
+	// qDebug("outer loop" );
+        for (int propIndex = 0; !found && propIndex < numProperties; ++propIndex) {
             if (!fnd[propIndex]) {
-		// We have to tread this seperately
-		//kdDebug(6080) << "LOOKING FOR: " << getPropertyName(properties[propIndex]).string() << endl;
-		bool found = false;
-		if (!isLast && properties[propIndex] == CSS_PROP_BACKGROUND_POSITION)
-		    found = parseBackgroundPosition(curP, nextP, endP);
-		else
-		    found = parseValue(curP, nextP, properties[propIndex]);
-
-		if (found) {
-		    fnd[propIndex] = foundAnything = true;
 #ifdef CSS_DEBUG
-		    kdDebug(6080) << "FOUND: " << getPropertyName(properties[propIndex]).string() << ": "
-				  << QString(curP, nextP - curP)  << endl;
+		kdDebug(6080) << "LOOKING FOR: " << getPropertyName(properties[propIndex]).string() << endl;
+#endif
+		if ( parseValue( properties[propIndex], important ) ) {
+		    fnd[propIndex] = found = true;
+#ifdef CSS_DEBUG
+		    kdDebug(6080) << "FOUND: " << getPropertyName(properties[propIndex]).string() << endl;
 #endif
-                    break;
 		}
 	    }
 	}
         // if we didn't find at least one match, this is an
         // invalid shorthand and we have to ignore it
-        if (!foundAnything)
-            return foundAnything;
-
-        do {
-            nextP++;
-            curP = nextP;
-
-            // oh, less parameteres than we expected
-            if (curP >= endP)
-                return foundAnything;
-        } while (curP->isSpace());
+        if (!found) {
+#ifdef CSS_DEBUG
+	    qDebug("didn't find anything" );
+#endif
+	    inParseShortHand = false;
+	    return false;
+	}
     }
-    return foundAnything;
+    inParseShortHand = false;
+#ifdef CSS_DEBUG
+    kdDebug( 6080 ) << "parsed shorthand" << endl;
+#endif
+    return true;
 }
 
-/*
- * Problem (again): the ambiguity of 'background-position'
- * from: http://www.w3.org/Style/CSS/Test/current/sec537.htm
-
-	BODY {background: green url(oransqr.gif) repeat-x center top fixed;}
-	.one {background: lime url(oransqr.gif) repeat-y 100% 0%;}
-	.two {background: lime url(oransqr.gif) repeat-y center top;}
-	.three {background: lime url(oransqr.gif) repeat-x left top;}
-*/
-
-bool StyleBaseImpl::parseBackgroundPosition(const QChar *curP, const QChar *&nextP, const QChar *endP)
+bool CSSParser::parse4Values( const int *properties,  bool important )
 {
-    // We first need to check if the property has two values.
-    // if this fails we try one value only.
-
-    const QChar *bckgrNextP = nextP;
-    while (bckgrNextP->isSpace() && bckgrNextP < endP) { bckgrNextP++; }
-    bool dummy;
-    bckgrNextP = getNext(bckgrNextP, endP, dummy);
-    //kdDebug(6080) << "BKCGR: 2: \"" << QString(curP, bckgrNextP - curP) << "\"" << endl;
+    /* From the CSS 2 specs, 8.3
+     * If there is only one value, it applies to all sides. If there are two values, the top and
+     * bottom margins are set to the first value and the right and left margins are set to the second.
+     * If there are three values, the top is set to the first value, the left and right are set to the
+     * second, and the bottom is set to the third. If there are four values, they apply to the top,
+     * right, bottom, and left, respectively.
+     */
 
-    bool found = parseValue(curP, bckgrNextP, CSS_PROP_BACKGROUND_POSITION);
-    if (!found) {
-	// We have not found a pair of Background-Positions, see if we have a single value
+    int num = inParseShortHand ? 1 : valueList->numValues;
+    // qDebug("parse4Values: num=%d", num );
+
+    // the order is top, right, bottom, left
+    switch( num ) {
+    case 1: {
+        if( !parseValue( properties[0], important ) ) return false;
+	CSSValueImpl *value = parsedProperties[numParsedProperties-1]->value();
+	addProperty( properties[1], value, important );
+	addProperty( properties[2], value, important );
+	addProperty( properties[3], value, important );
+        return true;
+    }
+    case 2: {
 
-    	//kdDebug(6080) << "BKCGR: Single: \"" << QString(curP, nextP - curP) << "\"" << endl;
-    	found = parseValue(curP, nextP, CSS_PROP_BACKGROUND_POSITION);
-    } else {
-	// Moving on
-	nextP = bckgrNextP;
+        if( !parseValue( properties[0], important ) ) return false;
+        if( !parseValue( properties[1], important ) ) return false;
+	CSSValueImpl *value = parsedProperties[numParsedProperties-2]->value();
+	addProperty( properties[2], value, important );
+	value = parsedProperties[numParsedProperties-2]->value();
+	addProperty( properties[3], value, important );
+        return true;
+    }
+    case 3: {
+        if( !parseValue( properties[0], important ) ) return false;
+        if( !parseValue( properties[1], important ) ) return false;
+        if( !parseValue( properties[2], important ) ) return false;
+	CSSValueImpl *value = parsedProperties[numParsedProperties-2]->value();
+	addProperty( properties[3], value, important );
+        return true;
+    }
+    case 4: {
+        if( !parseValue( properties[0], important ) ) return false;
+        if( !parseValue( properties[1], important ) ) return false;
+        if( !parseValue( properties[2], important ) ) return false;
+        if( !parseValue( properties[3], important ) ) return false;
+	return true;
+    }
+    default:
+        return false;
     }
-    //kdDebug(6080) << "found background property!" << endl;
-    return found;
 }
 
-
-CSSValueImpl* StyleBaseImpl::parseContent(const QChar *curP, const QChar *endP)
+// [ <string> | <uri> | <counter> | attr(X) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit
+// in CSS 2.1 this got somewhat reduced:
+// [ <string> | attr(X) | open-quote | close-quote | no-open-quote | no-close-quote ]+ | inherit
+bool CSSParser::parseContent( int propId, bool important )
 {
     CSSValueListImpl* values = new CSSValueListImpl();
 
-
-    while (curP < endP) {
-        const QChar *nextP = curP;
-        bool esc = false;
-        bool sq = false;
-        bool dq = false;
-        while ( nextP < endP ) {
-            if (esc)
-                esc = false;
-            else if (*nextP == '\\')
-                esc = true;
-            else if (!sq && (*nextP == '"')) {
-                if (dq) break;
-                dq = true;
-            }
-            else if (!dq && (*nextP == '\'')) {
-                if (sq) break;
-                sq = true;
-            }
-            else if (!sq && !dq && nextP->isSpace())
-                break;
-            nextP++;
-        }
-        QConstString cstr(curP, nextP-curP);
-        QString str = cstr.string();
-        CSSValueImpl* parsedValue=0;
-        if (str.startsWith("url("))
-        {
+    Value *val;
+    CSSValueImpl *parsedValue = 0;
+    while ( (val = valueList->current()) ) {
+        if ( val->unit == CSSPrimitiveValue::CSS_URI ) {
             // url
-	    DOMString value(curP, endP - curP);
-	    value = khtml::parseURL(value);
+	    DOMString value = khtml::parseURL(domString(val->string));
             parsedValue = new CSSImageValueImpl(
-            DOMString(KURL(baseURL().string(), value.string()).url()), this);
+		DOMString(KURL( styleElement->baseURL().string(), value.string()).url() ), styleElement );
 #ifdef CSS_DEBUG
-	    kdDebug( 6080 ) << "content, url=" << value.string() << " base=" << baseURL().string() << endl;
+	    kdDebug( 6080 ) << "content, url=" << value.string() << " base=" << styleElement->baseURL().string() << endl;
 #endif
-        }
-        else if (str.startsWith("attr("))
-        {
-            // attr
-        }
-        else if (str.startsWith("counter("))
-        {
-            // counter
-        }
-        else if (str.startsWith("open-quote"))
-        {
-            // open-quote
-        }
-        else if (str.startsWith("close-quote"))
-        {
+        } else if ( val->unit == Value::Function ) {
+	    // attr( X )
+            ValueList *args = val->function->args;
+            QString fname = qString( val->function->name ).lower();
+            if ( fname != "attr(" || !args )
+                return false;
+            if ( args->numValues != 1)
+                return false;
+            Value *a = args->current();
+            parsedValue = new CSSPrimitiveValueImpl(domString(a->string), CSSPrimitiveValue::CSS_ATTR);
+        } else if ( val->unit == CSSPrimitiveValue::CSS_IDENT ) {
             // open-quote
-        }
-        else if (str.startsWith("no-open-quote"))
-        {
+            // close-quote
             // no-open-quote
-        }
-        else if (str.startsWith("no-close-quote"))
-        {
             // no-close-quote
-        }
-        else if (str.length() && (str[0] == '\'' || str[0] == '"'))
-        {
-            // string
-            int l = str.length();
-            QString strstr;
-            for (int i = 0; i < l; ++i) {
-                if (i < l - 1 && str[i] == '\\') {
-                    QChar nextChar = str[i+1];
-                    if (nextChar == '\n')
-                        i++;
-                    else if ( nextChar == '\r' ) {
-                        i++;
-                        if ( str[i+1] == '\n' )       
-                            i++;
-                    }
-                    else if ( isHexadecimal( nextChar ) ) 
-                    {                            
-                        int initial=i;                            
-                        QString hex;                            
-                        bool ok;                            
-                        while ( i-initial<6 && i<l-1 && isHexadecimal( nextChar ) ) {                                							hex += nextChar;                                
-                            i++;                                
-                            nextChar = str[i+1];                            
-                        }                               
-                            
-                        strstr += QChar( hex.toInt(&ok, 16) );                            
-                        
-                        if ( i<l-1 && nextChar.isSpace() ) {                                
-                            i++;                                
-                            if ( nextChar == '\r' && str[i+1] == '\n' )                                   										i++;
-                        }
-                    }                        
-                    else {                            
-                        ++i;                            
-                        strstr += nextChar;                
-                    }
-                }
-                else if (str[i] != '\'' && str[i] != '"')
-                    strstr += str[i];
-            }
-            parsedValue = new CSSPrimitiveValueImpl(DOMString(strstr), CSSPrimitiveValue::CSS_STRING);
+        } else if ( val->unit == CSSPrimitiveValue::CSS_STRING ) {
+            parsedValue = new CSSPrimitiveValueImpl(domString(val->string), CSSPrimitiveValue::CSS_STRING);
         }
         if (parsedValue)
             values->append(parsedValue);
-
-        // skip over whitespace
-        for (curP = ++nextP ; curP < endP && curP->isSpace(); ++curP)
-            ;
+	else
+	    break;
+	valueList->next();
     }
-    return values;
-}
-
-bool StyleBaseImpl::isHexadecimal( const QChar &c )
-{
-    return ( c >= '0' && c <= '9' ) || ( c >= 'a' && c <= 'f' ) || ( c >= 'A' && c <= 'F' );
-}
-
-QPtrList<QChar> StyleBaseImpl::splitShorthandProperties(const QChar *curP, const QChar *endP)
-{
-    bool last = false;
-    QPtrList<QChar> list;
-    while(!last) {
-        const QChar *nextP = curP;
-        while(!(nextP->isSpace())) {
-            nextP++;
-            if(nextP >= endP) {
-                last = true;
-                break;
-            }
-        }
-        list.append(curP);
-        list.append(nextP);
-        if ( last ) break;
-        while(nextP->isSpace()) { // skip over WS between tokens
-            nextP++;
-            curP = nextP;
-            if(curP >= endP) {
-                last = true;
-                break;
-            }
-        }
-    }
-    return list;
-}
-
-#ifdef CSS_AURAL
-// used for shorthand properties xxx{1,2}
-bool StyleBaseImpl::parse2Values( const QChar *curP, const QChar *endP, const int *properties)
-{
-    QPtrList<QChar> list = splitShorthandProperties(curP, endP);
-    switch(list.count())
-    {
-    case 2:
-        if(!parseValue(list.at(0), list.at(1), properties[0])) return false;
-        setParsedValue(properties[1], m_propList->last()->value() );
-        return true;
-    case 4:
-        if(!parseValue(list.at(0), list.at(1), properties[0])) return false;
-        if(!parseValue(list.at(2), list.at(3), properties[1])) return false;
-        return true;
-    default:
-        return false;
+    if ( values->length() ) {
+	addProperty( propId, values, important );
+	valueList->next();
+	return true;
     }
+    delete values;
+    return false;
 }
-#endif
 
-// used for shorthand properties xxx{1,4}
-bool StyleBaseImpl::parse4Values( const QChar *curP, const QChar *endP, const int *properties)
+bool CSSParser::parseShape( int propId, bool important )
 {
-    /* From the CSS 2 specs, 8.3
-     * If there is only one value, it applies to all sides. If there are two values, the top and
-     * bottom margins are set to the first value and the right and left margins are set to the second.
-     * If there are three values, the top is set to the first value, the left and right are set to the
-     * second, and the bottom is set to the third. If there are four values, they apply to the top,
-     * right, bottom, and left, respectively.
-     */
+    Value *value = valueList->current();
+    ValueList *args = value->function->args;
+    QString fname = qString( value->function->name ).lower();
+    if ( fname != "rect(" || !args )
+	return false;
 
-    QPtrList<QChar> list = splitShorthandProperties(curP, endP);
-    switch(list.count())
-    {
-    case 2:
-        if(!parseValue(list.at(0), list.at(1), properties[0])) return false;
-        setParsedValue(properties[1], m_propList->last()->value());
-        setParsedValue(properties[2], m_propList->last()->value());
-        setParsedValue(properties[3], m_propList->last()->value());
-        return true;
-    case 4:
-        if(!parseValue(list.at(0), list.at(1), properties[0])) return false;
-        setParsedValue(properties[2], m_propList->last()->value());
-        if(!parseValue(list.at(2), list.at(3), properties[1])) return false;
-        setParsedValue(properties[3], m_propList->last()->value());
-        return true;
-    case 6:
-        if(!parseValue(list.at(0), list.at(1), properties[0])) return false;
-        if(!parseValue(list.at(2), list.at(3), properties[1])) return false;
-        setParsedValue(properties[3], m_propList->last()->value());
-        if(!parseValue(list.at(4), list.at(5), properties[2])) return false;
-        return true;
-    case 8:
-        if(!parseValue(list.at(0), list.at(1), properties[0])) return false;
-        if(!parseValue(list.at(2), list.at(3), properties[1])) return false;
-        if(!parseValue(list.at(4), list.at(5), properties[2])) return false;
-        if(!parseValue(list.at(6), list.at(7), properties[3])) return false;
-        return true;
-    default:
-        return false;
+    // rect( t, r, b, l ) || rect( t r b l )
+    if ( args->numValues != 4 && args->numValues != 7 )
+	return false;
+    RectImpl *rect = new RectImpl();
+    bool valid = true;
+    int i = 0;
+    Value *a = args->current();
+    while ( a ) {
+	valid = validUnit( a, FLength, strict );
+	if ( !valid )
+	    break;
+	CSSPrimitiveValueImpl *length =
+	    new CSSPrimitiveValueImpl( a->fValue, (CSSPrimitiveValue::UnitTypes) a->unit );
+	if ( i == 0 )
+	    rect->setTop( length );
+	else if ( i == 1 )
+	    rect->setRight( length );
+	else if ( i == 2 )
+	    rect->setBottom( length );
+	else
+	    rect->setLeft( length );
+	a = args->next();
+	if ( a && args->numValues == 7 ) {
+	    if ( a->unit == Value::Operator && a->iValue == ',' ) {
+		a = args->next();
+	    } else {
+		valid = false;
+		break;
+	    }
+	}
+	i++;
     }
+    if ( valid ) {
+	addProperty( propId, new CSSPrimitiveValueImpl( rect ), important );
+	valueList->next();
+	return true;
+    }
+    delete rect;
+    return false;
 }
 
-CSSPrimitiveValueImpl *
-StyleBaseImpl::parseUnit(const QChar * curP, const QChar *endP, int allowedUnits)
+// [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]? 'font-family'
+bool CSSParser::parseFont( bool important )
 {
-    // Everything should be lowercase -> preprocess
-    //assert(QString(curP, endP-curP).lower()==QString(curP,endP-curP));
-
-    if (curP==endP || *curP=='"') {return 0; /* e.g.: width=""  length="ffffff" */}
-
-    endP--;
-    while(*endP == ' ' && endP > curP) endP--;
-    const QChar *split = endP;
-    // splt up number and unit
-    while( (*split < '0' || *split > '9') && *split != '.' && split > curP)
-        split--;
-    split++;
-
-    QString s(curP, split-curP);
-
-    bool isInt = false;
-    if(s.find('.') == -1) isInt = true;
-
-    bool ok;
-    float value = s.toFloat(&ok);
-    if ( !ok || (value < 0 && (allowedUnits & NONNEGATIVE)) )
-	return 0;
-
-    if(split > endP) // no unit
-    {
-        if(allowedUnits & NUMBER)
-            return new CSSPrimitiveValueImpl(value, CSSPrimitiveValue::CSS_NUMBER);
-
-        if(allowedUnits & INTEGER && isInt) // ### DOM CSS doesn't seem to define something for integer
-            return new CSSPrimitiveValueImpl(value, CSSPrimitiveValue::CSS_NUMBER);
-
-        // ### according to the css specs only 0 is allowed without unit.
-        // there are however too many web pages out there using CSS without units
-        // cause ie and ns allow them. We do so if the document is not using a strict dtd
-        if(( allowedUnits & LENGTH ) && (value == 0 || !strictParsing) )
-            return new CSSPrimitiveValueImpl(value, CSSPrimitiveValue::CSS_PX);
-
-        return 0;
+//     kdDebug(6080) << "parsing font property current=" << valueList->currentValue << endl;
+    bool valid = true;
+    Value *value = valueList->current();
+    FontValueImpl *font = new FontValueImpl;
+    // optional font-style, font-variant and font-weight
+    while ( value ) {
+// 	kdDebug( 6080 ) << "got value " << value->id << " / " << (value->unit == CSSPrimitiveValue::CSS_STRING ||
+	// 				   value->unit == CSSPrimitiveValue::CSS_IDENT ? qString( value->string ) : QString::null )
+// 			<< endl;
+	int id = value->id;
+	if ( id ) {
+	    if ( id == CSS_VAL_NORMAL ) {
+		// do nothing, it's the inital value for all three
+	    }
+	    /*
+	      else if ( id == CSS_VAL_INHERIT ) {
+	      // set all non set ones to inherit
+	      // This is not that simple as the inherit could also apply to the following font-size.
+	      // very ahrd to tell without looking ahead.
+	      inherit = true;
+		} */
+	    else if ( id == CSS_VAL_ITALIC || id == CSS_VAL_OBLIQUE ) {
+		if ( font->style )
+		    goto invalid;
+		font->style = new CSSPrimitiveValueImpl( id );
+	    } else if ( id == CSS_VAL_SMALL_CAPS ) {
+		if ( font->variant )
+		    goto invalid;
+		font->variant = new CSSPrimitiveValueImpl( id );
+	    } else if ( id >= CSS_VAL_BOLD && id <= CSS_VAL_LIGHTER ) {
+		if ( font->weight )
+		    goto invalid;
+		font->weight = new CSSPrimitiveValueImpl( id );
+	    } else {
+		valid = false;
+	    }
+	} else if ( !font->weight && validUnit( value, FInteger|FNonNeg, true ) ) {
+	    int weight = (int)value->fValue;
+	    int val = 0;
+	    if ( weight == 100 )
+		val = CSS_VAL_100;
+	    else if ( weight == 200 )
+		val = CSS_VAL_200;
+	    else if ( weight == 300 )
+		val = CSS_VAL_300;
+	    else if ( weight == 400 )
+		val = CSS_VAL_400;
+	    else if ( weight == 500 )
+		val = CSS_VAL_500;
+	    else if ( weight == 600 )
+		val = CSS_VAL_600;
+	    else if ( weight == 700 )
+		val = CSS_VAL_700;
+	    else if ( weight == 800 )
+		val = CSS_VAL_800;
+	    else if ( weight == 900 )
+		val = CSS_VAL_900;
+
+	    if ( val )
+		font->weight = new CSSPrimitiveValueImpl( val );
+	    else
+		valid = false;
+	} else {
+	    valid = false;
+	}
+	if ( !valid )
+	    break;
+	value = valueList->next();
+    }
+    if ( !value )
+	goto invalid;
+
+    // set undefined values to default
+    if ( !font->style )
+	font->style = new CSSPrimitiveValueImpl( CSS_VAL_NORMAL );
+    if ( !font->variant )
+	font->variant = new CSSPrimitiveValueImpl( CSS_VAL_NORMAL );
+    if ( !font->weight )
+	font->weight = new CSSPrimitiveValueImpl( CSS_VAL_NORMAL );
+
+//     kdDebug( 6080 ) << "  got style, variant and weight current=" << valueList->currentValue << endl;
+
+    // now a font size _must_ come
+    // <absolute-size> | <relative-size> | <length> | <percentage> | inherit
+    if ( value->id >= CSS_VAL_XX_SMALL && value->id <= CSS_VAL_LARGER )
+	font->size = new CSSPrimitiveValueImpl( value->id );
+    else if ( validUnit( value, FLength|FPercent, strict ) ) {
+	font->size = new CSSPrimitiveValueImpl( value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit );
+    }
+    value = valueList->next();
+    if ( !font->size || !value )
+	goto invalid;
+
+    // kdDebug( 6080 ) << "  got size" << endl;
+
+    if ( value->unit == Value::Operator && value->iValue == '/' ) {
+	// line-height
+	value = valueList->next();
+	if ( !value )
+	    goto invalid;
+	if ( value->id == CSS_VAL_NORMAL ) {
+	    // default value, nothing to do
+	} else if ( validUnit( value, FNumber|FLength|FPercent, strict ) ) {
+	    font->lineHeight = new CSSPrimitiveValueImpl( value->fValue, (CSSPrimitiveValue::UnitTypes) value->unit );
+	} else {
+	    goto invalid;
+	}
+	value = valueList->next();
+	if ( !value )
+	    goto invalid;
+    } else {
+	font->lineHeight = new CSSPrimitiveValueImpl( CSS_VAL_NORMAL );
     }
 
-    CSSPrimitiveValue::UnitTypes type = CSSPrimitiveValue::CSS_UNKNOWN;
-    StyleBaseImpl::Units unit = StyleBaseImpl::UNKNOWN;
+//     kdDebug( 6080 ) << "  got line height current=" << valueList->currentValue << endl;
+    // font family must come now
+    font->family = parseFontFamily();
 
-    bool collapsible = false;
-    
-    switch(split->latin1())
-    {
-    case '%':
-        type = CSSPrimitiveValue::CSS_PERCENTAGE;
-        unit =StyleBaseImpl:: PERCENT;
-        break;
-    case '_':
-        if (!(allowedUnits & COLLAPSIBLE))
-            break;
-        split++;
-        if (split > endP) break;
-        switch (split->latin1()) {
-        case 'q':
-            split++;
-            if (split > endP) break;
-            switch (split->latin1()) {
-            case 'e':
-                split++;
-                if(split > endP) break;
-                switch(split->latin1())
-                {
-                    case 'm':
-                        type = CSSPrimitiveValue::CSS_EMS;
-                        unit = StyleBaseImpl::LENGTH;
-                        collapsible = true;
-                        break;
-                }
-            }
-            break;
-        }
-        break;
-    case 'e':
-        split++;
-        if(split > endP) break;
-        switch(split->latin1())
-	{
-	case 'm':
-            type = CSSPrimitiveValue::CSS_EMS;
-            unit = StyleBaseImpl::LENGTH;
-            break;
-	case 'x':
-            type = CSSPrimitiveValue::CSS_EXS;
-            unit = StyleBaseImpl::LENGTH;
-            break;
-        }
-        break;
-    case 'p':
-        split++;
-        if(split > endP) break;
-	switch(split->latin1())
-	{
-	case 'x':
-            type = CSSPrimitiveValue::CSS_PX;
-            unit = StyleBaseImpl::LENGTH;
-            break;
-	case 't':
-            type = CSSPrimitiveValue::CSS_PT;
-            unit = StyleBaseImpl::LENGTH;
-            break;
-	case 'c':
-            type = CSSPrimitiveValue::CSS_PC;
-            unit = StyleBaseImpl::LENGTH;
-            break;
-        }
-        break;
-    case 'c':
-        split++;
-        if(split > endP) break;
-        if(split->latin1() == 'm')
-        {
-            type = CSSPrimitiveValue::CSS_CM;
-            unit = StyleBaseImpl::LENGTH;
-        }
-        break;
-    case 'm':
-        split++;
-        if(split > endP) break;
-        switch(split->latin1())
-	{
-	case 'm':
-            type = CSSPrimitiveValue::CSS_MM;
-            unit = StyleBaseImpl::LENGTH;
-            break;
-	case 's':
-            type = CSSPrimitiveValue::CSS_MS;
-            unit = StyleBaseImpl::TIME;
-            break;
-        }
-        break;
-    case 'i':
-        split++;
-        if(split > endP) break;
-        if(split->latin1() == 'n')
-        {
-            type = CSSPrimitiveValue::CSS_IN;
-            unit = StyleBaseImpl::LENGTH;
-        }
-        break;
-    case 'd':
-        type = CSSPrimitiveValue::CSS_DEG;
-        unit = StyleBaseImpl::ANGLE;
-        break;
-    case 'r':
-        type = CSSPrimitiveValue::CSS_RAD;
-        unit = StyleBaseImpl::ANGLE;
-        break;
-    case 'g':
-        type = CSSPrimitiveValue::CSS_GRAD;
-        unit = StyleBaseImpl::ANGLE;
-        break;
-    case 's':
-        type = CSSPrimitiveValue::CSS_S;
-        unit = StyleBaseImpl::TIME;
-        break;
-    case 'h':
-        type = CSSPrimitiveValue::CSS_HZ;
-        unit = StyleBaseImpl::FREQUENCY;
-        break;
-    case 'k':
-        type = CSSPrimitiveValue::CSS_KHZ;
-        unit = StyleBaseImpl::FREQUENCY;
-        break;
-    }
+    if ( valueList->current() || !font->family )
+	goto invalid;
+//     kdDebug( 6080 ) << "  got family, parsing ok!" << endl;
 
-    // Error handling. e.g., don't treat 10pts as a valid unit.
-    split++;
-    if (split <= endP && split->latin1() != ';' && split->isLetterOrNumber())
-        return 0;
-        
-    if(unit & allowedUnits)
-    {
-#ifdef CSS_DEBUG
-        kdDebug( 6080 ) << "found allowed number " << value << ", unit " << type << endl;
-#endif
-        if (collapsible)
-            return new CSSQuirkPrimitiveValueImpl(value, type);
-        return new CSSPrimitiveValueImpl(value, type);
-    }
+    addProperty( CSS_PROP_FONT, font, important );
+    return true;
 
-    return 0;
+ invalid:
+//     kdDebug(6080) << "   -> invalid" << endl;
+    delete font;
+    return false;
 }
 
-CSSRuleImpl *
-StyleBaseImpl::parseStyleRule(const QChar *&curP, const QChar *endP)
+CSSValueListImpl *CSSParser::parseFontFamily()
 {
-    //kdDebug( 6080 ) << "style rule is \'" << QString(curP, endP-curP) << "\'" << endl;
-
-    const QChar *startP;
-    QPtrList<CSSSelector> *slist;
-    QPtrList<CSSProperty> *plist;
-
-    startP = curP;
-    curP = parseToChar(startP, endP, '{', false);
-    if (!curP)
-        return(0);
-#ifdef CSS_DEBUG
-    kdDebug( 6080 ) << "selector is \'" << QString(startP, curP-startP) << "\'" << endl;
-#endif
-
-    slist = parseSelector(startP, curP );
+//     kdDebug( 6080 ) << "CSSParser::parseFontFamily current=" << valueList->currentValue << endl;
+    CSSValueListImpl *list = new CSSValueListImpl;
+    Value *value = valueList->current();
+    while ( value ) {
+// 	kdDebug( 6080 ) << "got value " << value->id << " / "
+// 			<< (value->unit == CSSPrimitiveValue::CSS_STRING ||
+// 			    value->unit == CSSPrimitiveValue::CSS_IDENT ? qString( value->string ) : QString::null )
+// 			<< endl;
+	int id = value->id;
+	if ( id >= CSS_VAL_SERIF && id <= CSS_VAL__KONQ_BODY )
+	    list->append( new CSSPrimitiveValueImpl( id ) );
+	else if ( value->unit == CSSPrimitiveValue::CSS_STRING ||
+		  value->unit == CSSPrimitiveValue::CSS_IDENT )
+	    list->append( new FontFamilyValueImpl( qString( value->string ) ) );
+	else {
+// 	    kdDebug( 6080 ) << "invalid family part" << endl;
+	    break;
+	}
+	value = valueList->next();
+	if ( !value || value->unit != Value::Operator || value->iValue != ',' ) {
+	    break;
+	}
+	value = valueList->next();
+    }
+    if ( !list->length() ) {
+	delete list;
+	list = 0;
+    }
+    return list;
+}
 
-    curP++; // need to get past the '{' from above
 
-    startP = curP;
-    curP = parseToChar(startP, endP, '}', false);
+static QRgb parseColor(const QString &name)
+{
+    int len = name.length();
 
-    if (!curP)
-    {
-        delete slist;
-        return(0);
-    }
-#ifdef CSS_DEBUG
-    kdDebug( 6080 ) << "rules are \'" << QString(startP, curP-startP) << "\'" << endl;
-#endif
+    if ( !len )
+        return khtml::invalidColor;
 
-    plist = parseProperties(startP, curP );
 
-    curP++; // need to get past the '}' from above
+    bool ok;
 
-    if (!plist || !slist)
-    {
-        // Useless rule
-        delete slist;
-        delete plist;
-#ifdef CSS_DEBUG
-        kdDebug( 6080 ) << "bad style rule" << endl;
-#endif
-        return 0;
+    if ( len == 3 || len == 6 ) {
+	int val = name.toInt(&ok, 16);
+	if ( ok ) {
+	    if (len == 6)
+		return (0xff << 24) | val;
+	    else if ( len == 3 )
+		// #abc converts to #aabbcc according to the specs
+		return (0xff << 24) |
+		    (val&0xf00)<<12 | (val&0xf00)<<8 |
+		    (val&0xf0)<<8 | (val&0xf0)<<4 |
+		    (val&0xf)<<4 | (val&0xf);
+	}
     }
 
-    // return the newly created rule
-    CSSStyleRuleImpl *rule = new CSSStyleRuleImpl(this);
-    CSSStyleDeclarationImpl *decl = new CSSStyleDeclarationImpl(rule, plist);
+    // try a little harder
+    QColor tc;
+    tc.setNamedColor(name.lower());
+    if (tc.isValid()) return tc.rgb();
 
-    rule->setSelector(slist);
-    rule->setDeclaration(decl);
-    // ### set selector and value
-    return rule;
+    return khtml::invalidColor;
 }
 
-CSSRuleImpl *
-StyleBaseImpl::parseRule(const QChar *&curP, const QChar *endP)
-{
-    const QChar *startP;
 
-    curP = parseSpace( curP, endP );
-
-    if (!strictParsing) {
-	// allow ; between rules (not part of spec)
-	while (curP && (curP->isSpace() || *curP == ';'))
-	    curP++;
+CSSPrimitiveValueImpl *CSSParser::parseColor()
+{
+    QRgb c = khtml::invalidColor;
+    Value *value = valueList->current();
+    if ( !strict && value->unit == CSSPrimitiveValue::CSS_NUMBER &&
+        value->fValue >= 0. && value->fValue < 1000000. ) {
+        QString str;
+        str.sprintf( "%06d", (int)(value->fValue+.5) );
+        c = ::parseColor( str );
+    } else if ( value->unit == CSSPrimitiveValue::CSS_RGBCOLOR ||
+              value->unit == CSSPrimitiveValue::CSS_IDENT ||
+              value->unit == CSSPrimitiveValue::CSS_STRING ||
+              value->unit == CSSPrimitiveValue::CSS_DIMENSION )
+	c = ::parseColor( qString( value->string ));
+    else if ( value->unit == Value::Function &&
+		value->function->args->numValues == 5 /* rgb + two commas */ &&
+		qString( value->function->name ).lower() == "rgb(" ) {
+	ValueList *args = value->function->args;
+	Value *v = args->current();
+	if ( !validUnit( v, FInteger|FPercent, true ) )
+	    return 0;
+	int r = (int) ( v->fValue * (v->unit == CSSPrimitiveValue::CSS_PERCENTAGE ? 256./100. : 1.) );
+	v = args->next();
+	if ( v->unit != Value::Operator && v->iValue != ',' )
+	    return 0;
+	v = args->next();
+	if ( !validUnit( v, FInteger|FPercent, true ) )
+	    return 0;
+	int g = (int) ( v->fValue * (v->unit == CSSPrimitiveValue::CSS_PERCENTAGE ? 256./100. : 1.) );
+	v = args->next();
+	if ( v->unit != Value::Operator && v->iValue != ',' )
+	    return 0;
+	v = args->next();
+	if ( !validUnit( v, FInteger|FPercent, true ) )
+	    return 0;
+	int b = (int) ( v->fValue * (v->unit == CSSPrimitiveValue::CSS_PERCENTAGE ? 256./100. : 1.) );
+	r = QMAX( 0, QMIN( 255, r ) );
+	g = QMAX( 0, QMIN( 255, g ) );
+	b = QMAX( 0, QMIN( 255, b ) );
+	c = qRgb( r, g, b );
     }
 
-    startP = curP;
-    CSSRuleImpl *rule = 0;
+    if ( c != khtml::invalidColor )
+	return new CSSPrimitiveValueImpl(c);
+    return 0;
+}
+
 
-    if(!curP) return 0;
+static inline int yyerror( const char *str ) {
 #ifdef CSS_DEBUG
-    kdDebug( 6080 ) << "parse rule: current = " << curP->latin1() << endl;
+    kdDebug( 6080 ) << "CSS parse error " << str << endl;
+#else
+    Q_UNUSED( str );
 #endif
-
-    if (*curP == '@' && curP != endP && ( (curP+1)->isLetter() || (curP+1)->unicode() > 0xa0 )  )
-    {
-        rule = parseAtRule(curP, endP);
-    }
-    else
-    {
-        rule = parseStyleRule(curP, endP);
-        if( rule )
-            hasInlinedDecl = true;  // set flag to true iff we have a valid inlined decl.
-    }
-
-    if(curP) curP++;
-    return rule;
+    return 1;
 }
 
-/* Generate a sort of Normal Form for CSS.
- * Remove comments, it is guaranteed that there will not be more then one space between
- * tokens and all the tokens within curly braces are lower case (except text
- * within quotes and url tags). Space is replaced with QChar(' ') and removed where
- * it's not necessary.
- *
- * 4.1.3 Characters and case
- *
- * The following rules always hold:
- *
- *  All CSS style sheets are case-insensitive, except for parts that are not under
- *  the control of CSS. For example, the case-sensitivity of values of the HTML
- *  attributes "id" and "class", of font names, and of URIs lies outside the scope
- *  of this specification. Note in particular that element names are case-insensitive
- *  in HTML, but case-sensitive in XML.
- */
+#define END 0
 
-const QString StyleBaseImpl::preprocess(const QString &str, bool justOneRule)
-{
-  // ### use DOMString here to avoid coversions
-
-  char fixedSizeBuffer[8192];
-  uint size = str.length() * 2 * sizeof(QChar);
-  char *buffer = fixedSizeBuffer;
-  if (size > sizeof(fixedSizeBuffer))
-    buffer = new char [size];
-  QChar *p = (QChar *)buffer;
-
-  bool sq = false;	// Within single quote
-  bool dq = false;	// Within double quote
-  bool bracket = false;	// Within brackets, e.g. url(ThisIsStupid)
-  bool comment = false; // Within comment
-  bool skipgarbage = !justOneRule; // skip <!-- and ---> only in specifc places
-  bool firstChar = false; // Beginning of comment either /* or */
-  bool space = true;    // Last token was space
-  int curlyBracket = 0; // Within curlyBrackets -> lower
-  hasInlinedDecl = false; // reset the inlined decl. flag
-
-  const QChar *ch = str.unicode();
-  const QChar *last = ch + str.length();
-
-#ifdef CSS_DEBUG
-  kdDebug(6080) << "---Before---" << endl;
-  kdDebug(6080) << str << endl;
-  float orgLength = str.length();
-  kdDebug(6080) << "Length: " << orgLength << endl;
-#endif
+#include "parser.h"
 
-  while(ch < last) {
-//       qDebug("current: *%s*, sq=%d dq=%d b=%d c=%d fC=%d space=%d cB=%d sg=%d",
-//              QConstString(ch, kMin(last-ch, 10)).string().latin1(), sq, dq, bracket, comment, firstChar, space, curlyBracket, skipgarbage);
-    if( !comment && !sq && *ch == '"' ) {
-      dq = !dq;
-      *p++ = *ch;
-      space = skipgarbage = false;
-    } else if ( !comment && !dq && *ch == '\'') {
-      skipgarbage = sq;
-      sq = !sq;
-      *p++ = *ch;
-      space = false;
-    } else if ( !comment && !dq && !sq && *ch == '(') {
-      bracket = true;
-      *p++ = *ch;
-      space = true;  // Explictly true
-      skipgarbage = false;
-    } else if ( !comment && !dq && !sq && *ch == ')') {
-      bracket = false;
-      *p++ = *ch;
-      *p++ = QChar(' '); // Adding a space after this token
-      space = true;
-      skipgarbage = false;
-    } else if ( !comment && !dq && !sq && *ch == '{') {
-      ++curlyBracket;
-      *p++ = *ch;
-      space = true;  // Explictly true
-      skipgarbage = true;
-    } else if ( !comment && !dq && !sq && *ch == '}') {
-      --curlyBracket;
-      *p++ = *ch;
-      *p++ = QChar(' '); // Adding a space after this token
-      space = true;
-      skipgarbage = true;
-    } else if ( !comment && skipgarbage && !dq && !sq && (*ch == '-') && ((ch+2) < last)  /* SGML Comment */
-                && (*(ch+1) == '-') && (*(ch+2) == '>')) {
-        ch += 2; // skip -->
-    } else if ( !comment && skipgarbage && !dq && !sq && (*ch == '<') && ((ch+3) < last)  /* SGML Comment */
-                && (*(ch+1) == '!') && (*(ch+2) == '-') && (*(ch+3) == '-')) {
-        ch += 3; // skip <!--
-    } else if ( comment ) {
-      if ( firstChar && *ch == '/' ) {
-          comment = false;
-          firstChar = false;
-          skipgarbage = true;
-      } else {
-	firstChar = ( *ch == '*' );
-      }
-    } else if ( !sq && !dq && !bracket ) {
-      // check for comment
-      if ( firstChar ) {
-	if ( *ch == '*' ) {
-	  comment = true;
-	} else {
-	  *p++ = '/';
-	  if (curlyBracket > 0) {
-	    *p++ = ch->lower();
-	  } else {
-	    *p++ = *ch;
-	  }
-	  space = ch->isSpace();
-	}
-	firstChar = false;
-      } else if ( *ch == '/' ) {
-	firstChar = true; // Slash added only if next is not '*'
-      } else if ( *ch == ',' || *ch == ';') {
-	*p++ = *ch;
-	*p++ = QChar(' '); // Adding a space after these tokens
-	space = true;
-             skipgarbage = true;
-      } else {
-          if (!ch->isSpace())
-              skipgarbage = false;
-	goto addChar;
-      }
-    } else {
-        skipgarbage = ch->isSpace();
-      goto addChar;
-    }
-  end:
-    ++ch;
-  }
-  
-  {
-    QString processed((QChar *)buffer, p - (QChar *)buffer);
-    if (buffer != fixedSizeBuffer)
-        delete [] buffer;
+int DOM::CSSParser::lex( void *_yylval ) {
+    YYSTYPE *yylval = (YYSTYPE *)_yylval;
+    int token = lex();
+    int length;
+    unsigned short *t = text( &length );
 
-#ifdef CSS_DEBUG
-  kdDebug(6080) << "---After ---" << endl;
-  kdDebug(6080) << "[" << processed << "]" << endl;
-  kdDebug(6080) << "------------" << endl;
-  kdDebug(6080) << "Length: " << processed.length() << ", reduced size by: "
-		<< 100.0 - (100.0 * (processed.length()/orgLength)) << "%" << endl;
-  kdDebug(6080) << "------------" << endl;
+#ifdef TOKEN_DEBUG
+    qDebug("CSSTokenizer: got token %d: '%s'", token, token == END ? "" : QString( (QChar *)t, length ).latin1() );
 #endif
+    switch( token ) {
+    case S:
+    case SGML_CD:
+    case INCLUDES:
+    case DASHMATCH:
+	break;
+
+    case URI:
+    case STRING:
+    case IDENT:
+    case HASH:
+    case DIMEN:
+    case UNICODERANGE:
+    case FUNCTION:
+	yylval->string.string = t;
+	yylval->string.length = length;
+	break;
+
+    case IMPORT_SYM:
+    case PAGE_SYM:
+    case MEDIA_SYM:
+    case FONT_FACE_SYM:
+    case CHARSET_SYM:
+
+    case IMPORTANT_SYM:
+	break;
+
+    case QEMS:
+	length--;
+    case GRADS:
+	length--;
+    case DEGS:
+    case RADS:
+    case KHERZ:
+	length--;
+    case MSECS:
+    case HERZ:
+    case EMS:
+    case EXS:
+    case PXS:
+    case CMS:
+    case MMS:
+    case INS:
+    case PTS:
+    case PCS:
+	length--;
+    case SECS:
+    case PERCENTAGE:
+	length--;
+    case NUMBER:
+	yylval->val = QString( (QChar *)t, length ).toDouble();
+	//qDebug("value = %s, converted=%.2f", QString( (QChar *)t, length ).latin1(), yylval->val );
+	break;
 
-    return processed;
-  }
-
- addChar:
-  if ( !sq && !dq && !bracket ) {
-    if (!(space && ch->isSpace())) { // Don't add more than one space
-      if (ch->isSpace()) {
-	*p++ = QChar(' '); // Normalize whitespace
-      } else {
-	if (curlyBracket > 0 || justOneRule) {
-	  *p++ = ch->lower();
-	} else {
-	  *p++ = *ch;
-	}
-      }
+    default:
+	break;
     }
-    space = ch->isSpace();
-  } else {
-    *p++ = *ch; // We're within quotes or brackets, leave untouched
-  }
-  goto end;
-}
-
-// ------------------------------------------------------------------------------
 
-StyleListImpl::~StyleListImpl()
-{
-    StyleBaseImpl *n;
-
-    if(!m_lstChildren) return;
-
-    for( n = m_lstChildren->first(); n != 0; n = m_lstChildren->next() )
-    {
-        n->setParent(0);
-        if( !n->refCount() ) delete n;
-    }
-    delete m_lstChildren;
+    return token;
 }
 
-// --------------------------------------------------------------------------------
-
-void CSSSelector::print(void)
-{
-    kdDebug( 6080 ) << "[Selector: tag = " <<       tag << ", attr = \"" << attr << "\", match = \"" << match << "\" value = \"" << value.string().latin1() << "\" relation = " << (int)relation << endl;
-    if ( tagHistory )
-        tagHistory->print();
+static inline int toHex( char c ) {
+    if ( '0' <= c && c <= '9' )
+	return c - '0';
+    if ( 'a' <= c && c <= 'f' )
+	return c - 'a' + 10;
+    if ( 'A' <= c && c<= 'F' )
+	return c - 'A' + 10;
+    return 0;
 }
 
-unsigned int CSSSelector::specificity()
+unsigned short *DOM::CSSParser::text(int *length)
 {
-    if ( nonCSSHint )
-        return 0;
+    unsigned short *start = yytext;
+    int l = yyleng;
+    switch( yyTok ) {
+    case STRING:
+	l--;
+	/* nobreak */
+    case HASH:
+	start++;
+	l--;
+	break;
+    case URI:
+	// "url("{w}{string}{w}")"
+	// "url("{w}{url}{w}")"
+
+	// strip "url(" and ")"
+	start += 4;
+	l -= 5;
+	// strip {w}
+	while ( l &&
+		(*start == ' ' || *start == '\t' || *start == '\r' ||
+		 *start == '\n' || *start == '\f' ) ) {
+	    start++; l--;
+	}
+	if ( *start == '"' || *start == '\'' ) {
+	    start++; l--;
+	}
+	while ( l &&
+		(start[l-1] == ' ' || start[l-1] == '\t' || start[l-1] == '\r' ||
+		 start[l-1] == '\n' || start[l-1] == '\f' ) ) {
+	    l--;
+	}
+	if ( l && (start[l-1] == '\"' || start[l-1] == '\'' ) )
+	     l--;
 
-    int s = (tag != -1);
-    switch(match)
-    {
-    case Exact:
-        if(attr == ATTR_ID)
-        {
-            s += 0x10000;
-            break;
+    default:
+	break;
+    }
+
+    // process escapes
+    unsigned short *out = start;
+    unsigned short *escape = 0;
+
+    for ( int i = 0; i < l; i++ ) {
+        unsigned short *current = start+i;
+        if ( escape == current - 1 ) {
+            if ( ( *current >= '0' && *current <= '9' ) ||
+                 ( *current >= 'a' && *current <= 'f' ) ||
+                 ( *current >= 'A' && *current <= 'F' ) )
+                continue;
+            if ( yyTok == STRING &&
+                 ( *current == '\n' || *current == '\r' || *current == '\f' ) ) {
+                // ### handle \r\n case
+                if ( *current != '\r' )
+                    escape = 0;
+                continue;
+            }
+            // in all other cases copy the char to output
+            // ###
+            *out++ = *current;
+            escape = 0;
+            continue;
         }
-    case Set:
-    case List:
-    case Hyphen:
-    case Pseudo:
-    case Contain:
-    case Begin:
-    case End:
-        s += 0x100;
-    case None:
-        break;
-    }
-    if(tagHistory)
-        s += tagHistory->specificity();
-    // make sure it doesn't overflow
-    return s & 0xffffff;
-}
-
-void CSSSelector::extractPseudoType() const
-{
-    if (match != Pseudo)
-        return;
-    _pseudoType = PseudoOther;
-    if (!value.isEmpty()) {
-        switch (value[0]) {
-            case 'a':
-                if (value == "active")
-                    _pseudoType = PseudoActive;
-                else if (value == "after")
-                    _pseudoType = PseudoAfter;
-                break;
-            case 'b':
-                if (value == "before")
-                    _pseudoType = PseudoBefore;
-                break;
-            case 'e':
-                if (value == "empty")
-                    _pseudoType = PseudoEmpty;
-                break;
-            case 'f':
-                if (value == "first-child")
-                    _pseudoType = PseudoFirstChild;
-                else if (value == "first-letter")
-                    _pseudoType = PseudoFirstLetter;
-                else if (value == "first-line")
-                    _pseudoType = PseudoFirstLine;
-                else if (value == "focus")
-                    _pseudoType = PseudoFocus;
-                break;
-            case 'h':
-                if (value == "hover")
-                    _pseudoType = PseudoHover;
-                break;
-            case 'l':
-                if (value == "link")
-                    _pseudoType = PseudoLink;
-                break;
-            case 'v':
-                if (value == "visited")
-                    _pseudoType = PseudoVisited;
-                break;
+        if ( escape == current - 2 && yyTok == STRING &&
+             *(current-1) == '\r' && *current == '\n' ) {
+            escape = 0;
+            continue;
         }
-    }
-    
-    value = QString::null;
-}
-
-
-bool CSSSelector::operator == ( const CSSSelector &other )
-{
-    const CSSSelector *sel1 = this;
-    const CSSSelector *sel2 = &other;
-
-    while ( sel1 && sel2 ) {
-	if ( sel1->tag != sel2->tag || sel1->attr != sel2->attr ||
-	     sel1->relation != sel2->relation || sel1->match != sel2->match ||
-	     sel1->nonCSSHint != sel2->nonCSSHint ||
-	     sel1->value != sel2->value ||
-             sel1->pseudoType() != sel2->pseudoType())
-	    return false;
-	sel1 = sel1->tagHistory;
-	sel2 = sel2->tagHistory;
-    }
-    if ( sel1 || sel2 )
-	return false;
-    return true;
-}
-
-DOMString CSSSelector::selectorText() const
-{
-    DOMString str;
-    const CSSSelector* cs = this;
-    if ( cs->tag == -1 && cs->attr == ATTR_ID && cs->match == CSSSelector::Exact )
-    {
-        str = "#";
-        str += cs->value;
-    }
-    else if ( cs->tag == -1 && cs->attr == ATTR_CLASS && cs->match == CSSSelector::List )
-    {
-        str = ".";
-        str += cs->value;
-    }
-    else if ( cs->tag == -1 && cs->match == CSSSelector::Pseudo )
-    {
-        str = ":";
-        str += cs->value;
-    }
-    else
-    {
-        if ( cs->tag == -1 )
-            str = "*";
-        else
-            str = getTagName( cs->tag );
-        if ( cs->attr == ATTR_ID && cs->match == CSSSelector::Exact )
-        {
-            str += "#";
-            str += cs->value;
-        }
-        else if ( cs->attr == ATTR_CLASS && cs->match == CSSSelector::List )
-        {
-            str += ".";
-            str += cs->value;
+        if ( escape > current - 7 &&
+             ( ( *current >= '0' && *current <= '9' ) ||
+               ( *current >= 'a' && *current <= 'f' ) ||
+               ( *current >= 'A' && *current <= 'F' ) ) )
+            continue;
+        if ( escape ) {
+            // add escaped char
+            int uc = 0;
+            escape++;
+            while ( escape < current ) {
+                // 		qDebug("toHex( %c = %x", (char)*escape, toHex( *escape ) );
+                uc *= 16;
+                uc += toHex( *escape );
+                escape++;
+            }
+            // 	    qDebug(" converting escape: string='%s', value=0x%x", QString( (QChar *)e, current-e ).latin1(), uc );
+            // can't handle chars outside ucs2
+            if ( uc > 0xffff )
+                uc = 0xfffd;
+            *(out++) = (unsigned short)uc;
+            escape = 0;
+            if ( *current == ' ' ||
+                 *current == '\t' ||
+                 *current == '\r' ||
+                 *current == '\n' ||
+                 *current == '\f' )
+                continue;
         }
-        else if ( cs->match == CSSSelector::Pseudo )
-        {
-            str += ":";
-            str += cs->value;
+        if ( !escape && *current == '\\' ) {
+            escape = current;
+            continue;
         }
-        // optional attribute
-        if ( cs->attr ) {
-            DOMString attrName = getAttrName( cs->attr );
-            str += "[";
-            str += attrName;
-            switch (cs->match) {
-            case CSSSelector::Exact:
-                str += "=";
-                break;
-            case CSSSelector::Set:
-                str += " "; /// ## correct?
-                       break;
-            case CSSSelector::List:
-                str += "~=";
-                break;
-            case CSSSelector::Hyphen:
-                str += "|=";
-                break;
-            case CSSSelector::Begin:
-                str += "^=";
-                break;
-            case CSSSelector::End:
-                str += "$=";
-                break;
-            case CSSSelector::Contain:
-                str += "*=";
-                break;
-            default:
-                kdWarning(6080) << "Unhandled case in CSSStyleRuleImpl::selectorText : match=" << cs->match << endl;
-            }
-            str += "\"";
-            str += cs->value;
-            str += "\"]";
+        *(out++) = *current;
+    }
+    if ( escape ) {
+        // add escaped char
+        int uc = 0;
+        escape++;
+        while ( escape < start+l ) {
+            // 		qDebug("toHex( %c = %x", (char)*escape, toHex( *escape ) );
+            uc *= 16;
+            uc += toHex( *escape );
+            escape++;
         }
+        // 	    qDebug(" converting escape: string='%s', value=0x%x", QString( (QChar *)e, current-e ).latin1(), uc );
+        // can't handle chars outside ucs2
+        if ( uc > 0xffff )
+            uc = 0xfffd;
+        *(out++) = (unsigned short)uc;
     }
-    if ( cs->tagHistory ) {
-        DOMString tagHistoryText = cs->tagHistory->selectorText();
-        if ( cs->relation == Sibling )
-            str = tagHistoryText + " + " + str;
-        else if ( cs->relation == Child )
-            str = tagHistoryText + " > " + str;
-        else if ( cs->relation == SubSelector )
-            str += tagHistoryText; // the ":" is provided by selectorText()
-        else // Descendant
-            str = tagHistoryText + " " + str;
-    }
-    return str;
+    
+    *length = out - start;
+    return start;
 }
 
-// ----------------------------------------------------------------------------
 
+#define YY_DECL int DOM::CSSParser::lex()
+#define yyconst const
+typedef int yy_state_type;
+typedef unsigned int YY_CHAR;
+// this line makes sure we treat all Unicode chars correctly.
+#define YY_SC_TO_UI(c) (c > 0xff ? 0xff : c)
+#define YY_DO_BEFORE_ACTION \
+	yytext = yy_bp; \
+	yyleng = (int) (yy_cp - yy_bp); \
+	yy_hold_char = *yy_cp; \
+	*yy_cp = 0; \
+	yy_c_buf_p = yy_cp;
+#define YY_BREAK break;
+#define ECHO qDebug( "%s", QString( (QChar *)yytext, yyleng ).latin1() )
+#define YY_RULE_SETUP
+#define INITIAL 0
+#define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
+#define yyterminate() yyTok = END; return yyTok
+#define YY_FATAL_ERROR(a) qFatal(a)
+#define BEGIN yy_start = 1 + 2 *
+#define COMMENT 1
+
+#include "tokenizer.cpp"
diff --git a/WebCore/khtml/css/cssparser.h b/WebCore/khtml/css/cssparser.h
index ffa5b64..0f46efa 100644
--- a/WebCore/khtml/css/cssparser.h
+++ b/WebCore/khtml/css/cssparser.h
@@ -1,9 +1,9 @@
 /*
- * This file is part of the CSS implementation for KDE.
+ * This file is part of the DOM implementation for KDE.
  *
- * Copyright (C) 1999 Lars Knoll (knoll at kde.org)
- *               1999 Waldo Bastian (bastian at kde.org)
- * Copyright (C) 2003 Apple Computer, Inc.
+ * Copyright (C) 2003 Lars Knoll (knoll at kde.org)
+ *
+ * $Id$
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -19,246 +19,143 @@
  * along with this library; see the file COPYING.LIB.  If not, write to
  * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  * Boston, MA 02111-1307, USA.
- *
  */
 #ifndef _CSS_cssparser_h_
 #define _CSS_cssparser_h_
 
-#include "dom/dom_string.h"
-#include "dom/dom_misc.h"
-#include "misc/shared.h"
-#include <qdatetime.h>
-#include <qptrlist.h>
+#include <qstring.h>
+#include <dom/dom_string.h>
 
 namespace DOM {
-
-    class StyleSheetImpl;
-    class MediaList;
-
-    class CSSSelector;
-    class CSSProperty;
-    class CSSValueImpl;
-    class CSSPrimitiveValueImpl;
-    class CSSStyleDeclarationImpl;
+    class StyleListImpl;
+    class CSSStyleSheetImpl;
     class CSSRuleImpl;
     class CSSStyleRuleImpl;
-
     class DocumentImpl;
+    class CSSValueImpl;
+    class CSSValueListImpl;
+    class CSSPrimitiveValueImpl;
+    class CSSStyleDeclarationImpl;
+    class CSSProperty;
+    class CSSRuleListImpl;
 
-    int getPropertyID(const char *tagStr, int len);
-
-// this class represents a selector for a StyleRule
-class CSSSelector
-{
-public:
-    CSSSelector()
-	: tagHistory(0), attr(0), tag(0), relation( Descendant ),
-    match( None ), nonCSSHint( false ), pseudoId( 0 ), _pseudoType(PseudoNotParsed) {}
-
-    ~CSSSelector() {
-	delete tagHistory;
-    }
-
-    /**
-     * Print debug output for this selector
-     */
-    void print();
-
-    /**
-     * Re-create selector text from selector's data
-     */
-    DOMString selectorText() const;
-
-    // checks if the 2 selectors (including sub selectors) agree.
-    bool operator == ( const CSSSelector &other );
 
-    // tag == -1 means apply to all elements (Selector = *)
+    struct ParseString {
+	unsigned short *string;
+	int length;
+    };
 
-    unsigned int specificity();
+    struct Value;
+    class ValueList;
 
-    /* how the attribute value has to match.... Default is Exact */
-    enum Match
-    {
-	None = 0,
-	Exact,
-	Set,
-	List,
-	Hyphen,
-	Pseudo,
-	Contain,   // css3: E[foo*="bar"]
-	Begin,     // css3: E[foo^="bar"]
-	End        // css3: E[foo$="bar"]
+    struct Function {
+	ParseString name;
+	ValueList *args;
     };
 
-    enum Relation
-    {
-	Descendant = 0,
-	Child,
-	Sibling,
-	SubSelector
-    };
-    
-    enum PseudoType
-    {
-        PseudoNotParsed = 0,
-        PseudoOther,
-	PseudoEmpty,
-        PseudoFirstChild,
-        PseudoFirstLine,
-        PseudoFirstLetter,
-        PseudoLink,
-        PseudoVisited,
-        PseudoHover,
-        PseudoFocus,
-        PseudoActive,
-        PseudoBefore,
-        PseudoAfter
+    struct Value {
+	int id;
+	union {
+	    double fValue;
+	    int iValue;
+	    ParseString string;
+	    Function *function;
+	};
+	enum {
+	    Operator = 0x100000,
+	    Function = 0x100001,
+	    Q_EMS     = 0x100002
+	};
+
+	int unit;
     };
 
-    inline PseudoType pseudoType() const
-    {
-        if (_pseudoType == PseudoNotParsed)
-            extractPseudoType();
-        return _pseudoType;
+    static inline QString qString( const ParseString &ps ) {
+	return QString( (QChar *)ps.string, ps.length );
+    }
+    static inline DOMString domString( const ParseString &ps ) {
+	return DOMString( (QChar *)ps.string, ps.length );
     }
 
-    mutable DOM::DOMString value;
-    CSSSelector *tagHistory;
-    int          attr;
-    int          tag;
-
-    Relation relation     : 2;
-    Match 	 match         : 4;
-    bool	nonCSSHint : 1;
-    unsigned int pseudoId : 3;
-    
-    mutable PseudoType _pseudoType;
-    
-private:
-    void extractPseudoType() const;
-};
+    class ValueList {
+    public:
+	ValueList();
+	~ValueList();
+	void addValue( const Value &val );
+	Value *current() { return currentValue < numValues ? values + currentValue : 0; }
+	Value *next() { ++currentValue; return current(); }
+	Value *values;
+	int numValues;
+	int maxValues;
+	int currentValue;
+    };
 
-    // a style class which has a parent (almost all have)
-    class StyleBaseImpl : public khtml::TreeShared<StyleBaseImpl>
+    class CSSParser
     {
     public:
-	StyleBaseImpl()  { m_parent = 0; hasInlinedDecl = false; strictParsing = true; sawDescendantRule = false; }
-	StyleBaseImpl(StyleBaseImpl *p) { m_parent = p; hasInlinedDecl = false; strictParsing = (m_parent ? m_parent->useStrictParsing() : true); sawDescendantRule = false; }
-
-	virtual ~StyleBaseImpl() {}
-
-	// returns the url of the style sheet this object belongs to
-	DOMString baseURL();
-
-	virtual bool isStyleSheet() const { return false; }
-	virtual bool isCSSStyleSheet() const { return false; }
-	virtual bool isStyleSheetList() const { return false; }
-	virtual bool isMediaList() { return false; }
-	virtual bool isRuleList() { return false; }
-	virtual bool isRule() { return false; }
-	virtual bool isStyleRule() { return false; }
-	virtual bool isCharetRule() { return false; }
-	virtual bool isImportRule() { return false; }
-	virtual bool isMediaRule() { return false; }
-	virtual bool isQuirksRule() { return false; }
-	virtual bool isFontFaceRule() { return false; }
-	virtual bool isPageRule() { return false; }
-	virtual bool isUnknownRule() { return false; }
-	virtual bool isStyleDeclaration() { return false; }
-	virtual bool isValue() { return false; }
-	virtual bool isPrimitiveValue() const { return false; }
-	virtual bool isValueList() { return false; }
-	virtual bool isValueCustom() { return false; }
-
-	void setParent(StyleBaseImpl *parent) { m_parent = parent; }
-
-	const QString preprocess(const QString &str, bool justOneRule = false);
-	const QChar *parseSpace(const QChar *curP, const QChar *endP);
-	const QChar *parseToChar(const QChar *curP, const QChar *endP,
-				 QChar c, bool chkws, bool endAtBlock = false);
-
-	CSSSelector *parseSelector2(const QChar *curP, const QChar *endP, CSSSelector::Relation relation);
-	CSSSelector *parseSelector1(const QChar *curP, const QChar *endP);
-	QPtrList<CSSSelector> *parseSelector(const QChar *curP, const QChar *endP);
-
-	void parseProperty(const QChar *curP, const QChar *endP);
-	QPtrList<CSSProperty> *parseProperties(const QChar *curP, const QChar *endP);
-
-	/* parses generic CSSValues, return true, if it found a valid value */
-	bool parseValue(const QChar *curP, const QChar *endP, int propId);
-	bool parseValue(const QChar *curP, const QChar *endP, int propId,
-			bool important, bool nonCSSHint, QPtrList<CSSProperty> *propList);
-	bool parseFont(const QChar *curP, const QChar *endP);
-	bool parse4Values(const QChar *curP, const QChar *endP, const int *properties);
-	bool parseShortHand(const QChar *curP, const QChar *endP, const int *properties, int num);
-	void setParsedValue(int propId, const CSSValueImpl *parsedValue);
-	void setParsedValue(int propId, const CSSValueImpl *parsedValue,
-			    bool important, bool nonCSSHint, QPtrList<CSSProperty> *propList);
-	bool isHexadecimal( const QChar &c );
-	QPtrList<QChar> splitShorthandProperties(const QChar *curP, const QChar *endP);
-	bool parseBackgroundPosition(const QChar *curP, const QChar *&nextP, const QChar *endP);
+	CSSParser( bool strictParsing = true );
+	~CSSParser();
 
-	/* define CSS_AURAL in cssparser.cpp if you want to parse CSS2 Aural properties */
-	bool parse2Values(const QChar *curP, const QChar *endP, const int *properties);
-	bool parseAuralValue(const QChar *curP, const QChar *endP, int propId);
+	void parseSheet( DOM::CSSStyleSheetImpl *sheet, const DOM::DOMString &string );
+	DOM::CSSRuleImpl *parseRule( const DOM::DOMString &string );
+	bool parseValue( DOM::CSSStyleDeclarationImpl *decls, int id, const DOM::DOMString &string,
+			 bool _important, bool _nonCSSHint );
+	bool parseDeclaration( DOM::CSSStyleDeclarationImpl *decls, const DOM::DOMString &string,
+			       bool _nonCSSHint );
 
-        CSSValueImpl* parseContent(const QChar *curP, const QChar *endP);
+	static CSSParser *current() { return currentParser; }
 
-	// defines units allowed for a certain property, used in parseUnit
-	enum Units
-	{
-	    UNKNOWN   = 0x0000,
-	    INTEGER   = 0x0001,
-	    NUMBER    = 0x0002,  // real numbers
-	    PERCENT   = 0x0004,
-	    LENGTH    = 0x0008,
-	    ANGLE     = 0x0010,
-	    TIME      = 0x0020,
-	    FREQUENCY = 0x0040,
-	    NONNEGATIVE = 0x0080,
-        COLLAPSIBLE = 0x010
-	};
-
-	/* called by parseValue, parses numbers+units */
-	CSSPrimitiveValueImpl *parseUnit(const QChar * curP, const QChar *endP, int allowedUnits);
-
-	CSSRuleImpl *parseAtRule(const QChar *&curP, const QChar *endP);
-
-	// the caller is responible for deleting the returned lists in the next to methods
-	CSSRuleImpl *parseStyleRule(const QChar *&curP, const QChar *endP);
-	CSSRuleImpl *parseRule(const QChar *&curP, const QChar *endP);
 
-	virtual bool parseString(const DOMString &/*cssString*/, bool = false) { return false; }
+	DOM::DocumentImpl *document() const;
 
-	virtual void checkLoaded();
+	void addProperty( int propId, CSSValueImpl *value, bool important );
+	bool hasProperties() const { return numParsedProperties > 0; }
+	CSSStyleDeclarationImpl *createStyleDeclaration( CSSStyleRuleImpl *rule );
+	void clearProperties();
 
-	void setStrictParsing( bool b ) { strictParsing = b; }
-	bool useStrictParsing() const { return strictParsing; }
+	bool parseValue( int propId, bool important );
+	bool parseShortHand( const int *properties, int numProperties, bool important );
+	bool parse4Values( const int *properties, bool important );
+	bool parseContent( int propId, bool important );
+	bool parseShape( int propId, bool important );
+	bool parseFont(bool important);
+	CSSValueListImpl *parseFontFamily();
+	CSSPrimitiveValueImpl *parseColor();
 
-    protected:
-	bool hasInlinedDecl : 1;
-	bool strictParsing : 1;
-    bool sawDescendantRule : 1;
-    };
-
-    // a style class which has a list of children (StyleSheets for example)
-    class StyleListImpl : public StyleBaseImpl
-    {
+	int yyparse( void );
     public:
-	StyleListImpl() : StyleBaseImpl() { m_lstChildren = 0; }
-	StyleListImpl(StyleBaseImpl *parent) : StyleBaseImpl(parent) { m_lstChildren = 0; }
-
-	virtual ~StyleListImpl();
-
-	unsigned long length() { return m_lstChildren->count(); }
-	StyleBaseImpl *item(unsigned long num) { return m_lstChildren->at(num); }
-
-	void append(StyleBaseImpl *item) { m_lstChildren->append(item); }
-
-    protected:
-	QPtrList<StyleBaseImpl> *m_lstChildren;
+	bool strict;
+	bool important;
+	bool nonCSSHint;
+	int id;
+	DOM::StyleListImpl *styleElement;
+	DOM::CSSRuleImpl *rule;
+	ValueList *valueList;
+	CSSProperty **parsedProperties;
+	int numParsedProperties;
+	int maxParsedProperties;
+	bool inParseShortHand;
+
+	static CSSParser *currentParser;
+
+	// tokenizer methods and data
+    public:
+	int lex( void *yylval );
+	int token() { return yyTok; }
+	unsigned short *text( int *length);
+	int lex();
+    private:
+
+	unsigned short *data;
+	unsigned short *yytext;
+	unsigned short *yy_c_buf_p;
+	unsigned short yy_hold_char;
+	int yy_last_accepting_state;
+	unsigned short *yy_last_accepting_cpos;
+	int yyleng;
+	int yyTok;
+	int yy_start;
     };
 
 }; // namespace
-
 #endif
diff --git a/WebCore/khtml/css/cssproperties.c b/WebCore/khtml/css/cssproperties.c
index cecd10a..73b4a34 100644
--- a/WebCore/khtml/css/cssproperties.c
+++ b/WebCore/khtml/css/cssproperties.c
@@ -118,7 +118,7 @@ findProp (register const char *str, register unsigned int len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 113,
+      TOTAL_KEYWORDS = 112,
       MIN_WORD_LENGTH = 3,
       MAX_WORD_LENGTH = 26,
       MIN_HASH_VALUE = 5,
@@ -228,7 +228,6 @@ findProp (register const char *str, register unsigned int len)
       {"max-width", CSS_PROP_MAX_WIDTH},
       {"marker-offset", CSS_PROP_MARKER_OFFSET},
       {"-konq-flow-mode", CSS_PROP__KONQ_FLOW_MODE},
-      {"-konq-js-clip", CSS_PROP__KONQ_JS_CLIP},
       {"list-style-image", CSS_PROP_LIST_STYLE_IMAGE},
       {"page-break-inside", CSS_PROP_PAGE_BREAK_INSIDE},
       {"text-transform", CSS_PROP_TEXT_TRANSFORM},
@@ -288,16 +287,16 @@ findProp (register const char *str, register unsigned int len)
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  96,  -1,  -1,  -1,  -1,  -1,  97,  -1,  98,
        -1,  -1,  -1,  99,  -1, 100,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1, 101,  -1,  -1, 102,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1, 101,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1, 103,  -1,  -1,
-       -1,  -1,  -1,  -1, 104,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1, 102,  -1,  -1,
+       -1,  -1,  -1,  -1, 103,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1, 105, 106,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1, 107,  -1,  -1,  -1, 108,
+       -1, 104, 105,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1, 106,  -1,  -1,  -1, 107,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
@@ -305,20 +304,20 @@ findProp (register const char *str, register unsigned int len)
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1, 109,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1, 108,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1, 110,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1, 109,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1, 111,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1, 110,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1, 112
+       -1,  -1,  -1,  -1,  -1,  -1, 111
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -367,7 +366,6 @@ static const char * const propertyList[] = {
 "caption-side", 
 "clear", 
 "clip", 
-"-konq-js-clip", 
 "color", 
 "content", 
 "counter-increment", 
diff --git a/WebCore/khtml/css/cssproperties.h b/WebCore/khtml/css/cssproperties.h
index 109dda2..588973c 100644
--- a/WebCore/khtml/css/cssproperties.h
+++ b/WebCore/khtml/css/cssproperties.h
@@ -32,96 +32,95 @@
 #define CSS_PROP_CAPTION_SIDE 23
 #define CSS_PROP_CLEAR 24
 #define CSS_PROP_CLIP 25
-#define CSS_PROP__KONQ_JS_CLIP 26
-#define CSS_PROP_COLOR 27
-#define CSS_PROP_CONTENT 28
-#define CSS_PROP_COUNTER_INCREMENT 29
-#define CSS_PROP_COUNTER_RESET 30
-#define CSS_PROP_CURSOR 31
-#define CSS_PROP_DIRECTION 32
-#define CSS_PROP_DISPLAY 33
-#define CSS_PROP_EMPTY_CELLS 34
-#define CSS_PROP_FLOAT 35
-#define CSS_PROP_FONT_FAMILY 36
-#define CSS_PROP_FONT_SIZE 37
-#define CSS_PROP_FONT_SIZE_ADJUST 38
-#define CSS_PROP_FONT_STRETCH 39
-#define CSS_PROP_FONT_STYLE 40
-#define CSS_PROP_FONT_VARIANT 41
-#define CSS_PROP_FONT_WEIGHT 42
-#define CSS_PROP_HEIGHT 43
-#define CSS_PROP_LEFT 44
-#define CSS_PROP_LETTER_SPACING 45
-#define CSS_PROP_LINE_HEIGHT 46
-#define CSS_PROP_LIST_STYLE_IMAGE 47
-#define CSS_PROP_LIST_STYLE_POSITION 48
-#define CSS_PROP_LIST_STYLE_TYPE 49
-#define CSS_PROP_MARGIN_TOP 50
-#define CSS_PROP_MARGIN_RIGHT 51
-#define CSS_PROP_MARGIN_BOTTOM 52
-#define CSS_PROP_MARGIN_LEFT 53
-#define CSS_PROP_MARKER_OFFSET 54
-#define CSS_PROP_MAX_HEIGHT 55
-#define CSS_PROP_MAX_WIDTH 56
-#define CSS_PROP_MIN_HEIGHT 57
-#define CSS_PROP_MIN_WIDTH 58
-#define CSS_PROP_ORPHANS 59
-#define CSS_PROP_OUTLINE_COLOR 60
-#define CSS_PROP_OUTLINE_STYLE 61
-#define CSS_PROP_OUTLINE_WIDTH 62
-#define CSS_PROP_OVERFLOW 63
-#define CSS_PROP_PADDING_TOP 64
-#define CSS_PROP_PADDING_RIGHT 65
-#define CSS_PROP_PADDING_BOTTOM 66
-#define CSS_PROP_PADDING_LEFT 67
-#define CSS_PROP_PAGE 68
-#define CSS_PROP_PAGE_BREAK_AFTER 69
-#define CSS_PROP_PAGE_BREAK_BEFORE 70
-#define CSS_PROP_PAGE_BREAK_INSIDE 71
-#define CSS_PROP_POSITION 72
-#define CSS_PROP_QUOTES 73
-#define CSS_PROP_RIGHT 74
-#define CSS_PROP_SIZE 75
-#define CSS_PROP_TABLE_LAYOUT 76
-#define CSS_PROP_TEXT_ALIGN 77
-#define CSS_PROP_TEXT_DECORATION 78
-#define CSS_PROP_TEXT_DECORATION_COLOR 79
-#define CSS_PROP_TEXT_INDENT 80
-#define CSS_PROP_TEXT_SHADOW 81
-#define CSS_PROP_TEXT_TRANSFORM 82
-#define CSS_PROP_TOP 83
-#define CSS_PROP_UNICODE_BIDI 84
-#define CSS_PROP_VERTICAL_ALIGN 85
-#define CSS_PROP_VISIBILITY 86
-#define CSS_PROP_WHITE_SPACE 87
-#define CSS_PROP_WIDOWS 88
-#define CSS_PROP_WIDTH 89
-#define CSS_PROP_WORD_SPACING 90
-#define CSS_PROP_Z_INDEX 91
-#define CSS_PROP_BACKGROUND 92
-#define CSS_PROP_BORDER 93
-#define CSS_PROP_BORDER_COLOR 94
-#define CSS_PROP_BORDER_STYLE 95
-#define CSS_PROP_BORDER_TOP 96
-#define CSS_PROP_BORDER_RIGHT 97
-#define CSS_PROP_BORDER_BOTTOM 98
-#define CSS_PROP_BORDER_LEFT 99
-#define CSS_PROP_BORDER_WIDTH 100
-#define CSS_PROP_FONT 101
-#define CSS_PROP_LIST_STYLE 102
-#define CSS_PROP_MARGIN 103
-#define CSS_PROP_OUTLINE 104
-#define CSS_PROP_PADDING 105
-#define CSS_PROP_SCROLLBAR_FACE_COLOR 106
-#define CSS_PROP_SCROLLBAR_SHADOW_COLOR 107
-#define CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR 108
-#define CSS_PROP_SCROLLBAR_3DLIGHT_COLOR 109
-#define CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR 110
-#define CSS_PROP_SCROLLBAR_TRACK_COLOR 111
-#define CSS_PROP_SCROLLBAR_ARROW_COLOR 112
-#define CSS_PROP__KONQ_FLOW_MODE 113
+#define CSS_PROP_COLOR 26
+#define CSS_PROP_CONTENT 27
+#define CSS_PROP_COUNTER_INCREMENT 28
+#define CSS_PROP_COUNTER_RESET 29
+#define CSS_PROP_CURSOR 30
+#define CSS_PROP_DIRECTION 31
+#define CSS_PROP_DISPLAY 32
+#define CSS_PROP_EMPTY_CELLS 33
+#define CSS_PROP_FLOAT 34
+#define CSS_PROP_FONT_FAMILY 35
+#define CSS_PROP_FONT_SIZE 36
+#define CSS_PROP_FONT_SIZE_ADJUST 37
+#define CSS_PROP_FONT_STRETCH 38
+#define CSS_PROP_FONT_STYLE 39
+#define CSS_PROP_FONT_VARIANT 40
+#define CSS_PROP_FONT_WEIGHT 41
+#define CSS_PROP_HEIGHT 42
+#define CSS_PROP_LEFT 43
+#define CSS_PROP_LETTER_SPACING 44
+#define CSS_PROP_LINE_HEIGHT 45
+#define CSS_PROP_LIST_STYLE_IMAGE 46
+#define CSS_PROP_LIST_STYLE_POSITION 47
+#define CSS_PROP_LIST_STYLE_TYPE 48
+#define CSS_PROP_MARGIN_TOP 49
+#define CSS_PROP_MARGIN_RIGHT 50
+#define CSS_PROP_MARGIN_BOTTOM 51
+#define CSS_PROP_MARGIN_LEFT 52
+#define CSS_PROP_MARKER_OFFSET 53
+#define CSS_PROP_MAX_HEIGHT 54
+#define CSS_PROP_MAX_WIDTH 55
+#define CSS_PROP_MIN_HEIGHT 56
+#define CSS_PROP_MIN_WIDTH 57
+#define CSS_PROP_ORPHANS 58
+#define CSS_PROP_OUTLINE_COLOR 59
+#define CSS_PROP_OUTLINE_STYLE 60
+#define CSS_PROP_OUTLINE_WIDTH 61
+#define CSS_PROP_OVERFLOW 62
+#define CSS_PROP_PADDING_TOP 63
+#define CSS_PROP_PADDING_RIGHT 64
+#define CSS_PROP_PADDING_BOTTOM 65
+#define CSS_PROP_PADDING_LEFT 66
+#define CSS_PROP_PAGE 67
+#define CSS_PROP_PAGE_BREAK_AFTER 68
+#define CSS_PROP_PAGE_BREAK_BEFORE 69
+#define CSS_PROP_PAGE_BREAK_INSIDE 70
+#define CSS_PROP_POSITION 71
+#define CSS_PROP_QUOTES 72
+#define CSS_PROP_RIGHT 73
+#define CSS_PROP_SIZE 74
+#define CSS_PROP_TABLE_LAYOUT 75
+#define CSS_PROP_TEXT_ALIGN 76
+#define CSS_PROP_TEXT_DECORATION 77
+#define CSS_PROP_TEXT_DECORATION_COLOR 78
+#define CSS_PROP_TEXT_INDENT 79
+#define CSS_PROP_TEXT_SHADOW 80
+#define CSS_PROP_TEXT_TRANSFORM 81
+#define CSS_PROP_TOP 82
+#define CSS_PROP_UNICODE_BIDI 83
+#define CSS_PROP_VERTICAL_ALIGN 84
+#define CSS_PROP_VISIBILITY 85
+#define CSS_PROP_WHITE_SPACE 86
+#define CSS_PROP_WIDOWS 87
+#define CSS_PROP_WIDTH 88
+#define CSS_PROP_WORD_SPACING 89
+#define CSS_PROP_Z_INDEX 90
+#define CSS_PROP_BACKGROUND 91
+#define CSS_PROP_BORDER 92
+#define CSS_PROP_BORDER_COLOR 93
+#define CSS_PROP_BORDER_STYLE 94
+#define CSS_PROP_BORDER_TOP 95
+#define CSS_PROP_BORDER_RIGHT 96
+#define CSS_PROP_BORDER_BOTTOM 97
+#define CSS_PROP_BORDER_LEFT 98
+#define CSS_PROP_BORDER_WIDTH 99
+#define CSS_PROP_FONT 100
+#define CSS_PROP_LIST_STYLE 101
+#define CSS_PROP_MARGIN 102
+#define CSS_PROP_OUTLINE 103
+#define CSS_PROP_PADDING 104
+#define CSS_PROP_SCROLLBAR_FACE_COLOR 105
+#define CSS_PROP_SCROLLBAR_SHADOW_COLOR 106
+#define CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR 107
+#define CSS_PROP_SCROLLBAR_3DLIGHT_COLOR 108
+#define CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR 109
+#define CSS_PROP_SCROLLBAR_TRACK_COLOR 110
+#define CSS_PROP_SCROLLBAR_ARROW_COLOR 111
+#define CSS_PROP__KONQ_FLOW_MODE 112
 
 #define CSS_PROP_MAX CSS_PROP_Z_INDEX
-#define CSS_PROP_TOTAL 114
+#define CSS_PROP_TOTAL 113
 #endif
 
diff --git a/WebCore/khtml/css/cssproperties.in b/WebCore/khtml/css/cssproperties.in
index ebeef34..91b7886 100644
--- a/WebCore/khtml/css/cssproperties.in
+++ b/WebCore/khtml/css/cssproperties.in
@@ -40,7 +40,6 @@ bottom
 caption-side
 clear
 clip
--konq-js-clip
 color
 content
 counter-increment
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 06eb1e2..1d15585 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -74,6 +74,7 @@ CSSStyleSelectorList *CSSStyleSelector::defaultQuirksStyle = 0;
 CSSStyleSelectorList *CSSStyleSelector::defaultPrintStyle = 0;
 CSSStyleSheetImpl *CSSStyleSelector::defaultSheet = 0;
 RenderStyle* CSSStyleSelector::styleNotYetAvailable = 0;
+CSSStyleSheetImpl *CSSStyleSelector::quirksSheet = 0;
 
 static CSSStyleSelector::Encodedurl *encodedurl = 0;
 
@@ -107,7 +108,7 @@ CSSStyleSelector::CSSStyleSelector( DocumentImpl* doc, QString userStyleSheet, S
         userSheet->parseString( DOMString( userStyleSheet ) );
 
         userStyle = new CSSStyleSelectorList();
-        userStyle->append( userSheet, m_medium, strictParsing );
+        userStyle->append( userSheet, m_medium );
     }
 
     // add stylesheets from document
@@ -117,8 +118,7 @@ CSSStyleSelector::CSSStyleSelector( DocumentImpl* doc, QString userStyleSheet, S
     QPtrListIterator<StyleSheetImpl> it( styleSheets->styleSheets );
     for ( ; it.current(); ++it ) {
         if ( it.current()->isCSSStyleSheet() ) {
-            authorStyle->append( static_cast<CSSStyleSheetImpl*>( it.current() ),
-                                 m_medium, strictParsing );
+            authorStyle->append( static_cast<CSSStyleSheetImpl*>( it.current() ), m_medium );
         }
     }
 
@@ -152,7 +152,7 @@ CSSStyleSelector::CSSStyleSelector( CSSStyleSheetImpl *sheet )
     m_medium = sheet->doc()->view()->mediaType();
 
     authorStyle = new CSSStyleSelectorList();
-    authorStyle->append( sheet, m_medium, strictParsing );
+    authorStyle->append( sheet, m_medium );
 }
 
 void CSSStyleSelector::init()
@@ -179,40 +179,59 @@ CSSStyleSelector::~CSSStyleSelector()
 void CSSStyleSelector::addSheet( CSSStyleSheetImpl *sheet )
 {
     m_medium = sheet->doc()->view()->mediaType();
-    authorStyle->append( sheet, m_medium, strictParsing );
+    authorStyle->append( sheet, m_medium );
 }
 
 void CSSStyleSelector::loadDefaultStyle(const KHTMLSettings *s)
 {
     if(defaultStyle) return;
 
-    QFile f(locate( "data", "khtml/css/html4.css" ) );
-    f.open(IO_ReadOnly);
+    {
+        QFile f(locate( "data", "khtml/css/html4.css" ) );
+        f.open(IO_ReadOnly);
 
-    QCString file( f.size()+1 );
-    int readbytes = f.readBlock( file.data(), f.size() );
-    f.close();
-    if ( readbytes >= 0 )
-        file[readbytes] = '\0';
+        QCString file( f.size()+1 );
+        int readbytes = f.readBlock( file.data(), f.size() );
+        f.close();
+        if ( readbytes >= 0 )
+            file[readbytes] = '\0';
 
-    QString style = QString::fromLatin1( file.data() );
-    if(s)
-        style += s->settingsToCSS();
-    DOMString str(style);
+        QString style = QString::fromLatin1( file.data() );
+        if(s)
+            style += s->settingsToCSS();
+        DOMString str(style);
 
-    defaultSheet = new DOM::CSSStyleSheetImpl((DOM::CSSStyleSheetImpl * ) 0);
-    defaultSheet->parseString( str );
+        defaultSheet = new DOM::CSSStyleSheetImpl((DOM::CSSStyleSheetImpl * ) 0);
+        defaultSheet->parseString( str );
 
-    // Collect only strict-mode rules.
-    defaultStyle = new CSSStyleSelectorList();
-    defaultStyle->append( defaultSheet, "screen", 1 );
+        // Collect only strict-mode rules.
+        defaultStyle = new CSSStyleSelectorList();
+        defaultStyle->append( defaultSheet, "screen" );
+
+        defaultPrintStyle = new CSSStyleSelectorList();
+        defaultPrintStyle->append( defaultSheet, "print" );
+    }
+    {
+        QFile f(locate( "data", "khtml/css/quirks.css" ) );
+        f.open(IO_ReadOnly);
+
+        QCString file( f.size()+1 );
+        int readbytes = f.readBlock( file.data(), f.size() );
+        f.close();
+        if ( readbytes >= 0 )
+            file[readbytes] = '\0';
+
+        QString style = QString::fromLatin1( file.data() );
+        DOMString str(style);
+
+        quirksSheet = new DOM::CSSStyleSheetImpl((DOM::CSSStyleSheetImpl * ) 0);
+        quirksSheet->parseString( str );
+
+        // Collect only quirks-mode rules.
+        defaultQuirksStyle = new CSSStyleSelectorList();
+        defaultQuirksStyle->append( quirksSheet, "screen" );
+    }
 
-    // Collect only quirks-mode rules.
-    defaultQuirksStyle = new CSSStyleSelectorList();
-    defaultQuirksStyle->append( defaultSheet, "screen", 2 );
-    
-    defaultPrintStyle = new CSSStyleSelectorList();
-    defaultPrintStyle->append( defaultSheet, "print" );
     //kdDebug() << "CSSStyleSelector: default style has " << defaultStyle->count() << " elements"<< endl;
 }
 
@@ -282,7 +301,7 @@ static inline void bubbleSort( CSSOrderedProperty **b, CSSOrderedProperty **e )
 	bool swapped = FALSE;
         CSSOrderedProperty **y = e+1;
 	CSSOrderedProperty **x = e;
-        CSSOrderedProperty **swappedPos = 0; // quiet gcc warning
+        CSSOrderedProperty **swappedPos = 0;
 	do {
 	    if ( !((**(--x)) < (**(--y))) ) {
 		swapped = TRUE;
@@ -399,7 +418,8 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e)
 		    CSSStyleSelector::style->htmlFont().update( paintDeviceMetrics );
 		    fontDirty = false;
 		}
-                applyRule( propsToApply[i]->prop );
+                DOM::CSSProperty *prop = propsToApply[i]->prop;
+                applyRule( prop->m_id, prop->value() );
 	    }
 	    if ( fontDirty ) {
 	        checkForGenericFamilyChange(style, parentStyle);
@@ -434,8 +454,10 @@ RenderStyle *CSSStyleSelector::styleForElement(ElementImpl *e)
 
                 RenderStyle* oldStyle = style;
 		style = pseudoStyle;
-                if ( pseudoStyle )
-                    applyRule( pseudoProps[i]->prop );
+                if ( pseudoStyle ) {
+                    DOM::CSSProperty *prop = pseudoProps[i]->prop;
+                    applyRule( prop->m_id, prop->value() );
+                }
                 style = oldStyle;
             }
 
@@ -575,8 +597,10 @@ void CSSStyleSelector::checkSelector(int selIndex, DOM::ElementImpl *e)
         }
         case CSSSelector::Child:
         {
-		subject = false;
+            subject = false;
             n = n->parentNode();
+            if (!strictParsing)
+                while (n && n->implicitNode()) n = n->parentNode();
             if(!n || !n->isElementNode()) return;
             ElementImpl *elem = static_cast<ElementImpl *>(n);
             if(!checkOneSelector(sel, elem)) return;
@@ -705,6 +729,7 @@ bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl
         switch(sel->match)
         {
         case CSSSelector::Exact:
+        case CSSSelector::Id:
 	    if( (strictParsing && strcmp(sel->value, value) ) ||
                 (!strictParsing && strcasecmp(sel->value, value)))
                 return false;
@@ -812,6 +837,10 @@ bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl
                     return true;
                 }
                 break;
+            case CSSSelector::PseudoTarget:
+                if (e && e == e->getDocument()->getCSSTarget())
+                    return true;
+                break;
             case CSSSelector::PseudoLink:
                 if ( pseudoState == PseudoUnknown )
                     checkPseudoState( e );
@@ -865,6 +894,8 @@ bool CSSStyleSelector::checkOneSelector(DOM::CSSSelector *sel, DOM::ElementImpl
             case CSSSelector::PseudoNotParsed:
                 assert(false);
                 break;
+            case CSSSelector::PseudoFunction:
+                /* not supported for now */
             case CSSSelector::PseudoOther:
                 break;
         }
@@ -1034,8 +1065,7 @@ CSSStyleSelectorList::~CSSStyleSelectorList()
 }
 
 void CSSStyleSelectorList::append( CSSStyleSheetImpl *sheet,
-                                   const DOMString &medium,
-                                   int quirksMode )
+                                   const DOMString &medium )
 {
     if(!sheet || !sheet->isCSSStyleSheet()) return;
 
@@ -1049,7 +1079,7 @@ void CSSStyleSelectorList::append( CSSStyleSheetImpl *sheet,
     for(int i = 0; i< len; i++)
     {
         StyleBaseImpl *item = sheet->item(i);
-        if(item->isStyleRule() && quirksMode != 2)
+        if(item->isStyleRule())
         {
             CSSStyleRuleImpl *r = static_cast<CSSStyleRuleImpl *>(item);
             QPtrList<CSSSelector> *s = r->selector();
@@ -1073,31 +1103,6 @@ void CSSStyleSelectorList::append( CSSStyleSheetImpl *sheet,
                 append( importedSheet, medium );
             }
         }
-        else if (item->isQuirksRule() && quirksMode != 1) {
-            CSSQuirksRuleImpl *r = static_cast<CSSQuirksRuleImpl *>( item );
-            CSSRuleListImpl *rules = r->cssRules();
-
-            for( unsigned j = 0; j < rules->length(); j++ )
-            {
-                //kdDebug( 6080 ) << "*** Rule #" << j << endl;
-
-                CSSRuleImpl *childItem = rules->item( j );
-                if( childItem->isStyleRule() )
-                {
-                    // It is a StyleRule, so append it to our list
-                    CSSStyleRuleImpl *styleRule =
-                            static_cast<CSSStyleRuleImpl *>( childItem );
-
-                    QPtrList<CSSSelector> *s = styleRule->selector();
-                    for( int j = 0; j < ( int ) s->count(); j++ )
-                    {
-                        CSSOrderedRule *orderedRule = new CSSOrderedRule(
-                                        styleRule, s->at( j ), count() );
-                        QPtrList<CSSOrderedRule>::append( orderedRule );
-                    }
-                }
-            }   // for rules
-        }
         else if( item->isMediaRule() )
         {
             CSSMediaRuleImpl *r = static_cast<CSSMediaRuleImpl *>( item );
@@ -1238,16 +1243,163 @@ static Length convertToLength( CSSPrimitiveValueImpl *primitiveValue, RenderStyl
 	    l = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE)), Percent);
 	else if(type == CSSPrimitiveValue::CSS_NUMBER)
 	    l = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_NUMBER)*100), Percent);
+        else if (type == CSSPrimitiveValue::CSS_HTML_RELATIVE)
+            l = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_HTML_RELATIVE)), Relative);
 	else if ( ok )
 	    *ok = false;
     }
     return l;
 }
 
-void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
+
+// color mapping code
+struct colorMap {
+    int css_value;
+    QRgb color;
+};
+
+static const colorMap cmap[] = {
+    { CSS_VAL_AQUA, 0xFF00FFFF },
+    { CSS_VAL_BLACK, 0xFF000000 },
+    { CSS_VAL_BLUE, 0xFF0000FF },
+    { CSS_VAL_FUCHSIA, 0xFFFF00FF },
+    { CSS_VAL_GRAY, 0xFF808080 },
+    { CSS_VAL_GREEN, 0xFF008000  },
+    { CSS_VAL_LIME, 0xFF00FF00 },
+    { CSS_VAL_MAROON, 0xFF800000 },
+    { CSS_VAL_NAVY, 0xFF000080 },
+    { CSS_VAL_OLIVE, 0xFF808000  },
+    { CSS_VAL_ORANGE, 0xFFFFA500 },
+    { CSS_VAL_PURPLE, 0xFF800080 },
+    { CSS_VAL_RED, 0xFFFF0000 },
+    { CSS_VAL_SILVER, 0xFFC0C0C0 },
+    { CSS_VAL_TEAL, 0xFF008080  },
+    { CSS_VAL_WHITE, 0xFFFFFFFF },
+    { CSS_VAL_YELLOW, 0xFFFFFF00 },
+    { CSS_VAL_INVERT, invertedColor },
+    { CSS_VAL_GREY, 0xff808080 },
+    { 0, 0 }
+};
+
+struct uiColors {
+    int css_value;
+    const char * configGroup;
+    const char * configEntry;
+QPalette::ColorGroup group;
+QColorGroup::ColorRole role;
+};
+
+const char * const wmgroup = "WM";
+const char * const generalgroup = "General";
+
+/* Mapping system settings to CSS 2
+* Tried hard to get an appropriate mapping - schlpbch
+*/
+static const uiColors uimap[] = {
+    // Active window border.
+    { CSS_VAL_ACTIVEBORDER, wmgroup, "background", QPalette::Active, QColorGroup::Light },
+    // Active window caption.
+    { CSS_VAL_ACTIVECAPTION, wmgroup, "background", QPalette::Active, QColorGroup::Text },
+    // Text in caption, size box, and scrollbar arrow box.
+    { CSS_VAL_CAPTIONTEXT, wmgroup, "activeForeground", QPalette::Active, QColorGroup::Text },
+    // Face color for three-dimensional display elements.
+    { CSS_VAL_BUTTONFACE, wmgroup, 0, QPalette::Inactive, QColorGroup::Button },
+    // Dark shadow for three-dimensional display elements (for edges facing away from the light source).
+    { CSS_VAL_BUTTONHIGHLIGHT, wmgroup, 0, QPalette::Inactive, QColorGroup::Light },
+    // Shadow color for three-dimensional display elements.
+    { CSS_VAL_BUTTONSHADOW, wmgroup, 0, QPalette::Inactive, QColorGroup::Shadow },
+    // Text on push buttons.
+    { CSS_VAL_BUTTONTEXT, wmgroup, "buttonForeground", QPalette::Inactive, QColorGroup::ButtonText },
+    // Dark shadow for three-dimensional display elements.
+    { CSS_VAL_THREEDDARKSHADOW, wmgroup, 0, QPalette::Inactive, QColorGroup::Dark },
+    // Face color for three-dimensional display elements.
+    { CSS_VAL_THREEDFACE, wmgroup, 0, QPalette::Inactive, QColorGroup::Button },
+    // Highlight color for three-dimensional display elements.
+    { CSS_VAL_THREEDHIGHLIGHT, wmgroup, 0, QPalette::Inactive, QColorGroup::Light },
+    // Light color for three-dimensional display elements (for edges facing the light source).
+    { CSS_VAL_THREEDLIGHTSHADOW, wmgroup, 0, QPalette::Inactive, QColorGroup::Midlight },
+    // Dark shadow for three-dimensional display elements.
+    { CSS_VAL_THREEDSHADOW, wmgroup, 0, QPalette::Inactive, QColorGroup::Shadow },
+
+    // Inactive window border.
+    { CSS_VAL_INACTIVEBORDER, wmgroup, "background", QPalette::Disabled, QColorGroup::Background },
+    // Inactive window caption.
+    { CSS_VAL_INACTIVECAPTION, wmgroup, "inactiveBackground", QPalette::Disabled, QColorGroup::Background },
+    // Color of text in an inactive caption.
+    { CSS_VAL_INACTIVECAPTIONTEXT, wmgroup, "inactiveForeground", QPalette::Disabled, QColorGroup::Text },
+    { CSS_VAL_GRAYTEXT, wmgroup, 0, QPalette::Disabled, QColorGroup::Text },
+
+    // Menu background
+    { CSS_VAL_MENU, generalgroup, "background", QPalette::Inactive, QColorGroup::Background },
+    // Text in menus
+    { CSS_VAL_MENUTEXT, generalgroup, "foreground", QPalette::Inactive, QColorGroup::Background },
+
+    // Text of item(s) selected in a control.
+    { CSS_VAL_HIGHLIGHT, generalgroup, "selectBackground", QPalette::Inactive, QColorGroup::Background },
+
+    // Text of item(s) selected in a control.
+    { CSS_VAL_HIGHLIGHTTEXT, generalgroup, "selectForeground", QPalette::Inactive, QColorGroup::Background },
+
+    // Background color of multiple document interface.
+    { CSS_VAL_APPWORKSPACE, generalgroup, "background", QPalette::Inactive, QColorGroup::Text },
+
+    // Scroll bar gray area.
+    { CSS_VAL_SCROLLBAR, generalgroup, "background", QPalette::Inactive, QColorGroup::Background },
+
+    // Window background.
+    { CSS_VAL_WINDOW, generalgroup, "windowBackground", QPalette::Inactive, QColorGroup::Background },
+    // Window frame.
+    { CSS_VAL_WINDOWFRAME, generalgroup, "windowBackground", QPalette::Inactive, QColorGroup::Background },
+    // WindowText
+    { CSS_VAL_WINDOWTEXT, generalgroup, "windowForeground", QPalette::Inactive, QColorGroup::Text },
+    { CSS_VAL_TEXT, generalgroup, 0, QPalette::Inactive, QColorGroup::Text },
+    { 0, 0, 0, QPalette::NColorGroups, QColorGroup::NColorRoles }
+};
+
+static QColor colorForCSSValue( int css_value )
 {
-    CSSValueImpl *value = prop->value();
+    // try the regular ones first
+    const colorMap *col = cmap;
+    while ( col->css_value && col->css_value != css_value )
+        ++col;
+    if ( col->css_value )
+        return col->color;
+
+    const uiColors *uicol = uimap;
+    while ( uicol->css_value && uicol->css_value != css_value )
+        ++uicol;
+#if !APPLE_CHANGES
+    if ( !uicol->css_value ) {
+        if ( css_value == CSS_VAL_INFOBACKGROUND )
+            return QToolTip::palette().inactive().background();
+        else if ( css_value == CSS_VAL_INFOTEXT )
+            return QToolTip::palette().inactive().foreground();
+        else if ( css_value == CSS_VAL_BACKGROUND ) {
+            KConfig bckgrConfig("kdesktoprc", true, false); // No multi-screen support
+            bckgrConfig.setGroup("Desktop0");
+            // Desktop background.
+            return bckgrConfig.readColorEntry("Color1", &qApp->palette().disabled().background());
+        }
+        return khtml::invalidColor;
+    }
+#endif
+    
+    const QPalette &pal = qApp->palette();
+    QColor c = pal.color( uicol->group, uicol->role );
+#if !APPLE_CHANGES
+    if ( uicol->configEntry ) {
+        KConfig *globalConfig = KGlobal::config();
+        globalConfig->setGroup( uicol->configGroup );
+        c = globalConfig->readColorEntry( uicol->configEntry, &c );
+    }
+#endif
+    
+    return c;
+};
 
+
+void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
+{
     //kdDebug( 6080 ) << "applying property " << prop->m_id << endl;
 
     CSSPrimitiveValueImpl *primitiveValue = 0;
@@ -1258,7 +1410,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
 
     // here follows a long list, defining how to aplly certain properties to the style object.
     // rather boring stuff...
-    switch(prop->m_id)
+    switch(id)
     {
 // ident only properties
     case CSS_PROP_BACKGROUND_ATTACHMENT:
@@ -1341,7 +1493,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
         if(value->cssValueType() == CSSValue::CSS_INHERIT)
         {
             if(!parentNode) return;
-            switch(prop->m_id)
+            switch(id)
             {
             case CSS_PROP_BORDER_TOP_STYLE:
                 s = parentStyle->borderTopStyle();
@@ -1365,7 +1517,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
 	    if(!primitiveValue) return;
 	    s = (EBorderStyle) (primitiveValue->getIdent() - CSS_VAL_NONE);
 	}
-        switch(prop->m_id)
+        switch(id)
         {
         case CSS_PROP_BORDER_TOP_STYLE:
             style->setBorderTopStyle(s); return;
@@ -1457,8 +1609,8 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
 	EDisplay d;
 	if ( id == CSS_VAL_NONE) {
 	    d = NONE;
-	} else if ( id == CSS_VAL_MARKER ) {
-	    // marker is not supported at the moment, so we just ignore it.
+	} else if ( id == CSS_VAL_INLINE_BLOCK ) {
+	    // inline-block is not supported at the moment, so we just ignore it.
 	    return;
 	} else {
 	    d = EDisplay(primitiveValue->getIdent() - CSS_VAL_INLINE);
@@ -1534,21 +1686,23 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
 
     case CSS_PROP_FONT_VARIANT:
     {
+        FontDef fontDef = style->htmlFont().fontDef;
         if(value->cssValueType() == CSSValue::CSS_INHERIT) {
             if(!parentNode) return;
-            style->setFontVariant(parentStyle->fontVariant());
-            return;
-        }
-        if(!primitiveValue) return;
-        switch(primitiveValue->getIdent()) {
-	    case CSS_VAL_NORMAL:
-		style->setFontVariant( FVNORMAL ); break;
-	    case CSS_VAL_SMALL_CAPS:
-		style->setFontVariant( SMALL_CAPS ); break;
-	    default:
-            return;
+            fontDef.smallCaps = parentStyle->htmlFont().fontDef.weight;
+        } else {
+            if(!primitiveValue) return;
+            int id = primitiveValue->getIdent();
+            if ( id == CSS_VAL_NORMAL )
+                fontDef.smallCaps = false;
+            else if ( id == CSS_VAL_SMALL_CAPS )
+                fontDef.smallCaps = true;
+            else
+                return;
         }
-	break;
+        if (style->setFontDef( fontDef ))
+            fontDirty = true;
+        break;        
     }
 
     case CSS_PROP_FONT_WEIGHT:
@@ -1558,35 +1712,43 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
             if(!parentNode) return;
             fontDef.weight = parentStyle->htmlFont().fontDef.weight;
         } else {
-	    if(!primitiveValue) return;
-	    if(primitiveValue->getIdent())
-	    {
-		switch(primitiveValue->getIdent())
-		{
-		    // ### we just support normal and bold fonts at the moment...
-		    // setWeight can actually accept values between 0 and 99...
-		    case CSS_VAL_BOLD:
-		    case CSS_VAL_BOLDER:
-			fontDef.weight = QFont::Bold;
-			break;
-		    case CSS_VAL_NORMAL:
-		    case CSS_VAL_LIGHTER:
-			fontDef.weight = QFont::Normal;
-			break;
-		    default:
-			return;
-		}
-	    }
-	    else
-	    {
-		// ### fix parsing of 100-900 values in parser, apply them here
-	    }
-	}
+            if(!primitiveValue) return;
+            if(primitiveValue->getIdent())
+            {
+                switch(primitiveValue->getIdent()) {
+                    // ### we just support normal and bold fonts at the moment...
+                    // setWeight can actually accept values between 0 and 99...
+                    case CSS_VAL_BOLD:
+                    case CSS_VAL_BOLDER:
+                    case CSS_VAL_600:
+                    case CSS_VAL_700:
+                    case CSS_VAL_800:
+                    case CSS_VAL_900:
+                        fontDef.weight = QFont::Bold;
+                        break;
+                    case CSS_VAL_NORMAL:
+                    case CSS_VAL_LIGHTER:
+                    case CSS_VAL_100:
+                    case CSS_VAL_200:
+                    case CSS_VAL_300:
+                    case CSS_VAL_400:
+                    case CSS_VAL_500:
+                        fontDef.weight = QFont::Normal;
+                        break;
+                    default:
+                        return;
+                }
+            }
+            else
+            {
+                // ### fix parsing of 100-900 values in parser, apply them here
+            }
+        }
         if (style->setFontDef( fontDef ))
-	fontDirty = true;
+            fontDirty = true;
         break;
     }
-
+        
     case CSS_PROP_LIST_STYLE_POSITION:
     {
         if(value->cssValueType() == CSSValue::CSS_INHERIT)
@@ -1695,8 +1857,23 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
 //     case CSS_PROP_SPEAK_HEADER:
 //     case CSS_PROP_SPEAK_NUMERAL:
 //     case CSS_PROP_SPEAK_PUNCTUATION:
-    case CSS_PROP_TABLE_LAYOUT:
-	break;
+     case CSS_PROP_TABLE_LAYOUT: {
+        if ( !primitiveValue->getIdent() )
+            return;
+
+        ETableLayout l = TAUTO;
+        switch( primitiveValue->getIdent() ) {
+            case CSS_VAL_FIXED:
+                l = TFIXED;
+                // fall through
+            case CSS_VAL_AUTO:
+                style->setTableLayout( l );
+            default:
+                break;
+        }
+        break;
+    }
+        
     case CSS_PROP_UNICODE_BIDI: {
 	EUnicodeBidi b = UBNormal;
         if(value->cssValueType() == CSSValue::CSS_INHERIT) {
@@ -1838,24 +2015,13 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
         if(value->cssValueType() == CSSValue::CSS_INHERIT) {
             if(!parentNode) return;
             style->setCursor(parentStyle->cursor());
-            style->setCursorImage(parentStyle->cursorImage());
             return;
         } else if(primitiveValue) {
-	    if(primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_URI) {
-            	CSSImageValueImpl *image = static_cast<CSSImageValueImpl *>(primitiveValue);
-            	//kdDebug( 6080 ) << "setting cursor image to " << image->cssText().string() << endl;
-            	style->setCursorImage(image->image());
-            } else {
-		style->setCursor( (ECursor) (primitiveValue->getIdent() - CSS_VAL_AUTO) );
-	    }
+            style->setCursor( (ECursor) (primitiveValue->getIdent() - CSS_VAL_AUTO) );
         }
-        break;
+        break;        
 //    case CSS_PROP_PLAY_DURING:
         // CSS2PlayDuring
-    case CSS_PROP_TEXT_SHADOW:
-        // list of CSS2TextShadow
-        break;
-
 // colors || inherit
     case CSS_PROP_BACKGROUND_COLOR:
     case CSS_PROP_BORDER_TOP_COLOR:
@@ -1879,7 +2045,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
         QColor col;
         if(value->cssValueType() == CSSValue::CSS_INHERIT)
         {
-            switch(prop->m_id)
+            switch(id)
             {
             case CSS_PROP_BACKGROUND_COLOR:
                 col = parentStyle->backgroundColor(); break;
@@ -1899,14 +2065,27 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
             return;
         }
         } else {
-        if(!primitiveValue) return;
-        if(primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RGBCOLOR)
-            col = primitiveValue->getRGBColorValue()->color();
-        else
-            return;
-	}
+            if(!primitiveValue )
+                return;
+            int ident = primitiveValue->getIdent();
+            if ( ident ) {
+                if ( ident == CSS_VAL__KONQ_TEXT )
+                    col = element->getDocument()->textColor();
+                else if ( ident == CSS_VAL_TRANSPARENT )
+                    col = QColor();
+                else
+                    col = colorForCSSValue( ident );
+            } else if ( primitiveValue->primitiveType() == CSSPrimitiveValue::CSS_RGBCOLOR ) {
+#if !APPLE_CHANGES
+                if(qAlpha(primitiveValue->getRGBColorValue()))
+#endif
+                    col.setRgb(primitiveValue->getRGBColorValue());
+            } else {
+                return;
+            }
+        }
         //kdDebug( 6080 ) << "applying color " << col.isValid() << endl;
-        switch(prop->m_id)
+        switch(id)
         {
         case CSS_PROP_BACKGROUND_COLOR:
             style->setBackgroundColor(col); break;
@@ -2003,7 +2182,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
 	short width = 3;
         if(value->cssValueType() == CSSValue::CSS_INHERIT)
         {
-            switch(prop->m_id)
+            switch(id)
             {
             case CSS_PROP_BORDER_TOP_WIDTH:
 		    width = parentStyle->borderTopWidth(); break;
@@ -2040,7 +2219,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
         }
 	}
         if(width < 0) return;
-        switch(prop->m_id)
+        switch(id)
         {
         case CSS_PROP_BORDER_TOP_WIDTH:
             style->setBorderTopWidth(width);
@@ -2072,7 +2251,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
         if(value->cssValueType() == CSSValue::CSS_INHERIT)
         {
             if(!parentNode) return;
-            switch(prop->m_id)
+            switch(id)
             {
             case CSS_PROP_MARKER_OFFSET:
                 // ###
@@ -2090,7 +2269,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
 	    if(!primitiveValue) return;
 	    width = primitiveValue->computeLength(style, paintDeviceMetrics);
 	}
-        switch(prop->m_id)
+        switch(id)
         {
         case CSS_PROP_LETTER_SPACING:
             style->setLetterSpacing(width);
@@ -2105,7 +2284,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
         return;
     }
 
-// length, percent
+        // length, percent
     case CSS_PROP_MAX_WIDTH:
         // +none +inherit
         if(primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE)
@@ -2113,15 +2292,6 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
     case CSS_PROP_TOP:
     case CSS_PROP_LEFT:
     case CSS_PROP_RIGHT:
-        // http://www.w3.org/Style/css2-updates/REC-CSS2-19980512-errata
-        // introduces static-position value for top, left & right
-        if(prop->m_id != CSS_PROP_MAX_WIDTH && primitiveValue &&
-           primitiveValue->getIdent() == CSS_VAL_STATIC_POSITION)
-        {
-            //kdDebug( 6080 ) << "found value=static-position" << endl;
-            l = Length ( 0, Static );
-            apply = true;
-        }
     case CSS_PROP_BOTTOM:
     case CSS_PROP_WIDTH:
     case CSS_PROP_MIN_WIDTH:
@@ -2130,7 +2300,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
     case CSS_PROP_MARGIN_BOTTOM:
     case CSS_PROP_MARGIN_LEFT:
         // +inherit +auto
-        if(prop->m_id != CSS_PROP_MAX_WIDTH && primitiveValue &&
+        if(id != CSS_PROP_MAX_WIDTH && primitiveValue &&
            primitiveValue->getIdent() == CSS_VAL_AUTO)
         {
             //kdDebug( 6080 ) << "found value=auto" << endl;
@@ -2146,7 +2316,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
         if(value->cssValueType() == CSSValue::CSS_INHERIT) {
             if(!parentNode) return;
 	    apply = true;
-            switch(prop->m_id)
+            switch(id)
                 {
                 case CSS_PROP_MAX_WIDTH:
                     l = parentStyle->maxWidth(); break;
@@ -2191,12 +2361,14 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
                            primitiveValue->isQuirkValue());
             else if(type == CSSPrimitiveValue::CSS_PERCENTAGE)
                 l = Length((int)primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_PERCENTAGE), Percent);
+            else if (type == CSSPrimitiveValue::CSS_HTML_RELATIVE)
+                l = Length(int(primitiveValue->getFloatValue(CSSPrimitiveValue::CSS_HTML_RELATIVE)), Relative);
             else
                 return;
             apply = true;
         }
         if(!apply) return;
-        switch(prop->m_id)
+        switch(id)
             {
             case CSS_PROP_MAX_WIDTH:
                 style->setMaxWidth(l); break;
@@ -2242,14 +2414,14 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
     case CSS_PROP_HEIGHT:
     case CSS_PROP_MIN_HEIGHT:
         // +inherit +auto !can be calculted directly!
-        if(prop->m_id != CSS_PROP_MAX_HEIGHT && primitiveValue &&
+        if(id != CSS_PROP_MAX_HEIGHT && primitiveValue &&
            primitiveValue->getIdent() == CSS_VAL_AUTO)
             apply = true;
         if(value->cssValueType() == CSSValue::CSS_INHERIT)
         {
             if(!parentNode) return;
 	    apply = true;
-            switch(prop->m_id)
+            switch(id)
                 {
                 case CSS_PROP_MAX_HEIGHT:
                     l = parentStyle->maxHeight(); break;
@@ -2277,7 +2449,7 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
             apply = true;
         }
         if(!apply) return;
-        switch(prop->m_id)
+        switch(id)
         {
         case CSS_PROP_MAX_HEIGHT:
             style->setMaxHeight(l); break;
@@ -2550,7 +2722,16 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
             CSSPrimitiveValueImpl *val = static_cast<CSSPrimitiveValueImpl *>(item);
             if(val->primitiveType()==CSSPrimitiveValue::CSS_STRING)
             {
-                style->setContent(val->getStringValue());
+                style->setContent(val->getStringValue(), i != 0);
+            }
+            else if (val->primitiveType()==CSSPrimitiveValue::CSS_ATTR)
+            {
+                // FIXME: Should work with generic XML attributes also, and not
+                // just the hardcoded HTML set.  Can a namespace be specified for
+                // an attr(foo)?
+                int attrID = element->getDocument()->attrId(0, val->getStringValue(), false);
+                if (attrID)
+                    style->setContent(element->getAttribute(attrID).implementation(), i != 0);
             }
             else if (val->primitiveType()==CSSPrimitiveValue::CSS_URI)
             {
@@ -2582,62 +2763,34 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
             CSSValueImpl *item = list->item(i);
             if(!item->isPrimitiveValue()) continue;
             CSSPrimitiveValueImpl *val = static_cast<CSSPrimitiveValueImpl *>(item);
-            if(val->primitiveType() != CSSPrimitiveValue::CSS_STRING) return;
             QString face;
-            FontFamilyValueImpl *familyVal = static_cast<FontFamilyValueImpl *>(val);
-            if (familyVal->isKonqBody()) {
-                // Obtain the <body> element's font information,
-                // and use its family list.
-                DOM::DocumentImpl* doc = element->getDocument();
-                if (doc && doc->isHTMLDocument()) {
-                    DOM::HTMLDocumentImpl* htmldoc = static_cast<DOM::HTMLDocumentImpl*>(doc);
-                    DOM::HTMLElementImpl* body = htmldoc->body();
-                    if (body && body->renderer()) {
-                        FontDef& bodyFontDef = const_cast<FontDef &>(body->renderer()->style()->htmlFont().fontDef);
-                        fontDef.family = bodyFontDef.firstFamily();
-                        fontDef.genericFamily = bodyFontDef.genericFamily;
-                        if (style->setFontDef( fontDef )) {
-                            fontDirty = true;
-                        }
-                        break;
-                    }
-                }
-                
-                face = settings->stdFontName();
-            } else {
-            	FontDef::GenericFamilyType type = static_cast<FontDef::GenericFamilyType>(familyVal->genericFamilyType());
-                switch (type) {
-                    case FontDef::eNone:
-                        face = familyVal->fontName();
+            if( val->primitiveType() == CSSPrimitiveValue::CSS_STRING )
+                face = static_cast<FontFamilyValueImpl *>(val)->fontName();
+            else if (val->primitiveType() == CSSPrimitiveValue::CSS_IDENT) {
+                switch (val->getIdent()) {
+                    case CSS_VAL__KONQ_BODY:
+                        face = settings->stdFontName();
                         break;
-                    case FontDef::eSerif:
+                    case CSS_VAL_SERIF:
                         face = settings->serifFontName();
                         fontDef.setGenericFamily(FontDef::eSerif);
                         break;
-                    case FontDef::eSansSerif:
+                    case CSS_VAL_SANS_SERIF:
                         face = settings->sansSerifFontName();
                         fontDef.setGenericFamily(FontDef::eSansSerif);
                         break;
-                    case FontDef::eCursive:
+                    case CSS_VAL_CURSIVE:
                         face = settings->cursiveFontName();
                         fontDef.setGenericFamily(FontDef::eCursive);
                         break;
-                    case FontDef::eFantasy:
+                    case CSS_VAL_FANTASY:
                         face = settings->fantasyFontName();
                         fontDef.setGenericFamily(FontDef::eFantasy);
                         break;
-                    case FontDef::eMonospace:
+                    case CSS_VAL_MONOSPACE:
                         face = settings->fixedFontName();
                         fontDef.setGenericFamily(FontDef::eMonospace);
                         break;
-                    case FontDef::eStandard:
-                        // Actually "konq_default".
-                        // Treat this as though it's a generic family, since we will want
-                        // to reset to default sizes when we encounter this (and inherit
-                        // from an enclosing different family like monospace).
-                        face = settings->stdFontName();
-                        fontDef.setGenericFamily(FontDef::eStandard);
-                        break;
                 }
             }
     
@@ -2753,21 +2906,21 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
     case CSS_PROP_BORDER_WIDTH:
         if(value->cssValueType() != CSSValue::CSS_INHERIT || !parentNode) return;
 
-        if(prop->m_id == CSS_PROP_BORDER || prop->m_id == CSS_PROP_BORDER_COLOR)
+        if(id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_COLOR)
         {
             style->setBorderTopColor(parentStyle->borderTopColor());
             style->setBorderBottomColor(parentStyle->borderBottomColor());
             style->setBorderLeftColor(parentStyle->borderLeftColor());
             style->setBorderRightColor(parentStyle->borderRightColor());
         }
-        if(prop->m_id == CSS_PROP_BORDER || prop->m_id == CSS_PROP_BORDER_STYLE)
+        if(id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_STYLE)
         {
             style->setBorderTopStyle(parentStyle->borderTopStyle());
             style->setBorderBottomStyle(parentStyle->borderBottomStyle());
             style->setBorderLeftStyle(parentStyle->borderLeftStyle());
             style->setBorderRightStyle(parentStyle->borderRightStyle());
         }
-        if(prop->m_id == CSS_PROP_BORDER || prop->m_id == CSS_PROP_BORDER_WIDTH)
+        if(id == CSS_PROP_BORDER || id == CSS_PROP_BORDER_WIDTH)
         {
             style->setBorderTopWidth(parentStyle->borderTopWidth());
             style->setBorderBottomWidth(parentStyle->borderBottomWidth());
@@ -2816,6 +2969,34 @@ void CSSStyleSelector::applyRule( DOM::CSSProperty *prop )
 
 //     case CSS_PROP_CUE:
     case CSS_PROP_FONT:
+        if ( value->cssValueType() == CSSValue::CSS_INHERIT ) {
+            if ( !parentNode )
+                return;
+            FontDef fontDef = parentStyle->htmlFont().fontDef;
+            style->setLineHeight( parentStyle->lineHeight() );
+            if (style->setFontDef( fontDef ))
+                fontDirty = true;
+        } else if ( value->isFontValue() ) {
+            FontValueImpl *font = static_cast<FontValueImpl *>(value);
+            if ( !font->style || !font->variant || !font->weight ||
+                 !font->size || !font->lineHeight || !font->family )
+                return;
+            applyRule( CSS_PROP_FONT_STYLE, font->style );
+            applyRule( CSS_PROP_FONT_VARIANT, font->variant );
+            applyRule( CSS_PROP_FONT_WEIGHT, font->weight );
+            applyRule( CSS_PROP_FONT_SIZE, font->size );
+
+            // Line-height can depend on font().pixelSize(), so we have to update the font
+            // before we evaluate line-height, e.g., font: 1em/1em.  FIXME: Still not
+            // good enough: style="font:1em/1em; font-size:36px" should have a line-height of 36px.
+            if (fontDirty)
+                CSSStyleSelector::style->htmlFont().update( paintDeviceMetrics );
+            
+            applyRule( CSS_PROP_LINE_HEIGHT, font->lineHeight );
+            applyRule( CSS_PROP_FONT_FAMILY, font->family );
+        }
+        return;
+        
     case CSS_PROP_LIST_STYLE:
     case CSS_PROP_OUTLINE:
 //    case CSS_PROP_PAUSE:
diff --git a/WebCore/khtml/css/cssstyleselector.h b/WebCore/khtml/css/cssstyleselector.h
index 1268fe3..ad7b9e2 100644
--- a/WebCore/khtml/css/cssstyleselector.h
+++ b/WebCore/khtml/css/cssstyleselector.h
@@ -44,6 +44,7 @@ namespace DOM {
     class CSSStyleDeclarationImpl;
     class CSSProperty;
     class StyleSheetListImpl;
+    class CSSValueImpl;
 }
 
 namespace khtml
@@ -61,8 +62,8 @@ namespace khtml
      */
     enum Source {
 	Default = 0,
-	User = 1,
-	NonCSSHint = 2,
+	NonCSSHint = 1,
+        User = 2,
 	Author = 3,
 	Inline = 4,
 	AuthorImportant = 5,
@@ -159,8 +160,9 @@ namespace khtml
 				   unsigned int numProps);
 
 	static DOM::CSSStyleSheetImpl *defaultSheet;
+        static DOM::CSSStyleSheetImpl *quirksSheet;
 	static CSSStyleSelectorList *defaultStyle;
-    static CSSStyleSelectorList *defaultQuirksStyle;
+        static CSSStyleSelectorList *defaultQuirksStyle;
 	static CSSStyleSelectorList *defaultPrintStyle;
 	CSSStyleSelectorList *authorStyle;
         CSSStyleSelectorList *userStyle;
@@ -227,7 +229,7 @@ public:
 
 	bool fontDirty;
 	
-	void applyRule(DOM::CSSProperty *prop);
+	void applyRule(int id, DOM::CSSValueImpl *value);
     };
 
     /*
@@ -295,8 +297,7 @@ public:
 	virtual ~CSSStyleSelectorList();
 
 	void append( DOM::CSSStyleSheetImpl *sheet,
-                 const DOM::DOMString &medium = "screen",
-                 int quirksMode = 0 );
+                 const DOM::DOMString &medium = "screen" );
 
 	void collect( QPtrList<DOM::CSSSelector> *selectorList, CSSOrderedPropertyList *propList,
 		      Source regular, Source important );
diff --git a/WebCore/khtml/css/cssvalues.c b/WebCore/khtml/css/cssvalues.c
index f73ef92..36b68da 100644
--- a/WebCore/khtml/css/cssvalues.c
+++ b/WebCore/khtml/css/cssvalues.c
@@ -7,7 +7,7 @@ struct css_value {
     const char *name;
     int id;
 };
-/* maximum key range = 1382, duplicates = 1 */
+/* maximum key range = 1430, duplicates = 1 */
 
 #ifdef __GNUC__
 __inline
@@ -21,32 +21,32 @@ hash_val (register const char *str, register unsigned int len)
 {
   static const unsigned short asso_values[] =
     {
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382,   40, 1382, 1382,    0,   25,
-        35,   40,   45,   50,    5,   10,   20,    0, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382,    0,  163,    4,
-        64,   15,    0,  235,  160,   15,    5,  145,    0,  175,
-        70,    0,    9,  120,  120,   40,    0,  255,  179,  115,
-        15,   40,  195, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382, 1382,
-      1382, 1382, 1382, 1382, 1382, 1382
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430,    0, 1430, 1430,    0,    5,
+        10,   15,   20,   25,   30,   35,   40,    0, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430,    0,  188,   34,
+        78,  170,  185,  230,   55,    0,    5,   34,   20,   79,
+        80,   35,   14,  195,   25,    5,    0,  160,  213,  240,
+       210,  149,  240, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430, 1430,
+      1430, 1430, 1430, 1430, 1430, 1430
     };
   register int hval = 0;
 
@@ -108,364 +108,415 @@ findValue (register const char *str, register unsigned int len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 181,
+      TOTAL_KEYWORDS = 228,
       MIN_WORD_LENGTH = 3,
       MAX_WORD_LENGTH = 21,
       MIN_HASH_VALUE = 0,
-      MAX_HASH_VALUE = 1381
+      MAX_HASH_VALUE = 1429
     };
 
   static const struct css_value wordlist_value[] =
     {
       {"900", CSS_VAL_900},
-      {"600", CSS_VAL_600},
-      {"top", CSS_VAL_TOP},
-      {"700", CSS_VAL_700},
-      {"left", CSS_VAL_LEFT},
-      {"800", CSS_VAL_800},
       {"100", CSS_VAL_100},
-      {"text", CSS_VAL_TEXT},
-      {"italic", CSS_VAL_ITALIC},
       {"200", CSS_VAL_200},
       {"300", CSS_VAL_300},
       {"400", CSS_VAL_400},
       {"500", CSS_VAL_500},
+      {"600", CSS_VAL_600},
+      {"700", CSS_VAL_700},
       {"static", CSS_VAL_STATIC},
-      {"collapse", CSS_VAL_COLLAPSE},
-      {"text-top", CSS_VAL_TEXT_TOP},
-      {"icon", CSS_VAL_ICON},
-      {"caption", CSS_VAL_CAPTION},
-      {"fixed", CSS_VAL_FIXED},
-      {"solid", CSS_VAL_SOLID},
+      {"800", CSS_VAL_800},
       {"ltr", CSS_VAL_LTR},
       {"rtl", CSS_VAL_RTL},
+      {"top", CSS_VAL_TOP},
+      {"italic", CSS_VAL_ITALIC},
+      {"portrait", CSS_VAL_PORTRAIT},
+      {"cross", CSS_VAL_CROSS},
+      {"crop", CSS_VAL_CROP},
       {"disc", CSS_VAL_DISC},
+      {"thick", CSS_VAL_THICK},
+      {"small", CSS_VAL_SMALL},
+      {"thin", CSS_VAL_THIN},
+      {"solid", CSS_VAL_SOLID},
+      {"scroll", CSS_VAL_SCROLL},
+      {"katakana", CSS_VAL_KATAKANA},
+      {"icon", CSS_VAL_ICON},
+      {"caption", CSS_VAL_CAPTION},
+      {"small-caps", CSS_VAL_SMALL_CAPS},
+      {"crosshair", CSS_VAL_CROSSHAIR},
+      {"teal", CSS_VAL_TEAL},
+      {"auto", CSS_VAL_AUTO},
+      {"compact", CSS_VAL_COMPACT},
+      {"pre", CSS_VAL_PRE},
+      {"hand", CSS_VAL_HAND},
+      {"normal", CSS_VAL_NORMAL},
       {"wait", CSS_VAL_WAIT},
-      {"crop", CSS_VAL_CROP},
+      {"maroon", CSS_VAL_MAROON},
       {"inset", CSS_VAL_INSET},
-      {"dotted", CSS_VAL_DOTTED},
-      {"pre", CSS_VAL_PRE},
-      {"fantasy", CSS_VAL_FANTASY},
-      {"none", CSS_VAL_NONE},
-      {"circle", CSS_VAL_CIRCLE},
-      {"repeat", CSS_VAL_REPEAT},
-      {"scroll", CSS_VAL_SCROLL},
-      {"table", CSS_VAL_TABLE},
       {"help", CSS_VAL_HELP},
-      {"inline", CSS_VAL_INLINE},
-      {"serif", CSS_VAL_SERIF},
-      {"compact", CSS_VAL_COMPACT},
-      {"always", CSS_VAL_ALWAYS},
-      {"separate", CSS_VAL_SEPARATE},
-      {"landscape", CSS_VAL_LANDSCAPE},
-      {"cross", CSS_VAL_CROSS},
+      {"katakana-iroha", CSS_VAL_KATAKANA_IROHA},
+      {"lime", CSS_VAL_LIME},
+      {"red", CSS_VAL_RED},
+      {"list-item", CSS_VAL_LIST_ITEM},
+      {"black", CSS_VAL_BLACK},
+      {"both", CSS_VAL_BOTH},
+      {"circle", CSS_VAL_CIRCLE},
+      {"small-caption", CSS_VAL_SMALL_CAPTION},
       {"mix", CSS_VAL_MIX},
-      {"level", CSS_VAL_LEVEL},
-      {"repeat-x", CSS_VAL_REPEAT_X},
-      {"small", CSS_VAL_SMALL},
-      {"inside", CSS_VAL_INSIDE},
-      {"center", CSS_VAL_CENTER},
+      {"loud", CSS_VAL_LOUD},
+      {"collapse", CSS_VAL_COLLAPSE},
+      {"hide", CSS_VAL_HIDE},
+      {"right", CSS_VAL_RIGHT},
+      {"block", CSS_VAL_BLOCK},
+      {"smaller", CSS_VAL_SMALLER},
       {"bold", CSS_VAL_BOLD},
+      {"blink", CSS_VAL_BLINK},
       {"pointer", CSS_VAL_POINTER},
-      {"table-cell", CSS_VAL_TABLE_CELL},
-      {"repeat-y", CSS_VAL_REPEAT_Y},
-      {"thin", CSS_VAL_THIN},
-      {"static-position", CSS_VAL_STATIC_POSITION},
-      {"lower", CSS_VAL_LOWER},
-      {"expanded", CSS_VAL_EXPANDED},
-      {"capitalize", CSS_VAL_CAPITALIZE},
-      {"hide", CSS_VAL_HIDE},
-      {"auto", CSS_VAL_AUTO},
       {"avoid", CSS_VAL_AVOID},
-      {"portrait", CSS_VAL_PORTRAIT},
-      {"no-repeat", CSS_VAL_NO_REPEAT},
+      {"inherit", CSS_VAL_INHERIT},
+      {"inside", CSS_VAL_INSIDE},
       {"x-small", CSS_VAL_X_SMALL},
-      {"decimal", CSS_VAL_DECIMAL},
-      {"xx-small", CSS_VAL_XX_SMALL},
-      {"below", CSS_VAL_BELOW},
-      {"hand", CSS_VAL_HAND},
-      {"list-item", CSS_VAL_LIST_ITEM},
-      {"small-caps", CSS_VAL_SMALL_CAPS},
-      {"lowercase", CSS_VAL_LOWERCASE},
-      {"outset", CSS_VAL_OUTSET},
-      {"block", CSS_VAL_BLOCK},
-      {"monospace", CSS_VAL_MONOSPACE},
-      {"nowrap", CSS_VAL_NOWRAP},
       {"show", CSS_VAL_SHOW},
-      {"table-caption", CSS_VAL_TABLE_CAPTION},
-      {"baseline", CSS_VAL_BASELINE},
-      {"loud", CSS_VAL_LOUD},
-      {"both", CSS_VAL_BOTH},
-      {"thick", CSS_VAL_THICK},
-      {"wider", CSS_VAL_WIDER},
-      {"middle", CSS_VAL_MIDDLE},
-      {"default", CSS_VAL_DEFAULT},
       {"bottom", CSS_VAL_BOTTOM},
-      {"condensed", CSS_VAL_CONDENSED},
+      {"run-in", CSS_VAL_RUN_IN},
+      {"inline", CSS_VAL_INLINE},
+      {"scrollbar", CSS_VAL_SCROLLBAR},
+      {"sub", CSS_VAL_SUB},
+      {"aqua", CSS_VAL_AQUA},
+      {"dotted", CSS_VAL_DOTTED},
+      {"none", CSS_VAL_NONE},
+      {"outset", CSS_VAL_OUTSET},
+      {"super", CSS_VAL_SUPER},
+      {"left", CSS_VAL_LEFT},
+      {"table", CSS_VAL_TABLE},
+      {"repeat", CSS_VAL_REPEAT},
+      {"text", CSS_VAL_TEXT},
+      {"decimal", CSS_VAL_DECIMAL},
+      {"status-bar", CSS_VAL_STATUS_BAR},
+      {"separate", CSS_VAL_SEPARATE},
+      {"serif", CSS_VAL_SERIF},
       {"dashed", CSS_VAL_DASHED},
-      {"relative", CSS_VAL_RELATIVE},
-      {"smaller", CSS_VAL_SMALLER},
-      {"small-caption", CSS_VAL_SMALL_CAPTION},
-      {"justify", CSS_VAL_JUSTIFY},
-      {"above", CSS_VAL_ABOVE},
-      {"katakana", CSS_VAL_KATAKANA},
-      {"bolder", CSS_VAL_BOLDER},
-      {"normal", CSS_VAL_NORMAL},
-      {"move", CSS_VAL_MOVE},
+      {"hiragana", CSS_VAL_HIRAGANA},
+      {"nowrap", CSS_VAL_NOWRAP},
+      {"transparent", CSS_VAL_TRANSPARENT},
+      {"landscape", CSS_VAL_LANDSCAPE},
+      {"purple", CSS_VAL_PURPLE},
+      {"gray", CSS_VAL_GRAY},
+      {"always", CSS_VAL_ALWAYS},
+      {"fantasy", CSS_VAL_FANTASY},
+      {"middle", CSS_VAL_MIDDLE},
+      {"text-top", CSS_VAL_TEXT_TOP},
+      {"silver", CSS_VAL_SILVER},
+      {"armenian", CSS_VAL_ARMENIAN},
+      {"olive", CSS_VAL_OLIVE},
+      {"fuchsia", CSS_VAL_FUCHSIA},
+      {"navy", CSS_VAL_NAVY},
       {"large", CSS_VAL_LARGE},
-      {"lower-latin", CSS_VAL_LOWER_LATIN},
-      {"sans-serif", CSS_VAL_SANS_SERIF},
-      {"hidden", CSS_VAL_HIDDEN},
       {"outside", CSS_VAL_OUTSIDE},
-      {"blink", CSS_VAL_BLINK},
-      {"inherit", CSS_VAL_INHERIT},
+      {"monospace", CSS_VAL_MONOSPACE},
+      {"hidden", CSS_VAL_HIDDEN},
+      {"white", CSS_VAL_WHITE},
+      {"larger", CSS_VAL_LARGER},
+      {"upper-alpha", CSS_VAL_UPPER_ALPHA},
+      {"sans-serif", CSS_VAL_SANS_SERIF},
+      {"capitalize", CSS_VAL_CAPITALIZE},
+      {"center", CSS_VAL_CENTER},
+      {"upper-latin", CSS_VAL_UPPER_LATIN},
       {"invert", CSS_VAL_INVERT},
-      {"inline-table", CSS_VAL_INLINE_TABLE},
-      {"text-bottom", CSS_VAL_TEXT_BOTTOM},
-      {"overline", CSS_VAL_OVERLINE},
-      {"x-large", CSS_VAL_X_LARGE},
-      {"visible", CSS_VAL_VISIBLE},
-      {"embed", CSS_VAL_EMBED},
-      {"super", CSS_VAL_SUPER},
-      {"xx-large", CSS_VAL_XX_LARGE},
-      {"extra-expanded", CSS_VAL_EXTRA_EXPANDED},
-      {"transparent", CSS_VAL_TRANSPARENT},
+      {"menu", CSS_VAL_MENU},
+      {"lower", CSS_VAL_LOWER},
+      {"no-repeat", CSS_VAL_NO_REPEAT},
+      {"move", CSS_VAL_MOVE},
+      {"lighter", CSS_VAL_LIGHTER},
       {"ridge", CSS_VAL_RIDGE},
-      {"table-row", CSS_VAL_TABLE_ROW},
-      {"e-resize", CSS_VAL_E_RESIZE},
-      {"sub", CSS_VAL_SUB},
+      {"justify", CSS_VAL_JUSTIFY},
+      {"hiragana-iroha", CSS_VAL_HIRAGANA_IROHA},
+      {"progress", CSS_VAL_PROGRESS},
+      {"wider", CSS_VAL_WIDER},
+      {"bolder", CSS_VAL_BOLDER},
+      {"repeat-y", CSS_VAL_REPEAT_Y},
+      {"higher", CSS_VAL_HIGHER},
+      {"blue", CSS_VAL_BLUE},
+      {"-konq-auto", CSS_VAL__KONQ_AUTO},
+      {"orange", CSS_VAL_ORANGE},
+      {"table-caption", CSS_VAL_TABLE_CAPTION},
+      {"captiontext", CSS_VAL_CAPTIONTEXT},
+      {"xx-small", CSS_VAL_XX_SMALL},
+      {"square", CSS_VAL_SQUARE},
+      {"medium", CSS_VAL_MEDIUM},
+      {"grey", CSS_VAL_GREY},
+      {"absolute", CSS_VAL_ABSOLUTE},
       {"lower-alpha", CSS_VAL_LOWER_ALPHA},
-      {"armenian", CSS_VAL_ARMENIAN},
+      {"activecaption", CSS_VAL_ACTIVECAPTION},
+      {"-konq-normal", CSS_VAL__KONQ_NORMAL},
+      {"appworkspace", CSS_VAL_APPWORKSPACE},
+      {"repeat-x", CSS_VAL_REPEAT_X},
+      {"lower-latin", CSS_VAL_LOWER_LATIN},
       {"uppercase", CSS_VAL_UPPERCASE},
-      {"absolute", CSS_VAL_ABSOLUTE},
+      {"level", CSS_VAL_LEVEL},
+      {"visible", CSS_VAL_VISIBLE},
+      {"relative", CSS_VAL_RELATIVE},
+      {"narrower", CSS_VAL_NARROWER},
+      {"upper-roman", CSS_VAL_UPPER_ROMAN},
+      {"above", CSS_VAL_ABOVE},
+      {"cursive", CSS_VAL_CURSIVE},
+      {"default", CSS_VAL_DEFAULT},
       {"s-resize", CSS_VAL_S_RESIZE},
-      {"close-quote", CSS_VAL_CLOSE_QUOTE},
-      {"larger", CSS_VAL_LARGER},
-      {"se-resize", CSS_VAL_SE_RESIZE},
+      {"table-cell", CSS_VAL_TABLE_CELL},
+      {"baseline", CSS_VAL_BASELINE},
+      {"yellow", CSS_VAL_YELLOW},
+      {"fixed", CSS_VAL_FIXED},
+      {"highlight", CSS_VAL_HIGHLIGHT},
       {"double", CSS_VAL_DOUBLE},
-      {"crosshair", CSS_VAL_CROSSHAIR},
+      {"below", CSS_VAL_BELOW},
+      {"x-large", CSS_VAL_X_LARGE},
+      {"inactivecaption", CSS_VAL_INACTIVECAPTION},
+      {"inline-block", CSS_VAL_INLINE_BLOCK},
+      {"window", CSS_VAL_WINDOW},
+      {"green", CSS_VAL_GREEN},
+      {"table-row", CSS_VAL_TABLE_ROW},
+      {"infotext", CSS_VAL_INFOTEXT},
+      {"embed", CSS_VAL_EMBED},
       {"n-resize", CSS_VAL_N_RESIZE},
-      {"menu", CSS_VAL_MENU},
-      {"open-quote", CSS_VAL_OPEN_QUOTE},
-      {"ne-resize", CSS_VAL_NE_RESIZE},
-      {"right", CSS_VAL_RIGHT},
-      {"extra-condensed", CSS_VAL_EXTRA_CONDENSED},
-      {"upper-latin", CSS_VAL_UPPER_LATIN},
-      {"semi-expanded", CSS_VAL_SEMI_EXPANDED},
-      {"lighter", CSS_VAL_LIGHTER},
+      {"lowercase", CSS_VAL_LOWERCASE},
       {"groove", CSS_VAL_GROOVE},
-      {"square", CSS_VAL_SQUARE},
-      {"w-resize", CSS_VAL_W_RESIZE},
-      {"narrower", CSS_VAL_NARROWER},
+      {"lower-roman", CSS_VAL_LOWER_ROMAN},
+      {"overline", CSS_VAL_OVERLINE},
+      {"cjk-ideographic", CSS_VAL_CJK_IDEOGRAPHIC},
+      {"text-bottom", CSS_VAL_TEXT_BOTTOM},
+      {"-konq-text", CSS_VAL__KONQ_TEXT},
+      {"inline-table", CSS_VAL_INLINE_TABLE},
+      {"condensed", CSS_VAL_CONDENSED},
+      {"-konq-nowrap", CSS_VAL__KONQ_NOWRAP},
       {"oblique", CSS_VAL_OBLIQUE},
-      {"run-in", CSS_VAL_RUN_IN},
-      {"marker", CSS_VAL_MARKER},
+      {"georgian", CSS_VAL_GEORGIAN},
+      {"e-resize", CSS_VAL_E_RESIZE},
+      {"underline", CSS_VAL_UNDERLINE},
+      {"graytext", CSS_VAL_GRAYTEXT},
+      {"se-resize", CSS_VAL_SE_RESIZE},
+      {"table-column", CSS_VAL_TABLE_COLUMN},
+      {"-konq-body", CSS_VAL__KONQ_BODY},
+      {"expanded", CSS_VAL_EXPANDED},
+      {"-konq-center", CSS_VAL__KONQ_CENTER},
+      {"close-quote", CSS_VAL_CLOSE_QUOTE},
+      {"line-through", CSS_VAL_LINE_THROUGH},
+      {"buttontext", CSS_VAL_BUTTONTEXT},
       {"hebrew", CSS_VAL_HEBREW},
+      {"w-resize", CSS_VAL_W_RESIZE},
+      {"buttonface", CSS_VAL_BUTTONFACE},
       {"sw-resize", CSS_VAL_SW_RESIZE},
-      {"no-close-quote", CSS_VAL_NO_CLOSE_QUOTE},
-      {"hiragana", CSS_VAL_HIRAGANA},
-      {"upper-alpha", CSS_VAL_UPPER_ALPHA},
-      {"underline", CSS_VAL_UNDERLINE},
+      {"open-quote", CSS_VAL_OPEN_QUOTE},
+      {"ne-resize", CSS_VAL_NE_RESIZE},
+      {"background", CSS_VAL_BACKGROUND},
+      {"xx-large", CSS_VAL_XX_LARGE},
+      {"menutext", CSS_VAL_MENUTEXT},
+      {"buttonshadow", CSS_VAL_BUTTONSHADOW},
+      {"threedface", CSS_VAL_THREEDFACE},
+      {"threedshadow", CSS_VAL_THREEDSHADOW},
       {"nw-resize", CSS_VAL_NW_RESIZE},
-      {"semi-condensed", CSS_VAL_SEMI_CONDENSED},
-      {"cursive", CSS_VAL_CURSIVE},
+      {"ultra-condensed", CSS_VAL_ULTRA_CONDENSED},
+      {"activeborder", CSS_VAL_ACTIVEBORDER},
+      {"no-close-quote", CSS_VAL_NO_CLOSE_QUOTE},
+      {"-konq-around-floats", CSS_VAL__KONQ_AROUND_FLOATS},
       {"no-open-quote", CSS_VAL_NO_OPEN_QUOTE},
-      {"-konq-center", CSS_VAL__KONQ_CENTER},
-      {"lower-roman", CSS_VAL_LOWER_ROMAN},
-      {"status-bar", CSS_VAL_STATUS_BAR},
+      {"bidi-override", CSS_VAL_BIDI_OVERRIDE},
+      {"semi-condensed", CSS_VAL_SEMI_CONDENSED},
       {"ultra-expanded", CSS_VAL_ULTRA_EXPANDED},
-      {"-konq-auto", CSS_VAL__KONQ_AUTO},
-      {"georgian", CSS_VAL_GEORGIAN},
-      {"katakana-iroha", CSS_VAL_KATAKANA_IROHA},
-      {"medium", CSS_VAL_MEDIUM},
-      {"higher", CSS_VAL_HIGHER},
-      {"table-column", CSS_VAL_TABLE_COLUMN},
-      {"-konq-nowrap", CSS_VAL__KONQ_NOWRAP},
+      {"inactiveborder", CSS_VAL_INACTIVEBORDER},
+      {"highlighttext", CSS_VAL_HIGHLIGHTTEXT},
+      {"inactivecaptiontext", CSS_VAL_INACTIVECAPTIONTEXT},
+      {"threeddarkshadow", CSS_VAL_THREEDDARKSHADOW},
+      {"windowtext", CSS_VAL_WINDOWTEXT},
+      {"semi-expanded", CSS_VAL_SEMI_EXPANDED},
       {"message-box", CSS_VAL_MESSAGE_BOX},
-      {"ultra-condensed", CSS_VAL_ULTRA_CONDENSED},
-      {"-konq-normal", CSS_VAL__KONQ_NORMAL},
-      {"upper-roman", CSS_VAL_UPPER_ROMAN},
+      {"buttonhighlight", CSS_VAL_BUTTONHIGHLIGHT},
       {"lower-greek", CSS_VAL_LOWER_GREEK},
-      {"bidi-override", CSS_VAL_BIDI_OVERRIDE},
-      {"cjk-ideographic", CSS_VAL_CJK_IDEOGRAPHIC},
-      {"-konq-xxx-large", CSS_VAL__KONQ_XXX_LARGE},
-      {"hiragana-iroha", CSS_VAL_HIRAGANA_IROHA},
-      {"-konq-around-floats", CSS_VAL__KONQ_AROUND_FLOATS},
-      {"table-footer-group", CSS_VAL_TABLE_FOOTER_GROUP},
-      {"line-through", CSS_VAL_LINE_THROUGH},
-      {"decimal-leading-zero", CSS_VAL_DECIMAL_LEADING_ZERO},
-      {"-konq-baseline-middle", CSS_VAL__KONQ_BASELINE_MIDDLE},
+      {"windowframe", CSS_VAL_WINDOWFRAME},
+      {"extra-condensed", CSS_VAL_EXTRA_CONDENSED},
       {"table-row-group", CSS_VAL_TABLE_ROW_GROUP},
+      {"threedhighlight", CSS_VAL_THREEDHIGHLIGHT},
+      {"infobackground", CSS_VAL_INFOBACKGROUND},
+      {"extra-expanded", CSS_VAL_EXTRA_EXPANDED},
+      {"threedlightshadow", CSS_VAL_THREEDLIGHTSHADOW},
+      {"table-column-group", CSS_VAL_TABLE_COLUMN_GROUP},
+      {"table-footer-group", CSS_VAL_TABLE_FOOTER_GROUP},
       {"table-header-group", CSS_VAL_TABLE_HEADER_GROUP},
-      {"table-column-group", CSS_VAL_TABLE_COLUMN_GROUP}
+      {"-konq-baseline-middle", CSS_VAL__KONQ_BASELINE_MIDDLE},
+      {"-konq-xxx-large", CSS_VAL__KONQ_XXX_LARGE},
+      {"decimal-leading-zero", CSS_VAL_DECIMAL_LEADING_ZERO}
     };
 
   static const short lookup[] =
     {
          0,   -1,   -1,   -1,   -1,    1,   -1,   -1,
-        -1,    2,    3,   -1,   -1,   -1,   -1,    4,
-        -1,   -1,   -1,   -1,    5,   -1,   -1,   -1,
-        -1,    6,   -1,   -1,   -1,   -1,    7,   -1,
-        -1,   -1,    8,    9,   -1,   -1,   -1,   -1,
-        10,   -1,   -1,   -1,   -1,   11,   -1,   -1,
-        -1,   -1,   12,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   13,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   14,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   15,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   16,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   17,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   18,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   19,
-      -303, -161,   -2,   22,   -1,   -1,   -1,   -1,
-        -1,   -1,   23,   -1,   -1,   24,   -1,   -1,
-        -1,   -1,   -1,   -1,   25,   -1,   -1,   26,
-        27,   -1,   -1,   -1,   -1,   -1,   28,   -1,
-        -1,   -1,   -1,   29,   -1,   -1,   30,   31,
-        -1,   -1,   -1,   -1,   32,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   33,   -1,   -1,   -1,   -1,   -1,
-        34,   35,   -1,   -1,   -1,   -1,   36,   -1,
-        37,   -1,   -1,   38,   -1,   -1,   -1,   39,
-        -1,   -1,   40,   -1,   41,   42,   -1,   -1,
-        -1,   43,   -1,   -1,   -1,   -1,   44,   45,
-        -1,   -1,   -1,   46,   -1,   -1,   -1,   -1,
-        47,   -1,   -1,   48,   -1,   49,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   50,   -1,   51,
-        -1,   -1,   -1,   -1,   -1,   52,   -1,   -1,
-        53,   -1,   54,   -1,   55,   56,   57,   58,
-        -1,   -1,   59,   -1,   -1,   -1,   -1,   -1,
-        60,   -1,   -1,   -1,   -1,   61,   62,   -1,
-        -1,   63,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   64,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   65,   66,   -1,
-        -1,   -1,   -1,   -1,   67,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   68,   69,   70,   -1,
-        71,   72,   73,   74,   75,   -1,   76,   77,
-        -1,   -1,   -1,   78,   79,   -1,   -1,   -1,
-        -1,   80,   -1,   -1,   -1,   81,   82,   -1,
-        -1,   -1,   83,   -1,   -1,   -1,   84,   85,
-        86,   -1,   -1,   -1,   -1,   -1,   87,   -1,
-        -1,   88,   -1,   89,   -1,   90,   -1,   -1,
-        91,   -1,   92,   -1,   -1,   93,   -1,   -1,
-        -1,   94,   95,   -1,   -1,   -1,   -1,   96,
-        -1,   -1,   -1,   -1,   97,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   98,   99,   -1,   -1,
-        -1,  100,   -1,  101,   -1,   -1,   -1,  102,
-        -1,   -1,   -1,  103,   -1,   -1,   -1,   -1,
-       104,   -1,   -1,   -1,   -1,   -1,  105,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,  106,   -1,  107,   -1,   -1,   -1,   -1,
-       108,   -1,   -1,   -1,   -1,   -1,   -1,  109,
-       110,   -1,  111,   -1,  112,   -1,   -1,   -1,
-        -1,  113,   -1,   -1,   -1,  114,   -1,  115,
-        -1,   -1,  116,  117,   -1,   -1,   -1,   -1,
-        -1,  118,   -1,  119,   -1,   -1,   -1,   -1,
-        -1,  120,   -1,   -1,   -1,   -1,   -1,   -1,
-       121,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,  122,  123,   -1,   -1,   -1,   -1,  124,
-        -1,  125,   -1,  126,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,  127,   -1,
-        -1,   -1,   -1,  128,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,  129,  130,   -1,   -1,
-        -1,   -1,  131,   -1,  132,  133,   -1,   -1,
-        -1,  134,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,  135,   -1,   -1,   -1,  136,  137,   -1,
-        -1,   -1,   -1,  138,   -1,   -1,   -1,   -1,
-       139,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-       140,   -1,  141,   -1,   -1,   -1,   -1,  142,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,  143,   -1,   -1,   -1,
-        -1,   -1,   -1,  144,   -1,   -1,   -1,  145,
-       146,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,    2,   -1,   -1,   -1,   -1,    3,
+        -1,   -1,   -1,   -1,    4,   -1,   -1,   -1,
+        -1,    5,   -1,   -1,   -1,   -1,    6,   -1,
+        -1,   -1,   -1,    7,   -1,   -1,   -1,    8,
+         9,   -1,   -1,   -1,   -1, -275, -218,   -2,
+        -1,   12,   -1,   -1,   -1,   -1,   13,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,  147,   -1,   -1,   -1,   -1,   -1,   -1,
-       148,  149,   -1,  150,  151,   -1,   -1,   -1,
-        -1,   -1,  152,   -1,   -1,   -1,   -1,  153,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,  154,
-        -1,   -1,  155,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,  156,   -1,   -1,  157,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,  158,   -1,   -1,   -1,   -1,  159,
-        -1,   -1,   -1,  160,   -1,   -1,   -1,   -1,
-        -1,  161,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,  162,   -1,   -1,   -1,   -1,   -1,
-        -1,  163,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,  164,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   14,   -1,   -1,   -1,   -1,
+        15,   -1,   -1,   -1,   16,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   17,   -1,   -1,
+        -1,   -1,   -1,   18,   19,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   20,
+        -1,   -1,   21,   22,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   23,   24,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,  165,   -1,   -1,
+        -1,   -1,   -1,   25,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,  166,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,  167,   -1,   -1,
+        -1,   26,   -1,   -1,   -1,   -1,   -1,   -1,
+        27,   -1,   -1,   -1,   -1,   -1,   28,   -1,
+        -1,   -1,   -1,   29,   30,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   31,   -1,   -1,   -1,   32,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   33,
+        34,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   35,   36,
+        -1,   -1,   -1,   37,   -1,   -1,   -1,   38,
+        -1,   -1,   -1,   -1,   -1,   39,   -1,   -1,
+        -1,   40,   41,   -1,   42,   -1,   43,   -1,
+        -1,   -1,   -1,   44,   -1,   -1,   -1,   45,
+        -1,   46,   -1,   -1,   -1,   47,   -1,   -1,
+        -1,   -1,   48,   -1,   -1,   -1,   -1,   49,
+        -1,   -1,   -1,   -1,   -1,   -1,   50,   51,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   52,
+        -1,   53,   54,   -1,   55,   -1,   56,   -1,
+        -1,   -1,   57,   -1,   -1,   58,   59,   60,
+        -1,   61,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   62,   -1,   -1,   -1,   -1,   63,   -1,
+        64,   65,   -1,   66,   -1,   -1,   -1,   -1,
+        -1,   67,   -1,   -1,   -1,   68,   -1,   -1,
+        -1,   -1,   69,   -1,   -1,   -1,   70,   71,
+        -1,   -1,   72,   73,   74,   75,   -1,   76,
+        77,   78,   79,   -1,   -1,   -1,   80,   -1,
+        -1,   -1,   81,   -1,   -1,   -1,   -1,   82,
+        -1,   83,   -1,   84,   85,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   86,   -1,
+        -1,   -1,   -1,   87,   -1,   -1,   -1,   -1,
+        -1,   88,   -1,   -1,   -1,   89,   -1,   -1,
+        -1,   90,   91,   -1,   -1,   -1,   92,   93,
+        -1,   -1,   94,   -1,   -1,   95,   -1,   -1,
+        96,   -1,   -1,   -1,   97,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   98,   -1,   -1,
+        -1,   99,   -1,   -1,   -1,   -1,  100,   -1,
+       101,   -1,   -1,  102,   -1,   -1,  103,  104,
+        -1,   -1,   -1,  105,   -1,   -1,   -1,   -1,
+       106,  107,  108,   -1,   -1,   -1,  109,   -1,
+        -1,  110,   -1,   -1,  111,   -1,   -1,  112,
+       113,  114,   -1,   -1,   -1,  115,   -1,   -1,
+        -1,  116,   -1,   -1,  117,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+       118,   -1,   -1,   -1,   -1,   -1,   -1,  119,
+        -1,   -1,  120,  121,  122,  123,   -1,  124,
+       125,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,  126,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,  127,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,  128,   -1,
+        -1,   -1,  129,  130,  131,   -1,   -1,  132,
+        -1,  133,   -1,   -1,   -1,  134,  135,   -1,
+       136,  137,   -1,   -1,  138,   -1,  139,   -1,
+       140,   -1,  141,   -1,   -1,   -1,  142,  143,
+        -1,   -1,   -1,   -1,   -1,  144,   -1,  145,
+        -1,   -1,   -1,   -1,   -1,   -1,  146,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,  147,  148,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,  149,   -1,  150,   -1,   -1,
+        -1,   -1,   -1,  151,   -1,  152,   -1,  153,
+        -1,   -1,   -1,   -1,  154,  155,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,  156,   -1,  157,   -1,   -1,  158,   -1,
+       159,   -1,   -1,   -1,   -1,  160,   -1,   -1,
+        -1,   -1,  161,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,  162,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,  163,  164,   -1,   -1,
+        -1,  165,  166,   -1,   -1,  167,   -1,   -1,
         -1,   -1,   -1,   -1,  168,   -1,   -1,   -1,
-        -1,  169,   -1,   -1,   -1,   -1,   -1,  170,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,  171,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,  172,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+       169,   -1,  170,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,  171,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+       172,   -1,  173,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,  174,   -1,   -1,  175,
+       176,  177,  178,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,  179,   -1,   -1,   -1,   -1,   -1,
+       180,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,  181,
+       182,   -1,   -1,   -1,   -1,   -1,  183,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,  184,   -1,   -1,   -1,   -1,
+       185,   -1,  186,   -1,  187,   -1,   -1,  188,
+        -1,   -1,   -1,  189,  190,   -1,   -1,   -1,
+       191,  192,   -1,   -1,   -1,  193,   -1,   -1,
+        -1,   -1,   -1,   -1,  194,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,  195,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,  173,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,  174,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,  196,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,  197,   -1,   -1,   -1,   -1,  198,
+        -1,   -1,  199,  200,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,  201,
+        -1,   -1,   -1,   -1,   -1,   -1,  202,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,  203,   -1,
+       204,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,  205,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,  175,   -1,
+        -1,   -1,  206,   -1,   -1,   -1,   -1,   -1,
+        -1,  207,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,  176,   -1,   -1,   -1,   -1,   -1,
+       208,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+       209,   -1,   -1,   -1,   -1,  210,  211,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,  177,   -1,   -1,   -1,   -1,   -1,
-       178,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,  212,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,  213,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,  214,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,  215,   -1,   -1,  216,
+        -1,   -1,   -1,   -1,   -1,   -1,  217,  218,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,  219,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,  220,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+       221,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,  222,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,  179,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,  223,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,  224,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
@@ -473,8 +524,10 @@ findValue (register const char *str, register unsigned int len)
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,  225,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,  180
+        -1,   -1,   -1,  226,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,  227
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -571,7 +624,54 @@ static const char * const valueList[] = {
 "cursive", 
 "fantasy", 
 "monospace", 
+"-konq-body", 
 "transparent", 
+"aqua", 
+"black", 
+"blue", 
+"fuchsia", 
+"gray", 
+"green", 
+"lime", 
+"maroon", 
+"navy", 
+"olive", 
+"orange", 
+"purple", 
+"red", 
+"silver", 
+"teal", 
+"white", 
+"yellow", 
+"activeborder", 
+"activecaption", 
+"appworkspace", 
+"background", 
+"buttonface", 
+"buttonhighlight", 
+"buttonshadow", 
+"buttontext", 
+"captiontext", 
+"graytext", 
+"highlight", 
+"highlighttext", 
+"inactiveborder", 
+"inactivecaption", 
+"inactivecaptiontext", 
+"infobackground", 
+"infotext", 
+"menutext", 
+"scrollbar", 
+"threeddarkshadow", 
+"threedface", 
+"threedhighlight", 
+"threedlightshadow", 
+"threedshadow", 
+"window", 
+"windowframe", 
+"windowtext", 
+"grey", 
+"-konq-text", 
 "repeat", 
 "repeat-x", 
 "repeat-y", 
@@ -618,7 +718,7 @@ static const char * const valueList[] = {
 "list-item", 
 "run-in", 
 "compact", 
-"marker", 
+"inline-block", 
 "table", 
 "inline-table", 
 "table-row-group", 
@@ -633,6 +733,7 @@ static const char * const valueList[] = {
 "crosshair", 
 "default", 
 "pointer", 
+"progress", 
 "move", 
 "e-resize", 
 "ne-resize", 
@@ -687,7 +788,6 @@ static const char * const valueList[] = {
 "separate", 
 "show", 
 "static", 
-"static-position", 
 "thick", 
 "thin", 
 "underline", 
diff --git a/WebCore/khtml/css/cssvalues.h b/WebCore/khtml/css/cssvalues.h
index 9f1691c..683bd95 100644
--- a/WebCore/khtml/css/cssvalues.h
+++ b/WebCore/khtml/css/cssvalues.h
@@ -67,130 +67,177 @@ DOM::DOMString getValueName(unsigned short id);
 #define CSS_VAL_CURSIVE 56
 #define CSS_VAL_FANTASY 57
 #define CSS_VAL_MONOSPACE 58
-#define CSS_VAL_TRANSPARENT 59
-#define CSS_VAL_REPEAT 60
-#define CSS_VAL_REPEAT_X 61
-#define CSS_VAL_REPEAT_Y 62
-#define CSS_VAL_NO_REPEAT 63
-#define CSS_VAL_BASELINE 64
-#define CSS_VAL_MIDDLE 65
-#define CSS_VAL_SUB 66
-#define CSS_VAL_SUPER 67
-#define CSS_VAL_TEXT_TOP 68
-#define CSS_VAL_TEXT_BOTTOM 69
-#define CSS_VAL_TOP 70
-#define CSS_VAL_BOTTOM 71
-#define CSS_VAL__KONQ_BASELINE_MIDDLE 72
-#define CSS_VAL__KONQ_AUTO 73
-#define CSS_VAL_LEFT 74
-#define CSS_VAL_RIGHT 75
-#define CSS_VAL_CENTER 76
-#define CSS_VAL_JUSTIFY 77
-#define CSS_VAL__KONQ_CENTER 78
-#define CSS_VAL_OUTSIDE 79
-#define CSS_VAL_INSIDE 80
-#define CSS_VAL_DISC 81
-#define CSS_VAL_CIRCLE 82
-#define CSS_VAL_SQUARE 83
-#define CSS_VAL_DECIMAL 84
-#define CSS_VAL_DECIMAL_LEADING_ZERO 85
-#define CSS_VAL_LOWER_ROMAN 86
-#define CSS_VAL_UPPER_ROMAN 87
-#define CSS_VAL_LOWER_GREEK 88
-#define CSS_VAL_LOWER_ALPHA 89
-#define CSS_VAL_LOWER_LATIN 90
-#define CSS_VAL_UPPER_ALPHA 91
-#define CSS_VAL_UPPER_LATIN 92
-#define CSS_VAL_HEBREW 93
-#define CSS_VAL_ARMENIAN 94
-#define CSS_VAL_GEORGIAN 95
-#define CSS_VAL_CJK_IDEOGRAPHIC 96
-#define CSS_VAL_HIRAGANA 97
-#define CSS_VAL_KATAKANA 98
-#define CSS_VAL_HIRAGANA_IROHA 99
-#define CSS_VAL_KATAKANA_IROHA 100
-#define CSS_VAL_INLINE 101
-#define CSS_VAL_BLOCK 102
-#define CSS_VAL_LIST_ITEM 103
-#define CSS_VAL_RUN_IN 104
-#define CSS_VAL_COMPACT 105
-#define CSS_VAL_MARKER 106
-#define CSS_VAL_TABLE 107
-#define CSS_VAL_INLINE_TABLE 108
-#define CSS_VAL_TABLE_ROW_GROUP 109
-#define CSS_VAL_TABLE_HEADER_GROUP 110
-#define CSS_VAL_TABLE_FOOTER_GROUP 111
-#define CSS_VAL_TABLE_ROW 112
-#define CSS_VAL_TABLE_COLUMN_GROUP 113
-#define CSS_VAL_TABLE_COLUMN 114
-#define CSS_VAL_TABLE_CELL 115
-#define CSS_VAL_TABLE_CAPTION 116
-#define CSS_VAL_AUTO 117
-#define CSS_VAL_CROSSHAIR 118
-#define CSS_VAL_DEFAULT 119
-#define CSS_VAL_POINTER 120
-#define CSS_VAL_MOVE 121
-#define CSS_VAL_E_RESIZE 122
-#define CSS_VAL_NE_RESIZE 123
-#define CSS_VAL_NW_RESIZE 124
-#define CSS_VAL_N_RESIZE 125
-#define CSS_VAL_SE_RESIZE 126
-#define CSS_VAL_SW_RESIZE 127
-#define CSS_VAL_S_RESIZE 128
-#define CSS_VAL_W_RESIZE 129
-#define CSS_VAL_TEXT 130
-#define CSS_VAL_WAIT 131
-#define CSS_VAL_HELP 132
-#define CSS_VAL_LTR 133
-#define CSS_VAL_RTL 134
-#define CSS_VAL_CAPITALIZE 135
-#define CSS_VAL_UPPERCASE 136
-#define CSS_VAL_LOWERCASE 137
-#define CSS_VAL_VISIBLE 138
-#define CSS_VAL_COLLAPSE 139
-#define CSS_VAL_ABOVE 140
-#define CSS_VAL_ABSOLUTE 141
-#define CSS_VAL_ALWAYS 142
-#define CSS_VAL_AVOID 143
-#define CSS_VAL_BELOW 144
-#define CSS_VAL_BIDI_OVERRIDE 145
-#define CSS_VAL_BLINK 146
-#define CSS_VAL_BOTH 147
-#define CSS_VAL_CLOSE_QUOTE 148
-#define CSS_VAL_CROP 149
-#define CSS_VAL_CROSS 150
-#define CSS_VAL_EMBED 151
-#define CSS_VAL_FIXED 152
-#define CSS_VAL_HAND 153
-#define CSS_VAL_HIDE 154
-#define CSS_VAL_HIGHER 155
-#define CSS_VAL_INVERT 156
-#define CSS_VAL_LANDSCAPE 157
-#define CSS_VAL_LEVEL 158
-#define CSS_VAL_LINE_THROUGH 159
-#define CSS_VAL_LOUD 160
-#define CSS_VAL_LOWER 161
-#define CSS_VAL_MIX 162
-#define CSS_VAL_NO_CLOSE_QUOTE 163
-#define CSS_VAL_NO_OPEN_QUOTE 164
-#define CSS_VAL_NOWRAP 165
-#define CSS_VAL_OPEN_QUOTE 166
-#define CSS_VAL_OVERLINE 167
-#define CSS_VAL_PORTRAIT 168
-#define CSS_VAL_PRE 169
-#define CSS_VAL_RELATIVE 170
-#define CSS_VAL_SCROLL 171
-#define CSS_VAL_SEPARATE 172
-#define CSS_VAL_SHOW 173
-#define CSS_VAL_STATIC 174
-#define CSS_VAL_STATIC_POSITION 175
-#define CSS_VAL_THICK 176
-#define CSS_VAL_THIN 177
-#define CSS_VAL_UNDERLINE 178
-#define CSS_VAL__KONQ_NOWRAP 179
-#define CSS_VAL__KONQ_NORMAL 180
-#define CSS_VAL__KONQ_AROUND_FLOATS 181
+#define CSS_VAL__KONQ_BODY 59
+#define CSS_VAL_TRANSPARENT 60
+#define CSS_VAL_AQUA 61
+#define CSS_VAL_BLACK 62
+#define CSS_VAL_BLUE 63
+#define CSS_VAL_FUCHSIA 64
+#define CSS_VAL_GRAY 65
+#define CSS_VAL_GREEN 66
+#define CSS_VAL_LIME 67
+#define CSS_VAL_MAROON 68
+#define CSS_VAL_NAVY 69
+#define CSS_VAL_OLIVE 70
+#define CSS_VAL_ORANGE 71
+#define CSS_VAL_PURPLE 72
+#define CSS_VAL_RED 73
+#define CSS_VAL_SILVER 74
+#define CSS_VAL_TEAL 75
+#define CSS_VAL_WHITE 76
+#define CSS_VAL_YELLOW 77
+#define CSS_VAL_ACTIVEBORDER 78
+#define CSS_VAL_ACTIVECAPTION 79
+#define CSS_VAL_APPWORKSPACE 80
+#define CSS_VAL_BACKGROUND 81
+#define CSS_VAL_BUTTONFACE 82
+#define CSS_VAL_BUTTONHIGHLIGHT 83
+#define CSS_VAL_BUTTONSHADOW 84
+#define CSS_VAL_BUTTONTEXT 85
+#define CSS_VAL_CAPTIONTEXT 86
+#define CSS_VAL_GRAYTEXT 87
+#define CSS_VAL_HIGHLIGHT 88
+#define CSS_VAL_HIGHLIGHTTEXT 89
+#define CSS_VAL_INACTIVEBORDER 90
+#define CSS_VAL_INACTIVECAPTION 91
+#define CSS_VAL_INACTIVECAPTIONTEXT 92
+#define CSS_VAL_INFOBACKGROUND 93
+#define CSS_VAL_INFOTEXT 94
+#define CSS_VAL_MENUTEXT 95
+#define CSS_VAL_SCROLLBAR 96
+#define CSS_VAL_THREEDDARKSHADOW 97
+#define CSS_VAL_THREEDFACE 98
+#define CSS_VAL_THREEDHIGHLIGHT 99
+#define CSS_VAL_THREEDLIGHTSHADOW 100
+#define CSS_VAL_THREEDSHADOW 101
+#define CSS_VAL_WINDOW 102
+#define CSS_VAL_WINDOWFRAME 103
+#define CSS_VAL_WINDOWTEXT 104
+#define CSS_VAL_GREY 105
+#define CSS_VAL__KONQ_TEXT 106
+#define CSS_VAL_REPEAT 107
+#define CSS_VAL_REPEAT_X 108
+#define CSS_VAL_REPEAT_Y 109
+#define CSS_VAL_NO_REPEAT 110
+#define CSS_VAL_BASELINE 111
+#define CSS_VAL_MIDDLE 112
+#define CSS_VAL_SUB 113
+#define CSS_VAL_SUPER 114
+#define CSS_VAL_TEXT_TOP 115
+#define CSS_VAL_TEXT_BOTTOM 116
+#define CSS_VAL_TOP 117
+#define CSS_VAL_BOTTOM 118
+#define CSS_VAL__KONQ_BASELINE_MIDDLE 119
+#define CSS_VAL__KONQ_AUTO 120
+#define CSS_VAL_LEFT 121
+#define CSS_VAL_RIGHT 122
+#define CSS_VAL_CENTER 123
+#define CSS_VAL_JUSTIFY 124
+#define CSS_VAL__KONQ_CENTER 125
+#define CSS_VAL_OUTSIDE 126
+#define CSS_VAL_INSIDE 127
+#define CSS_VAL_DISC 128
+#define CSS_VAL_CIRCLE 129
+#define CSS_VAL_SQUARE 130
+#define CSS_VAL_DECIMAL 131
+#define CSS_VAL_DECIMAL_LEADING_ZERO 132
+#define CSS_VAL_LOWER_ROMAN 133
+#define CSS_VAL_UPPER_ROMAN 134
+#define CSS_VAL_LOWER_GREEK 135
+#define CSS_VAL_LOWER_ALPHA 136
+#define CSS_VAL_LOWER_LATIN 137
+#define CSS_VAL_UPPER_ALPHA 138
+#define CSS_VAL_UPPER_LATIN 139
+#define CSS_VAL_HEBREW 140
+#define CSS_VAL_ARMENIAN 141
+#define CSS_VAL_GEORGIAN 142
+#define CSS_VAL_CJK_IDEOGRAPHIC 143
+#define CSS_VAL_HIRAGANA 144
+#define CSS_VAL_KATAKANA 145
+#define CSS_VAL_HIRAGANA_IROHA 146
+#define CSS_VAL_KATAKANA_IROHA 147
+#define CSS_VAL_INLINE 148
+#define CSS_VAL_BLOCK 149
+#define CSS_VAL_LIST_ITEM 150
+#define CSS_VAL_RUN_IN 151
+#define CSS_VAL_COMPACT 152
+#define CSS_VAL_INLINE_BLOCK 153
+#define CSS_VAL_TABLE 154
+#define CSS_VAL_INLINE_TABLE 155
+#define CSS_VAL_TABLE_ROW_GROUP 156
+#define CSS_VAL_TABLE_HEADER_GROUP 157
+#define CSS_VAL_TABLE_FOOTER_GROUP 158
+#define CSS_VAL_TABLE_ROW 159
+#define CSS_VAL_TABLE_COLUMN_GROUP 160
+#define CSS_VAL_TABLE_COLUMN 161
+#define CSS_VAL_TABLE_CELL 162
+#define CSS_VAL_TABLE_CAPTION 163
+#define CSS_VAL_AUTO 164
+#define CSS_VAL_CROSSHAIR 165
+#define CSS_VAL_DEFAULT 166
+#define CSS_VAL_POINTER 167
+#define CSS_VAL_PROGRESS 168
+#define CSS_VAL_MOVE 169
+#define CSS_VAL_E_RESIZE 170
+#define CSS_VAL_NE_RESIZE 171
+#define CSS_VAL_NW_RESIZE 172
+#define CSS_VAL_N_RESIZE 173
+#define CSS_VAL_SE_RESIZE 174
+#define CSS_VAL_SW_RESIZE 175
+#define CSS_VAL_S_RESIZE 176
+#define CSS_VAL_W_RESIZE 177
+#define CSS_VAL_TEXT 178
+#define CSS_VAL_WAIT 179
+#define CSS_VAL_HELP 180
+#define CSS_VAL_LTR 181
+#define CSS_VAL_RTL 182
+#define CSS_VAL_CAPITALIZE 183
+#define CSS_VAL_UPPERCASE 184
+#define CSS_VAL_LOWERCASE 185
+#define CSS_VAL_VISIBLE 186
+#define CSS_VAL_COLLAPSE 187
+#define CSS_VAL_ABOVE 188
+#define CSS_VAL_ABSOLUTE 189
+#define CSS_VAL_ALWAYS 190
+#define CSS_VAL_AVOID 191
+#define CSS_VAL_BELOW 192
+#define CSS_VAL_BIDI_OVERRIDE 193
+#define CSS_VAL_BLINK 194
+#define CSS_VAL_BOTH 195
+#define CSS_VAL_CLOSE_QUOTE 196
+#define CSS_VAL_CROP 197
+#define CSS_VAL_CROSS 198
+#define CSS_VAL_EMBED 199
+#define CSS_VAL_FIXED 200
+#define CSS_VAL_HAND 201
+#define CSS_VAL_HIDE 202
+#define CSS_VAL_HIGHER 203
+#define CSS_VAL_INVERT 204
+#define CSS_VAL_LANDSCAPE 205
+#define CSS_VAL_LEVEL 206
+#define CSS_VAL_LINE_THROUGH 207
+#define CSS_VAL_LOUD 208
+#define CSS_VAL_LOWER 209
+#define CSS_VAL_MIX 210
+#define CSS_VAL_NO_CLOSE_QUOTE 211
+#define CSS_VAL_NO_OPEN_QUOTE 212
+#define CSS_VAL_NOWRAP 213
+#define CSS_VAL_OPEN_QUOTE 214
+#define CSS_VAL_OVERLINE 215
+#define CSS_VAL_PORTRAIT 216
+#define CSS_VAL_PRE 217
+#define CSS_VAL_RELATIVE 218
+#define CSS_VAL_SCROLL 219
+#define CSS_VAL_SEPARATE 220
+#define CSS_VAL_SHOW 221
+#define CSS_VAL_STATIC 222
+#define CSS_VAL_THICK 223
+#define CSS_VAL_THIN 224
+#define CSS_VAL_UNDERLINE 225
+#define CSS_VAL__KONQ_NOWRAP 226
+#define CSS_VAL__KONQ_NORMAL 227
+#define CSS_VAL__KONQ_AROUND_FLOATS 228
 
-#define CSS_VAL_TOTAL 182
+#define CSS_VAL_TOTAL 229
 #endif
 
diff --git a/WebCore/khtml/css/cssvalues.in b/WebCore/khtml/css/cssvalues.in
index c457364..39665a4 100644
--- a/WebCore/khtml/css/cssvalues.in
+++ b/WebCore/khtml/css/cssvalues.in
@@ -11,10 +11,10 @@
 #
 inherit
 #
-# CSS_PROP_OUTLINE_STYLE 
-# CSS_PROP_BORDER_TOP_STYLE  
-# CSS_PROP_BORDER_BOTTOM_STYLE  
-# CSS_PROP_BORDER_LEFT_STYLE  
+# CSS_PROP_OUTLINE_STYLE
+# CSS_PROP_BORDER_TOP_STYLE
+# CSS_PROP_BORDER_BOTTOM_STYLE
+# CSS_PROP_BORDER_LEFT_STYLE
 none
 hidden
 dotted
@@ -62,7 +62,7 @@ lighter
 800
 900
 #
-# CSS_PROP_FONT_SIZE: 
+# CSS_PROP_FONT_SIZE:
 #
 xx-small
 x-small
@@ -96,20 +96,73 @@ sans-serif
 cursive
 fantasy
 monospace
+-konq-body
 #
 #
 # CSS_PROP_BACKGROUND_COLOR:
 #
 transparent
 #
-# CSS_PROP_BACKGROUND_REPEAT:  
+#
+# CSS_PROP_*_COLOR
+#
+aqua
+black
+blue
+fuchsia
+gray
+green
+lime
+maroon
+navy
+olive
+orange
+purple
+red
+silver
+teal
+white
+yellow
+activeborder
+activecaption
+appworkspace
+background
+buttonface
+buttonhighlight
+buttonshadow
+buttontext
+captiontext
+graytext
+highlight
+highlighttext
+inactiveborder
+inactivecaption
+inactivecaptiontext
+infobackground
+infotext
+menutext
+scrollbar
+threeddarkshadow
+threedface
+threedhighlight
+threedlightshadow
+threedshadow
+window
+windowframe
+windowtext
+#
+# colors in non strict mode
+grey
+-konq-text
+#
+# CSS_PROP_BACKGROUND_REPEAT:
 #
 repeat
 repeat-x
 repeat-y
 no-repeat
 #
-# CSS_PROP_VERTICAL_ALIGN: 
+# CSS_PROP_VERTICAL_ALIGN:
 #
 baseline
 middle
@@ -122,7 +175,7 @@ bottom
 # HTML alignment MIDDLE has no corresponding CSS alignment
 -konq-baseline-middle
 #
-# CSS_PROP_TEXT_ALIGN: 
+# CSS_PROP_TEXT_ALIGN:
 #
 -konq-auto
 left
@@ -131,7 +184,7 @@ center
 justify
 -konq-center
 #
-# CSS_PROP_LIST_STYLE_POSITION: 
+# CSS_PROP_LIST_STYLE_POSITION:
 #
 outside
 inside
@@ -167,7 +220,7 @@ block
 list-item
 run-in
 compact
-marker
+inline-block
 table
 inline-table
 table-row-group
@@ -186,6 +239,7 @@ auto
 crosshair
 default
 pointer
+progress
 move
 e-resize
 ne-resize
@@ -199,12 +253,12 @@ text
 wait
 help
 #
-# CSS_PROP_DIRECTION:  
+# CSS_PROP_DIRECTION:
 #
 ltr
 rtl
 #
-# CSS_PROP_TEXT_TRANSFORM:  
+# CSS_PROP_TEXT_TRANSFORM:
 #
 capitalize
 uppercase
@@ -254,7 +308,6 @@ scroll
 separate
 show
 static
-static-position
 thick
 thin
 underline
@@ -265,7 +318,7 @@ underline
 #
 # Not supported CSS 2 Aural values
 #
-# CSS_PROP_AZIMUTH:  
+# CSS_PROP_AZIMUTH:
 #
 #A left-side
 #A far-left
@@ -280,7 +333,7 @@ underline
 #A leftwards
 #A rightwards
 #
-# CSS_PROP_SPEECH_RATE:   
+# CSS_PROP_SPEECH_RATE:
 #
 #A x-slow
 #A slow
@@ -300,7 +353,7 @@ underline
 #A x-high
 #A x-loud
 #
-# CSS_PROP_PITCH: 
+# CSS_PROP_PITCH:
 #
 #A x-low
 #A low
@@ -308,13 +361,13 @@ underline
 #A #high
 #A #x-high
 #
-# CSS_PROP_SPEAK:  
+# CSS_PROP_SPEAK:
 #
 #A #normal
 #A #none
 #A spell-out
 #
-# CSS_PROP_SPEAK_HEADER:  
+# CSS_PROP_SPEAK_HEADER:
 #
 #A #once
 #A always
diff --git a/WebCore/khtml/css/html4.css b/WebCore/khtml/css/html4.css
index 04931da..2e974e0 100644
--- a/WebCore/khtml/css/html4.css
+++ b/WebCore/khtml/css/html4.css
@@ -2,18 +2,17 @@
  * The default style sheet used by khtml to render HTML pages
  * (C) Lars Knoll (knoll at kde.org) 2000
  *
- * Konqueror/khtml relies on the existance of this style sheet for
+ * Konqueror/khtml relies on the existence of this style sheet for
  * rendering. Do not remove or modify this file unless you know
  * what you are doing.
  */
 
 html {
 	display: block;
-	color: text;        
 } 
 
 /*
- * head and it's children all have display=none
+ * head and its children all have display=none
  */
 
 head { 
@@ -60,7 +59,7 @@ script {
 
 p {
 	display: block;
-	margin: 1.0_qem 0px;
+	margin: 1.0__qem 0px;
 }
 
 div {
@@ -77,7 +76,7 @@ address {
       
 blockquote {
 	display: block;
-	margin: 1_qem 40px 1em 40px;
+	margin: 1__qem 40px 1em 40px;
 }
 
 Q        {
@@ -114,7 +113,7 @@ APPLET {
 CENTER { 
 	display: block;
 	/* special centering to be able to emulate the html4/netscape behaviour */
-	text-align: -konq-center;
+	text-align: \2d konq-center;
 }  
       
 HR  { 
@@ -125,7 +124,7 @@ HR  {
         border-width: 1px;
         margin-left: 1px; /* will be overwritten by ALIGN */ 
         margin-right: 1px; /* will be overwritten by ALIGN */
-        -konq-flow-mode: -konq-around-floats
+        \2d konq-flow-mode: \2d konq-around-floats;
 } 
  
 MAP { 
@@ -140,41 +139,41 @@ MAP {
 H1 { 
 	display: block;
 	font-size: 2em; 
-	margin: .67_qem auto .67em auto;
+	margin: .67__qem auto .67em auto;
 	font-weight: bolder;
 }
       
 H2 { 
 	display: block;
 	font-size: 1.5em; 
-	margin: .83_qem auto .83em auto;
+	margin: .83__qem auto .83em auto;
 	font-weight: bolder;
 }
       
 H3 { 
 	display: block;
 	font-size: 1.17em; 
-	margin: 1_qem auto 1em auto;
+	margin: 1__qem auto 1em auto;
 	font-weight: bolder;
 }
       
 H4 {
 	display: block;
-	margin: 1.33_qem auto 1.33em auto;
+	margin: 1.33__qem auto 1.33em auto;
 	font-weight: bolder;
 }
 
 H5 { 
 	display: block;
 	font-size: .83em; 
-	margin: 1.67_qem auto 1.67em auto;
+	margin: 1.67__qem auto 1.67em auto;
 	font-weight: bolder;
 }
 
 H6 { 
 	display: block;
 	font-size: .67em; 
-	margin: 2.33_qem auto 2.33em auto;
+	margin: 2.33__qem auto 2.33em auto;
 	font-weight: bolder;
 }
 
@@ -185,10 +184,10 @@ H6 {
 TABLE { 
 	display: table;
 	border-collapse: separate;
-	text-align: -konq-auto;
+	text-align: \2d konq-auto;
 	border-spacing: 2px;
 	border-color: gray;
-    -konq-flow-mode: -konq-around-floats;
+        \2d konq-flow-mode: \2d konq-around-floats;
 }
 
 TD[align=left] > TABLE {
@@ -249,7 +248,7 @@ TH {
 
 CAPTION { 
 	display: table-caption;  
-	text-align: -konq-center; 
+	text-align: \2d konq-center; 
 }
 
 /* rules to deal with right-aligned divs. -dwh */
@@ -265,14 +264,14 @@ DIV[align="right"] > DIV
 UL, MENU, DIR {
         display: block;
         list-style-type: disc;
-        margin: 1_qem 0 1em 0;
+        margin: 1__qem 0 1em 0;
         padding-left: 40px;
 }
 
 OL {
         display: block;
         list-style-type: decimal;
-        margin: 1_qem 0 1em 0;
+        margin: 1__qem 0 1em 0;
         padding-left: 40px;
 }
 
@@ -301,7 +300,7 @@ DD {
 
 DL {
 	display: block;
-	margin: 1_qem 0 1em 0;
+	margin: 1__qem 0 1em 0;
 } 
 
 DT {
@@ -333,7 +332,7 @@ OL OL {
 
 FORM {
 	display: block;
-    margin: 0_qem 0 1em 0;
+    margin: 0__qem 0 1em 0;
 }
 
 FIELDSET {
@@ -422,7 +421,7 @@ PLAINTEXT {
 	display: block;
 	font-family: monospace; 
 	white-space: pre; 
-	margin: 1_qem 0;
+	margin: 1__qem 0;
 }
       
 BIG { 
@@ -528,23 +527,6 @@ marquee {
         display: none;
 }
 
- at konq-quirks
-{
-    /* Give floated images margins of 3px */
-    img[align="left"] {
-        margin-right: 3px;
-    }
-    
-    img[align="right"] {
-        margin-left: 3px;
-    }
-    
-    /* Make lists flow around floats. */
-    UL, OL, MENU, DIR {
-        -konq-flow-mode: -konq-around-floats;
-    }
-}
-
 /* noscript is handled internally, as it depends on the html settings */
 
 /* media rules are commented out for the moment. We'll have to add
diff --git a/WebCore/khtml/css/parser.cpp b/WebCore/khtml/css/parser.cpp
new file mode 100644
index 0000000..cfa0938
--- /dev/null
+++ b/WebCore/khtml/css/parser.cpp
@@ -0,0 +1,2065 @@
+
+/*  A Bison parser, made from parser.y
+    by GNU Bison version 1.28  */
+
+#define YYBISON 1  /* Identify Bison output.  */
+
+#define yyparse cssyyparse
+#define yylex cssyylex
+#define yyerror cssyyerror
+#define yylval cssyylval
+#define yychar cssyychar
+#define yydebug cssyydebug
+#define yynerrs cssyynerrs
+#define	S	257
+#define	SGML_CD	258
+#define	INCLUDES	259
+#define	DASHMATCH	260
+#define	BEGINSWITH	261
+#define	ENDSWITH	262
+#define	CONTAINS	263
+#define	STRING	264
+#define	IDENT	265
+#define	HASH	266
+#define	IMPORT_SYM	267
+#define	PAGE_SYM	268
+#define	MEDIA_SYM	269
+#define	FONT_FACE_SYM	270
+#define	CHARSET_SYM	271
+#define	KONQ_RULE_SYM	272
+#define	KONQ_DECLS_SYM	273
+#define	KONQ_VALUE_SYM	274
+#define	IMPORTANT_SYM	275
+#define	QEMS	276
+#define	EMS	277
+#define	EXS	278
+#define	PXS	279
+#define	CMS	280
+#define	MMS	281
+#define	INS	282
+#define	PTS	283
+#define	PCS	284
+#define	DEGS	285
+#define	RADS	286
+#define	GRADS	287
+#define	MSECS	288
+#define	SECS	289
+#define	HERZ	290
+#define	KHERZ	291
+#define	DIMEN	292
+#define	PERCENTAGE	293
+#define	NUMBER	294
+#define	URI	295
+#define	FUNCTION	296
+#define	UNICODERANGE	297
+
+#line 1 "parser.y"
+
+
+/*
+ *  This file is part of the KDE libraries
+ *  Copyright (C) 2002-2003 Lars Knoll (knoll at kde.org)
+ *  Copyright (c) 2003 Apple Computer
+ * 
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <stdlib.h>
+
+#include <dom/dom_string.h>
+#include <xml/dom_docimpl.h>
+#include <css/css_ruleimpl.h>
+#include <css/css_stylesheetimpl.h>
+#include <css/css_valueimpl.h>
+#include <misc/htmlhashes.h>
+#include "cssparser.h"
+
+#include <assert.h>
+#include <kdebug.h>
+// #define CSS_DEBUG
+
+using namespace DOM;
+
+//
+// The following file defines the function
+//     const struct props *findProp(const char *word, int len)
+//
+// with 'props->id' a CSS property in the range from CSS_PROP_MIN to
+// (and including) CSS_PROP_TOTAL-1
+#include "cssproperties.c"
+#include "cssvalues.c"
+
+int DOM::getPropertyID(const char *tagStr, int len)
+{
+    const struct props *propsPtr = findProp(tagStr, len);
+    if (!propsPtr)
+        return 0;
+
+    return propsPtr->id;
+}
+
+static inline int getValueID(const char *tagStr, int len)
+{
+    const struct css_value *val = findValue(tagStr, len);
+    if (!val)
+        return 0;
+
+    return val->id;
+}
+
+
+#define YYDEBUG 0
+#define YYMAXDEPTH 0
+#define YYPARSE_PARAM parser
+
+#line 80 "parser.y"
+typedef union {
+    CSSRuleImpl *rule;
+    CSSSelector *selector;
+    QPtrList<CSSSelector> *selectorList;
+    bool ok;
+    MediaListImpl *mediaList;
+    CSSMediaRuleImpl *mediaRule;
+    CSSRuleListImpl *ruleList;
+    ParseString string;
+    float val;
+    int prop_id;
+    int attribute;
+    int element;
+    CSSSelector::Relation relation;
+    bool b;
+    char tok;
+    Value value;
+    ValueList *valueList;
+} YYSTYPE;
+#line 100 "parser.y"
+
+
+static inline int cssyyerror(const char *x ) {
+#ifdef CSS_DEBUG
+    qDebug( x );
+#else
+    Q_UNUSED( x );
+#endif
+    return 1;
+}
+
+static int cssyylex( YYSTYPE *yylval ) {
+    return CSSParser::current()->lex( yylval );
+}
+
+
+#include <stdio.h>
+
+#ifndef __cplusplus
+#ifndef __STDC__
+#define const
+#endif
+#endif
+
+
+
+#define	YYFINAL		258
+#define	YYFLAG		-32768
+#define	YYNTBASE	60
+
+#define YYTRANSLATE(x) ((unsigned)(x) <= 297 ? yytranslate[x] : 109)
+
+static const char yytranslate[] = {     0,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+    57,    54,    51,    50,    53,    14,    58,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,    13,    49,     2,
+    56,    52,     2,    59,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+    15,     2,    55,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,    47,     2,    48,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     1,     3,     4,     5,     6,
+     7,     8,     9,    10,    11,    12,    16,    17,    18,    19,
+    20,    21,    22,    23,    24,    25,    26,    27,    28,    29,
+    30,    31,    32,    33,    34,    35,    36,    37,    38,    39,
+    40,    41,    42,    43,    44,    45,    46
+};
+
+#if YYDEBUG != 0
+static const short yyprhs[] = {     0,
+     0,     5,     8,    11,    14,    21,    27,    33,    34,    37,
+    38,    41,    44,    45,    51,    55,    59,    60,    64,    65,
+    69,    71,    73,    75,    77,    79,    81,    88,    92,    96,
+    98,   100,   101,   103,   108,   116,   118,   123,   124,   128,
+   131,   135,   139,   143,   147,   150,   153,   154,   156,   158,
+   164,   166,   171,   173,   177,   180,   184,   187,   189,   191,
+   193,   196,   198,   200,   202,   204,   207,   210,   215,   224,
+   226,   228,   230,   232,   234,   236,   238,   240,   243,   250,
+   252,   255,   257,   261,   263,   267,   271,   277,   282,   287,
+   294,   300,   303,   306,   307,   309,   313,   316,   319,   320,
+   322,   325,   328,   331,   334,   337,   339,   341,   344,   347,
+   350,   353,   356,   359,   362,   365,   368,   371,   374,   377,
+   380,   383,   386,   389,   392,   395,   398,   404,   407,   411,
+   415,   418,   424,   428,   430
+};
+
+static const short yyrhs[] = {    66,
+    65,    67,    68,     0,    61,    64,     0,    62,    64,     0,
+    63,    64,     0,    21,    47,    64,    81,    64,    48,     0,
+    22,    47,    64,    94,    48,     0,    23,    47,    64,    99,
+    48,     0,     0,    64,     3,     0,     0,    65,     4,     0,
+    65,     3,     0,     0,    20,    64,    10,    64,    49,     0,
+    20,     1,   107,     0,    20,     1,    49,     0,     0,    67,
+    70,    65,     0,     0,    68,    69,    65,     0,    81,     0,
+    73,     0,    77,     0,    78,     0,   106,     0,   105,     0,
+    16,    64,    71,    64,    72,    49,     0,    16,     1,   107,
+     0,    16,     1,    49,     0,    10,     0,    44,     0,     0,
+    76,     0,    72,    50,    64,    76,     0,    18,    64,    74,
+    47,    64,    75,    48,     0,    76,     0,    72,    50,    64,
+    76,     0,     0,    75,    81,    64,     0,    11,    64,     0,
+    17,     1,   107,     0,    17,     1,    49,     0,    19,     1,
+   107,     0,    19,     1,    49,     0,    51,    64,     0,    52,
+    64,     0,     0,    53,     0,    51,     0,    82,    47,    64,
+    94,    48,     0,    83,     0,    82,    50,    64,    83,     0,
+    84,     0,    83,    79,    84,     0,    85,    64,     0,    85,
+    86,    64,     0,    86,    64,     0,    11,     0,    54,     0,
+    87,     0,    86,    87,     0,    12,     0,    88,     0,    90,
+     0,    93,     0,    14,    11,     0,    11,    64,     0,    15,
+    64,    89,    55,     0,    15,    64,    89,    91,    64,    92,
+    64,    55,     0,    56,     0,     5,     0,     6,     0,     7,
+     0,     8,     0,     9,     0,    11,     0,    10,     0,    13,
+    11,     0,    13,    45,    64,    11,    64,    57,     0,    96,
+     0,    95,    96,     0,    95,     0,     1,   108,     1,     0,
+     1,     0,    96,    49,    64,     0,     1,    49,    64,     0,
+     1,   108,     1,    49,    64,     0,    95,    96,    49,    64,
+     0,    95,     1,    49,    64,     0,    95,     1,   108,     1,
+    49,    64,     0,    97,    13,    64,    99,    98,     0,    11,
+    64,     0,    24,    64,     0,     0,   101,     0,    99,   100,
+   101,     0,    58,    64,     0,    50,    64,     0,     0,   102,
+     0,    80,   102,     0,    10,    64,     0,    11,    64,     0,
+    44,    64,     0,    46,    64,     0,   104,     0,   103,     0,
+    43,    64,     0,    42,    64,     0,    28,    64,     0,    29,
+    64,     0,    30,    64,     0,    31,    64,     0,    32,    64,
+     0,    33,    64,     0,    34,    64,     0,    35,    64,     0,
+    36,    64,     0,    37,    64,     0,    38,    64,     0,    39,
+    64,     0,    40,    64,     0,    26,    64,     0,    25,    64,
+     0,    27,    64,     0,    41,    64,     0,    45,    64,    99,
+    57,    64,     0,    12,    64,     0,    59,     1,   107,     0,
+    59,     1,    49,     0,     1,   107,     0,    47,     1,   108,
+     1,    48,     0,    47,     1,    48,     0,   107,     0,   108,
+     1,   107,     0
+};
+
+#endif
+
+#if YYDEBUG != 0
+static const short yyrline[] = { 0,
+   226,   228,   229,   230,   233,   240,   246,   271,   273,   276,
+   278,   279,   282,   284,   289,   290,   293,   295,   306,   308,
+   318,   320,   321,   322,   323,   324,   327,   338,   341,   346,
+   348,   351,   355,   359,   366,   380,   385,   392,   394,   403,
+   425,   429,   434,   438,   443,   445,   446,   449,   451,   454,
+   474,   488,   504,   508,   525,   530,   534,   540,   561,   566,
+   571,   581,   588,   589,   590,   593,   602,   626,   632,   640,
+   644,   647,   650,   653,   656,   661,   663,   666,   672,   680,
+   684,   689,   692,   698,   706,   710,   716,   722,   727,   733,
+   741,   764,   771,   773,   776,   781,   794,   798,   801,   806,
+   808,   809,   810,   816,   817,   818,   820,   825,   827,   828,
+   829,   830,   831,   832,   833,   834,   835,   836,   837,   838,
+   839,   840,   841,   842,   843,   844,   848,   863,   870,   877,
+   885,   911,   913,   916,   918
+};
+#endif
+
+
+#if YYDEBUG != 0 || defined (YYERROR_VERBOSE)
+
+static const char * const yytname[] = {   "$","error","$undefined.","S","SGML_CD",
+"INCLUDES","DASHMATCH","BEGINSWITH","ENDSWITH","CONTAINS","STRING","IDENT","HASH",
+"':'","'.'","'['","IMPORT_SYM","PAGE_SYM","MEDIA_SYM","FONT_FACE_SYM","CHARSET_SYM",
+"KONQ_RULE_SYM","KONQ_DECLS_SYM","KONQ_VALUE_SYM","IMPORTANT_SYM","QEMS","EMS",
+"EXS","PXS","CMS","MMS","INS","PTS","PCS","DEGS","RADS","GRADS","MSECS","SECS",
+"HERZ","KHERZ","DIMEN","PERCENTAGE","NUMBER","URI","FUNCTION","UNICODERANGE",
+"'{'","'}'","';'","','","'+'","'>'","'-'","'*'","']'","'='","')'","'/'","'@'",
+"stylesheet","konq_rule","konq_decls","konq_value","maybe_space","maybe_sgml",
+"maybe_charset","import_list","rule_list","rule","import","string_or_uri","media_list",
+"media","media_list2","ruleset_list","medium","page","font_face","combinator",
+"unary_operator","ruleset","selector_list","selector","simple_selector","element_name",
+"specifier_list","specifier","class","attrib_id","attrib","match","ident_or_string",
+"pseudo","declaration_list","decl_list","declaration","property","prio","expr",
+"operator","term","unary_term","function","hexcolor","invalid_at","invalid_rule",
+"invalid_block","invalid_block_list", NULL
+};
+#endif
+
+static const short yyr1[] = {     0,
+    60,    60,    60,    60,    61,    62,    63,    64,    64,    65,
+    65,    65,    66,    66,    66,    66,    67,    67,    68,    68,
+    69,    69,    69,    69,    69,    69,    70,    70,    70,    71,
+    71,    72,    72,    72,    73,    74,    74,    75,    75,    76,
+    77,    77,    78,    78,    79,    79,    79,    80,    80,    81,
+    82,    82,    83,    83,    84,    84,    84,    85,    85,    86,
+    86,    87,    87,    87,    87,    88,    89,    90,    90,    91,
+    91,    91,    91,    91,    91,    92,    92,    93,    93,    94,
+    94,    94,    94,    94,    95,    95,    95,    95,    95,    95,
+    96,    97,    98,    98,    99,    99,   100,   100,   100,   101,
+   101,   101,   101,   101,   101,   101,   101,   102,   102,   102,
+   102,   102,   102,   102,   102,   102,   102,   102,   102,   102,
+   102,   102,   102,   102,   102,   102,   103,   104,   105,   105,
+   106,   107,   107,   108,   108
+};
+
+static const short yyr2[] = {     0,
+     4,     2,     2,     2,     6,     5,     5,     0,     2,     0,
+     2,     2,     0,     5,     3,     3,     0,     3,     0,     3,
+     1,     1,     1,     1,     1,     1,     6,     3,     3,     1,
+     1,     0,     1,     4,     7,     1,     4,     0,     3,     2,
+     3,     3,     3,     3,     2,     2,     0,     1,     1,     5,
+     1,     4,     1,     3,     2,     3,     2,     1,     1,     1,
+     2,     1,     1,     1,     1,     2,     2,     4,     8,     1,
+     1,     1,     1,     1,     1,     1,     1,     2,     6,     1,
+     2,     1,     3,     1,     3,     3,     5,     4,     4,     6,
+     5,     2,     2,     0,     1,     3,     2,     2,     0,     1,
+     2,     2,     2,     2,     2,     1,     1,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     2,     2,     2,     2,
+     2,     2,     2,     2,     2,     2,     5,     2,     3,     3,
+     2,     5,     3,     1,     3
+};
+
+static const short yydefact[] = {    13,
+     0,     0,     0,     0,     8,     8,     8,    10,     0,     0,
+     8,     8,     8,     2,     3,     4,    17,     0,    16,    15,
+     9,     8,     0,     0,     0,    12,    11,    19,     0,     0,
+    58,    62,     0,     0,     8,    59,     8,     0,    47,    53,
+     8,     8,    60,    63,    64,    65,    84,     8,     0,     0,
+    80,     0,     8,     8,     8,     8,     8,     8,     8,     8,
+     8,     8,     8,     8,     8,     8,     8,     8,     8,     8,
+     8,     8,     8,     8,     8,     8,     8,    49,    48,     0,
+    99,    95,   100,   107,   106,     0,     0,    10,   133,   134,
+     0,    14,    78,     8,    66,     0,     0,     8,     8,     8,
+     8,     0,    55,     8,    57,    61,     8,     0,    92,     6,
+     0,    81,     8,     8,   102,   103,   128,   124,   123,   125,
+   110,   111,   112,   113,   114,   115,   116,   117,   118,   119,
+   120,   121,   122,   126,   109,   108,   104,     0,   105,   101,
+     7,     8,     8,     0,     0,     0,     0,     0,     8,     0,
+     0,    10,    22,    23,    24,    21,    26,    25,    18,     0,
+     0,     8,     0,     5,     0,     0,    45,    46,    54,    56,
+    86,    83,     8,     0,     8,    85,     0,    99,    98,    97,
+    96,    29,    28,    30,    31,     8,   131,     0,    32,     0,
+     0,    20,   132,   135,     8,    67,    71,    72,    73,    74,
+    75,    68,    70,     8,     0,    47,     8,    89,     0,    88,
+    99,     8,    32,    42,    41,     8,     0,     0,    33,    44,
+    43,   130,   129,     0,     0,    50,    87,     8,     8,    91,
+   127,     0,    33,    40,     8,     8,    79,    77,    76,     8,
+    90,    93,    27,     8,     0,    38,     0,     0,    34,     0,
+    69,    34,    35,     8,    39,     0,     0,     0
+};
+
+static const short yydefgoto[] = {   256,
+     5,     6,     7,    10,    17,     8,    28,    87,   152,    88,
+   186,   217,   153,   218,   250,   219,   154,   155,   102,    80,
+    37,    38,    39,    40,    41,    42,    43,    44,   163,    45,
+   204,   240,    46,    49,    50,    51,    52,   230,    81,   144,
+    82,    83,    84,    85,   157,   158,    90,    91
+};
+
+static const short yypact[] = {   175,
+    32,   -36,    -9,    -3,-32768,-32768,-32768,-32768,    93,    97,
+-32768,-32768,-32768,    79,    79,    79,   152,    87,-32768,-32768,
+-32768,-32768,   117,    13,   226,-32768,-32768,    81,   153,    31,
+-32768,-32768,    80,    92,-32768,-32768,-32768,    51,   128,-32768,
+   200,   200,-32768,-32768,-32768,-32768,    96,-32768,    58,    30,
+    77,   123,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   292,
+   -30,-32768,-32768,-32768,-32768,   173,   104,-32768,-32768,-32768,
+   145,-32768,-32768,-32768,-32768,    12,    42,-32768,-32768,-32768,
+-32768,   137,    79,   200,    79,-32768,-32768,   176,    79,-32768,
+   115,   138,-32768,-32768,    79,    79,    79,    79,    79,    79,
+    79,    79,    79,    79,    79,    79,    79,    79,    79,    79,
+    79,    79,    79,    79,    79,    79,    79,   226,    79,-32768,
+-32768,-32768,-32768,   263,   139,     2,   158,   208,-32768,   219,
+   221,-32768,-32768,-32768,-32768,-32768,-32768,-32768,   152,   185,
+    18,-32768,    78,-32768,    13,   117,    79,    79,-32768,    79,
+    79,   157,-32768,   225,-32768,    79,   226,   -31,    79,    79,
+-32768,-32768,-32768,-32768,-32768,-32768,-32768,   161,    36,   169,
+   172,   152,-32768,-32768,-32768,    79,-32768,-32768,-32768,-32768,
+-32768,-32768,-32768,-32768,   180,   142,-32768,    79,   178,    79,
+   111,-32768,    36,-32768,-32768,-32768,   184,   195,   196,-32768,
+-32768,-32768,-32768,    19,   162,-32768,    79,-32768,-32768,-32768,
+    79,   191,-32768,    79,-32768,-32768,-32768,-32768,-32768,-32768,
+    79,    79,-32768,-32768,    36,    79,    22,    36,   197,    99,
+-32768,-32768,-32768,-32768,    79,   245,   246,-32768
+};
+
+static const short yypgoto[] = {-32768,
+-32768,-32768,-32768,    -5,   -79,-32768,-32768,-32768,-32768,-32768,
+-32768,    34,-32768,-32768,-32768,  -121,-32768,-32768,-32768,-32768,
+   -83,-32768,    82,   148,-32768,   235,   -29,-32768,-32768,-32768,
+-32768,-32768,-32768,   113,-32768,   230,-32768,-32768,   -98,-32768,
+   140,   201,-32768,-32768,-32768,-32768,    -6,   -37
+};
+
+
+#define	YYLAST		335
+
+
+static const short yytable[] = {    14,
+    15,    16,    20,   156,    21,    23,    24,    25,   159,   108,
+    11,   184,   106,    47,    21,    21,    30,   141,   142,   142,
+    21,    21,   162,    48,    21,   212,   143,   143,   195,    96,
+   111,    97,     9,    21,    -8,   103,   105,    12,    21,   178,
+    48,    -8,   109,    13,    21,   185,   216,   115,   116,   117,
+   118,   119,   120,   121,   122,   123,   124,   125,   126,   127,
+   128,   129,   130,   131,   132,   133,   134,   135,   136,   137,
+   138,   139,   192,   174,   106,   237,   251,   -82,   211,    92,
+   146,    21,   197,   198,   199,   200,   201,    29,   161,   164,
+    93,   233,   165,   166,   167,   168,    86,    98,   170,    21,
+    99,   171,    95,    -1,   147,   110,    22,   176,   177,    31,
+    32,    33,    34,    35,    31,    32,    33,    34,    35,    21,
+   148,   149,   150,   249,    94,   113,   252,    31,    32,    33,
+    34,    35,   202,   203,   229,   114,   179,   180,   183,    18,
+   187,    19,    18,   189,   107,   160,   253,    31,    32,    33,
+    34,    35,    36,   194,    26,    27,   196,    36,   -94,   -94,
+   142,    18,   151,   173,    21,   194,   254,   208,   143,   210,
+    36,   238,   239,   145,   -51,    -8,   172,   -51,   100,   101,
+   213,   215,    -8,   221,   223,    18,   175,   182,   -52,   224,
+    36,   -52,   100,   101,     1,     2,     3,     4,   225,    18,
+    89,   227,   194,    18,    18,   207,   231,    18,   188,   214,
+   234,    32,    33,    34,    35,    18,    -8,   220,    18,   190,
+   222,   191,   241,   242,    18,   209,   228,   226,    21,   245,
+   246,    18,   193,   235,   247,    53,    54,    55,   248,   243,
+   244,   236,   -36,   -37,   257,   258,   232,   206,   255,   169,
+    56,    57,    58,    59,    60,    61,    62,    63,    64,    65,
+    66,    67,    68,    69,    70,    71,    72,    73,    74,    75,
+    76,    77,    53,    54,    55,   104,    78,   205,    79,   112,
+   140,     0,     0,   181,     0,     0,     0,    56,    57,    58,
+    59,    60,    61,    62,    63,    64,    65,    66,    67,    68,
+    69,    70,    71,    72,    73,    74,    75,    76,    77,     0,
+     0,     0,     0,    78,     0,    79,    56,    57,    58,    59,
+    60,    61,    62,    63,    64,    65,    66,    67,    68,    69,
+    70,    71,    72,    73,    74
+};
+
+static const short yycheck[] = {     5,
+     6,     7,     9,    87,     3,    11,    12,    13,    88,    47,
+    47,    10,    42,     1,     3,     3,    22,    48,    50,    50,
+     3,     3,    11,    11,     3,    57,    58,    58,    11,    35,
+     1,    37,     1,     3,     3,    41,    42,    47,     3,   138,
+    11,    10,    48,    47,     3,    44,    11,    53,    54,    55,
+    56,    57,    58,    59,    60,    61,    62,    63,    64,    65,
+    66,    67,    68,    69,    70,    71,    72,    73,    74,    75,
+    76,    77,   152,   111,   104,    57,    55,    48,   177,    49,
+    86,     3,     5,     6,     7,     8,     9,     1,    94,    48,
+    11,   213,    98,    99,   100,   101,    16,    47,   104,     3,
+    50,   107,    11,     0,     1,    48,    10,   113,   114,    11,
+    12,    13,    14,    15,    11,    12,    13,    14,    15,     3,
+    17,    18,    19,   245,    45,    49,   248,    11,    12,    13,
+    14,    15,    55,    56,    24,    13,   142,   143,   145,    47,
+   147,    49,    47,   149,    49,     1,    48,    11,    12,    13,
+    14,    15,    54,   160,     3,     4,   162,    54,    48,    49,
+    50,    47,    59,    49,     3,   172,   250,   173,    58,   175,
+    54,    10,    11,     1,    47,     3,     1,    50,    51,    52,
+   186,   188,    10,   190,   191,    47,    49,    49,    47,   195,
+    54,    50,    51,    52,    20,    21,    22,    23,   204,    47,
+    48,   207,   209,    47,    47,    49,   212,    47,     1,    49,
+   216,    12,    13,    14,    15,    47,    44,    49,    47,     1,
+    49,     1,   228,   229,    47,     1,    49,    48,     3,   235,
+   236,    47,    48,    50,   240,    10,    11,    12,   244,    49,
+    50,    47,    47,    47,     0,     0,   213,   166,   254,   102,
+    25,    26,    27,    28,    29,    30,    31,    32,    33,    34,
+    35,    36,    37,    38,    39,    40,    41,    42,    43,    44,
+    45,    46,    10,    11,    12,    41,    51,   165,    53,    50,
+    80,    -1,    -1,   144,    -1,    -1,    -1,    25,    26,    27,
+    28,    29,    30,    31,    32,    33,    34,    35,    36,    37,
+    38,    39,    40,    41,    42,    43,    44,    45,    46,    -1,
+    -1,    -1,    -1,    51,    -1,    53,    25,    26,    27,    28,
+    29,    30,    31,    32,    33,    34,    35,    36,    37,    38,
+    39,    40,    41,    42,    43
+};
+#define YYPURE 1
+
+/* -*-C-*-  Note some compilers choke on comments on `#line' lines.  */
+#line 3 "/usr/share/bison.simple"
+/* This file comes from bison-1.28.  */
+
+/* Skeleton output parser for bison,
+   Copyright (C) 1984, 1989, 1990 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* As a special exception, when this file is copied by Bison into a
+   Bison output file, you may use that output file without restriction.
+   This special exception was added by the Free Software Foundation
+   in version 1.24 of Bison.  */
+
+/* This is the parser code that is written into each bison parser
+  when the %semantic_parser declaration is not specified in the grammar.
+  It was written by Richard Stallman by simplifying the hairy parser
+  used when %semantic_parser is specified.  */
+
+#ifndef YYSTACK_USE_ALLOCA
+#ifdef alloca
+#define YYSTACK_USE_ALLOCA
+#else /* alloca not defined */
+#ifdef __GNUC__
+#define YYSTACK_USE_ALLOCA
+#define alloca __builtin_alloca
+#else /* not GNU C.  */
+#if (!defined (__STDC__) && defined (sparc)) || defined (__sparc__) || defined (__sparc) || defined (__sgi) || (defined (__sun) && defined (__i386))
+#define YYSTACK_USE_ALLOCA
+#include <alloca.h>
+#else /* not sparc */
+/* We think this test detects Watcom and Microsoft C.  */
+/* This used to test MSDOS, but that is a bad idea
+   since that symbol is in the user namespace.  */
+#if (defined (_MSDOS) || defined (_MSDOS_)) && !defined (__TURBOC__)
+#if 0 /* No need for malloc.h, which pollutes the namespace;
+	 instead, just don't use alloca.  */
+#include <malloc.h>
+#endif
+#else /* not MSDOS, or __TURBOC__ */
+#if defined(_AIX)
+/* I don't know what this was needed for, but it pollutes the namespace.
+   So I turned it off.   rms, 2 May 1997.  */
+/* #include <malloc.h>  */
+ #pragma alloca
+#define YYSTACK_USE_ALLOCA
+#else /* not MSDOS, or __TURBOC__, or _AIX */
+#if 0
+#ifdef __hpux /* haible at ilog.fr says this works for HPUX 9.05 and up,
+		 and on HPUX 10.  Eventually we can turn this on.  */
+#define YYSTACK_USE_ALLOCA
+#define alloca __builtin_alloca
+#endif /* __hpux */
+#endif
+#endif /* not _AIX */
+#endif /* not MSDOS, or __TURBOC__ */
+#endif /* not sparc */
+#endif /* not GNU C */
+#endif /* alloca not defined */
+#endif /* YYSTACK_USE_ALLOCA not defined */
+
+#ifdef YYSTACK_USE_ALLOCA
+#define YYSTACK_ALLOC alloca
+#else
+#define YYSTACK_ALLOC malloc
+#endif
+
+/* Note: there must be only one dollar sign in this file.
+   It is replaced by the list of actions, each action
+   as one case of the switch.  */
+
+#define yyerrok		(yyerrstatus = 0)
+#define yyclearin	(yychar = YYEMPTY)
+#define YYEMPTY		-2
+#define YYEOF		0
+#define YYACCEPT	goto yyacceptlab
+#define YYABORT 	goto yyabortlab
+#define YYERROR		goto yyerrlab1
+/* Like YYERROR except do call yyerror.
+   This remains here temporarily to ease the
+   transition to the new meaning of YYERROR, for GCC.
+   Once GCC version 2 has supplanted version 1, this can go.  */
+#define YYFAIL		goto yyerrlab
+#define YYRECOVERING()  (!!yyerrstatus)
+#define YYBACKUP(token, value) \
+do								\
+  if (yychar == YYEMPTY && yylen == 1)				\
+    { yychar = (token), yylval = (value);			\
+      yychar1 = YYTRANSLATE (yychar);				\
+      YYPOPSTACK;						\
+      goto yybackup;						\
+    }								\
+  else								\
+    { yyerror ("syntax error: cannot back up"); YYERROR; }	\
+while (0)
+
+#define YYTERROR	1
+#define YYERRCODE	256
+
+#ifndef YYPURE
+#define YYLEX		yylex()
+#endif
+
+#ifdef YYPURE
+#ifdef YYLSP_NEEDED
+#ifdef YYLEX_PARAM
+#define YYLEX		yylex(&yylval, &yylloc, YYLEX_PARAM)
+#else
+#define YYLEX		yylex(&yylval, &yylloc)
+#endif
+#else /* not YYLSP_NEEDED */
+#ifdef YYLEX_PARAM
+#define YYLEX		yylex(&yylval, YYLEX_PARAM)
+#else
+#define YYLEX		yylex(&yylval)
+#endif
+#endif /* not YYLSP_NEEDED */
+#endif
+
+/* If nonreentrant, generate the variables here */
+
+#ifndef YYPURE
+
+int	yychar;			/*  the lookahead symbol		*/
+YYSTYPE	yylval;			/*  the semantic value of the		*/
+				/*  lookahead symbol			*/
+
+#ifdef YYLSP_NEEDED
+YYLTYPE yylloc;			/*  location data for the lookahead	*/
+				/*  symbol				*/
+#endif
+
+int yynerrs;			/*  number of parse errors so far       */
+#endif  /* not YYPURE */
+
+#if YYDEBUG != 0
+int yydebug;			/*  nonzero means print parse trace	*/
+/* Since this is uninitialized, it does not stop multiple parsers
+   from coexisting.  */
+#endif
+
+/*  YYINITDEPTH indicates the initial size of the parser's stacks	*/
+
+#ifndef	YYINITDEPTH
+#define YYINITDEPTH 200
+#endif
+
+/*  YYMAXDEPTH is the maximum size the stacks can grow to
+    (effective only if the built-in stack extension method is used).  */
+
+#if YYMAXDEPTH == 0
+#undef YYMAXDEPTH
+#endif
+
+#ifndef YYMAXDEPTH
+#define YYMAXDEPTH 10000
+#endif
+
+/* Define __yy_memcpy.  Note that the size argument
+   should be passed with type unsigned int, because that is what the non-GCC
+   definitions require.  With GCC, __builtin_memcpy takes an arg
+   of type size_t, but it can handle unsigned int.  */
+
+#if __GNUC__ > 1		/* GNU C and GNU C++ define this.  */
+#define __yy_memcpy(TO,FROM,COUNT)	__builtin_memcpy(TO,FROM,COUNT)
+#else				/* not GNU C or C++ */
+#ifndef __cplusplus
+
+/* This is the most reliable way to avoid incompatibilities
+   in available built-in functions on various systems.  */
+static void
+__yy_memcpy (to, from, count)
+     char *to;
+     char *from;
+     unsigned int count;
+{
+  register char *f = from;
+  register char *t = to;
+  register int i = count;
+
+  while (i-- > 0)
+    *t++ = *f++;
+}
+
+#else /* __cplusplus */
+
+/* This is the most reliable way to avoid incompatibilities
+   in available built-in functions on various systems.  */
+static void
+__yy_memcpy (char *to, char *from, unsigned int count)
+{
+  register char *t = to;
+  register char *f = from;
+  register int i = count;
+
+  while (i-- > 0)
+    *t++ = *f++;
+}
+
+#endif
+#endif
+
+#line 217 "/usr/share/bison.simple"
+
+/* The user can define YYPARSE_PARAM as the name of an argument to be passed
+   into yyparse.  The argument should have type void *.
+   It should actually point to an object.
+   Grammar actions can access the variable by casting it
+   to the proper pointer type.  */
+
+#ifdef YYPARSE_PARAM
+#ifdef __cplusplus
+#define YYPARSE_PARAM_ARG void *YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL
+#else /* not __cplusplus */
+#define YYPARSE_PARAM_ARG YYPARSE_PARAM
+#define YYPARSE_PARAM_DECL void *YYPARSE_PARAM;
+#endif /* not __cplusplus */
+#else /* not YYPARSE_PARAM */
+#define YYPARSE_PARAM_ARG
+#define YYPARSE_PARAM_DECL
+#endif /* not YYPARSE_PARAM */
+
+/* Prevent warning if -Wstrict-prototypes.  */
+#ifdef __GNUC__
+#ifdef YYPARSE_PARAM
+int yyparse (void *);
+#else
+int yyparse (void);
+#endif
+#endif
+
+int
+yyparse(YYPARSE_PARAM_ARG)
+     YYPARSE_PARAM_DECL
+{
+  register int yystate;
+  register int yyn;
+  register short *yyssp;
+  register YYSTYPE *yyvsp;
+  int yyerrstatus;	/*  number of tokens to shift before error messages enabled */
+  int yychar1 = 0;		/*  lookahead token as an internal (translated) token number */
+
+  short	yyssa[YYINITDEPTH];	/*  the state stack			*/
+  YYSTYPE yyvsa[YYINITDEPTH];	/*  the semantic value stack		*/
+
+  short *yyss = yyssa;		/*  refer to the stacks thru separate pointers */
+  YYSTYPE *yyvs = yyvsa;	/*  to allow yyoverflow to reallocate them elsewhere */
+
+#ifdef YYLSP_NEEDED
+  YYLTYPE yylsa[YYINITDEPTH];	/*  the location stack			*/
+  YYLTYPE *yyls = yylsa;
+  YYLTYPE *yylsp;
+
+#define YYPOPSTACK   (yyvsp--, yyssp--, yylsp--)
+#else
+#define YYPOPSTACK   (yyvsp--, yyssp--)
+#endif
+
+  int yystacksize = YYINITDEPTH;
+  int yyfree_stacks = 0;
+
+#ifdef YYPURE
+  int yychar;
+  YYSTYPE yylval;
+  int yynerrs;
+#ifdef YYLSP_NEEDED
+  YYLTYPE yylloc;
+#endif
+#endif
+
+  YYSTYPE yyval;		/*  the variable used to return		*/
+				/*  semantic values from the action	*/
+				/*  routines				*/
+
+  int yylen;
+
+#if YYDEBUG != 0
+  if (yydebug)
+    fprintf(stderr, "Starting parse\n");
+#endif
+
+  yystate = 0;
+  yyerrstatus = 0;
+  yynerrs = 0;
+  yychar = YYEMPTY;		/* Cause a token to be read.  */
+
+  /* Initialize stack pointers.
+     Waste one element of value and location stack
+     so that they stay on the same level as the state stack.
+     The wasted elements are never initialized.  */
+
+  yyssp = yyss - 1;
+  yyvsp = yyvs;
+#ifdef YYLSP_NEEDED
+  yylsp = yyls;
+#endif
+
+/* Push a new state, which is found in  yystate  .  */
+/* In all cases, when you get here, the value and location stacks
+   have just been pushed. so pushing a state here evens the stacks.  */
+yynewstate:
+
+  *++yyssp = yystate;
+
+  if (yyssp >= yyss + yystacksize - 1)
+    {
+      /* Give user a chance to reallocate the stack */
+      /* Use copies of these so that the &'s don't force the real ones into memory. */
+      YYSTYPE *yyvs1 = yyvs;
+      short *yyss1 = yyss;
+#ifdef YYLSP_NEEDED
+      YYLTYPE *yyls1 = yyls;
+#endif
+
+      /* Get the current used size of the three stacks, in elements.  */
+      int size = yyssp - yyss + 1;
+
+#ifdef yyoverflow
+      /* Each stack pointer address is followed by the size of
+	 the data in use in that stack, in bytes.  */
+#ifdef YYLSP_NEEDED
+      /* This used to be a conditional around just the two extra args,
+	 but that might be undefined if yyoverflow is a macro.  */
+      yyoverflow("parser stack overflow",
+		 &yyss1, size * sizeof (*yyssp),
+		 &yyvs1, size * sizeof (*yyvsp),
+		 &yyls1, size * sizeof (*yylsp),
+		 &yystacksize);
+#else
+      yyoverflow("parser stack overflow",
+		 &yyss1, size * sizeof (*yyssp),
+		 &yyvs1, size * sizeof (*yyvsp),
+		 &yystacksize);
+#endif
+
+      yyss = yyss1; yyvs = yyvs1;
+#ifdef YYLSP_NEEDED
+      yyls = yyls1;
+#endif
+#else /* no yyoverflow */
+      /* Extend the stack our own way.  */
+      if (yystacksize >= YYMAXDEPTH)
+	{
+	  yyerror("parser stack overflow");
+	  if (yyfree_stacks)
+	    {
+	      free (yyss);
+	      free (yyvs);
+#ifdef YYLSP_NEEDED
+	      free (yyls);
+#endif
+	    }
+	  return 2;
+	}
+      yystacksize *= 2;
+      if (yystacksize > YYMAXDEPTH)
+	yystacksize = YYMAXDEPTH;
+#ifndef YYSTACK_USE_ALLOCA
+      yyfree_stacks = 1;
+#endif
+      yyss = (short *) YYSTACK_ALLOC (yystacksize * sizeof (*yyssp));
+      __yy_memcpy ((char *)yyss, (char *)yyss1,
+		   size * (unsigned int) sizeof (*yyssp));
+      yyvs = (YYSTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yyvsp));
+      __yy_memcpy ((char *)yyvs, (char *)yyvs1,
+		   size * (unsigned int) sizeof (*yyvsp));
+#ifdef YYLSP_NEEDED
+      yyls = (YYLTYPE *) YYSTACK_ALLOC (yystacksize * sizeof (*yylsp));
+      __yy_memcpy ((char *)yyls, (char *)yyls1,
+		   size * (unsigned int) sizeof (*yylsp));
+#endif
+#endif /* no yyoverflow */
+
+      yyssp = yyss + size - 1;
+      yyvsp = yyvs + size - 1;
+#ifdef YYLSP_NEEDED
+      yylsp = yyls + size - 1;
+#endif
+
+#if YYDEBUG != 0
+      if (yydebug)
+	fprintf(stderr, "Stack size increased to %d\n", yystacksize);
+#endif
+
+      if (yyssp >= yyss + yystacksize - 1)
+	YYABORT;
+    }
+
+#if YYDEBUG != 0
+  if (yydebug)
+    fprintf(stderr, "Entering state %d\n", yystate);
+#endif
+
+  goto yybackup;
+ yybackup:
+
+/* Do appropriate processing given the current state.  */
+/* Read a lookahead token if we need one and don't already have one.  */
+/* yyresume: */
+
+  /* First try to decide what to do without reference to lookahead token.  */
+
+  yyn = yypact[yystate];
+  if (yyn == YYFLAG)
+    goto yydefault;
+
+  /* Not known => get a lookahead token if don't already have one.  */
+
+  /* yychar is either YYEMPTY or YYEOF
+     or a valid token in external form.  */
+
+  if (yychar == YYEMPTY)
+    {
+#if YYDEBUG != 0
+      if (yydebug)
+	fprintf(stderr, "Reading a token: ");
+#endif
+      yychar = YYLEX;
+    }
+
+  /* Convert token to internal form (in yychar1) for indexing tables with */
+
+  if (yychar <= 0)		/* This means end of input. */
+    {
+      yychar1 = 0;
+      yychar = YYEOF;		/* Don't call YYLEX any more */
+
+#if YYDEBUG != 0
+      if (yydebug)
+	fprintf(stderr, "Now at end of input.\n");
+#endif
+    }
+  else
+    {
+      yychar1 = YYTRANSLATE(yychar);
+
+#if YYDEBUG != 0
+      if (yydebug)
+	{
+	  fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
+	  /* Give the individual parser a way to print the precise meaning
+	     of a token, for further debugging info.  */
+#ifdef YYPRINT
+	  YYPRINT (stderr, yychar, yylval);
+#endif
+	  fprintf (stderr, ")\n");
+	}
+#endif
+    }
+
+  yyn += yychar1;
+  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != yychar1)
+    goto yydefault;
+
+  yyn = yytable[yyn];
+
+  /* yyn is what to do for this token type in this state.
+     Negative => reduce, -yyn is rule number.
+     Positive => shift, yyn is new state.
+       New state is final state => don't bother to shift,
+       just return success.
+     0, or most negative number => error.  */
+
+  if (yyn < 0)
+    {
+      if (yyn == YYFLAG)
+	goto yyerrlab;
+      yyn = -yyn;
+      goto yyreduce;
+    }
+  else if (yyn == 0)
+    goto yyerrlab;
+
+  if (yyn == YYFINAL)
+    YYACCEPT;
+
+  /* Shift the lookahead token.  */
+
+#if YYDEBUG != 0
+  if (yydebug)
+    fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
+#endif
+
+  /* Discard the token being shifted unless it is eof.  */
+  if (yychar != YYEOF)
+    yychar = YYEMPTY;
+
+  *++yyvsp = yylval;
+#ifdef YYLSP_NEEDED
+  *++yylsp = yylloc;
+#endif
+
+  /* count tokens shifted since error; after three, turn off error status.  */
+  if (yyerrstatus) yyerrstatus--;
+
+  yystate = yyn;
+  goto yynewstate;
+
+/* Do the default action for the current state.  */
+yydefault:
+
+  yyn = yydefact[yystate];
+  if (yyn == 0)
+    goto yyerrlab;
+
+/* Do a reduction.  yyn is the number of a rule to reduce with.  */
+yyreduce:
+  yylen = yyr2[yyn];
+  if (yylen > 0)
+    yyval = yyvsp[1-yylen]; /* implement default value of the action */
+
+#if YYDEBUG != 0
+  if (yydebug)
+    {
+      int i;
+
+      fprintf (stderr, "Reducing via rule %d (line %d), ",
+	       yyn, yyrline[yyn]);
+
+      /* Print the symbols being reduced, and their result.  */
+      for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
+	fprintf (stderr, "%s ", yytname[yyrhs[i]]);
+      fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
+    }
+#endif
+
+
+  switch (yyn) {
+
+case 5:
+#line 234 "parser.y"
+{
+        CSSParser *p = static_cast<CSSParser *>(parser);
+	p->rule = yyvsp[-2].rule;
+    ;
+    break;}
+case 6:
+#line 241 "parser.y"
+{
+	/* can be empty */
+    ;
+    break;}
+case 7:
+#line 247 "parser.y"
+{
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	if ( yyvsp[-1].valueList ) {
+	    p->valueList = yyvsp[-1].valueList;
+#ifdef CSS_DEBUG
+	    kdDebug( 6080 ) << "   got property for " << p->id <<
+		(p->important?" important":"")<< endl;
+	    bool ok =
+#endif
+		p->parseValue( p->id, p->important );
+#ifdef CSS_DEBUG
+	    if ( !ok )
+		kdDebug( 6080 ) << "     couldn't parse value!" << endl;
+#endif
+	}
+#ifdef CSS_DEBUG
+	else
+	    kdDebug( 6080 ) << "     no value found!" << endl;
+#endif
+	delete p->valueList;
+	p->valueList = 0;
+    ;
+    break;}
+case 14:
+#line 284 "parser.y"
+{
+#ifdef CSS_DEBUG
+     kdDebug( 6080 ) << "charset rule: " << qString(yyvsp[-2].string) << endl;
+#endif
+ ;
+    break;}
+case 18:
+#line 295 "parser.y"
+{
+     CSSParser *p = static_cast<CSSParser *>(parser);
+     if ( yyvsp[-1].rule && p->styleElement && p->styleElement->isCSSStyleSheet() ) {
+	 p->styleElement->append( yyvsp[-1].rule );
+     } else {
+	 delete yyvsp[-1].rule;
+     }
+ ;
+    break;}
+case 20:
+#line 308 "parser.y"
+{
+     CSSParser *p = static_cast<CSSParser *>(parser);
+     if ( yyvsp[-1].rule && p->styleElement && p->styleElement->isCSSStyleSheet() ) {
+	 p->styleElement->append( yyvsp[-1].rule );
+     } else {
+	 delete yyvsp[-1].rule;
+     }
+ ;
+    break;}
+case 27:
+#line 328 "parser.y"
+{
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "@import: " << qString(yyvsp[-3].string) << endl;
+#endif
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	if ( p->styleElement && p->styleElement->isCSSStyleSheet() )
+	    yyval.rule = new CSSImportRuleImpl( p->styleElement, domString(yyvsp[-3].string), yyvsp[-1].mediaList );
+	else
+	    yyval.rule = 0;
+    ;
+    break;}
+case 28:
+#line 338 "parser.y"
+{
+        yyval.rule = 0;
+    ;
+    break;}
+case 29:
+#line 341 "parser.y"
+{
+        yyval.rule = 0;
+    ;
+    break;}
+case 32:
+#line 352 "parser.y"
+{
+	yyval.mediaList = 0;
+    ;
+    break;}
+case 33:
+#line 355 "parser.y"
+{
+	yyval.mediaList = new MediaListImpl();
+	yyval.mediaList->appendMedium( domString(yyvsp[0].string) );
+    ;
+    break;}
+case 34:
+#line 359 "parser.y"
+{
+	yyval.mediaList = yyvsp[-3].mediaList;
+	if ( !yyval.mediaList ) yyval.mediaList = new MediaListImpl();
+	yyval.mediaList->appendMedium( domString(yyvsp[0].string) );
+    ;
+    break;}
+case 35:
+#line 367 "parser.y"
+{
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	if ( yyvsp[-4].mediaList && yyvsp[-1].ruleList &&
+	     p->styleElement && p->styleElement->isCSSStyleSheet() ) {
+	    yyval.rule = new CSSMediaRuleImpl( static_cast<CSSStyleSheetImpl*>(p->styleElement), yyvsp[-4].mediaList, yyvsp[-1].ruleList );
+	} else {
+	    yyval.rule = 0;
+	    delete yyvsp[-4].mediaList;
+	    delete yyvsp[-1].ruleList;
+	}
+    ;
+    break;}
+case 36:
+#line 381 "parser.y"
+{
+	yyval.mediaList = new MediaListImpl();
+	yyval.mediaList->appendMedium( domString(yyvsp[0].string) );
+    ;
+    break;}
+case 37:
+#line 385 "parser.y"
+{
+	yyval.mediaList = yyvsp[-3].mediaList;
+	yyval.mediaList->appendMedium( domString(yyvsp[0].string) );
+    ;
+    break;}
+case 38:
+#line 393 "parser.y"
+{ yyval.ruleList = 0; ;
+    break;}
+case 39:
+#line 394 "parser.y"
+{
+      yyval.ruleList = yyvsp[-2].ruleList;
+      if ( yyvsp[-1].rule ) {
+	  if ( !yyval.ruleList ) yyval.ruleList = new CSSRuleListImpl();
+	  yyval.ruleList->append( yyvsp[-1].rule );
+      }
+  ;
+    break;}
+case 40:
+#line 404 "parser.y"
+{
+      yyval.string = yyvsp[-1].string;
+  ;
+    break;}
+case 41:
+#line 426 "parser.y"
+{
+      yyval.rule = 0;
+    ;
+    break;}
+case 42:
+#line 429 "parser.y"
+{
+      yyval.rule = 0;
+    ;
+    break;}
+case 43:
+#line 435 "parser.y"
+{
+      yyval.rule = 0;
+    ;
+    break;}
+case 44:
+#line 438 "parser.y"
+{
+      yyval.rule = 0;
+    ;
+    break;}
+case 45:
+#line 444 "parser.y"
+{ yyval.relation = CSSSelector::Sibling; ;
+    break;}
+case 46:
+#line 445 "parser.y"
+{ yyval.relation = CSSSelector::Child; ;
+    break;}
+case 47:
+#line 446 "parser.y"
+{ yyval.relation = CSSSelector::Descendant; ;
+    break;}
+case 48:
+#line 450 "parser.y"
+{ yyval.val = -1; ;
+    break;}
+case 49:
+#line 451 "parser.y"
+{ yyval.val = 1; ;
+    break;}
+case 50:
+#line 455 "parser.y"
+{
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "got ruleset" << endl << "  selector:" << endl;
+#endif
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	if ( yyvsp[-4].selectorList && yyvsp[-1].ok && p->numParsedProperties ) {
+	    CSSStyleRuleImpl *rule = new CSSStyleRuleImpl( p->styleElement );
+	    CSSStyleDeclarationImpl *decl = p->createStyleDeclaration( rule );
+	    rule->setSelector( yyvsp[-4].selectorList );
+	    rule->setDeclaration(decl);
+	    yyval.rule = rule;
+	} else {
+	    yyval.rule = 0;
+	    delete yyvsp[-4].selectorList;
+	    p->clearProperties();
+	}
+    ;
+    break;}
+case 51:
+#line 475 "parser.y"
+{
+	if ( yyvsp[0].selector ) {
+	    yyval.selectorList = new QPtrList<CSSSelector>;
+            yyval.selectorList->setAutoDelete( true );
+#ifdef CSS_DEBUG
+	    kdDebug( 6080 ) << "   got simple selector:" << endl;
+	    yyvsp[0].selector->print();
+#endif
+	    yyval.selectorList->append( yyvsp[0].selector );
+	} else {
+	    yyval.selectorList = 0;
+	}
+    ;
+    break;}
+case 52:
+#line 488 "parser.y"
+{
+	yyval.selectorList = yyvsp[-3].selectorList;
+	if ( yyvsp[0].selector ) {
+	    if ( !yyval.selectorList ) {
+                yyval.selectorList = new QPtrList<CSSSelector>;
+                yyval.selectorList->setAutoDelete(true);
+            }
+	    yyval.selectorList->append( yyvsp[0].selector );
+#ifdef CSS_DEBUG
+	    kdDebug( 6080 ) << "   got simple selector:" << endl;
+	    yyvsp[0].selector->print();
+#endif
+	}
+    ;
+    break;}
+case 53:
+#line 505 "parser.y"
+{
+	yyval.selector = yyvsp[0].selector;
+    ;
+    break;}
+case 54:
+#line 508 "parser.y"
+{
+    	yyval.selector = yyvsp[0].selector;
+        CSSSelector *end = yyvsp[0].selector;
+        while( end->tagHistory )
+            end = end->tagHistory;
+	end->relation = yyvsp[-1].relation;
+	end->tagHistory = yyvsp[-2].selector;
+        if ( yyvsp[-1].relation == CSSSelector::Descendant ||
+             yyvsp[-1].relation == CSSSelector::Child ) {
+            CSSParser *p = static_cast<CSSParser *>(parser);
+DOM::DocumentImpl *doc = p->document();
+            if ( doc )
+                doc->setUsesDescendantRules(true);
+        }
+    ;
+    break;}
+case 55:
+#line 526 "parser.y"
+{
+	yyval.selector = new CSSSelector();
+	yyval.selector->tag = yyvsp[-1].element;
+    ;
+    break;}
+case 56:
+#line 530 "parser.y"
+{
+	yyval.selector = yyvsp[-1].selector;
+	yyval.selector->tag = yyvsp[-2].element;
+    ;
+    break;}
+case 57:
+#line 534 "parser.y"
+{
+	yyval.selector = yyvsp[-1].selector;
+	yyval.selector->tag = -1;
+    ;
+    break;}
+case 58:
+#line 541 "parser.y"
+{
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	DOM::DocumentImpl *doc = p->document();
+	QString tag = qString(yyvsp[0].string);
+	if ( doc ) {
+	    if (doc->isHTMLDocument())
+		tag = tag.lower();
+	    const DOMString dtag(tag);
+#if APPLE_CHANGES
+            yyval.element = doc->tagId(0, dtag.implementation(), false);
+#else
+	    yyval.element = doc->elementNames()->getId(dtag.implementation(), false);
+#endif
+	} else {
+	    yyval.element = khtml::getTagID(tag.lower().ascii(), tag.length());
+	    // this case should never happen - only when loading
+	    // the default stylesheet - which must not contain unknown tags
+// 	    assert($$ != 0);
+	}
+    ;
+    break;}
+case 59:
+#line 561 "parser.y"
+{
+	yyval.element = -1;
+    ;
+    break;}
+case 60:
+#line 567 "parser.y"
+{
+	yyval.selector = yyvsp[0].selector;
+	yyval.selector->nonCSSHint = static_cast<CSSParser *>(parser)->nonCSSHint;
+    ;
+    break;}
+case 61:
+#line 571 "parser.y"
+{
+	yyval.selector = yyvsp[-1].selector;
+        CSSSelector *end = yyvsp[-1].selector;
+        while( end->tagHistory )
+            end = end->tagHistory;
+        end->relation = CSSSelector::SubSelector;
+        end->tagHistory = yyvsp[0].selector;
+    ;
+    break;}
+case 62:
+#line 582 "parser.y"
+{
+	yyval.selector = new CSSSelector();
+	yyval.selector->match = CSSSelector::Id;
+	yyval.selector->attr = ATTR_ID;
+	yyval.selector->value = domString(yyvsp[0].string);
+    ;
+    break;}
+case 66:
+#line 594 "parser.y"
+{
+	yyval.selector = new CSSSelector();
+	yyval.selector->match = CSSSelector::List;
+	yyval.selector->attr = ATTR_CLASS;
+	yyval.selector->value = domString(yyvsp[0].string);
+    ;
+    break;}
+case 67:
+#line 603 "parser.y"
+{
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	DOM::DocumentImpl *doc = p->document();
+
+	QString attr = qString(yyvsp[-1].string);
+	if ( doc ) {
+	    if (doc->isHTMLDocument())
+		attr = attr.lower();
+	    const DOMString dattr(attr);
+#if APPLE_CHANGES
+            yyval.attribute = doc->attrId(0, dattr.implementation(), false);
+#else
+	    yyval.attribute = doc->attrNames()->getId(dattr.implementation(), false);
+#endif
+	} else {
+	    yyval.attribute = khtml::getAttrID(attr.lower().ascii(), attr.length());
+	    // this case should never happen - only when loading
+	    // the default stylesheet - which must not contain unknown attributes
+	    assert(yyval.attribute != 0);
+	    }
+    ;
+    break;}
+case 68:
+#line 627 "parser.y"
+{
+	yyval.selector = new CSSSelector();
+	yyval.selector->attr = yyvsp[-1].attribute;
+	yyval.selector->match = CSSSelector::Set;
+    ;
+    break;}
+case 69:
+#line 632 "parser.y"
+{
+	yyval.selector = new CSSSelector();
+	yyval.selector->attr = yyvsp[-5].attribute;
+	yyval.selector->match = (CSSSelector::Match)yyvsp[-4].val;
+	yyval.selector->value = domString(yyvsp[-2].string);
+    ;
+    break;}
+case 70:
+#line 641 "parser.y"
+{
+	yyval.val = CSSSelector::Exact;
+    ;
+    break;}
+case 71:
+#line 644 "parser.y"
+{
+	yyval.val = CSSSelector::List;
+    ;
+    break;}
+case 72:
+#line 647 "parser.y"
+{
+	yyval.val = CSSSelector::Hyphen;
+    ;
+    break;}
+case 73:
+#line 650 "parser.y"
+{
+	yyval.val = CSSSelector::Begin;
+    ;
+    break;}
+case 74:
+#line 653 "parser.y"
+{
+	yyval.val = CSSSelector::End;
+    ;
+    break;}
+case 75:
+#line 656 "parser.y"
+{
+	yyval.val = CSSSelector::Contain;
+    ;
+    break;}
+case 78:
+#line 667 "parser.y"
+{
+	yyval.selector = new CSSSelector();
+	yyval.selector->match = CSSSelector::Pseudo;
+	yyval.selector->value = domString(yyvsp[0].string);
+    ;
+    break;}
+case 79:
+#line 672 "parser.y"
+{
+	yyval.selector = new CSSSelector();
+	yyval.selector->match = CSSSelector::Pseudo;
+	yyval.selector->_pseudoType = CSSSelector::PseudoFunction;
+	yyval.selector->value = domString(yyvsp[-2].string);
+    ;
+    break;}
+case 80:
+#line 681 "parser.y"
+{
+	yyval.ok = yyvsp[0].ok;
+    ;
+    break;}
+case 81:
+#line 684 "parser.y"
+{
+	yyval.ok = yyvsp[-1].ok;
+	if ( yyvsp[0].ok )
+	    yyval.ok = yyvsp[0].ok;
+    ;
+    break;}
+case 82:
+#line 689 "parser.y"
+{
+	yyval.ok = yyvsp[0].ok;
+    ;
+    break;}
+case 83:
+#line 692 "parser.y"
+{
+	yyval.ok = false;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping bogus declaration" << endl;
+#endif
+    ;
+    break;}
+case 84:
+#line 698 "parser.y"
+{
+	yyval.ok = false;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping all declarations" << endl;
+#endif
+    ;
+    break;}
+case 85:
+#line 707 "parser.y"
+{
+	yyval.ok = yyvsp[-2].ok;
+    ;
+    break;}
+case 86:
+#line 710 "parser.y"
+{
+	yyval.ok = false;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping bogus declaration" << endl;
+#endif
+    ;
+    break;}
+case 87:
+#line 716 "parser.y"
+{
+	yyval.ok = false;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping bogus declaration" << endl;
+#endif
+    ;
+    break;}
+case 88:
+#line 722 "parser.y"
+{
+	yyval.ok = yyvsp[-3].ok;
+	if ( yyvsp[-2].ok )
+	    yyval.ok = yyvsp[-2].ok;
+    ;
+    break;}
+case 89:
+#line 727 "parser.y"
+{
+	yyval.ok = yyvsp[-3].ok;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping bogus declaration" << endl;
+#endif
+    ;
+    break;}
+case 90:
+#line 733 "parser.y"
+{
+	yyval.ok = yyvsp[-5].ok;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping bogus declaration" << endl;
+#endif
+    ;
+    break;}
+case 91:
+#line 742 "parser.y"
+{
+	yyval.ok = false;
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	if ( yyvsp[-4].prop_id && yyvsp[-1].valueList ) {
+	    p->valueList = yyvsp[-1].valueList;
+#ifdef CSS_DEBUG
+	    kdDebug( 6080 ) << "   got property: " << yyvsp[-4].prop_id <<
+		(yyvsp[0].b?" important":"")<< endl;
+#endif
+	    bool ok = p->parseValue( yyvsp[-4].prop_id, yyvsp[0].b );
+	    if ( ok )
+		yyval.ok = ok;
+#ifdef CSS_DEBUG
+	    else
+		kdDebug( 6080 ) << "     couldn't parse value!" << endl;
+#endif
+	}
+	delete p->valueList;
+	p->valueList = 0;
+    ;
+    break;}
+case 92:
+#line 765 "parser.y"
+{
+	QString str = qString(yyvsp[-1].string);
+	yyval.prop_id = getPropertyID( str.lower().latin1(), str.length() );
+    ;
+    break;}
+case 93:
+#line 772 "parser.y"
+{ yyval.b = true; ;
+    break;}
+case 94:
+#line 773 "parser.y"
+{ yyval.b = false; ;
+    break;}
+case 95:
+#line 777 "parser.y"
+{
+	yyval.valueList = new ValueList;
+	yyval.valueList->addValue( yyvsp[0].value );
+    ;
+    break;}
+case 96:
+#line 781 "parser.y"
+{
+	yyval.valueList = yyvsp[-2].valueList;
+	if ( yyvsp[-1].tok ) {
+	    Value v;
+	    v.id = 0;
+	    v.unit = Value::Operator;
+	    v.iValue = yyvsp[-1].tok;
+	    yyval.valueList->addValue( v );
+	}
+	yyval.valueList->addValue( yyvsp[0].value );
+    ;
+    break;}
+case 97:
+#line 795 "parser.y"
+{
+	yyval.tok = '/';
+    ;
+    break;}
+case 98:
+#line 798 "parser.y"
+{
+	yyval.tok = ',';
+    ;
+    break;}
+case 99:
+#line 801 "parser.y"
+{
+        yyval.tok = 0;
+  ;
+    break;}
+case 100:
+#line 807 "parser.y"
+{ yyval.value = yyvsp[0].value; ;
+    break;}
+case 101:
+#line 808 "parser.y"
+{ yyval.value = yyvsp[0].value; yyval.value.fValue *= yyvsp[-1].val; ;
+    break;}
+case 102:
+#line 809 "parser.y"
+{ yyval.value.id = 0; yyval.value.string = yyvsp[-1].string; yyval.value.unit = CSSPrimitiveValue::CSS_STRING; ;
+    break;}
+case 103:
+#line 810 "parser.y"
+{
+      QString str = qString( yyvsp[-1].string );
+      yyval.value.id = getValueID( str.lower().latin1(), str.length() );
+      yyval.value.unit = CSSPrimitiveValue::CSS_IDENT;
+      yyval.value.string = yyvsp[-1].string;
+  ;
+    break;}
+case 104:
+#line 816 "parser.y"
+{ yyval.value.id = 0; yyval.value.string = yyvsp[-1].string; yyval.value.unit = CSSPrimitiveValue::CSS_URI; ;
+    break;}
+case 105:
+#line 817 "parser.y"
+{ yyval.value.id = 0; yyval.value.iValue = 0; yyval.value.unit = CSSPrimitiveValue::CSS_UNKNOWN;/* ### */ ;
+    break;}
+case 106:
+#line 818 "parser.y"
+{ yyval.value.id = 0; yyval.value.string = yyvsp[0].string; yyval.value.unit = CSSPrimitiveValue::CSS_RGBCOLOR; ;
+    break;}
+case 107:
+#line 820 "parser.y"
+{
+      yyval.value = yyvsp[0].value;
+  ;
+    break;}
+case 108:
+#line 826 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_NUMBER; ;
+    break;}
+case 109:
+#line 827 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PERCENTAGE; ;
+    break;}
+case 110:
+#line 828 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PX; ;
+    break;}
+case 111:
+#line 829 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_CM; ;
+    break;}
+case 112:
+#line 830 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_MM; ;
+    break;}
+case 113:
+#line 831 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_IN; ;
+    break;}
+case 114:
+#line 832 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PT; ;
+    break;}
+case 115:
+#line 833 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_PC; ;
+    break;}
+case 116:
+#line 834 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_DEG; ;
+    break;}
+case 117:
+#line 835 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_RAD; ;
+    break;}
+case 118:
+#line 836 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_GRAD; ;
+    break;}
+case 119:
+#line 837 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_MS; ;
+    break;}
+case 120:
+#line 838 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_S; ;
+    break;}
+case 121:
+#line 839 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_HZ; ;
+    break;}
+case 122:
+#line 840 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_KHZ; ;
+    break;}
+case 123:
+#line 841 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_EMS; ;
+    break;}
+case 124:
+#line 842 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = Value::Q_EMS; ;
+    break;}
+case 125:
+#line 843 "parser.y"
+{ yyval.value.id = 0; yyval.value.fValue = yyvsp[-1].val; yyval.value.unit = CSSPrimitiveValue::CSS_EXS; ;
+    break;}
+case 126:
+#line 844 "parser.y"
+{ yyval.value.id = 0; yyval.value.string = yyvsp[-1].string; yyval.value.unit = CSSPrimitiveValue::CSS_DIMENSION ;
+    break;}
+case 127:
+#line 849 "parser.y"
+{
+      Function *f = new Function;
+      f->name = yyvsp[-4].string;
+      f->args = yyvsp[-2].valueList;
+      yyval.value.id = 0;
+      yyval.value.unit = Value::Function;
+      yyval.value.function = f;
+  ;
+    break;}
+case 128:
+#line 864 "parser.y"
+{ yyval.string = yyvsp[-1].string; ;
+    break;}
+case 129:
+#line 871 "parser.y"
+{
+	yyval.rule = 0;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipped invalid @-rule" << endl;
+#endif
+    ;
+    break;}
+case 130:
+#line 877 "parser.y"
+{
+	yyval.rule = 0;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipped invalid @-rule" << endl;
+#endif
+    ;
+    break;}
+case 131:
+#line 886 "parser.y"
+{
+	yyval.rule = 0;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipped invalid rule" << endl;
+#endif
+    ;
+    break;}
+}
+   /* the action file gets copied in in place of this dollarsign */
+#line 543 "/usr/share/bison.simple"
+
+  yyvsp -= yylen;
+  yyssp -= yylen;
+#ifdef YYLSP_NEEDED
+  yylsp -= yylen;
+#endif
+
+#if YYDEBUG != 0
+  if (yydebug)
+    {
+      short *ssp1 = yyss - 1;
+      fprintf (stderr, "state stack now");
+      while (ssp1 != yyssp)
+	fprintf (stderr, " %d", *++ssp1);
+      fprintf (stderr, "\n");
+    }
+#endif
+
+  *++yyvsp = yyval;
+
+#ifdef YYLSP_NEEDED
+  yylsp++;
+  if (yylen == 0)
+    {
+      yylsp->first_line = yylloc.first_line;
+      yylsp->first_column = yylloc.first_column;
+      yylsp->last_line = (yylsp-1)->last_line;
+      yylsp->last_column = (yylsp-1)->last_column;
+      yylsp->text = 0;
+    }
+  else
+    {
+      yylsp->last_line = (yylsp+yylen-1)->last_line;
+      yylsp->last_column = (yylsp+yylen-1)->last_column;
+    }
+#endif
+
+  /* Now "shift" the result of the reduction.
+     Determine what state that goes to,
+     based on the state we popped back to
+     and the rule number reduced by.  */
+
+  yyn = yyr1[yyn];
+
+  yystate = yypgoto[yyn - YYNTBASE] + *yyssp;
+  if (yystate >= 0 && yystate <= YYLAST && yycheck[yystate] == *yyssp)
+    yystate = yytable[yystate];
+  else
+    yystate = yydefgoto[yyn - YYNTBASE];
+
+  goto yynewstate;
+
+yyerrlab:   /* here on detecting error */
+
+  if (! yyerrstatus)
+    /* If not already recovering from an error, report this error.  */
+    {
+      ++yynerrs;
+
+#ifdef YYERROR_VERBOSE
+      yyn = yypact[yystate];
+
+      if (yyn > YYFLAG && yyn < YYLAST)
+	{
+	  int size = 0;
+	  char *msg;
+	  int x, count;
+
+	  count = 0;
+	  /* Start X at -yyn if nec to avoid negative indexes in yycheck.  */
+	  for (x = (yyn < 0 ? -yyn : 0);
+	       x < (sizeof(yytname) / sizeof(char *)); x++)
+	    if (yycheck[x + yyn] == x)
+	      size += strlen(yytname[x]) + 15, count++;
+	  msg = (char *) malloc(size + 15);
+	  if (msg != 0)
+	    {
+	      strcpy(msg, "parse error");
+
+	      if (count < 5)
+		{
+		  count = 0;
+		  for (x = (yyn < 0 ? -yyn : 0);
+		       x < (sizeof(yytname) / sizeof(char *)); x++)
+		    if (yycheck[x + yyn] == x)
+		      {
+			strcat(msg, count == 0 ? ", expecting `" : " or `");
+			strcat(msg, yytname[x]);
+			strcat(msg, "'");
+			count++;
+		      }
+		}
+	      yyerror(msg);
+	      free(msg);
+	    }
+	  else
+	    yyerror ("parse error; also virtual memory exceeded");
+	}
+      else
+#endif /* YYERROR_VERBOSE */
+	yyerror("parse error");
+    }
+
+  goto yyerrlab1;
+yyerrlab1:   /* here on error raised explicitly by an action */
+
+  if (yyerrstatus == 3)
+    {
+      /* if just tried and failed to reuse lookahead token after an error, discard it.  */
+
+      /* return failure if at end of input */
+      if (yychar == YYEOF)
+	YYABORT;
+
+#if YYDEBUG != 0
+      if (yydebug)
+	fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
+#endif
+
+      yychar = YYEMPTY;
+    }
+
+  /* Else will try to reuse lookahead token
+     after shifting the error token.  */
+
+  yyerrstatus = 3;		/* Each real token shifted decrements this */
+
+  goto yyerrhandle;
+
+yyerrdefault:  /* current state does not do anything special for the error token. */
+
+#if 0
+  /* This is wrong; only states that explicitly want error tokens
+     should shift them.  */
+  yyn = yydefact[yystate];  /* If its default is to accept any token, ok.  Otherwise pop it.*/
+  if (yyn) goto yydefault;
+#endif
+
+yyerrpop:   /* pop the current state because it cannot handle the error token */
+
+  if (yyssp == yyss) YYABORT;
+  yyvsp--;
+  yystate = *--yyssp;
+#ifdef YYLSP_NEEDED
+  yylsp--;
+#endif
+
+#if YYDEBUG != 0
+  if (yydebug)
+    {
+      short *ssp1 = yyss - 1;
+      fprintf (stderr, "Error: state stack now");
+      while (ssp1 != yyssp)
+	fprintf (stderr, " %d", *++ssp1);
+      fprintf (stderr, "\n");
+    }
+#endif
+
+yyerrhandle:
+
+  yyn = yypact[yystate];
+  if (yyn == YYFLAG)
+    goto yyerrdefault;
+
+  yyn += YYTERROR;
+  if (yyn < 0 || yyn > YYLAST || yycheck[yyn] != YYTERROR)
+    goto yyerrdefault;
+
+  yyn = yytable[yyn];
+  if (yyn < 0)
+    {
+      if (yyn == YYFLAG)
+	goto yyerrpop;
+      yyn = -yyn;
+      goto yyreduce;
+    }
+  else if (yyn == 0)
+    goto yyerrpop;
+
+  if (yyn == YYFINAL)
+    YYACCEPT;
+
+#if YYDEBUG != 0
+  if (yydebug)
+    fprintf(stderr, "Shifting error token, ");
+#endif
+
+  *++yyvsp = yylval;
+#ifdef YYLSP_NEEDED
+  *++yylsp = yylloc;
+#endif
+
+  yystate = yyn;
+  goto yynewstate;
+
+ yyacceptlab:
+  /* YYACCEPT comes here.  */
+  if (yyfree_stacks)
+    {
+      free (yyss);
+      free (yyvs);
+#ifdef YYLSP_NEEDED
+      free (yyls);
+#endif
+    }
+  return 0;
+
+ yyabortlab:
+  /* YYABORT comes here.  */
+  if (yyfree_stacks)
+    {
+      free (yyss);
+      free (yyvs);
+#ifdef YYLSP_NEEDED
+      free (yyls);
+#endif
+    }
+  return 1;
+}
+#line 921 "parser.y"
+
+
diff --git a/WebCore/khtml/css/parser.h b/WebCore/khtml/css/parser.h
new file mode 100644
index 0000000..5b0fd0c
--- /dev/null
+++ b/WebCore/khtml/css/parser.h
@@ -0,0 +1,61 @@
+typedef union {
+    CSSRuleImpl *rule;
+    CSSSelector *selector;
+    QPtrList<CSSSelector> *selectorList;
+    bool ok;
+    MediaListImpl *mediaList;
+    CSSMediaRuleImpl *mediaRule;
+    CSSRuleListImpl *ruleList;
+    ParseString string;
+    float val;
+    int prop_id;
+    int attribute;
+    int element;
+    CSSSelector::Relation relation;
+    bool b;
+    char tok;
+    Value value;
+    ValueList *valueList;
+} YYSTYPE;
+#define	S	257
+#define	SGML_CD	258
+#define	INCLUDES	259
+#define	DASHMATCH	260
+#define	BEGINSWITH	261
+#define	ENDSWITH	262
+#define	CONTAINS	263
+#define	STRING	264
+#define	IDENT	265
+#define	HASH	266
+#define	IMPORT_SYM	267
+#define	PAGE_SYM	268
+#define	MEDIA_SYM	269
+#define	FONT_FACE_SYM	270
+#define	CHARSET_SYM	271
+#define	KONQ_RULE_SYM	272
+#define	KONQ_DECLS_SYM	273
+#define	KONQ_VALUE_SYM	274
+#define	IMPORTANT_SYM	275
+#define	QEMS	276
+#define	EMS	277
+#define	EXS	278
+#define	PXS	279
+#define	CMS	280
+#define	MMS	281
+#define	INS	282
+#define	PTS	283
+#define	PCS	284
+#define	DEGS	285
+#define	RADS	286
+#define	GRADS	287
+#define	MSECS	288
+#define	SECS	289
+#define	HERZ	290
+#define	KHERZ	291
+#define	DIMEN	292
+#define	PERCENTAGE	293
+#define	NUMBER	294
+#define	URI	295
+#define	FUNCTION	296
+#define	UNICODERANGE	297
+
diff --git a/WebCore/khtml/css/parser.y b/WebCore/khtml/css/parser.y
new file mode 100644
index 0000000..be72e25
--- /dev/null
+++ b/WebCore/khtml/css/parser.y
@@ -0,0 +1,922 @@
+%{
+
+/*
+ *  This file is part of the KDE libraries
+ *  Copyright (C) 2002-2003 Lars Knoll (knoll at kde.org)
+ *  Copyright (c) 2003 Apple Computer
+ * 
+ *  This library is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2 of the License, or (at your option) any later version.
+ *
+ *  This library is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with this library; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ *
+ *  $Id$
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <string.h>
+#include <stdlib.h>
+
+#include <dom/dom_string.h>
+#include <xml/dom_docimpl.h>
+#include <css/css_ruleimpl.h>
+#include <css/css_stylesheetimpl.h>
+#include <css/css_valueimpl.h>
+#include <misc/htmlhashes.h>
+#include "cssparser.h"
+
+#include <assert.h>
+#include <kdebug.h>
+// #define CSS_DEBUG
+
+using namespace DOM;
+
+//
+// The following file defines the function
+//     const struct props *findProp(const char *word, int len)
+//
+// with 'props->id' a CSS property in the range from CSS_PROP_MIN to
+// (and including) CSS_PROP_TOTAL-1
+#include "cssproperties.c"
+#include "cssvalues.c"
+
+int DOM::getPropertyID(const char *tagStr, int len)
+{
+    const struct props *propsPtr = findProp(tagStr, len);
+    if (!propsPtr)
+        return 0;
+
+    return propsPtr->id;
+}
+
+static inline int getValueID(const char *tagStr, int len)
+{
+    const struct css_value *val = findValue(tagStr, len);
+    if (!val)
+        return 0;
+
+    return val->id;
+}
+
+
+#define YYDEBUG 0
+#define YYMAXDEPTH 0
+#define YYPARSE_PARAM parser
+%}
+
+%pure_parser
+
+%union {
+    CSSRuleImpl *rule;
+    CSSSelector *selector;
+    QPtrList<CSSSelector> *selectorList;
+    bool ok;
+    MediaListImpl *mediaList;
+    CSSMediaRuleImpl *mediaRule;
+    CSSRuleListImpl *ruleList;
+    ParseString string;
+    float val;
+    int prop_id;
+    int attribute;
+    int element;
+    CSSSelector::Relation relation;
+    bool b;
+    char tok;
+    Value value;
+    ValueList *valueList;
+}
+
+%{
+
+static inline int cssyyerror(const char *x ) {
+#ifdef CSS_DEBUG
+    qDebug( x );
+#else
+    Q_UNUSED( x );
+#endif
+    return 1;
+}
+
+static int cssyylex( YYSTYPE *yylval ) {
+    return CSSParser::current()->lex( yylval );
+}
+
+
+%}
+
+%expect 12
+
+%token S SGML_CD
+
+%token INCLUDES
+%token DASHMATCH
+%token BEGINSWITH
+%token ENDSWITH
+%token CONTAINS
+
+%token <string> STRING
+
+%token <string> IDENT
+
+%token <string> HASH
+%token ':'
+%token '.'
+%token '['
+
+%token IMPORT_SYM
+%token PAGE_SYM
+%token MEDIA_SYM
+%token FONT_FACE_SYM
+%token CHARSET_SYM
+%token KONQ_RULE_SYM
+%token KONQ_DECLS_SYM
+%token KONQ_VALUE_SYM
+
+%token IMPORTANT_SYM
+
+%token <val> QEMS
+%token <val> EMS
+%token <val> EXS
+%token <val> PXS
+%token <val> CMS
+%token <val> MMS
+%token <val> INS
+%token <val> PTS
+%token <val> PCS
+%token <val> DEGS
+%token <val> RADS
+%token <val> GRADS
+%token <val> MSECS
+%token <val> SECS
+%token <val> HERZ
+%token <val> KHERZ
+%token <string> DIMEN
+%token <val> PERCENTAGE
+%token <val> NUMBER
+
+%token <string> URI
+%token <string> FUNCTION
+
+%token <string> UNICODERANGE
+
+%type <relation> combinator
+
+%type <rule> ruleset
+%type <rule> media
+%type <rule> import
+%type <rule> page
+%type <rule> font_face
+%type <rule> invalid_rule
+%type <rule> invalid_at
+%type <rule> rule
+
+%type <string> string_or_uri
+%type <string> ident_or_string
+%type <string> medium
+%type <string> hexcolor
+
+%type <mediaList> media_list
+%type <mediaList> media_list2
+
+%type <ruleList> ruleset_list
+
+%type <prop_id> property
+
+%type <selector> specifier
+%type <selector> specifier_list
+%type <selector> simple_selector
+%type <selector> selector
+%type <selectorList> selector_list
+%type <selector> class
+%type <selector> attrib
+%type <selector> pseudo
+
+%type <ok> declaration_list
+%type <ok> decl_list
+%type <ok> declaration
+
+%type <b> prio
+
+%type <val> match
+%type <val> unary_operator
+%type <tok> operator
+
+%type <valueList> expr
+%type <value> term
+%type <value> unary_term
+%type <value> function
+
+%type <element> element_name
+
+%type <attribute> attrib_id
+
+%%
+
+stylesheet:
+    maybe_charset maybe_sgml import_list rule_list
+  | konq_rule maybe_space
+  | konq_decls maybe_space
+  | konq_value maybe_space
+  ;
+
+konq_rule:
+    KONQ_RULE_SYM '{' maybe_space ruleset maybe_space '}' {
+        CSSParser *p = static_cast<CSSParser *>(parser);
+	p->rule = $4;
+    }
+;
+
+konq_decls:
+    KONQ_DECLS_SYM '{' maybe_space declaration_list '}' {
+	/* can be empty */
+    }
+;
+
+konq_value:
+    KONQ_VALUE_SYM '{' maybe_space expr '}' {
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	if ( $4 ) {
+	    p->valueList = $4;
+#ifdef CSS_DEBUG
+	    kdDebug( 6080 ) << "   got property for " << p->id <<
+		(p->important?" important":"")<< endl;
+	    bool ok =
+#endif
+		p->parseValue( p->id, p->important );
+#ifdef CSS_DEBUG
+	    if ( !ok )
+		kdDebug( 6080 ) << "     couldn't parse value!" << endl;
+#endif
+	}
+#ifdef CSS_DEBUG
+	else
+	    kdDebug( 6080 ) << "     no value found!" << endl;
+#endif
+	delete p->valueList;
+	p->valueList = 0;
+    }
+;
+
+maybe_space:
+    /* empty */
+  | maybe_space S
+  ;
+
+maybe_sgml:
+    /* empty */
+  | maybe_sgml SGML_CD
+  | maybe_sgml S
+  ;
+
+maybe_charset:
+   /* empty */
+ | CHARSET_SYM maybe_space STRING maybe_space ';' {
+#ifdef CSS_DEBUG
+     kdDebug( 6080 ) << "charset rule: " << qString($3) << endl;
+#endif
+ }
+  | CHARSET_SYM error invalid_block
+  | CHARSET_SYM error ';'
+ ;
+
+import_list:
+ /* empty */
+ | import_list import maybe_sgml {
+     CSSParser *p = static_cast<CSSParser *>(parser);
+     if ( $2 && p->styleElement && p->styleElement->isCSSStyleSheet() ) {
+	 p->styleElement->append( $2 );
+     } else {
+	 delete $2;
+     }
+ }
+ ;
+
+
+rule_list:
+   /* empty */
+ | rule_list rule maybe_sgml {
+     CSSParser *p = static_cast<CSSParser *>(parser);
+     if ( $2 && p->styleElement && p->styleElement->isCSSStyleSheet() ) {
+	 p->styleElement->append( $2 );
+     } else {
+	 delete $2;
+     }
+ }
+    ;
+
+rule:
+    ruleset
+  | media
+  | page
+  | font_face
+  | invalid_rule
+  | invalid_at
+    ;
+
+import:
+    IMPORT_SYM maybe_space string_or_uri maybe_space media_list ';' {
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "@import: " << qString($3) << endl;
+#endif
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	if ( p->styleElement && p->styleElement->isCSSStyleSheet() )
+	    $$ = new CSSImportRuleImpl( p->styleElement, domString($3), $5 );
+	else
+	    $$ = 0;
+    }
+  | IMPORT_SYM error invalid_block {
+        $$ = 0;
+    }
+  | IMPORT_SYM error ';' {
+        $$ = 0;
+    }
+  ;
+
+string_or_uri:
+    STRING
+  | URI
+    ;
+
+media_list:
+    /* empty */ {
+	$$ = 0;
+    }
+    | medium {
+	$$ = new MediaListImpl();
+	$$->appendMedium( domString($1) );
+    }
+    | media_list ',' maybe_space medium {
+	$$ = $1;
+	if ( !$$ ) $$ = new MediaListImpl();
+	$$->appendMedium( domString($4) );
+    }
+;
+
+media:
+    MEDIA_SYM maybe_space media_list2 '{' maybe_space ruleset_list '}' {
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	if ( $3 && $6 &&
+	     p->styleElement && p->styleElement->isCSSStyleSheet() ) {
+	    $$ = new CSSMediaRuleImpl( static_cast<CSSStyleSheetImpl*>(p->styleElement), $3, $6 );
+	} else {
+	    $$ = 0;
+	    delete $3;
+	    delete $6;
+	}
+    }
+  ;
+
+media_list2:
+    medium {
+	$$ = new MediaListImpl();
+	$$->appendMedium( domString($1) );
+    }
+    | media_list ',' maybe_space medium {
+	$$ = $1;
+	$$->appendMedium( domString($4) );
+    }
+    ;
+
+
+ruleset_list:
+    /* empty */ { $$ = 0; }
+  | ruleset_list ruleset maybe_space {
+      $$ = $1;
+      if ( $2 ) {
+	  if ( !$$ ) $$ = new CSSRuleListImpl();
+	  $$->append( $2 );
+      }
+  }
+    ;
+
+medium:
+  IDENT maybe_space {
+      $$ = $1;
+  }
+  ;
+
+/*
+page:
+    PAGE_SYM maybe_space IDENT? pseudo_page? maybe_space
+    '{' maybe_space declaration [ ';' maybe_space declaration ]* '}' maybe_space
+  ;
+
+pseudo_page
+  : ':' IDENT
+  ;
+
+font_face
+  : FONT_FACE_SYM maybe_space
+    '{' maybe_space declaration [ ';' maybe_space declaration ]* '}' maybe_space
+  ;
+*/
+
+page:
+    PAGE_SYM error invalid_block {
+      $$ = 0;
+    }
+  | PAGE_SYM error ';' {
+      $$ = 0;
+    }
+    ;
+
+font_face:
+    FONT_FACE_SYM error invalid_block {
+      $$ = 0;
+    }
+  | FONT_FACE_SYM error ';' {
+      $$ = 0;
+    }
+;
+
+combinator:
+  '+' maybe_space { $$ = CSSSelector::Sibling; }
+  | '>' maybe_space { $$ = CSSSelector::Child; }
+  | /* empty */ { $$ = CSSSelector::Descendant; }
+  ;
+
+unary_operator:
+    '-' { $$ = -1; }
+  | '+' { $$ = 1; }
+  ;
+
+ruleset:
+    selector_list '{' maybe_space declaration_list '}' {
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "got ruleset" << endl << "  selector:" << endl;
+#endif
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	if ( $1 && $4 && p->numParsedProperties ) {
+	    CSSStyleRuleImpl *rule = new CSSStyleRuleImpl( p->styleElement );
+	    CSSStyleDeclarationImpl *decl = p->createStyleDeclaration( rule );
+	    rule->setSelector( $1 );
+	    rule->setDeclaration(decl);
+	    $$ = rule;
+	} else {
+	    $$ = 0;
+	    delete $1;
+	    p->clearProperties();
+	}
+    }
+  ;
+
+selector_list:
+    selector {
+	if ( $1 ) {
+	    $$ = new QPtrList<CSSSelector>;
+            $$->setAutoDelete( true );
+#ifdef CSS_DEBUG
+	    kdDebug( 6080 ) << "   got simple selector:" << endl;
+	    $1->print();
+#endif
+	    $$->append( $1 );
+	} else {
+	    $$ = 0;
+	}
+    }
+    | selector_list ',' maybe_space selector {
+	$$ = $1;
+	if ( $4 ) {
+	    if ( !$$ ) {
+                $$ = new QPtrList<CSSSelector>;
+                $$->setAutoDelete(true);
+            }
+	    $$->append( $4 );
+#ifdef CSS_DEBUG
+	    kdDebug( 6080 ) << "   got simple selector:" << endl;
+	    $4->print();
+#endif
+	}
+    }
+   ;
+
+selector:
+    simple_selector {
+	$$ = $1;
+    }
+    | selector combinator simple_selector {
+    	$$ = $3;
+        CSSSelector *end = $3;
+        while( end->tagHistory )
+            end = end->tagHistory;
+	end->relation = $2;
+	end->tagHistory = $1;
+        if ( $2 == CSSSelector::Descendant ||
+             $2 == CSSSelector::Child ) {
+            CSSParser *p = static_cast<CSSParser *>(parser);
+DOM::DocumentImpl *doc = p->document();
+            if ( doc )
+                doc->setUsesDescendantRules(true);
+        }
+    }
+    ;
+
+simple_selector:
+    element_name maybe_space {
+	$$ = new CSSSelector();
+	$$->tag = $1;
+    }
+    | element_name specifier_list maybe_space {
+	$$ = $2;
+	$$->tag = $1;
+    }
+    | specifier_list maybe_space {
+	$$ = $1;
+	$$->tag = -1;
+    }
+  ;
+
+element_name:
+    IDENT {
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	DOM::DocumentImpl *doc = p->document();
+	QString tag = qString($1);
+	if ( doc ) {
+	    if (doc->isHTMLDocument())
+		tag = tag.lower();
+	    const DOMString dtag(tag);
+#if APPLE_CHANGES
+            $$ = doc->tagId(0, dtag.implementation(), false);
+#else
+	    $$ = doc->elementNames()->getId(dtag.implementation(), false);
+#endif
+	} else {
+	    $$ = khtml::getTagID(tag.lower().ascii(), tag.length());
+	    // this case should never happen - only when loading
+	    // the default stylesheet - which must not contain unknown tags
+// 	    assert($$ != 0);
+	}
+    }
+    | '*' {
+	$$ = -1;
+    }
+  ;
+
+specifier_list:
+    specifier {
+	$$ = $1;
+	$$->nonCSSHint = static_cast<CSSParser *>(parser)->nonCSSHint;
+    }
+    | specifier_list specifier {
+	$$ = $1;
+        CSSSelector *end = $1;
+        while( end->tagHistory )
+            end = end->tagHistory;
+        end->relation = CSSSelector::SubSelector;
+        end->tagHistory = $2;
+    }
+;
+
+specifier:
+    HASH {
+	$$ = new CSSSelector();
+	$$->match = CSSSelector::Id;
+	$$->attr = ATTR_ID;
+	$$->value = domString($1);
+    }
+  | class
+  | attrib
+  | pseudo
+    ;
+
+class:
+    '.' IDENT {
+	$$ = new CSSSelector();
+	$$->match = CSSSelector::List;
+	$$->attr = ATTR_CLASS;
+	$$->value = domString($2);
+    }
+  ;
+
+attrib_id:
+    IDENT maybe_space {
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	DOM::DocumentImpl *doc = p->document();
+
+	QString attr = qString($1);
+	if ( doc ) {
+	    if (doc->isHTMLDocument())
+		attr = attr.lower();
+	    const DOMString dattr(attr);
+#if APPLE_CHANGES
+            $$ = doc->attrId(0, dattr.implementation(), false);
+#else
+	    $$ = doc->attrNames()->getId(dattr.implementation(), false);
+#endif
+	} else {
+	    $$ = khtml::getAttrID(attr.lower().ascii(), attr.length());
+	    // this case should never happen - only when loading
+	    // the default stylesheet - which must not contain unknown attributes
+	    assert($$ != 0);
+	    }
+    }
+    ;
+
+attrib:
+    '[' maybe_space attrib_id ']' {
+	$$ = new CSSSelector();
+	$$->attr = $3;
+	$$->match = CSSSelector::Set;
+    }
+    | '[' maybe_space attrib_id match maybe_space ident_or_string maybe_space ']' {
+	$$ = new CSSSelector();
+	$$->attr = $3;
+	$$->match = (CSSSelector::Match)$4;
+	$$->value = domString($6);
+    }
+  ;
+
+match:
+    '=' {
+	$$ = CSSSelector::Exact;
+    }
+    | INCLUDES {
+	$$ = CSSSelector::List;
+    }
+    | DASHMATCH {
+	$$ = CSSSelector::Hyphen;
+    }
+    | BEGINSWITH {
+	$$ = CSSSelector::Begin;
+    }
+    | ENDSWITH {
+	$$ = CSSSelector::End;
+    }
+    | CONTAINS {
+	$$ = CSSSelector::Contain;
+    }
+    ;
+
+ident_or_string:
+    IDENT
+  | STRING
+    ;
+
+pseudo:
+    ':' IDENT {
+	$$ = new CSSSelector();
+	$$->match = CSSSelector::Pseudo;
+	$$->value = domString($2);
+    }
+    | ':' FUNCTION maybe_space IDENT maybe_space ')' {
+	$$ = new CSSSelector();
+	$$->match = CSSSelector::Pseudo;
+	$$->_pseudoType = CSSSelector::PseudoFunction;
+	$$->value = domString($4);
+    }
+  ;
+
+declaration_list:
+    declaration {
+	$$ = $1;
+    }
+    | decl_list declaration {
+	$$ = $1;
+	if ( $2 )
+	    $$ = $2;
+    }
+    | decl_list {
+	$$ = $1;
+    }
+    | error invalid_block_list error {
+	$$ = false;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping bogus declaration" << endl;
+#endif
+    }
+    | error {
+	$$ = false;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping all declarations" << endl;
+#endif
+    }
+    ;
+
+decl_list:
+    declaration ';' maybe_space {
+	$$ = $1;
+    }
+    | error ';' maybe_space {
+	$$ = false;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping bogus declaration" << endl;
+#endif
+    }
+    | error invalid_block_list error ';' maybe_space {
+	$$ = false;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping bogus declaration" << endl;
+#endif
+    }
+    | decl_list declaration ';' maybe_space {
+	$$ = $1;
+	if ( $2 )
+	    $$ = $2;
+    }
+    | decl_list error ';' maybe_space {
+	$$ = $1;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping bogus declaration" << endl;
+#endif
+    }
+    | decl_list error invalid_block_list error ';' maybe_space {
+	$$ = $1;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipping bogus declaration" << endl;
+#endif
+    }
+    ;
+
+declaration:
+    property ':' maybe_space expr prio {
+	$$ = false;
+	CSSParser *p = static_cast<CSSParser *>(parser);
+	if ( $1 && $4 ) {
+	    p->valueList = $4;
+#ifdef CSS_DEBUG
+	    kdDebug( 6080 ) << "   got property: " << $1 <<
+		($5?" important":"")<< endl;
+#endif
+	    bool ok = p->parseValue( $1, $5 );
+	    if ( ok )
+		$$ = ok;
+#ifdef CSS_DEBUG
+	    else
+		kdDebug( 6080 ) << "     couldn't parse value!" << endl;
+#endif
+	}
+	delete p->valueList;
+	p->valueList = 0;
+    }
+  ;
+
+property:
+    IDENT maybe_space {
+	QString str = qString($1);
+	$$ = getPropertyID( str.lower().latin1(), str.length() );
+    }
+  ;
+
+prio:
+    IMPORTANT_SYM maybe_space { $$ = true; }
+    | /* empty */ { $$ = false; }
+  ;
+
+expr:
+    term {
+	$$ = new ValueList;
+	$$->addValue( $1 );
+    }
+    | expr operator term {
+	$$ = $1;
+	if ( $2 ) {
+	    Value v;
+	    v.id = 0;
+	    v.unit = Value::Operator;
+	    v.iValue = $2;
+	    $$->addValue( v );
+	}
+	$$->addValue( $3 );
+    }
+  ;
+
+operator:
+    '/' maybe_space {
+	$$ = '/';
+    }
+  | ',' maybe_space {
+	$$ = ',';
+    }
+  | /* empty */ {
+        $$ = 0;
+  }
+  ;
+
+term:
+  unary_term { $$ = $1; }
+   | unary_operator unary_term { $$ = $2; $$.fValue *= $1; }
+  | STRING maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_STRING; }
+  | IDENT maybe_space {
+      QString str = qString( $1 );
+      $$.id = getValueID( str.lower().latin1(), str.length() );
+      $$.unit = CSSPrimitiveValue::CSS_IDENT;
+      $$.string = $1;
+  }
+  | URI maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_URI; }
+  | UNICODERANGE maybe_space { $$.id = 0; $$.iValue = 0; $$.unit = CSSPrimitiveValue::CSS_UNKNOWN;/* ### */ }
+  | hexcolor { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_RGBCOLOR; }
+/* ### according to the specs a function can have a unary_operator in front. I know no case where this makes sense */
+  | function {
+      $$ = $1;
+  }
+  ;
+
+unary_term:
+  NUMBER maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_NUMBER; }
+  | PERCENTAGE maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_PERCENTAGE; }
+  | PXS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_PX; }
+  | CMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_CM; }
+  | MMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_MM; }
+  | INS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_IN; }
+  | PTS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_PT; }
+  | PCS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_PC; }
+  | DEGS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_DEG; }
+  | RADS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_RAD; }
+  | GRADS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_GRAD; }
+  | MSECS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_MS; }
+  | SECS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_S; }
+  | HERZ maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_HZ; }
+  | KHERZ maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_KHZ; }
+  | EMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_EMS; }
+  | QEMS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = Value::Q_EMS; }
+  | EXS maybe_space { $$.id = 0; $$.fValue = $1; $$.unit = CSSPrimitiveValue::CSS_EXS; }
+  | DIMEN maybe_space { $$.id = 0; $$.string = $1; $$.unit = CSSPrimitiveValue::CSS_DIMENSION }
+    ;
+
+
+function:
+  FUNCTION maybe_space expr ')' maybe_space {
+      Function *f = new Function;
+      f->name = $1;
+      f->args = $3;
+      $$.id = 0;
+      $$.unit = Value::Function;
+      $$.function = f;
+  }
+  ;
+/*
+ * There is a constraint on the color that it must
+ * have either 3 or 6 hex-digits (i.e., [0-9a-fA-F])
+ * after the "#"; e.g., "#000" is OK, but "#abcd" is not.
+ */
+hexcolor:
+  HASH maybe_space { $$ = $1; }
+  ;
+
+
+/* error handling rules */
+
+invalid_at:
+    '@' error invalid_block {
+	$$ = 0;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipped invalid @-rule" << endl;
+#endif
+    }
+  | '@' error ';' {
+	$$ = 0;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipped invalid @-rule" << endl;
+#endif
+    }
+    ;
+
+invalid_rule:
+    error invalid_block {
+	$$ = 0;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipped invalid rule" << endl;
+#endif
+    }
+/*
+  Seems like the two rules below are trying too much and violating
+  http://www.hixie.ch/tests/evil/mixed/csserrorhandling.html
+
+  | error ';' {
+	$$ = 0;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipped invalid rule" << endl;
+#endif
+    }
+  | error '}' {
+	$$ = 0;
+#ifdef CSS_DEBUG
+	kdDebug( 6080 ) << "skipped invalid rule" << endl;
+#endif
+    }
+*/
+    ;
+
+invalid_block:
+    '{' error invalid_block_list error '}'
+  | '{' error '}'
+    ;
+
+invalid_block_list:
+    invalid_block
+  | invalid_block_list error invalid_block
+;
+
+%%
+
diff --git a/WebCore/khtml/css/quirks.css b/WebCore/khtml/css/quirks.css
new file mode 100644
index 0000000..267eac4
--- /dev/null
+++ b/WebCore/khtml/css/quirks.css
@@ -0,0 +1,23 @@
+/* 
+ * This style sheet is used by khtml to render HTML pages in quirks mode
+ * (C) 2000-2003 Lars Knoll (knoll at kde.org)
+ *
+ * Konqueror/khtml relies on the existance of this style sheet for
+ * rendering. Do not remove or modify this file unless you know
+ * what you are doing.
+ */
+
+/* Give floated images margins of 3px */
+img[align="left"] {
+    margin-right: 3px;
+}
+    
+img[align="right"] {
+    margin-left: 3px;
+}
+
+/* Make lists flow around floats. */
+UL, OL, MENU, DIR {
+    \2d konq-flow-mode: \2d konq-around-floats;
+}
+    
\ No newline at end of file
diff --git a/WebCore/khtml/css/tokenizer.cpp b/WebCore/khtml/css/tokenizer.cpp
new file mode 100644
index 0000000..773f48f
--- /dev/null
+++ b/WebCore/khtml/css/tokenizer.cpp
@@ -0,0 +1,880 @@
+/*
+ * This file is part of the DOM implementation for KDE.
+ *
+ * Copyright (C) 2003 Lars Knoll (knoll at kde.org)
+ *
+ * $Id$
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public License
+ * along with this library; see the file COPYING.LIB.  If not, write to
+ * the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+ * Boston, MA 02111-1307, USA.
+ */
+
+/* This file is mostly data generated by flex. Unfortunately flex
+   can't handle 16bit strings directly, so we just copy the part of
+   the code we need and modify it to our needs.
+
+   Most of the defines below are to make sure we can easily use the
+   flex generated code, using as little editing as possible.
+
+   The flex syntax to generate the lexer are more or less directly
+   copied from the CSS2.1 specs, with some fixes for comments and
+   the important symbol.
+
+   To regenerate, run flex on tokenizer.flex. After this, copy the
+   data tables and the YY_DECL method over to this file. Remove the
+   init code from YY_DECL and change the YY_END_OF_BUFFER to only call
+   yyterminate().
+
+*/
+
+// --------- begin generated code -------------------
+
+#define YY_NUM_RULES 47
+#define YY_END_OF_BUFFER 48
+static yyconst short int yy_accept[304] =
+    {   0,
+        0,    0,   48,   46,    2,    2,   46,   46,   46,   46,
+       46,   46,   46,   46,   46,   40,   46,   46,   46,   46,
+       11,   11,   46,   46,    2,    0,    0,    0,   10,    0,
+       12,    0,    8,    0,    0,    9,    0,   40,    0,   39,
+        0,   40,    0,   38,   38,   38,   38,   38,   38,   38,
+       38,   38,   38,   38,   38,   35,    0,    0,    0,    0,
+        0,    0,    0,   11,   11,    7,   43,   11,    0,    0,
+       11,    6,    5,    0,    0,    0,   10,    0,    0,   12,
+       12,    0,    0,   10,    0,    0,    4,    0,    0,   38,
+       38,   38,    0,   38,   26,   38,   22,   24,   38,   36,
+
+       28,   38,   27,   34,   30,   29,   25,   38,    0,    0,
+        0,    0,    0,    0,    0,   11,   11,   11,   44,   44,
+       11,    0,    0,    0,   12,    0,    0,    0,    1,   38,
+       38,   38,   38,   31,   38,   37,   32,    3,    0,    0,
+        0,    0,    0,    0,   11,   11,    0,   44,   44,   44,
+       43,    0,    0,   12,    0,    0,    0,   38,   38,   38,
+       33,    0,    0,    0,    0,    0,   14,   11,   11,   45,
+       44,   44,   44,   44,    0,    0,    0,    0,   42,    0,
+        0,    0,   12,    0,   38,   38,   23,    0,    0,    0,
+        0,   15,   11,   11,   45,   44,   44,   44,   44,   44,
+
+        0,    0,    0,    0,    0,    0,    0,    0,    0,   42,
+        0,    0,    0,    0,   12,    0,   38,   38,    0,    0,
+        0,   13,   11,   11,   45,   44,   44,   44,   44,   44,
+       44,    0,   41,    0,    0,    0,    0,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,   12,    0,   38,   38,
+        0,    0,    0,   17,    0,   11,   45,   44,   44,   44,
+       44,   44,   44,   44,    0,   41,    0,    0,    0,   41,
+        0,    0,    0,    0,   38,    0,    0,    0,    0,   45,
+        0,    0,    0,   21,    0,    0,    0,   16,   45,    0,
+        0,    0,    0,   18,    0,    0,    0,    0,   19,   20,
+
+        0,    0,    0
+    } ;
+
+static yyconst int yy_ec[256] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    2,    3,
+        1,    4,    5,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    6,    7,    8,    9,   10,   11,   12,   13,   14,
+       15,   16,   17,   12,   18,   19,   20,   21,   21,   21,
+       21,   21,   21,   21,   21,   21,   21,   12,   12,   22,
+       23,   24,   25,   26,   30,   31,   32,   33,   34,   35,
+       36,   37,   38,   39,   40,   41,   42,   43,   44,   45,
+       46,   47,   48,   49,   50,   51,   39,   52,   39,   53,
+       12,   27,   12,   28,   29,   12,   30,   31,   32,   33,
+
+       34,   35,   36,   37,   38,   39,   40,   41,   42,   43,
+       44,   45,   46,   47,   48,   49,   50,   51,   39,   52,
+       39,   53,   12,   54,   12,   55,    1,   56,   56,   56,
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       56,   56,   56,   56,   56,   56,   56,   56,   56,   56,
+       56,   56,   56,   56,   56
+    } ;
+
+static yyconst int yy_meta[57] =
+    {   0,
+        1,    2,    3,    3,    3,    4,    4,    4,    4,    4,
+        4,    4,    4,    5,    4,    4,    4,    6,    4,    4,
+        6,    4,    4,    4,    7,    4,    8,    4,    8,    6,
+        6,    6,    6,    6,    6,    8,    8,    8,    8,    8,
+        8,    8,    8,    8,    8,    8,    8,    8,    8,    8,
+        8,    8,    8,    4,    4,    8
+    } ;
+
+static yyconst short int yy_base[330] =
+    {   0,
+        0,    0,  723, 1578,   55,   60,   65,   64,  694,  697,
+       60,  696,  700,  683,  687,   93,  695,   57,   75,  678,
+       63,   66,  677,  676,  113,  148,  656,   70, 1578,  185,
+      670,  126, 1578,   61,  219, 1578,  659,   60,  666, 1578,
+      658,    0,  134,   55,  651,   58,   67,  121,  135,  143,
+      148,   49,  150,  151,  144,  650,  658,  622,  624,  597,
+      598,  603,  606,   84,  253, 1578, 1578,  158,  204,  268,
+      167, 1578, 1578,  590,  199,  168,  172,  302,  336,  607,
+      370,  201,  184,  200,  404,  438, 1578,  609,  185,  596,
+      472,  595,  321,  183,  594,  206,  593,  579,  214,  578,
+
+      564,  216,  555,  554,  553,  552,  551,  233,  559,  532,
+      544,  530,  527,  538,  534,  423,  234,  506,  245,  544,
+      248,  513,  237,  498,  513,  252,  521,  534, 1578,  528,
+      508,  562,  244,  499,  249,  498,  497, 1578,  480,  475,
+      472,  476,  480,  483,  554,  569,  577,  272,  491,  490,
+      611,  467,  597,  612,  618,  484,  252,  633,  639,  250,
+      471,  451,  448,  477,  440,  456, 1578,  654,  660,  675,
+      291,  459,  458,  457,  709,  735,  286,  268, 1578,  761,
+      432,  695,  721,  768,  776,  783,  453,  461,  433,  395,
+      380, 1578,  791,  798,  806,  293,  402,  394,  369,  368,
+
+      343,  288,  375,  840,  299,  874,  908,  934,  960,  986,
+     1012, 1046,  358,  825,  859,  894,  920,  946,  365,  338,
+      335, 1578,  972, 1053, 1061,  296,  339,  337,  336,  335,
+      334,  380, 1578,  316,  323,  418, 1095, 1129,  386,  401,
+     1108, 1163, 1197, 1182,  287, 1204, 1212, 1219,  458, 1227,
+      294,  277,  295, 1578,  290,  444, 1234,  302, 1578, 1578,
+     1578, 1578, 1578, 1578,  486,  384,  388, 1242, 1276,  405,
+      439, 1262, 1277,  268,  653,  259,  232,  206,  197, 1283,
+     1298, 1304, 1319, 1578,  189,  175,  134, 1578, 1578, 1325,
+     1340, 1346,  131, 1578,   87, 1361, 1367, 1382, 1578, 1578,
+
+     1388, 1403, 1578, 1437, 1440, 1447, 1452, 1456, 1463, 1468,
+     1475, 1483, 1488, 1491, 1496, 1504, 1509, 1512, 1519, 1522,
+     1528, 1531, 1537, 1544, 1551, 1554, 1560, 1567, 1570
+    } ;
+
+static yyconst short int yy_def[330] =
+    {   0,
+      303,    1,  303,  303,  303,  303,  303,  304,  305,  303,
+      306,  303,  303,  303,  303,  303,  303,  303,  307,  303,
+      308,  308,  303,  303,  303,  303,  303,  304,  303,  309,
+      305,  310,  303,  306,  311,  303,  303,   16,  312,  303,
+      303,   16,  313,  314,  314,  314,  314,  314,  314,  314,
+      314,  314,  314,  314,  314,  314,  303,  303,  303,  303,
+      303,  303,  303,  308,  308,  303,  303,  308,  315,  303,
+      308,  303,  303,  303,  304,  304,  304,  304,  309,  305,
+      305,  306,  306,  306,  306,  311,  303,  312,  316,  314,
+      314,  314,  317,  314,  314,  314,  314,  314,  314,  314,
+
+      314,  314,  314,  314,  314,  314,  314,  314,  303,  303,
+      303,  303,  303,  303,  303,   65,  308,   65,  318,  303,
+      308,  303,  304,   78,   81,  306,   85,  319,  303,   91,
+      314,   91,  314,  314,  314,  314,  314,  303,  303,  303,
+      303,  303,  303,  303,   65,  118,  303,  320,  303,  303,
+      321,  303,   78,   81,   85,  319,  316,   91,  132,  314,
+      314,  303,  303,  303,  303,  303,  303,   65,  118,  303,
+      322,  303,  303,  303,  321,  321,  323,  324,  303,  325,
+      303,   78,   81,   85,   91,  132,  314,  303,  303,  303,
+      303,  303,   65,  118,  303,  326,  303,  303,  303,  303,
+
+      303,  323,  303,  327,  324,  328,  321,  321,  321,  321,
+      321,  325,  303,   78,   81,   85,   91,  132,  303,  303,
+      303,  303,   65,  118,  303,  329,  303,  303,  303,  303,
+      303,  303,  303,  323,  323,  323,  323,  327,  324,  324,
+      324,  324,  328,  211,  303,   78,   81,   85,  314,  132,
+      303,  303,  303,  303,  303,  223,  303,  303,  303,  303,
+      303,  303,  303,  303,  323,  323,  323,  237,  324,  324,
+      324,  242,  211,  303,  314,  303,  303,  303,  303,  303,
+      237,  242,  211,  303,  303,  303,  303,  303,  303,  237,
+      242,  211,  303,  303,  303,  237,  242,  211,  303,  303,
+
+      237,  242,    0,  303,  303,  303,  303,  303,  303,  303,
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+      303,  303,  303,  303,  303,  303,  303,  303,  303
+    } ;
+
+static yyconst short int yy_nxt[1635] =
+    {   0,
+        4,    5,    6,    5,    5,    5,    7,    8,    9,   10,
+        4,    4,   11,    4,    4,   12,    4,   13,   14,   15,
+       16,   17,    4,    4,    4,   18,   19,   20,   21,   21,
+       21,   21,   21,   21,   21,   21,   21,   21,   21,   21,
+       21,   21,   21,   21,   21,   21,   21,   21,   21,   22,
+       21,   21,   21,   23,   24,   21,   25,   25,   25,   25,
+       25,   25,   25,   25,   25,   25,   26,   26,   26,   26,
+       26,   29,   29,   29,   58,   93,   67,   29,  303,   67,
+       38,   93,   70,   94,   93,  102,   35,   35,   59,   69,
+       30,   60,   69,   93,   61,   65,   30,   67,   62,   95,
+
+       96,   63,   27,   40,   65,   65,   65,   65,   65,   65,
+       69,   41,   71,   42,   25,   25,   25,   25,   25,   43,
+      300,   44,   45,   45,   46,   47,   48,   45,   49,   50,
+       51,   45,   52,   45,   53,   45,   45,   54,   45,   55,
+       56,   45,   45,   45,   45,   45,   81,   93,   45,   26,
+       26,   26,   26,   26,   91,   81,   81,   81,   81,   81,
+       81,   93,   97,   91,   91,   91,   91,   91,   91,   93,
+       93,   67,   98,  108,   93,   29,   93,   93,  299,   29,
+       67,   99,  105,  295,   69,   27,   28,   28,   28,   75,
+      101,  103,   77,   69,   30,  100,   29,  104,   30,  106,
+
+       89,   28,  107,   34,  129,   78,   29,  121,  294,   93,
+       35,   79,   29,   29,   78,   78,   78,   78,   78,   78,
+       34,   34,   34,   82,  118,   30,   35,   35,  133,  293,
+      288,   84,   93,  118,  118,  118,  118,  118,  118,   85,
+       93,  134,   93,  135,   29,   86,  287,   67,   85,   85,
+       85,   85,   85,   85,   64,   64,   64,   64,   64,   93,
+       69,  151,  147,   30,   29,  137,   67,  157,  136,  149,
+       93,  129,  286,  116,   69,   93,   93,  160,   35,   69,
+      203,  161,  116,  116,  116,  116,  116,  116,  119,  147,
+      285,  187,  120,  203,  206,  203,  172,  119,  119,  119,
+
+      119,  119,  119,   76,  123,  123,  123,   76,  147,   29,
+      147,  203,  204,  147,  204,  197,  284,  227,  202,  147,
+      259,  279,  124,  203,  278,  206,  277,  276,   30,  274,
+      203,  124,  124,  124,  124,  124,  124,   28,   28,   28,
+       75,  132,  204,   77,  201,  201,  201,  201,  201,  204,
+      132,  132,  132,  132,  132,  132,   78,  179,  264,  263,
+      262,  261,   79,  260,  255,   78,   78,   78,   78,   78,
+       78,   80,   80,   80,   80,   80,  232,  232,  232,  232,
+      232,  232,  232,  232,  232,  232,  254,  245,  205,  233,
+      125,  203,  231,  230,  233,  203,   32,  251,  203,  125,
+
+      125,  125,  125,  125,  125,   83,  126,  126,  126,   83,
+      204,  252,  206,  203,  204,  253,   29,  203,  229,  265,
+      232,  232,  232,  265,  127,  203,  228,  206,  222,  221,
+       35,  206,  266,  127,  127,  127,  127,  127,  127,   34,
+       34,   34,   82,  145,  204,  117,  117,  117,  117,  117,
+       84,  203,  145,  145,  145,  145,  145,  145,   85,   90,
+       90,   90,   90,   90,   86,  206,  220,   85,   85,   85,
+       85,   85,   85,   90,   90,   90,   90,   90,  219,   93,
+      213,  200,  199,  198,   93,  192,  191,  265,  232,  232,
+      232,  265,  130,  203,  190,  189,  188,   93,   93,  157,
+
+      266,  130,  130,  130,  130,  130,  130,  117,  117,  117,
+      117,  117,  204,  181,  174,  173,  167,  166,  153,  165,
+      164,  163,  162,   93,   93,   93,  146,  153,  153,  153,
+      153,  153,  153,  154,   93,  146,  146,  146,  146,  146,
+      146,  155,  154,  154,  154,  154,  154,  154,  158,  157,
+      155,  155,  155,  155,  155,  155,  152,  158,  158,  158,
+      158,  158,  158,  131,  131,  131,  131,  131,  150,  144,
+      143,  142,  141,  140,  168,  139,  138,   93,   93,   93,
+       93,   93,  159,  168,  168,  168,  168,  168,  168,  169,
+       93,  159,  159,  159,  159,  159,  159,  170,  169,  169,
+
+      169,  169,  169,  169,   93,   93,  170,  170,  170,  170,
+      170,  170,  175,  175,  175,  175,  175,  182,  177,   93,
+       93,   93,   93,  178,   89,  179,  182,  182,  182,  182,
+      182,  182,  183,   32,  122,  115,  114,  180,  184,  113,
+      112,  183,  183,  183,  183,  183,  183,  184,  184,  184,
+      184,  184,  184,  185,  131,  131,  131,  131,  131,  186,
+      111,  110,  185,  185,  185,  185,  185,  185,  186,  186,
+      186,  186,  186,  186,  193,  109,   93,   93,   38,   93,
+      194,   89,   87,  193,  193,  193,  193,  193,  193,  194,
+      194,  194,  194,  194,  194,  195,   32,   74,   73,   72,
+
+       66,   57,   39,   38,  195,  195,  195,  195,  195,  195,
+      175,  175,  175,  175,  175,  214,  177,   37,   36,   33,
+       32,  178,  303,  179,  214,  214,  214,  214,  214,  214,
+      303,  303,  303,  303,  303,  180,  201,  201,  201,  201,
+      201,  215,  303,  303,  303,  303,  303,  303,  303,  179,
+      215,  215,  215,  215,  215,  215,  303,  303,  303,  303,
+      303,  180,  201,  201,  201,  201,  207,  303,  209,  303,
+      303,  303,  303,  209,  209,  210,  303,  303,  303,  303,
+      303,  211,  303,  303,  303,  303,  303,  212,  216,  303,
+      211,  211,  211,  211,  211,  211,  217,  216,  216,  216,
+
+      216,  216,  216,  218,  303,  217,  217,  217,  217,  217,
+      217,  223,  218,  218,  218,  218,  218,  218,  224,  303,
+      223,  223,  223,  223,  223,  223,  225,  224,  224,  224,
+      224,  224,  224,  303,  303,  225,  225,  225,  225,  225,
+      225,  202,  202,  202,  234,  246,  303,  236,  303,  303,
+      303,  303,  303,  303,  246,  246,  246,  246,  246,  246,
+      237,  303,  303,  303,  303,  303,  238,  303,  303,  237,
+      237,  237,  237,  237,  237,  205,  205,  205,  239,  247,
+      303,  303,  303,  303,  303,  303,  241,  303,  247,  247,
+      247,  247,  247,  247,  242,  303,  303,  303,  303,  303,
+
+      243,  303,  303,  242,  242,  242,  242,  242,  242,  201,
+      201,  201,  201,  201,  248,  303,  303,  303,  303,  303,
+      303,  303,  179,  248,  248,  248,  248,  248,  248,  303,
+      303,  303,  303,  303,  180,  201,  201,  201,  201,  201,
+      249,  303,  303,  303,  303,  303,  303,  303,  179,  249,
+      249,  249,  249,  249,  249,  303,  303,  303,  303,  303,
+      180,  201,  201,  201,  201,  201,  250,  303,  303,  303,
+      303,  303,  303,  303,  179,  250,  250,  250,  250,  250,
+      250,  303,  303,  303,  303,  303,  180,  201,  201,  201,
+      201,  201,   68,  303,  303,  303,  303,  303,  303,  303,
+
+      179,   68,   68,   68,   68,   68,   68,  303,  303,  303,
+      303,  303,  180,  207,  207,  207,  207,  207,  303,  303,
+      303,  303,  303,  303,  303,  303,  179,  303,  303,  303,
+      303,  303,  244,  303,  303,  303,  303,  303,  180,  303,
+      303,  244,  244,  244,  244,  244,  244,  201,  201,  201,
+      201,  207,  303,  209,  303,  303,  303,  303,  209,  209,
+      210,  303,  303,  303,  303,  303,  211,  303,  303,  303,
+      303,  303,  212,  256,  303,  211,  211,  211,  211,  211,
+      211,  257,  256,  256,  256,  256,  256,  256,  303,  303,
+      257,  257,  257,  257,  257,  257,  235,  267,  267,  267,
+
+      235,  303,  203,  303,  303,  303,  303,  303,  303,  269,
+      232,  232,  232,  269,  303,  268,  303,  303,  303,  303,
+      203,  204,  270,  303,  268,  268,  268,  268,  268,  268,
+      202,  202,  202,  234,  206,  303,  236,  303,  303,  303,
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  237,
+      303,  303,  303,  303,  303,  238,  303,  303,  237,  237,
+      237,  237,  237,  237,  240,  271,  271,  271,  240,  303,
+      303,  303,  303,  303,  303,  203,  303,  303,  303,  303,
+      303,  303,  303,  272,  303,  303,  303,  303,  303,  206,
+      303,  303,  272,  272,  272,  272,  272,  272,  205,  205,
+
+      205,  239,  273,  303,  303,  303,  303,  303,  303,  241,
+      303,  273,  273,  273,  273,  273,  273,  242,  303,  303,
+      303,  303,  303,  243,   28,  303,  242,  242,  242,  242,
+      242,  242,   31,   28,   28,   28,   28,   28,   28,   34,
+      303,   31,   31,   31,   31,   31,   31,  275,   34,   34,
+       34,   34,   34,   34,  280,  303,  275,  275,  275,  275,
+      275,  275,  281,  280,  280,  280,  280,  280,  280,  303,
+      303,  281,  281,  281,  281,  281,  281,  269,  232,  232,
+      232,  269,  282,  303,  303,  303,  303,  303,  203,  303,
+      270,  282,  282,  282,  282,  282,  282,  283,  303,  303,
+
+      303,  303,  206,  289,  303,  303,  283,  283,  283,  283,
+      283,  283,  289,  289,  289,  289,  289,  289,  290,  303,
+      303,  303,  303,  303,  291,  303,  303,  290,  290,  290,
+      290,  290,  290,  291,  291,  291,  291,  291,  291,  292,
+      303,  303,  303,  303,  303,  296,  303,  303,  292,  292,
+      292,  292,  292,  292,  296,  296,  296,  296,  296,  296,
+      297,  303,  303,  303,  303,  303,  298,  303,  303,  297,
+      297,  297,  297,  297,  297,  298,  298,  298,  298,  298,
+      298,  301,  303,  303,  303,  303,  303,  302,  303,  303,
+      301,  301,  301,  301,  301,  301,  302,  302,  302,  302,
+
+      302,  302,  176,  303,  303,  303,  303,  303,  202,  303,
+      303,  176,  176,  176,  176,  176,  176,  202,  202,  202,
+      202,  202,  202,  205,  303,  303,  303,  303,  303,  303,
+      303,  303,  205,  205,  205,  205,  205,  205,   28,  303,
+       28,   28,   28,   28,   28,   31,  303,   31,   34,  303,
+       34,   34,   34,   34,   34,   64,   64,   64,   64,   64,
+       68,   68,  303,   68,   76,   76,   76,   76,   76,   76,
+       76,   80,   80,   80,   80,   80,   83,   83,   83,   83,
+       83,   83,   83,   88,   88,   88,   88,   88,   88,   88,
+       88,   90,   90,   90,   90,   90,   92,  303,   92,  117,
+
+      117,  117,  117,  117,  128,  128,  128,  128,  128,  128,
+      128,  128,  131,  131,  131,  131,  131,  148,  148,  156,
+      156,  156,  156,  156,  156,  156,  156,  171,  171,  176,
+      176,  176,  303,  176,  176,  176,  196,  196,  202,  303,
+      202,  202,  202,  202,  202,  205,  303,  205,  205,  205,
+      205,  205,  208,  208,  208,  208,  208,  208,  208,  226,
+      226,  235,  235,  235,  235,  235,  235,  235,  240,  240,
+      240,  240,  240,  240,  240,  258,  258,    3,  303,  303,
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+      303,  303,  303,  303
+    } ;
+
+static yyconst short int yy_chk[1635] =
+    {   0,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    1,    1,    1,    1,
+        1,    1,    1,    1,    1,    1,    5,    5,    5,    5,
+        5,    6,    6,    6,    6,    6,    7,    7,    7,    7,
+        7,    8,   11,   34,   18,   52,   21,   28,   38,   22,
+       38,   44,   22,   44,   46,   52,   11,   34,   18,   21,
+        8,   18,   22,   47,   18,   19,   28,   64,   18,   46,
+
+       47,   18,    7,   16,   19,   19,   19,   19,   19,   19,
+       64,   16,   22,   16,   25,   25,   25,   25,   25,   16,
+      295,   16,   16,   16,   16,   16,   16,   16,   16,   16,
+       16,   16,   16,   16,   16,   16,   16,   16,   16,   16,
+       16,   16,   16,   16,   16,   16,   32,   48,   16,   26,
+       26,   26,   26,   26,   43,   32,   32,   32,   32,   32,
+       32,   49,   48,   43,   43,   43,   43,   43,   43,   50,
+       55,   68,   48,   55,   51,   76,   53,   54,  293,   77,
+       71,   49,   54,  287,   68,   26,   30,   30,   30,   30,
+       51,   53,   30,   71,   76,   50,   83,   53,   77,   54,
+
+       89,   75,   54,   82,   89,   30,   75,   71,  286,   94,
+       83,   30,   84,   82,   30,   30,   30,   30,   30,   30,
+       35,   35,   35,   35,   69,   75,   84,   82,   94,  285,
+      279,   35,   96,   69,   69,   69,   69,   69,   69,   35,
+       99,   96,  102,   99,  123,   35,  278,  117,   35,   35,
+       35,   35,   35,   35,   65,   65,   65,   65,   65,  108,
+      117,  121,  119,  123,  126,  108,   65,  157,  102,  119,
+      133,  157,  277,   65,  121,  135,  160,  133,  126,   65,
+      178,  135,   65,   65,   65,   65,   65,   65,   70,  148,
+      276,  160,   70,  177,  178,  202,  148,   70,   70,   70,
+
+       70,   70,   70,   78,   78,   78,   78,   78,  171,   78,
+      196,  205,  177,  226,  202,  171,  274,  196,  234,  258,
+      226,  255,   78,  234,  253,  205,  252,  251,   78,  245,
+      235,   78,   78,   78,   78,   78,   78,   79,   79,   79,
+       79,   93,  234,   79,  201,  201,  201,  201,  201,  235,
+       93,   93,   93,   93,   93,   93,   79,  201,  231,  230,
+      229,  228,   79,  227,  221,   79,   79,   79,   79,   79,
+       79,   81,   81,   81,   81,   81,  203,  203,  203,  203,
+      203,  232,  232,  232,  232,  232,  220,  213,  239,  203,
+       81,  266,  200,  199,  232,  267,   81,  219,  239,   81,
+
+       81,   81,   81,   81,   81,   85,   85,   85,   85,   85,
+      266,  219,  239,  240,  267,  219,   85,  270,  198,  236,
+      236,  236,  236,  236,   85,  236,  197,  240,  191,  190,
+       85,  270,  236,   85,   85,   85,   85,   85,   85,   86,
+       86,   86,   86,  116,  236,  256,  256,  256,  256,  256,
+       86,  271,  116,  116,  116,  116,  116,  116,   86,  249,
+      249,  249,  249,  249,   86,  271,  189,   86,   86,   86,
+       86,   86,   86,   91,   91,   91,   91,   91,  188,  187,
+      181,  174,  173,  172,  249,  166,  165,  265,  265,  265,
+      265,  265,   91,  265,  164,  163,  162,  161,   91,  156,
+
+      265,   91,   91,   91,   91,   91,   91,  118,  118,  118,
+      118,  118,  265,  152,  150,  149,  144,  143,  124,  142,
+      141,  140,  139,  137,  136,  134,  118,  124,  124,  124,
+      124,  124,  124,  125,  131,  118,  118,  118,  118,  118,
+      118,  127,  125,  125,  125,  125,  125,  125,  130,  128,
+      127,  127,  127,  127,  127,  127,  122,  130,  130,  130,
+      130,  130,  130,  132,  132,  132,  132,  132,  120,  115,
+      114,  113,  112,  111,  145,  110,  109,  107,  106,  105,
+      104,  103,  132,  145,  145,  145,  145,  145,  145,  146,
+      101,  132,  132,  132,  132,  132,  132,  147,  146,  146,
+
+      146,  146,  146,  146,  100,   98,  147,  147,  147,  147,
+      147,  147,  151,  151,  151,  151,  151,  153,  151,   97,
+       95,   92,   90,  151,   88,  151,  153,  153,  153,  153,
+      153,  153,  154,   80,   74,   63,   62,  151,  155,   61,
+       60,  154,  154,  154,  154,  154,  154,  155,  155,  155,
+      155,  155,  155,  158,  275,  275,  275,  275,  275,  159,
+       59,   58,  158,  158,  158,  158,  158,  158,  159,  159,
+      159,  159,  159,  159,  168,   57,   56,   45,   41,  275,
+      169,   39,   37,  168,  168,  168,  168,  168,  168,  169,
+      169,  169,  169,  169,  169,  170,   31,   27,   24,   23,
+
+       20,   17,   15,   14,  170,  170,  170,  170,  170,  170,
+      175,  175,  175,  175,  175,  182,  175,   13,   12,   10,
+        9,  175,    3,  175,  182,  182,  182,  182,  182,  182,
+        0,    0,    0,    0,    0,  175,  176,  176,  176,  176,
+      176,  183,  176,    0,    0,    0,    0,  176,    0,  176,
+      183,  183,  183,  183,  183,  183,    0,    0,    0,    0,
+        0,  176,  180,  180,  180,  180,  180,    0,  180,    0,
+        0,    0,    0,  180,  180,  180,    0,    0,    0,    0,
+        0,  180,    0,    0,    0,    0,    0,  180,  184,    0,
+      180,  180,  180,  180,  180,  180,  185,  184,  184,  184,
+
+      184,  184,  184,  186,    0,  185,  185,  185,  185,  185,
+      185,  193,  186,  186,  186,  186,  186,  186,  194,    0,
+      193,  193,  193,  193,  193,  193,  195,  194,  194,  194,
+      194,  194,  194,    0,    0,  195,  195,  195,  195,  195,
+      195,  204,  204,  204,  204,  214,    0,  204,    0,    0,
+        0,    0,    0,    0,  214,  214,  214,  214,  214,  214,
+      204,    0,    0,    0,    0,    0,  204,    0,    0,  204,
+      204,  204,  204,  204,  204,  206,  206,  206,  206,  215,
+        0,    0,    0,    0,    0,    0,  206,    0,  215,  215,
+      215,  215,  215,  215,  206,    0,    0,    0,    0,    0,
+
+      206,    0,    0,  206,  206,  206,  206,  206,  206,  207,
+      207,  207,  207,  207,  216,  207,    0,    0,    0,    0,
+      207,    0,  207,  216,  216,  216,  216,  216,  216,    0,
+        0,    0,    0,    0,  207,  208,  208,  208,  208,  208,
+      217,  208,    0,    0,    0,    0,  208,    0,  208,  217,
+      217,  217,  217,  217,  217,    0,    0,    0,    0,    0,
+      208,  209,  209,  209,  209,  209,  218,  209,    0,    0,
+        0,    0,  209,    0,  209,  218,  218,  218,  218,  218,
+      218,    0,    0,    0,    0,    0,  209,  210,  210,  210,
+      210,  210,  223,  210,    0,    0,    0,    0,  210,    0,
+
+      210,  223,  223,  223,  223,  223,  223,    0,    0,    0,
+        0,    0,  210,  211,  211,  211,  211,  211,    0,  211,
+        0,    0,    0,    0,  211,    0,  211,    0,    0,    0,
+        0,    0,  211,    0,    0,    0,    0,    0,  211,    0,
+        0,  211,  211,  211,  211,  211,  211,  212,  212,  212,
+      212,  212,    0,  212,    0,    0,    0,    0,  212,  212,
+      212,    0,    0,    0,    0,    0,  212,    0,    0,    0,
+        0,    0,  212,  224,    0,  212,  212,  212,  212,  212,
+      212,  225,  224,  224,  224,  224,  224,  224,    0,    0,
+      225,  225,  225,  225,  225,  225,  237,  237,  237,  237,
+
+      237,    0,  237,    0,    0,    0,    0,    0,    0,  241,
+      241,  241,  241,  241,    0,  237,    0,    0,    0,    0,
+      241,  237,  241,    0,  237,  237,  237,  237,  237,  237,
+      238,  238,  238,  238,  241,    0,  238,    0,    0,    0,
+        0,    0,    0,    0,    0,    0,    0,    0,    0,  238,
+        0,    0,    0,    0,    0,  238,    0,    0,  238,  238,
+      238,  238,  238,  238,  242,  242,  242,  242,  242,    0,
+        0,    0,    0,    0,    0,  242,    0,    0,    0,    0,
+        0,    0,    0,  242,    0,    0,    0,    0,    0,  242,
+        0,    0,  242,  242,  242,  242,  242,  242,  243,  243,
+
+      243,  243,  244,    0,    0,    0,    0,    0,    0,  243,
+        0,  244,  244,  244,  244,  244,  244,  243,    0,    0,
+        0,    0,    0,  243,  246,    0,  243,  243,  243,  243,
+      243,  243,  247,  246,  246,  246,  246,  246,  246,  248,
+        0,  247,  247,  247,  247,  247,  247,  250,  248,  248,
+      248,  248,  248,  248,  257,    0,  250,  250,  250,  250,
+      250,  250,  268,  257,  257,  257,  257,  257,  257,    0,
+        0,  268,  268,  268,  268,  268,  268,  269,  269,  269,
+      269,  269,  272,    0,    0,    0,    0,    0,  269,    0,
+      269,  272,  272,  272,  272,  272,  272,  273,    0,    0,
+
+        0,    0,  269,  280,    0,    0,  273,  273,  273,  273,
+      273,  273,  280,  280,  280,  280,  280,  280,  281,    0,
+        0,    0,    0,    0,  282,    0,    0,  281,  281,  281,
+      281,  281,  281,  282,  282,  282,  282,  282,  282,  283,
+        0,    0,    0,    0,    0,  290,    0,    0,  283,  283,
+      283,  283,  283,  283,  290,  290,  290,  290,  290,  290,
+      291,    0,    0,    0,    0,    0,  292,    0,    0,  291,
+      291,  291,  291,  291,  291,  292,  292,  292,  292,  292,
+      292,  296,    0,    0,    0,    0,    0,  297,    0,    0,
+      296,  296,  296,  296,  296,  296,  297,  297,  297,  297,
+
+      297,  297,  298,    0,    0,    0,    0,    0,  301,    0,
+        0,  298,  298,  298,  298,  298,  298,  301,  301,  301,
+      301,  301,  301,  302,    0,    0,    0,    0,    0,    0,
+        0,    0,  302,  302,  302,  302,  302,  302,  304,    0,
+      304,  304,  304,  304,  304,  305,    0,  305,  306,    0,
+      306,  306,  306,  306,  306,  307,  307,  307,  307,  307,
+      308,  308,    0,  308,  309,  309,  309,  309,  309,  309,
+      309,  310,  310,  310,  310,  310,  311,  311,  311,  311,
+      311,  311,  311,  312,  312,  312,  312,  312,  312,  312,
+      312,  313,  313,  313,  313,  313,  314,    0,  314,  315,
+
+      315,  315,  315,  315,  316,  316,  316,  316,  316,  316,
+      316,  316,  317,  317,  317,  317,  317,  318,  318,  319,
+      319,  319,  319,  319,  319,  319,  319,  320,  320,  321,
+      321,  321,    0,  321,  321,  321,  322,  322,  323,    0,
+      323,  323,  323,  323,  323,  324,    0,  324,  324,  324,
+      324,  324,  325,  325,  325,  325,  325,  325,  325,  326,
+      326,  327,  327,  327,  327,  327,  327,  327,  328,  328,
+      328,  328,  328,  328,  328,  329,  329,  303,  303,  303,
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+      303,  303,  303,  303,  303,  303,  303,  303,  303,  303,
+      303,  303,  303,  303
+    } ;
+
+
+YY_DECL
+	{
+	register yy_state_type yy_current_state;
+	register unsigned short *yy_cp, *yy_bp;
+	register int yy_act;
+	while ( 1 )		/* loops until end-of-file is reached */
+		{
+		yy_cp = yy_c_buf_p;
+
+		/* Support of yytext. */
+		*yy_cp = yy_hold_char;
+
+		/* yy_bp points to the position in yy_ch_buf of the start of
+		 * the current run.
+		 */
+		yy_bp = yy_cp;
+
+		yy_current_state = yy_start;
+		do
+			{
+			register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
+			if ( yy_accept[yy_current_state] )
+				{
+				yy_last_accepting_state = yy_current_state;
+				yy_last_accepting_cpos = yy_cp;
+				}
+			while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
+				{
+				yy_current_state = (int) yy_def[yy_current_state];
+				if ( yy_current_state >= 304 )
+					yy_c = yy_meta[(unsigned int) yy_c];
+				}
+			yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
+			++yy_cp;
+			}
+		while ( yy_base[yy_current_state] != 1578 );
+
+yy_find_action:
+		yy_act = yy_accept[yy_current_state];
+		if ( yy_act == 0 )
+			{ /* have to back up */
+			yy_cp = yy_last_accepting_cpos;
+			yy_current_state = yy_last_accepting_state;
+			yy_act = yy_accept[yy_current_state];
+			}
+
+		YY_DO_BEFORE_ACTION;
+
+
+		switch ( yy_act )
+	{ /* beginning of action switch */
+			case 0: /* must back up */
+			/* undo the effects of YY_DO_BEFORE_ACTION */
+			*yy_cp = yy_hold_char;
+			yy_cp = yy_last_accepting_cpos;
+			yy_current_state = yy_last_accepting_state;
+			goto yy_find_action;
+
+case 1:
+YY_RULE_SETUP
+#line 25 "tokenizer.flex"
+/* ignore comments */
+	YY_BREAK
+case 2:
+YY_RULE_SETUP
+#line 27 "tokenizer.flex"
+{yyTok = S; return yyTok;}
+	YY_BREAK
+case 3:
+YY_RULE_SETUP
+#line 29 "tokenizer.flex"
+{yyTok = SGML_CD; return yyTok;}
+	YY_BREAK
+case 4:
+YY_RULE_SETUP
+#line 30 "tokenizer.flex"
+{yyTok = SGML_CD; return yyTok;}
+	YY_BREAK
+case 5:
+YY_RULE_SETUP
+#line 31 "tokenizer.flex"
+{yyTok = INCLUDES; return yyTok;}
+	YY_BREAK
+case 6:
+YY_RULE_SETUP
+#line 32 "tokenizer.flex"
+{yyTok = DASHMATCH; return yyTok;}
+	YY_BREAK
+case 7:
+YY_RULE_SETUP
+#line 33 "tokenizer.flex"
+{yyTok = BEGINSWITH; return yyTok;}
+	YY_BREAK
+case 8:
+YY_RULE_SETUP
+#line 34 "tokenizer.flex"
+{yyTok = ENDSWITH; return yyTok;}
+	YY_BREAK
+case 9:
+YY_RULE_SETUP
+#line 35 "tokenizer.flex"
+{yyTok = CONTAINS; return yyTok;}
+	YY_BREAK
+case 10:
+YY_RULE_SETUP
+#line 37 "tokenizer.flex"
+{yyTok = STRING; return yyTok;}
+	YY_BREAK
+case 11:
+YY_RULE_SETUP
+#line 39 "tokenizer.flex"
+{yyTok = IDENT; return yyTok;}
+	YY_BREAK
+case 12:
+YY_RULE_SETUP
+#line 41 "tokenizer.flex"
+{yyTok = HASH; return yyTok;}
+	YY_BREAK
+case 13:
+YY_RULE_SETUP
+#line 43 "tokenizer.flex"
+{yyTok = IMPORT_SYM; return yyTok;}
+	YY_BREAK
+case 14:
+YY_RULE_SETUP
+#line 44 "tokenizer.flex"
+{yyTok = PAGE_SYM; return yyTok;}
+	YY_BREAK
+case 15:
+YY_RULE_SETUP
+#line 45 "tokenizer.flex"
+{yyTok = MEDIA_SYM; return yyTok;}
+	YY_BREAK
+case 16:
+YY_RULE_SETUP
+#line 46 "tokenizer.flex"
+{yyTok = FONT_FACE_SYM; return yyTok;}
+	YY_BREAK
+case 17:
+YY_RULE_SETUP
+#line 47 "tokenizer.flex"
+{yyTok = CHARSET_SYM; return yyTok;}
+	YY_BREAK
+case 18:
+YY_RULE_SETUP
+#line 48 "tokenizer.flex"
+{yyTok = KONQ_RULE_SYM; return yyTok; }
+	YY_BREAK
+case 19:
+YY_RULE_SETUP
+#line 49 "tokenizer.flex"
+{yyTok = KONQ_DECLS_SYM; return yyTok; }
+	YY_BREAK
+case 20:
+YY_RULE_SETUP
+#line 50 "tokenizer.flex"
+{yyTok = KONQ_VALUE_SYM; return yyTok; }
+	YY_BREAK
+case 21:
+YY_RULE_SETUP
+#line 52 "tokenizer.flex"
+{yyTok = IMPORTANT_SYM; return yyTok;}
+	YY_BREAK
+case 22:
+YY_RULE_SETUP
+#line 54 "tokenizer.flex"
+{yyTok = EMS; return yyTok;}
+	YY_BREAK
+case 23:
+YY_RULE_SETUP
+#line 55 "tokenizer.flex"
+{yyTok = QEMS; return yyTok;} /* quirky ems */
+	YY_BREAK
+case 24:
+YY_RULE_SETUP
+#line 56 "tokenizer.flex"
+{yyTok = EXS; return yyTok;}
+	YY_BREAK
+case 25:
+YY_RULE_SETUP
+#line 57 "tokenizer.flex"
+{yyTok = PXS; return yyTok;}
+	YY_BREAK
+case 26:
+YY_RULE_SETUP
+#line 58 "tokenizer.flex"
+{yyTok = CMS; return yyTok;}
+	YY_BREAK
+case 27:
+YY_RULE_SETUP
+#line 59 "tokenizer.flex"
+{yyTok = MMS; return yyTok;}
+	YY_BREAK
+case 28:
+YY_RULE_SETUP
+#line 60 "tokenizer.flex"
+{yyTok = INS; return yyTok;}
+	YY_BREAK
+case 29:
+YY_RULE_SETUP
+#line 61 "tokenizer.flex"
+{yyTok = PTS; return yyTok;}
+	YY_BREAK
+case 30:
+YY_RULE_SETUP
+#line 62 "tokenizer.flex"
+{yyTok = PCS; return yyTok;}
+	YY_BREAK
+case 31:
+YY_RULE_SETUP
+#line 63 "tokenizer.flex"
+{yyTok = DEGS; return yyTok;}
+	YY_BREAK
+case 32:
+YY_RULE_SETUP
+#line 64 "tokenizer.flex"
+{yyTok = RADS; return yyTok;}
+	YY_BREAK
+case 33:
+YY_RULE_SETUP
+#line 65 "tokenizer.flex"
+{yyTok = GRADS; return yyTok;}
+	YY_BREAK
+case 34:
+YY_RULE_SETUP
+#line 66 "tokenizer.flex"
+{yyTok = MSECS; return yyTok;}
+	YY_BREAK
+case 35:
+YY_RULE_SETUP
+#line 67 "tokenizer.flex"
+{yyTok = SECS; return yyTok;}
+	YY_BREAK
+case 36:
+YY_RULE_SETUP
+#line 68 "tokenizer.flex"
+{yyTok = HERZ; return yyTok;}
+	YY_BREAK
+case 37:
+YY_RULE_SETUP
+#line 69 "tokenizer.flex"
+{yyTok = KHERZ; return yyTok;}
+	YY_BREAK
+case 38:
+YY_RULE_SETUP
+#line 70 "tokenizer.flex"
+{yyTok = DIMEN; return yyTok;}
+	YY_BREAK
+case 39:
+YY_RULE_SETUP
+#line 71 "tokenizer.flex"
+{yyTok = PERCENTAGE; return yyTok;}
+	YY_BREAK
+case 40:
+YY_RULE_SETUP
+#line 72 "tokenizer.flex"
+{yyTok = NUMBER; return yyTok;}
+	YY_BREAK
+case 41:
+YY_RULE_SETUP
+#line 74 "tokenizer.flex"
+{yyTok = URI; return yyTok;}
+	YY_BREAK
+case 42:
+YY_RULE_SETUP
+#line 75 "tokenizer.flex"
+{yyTok = URI; return yyTok;}
+	YY_BREAK
+case 43:
+YY_RULE_SETUP
+#line 76 "tokenizer.flex"
+{yyTok = FUNCTION; return yyTok;}
+	YY_BREAK
+case 44:
+YY_RULE_SETUP
+#line 78 "tokenizer.flex"
+{yyTok = UNICODERANGE; return yyTok;}
+	YY_BREAK
+case 45:
+YY_RULE_SETUP
+#line 79 "tokenizer.flex"
+{yyTok = UNICODERANGE; return yyTok;}
+	YY_BREAK
+case 46:
+YY_RULE_SETUP
+#line 81 "tokenizer.flex"
+{yyTok = *yytext; return yyTok;}
+	YY_BREAK
+case 47:
+YY_RULE_SETUP
+#line 83 "tokenizer.flex"
+ECHO;
+	YY_BREAK
+#line 1304 "lex.yy.c"
+case YY_STATE_EOF(INITIAL):
+	case YY_END_OF_BUFFER:
+	yyterminate();
+
+	default:
+		YY_FATAL_ERROR(
+			"fatal flex scanner internal error--no action found" );
+	} /* end of action switch */
+		} /* end of scanning one token */
+	} /* end of yylex */
+
+
diff --git a/WebCore/khtml/css/tokenizer.flex b/WebCore/khtml/css/tokenizer.flex
new file mode 100644
index 0000000..604b6bf
--- /dev/null
+++ b/WebCore/khtml/css/tokenizer.flex
@@ -0,0 +1,84 @@
+%option case-insensitive
+%option noyywrap
+%option 8bit
+
+h               [0-9a-fA-F]
+nonascii        [\200-\377]
+unicode         \\{h}{1,6}[ \t\r\n\f]?
+escape          {unicode}|\\[ -~\200-\377]
+nmstart         [_a-zA-Z]|{nonascii}|{escape}
+nmchar          [_a-zA-Z0-9-]|{nonascii}|{escape}
+string1         \"([\t !#$%&(-~]|\\{nl}|\'|{nonascii}|{escape})*\"
+string2         \'([\t !#$%&(-~]|\\{nl}|\"|{nonascii}|{escape})*\'
+
+ident           {nmstart}{nmchar}*
+name            {nmchar}+
+num             [0-9]+|[0-9]*"."[0-9]+
+string          {string1}|{string2}
+url             ([!#$%&*-~]|{nonascii}|{escape})*
+w               [ \t\r\n\f]*
+nl              \n|\r\n|\r|\f
+range           \?{1,6}|{h}(\?{0,5}|{h}(\?{0,4}|{h}(\?{0,3}|{h}(\?{0,2}|{h}(\??|{h})))))
+
+%%
+
+\/\*[^*]*\*+([^/*][^*]*\*+)*\/  /* ignore comments */
+
+[ \t\r\n\f]+            {yyTok = S; return yyTok;}
+
+"<!--"                  {yyTok = SGML_CD; return yyTok;}
+"-->"                   {yyTok = SGML_CD; return yyTok;}
+"~="                    {yyTok = INCLUDES; return yyTok;}
+"|="                    {yyTok = DASHMATCH; return yyTok;}
+"^="                    {yyTok = BEGINSWITH; return yyTok;}
+"$="                    {yyTok = ENDSWITH; return yyTok;}
+"*="                    {yyTok = CONTAINS; return yyTok;}
+
+{string}                {yyTok = STRING; return yyTok;}
+
+{ident}                 {yyTok = IDENT; return yyTok;}
+
+"#"{name}               {yyTok = HASH; return yyTok;}
+
+"@import"               {yyTok = IMPORT_SYM; return yyTok;}
+"@page"                 {yyTok = PAGE_SYM; return yyTok;}
+"@media"                {yyTok = MEDIA_SYM; return yyTok;}
+"@font-face"            {yyTok = FONT_FACE_SYM; return yyTok;}
+"@charset"              {yyTok = CHARSET_SYM; return yyTok;}
+"@-konq-rule"    {yyTok = KONQ_RULE_SYM; return yyTok; }
+"@-konq-decls"   {yyTok = KONQ_DECLS_SYM; return yyTok; }
+"@-konq-value"   {yyTok = KONQ_VALUE_SYM; return yyTok; }
+
+"!"{w}"important"         {yyTok = IMPORTANT_SYM; return yyTok;}
+
+{num}em                 {yyTok = EMS; return yyTok;}
+{num}__qem              {yyTok = QEMS; return yyTok;} /* quirky ems */
+{num}ex                 {yyTok = EXS; return yyTok;}
+{num}px                 {yyTok = PXS; return yyTok;}
+{num}cm                 {yyTok = CMS; return yyTok;}
+{num}mm                 {yyTok = MMS; return yyTok;}
+{num}in                 {yyTok = INS; return yyTok;}
+{num}pt                 {yyTok = PTS; return yyTok;}
+{num}pc                 {yyTok = PCS; return yyTok;}
+{num}deg                {yyTok = DEGS; return yyTok;}
+{num}rad                {yyTok = RADS; return yyTok;}
+{num}grad               {yyTok = GRADS; return yyTok;}
+{num}ms                 {yyTok = MSECS; return yyTok;}
+{num}s                  {yyTok = SECS; return yyTok;}
+{num}Hz                 {yyTok = HERZ; return yyTok;}
+{num}kHz                {yyTok = KHERZ; return yyTok;}
+{num}{ident}            {yyTok = DIMEN; return yyTok;}
+{num}%                  {yyTok = PERCENTAGE; return yyTok;}
+{num}                   {yyTok = NUMBER; return yyTok;}
+
+"url("{w}{string}{w}")" {yyTok = URI; return yyTok;}
+"url("{w}{url}{w}")"    {yyTok = URI; return yyTok;}
+{ident}"("              {yyTok = FUNCTION; return yyTok;}
+
+U\+{range}              {yyTok = UNICODERANGE; return yyTok;}
+U\+{h}{1,6}-{h}{1,6}    {yyTok = UNICODERANGE; return yyTok;}
+
+.                       {yyTok = *yytext; return yyTok;}
+
+%%
+
diff --git a/WebCore/khtml/dom/css_value.h b/WebCore/khtml/dom/css_value.h
index e6687df..6d51040 100644
--- a/WebCore/khtml/dom/css_value.h
+++ b/WebCore/khtml/dom/css_value.h
@@ -406,7 +406,8 @@ public:
         CSS_ATTR = 22,
         CSS_COUNTER = 23,
         CSS_RECT = 24,
-        CSS_RGBCOLOR = 25
+        CSS_RGBCOLOR = 25,
+        CSS_HTML_RELATIVE = 255
     };
 
     /**
diff --git a/WebCore/khtml/dom/html_element.cpp b/WebCore/khtml/dom/html_element.cpp
index c112b56..e5dddf8 100644
--- a/WebCore/khtml/dom/html_element.cpp
+++ b/WebCore/khtml/dom/html_element.cpp
@@ -21,7 +21,7 @@
  */
 #include "dom/dom_exception.h"
 #include "dom/html_misc.h"
-#include "css/cssparser.h"
+#include "css/css_base.h"
 #include "html/html_miscimpl.h" // HTMLCollectionImpl
 
 #include "misc/htmlhashes.h"
diff --git a/WebCore/khtml/ecma/kjs_css.cpp b/WebCore/khtml/ecma/kjs_css.cpp
index 856345c..bbe5e22 100644
--- a/WebCore/khtml/ecma/kjs_css.cpp
+++ b/WebCore/khtml/ecma/kjs_css.cpp
@@ -25,7 +25,7 @@
 
 #include <dom/html_head.h> // for HTMLStyleElement
 
-#include <css/cssparser.h>
+#include <css/css_base.h>
 #include "kjs_dom.h"
 
 using namespace KJS;
diff --git a/WebCore/khtml/html/html_baseimpl.cpp b/WebCore/khtml/html/html_baseimpl.cpp
index 34313ed..cffa617 100644
--- a/WebCore/khtml/html/html_baseimpl.cpp
+++ b/WebCore/khtml/html/html_baseimpl.cpp
@@ -97,11 +97,11 @@ void HTMLBodyElementImpl::parseAttribute(AttributeImpl *attr)
         addCSSLength(CSS_PROP_MARGIN_TOP, attr->value());
         break;
     case ATTR_BGCOLOR:
-        addCSSProperty(CSS_PROP_BACKGROUND_COLOR, attr->value());
+        addHTMLColor(CSS_PROP_BACKGROUND_COLOR, attr->value());
         m_bgSet = !attr->value().isNull();
         break;
     case ATTR_TEXT:
-        addCSSProperty(CSS_PROP_COLOR, attr->value());
+        addHTMLColor(CSS_PROP_COLOR, attr->value());
         m_fgSet = !attr->value().isNull();
         break;
     case ATTR_BGPROPERTIES:
diff --git a/WebCore/khtml/html/html_blockimpl.cpp b/WebCore/khtml/html/html_blockimpl.cpp
index 9e746fe..7e5d862 100644
--- a/WebCore/khtml/html/html_blockimpl.cpp
+++ b/WebCore/khtml/html/html_blockimpl.cpp
@@ -74,8 +74,9 @@ void HTMLDivElementImpl::parseAttribute(AttributeImpl *attr)
     {
         DOMString v = attr->value();
 	if ( strcasecmp( attr->value(), "middle" ) == 0 || strcasecmp( attr->value(), "center" ) == 0 )
-            v = "-konq-center";
-        addCSSProperty(CSS_PROP_TEXT_ALIGN, v);
+           addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KONQ_CENTER);
+        else
+            addCSSProperty(CSS_PROP_TEXT_ALIGN, v);
         break;
     }
     default:
@@ -147,7 +148,7 @@ void HTMLHRElementImpl::attach()
             addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
             addCSSProperty(CSS_PROP_BORDER_TOP_WIDTH, DOMString("0"));
             addCSSLength(CSS_PROP_BORDER_BOTTOM_WIDTH, DOMString(si));
-            addCSSProperty(CSS_PROP_BORDER_COLOR, color);
+            addHTMLColor(CSS_PROP_BORDER_COLOR, color);
         }
         else {
             if (_s > 1 && getAttribute(ATTR_NOSHADE).isNull()) {
@@ -196,9 +197,10 @@ void HTMLParagraphElementImpl::parseAttribute(AttributeImpl *attr)
         {
             DOMString v = attr->value();
             if ( strcasecmp( attr->value(), "middle" ) == 0 || strcasecmp( attr->value(), "center" ) == 0 )
-                    v = "-konq-center";
+                addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KONQ_CENTER);
+            else
                 addCSSProperty(CSS_PROP_TEXT_ALIGN, v);
-                break;
+            break;
         }
         default:
             HTMLElementImpl::parseAttribute(attr);
diff --git a/WebCore/khtml/html/html_elementimpl.cpp b/WebCore/khtml/html/html_elementimpl.cpp
index ed53cac..9ed54c5 100644
--- a/WebCore/khtml/html/html_elementimpl.cpp
+++ b/WebCore/khtml/html/html_elementimpl.cpp
@@ -247,6 +247,101 @@ void HTMLElementImpl::addCSSLength(int id, const DOMString &value)
     setChanged();
 }
 
+static inline bool isHexDigit( const QChar &c ) {
+    return ( c >= '0' && c <= '9' ) ||
+	   ( c >= 'a' && c <= 'f' ) ||
+	   ( c >= 'A' && c <= 'F' );
+}
+
+static inline int toHex( const QChar &c ) {
+    return ( (c >= '0' && c <= '9')
+             ? (c.unicode() - '0')
+             : ( ( c >= 'a' && c <= 'f' )
+                 ? (c.unicode() - 'a' + 10)
+                 : ( ( c >= 'A' && c <= 'F' )
+                     ? (c.unicode() - 'A' + 10)
+                     : -1 ) ) );
+}
+
+/* color parsing that tries to match as close as possible IE 6. */
+void HTMLElementImpl::addHTMLColor( int id, const DOMString &c )
+{
+    if(!m_styleDecls) createDecl();
+
+    // this is the only case no color gets applied in IE.
+    if ( !c.length() )
+        return;
+
+    if ( m_styleDecls->setProperty(id, c, false, true) )
+        return;
+
+    QString color = c.string();
+    // not something that fits the specs.
+
+    // we're emulating IEs color parser here. It maps transparent to black, otherwise it tries to build a rgb value
+    // out of everyhting you put in. The algorithm is experimentally determined, but seems to work for all test cases I have.
+
+    // the length of the color value is rounded up to the next
+    // multiple of 3. each part of the rgb triple then gets one third
+    // of the length.
+    //
+    // Each triplet is parsed byte by byte, mapping
+    // each number to a hex value (0-9a-fA-F to their values
+    // everything else to 0).
+    //
+    // The highest non zero digit in all triplets is remembered, and
+    // used as a normalization point to normalize to values between 0
+    // and 255.
+
+    if ( color.lower() != "transparent" ) {
+        if ( color[0] == '#' )
+            color.remove( 0,  1 );
+        int basicLength = (color.length() + 2) / 3;
+        if ( basicLength > 1 ) {
+            // IE ignores colors with three digits or less
+            // 	    qDebug("trying to fix up color '%s'. basicLength=%d, length=%d",
+            // 		   color.latin1(), basicLength, color.length() );
+            int colors[3] = { 0, 0, 0 };
+            int component = 0;
+            int pos = 0;
+            int maxDigit = basicLength-1;
+            while ( component < 3 ) {
+                // search forward for digits in the string
+                int numDigits = 0;
+                while ( pos < (int)color.length() && numDigits < basicLength ) {
+                    int hex = toHex( color[pos] );
+                    colors[component] = (colors[component] << 4);
+                    if ( hex > 0 ) {
+                        colors[component] += hex;
+                        maxDigit = QMIN( maxDigit, numDigits );
+                    }
+                    numDigits++;
+                    pos++;
+                }
+                while ( numDigits++ < basicLength )
+                    colors[component] <<= 4;
+                component++;
+            }
+            maxDigit = basicLength - maxDigit;
+            // 	    qDebug("color is %x %x %x, maxDigit=%d",  colors[0], colors[1], colors[2], maxDigit );
+
+            // normalize to 00-ff. The highest filled digit counts, minimum is 2 digits
+            maxDigit -= 2;
+            colors[0] >>= 4*maxDigit;
+            colors[1] >>= 4*maxDigit;
+            colors[2] >>= 4*maxDigit;
+            // 	    qDebug("normalized color is %x %x %x",  colors[0], colors[1], colors[2] );
+            // 	assert( colors[0] < 0x100 && colors[1] < 0x100 && colors[2] < 0x100 );
+
+            color.sprintf("#%02x%02x%02x", colors[0], colors[1], colors[2] );
+            // 	    qDebug( "trying to add fixed color string '%s'", color.latin1() );
+            if ( m_styleDecls->setProperty(id, DOMString(color), false, true) )
+                return;
+        }
+    }
+    m_styleDecls->setProperty(id, CSS_VAL_BLACK, false, true);
+}
+
 void HTMLElementImpl::removeCSSProperty(int id)
 {
     if(!m_styleDecls)
diff --git a/WebCore/khtml/html/html_elementimpl.h b/WebCore/khtml/html/html_elementimpl.h
index 106cee4..482648f 100644
--- a/WebCore/khtml/html/html_elementimpl.h
+++ b/WebCore/khtml/html/html_elementimpl.h
@@ -50,6 +50,7 @@ public:
     void addCSSLength(int id, const DOMString &value);
     void addCSSProperty(int id, const DOMString &value);
     void addCSSProperty(int id, int value);
+    void addHTMLColor( int id, const DOMString &c );
     void removeCSSProperty(int id);
 
     DOMString innerHTML() const;
diff --git a/WebCore/khtml/html/html_inlineimpl.cpp b/WebCore/khtml/html/html_inlineimpl.cpp
index f05a297..ae0b7cb 100644
--- a/WebCore/khtml/html/html_inlineimpl.cpp
+++ b/WebCore/khtml/html/html_inlineimpl.cpp
@@ -315,9 +315,7 @@ void HTMLFontElementImpl::parseAttribute(AttributeImpl *attr)
         break;
     }
     case ATTR_COLOR:
-        addCSSProperty(CSS_PROP_COLOR, attr->value());
-        // HTML4 compatibility hack
-        addCSSProperty(CSS_PROP_TEXT_DECORATION_COLOR, attr->value());
+        addHTMLColor(CSS_PROP_COLOR, attr->value());
         break;
     case ATTR_FACE:
         addCSSProperty(CSS_PROP_FONT_FAMILY, attr->value());
diff --git a/WebCore/khtml/html/html_tableimpl.cpp b/WebCore/khtml/html/html_tableimpl.cpp
index 9abb1b4..0426180 100644
--- a/WebCore/khtml/html/html_tableimpl.cpp
+++ b/WebCore/khtml/html/html_tableimpl.cpp
@@ -421,13 +421,13 @@ void HTMLTableElementImpl::parseAttribute(AttributeImpl *attr)
     }
     case ATTR_BGCOLOR:
         if (!attr->value().isEmpty())
-            addCSSProperty(CSS_PROP_BACKGROUND_COLOR, attr->value());
+            addHTMLColor(CSS_PROP_BACKGROUND_COLOR, attr->value());
         else
             removeCSSProperty(CSS_PROP_BACKGROUND_COLOR);
         break;
     case ATTR_BORDERCOLOR:
         if(!attr->value().isEmpty()) {
-            addCSSProperty(CSS_PROP_BORDER_COLOR, attr->value());
+            addHTMLColor(CSS_PROP_BORDER_COLOR, attr->value());
             addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
             addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
             addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
@@ -536,8 +536,8 @@ void HTMLTableElementImpl::attach()
         // only difference to 100% correct is that in strict mode <font> elements are propagated into tables.
         if ( getDocument()->inQuirksMode() ) {
             addCSSProperty( CSS_PROP_FONT_SIZE, CSS_VAL_MEDIUM );
-            addCSSProperty( CSS_PROP_COLOR, getDocument()->textColor() );
-            addCSSProperty( CSS_PROP_FONT_FAMILY, "konq_body" );
+            addCSSProperty( CSS_PROP_COLOR, CSS_VAL__KONQ_TEXT );
+            addCSSProperty( CSS_PROP_FONT_FAMILY, CSS_VAL__KONQ_BODY );
         }
         
         if (!m_noBorder) {
@@ -562,7 +562,7 @@ void HTMLTablePartElementImpl::parseAttribute(AttributeImpl *attr)
     {
     case ATTR_BGCOLOR:
         if (attr->val())
-            addCSSProperty(CSS_PROP_BACKGROUND_COLOR, attr->value() );
+            addHTMLColor(CSS_PROP_BACKGROUND_COLOR, attr->value() );
         else
             removeCSSProperty(CSS_PROP_BACKGROUND_COLOR);
         break;
@@ -580,7 +580,7 @@ void HTMLTablePartElementImpl::parseAttribute(AttributeImpl *attr)
     case ATTR_BORDERCOLOR:
     {
         if(!attr->value().isEmpty()) {
-            addCSSProperty(CSS_PROP_BORDER_COLOR, attr->value());
+            addHTMLColor(CSS_PROP_BORDER_COLOR, attr->value());
             addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
             addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
             addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
@@ -600,8 +600,9 @@ void HTMLTablePartElementImpl::parseAttribute(AttributeImpl *attr)
     {
         DOMString v = attr->value();
         if ( strcasecmp( attr->value(), "middle" ) == 0 || strcasecmp( attr->value(), "center" ) == 0 )
-            v = "-konq-center";
-        addCSSProperty(CSS_PROP_TEXT_ALIGN, v);
+            addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KONQ_CENTER);
+        else
+            addCSSProperty(CSS_PROP_TEXT_ALIGN, v);
         break;
     }
     case ATTR_HEIGHT:
@@ -857,7 +858,7 @@ void HTMLTableCellElementImpl::parseAttribute(AttributeImpl *attr)
         break;
     case ATTR_NOWRAP:
         if (attr->val() != 0)
-            addCSSProperty(CSS_PROP_WHITE_SPACE, "-konq-nowrap");
+            addCSSProperty(CSS_PROP_WHITE_SPACE, CSS_VAL__KONQ_NOWRAP);
         else
             removeCSSProperty(CSS_PROP_WHITE_SPACE);
         break;
diff --git a/WebCore/khtml/khtml_part.cpp b/WebCore/khtml/khtml_part.cpp
index 5449d04..234a9c3 100644
--- a/WebCore/khtml/khtml_part.cpp
+++ b/WebCore/khtml/khtml_part.cpp
@@ -1955,6 +1955,8 @@ bool KHTMLPart::gotoAnchor( const QString &name )
   NodeImpl *n = anchors->namedItem(name, !d->m_doc->inQuirksMode());
   anchors->deref();
 
+  d->m_doc->setCSSTarget(n); // Setting to null will clear the current target.
+  
   if(!n) {
       kdDebug(6050) << "KHTMLPart::gotoAnchor node '" << name << "' not found" << endl;
       return false;
diff --git a/WebCore/khtml/misc/helper.h b/WebCore/khtml/misc/helper.h
index cbfc868..cc3b345 100644
--- a/WebCore/khtml/misc/helper.h
+++ b/WebCore/khtml/misc/helper.h
@@ -29,6 +29,11 @@ class QPainter;
 
 namespace khtml
 {
+    const QRgb transparentColor = 0x00000000;
+    const QRgb invalidColor     = 0x00000001;
+    const QRgb invertedColor    = 0x00000002;
+    const QRgb defaultTextColor = 0x00000003;
+    
     void setNamedColor(QColor &color, const QString &name);
 
     extern QPainter *printpainter;
diff --git a/WebCore/khtml/rendering/render_body.cpp b/WebCore/khtml/rendering/render_body.cpp
index e27e3a5..8b3738e 100644
--- a/WebCore/khtml/rendering/render_body.cpp
+++ b/WebCore/khtml/rendering/render_body.cpp
@@ -47,7 +47,7 @@ void RenderBody::setStyle(RenderStyle* style)
 //     qDebug("RenderBody::setStyle()");
     style->setDisplay(BLOCK); // Don't allow RenderBody to be inline at the moment.
     RenderBlock::setStyle(style);
-    element()->getDocument()->setTextColor( DOMString( style->color().name() ) );
+    element()->getDocument()->setTextColor( style->color() );
     scrollbarsStyled = false;
 }
 
diff --git a/WebCore/khtml/rendering/render_list.cpp b/WebCore/khtml/rendering/render_list.cpp
index 62e781c..dc87128 100644
--- a/WebCore/khtml/rendering/render_list.cpp
+++ b/WebCore/khtml/rendering/render_list.cpp
@@ -586,17 +586,12 @@ void RenderListMarker::calcWidth()
 
 short RenderListMarker::lineHeight(bool b) const
 {
-    if (m_listImage)
-        return height()+marginTop()+marginBottom();
-    return RenderBox::lineHeight(b);
+    return height();
 }
 
 short RenderListMarker::baselinePosition(bool b) const
 {
-    if (m_listImage)
-        return height()+marginTop()+marginBottom();
-    // FIXME: This should one day really align.
-    return RenderBox::baselinePosition(b);
+    return height();
 }
 
 bool RenderListMarker::isInside() const
diff --git a/WebCore/khtml/rendering/render_style.cpp b/WebCore/khtml/rendering/render_style.cpp
index 486b3cd..36a7d3a 100644
--- a/WebCore/khtml/rendering/render_style.cpp
+++ b/WebCore/khtml/rendering/render_style.cpp
@@ -468,16 +468,24 @@ void RenderStyle::setClip( Length top, Length right, Length bottom, Length left
     data->clip.left = left;
 }
 
-void RenderStyle::setContent(DOM::DOMStringImpl* s)
+void RenderStyle::setContent(DOM::DOMStringImpl* s, bool add)
 {
     if ( !content )
 	content = new ContentData;
-    else
+    else if (!add)
 	content->clearContent();
     
     if (!s)
         s = new DOM::DOMStringImpl("");
-    content->_content.text = s;
+
+    if (add) {
+        DOM::DOMStringImpl* oldStr = content->_content.text;
+        content->_content.text = oldStr->copy();
+        content->_content.text->append(s);
+        oldStr->deref();
+    }
+    else
+        content->_content.text = s;
     content->_content.text->ref();
         
     content->_contentType = CONTENT_TEXT;
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index 6cda99b..ce7bc75 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -911,7 +911,7 @@ public:
 	    return 0;
     }
 
-    void setContent(DOM::DOMStringImpl* s);
+    void setContent(DOM::DOMStringImpl* s, bool add = false);
     void setContent(CachedObject* o);
 
     bool inheritedNotEqual( RenderStyle *other ) const;
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 7010a78..676e8dd 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -269,7 +269,7 @@ DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v)
     m_implementation->ref();
     pMode = Strict;
     hMode = XHtml;
-    m_textColor = "#000000";
+    m_textColor = Qt::black;
     m_elementNames = 0;
     m_elementNameAlloc = 0;
     m_elementNameCount = 0;
@@ -297,6 +297,8 @@ DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v)
                                             !inQuirksMode() );
     m_windowEventListeners.setAutoDelete(true);
     m_pendingStylesheets = 0;
+
+    m_cssTarget = 0;
 }
 
 DocumentImpl::~DocumentImpl()
@@ -2046,6 +2048,20 @@ void DocumentImpl::setFocusNode(NodeImpl *newFocusNode)
     }
 }
 
+void DocumentImpl::setCSSTarget(NodeImpl* n)
+{
+    if (m_cssTarget)
+        m_cssTarget->setChanged();
+    m_cssTarget = n;
+    if (n)
+        n->setChanged();
+}
+
+NodeImpl* DocumentImpl::getCSSTarget()
+{
+    return m_cssTarget;
+}
+
 void DocumentImpl::attachNodeIterator(NodeIteratorImpl *ni)
 {
     m_nodeIterators.append(ni);
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 5badb0d..4f71172 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -307,8 +307,8 @@ public:
     void setParsing(bool b) { m_bParsing = b; }
     bool parsing() const { return m_bParsing; }
 
-    void setTextColor( DOMString color ) { m_textColor = color; }
-    DOMString textColor() const { return m_textColor; }
+    void setTextColor( QColor color ) { m_textColor = color; }
+    QColor textColor() const { return m_textColor; }
 
     // internal
     NodeImpl *findElement( Id id );
@@ -346,6 +346,10 @@ public:
     NodeImpl *focusNode() const { return m_focusNode; }
     void setFocusNode(NodeImpl *newFocusNode);
 
+    // Updates for :target (CSS3 selector).
+    void setCSSTarget(NodeImpl* n);
+    NodeImpl* getCSSTarget();
+    
     bool isDocumentChanged()	{ return m_docChanged; }
     virtual void setDocumentChanged(bool);
     void attachNodeIterator(NodeIteratorImpl *ni);
@@ -460,7 +464,7 @@ protected:
     ParseMode pMode;
     HTMLMode hMode;
 
-    DOMString m_textColor;
+    QColor m_textColor;
     NodeImpl *m_focusNode;
 
     // ### replace me with something more efficient
@@ -504,6 +508,8 @@ protected:
     QPtrList<khtml::RenderImage> m_imageLoadEventDispatchingList;
     int m_imageLoadEventTimer;
 
+    NodeImpl* m_cssTarget;
+    
 #if APPLE_CHANGES
 public:
     KWQSignal m_finishedParsing;
diff --git a/WebCore/kwq/KWQChar.mm b/WebCore/kwq/KWQChar.mm
index f5c7e5f..6c5d930 100644
--- a/WebCore/kwq/KWQChar.mm
+++ b/WebCore/kwq/KWQChar.mm
@@ -41,16 +41,6 @@ static CFMutableStringRef GetScratchUniCharString()
 
 const QChar QChar::null;
 
-bool QChar::isSpace() const
-{
-    // Use isspace() for basic latin1.  This will include newlines, which
-    // aren't included in unicode DirWS.
-    if (c <= 0x7F) {
-        return isspace(c);
-    }
-    return direction() == DirWS;
-}
-
 bool QChar::isDigit() const
 {
     static CFCharacterSetRef set = CFCharacterSetGetPredefined(kCFCharacterSetDecimalDigit);
@@ -102,11 +92,6 @@ QChar QChar::upper() const
     return scratchUniChar;
 }
 
-QChar::Direction QChar::direction() const
-{
-    return (QChar::Direction)WebCoreUnicodeDirectionFunction(c);
-}
-
 bool QChar::mirrored() const
 {
     return WebCoreUnicodeMirroredFunction(c);
diff --git a/WebCore/kwq/KWQColor.h b/WebCore/kwq/KWQColor.h
index d21674a..6e91dfe 100644
--- a/WebCore/kwq/KWQColor.h
+++ b/WebCore/kwq/KWQColor.h
@@ -44,10 +44,11 @@ const QRgb KWQInvalidColor = 0x40000000;
 class QColor {
 public:
     QColor() : color(KWQInvalidColor) { }
+    QColor(QRgb col) :color(col) {}
     QColor(int r, int g, int b) : color(qRgb(r, g, b)) { }
     explicit QColor(const QString &);
     QColor(const char *); // can't be explicit because of helper.cpp
-
+    
     QString name() const;
     void setNamedColor(const QString&);
 
diff --git a/WebCore/kwq/KWQKStandardDirs.mm b/WebCore/kwq/KWQKStandardDirs.mm
index 04d3831..498b585 100644
--- a/WebCore/kwq/KWQKStandardDirs.mm
+++ b/WebCore/kwq/KWQKStandardDirs.mm
@@ -32,7 +32,13 @@
 
 QString locate(const char *type, const QString &filename, const KInstance *instance)
 {
+    // FIXME: Eliminate this hard-coding at some point?
+    bool quirk = true;
+    if (filename.contains("html4"))
+        quirk = false;
     NSBundle *bundle = [NSBundle bundleForClass:[KWQKStandardDirsBundleDummy class]];
+    if (quirk)
+        return QString::fromNSString([bundle pathForResource:@"quirks" ofType:@"css"]);
     return QString::fromNSString([bundle pathForResource:@"html4" ofType:@"css"]);
 }
 
diff --git a/WebCore/kwq/KWQPainter.mm b/WebCore/kwq/KWQPainter.mm
index df9d4d0..87aa13c 100644
--- a/WebCore/kwq/KWQPainter.mm
+++ b/WebCore/kwq/KWQPainter.mm
@@ -164,7 +164,7 @@ void QPainter::_setColorFromPen()
     [data->state.pen.color().getNSColor() set];
 }
 
-// This is only used to draw borders around text, and lines over text.
+// This is only used to draw borders.
 void QPainter::drawLine(int x1, int y1, int x2, int y2)
 {
     if (data->state.paintingDisabled)
@@ -176,45 +176,113 @@ void QPainter::drawLine(int x1, int y1, int x2, int y2)
     float width = data->state.pen.width();
     if (width < 1)
         width = 1;
+
+    NSPoint p1 = NSMakePoint(x1, y1);
+    NSPoint p2 = NSMakePoint(x2, y2);
     
-    NSPoint p1 = NSMakePoint(x1 + width/2, y1 + width/2);
-    NSPoint p2 = NSMakePoint(x2 + width/2, y2 + width/2);
+    // For odd widths, we add in 0.5 to the appropriate x/y so that the float arithmetic
+    // works out.  For example, with a border width of 3, KHTML will pass us (y1+y2)/2, e.g.,
+    // (50+53)/2 = 103/2 = 51 when we want 51.5.  It is always true that an even width gave
+    // us a perfect position, but an odd width gave us a position that is off by exactly 0.5.
+    if (penStyle == DotLine || penStyle == DashLine) {
+        if (x1 == x2) {
+            p1.y += width;
+            p2.y -= width;
+        }
+        else {
+            p1.x += width;
+            p2.x -= width;
+        }
+    }
     
-    // This hack makes sure we don't end up with lines hanging off the ends, while
-    // keeping lines horizontal or vertical.
-    if (x1 != x2)
-        p2.x -= width;
-    if (y1 != y2)
-        p2.y -= width;
+    if (((int)width)%2) {
+        if (x1 == x2) {
+            // We're a vertical line.  Adjust our x.
+            p1.x += 0.5;
+            p2.x += 0.5;
+        }
+        else {
+            // We're a horizontal line. Adjust our y.
+            p1.y += 0.5;
+            p2.y += 0.5;
+        }
+    }
     
     NSBezierPath *path = [[NSBezierPath alloc] init];
     [path setLineWidth:width];
 
+    int patWidth = 0;
     switch (penStyle) {
     case NoPen:
     case SolidLine:
         break;
     case DotLine:
-        {
-            const float dottedLine[2] = { 3, 3 };
-            [path setLineDash:dottedLine count:2 phase:0];
-        }
+        patWidth = (int)width;
         break;
     case DashLine:
-        {
-            const float dashedLine[2] = { 4, 2 };
-            [path setLineDash:dashedLine count:2 phase:0];
-        }
+        patWidth = 3*(int)width;
         break;
     }
 
+    _setColorFromPen();
+    NSGraphicsContext *graphicsContext = [NSGraphicsContext currentContext];
+    BOOL flag = [graphicsContext shouldAntialias];
+    [graphicsContext setShouldAntialias: NO];
+    
+    if (patWidth) {
+        // Do a rect fill of our endpoints.  This ensures we always have the
+        // appearance of being a border.  We then draw the actual dotted/dashed line.
+        if (x1 == x2) {
+            NSRectFill(NSMakeRect(p1.x-width/2, p1.y-width, width, width));
+            NSRectFill(NSMakeRect(p2.x-width/2, p2.y, width, width));
+        }
+        else {
+            NSRectFill(NSMakeRect(p1.x-width, p1.y-width/2, width, width));
+            NSRectFill(NSMakeRect(p2.x, p2.y-width/2, width, width));
+        }
+        
+        // Example: 80 pixels with a width of 30 pixels.
+        // Remainder is 20.  The maximum pixels of line we could paint
+        // will be 50 pixels.
+        int distance = ((x1 == x2) ? (y2 - y1) : (x2 - x1)) - 2*(int)width;
+        int remainder = distance%patWidth;
+        int coverage = distance-remainder;
+        int numSegments = coverage/patWidth;
+
+        float patternOffset = 0;
+        // Special case 1px dotted borders for speed.
+        if (patWidth == 1)
+            patternOffset = 1.0;
+        else {
+            bool evenNumberOfSegments = numSegments%2 == 0;
+            if (remainder)
+                evenNumberOfSegments = !evenNumberOfSegments;
+            if (evenNumberOfSegments) {
+                if (remainder) {
+                    patternOffset += patWidth - remainder;
+                    patternOffset += remainder/2;
+                }
+                else
+                    patternOffset = patWidth/2;
+            }
+            else if (!evenNumberOfSegments) {
+                if (remainder)
+                    patternOffset = (patWidth - remainder)/2;
+            }
+        }
+        
+        const float dottedLine[2] = { patWidth, patWidth };
+        [path setLineDash:dottedLine count:2 phase:patternOffset];
+    }
+    
     [path moveToPoint:p1];
     [path lineToPoint:p2];
 
-    _setColorFromPen();
     [path stroke];
     
     [path release];
+
+    [graphicsContext setShouldAntialias: flag];
 }
 
 
diff --git a/WebCore/kwq/KWQString.h b/WebCore/kwq/KWQString.h
index 2f76c19..e5fa183 100644
--- a/WebCore/kwq/KWQString.h
+++ b/WebCore/kwq/KWQString.h
@@ -29,6 +29,7 @@
 #include <CoreFoundation/CoreFoundation.h>
 
 #include "KWQCString.h"
+#include "WebCoreUnicode.h"
 
 // Make htmltokenizer.cpp happy
 #define QT_VERSION 300
@@ -64,7 +65,15 @@ public:
     uchar row() const;
     char latin1() const;
     bool isNull() const;
-    bool isSpace() const;
+    bool isSpace() const
+    {
+        // Use isspace() for basic latin1.  This will include newlines, which
+        // aren't included in unicode DirWS.
+        if (c <= 0x7F) {
+            return isspace(c);
+        }
+        return direction() == DirWS;
+    }
     bool isDigit() const;
     bool isLetter() const;
     bool isNumber() const;
@@ -73,7 +82,11 @@ public:
     int digitValue() const;
     QChar lower() const;
     QChar upper() const;
-    Direction direction() const;
+    Direction direction() const
+    {
+        return (QChar::Direction)WebCoreUnicodeDirectionFunction(c);
+    }
+    
     bool mirrored() const;
     QChar mirroredChar() const;
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list