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


The following commit has been merged in the debian/unstable branch:
commit 377ce05d79cc30228a313bbb3598c8ae00760bce
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Tue Feb 10 20:52:13 2004 +0000

    	Improve attribute parsing of mapped attributes (that map to CSS properties) so that they can pull the
    	style declarations from a global cache.
    
    	Made RenderStyles be arena allocated as well.
    
            Reviewed by darin
    
            * khtml/css/css_valueimpl.cpp:
            (CSSImageValueImpl::CSSImageValueImpl):
            (CSSImageValueImpl::image):
            * khtml/css/css_valueimpl.h:
            * khtml/css/cssstyleselector.cpp:
            (khtml::CSSStyleSelector::initForStyleResolve):
            (khtml::CSSStyleSelector::styleForElement):
            (khtml::CSSStyleSelector::pseudoStyleForElement):
            (khtml::CSSStyleSelector::applyProperty):
            * khtml/css/cssstyleselector.h:
            * khtml/css/html4.css:
            * khtml/css/quirks.css:
            * khtml/dom/dom_element.cpp:
            (Element::style):
            * khtml/dom/html_element.cpp:
            * khtml/dom/html_element.h:
            * khtml/html/html_baseimpl.cpp:
            (HTMLBodyElementImpl::HTMLBodyElementImpl):
            (HTMLBodyElementImpl::mapToEntry):
            (HTMLBodyElementImpl::parseHTMLAttribute):
            (HTMLBodyElementImpl::insertedIntoDocument):
            (HTMLFrameElementImpl::parseHTMLAttribute):
            (HTMLFrameSetElementImpl::parseHTMLAttribute):
            (HTMLIFrameElementImpl::mapToEntry):
            (HTMLIFrameElementImpl::parseHTMLAttribute):
            * khtml/html/html_baseimpl.h:
            * khtml/html/html_blockimpl.cpp:
            (HTMLDivElementImpl::mapToEntry):
            (HTMLDivElementImpl::parseHTMLAttribute):
            (HTMLHRElementImpl::mapToEntry):
            (HTMLHRElementImpl::parseHTMLAttribute):
            (HTMLParagraphElementImpl::mapToEntry):
            (HTMLParagraphElementImpl::parseHTMLAttribute):
            (HTMLMarqueeElementImpl::mapToEntry):
            (HTMLMarqueeElementImpl::parseHTMLAttribute):
            (HTMLLayerElementImpl::HTMLLayerElementImpl):
            (HTMLLayerElementImpl::id):
            * khtml/html/html_blockimpl.h:
            * khtml/html/html_documentimpl.cpp:
            (HTMLDocumentImpl::determineParseMode):
            * khtml/html/html_documentimpl.h:
            * khtml/html/html_elementimpl.cpp:
            (CSSMappedAttributeDeclarationImpl::~CSSMappedAttributeDeclarationImpl):
            (HTMLElementImpl::getMappedAttributeDecl):
            (HTMLElementImpl::setMappedAttributeDecl):
            (HTMLElementImpl::removeMappedAttributeDecl):
            (HTMLAttributeImpl::~HTMLAttributeImpl):
            (HTMLAttributeImpl::clone):
            (m_mappedAttributeCount):
            (HTMLNamedAttrMapImpl::clearAttributes):
            (HTMLElementImpl::HTMLElementImpl):
            (HTMLElementImpl::~HTMLElementImpl):
            (HTMLElementImpl::createAttribute):
            (HTMLElementImpl::createInlineStyleDecl):
            (HTMLElementImpl::attributeChanged):
            (HTMLElementImpl::mapToEntry):
            (HTMLElementImpl::parseHTMLAttribute):
            (HTMLElementImpl::additionalAttributeStyleDecl):
            (isHexDigit):
            (toHex):
            (HTMLElementImpl::addCSSProperty):
            (HTMLElementImpl::addCSSStringProperty):
            (HTMLElementImpl::addCSSImageProperty):
            (HTMLElementImpl::addCSSLength):
            (HTMLElementImpl::addHTMLColor):
            (HTMLElementImpl::createMappedDecl):
            (HTMLElementImpl::addHTMLAlignment):
            (HTMLElementImpl::setContentEditable):
            * khtml/html/html_elementimpl.h:
            (DOM::):
            (DOM::CSSMappedAttributeDeclarationImpl::CSSMappedAttributeDeclarationImpl):
            (DOM::CSSMappedAttributeDeclarationImpl::setMappedState):
            (DOM::HTMLAttributeImpl::HTMLAttributeImpl):
            (DOM::HTMLAttributeImpl::decl):
            (DOM::HTMLAttributeImpl::setDecl):
            (DOM::HTMLNamedAttrMapImpl::hasMappedAttributes):
            (DOM::HTMLNamedAttrMapImpl::declRemoved):
            (DOM::HTMLNamedAttrMapImpl::declAdded):
            (DOM::HTMLNamedAttrMapImpl::attributeItem):
            (DOM::HTMLElementImpl::hasMappedAttributes):
            (DOM::HTMLElementImpl::htmlAttributes):
            (DOM::HTMLElementImpl::inlineStyleDecl):
            * khtml/html/html_formimpl.cpp:
            (HTMLFormElementImpl::parseHTMLAttribute):
            (HTMLGenericFormElementImpl::parseHTMLAttribute):
            (HTMLButtonElementImpl::parseHTMLAttribute):
            (HTMLInputElementImpl::setType):
            (HTMLInputElementImpl::mapToEntry):
            (HTMLInputElementImpl::parseHTMLAttribute):
            (HTMLInputElementImpl::attach):
            (HTMLLabelElementImpl::parseHTMLAttribute):
            (HTMLSelectElementImpl::parseHTMLAttribute):
            (HTMLKeygenElementImpl::parseHTMLAttribute):
            (HTMLOptGroupElementImpl::parseHTMLAttribute):
            (HTMLOptionElementImpl::parseHTMLAttribute):
            (HTMLTextAreaElementImpl::parseHTMLAttribute):
            (HTMLIsIndexElementImpl::parseHTMLAttribute):
            * khtml/html/html_formimpl.h:
            * khtml/html/html_headimpl.cpp:
            (HTMLBaseElementImpl::parseHTMLAttribute):
            (HTMLLinkElementImpl::parseHTMLAttribute):
            (HTMLMetaElementImpl::parseHTMLAttribute):
            (HTMLStyleElementImpl::parseHTMLAttribute):
            * khtml/html/html_headimpl.h:
            * khtml/html/html_imageimpl.cpp:
            (HTMLImageElementImpl::mapToEntry):
            (HTMLImageElementImpl::parseHTMLAttribute):
            (HTMLMapElementImpl::parseHTMLAttribute):
            (HTMLAreaElementImpl::parseHTMLAttribute):
            * khtml/html/html_imageimpl.h:
            * khtml/html/html_inlineimpl.cpp:
            (HTMLAnchorElementImpl::parseHTMLAttribute):
            (HTMLBRElementImpl::mapToEntry):
            (HTMLBRElementImpl::parseHTMLAttribute):
            (HTMLFontElementImpl::mapToEntry):
            (HTMLFontElementImpl::parseHTMLAttribute):
            * khtml/html/html_inlineimpl.h:
            * khtml/html/html_listimpl.cpp:
            (HTMLUListElementImpl::mapToEntry):
            (HTMLUListElementImpl::parseHTMLAttribute):
            (HTMLOListElementImpl::mapToEntry):
            (HTMLOListElementImpl::parseHTMLAttribute):
            (HTMLLIElementImpl::mapToEntry):
            (HTMLLIElementImpl::parseHTMLAttribute):
            * khtml/html/html_listimpl.h:
            * khtml/html/html_objectimpl.cpp:
            (HTMLAppletElementImpl::mapToEntry):
            (HTMLAppletElementImpl::parseHTMLAttribute):
            (HTMLEmbedElementImpl::HTMLEmbedElementImpl):
            (HTMLEmbedElementImpl::mapToEntry):
            (HTMLEmbedElementImpl::parseHTMLAttribute):
            (HTMLEmbedElementImpl::attach):
            (HTMLObjectElementImpl::mapToEntry):
            (HTMLObjectElementImpl::parseHTMLAttribute):
            (HTMLParamElementImpl::parseHTMLAttribute):
            * khtml/html/html_objectimpl.h:
            * khtml/html/html_tableimpl.cpp:
            (HTMLTableElementImpl::HTMLTableElementImpl):
            (HTMLTableElementImpl::~HTMLTableElementImpl):
            (HTMLTableElementImpl::mapToEntry):
            (HTMLTableElementImpl::parseHTMLAttribute):
            (HTMLTableElementImpl::additionalAttributeStyleDecl):
            (HTMLTableElementImpl::getSharedCellDecl):
            (HTMLTableElementImpl::attach):
            (HTMLTablePartElementImpl::mapToEntry):
            (HTMLTablePartElementImpl::parseHTMLAttribute):
            (HTMLTableCellElementImpl::mapToEntry):
            (HTMLTableCellElementImpl::parseHTMLAttribute):
            (HTMLTableCellElementImpl::additionalAttributeStyleDecl):
            (HTMLTableCellElementImpl::attach):
            (HTMLTableColElementImpl::mapToEntry):
            (HTMLTableColElementImpl::parseHTMLAttribute):
            (HTMLTableCaptionElementImpl::mapToEntry):
            (HTMLTableCaptionElementImpl::parseHTMLAttribute):
            * khtml/html/html_tableimpl.h:
            * khtml/html/htmlparser.cpp:
            (KHTMLParser::insertNode):
            (KHTMLParser::getElement):
            * khtml/html/htmltokenizer.h:
            (khtml::Token::addAttribute):
            * khtml/misc/htmlattrs.c:
            (hash_attr):
            (findAttr):
            * khtml/misc/htmlattrs.h:
            * khtml/misc/htmlattrs.in:
            * khtml/rendering/render_block.cpp:
            (khtml::RenderBlock::setStyle):
            (khtml::RenderBlock::updateFirstLetter):
            * khtml/rendering/render_container.cpp:
            (RenderContainer::addChild):
            (RenderContainer::updatePseudoChild):
            * khtml/rendering/render_frames.cpp:
            (RenderPartObject::updateWidget):
            * khtml/rendering/render_inline.cpp:
            (RenderInline::addChildToFlow):
            * khtml/rendering/render_list.cpp:
            (RenderListItem::setStyle):
            * khtml/rendering/render_object.cpp:
            (RenderObject::~RenderObject):
            (RenderObject::createAnonymousBlock):
            (RenderObject::setStyle):
            (RenderObject::remove):
            * khtml/rendering/render_style.cpp:
            (throw):
            (RenderStyle::operator delete):
            (RenderStyle::arenaDelete):
            (RenderStyle::RenderStyle):
            (RenderStyle::~RenderStyle):
            (RenderStyle::addPseudoStyle):
            * khtml/rendering/render_style.h:
            (khtml::RenderStyle::ref):
            (khtml::RenderStyle::deref):
            (khtml::RenderStyle::hasOneRef):
            (khtml::RenderStyle::refCount):
            * khtml/rendering/render_table.cpp:
            (RenderTable::addChild):
            (RenderTableSection::addChild):
            (RenderTableRow::addChild):
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::DocumentImpl):
            (DocumentImpl::createAttribute):
            (DocumentImpl::recalcStyle):
            * khtml/xml/dom_docimpl.h:
            * khtml/xml/dom_elementimpl.cpp:
            (AttributeImpl::clone):
            (AttrImpl::setValue):
            (AttrImpl::cloneNode):
            (ElementImpl::setAttribute):
            (ElementImpl::createAttribute):
            (ElementImpl::setAttributeMap):
            (ElementImpl::recalcStyle):
            (NamedAttrMapImpl::~NamedAttrMapImpl):
            (NamedAttrMapImpl::operator=):
            (NamedAttrMapImpl::addAttribute):
            (NamedAttrMapImpl::removeAttribute):
            * khtml/xml/dom_elementimpl.h:
            (DOM::AttributeImpl::~AttributeImpl):
            (DOM::ElementImpl::attributeChanged):
            (DOM::NamedAttrMapImpl::length):
            * khtml/xml/dom_nodeimpl.cpp:
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@6055 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 6fa71e7..5e377d1 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,233 @@
+2004-02-10  David Hyatt  <hyatt at apple.com>
+
+	Improve attribute parsing of mapped attributes (that map to CSS properties) so that they can pull the
+	style declarations from a global cache.
+
+	Made RenderStyles be arena allocated as well.
+	
+        Reviewed by darin
+
+        * khtml/css/css_valueimpl.cpp:
+        (CSSImageValueImpl::CSSImageValueImpl):
+        (CSSImageValueImpl::image):
+        * khtml/css/css_valueimpl.h:
+        * khtml/css/cssstyleselector.cpp:
+        (khtml::CSSStyleSelector::initForStyleResolve):
+        (khtml::CSSStyleSelector::styleForElement):
+        (khtml::CSSStyleSelector::pseudoStyleForElement):
+        (khtml::CSSStyleSelector::applyProperty):
+        * khtml/css/cssstyleselector.h:
+        * khtml/css/html4.css:
+        * khtml/css/quirks.css:
+        * khtml/dom/dom_element.cpp:
+        (Element::style):
+        * khtml/dom/html_element.cpp:
+        * khtml/dom/html_element.h:
+        * khtml/html/html_baseimpl.cpp:
+        (HTMLBodyElementImpl::HTMLBodyElementImpl):
+        (HTMLBodyElementImpl::mapToEntry):
+        (HTMLBodyElementImpl::parseHTMLAttribute):
+        (HTMLBodyElementImpl::insertedIntoDocument):
+        (HTMLFrameElementImpl::parseHTMLAttribute):
+        (HTMLFrameSetElementImpl::parseHTMLAttribute):
+        (HTMLIFrameElementImpl::mapToEntry):
+        (HTMLIFrameElementImpl::parseHTMLAttribute):
+        * khtml/html/html_baseimpl.h:
+        * khtml/html/html_blockimpl.cpp:
+        (HTMLDivElementImpl::mapToEntry):
+        (HTMLDivElementImpl::parseHTMLAttribute):
+        (HTMLHRElementImpl::mapToEntry):
+        (HTMLHRElementImpl::parseHTMLAttribute):
+        (HTMLParagraphElementImpl::mapToEntry):
+        (HTMLParagraphElementImpl::parseHTMLAttribute):
+        (HTMLMarqueeElementImpl::mapToEntry):
+        (HTMLMarqueeElementImpl::parseHTMLAttribute):
+        (HTMLLayerElementImpl::HTMLLayerElementImpl):
+        (HTMLLayerElementImpl::id):
+        * khtml/html/html_blockimpl.h:
+        * khtml/html/html_documentimpl.cpp:
+        (HTMLDocumentImpl::determineParseMode):
+        * khtml/html/html_documentimpl.h:
+        * khtml/html/html_elementimpl.cpp:
+        (CSSMappedAttributeDeclarationImpl::~CSSMappedAttributeDeclarationImpl):
+        (HTMLElementImpl::getMappedAttributeDecl):
+        (HTMLElementImpl::setMappedAttributeDecl):
+        (HTMLElementImpl::removeMappedAttributeDecl):
+        (HTMLAttributeImpl::~HTMLAttributeImpl):
+        (HTMLAttributeImpl::clone):
+        (m_mappedAttributeCount):
+        (HTMLNamedAttrMapImpl::clearAttributes):
+        (HTMLElementImpl::HTMLElementImpl):
+        (HTMLElementImpl::~HTMLElementImpl):
+        (HTMLElementImpl::createAttribute):
+        (HTMLElementImpl::createInlineStyleDecl):
+        (HTMLElementImpl::attributeChanged):
+        (HTMLElementImpl::mapToEntry):
+        (HTMLElementImpl::parseHTMLAttribute):
+        (HTMLElementImpl::additionalAttributeStyleDecl):
+        (isHexDigit):
+        (toHex):
+        (HTMLElementImpl::addCSSProperty):
+        (HTMLElementImpl::addCSSStringProperty):
+        (HTMLElementImpl::addCSSImageProperty):
+        (HTMLElementImpl::addCSSLength):
+        (HTMLElementImpl::addHTMLColor):
+        (HTMLElementImpl::createMappedDecl):
+        (HTMLElementImpl::addHTMLAlignment):
+        (HTMLElementImpl::setContentEditable):
+        * khtml/html/html_elementimpl.h:
+        (DOM::):
+        (DOM::CSSMappedAttributeDeclarationImpl::CSSMappedAttributeDeclarationImpl):
+        (DOM::CSSMappedAttributeDeclarationImpl::setMappedState):
+        (DOM::HTMLAttributeImpl::HTMLAttributeImpl):
+        (DOM::HTMLAttributeImpl::decl):
+        (DOM::HTMLAttributeImpl::setDecl):
+        (DOM::HTMLNamedAttrMapImpl::hasMappedAttributes):
+        (DOM::HTMLNamedAttrMapImpl::declRemoved):
+        (DOM::HTMLNamedAttrMapImpl::declAdded):
+        (DOM::HTMLNamedAttrMapImpl::attributeItem):
+        (DOM::HTMLElementImpl::hasMappedAttributes):
+        (DOM::HTMLElementImpl::htmlAttributes):
+        (DOM::HTMLElementImpl::inlineStyleDecl):
+        * khtml/html/html_formimpl.cpp:
+        (HTMLFormElementImpl::parseHTMLAttribute):
+        (HTMLGenericFormElementImpl::parseHTMLAttribute):
+        (HTMLButtonElementImpl::parseHTMLAttribute):
+        (HTMLInputElementImpl::setType):
+        (HTMLInputElementImpl::mapToEntry):
+        (HTMLInputElementImpl::parseHTMLAttribute):
+        (HTMLInputElementImpl::attach):
+        (HTMLLabelElementImpl::parseHTMLAttribute):
+        (HTMLSelectElementImpl::parseHTMLAttribute):
+        (HTMLKeygenElementImpl::parseHTMLAttribute):
+        (HTMLOptGroupElementImpl::parseHTMLAttribute):
+        (HTMLOptionElementImpl::parseHTMLAttribute):
+        (HTMLTextAreaElementImpl::parseHTMLAttribute):
+        (HTMLIsIndexElementImpl::parseHTMLAttribute):
+        * khtml/html/html_formimpl.h:
+        * khtml/html/html_headimpl.cpp:
+        (HTMLBaseElementImpl::parseHTMLAttribute):
+        (HTMLLinkElementImpl::parseHTMLAttribute):
+        (HTMLMetaElementImpl::parseHTMLAttribute):
+        (HTMLStyleElementImpl::parseHTMLAttribute):
+        * khtml/html/html_headimpl.h:
+        * khtml/html/html_imageimpl.cpp:
+        (HTMLImageElementImpl::mapToEntry):
+        (HTMLImageElementImpl::parseHTMLAttribute):
+        (HTMLMapElementImpl::parseHTMLAttribute):
+        (HTMLAreaElementImpl::parseHTMLAttribute):
+        * khtml/html/html_imageimpl.h:
+        * khtml/html/html_inlineimpl.cpp:
+        (HTMLAnchorElementImpl::parseHTMLAttribute):
+        (HTMLBRElementImpl::mapToEntry):
+        (HTMLBRElementImpl::parseHTMLAttribute):
+        (HTMLFontElementImpl::mapToEntry):
+        (HTMLFontElementImpl::parseHTMLAttribute):
+        * khtml/html/html_inlineimpl.h:
+        * khtml/html/html_listimpl.cpp:
+        (HTMLUListElementImpl::mapToEntry):
+        (HTMLUListElementImpl::parseHTMLAttribute):
+        (HTMLOListElementImpl::mapToEntry):
+        (HTMLOListElementImpl::parseHTMLAttribute):
+        (HTMLLIElementImpl::mapToEntry):
+        (HTMLLIElementImpl::parseHTMLAttribute):
+        * khtml/html/html_listimpl.h:
+        * khtml/html/html_objectimpl.cpp:
+        (HTMLAppletElementImpl::mapToEntry):
+        (HTMLAppletElementImpl::parseHTMLAttribute):
+        (HTMLEmbedElementImpl::HTMLEmbedElementImpl):
+        (HTMLEmbedElementImpl::mapToEntry):
+        (HTMLEmbedElementImpl::parseHTMLAttribute):
+        (HTMLEmbedElementImpl::attach):
+        (HTMLObjectElementImpl::mapToEntry):
+        (HTMLObjectElementImpl::parseHTMLAttribute):
+        (HTMLParamElementImpl::parseHTMLAttribute):
+        * khtml/html/html_objectimpl.h:
+        * khtml/html/html_tableimpl.cpp:
+        (HTMLTableElementImpl::HTMLTableElementImpl):
+        (HTMLTableElementImpl::~HTMLTableElementImpl):
+        (HTMLTableElementImpl::mapToEntry):
+        (HTMLTableElementImpl::parseHTMLAttribute):
+        (HTMLTableElementImpl::additionalAttributeStyleDecl):
+        (HTMLTableElementImpl::getSharedCellDecl):
+        (HTMLTableElementImpl::attach):
+        (HTMLTablePartElementImpl::mapToEntry):
+        (HTMLTablePartElementImpl::parseHTMLAttribute):
+        (HTMLTableCellElementImpl::mapToEntry):
+        (HTMLTableCellElementImpl::parseHTMLAttribute):
+        (HTMLTableCellElementImpl::additionalAttributeStyleDecl):
+        (HTMLTableCellElementImpl::attach):
+        (HTMLTableColElementImpl::mapToEntry):
+        (HTMLTableColElementImpl::parseHTMLAttribute):
+        (HTMLTableCaptionElementImpl::mapToEntry):
+        (HTMLTableCaptionElementImpl::parseHTMLAttribute):
+        * khtml/html/html_tableimpl.h:
+        * khtml/html/htmlparser.cpp:
+        (KHTMLParser::insertNode):
+        (KHTMLParser::getElement):
+        * khtml/html/htmltokenizer.h:
+        (khtml::Token::addAttribute):
+        * khtml/misc/htmlattrs.c:
+        (hash_attr):
+        (findAttr):
+        * khtml/misc/htmlattrs.h:
+        * khtml/misc/htmlattrs.in:
+        * khtml/rendering/render_block.cpp:
+        (khtml::RenderBlock::setStyle):
+        (khtml::RenderBlock::updateFirstLetter):
+        * khtml/rendering/render_container.cpp:
+        (RenderContainer::addChild):
+        (RenderContainer::updatePseudoChild):
+        * khtml/rendering/render_frames.cpp:
+        (RenderPartObject::updateWidget):
+        * khtml/rendering/render_inline.cpp:
+        (RenderInline::addChildToFlow):
+        * khtml/rendering/render_list.cpp:
+        (RenderListItem::setStyle):
+        * khtml/rendering/render_object.cpp:
+        (RenderObject::~RenderObject):
+        (RenderObject::createAnonymousBlock):
+        (RenderObject::setStyle):
+        (RenderObject::remove):
+        * khtml/rendering/render_style.cpp:
+        (throw):
+        (RenderStyle::operator delete):
+        (RenderStyle::arenaDelete):
+        (RenderStyle::RenderStyle):
+        (RenderStyle::~RenderStyle):
+        (RenderStyle::addPseudoStyle):
+        * khtml/rendering/render_style.h:
+        (khtml::RenderStyle::ref):
+        (khtml::RenderStyle::deref):
+        (khtml::RenderStyle::hasOneRef):
+        (khtml::RenderStyle::refCount):
+        * khtml/rendering/render_table.cpp:
+        (RenderTable::addChild):
+        (RenderTableSection::addChild):
+        (RenderTableRow::addChild):
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::DocumentImpl):
+        (DocumentImpl::createAttribute):
+        (DocumentImpl::recalcStyle):
+        * khtml/xml/dom_docimpl.h:
+        * khtml/xml/dom_elementimpl.cpp:
+        (AttributeImpl::clone):
+        (AttrImpl::setValue):
+        (AttrImpl::cloneNode):
+        (ElementImpl::setAttribute):
+        (ElementImpl::createAttribute):
+        (ElementImpl::setAttributeMap):
+        (ElementImpl::recalcStyle):
+        (NamedAttrMapImpl::~NamedAttrMapImpl):
+        (NamedAttrMapImpl::operator=):
+        (NamedAttrMapImpl::addAttribute):
+        (NamedAttrMapImpl::removeAttribute):
+        * khtml/xml/dom_elementimpl.h:
+        (DOM::AttributeImpl::~AttributeImpl):
+        (DOM::ElementImpl::attributeChanged):
+        (DOM::NamedAttrMapImpl::length):
+        * khtml/xml/dom_nodeimpl.cpp:
+
 2004-02-09  Darin Adler  <darin at apple.com>
 
         Reviewed by Dave.
diff --git a/WebCore/khtml/css/css_valueimpl.cpp b/WebCore/khtml/css/css_valueimpl.cpp
index 62e7699..5237936 100644
--- a/WebCore/khtml/css/css_valueimpl.cpp
+++ b/WebCore/khtml/css/css_valueimpl.cpp
@@ -407,7 +407,6 @@ bool CSSStyleDeclarationImpl::parseString( const DOMString &/*string*/, bool )
     // ###
 }
 
-
 // --------------------------------------------------------------------------------------
 
 CSSValueImpl::CSSValueImpl()
@@ -834,17 +833,12 @@ void RectImpl::setLeft( CSSPrimitiveValueImpl *left )
 // -----------------------------------------------------------------
 
 CSSImageValueImpl::CSSImageValueImpl(const DOMString &url, StyleBaseImpl *style)
-    : CSSPrimitiveValueImpl(url, CSSPrimitiveValue::CSS_URI), m_loader(0), m_image(0), m_accessedImage(false)
+    : CSSPrimitiveValueImpl(url, CSSPrimitiveValue::CSS_URI), m_image(0), m_accessedImage(false)
 {
-    StyleBaseImpl *root = style;
-    while (root->parent())
-        root = root->parent();
-    if (root->isCSSStyleSheet())
-        m_loader = static_cast<CSSStyleSheetImpl*>(root)->docLoader();
 }
 
 CSSImageValueImpl::CSSImageValueImpl()
-    : CSSPrimitiveValueImpl(CSS_VAL_NONE), m_loader(0), m_image(0), m_accessedImage(true)
+    : CSSPrimitiveValueImpl(CSS_VAL_NONE), m_image(0), m_accessedImage(true)
 {
 }
 
@@ -853,13 +847,13 @@ CSSImageValueImpl::~CSSImageValueImpl()
     if(m_image) m_image->deref(this);
 }
 
-khtml::CachedImage* CSSImageValueImpl::image()
+khtml::CachedImage* CSSImageValueImpl::image(khtml::DocLoader* loader)
 {
     if (!m_accessedImage) {
         m_accessedImage = true;
 
-        if (m_loader)
-            m_image = m_loader->requestImage(getStringValue());
+        if (loader)
+            m_image = loader->requestImage(getStringValue());
         else
             m_image = khtml::Cache::requestImage(0, getStringValue());
         
diff --git a/WebCore/khtml/css/css_valueimpl.h b/WebCore/khtml/css/css_valueimpl.h
index 912e2ba..7b92b0d 100644
--- a/WebCore/khtml/css/css_valueimpl.h
+++ b/WebCore/khtml/css/css_valueimpl.h
@@ -293,10 +293,9 @@ public:
     CSSImageValueImpl();
     virtual ~CSSImageValueImpl();
 
-    khtml::CachedImage *image();
+    khtml::CachedImage *image(khtml::DocLoader* loader);
 
 protected:
-    khtml::DocLoader* m_loader;
     khtml::CachedImage* m_image;
     bool m_accessedImage;
 };
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 59331ac..53dafc4 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -252,20 +252,6 @@ void CSSStyleSelector::loadDefaultStyle(const KHTMLSettings *s)
     //kdDebug() << "CSSStyleSelector: default style has " << defaultStyle->count() << " elements"<< endl;
 }
 
-void CSSStyleSelector::clear()
-{
-    delete defaultStyle;
-    delete defaultQuirksStyle;
-    delete defaultPrintStyle;
-    delete defaultSheet;
-    delete styleNotYetAvailable;
-    defaultStyle = 0;
-    defaultQuirksStyle = 0;
-    defaultPrintStyle = 0;
-    defaultSheet = 0;
-    styleNotYetAvailable = 0;
-}
-
 void CSSStyleSelector::addMatchedRule(CSSRuleData* rule)
 {
     if (m_matchedRules.size() <= m_matchedRuleCount)
@@ -427,6 +413,11 @@ void CSSStyleSelector::initForStyleResolve(ElementImpl* e, RenderStyle* defaultP
     pseudoStyle = RenderStyle::NOPSEUDO;
     
     element = e;
+    if (element && element->isHTMLElement())
+        htmlElement = static_cast<HTMLElementImpl*>(element);
+    else
+        htmlElement = 0;
+
     parentNode = e->parentNode();
     if (defaultParent)
         parentStyle = defaultParent;
@@ -451,7 +442,7 @@ RenderStyle* CSSStyleSelector::styleForElement(ElementImpl* e, RenderStyle* defa
 {
     if (!e->getDocument()->haveStylesheetsLoaded()) {
         if (!styleNotYetAvailable) {
-            styleNotYetAvailable = new RenderStyle();
+            styleNotYetAvailable = ::new RenderStyle();
             styleNotYetAvailable->setDisplay(NONE);
             styleNotYetAvailable->ref();
         }
@@ -460,9 +451,9 @@ RenderStyle* CSSStyleSelector::styleForElement(ElementImpl* e, RenderStyle* defa
     
     initForStyleResolve(e, defaultParent);
 
-    style = new RenderStyle();
-    if( parentStyle )
-        style->inheritFrom( parentStyle );
+    style = new (e->getDocument()->renderArena()) RenderStyle();
+    if (parentStyle)
+        style->inheritFrom(parentStyle);
     else
         parentStyle = style;
     
@@ -481,33 +472,47 @@ RenderStyle* CSSStyleSelector::styleForElement(ElementImpl* e, RenderStyle* defa
     // 4. Now we check user sheet rules.
     int firstUserRule = -1, lastUserRule = -1;
     matchRules(m_userStyle, firstUserRule, lastUserRule);
-    
+
     // 5. Now check author rules, beginning first with presentational attributes
     // mapped from HTML.
     int firstAuthorRule = -1, lastAuthorRule = -1;
-    CSSStyleDeclarationImpl* attributeDecl = e->attributeStyleDecl();
-    if (attributeDecl) {
-        firstAuthorRule = lastAuthorRule = m_matchedDeclCount;
-        addMatchedDeclaration(attributeDecl);
-    }
-    
-    // Table cells share an additional mapped rule.
-    attributeDecl = e->additionalAttributeStyleDecl();
-    if (attributeDecl) {
-        if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
-        lastAuthorRule = m_matchedDeclCount;
-        addMatchedDeclaration(attributeDecl);
+    if (htmlElement) {
+        // Ask if the HTML element has mapped attributes.
+        if (htmlElement->hasMappedAttributes()) {
+            // Walk our attribute list and add in each decl.
+            const HTMLNamedAttrMapImpl* map = htmlElement->htmlAttributes();
+            for (uint i = 0; i < map->length(); i++) {
+                HTMLAttributeImpl* attr = map->attributeItem(i);
+                if (attr->decl()) {
+                    if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
+                    lastAuthorRule = m_matchedDeclCount;
+                    addMatchedDeclaration(attr->decl());
+                }
+            }
+        }
+
+        // Now we check additional mapped declarations.
+        // Tables and table cells share an additional mapped rule that must be applied
+        // after all attributes, since their mapped style depends on the values of multiple attributes.
+        CSSStyleDeclarationImpl* attributeDecl = htmlElement->additionalAttributeStyleDecl();
+        if (attributeDecl) {
+            if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
+            lastAuthorRule = m_matchedDeclCount;
+            addMatchedDeclaration(attributeDecl);
+        }
     }
     
     // 6. Check the rules in author sheets next.
     matchRules(m_authorStyle, firstAuthorRule, lastAuthorRule);
     
     // 7. Now check our inline style attribute.
-    CSSStyleDeclarationImpl* inlineDecl = e->inlineStyleDecl();
-    if (inlineDecl) {
-        if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
-        lastAuthorRule = m_matchedDeclCount;
-        addMatchedDeclaration(inlineDecl);
+    if (htmlElement) {
+        CSSStyleDeclarationImpl* inlineDecl = htmlElement->inlineStyleDecl();
+        if (inlineDecl) {
+            if (firstAuthorRule == -1) firstAuthorRule = m_matchedDeclCount;
+            lastAuthorRule = m_matchedDeclCount;
+            addMatchedDeclaration(inlineDecl);
+        }
     }
     
     // Now we have all of the matched rules in the appropriate order.  Walk the rules and apply
@@ -555,7 +560,7 @@ RenderStyle* CSSStyleSelector::pseudoStyleForElement(RenderStyle::PseudoId pseud
     
     if (!e->getDocument()->haveStylesheetsLoaded()) {
         if (!styleNotYetAvailable) {
-            styleNotYetAvailable = new RenderStyle();
+            styleNotYetAvailable = ::new RenderStyle();
             styleNotYetAvailable->setDisplay(NONE);
             styleNotYetAvailable->ref();
         }
@@ -577,9 +582,9 @@ RenderStyle* CSSStyleSelector::pseudoStyleForElement(RenderStyle::PseudoId pseud
     if (m_matchedDeclCount == 0)
         return 0;
     
-    style = new RenderStyle();
-    if( parentStyle )
-        style->inheritFrom( parentStyle );
+    style = new (e->getDocument()->renderArena()) RenderStyle();
+    if (parentStyle)
+        style->inheritFrom(parentStyle);
     else
         parentStyle = style;
     style->noninherited_flags._styleType = pseudoStyle;
@@ -2211,7 +2216,8 @@ void CSSStyleSelector::applyProperty( int id, DOM::CSSValueImpl *value )
     {
         HANDLE_INHERIT_AND_INITIAL(backgroundImage, BackgroundImage)
 	if (!primitiveValue) return;
-	style->setBackgroundImage(static_cast<CSSImageValueImpl *>(primitiveValue)->image());
+	style->setBackgroundImage(static_cast<CSSImageValueImpl *>(primitiveValue)
+                                  ->image(element->getDocument()->docLoader()));
         //kdDebug( 6080 ) << "setting image in style to " << image->image() << endl;
         break;
     }
@@ -2219,7 +2225,8 @@ void CSSStyleSelector::applyProperty( int id, DOM::CSSValueImpl *value )
     {
         HANDLE_INHERIT_AND_INITIAL(listStyleImage, ListStyleImage)
         if (!primitiveValue) return;
-	style->setListStyleImage(static_cast<CSSImageValueImpl *>(primitiveValue)->image());
+	style->setListStyleImage(static_cast<CSSImageValueImpl *>(primitiveValue)
+                                 ->image(element->getDocument()->docLoader()));
         //kdDebug( 6080 ) << "setting image in list to " << image->image() << endl;
         break;
     }
@@ -2783,7 +2790,7 @@ void CSSStyleSelector::applyProperty( int id, DOM::CSSValueImpl *value )
             else if (val->primitiveType()==CSSPrimitiveValue::CSS_URI)
             {
                 CSSImageValueImpl *image = static_cast<CSSImageValueImpl *>(val);
-                style->setContent(image->image(), i != 0);
+                style->setContent(image->image(element->getDocument()->docLoader()), i != 0);
             }
 
         }
diff --git a/WebCore/khtml/css/cssstyleselector.h b/WebCore/khtml/css/cssstyleselector.h
index 78cd837..64f8b7f 100644
--- a/WebCore/khtml/css/cssstyleselector.h
+++ b/WebCore/khtml/css/cssstyleselector.h
@@ -39,6 +39,7 @@ namespace DOM {
     class DocumentImpl;
     class NodeImpl;
     class ElementImpl;
+    class HTMLElementImpl;
     class StyleSheetImpl;
     class CSSStyleSheetImpl;
     class CSSSelector;
@@ -101,7 +102,6 @@ namespace khtml
 	~CSSStyleSelector();
 
 	static void loadDefaultStyle(const KHTMLSettings *s = 0);
-	static void clear();
 
         void initForStyleResolve(DOM::ElementImpl* e, RenderStyle* parentStyle);
 	RenderStyle *styleForElement(DOM::ElementImpl* e, RenderStyle* parentStyle=0);
@@ -191,6 +191,7 @@ public:
 	RenderStyle *style;
 	RenderStyle *parentStyle;
 	DOM::ElementImpl *element;
+        DOM::HTMLElementImpl *htmlElement;
 	DOM::NodeImpl *parentNode;
         RenderStyle::PseudoId pseudoStyle;
 	KHTMLView *view;
diff --git a/WebCore/khtml/css/html4.css b/WebCore/khtml/css/html4.css
index f138fc8..b755dcc 100644
--- a/WebCore/khtml/css/html4.css
+++ b/WebCore/khtml/css/html4.css
@@ -103,12 +103,9 @@ CENTER {
       
 HR  { 
         display: block; 
-        margin-top: 12px; 
-        margin-bottom: 12px; 
+        margin: 0.5em auto; 
         border-style: inset;
         border-width: 1px;
-        margin-left: auto;
-        margin-right: auto;
 }
 
 MAP { 
diff --git a/WebCore/khtml/css/quirks.css b/WebCore/khtml/css/quirks.css
index a739aa1..3888f91 100644
--- a/WebCore/khtml/css/quirks.css
+++ b/WebCore/khtml/css/quirks.css
@@ -1,6 +1,7 @@
 /* 
  * This style sheet is used by khtml to render HTML pages in quirks mode
  * (C) 2000-2003 Lars Knoll (knoll at kde.org)
+ * (C) 2004 Apple Computer
  *
  * Konqueror/khtml relies on the existence of this style sheet for
  * rendering. Do not remove or modify this file unless you know
diff --git a/WebCore/khtml/dom/dom_element.cpp b/WebCore/khtml/dom/dom_element.cpp
index d061287..d2f76ad 100644
--- a/WebCore/khtml/dom/dom_element.cpp
+++ b/WebCore/khtml/dom/dom_element.cpp
@@ -24,6 +24,9 @@
 #include "xml/dom_docimpl.h"
 #include "xml/dom_elementimpl.h"
 
+// FIXME: Remove when .style gets moved to html_element.cpp.
+#include "html/html_elementimpl.h"
+
 using namespace DOM;
 
 Attr::Attr() : Node()
@@ -291,9 +294,11 @@ bool Element::isHTMLElement() const
     return ((ElementImpl *)impl)->isHTMLElement();
 }
 
+// FIXME: This should move down to HTMLElement.
 CSSStyleDeclaration Element::style()
 {
-    if (impl) return ((ElementImpl *)impl)->getInlineStyleDecl();
+    if (isHTMLElement())
+        return ((HTMLElementImpl *)impl)->getInlineStyleDecl();
     return 0;
 }
 
diff --git a/WebCore/khtml/dom/html_element.cpp b/WebCore/khtml/dom/html_element.cpp
index ea05011..ed71a0c 100644
--- a/WebCore/khtml/dom/html_element.cpp
+++ b/WebCore/khtml/dom/html_element.cpp
@@ -116,20 +116,6 @@ void HTMLElement::setClassName( const DOMString &value )
     if(impl) ((ElementImpl *)impl)->setAttribute(ATTR_CLASS, value);
 }
 
-void HTMLElement::removeCSSProperty( const DOMString &property )
-{
-    int id = getPropertyID(property.string().lower().ascii(), property.length());
-    if(id && impl)
-        static_cast<HTMLElementImpl*>(impl)->removeCSSProperty(id);
-}
-
-void HTMLElement::addCSSProperty( const DOMString &property, const DOMString &value )
-{
-    int id = getPropertyID(property.string().lower().ascii(), property.length());
-    if(id && impl)
-        static_cast<HTMLElementImpl*>(impl)->addCSSProperty(id, value);
-}
-
 DOMString HTMLElement::innerHTML() const
 {
     if ( !impl ) return DOMString();
diff --git a/WebCore/khtml/dom/html_element.h b/WebCore/khtml/dom/html_element.h
index 1387b08..cd35125 100644
--- a/WebCore/khtml/dom/html_element.h
+++ b/WebCore/khtml/dom/html_element.h
@@ -190,16 +190,6 @@ public:
      */
     HTMLCollection children() const;
 
-    /*
-     * @internal
-     */
-    void removeCSSProperty( const DOMString& property );
-
-    /*
-     * @internal
-     */
-    void addCSSProperty( const DOMString &property, const DOMString &value );
-
     bool isContentEditable() const;
     DOMString contentEditable() const;
     void setContentEditable(const DOMString &enabled);
diff --git a/WebCore/khtml/html/html_baseimpl.cpp b/WebCore/khtml/html/html_baseimpl.cpp
index 98093eb..c6d7aab 100644
--- a/WebCore/khtml/html/html_baseimpl.cpp
+++ b/WebCore/khtml/html/html_baseimpl.cpp
@@ -49,8 +49,7 @@ using namespace DOM;
 using namespace khtml;
 
 HTMLBodyElementImpl::HTMLBodyElementImpl(DocumentPtr *doc)
-    : HTMLElementImpl(doc),
-    m_bgSet( false ), m_fgSet( false ), m_linkDecl(0)
+    : HTMLElementImpl(doc), m_linkDecl(0)
 {
 }
 
@@ -75,47 +74,59 @@ void HTMLBodyElementImpl::createLinkDecl()
     m_linkDecl->setStrictParsing(!getDocument()->inCompatMode());
 }
 
-void HTMLBodyElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLBodyElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
 {
     switch(attr->id())
     {
+        case ATTR_BACKGROUND:
+        case ATTR_BGCOLOR:
+        case ATTR_TEXT:
+        case ATTR_MARGINWIDTH:
+        case ATTR_LEFTMARGIN:
+        case ATTR_MARGINHEIGHT:
+        case ATTR_TOPMARGIN:
+        case ATTR_BGPROPERTIES:
+            result = eUniversal;
+            return false;
+        default:
+            break;
+    }
+    
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
 
+void HTMLBodyElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
+{
+    switch(attr->id())
+    {
     case ATTR_BACKGROUND:
     {
         QString url = khtml::parseURL( attr->value() ).string();
-        if (!url.isEmpty()) {
-            addCSSImageProperty(CSS_PROP_BACKGROUND_IMAGE, getDocument()->completeURL(url));
-            m_bgSet = true;
-        }
-        else {
-            removeCSSProperty(CSS_PROP_BACKGROUND_IMAGE);
-            m_bgSet = false;
-        }
+        if (!url.isEmpty())
+            addCSSImageProperty(attr, CSS_PROP_BACKGROUND_IMAGE, getDocument()->completeURL(url));
         break;
     }
     case ATTR_MARGINWIDTH:
-        addCSSLength(CSS_PROP_MARGIN_RIGHT, attr->value() );
+        addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value() );
         /* nobreak; */
     case ATTR_LEFTMARGIN:
-        addCSSLength(CSS_PROP_MARGIN_LEFT, attr->value() );
+        addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value() );
         break;
     case ATTR_MARGINHEIGHT:
-        addCSSLength(CSS_PROP_MARGIN_BOTTOM, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());
         /* nobreak */
     case ATTR_TOPMARGIN:
-        addCSSLength(CSS_PROP_MARGIN_TOP, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
         break;
     case ATTR_BGCOLOR:
-        addHTMLColor(CSS_PROP_BACKGROUND_COLOR, attr->value());
-        m_bgSet = !attr->isNull();
+        addHTMLColor(attr, CSS_PROP_BACKGROUND_COLOR, attr->value());
         break;
     case ATTR_TEXT:
-        addHTMLColor(CSS_PROP_COLOR, attr->value());
-        m_fgSet = !attr->isNull();
+        addHTMLColor(attr, CSS_PROP_COLOR, attr->value());
         break;
     case ATTR_BGPROPERTIES:
         if ( strcasecmp( attr->value(), "fixed" ) == 0)
-            addCSSProperty(CSS_PROP_BACKGROUND_ATTACHMENT, CSS_VAL_FIXED);
+            addCSSProperty(attr, CSS_PROP_BACKGROUND_ATTACHMENT, CSS_VAL_FIXED);
         break;
     case ATTR_VLINK:
     case ATTR_ALINK:
@@ -172,7 +183,7 @@ void HTMLBodyElementImpl::parseAttribute(AttributeImpl *attr)
     case ATTR_NOSAVE:
 	break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -183,23 +194,16 @@ void HTMLBodyElementImpl::insertedIntoDocument()
     // FIXME: perhaps all this stuff should be in attach() instead of here...
 
     KHTMLView* w = getDocument()->view();
-    if(w && w->marginWidth() != -1) {
+    if (w && w->marginWidth() != -1) {
         QString s;
         s.sprintf( "%d", w->marginWidth() );
-        addCSSLength(CSS_PROP_MARGIN_LEFT, s);
-        addCSSLength(CSS_PROP_MARGIN_RIGHT, s);
+        setAttribute(ATTR_MARGINWIDTH, s);
     }
-    if(w && w->marginHeight() != -1) {
+    if (w && w->marginHeight() != -1) {
         QString s;
         s.sprintf( "%d", w->marginHeight() );
-        addCSSLength(CSS_PROP_MARGIN_TOP, s);
-        addCSSLength(CSS_PROP_MARGIN_BOTTOM, s);
+        setAttribute(ATTR_MARGINHEIGHT, s);
     }
-
-    if ( m_bgSet && !m_fgSet )
-        addCSSProperty(CSS_PROP_COLOR, "#000000");
-
-    getDocument()->updateStyleSelector();
 }
 
 // -------------------------------------------------------------------------
@@ -317,7 +321,7 @@ void HTMLFrameElementImpl::openURL()
 }
 
 
-void HTMLFrameElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLFrameElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -370,7 +374,7 @@ void HTMLFrameElementImpl::parseAttribute(AttributeImpl *attr)
                                 getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -516,7 +520,7 @@ NodeImpl::Id HTMLFrameSetElementImpl::id() const
     return ID_FRAMESET;
 }
 
-void HTMLFrameSetElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLFrameSetElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -557,7 +561,7 @@ void HTMLFrameSetElementImpl::parseAttribute(AttributeImpl *attr)
 	    getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -672,21 +676,38 @@ NodeImpl::Id HTMLIFrameElementImpl::id() const
     return ID_IFRAME;
 }
 
-void HTMLIFrameElementImpl::parseAttribute(AttributeImpl *attr )
+bool HTMLIFrameElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch (attr->id()) {
+        case ATTR_WIDTH:
+        case ATTR_HEIGHT:
+            result = eUniversal;
+            return false;
+        case ATTR_ALIGN:
+            result = eReplaced; // Share with <img> since the alignment behavior is the same.
+            return false;
+        default:
+            break;
+    }
+    
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLIFrameElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr )
 {
   switch (  attr->id() )
   {
     case ATTR_WIDTH:
-      addCSSLength( CSS_PROP_WIDTH, attr->value());
+      addCSSLength( attr, CSS_PROP_WIDTH, attr->value());
       break;
     case ATTR_HEIGHT:
-      addCSSLength( CSS_PROP_HEIGHT, attr->value() );
+      addCSSLength( attr, CSS_PROP_HEIGHT, attr->value() );
       break;
     case ATTR_ALIGN:
-      addHTMLAlignment( attr->value() );
+      addHTMLAlignment( attr );
       break;
     default:
-      HTMLFrameElementImpl::parseAttribute( attr );
+      HTMLFrameElementImpl::parseHTMLAttribute( attr );
   }
 }
 
diff --git a/WebCore/khtml/html/html_baseimpl.h b/WebCore/khtml/html/html_baseimpl.h
index ffb2f4b..f4db2a4 100644
--- a/WebCore/khtml/html/html_baseimpl.h
+++ b/WebCore/khtml/html/html_baseimpl.h
@@ -56,14 +56,14 @@ public:
 
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *);
+
     virtual void insertedIntoDocument();
 
     void createLinkDecl();
 
 protected:
-    bool m_bgSet;
-    bool m_fgSet;
     CSSStyleDeclarationImpl* m_linkDecl;
 };
 
@@ -81,7 +81,7 @@ public:
 
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *);
     virtual void attach();
     virtual void detach();
     virtual bool rendererIsNeeded(khtml::RenderStyle *);
@@ -132,7 +132,7 @@ public:
 
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *);
     virtual void attach();
     virtual bool rendererIsNeeded(khtml::RenderStyle *);
     virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
@@ -198,7 +198,9 @@ public:
 
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
+
     virtual void attach();
     virtual bool rendererIsNeeded(khtml::RenderStyle *);
     virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
diff --git a/WebCore/khtml/html/html_blockimpl.cpp b/WebCore/khtml/html/html_blockimpl.cpp
index 00f34aa..835c462 100644
--- a/WebCore/khtml/html/html_blockimpl.cpp
+++ b/WebCore/khtml/html/html_blockimpl.cpp
@@ -66,7 +66,16 @@ NodeImpl::Id HTMLDivElementImpl::id() const
     return ID_DIV;
 }
 
-void HTMLDivElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLDivElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    if (attr->id() == ATTR_ALIGN) {
+        result = eBlock;
+        return false;
+    }
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+        
+void HTMLDivElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -74,17 +83,17 @@ void HTMLDivElementImpl::parseAttribute(AttributeImpl *attr)
     {
         DOMString v = attr->value();
 	if ( strcasecmp( attr->value(), "middle" ) == 0 || strcasecmp( attr->value(), "center" ) == 0 )
-           addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_CENTER);
+           addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_CENTER);
         else if (strcasecmp(attr->value(), "left") == 0)
-            addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_LEFT);
+            addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_LEFT);
         else if (strcasecmp(attr->value(), "right") == 0)
-            addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_RIGHT);
+            addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_RIGHT);
         else
-            addCSSProperty(CSS_PROP_TEXT_ALIGN, v);
+            addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, v);
         break;
     }
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -104,79 +113,81 @@ NodeImpl::Id HTMLHRElementImpl::id() const
     return ID_HR;
 }
 
-void HTMLHRElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLHRElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch (attr->id()) {
+        case ATTR_ALIGN:
+        case ATTR_WIDTH:
+        case ATTR_COLOR:
+        case ATTR_SIZE:
+        case ATTR_NOSHADE:
+            result = eHR;
+            return false;
+        default:
+            break;
+    }
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLHRElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch( attr->id() )
     {
     case ATTR_ALIGN: {
         if (strcasecmp(attr->value(), "left") == 0) {
-            addCSSProperty(CSS_PROP_MARGIN_LEFT, "0");
-	    addCSSProperty(CSS_PROP_MARGIN_RIGHT, CSS_VAL_AUTO);
+            addCSSProperty(attr, CSS_PROP_MARGIN_LEFT, "0");
+	    addCSSProperty(attr, CSS_PROP_MARGIN_RIGHT, CSS_VAL_AUTO);
 	}
         else if (strcasecmp(attr->value(), "right") == 0) {
-	    addCSSProperty(CSS_PROP_MARGIN_LEFT, CSS_VAL_AUTO);
-	    addCSSProperty(CSS_PROP_MARGIN_RIGHT, "0");
+	    addCSSProperty(attr, CSS_PROP_MARGIN_LEFT, CSS_VAL_AUTO);
+	    addCSSProperty(attr, CSS_PROP_MARGIN_RIGHT, "0");
 	}
 	else {
-      	    addCSSProperty(CSS_PROP_MARGIN_LEFT, CSS_VAL_AUTO);
-            addCSSProperty(CSS_PROP_MARGIN_RIGHT, CSS_VAL_AUTO);
+      	    addCSSProperty(attr, CSS_PROP_MARGIN_LEFT, CSS_VAL_AUTO);
+            addCSSProperty(attr, CSS_PROP_MARGIN_RIGHT, CSS_VAL_AUTO);
 	}
         break;
     }
     case ATTR_WIDTH:
     {
-        if (attr->isNull()) break;
         // cheap hack to cause linebreaks
         // khtmltests/html/strange_hr.html
         bool ok;
         int v = attr->value().implementation()->toInt(&ok);
         if(ok && !v)
-            addCSSLength(CSS_PROP_WIDTH, "1");
+            addCSSLength(attr, CSS_PROP_WIDTH, "1");
         else
-            addCSSLength(CSS_PROP_WIDTH, attr->value());
+            addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
+        break;
     }
-    break;
-    default:
-        HTMLElementImpl::parseAttribute(attr);
+    case ATTR_COLOR:
+        addCSSProperty(attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
+        addCSSProperty(attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
+        addCSSProperty(attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
+        addCSSProperty(attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
+        addHTMLColor(attr, CSS_PROP_BORDER_COLOR, attr->value());
+        addHTMLColor(attr, CSS_PROP_BACKGROUND_COLOR, attr->value());
+        break;
+    case ATTR_NOSHADE:
+        addCSSProperty(attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
+        addCSSProperty(attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
+        addCSSProperty(attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
+        addCSSProperty(attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
+        addHTMLColor(attr, CSS_PROP_BORDER_COLOR, DOMString("grey"));
+        addHTMLColor(attr, CSS_PROP_BACKGROUND_COLOR, DOMString("grey"));
+        break;
+    case ATTR_SIZE: {
+        DOMStringImpl* si = attr->value().implementation();
+        int size = si->toInt();
+        if (size <= 1)
+            addCSSProperty(attr, CSS_PROP_BORDER_BOTTOM_WIDTH, DOMString("0"));
+        else
+            addCSSLength(attr, CSS_PROP_HEIGHT, DOMString(QString::number(size-2)));
+        break;
     }
-}
-
-// ### make sure we undo what we did during detach
-void HTMLHRElementImpl::attach()
-{
-    if (attributes(true /* readonly */)) {
-        // there are some attributes, lets check
-        const AtomicString& color = getAttribute(ATTR_COLOR);
-        DOMStringImpl* si = getAttribute(ATTR_SIZE).implementation();
-        int _s =  si ? si->toInt() : -1;
-        if (!color.isNull()) {
-            addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
-            addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
-            addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
-            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));
-            addHTMLColor(CSS_PROP_BORDER_COLOR, color);
-        }
-        else {
-            if (_s > 1 && getAttribute(ATTR_NOSHADE).isNull()) {
-                DOMString n("1");
-                addCSSProperty(CSS_PROP_BORDER_BOTTOM_WIDTH, n);
-                addCSSProperty(CSS_PROP_BORDER_TOP_WIDTH, n);
-                addCSSProperty(CSS_PROP_BORDER_LEFT_WIDTH, n);
-                addCSSProperty(CSS_PROP_BORDER_RIGHT_WIDTH, n);
-                addCSSLength(CSS_PROP_HEIGHT, DOMString(QString::number(_s-2)));
-            }
-            else if (_s >= 0) {
-                addCSSProperty(CSS_PROP_BORDER_TOP_WIDTH, DOMString(QString::number(_s)));
-                addCSSProperty(CSS_PROP_BORDER_BOTTOM_WIDTH, DOMString("0"));
-            }
-        }
-        if (_s == 0)
-            addCSSProperty(CSS_PROP_MARGIN_BOTTOM, DOMString("1"));
+    default:
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
-
-    HTMLElementImpl::attach();
 }
 
 // -------------------------------------------------------------------------
@@ -198,7 +209,16 @@ NodeImpl::Id HTMLParagraphElementImpl::id() const
     return ID_P;
 }
 
-void HTMLParagraphElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLParagraphElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    if (attr->id() == ATTR_ALIGN) {
+        result = eBlock; // We can share with DIV here.
+        return false;
+    }
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLParagraphElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -206,17 +226,17 @@ void HTMLParagraphElementImpl::parseAttribute(AttributeImpl *attr)
         {
             DOMString v = attr->value();
             if ( strcasecmp( attr->value(), "middle" ) == 0 || strcasecmp( attr->value(), "center" ) == 0 )
-                addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_CENTER);
+                addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_CENTER);
             else if (strcasecmp(attr->value(), "left") == 0)
-                addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_LEFT);
+                addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_LEFT);
             else if (strcasecmp(attr->value(), "right") == 0)
-                addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_RIGHT);
+                addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_RIGHT);
             else
-                addCSSProperty(CSS_PROP_TEXT_ALIGN, v);
+                addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, v);
             break;
         }
         default:
-            HTMLElementImpl::parseAttribute(attr);
+            HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -254,87 +274,85 @@ NodeImpl::Id HTMLMarqueeElementImpl::id() const
     return ID_MARQUEE;
 }
 
-void HTMLMarqueeElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLMarqueeElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch (attr->id()) {
+        case ATTR_WIDTH:
+        case ATTR_HEIGHT:
+        case ATTR_BGCOLOR:
+        case ATTR_VSPACE:
+        case ATTR_HSPACE:
+        case ATTR_SCROLLAMOUNT:
+        case ATTR_SCROLLDELAY:
+        case ATTR_LOOP:
+        case ATTR_BEHAVIOR:
+        case ATTR_DIRECTION:
+            result = eUniversal;
+            return false;
+        default:
+            break;
+    }
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+            
+            
+void HTMLMarqueeElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
         case ATTR_WIDTH:
             if (!attr->value().isEmpty())
-                addCSSLength(CSS_PROP_WIDTH, attr->value());
-            else
-                removeCSSProperty(CSS_PROP_WIDTH);
+                addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
             break;
         case ATTR_HEIGHT:
             if (!attr->value().isEmpty())
-                addCSSLength(CSS_PROP_HEIGHT, attr->value());
-            else
-                removeCSSProperty(CSS_PROP_HEIGHT);
+                addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
             break;
         case ATTR_BGCOLOR:
             if (!attr->value().isEmpty())
-                addHTMLColor(CSS_PROP_BACKGROUND_COLOR, attr->value());
-            else
-                removeCSSProperty(CSS_PROP_BACKGROUND_COLOR);
+                addHTMLColor(attr, CSS_PROP_BACKGROUND_COLOR, attr->value());
             break;
         case ATTR_VSPACE:
             if (!attr->value().isEmpty()) {
-                addCSSLength(CSS_PROP_MARGIN_TOP, attr->value());
-                addCSSLength(CSS_PROP_MARGIN_BOTTOM, attr->value());
-            }
-            else {
-                removeCSSProperty(CSS_PROP_MARGIN_TOP);
-                removeCSSProperty(CSS_PROP_MARGIN_BOTTOM);
+                addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
+                addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());
             }
             break;
         case ATTR_HSPACE:
             if (!attr->value().isEmpty()) {
-                addCSSLength(CSS_PROP_MARGIN_LEFT, attr->value());
-                addCSSLength(CSS_PROP_MARGIN_RIGHT, attr->value());
-            }
-            else {
-                removeCSSProperty(CSS_PROP_MARGIN_LEFT);
-                removeCSSProperty(CSS_PROP_MARGIN_RIGHT);
+                addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value());
+                addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value());
             }
             break;
         case ATTR_SCROLLAMOUNT:
             if (!attr->value().isEmpty())
-                addCSSLength(CSS_PROP__KHTML_MARQUEE_INCREMENT, attr->value());
-            else
-                removeCSSProperty(CSS_PROP__KHTML_MARQUEE_INCREMENT);
+                addCSSLength(attr, CSS_PROP__KHTML_MARQUEE_INCREMENT, attr->value());
             break;
         case ATTR_SCROLLDELAY:
             if (!attr->value().isEmpty())
-                addCSSLength(CSS_PROP__KHTML_MARQUEE_SPEED, attr->value());
-            else
-                removeCSSProperty(CSS_PROP__KHTML_MARQUEE_SPEED);
+                addCSSLength(attr, CSS_PROP__KHTML_MARQUEE_SPEED, attr->value());
             break;
         case ATTR_LOOP:
             if (!attr->value().isEmpty()) {
                 if (attr->value() == "-1" || strcasecmp(attr->value(), "infinite") == 0)
-                    addCSSProperty(CSS_PROP__KHTML_MARQUEE_REPETITION, CSS_VAL_INFINITE);
+                    addCSSProperty(attr, CSS_PROP__KHTML_MARQUEE_REPETITION, CSS_VAL_INFINITE);
                 else
-                    addCSSLength(CSS_PROP__KHTML_MARQUEE_REPETITION, attr->value());
+                    addCSSLength(attr, CSS_PROP__KHTML_MARQUEE_REPETITION, attr->value());
             }
-            else
-                removeCSSProperty(CSS_PROP__KHTML_MARQUEE_REPETITION);
             break;
         case ATTR_BEHAVIOR:
             if (!attr->value().isEmpty())
-                addCSSProperty(CSS_PROP__KHTML_MARQUEE_STYLE, attr->value());
-            else
-                removeCSSProperty(CSS_PROP__KHTML_MARQUEE_STYLE);
+                addCSSProperty(attr, CSS_PROP__KHTML_MARQUEE_STYLE, attr->value());
             break;
         case ATTR_DIRECTION:
             if (!attr->value().isEmpty())
-                addCSSProperty(CSS_PROP__KHTML_MARQUEE_DIRECTION, attr->value());
-            else
-                removeCSSProperty(CSS_PROP__KHTML_MARQUEE_DIRECTION);
+                addCSSProperty(attr, CSS_PROP__KHTML_MARQUEE_DIRECTION, attr->value());
             break;
         case ATTR_TRUESPEED:
             m_minimumDelay = !attr->isNull() ? 0 : defaultMinimumDelay;
             break;
         default:
-            HTMLElementImpl::parseAttribute(attr);
+            HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -343,8 +361,6 @@ void HTMLMarqueeElementImpl::parseAttribute(AttributeImpl *attr)
 HTMLLayerElementImpl::HTMLLayerElementImpl(DocumentPtr *doc)
     : HTMLDivElementImpl( doc )
 {
-//    addCSSProperty(CSS_PROP_POSITION, CSS_VAL_ABSOLUTE);
-//    fixed = false;
 }
 
 HTMLLayerElementImpl::~HTMLLayerElementImpl()
@@ -355,46 +371,3 @@ NodeImpl::Id HTMLLayerElementImpl::id() const
 {
     return ID_LAYER;
 }
-
-
-void HTMLLayerElementImpl::parseAttribute(AttributeImpl *attr)
-{
-    HTMLElementImpl::parseAttribute(attr);
-
-    // layers are evil
-/*    int cssprop;
-    bool page = false;
-    switch(attr->id()) {
-        case ATTR_PAGEX:
-            page = true;
-        case ATTR_LEFT:
-            cssprop = CSS_PROP_LEFT;
-            break;
-        case ATTR_PAGEY:
-            page = true;
-        case ATTR_TOP:
-            cssprop = CSS_PROP_TOP;
-            break;
-        case ATTR_WIDTH:
-            cssprop = CSS_PROP_WIDTH;
-            break;
-        case ATTR_HEIGHT:
-            cssprop = CSS_PROP_HEIGHT;
-            break;
-        case ATTR_Z_INDEX:
-            cssprop = CSS_PROP_Z_INDEX;
-            break;
-        case ATTR_VISIBILITY:
-            cssprop = CSS_PROP_VISIBILITY;
-            break;
-        default:
-            HTMLDivElementImpl::parseAttribute(attr);
-            return;
-    }
-    addCSSProperty(cssprop, attr->value());
-    if ( !fixed && page ) {
-        addCSSProperty(CSS_PROP_POSITION, "fixed");
-        fixed = true;
-    }*/
-}
-
diff --git a/WebCore/khtml/html/html_blockimpl.h b/WebCore/khtml/html/html_blockimpl.h
index b263d57..47a9cf4 100644
--- a/WebCore/khtml/html/html_blockimpl.h
+++ b/WebCore/khtml/html/html_blockimpl.h
@@ -54,7 +54,9 @@ public:
     ~HTMLDivElementImpl();
 
     virtual NodeImpl::Id id() const;
-    virtual void parseAttribute(AttributeImpl *token);
+    
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *token);
 };
 
 // -------------------------------------------------------------------------
@@ -66,11 +68,9 @@ public:
     ~HTMLHRElementImpl();
 
     virtual NodeImpl::Id id() const;
-    virtual void parseAttribute(AttributeImpl *);
-    virtual void attach();
-
-protected:
-    bool noShade : 1;
+    
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *);
 };
 
 // -------------------------------------------------------------------------
@@ -94,7 +94,8 @@ class HTMLParagraphElementImpl : public HTMLElementImpl
 public:
     HTMLParagraphElementImpl(DocumentPtr *doc);
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     
     virtual NodeImpl::Id id() const;
 };
@@ -118,7 +119,9 @@ public:
     HTMLMarqueeElementImpl(DocumentPtr *doc);
 
     virtual NodeImpl::Id id() const;
-    virtual void parseAttribute(AttributeImpl *token);
+    
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *token);
 
     int minimumDelay() const { return m_minimumDelay; }
     
@@ -136,8 +139,6 @@ public:
 
     virtual NodeImpl::Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *);
-
     bool fixed;
 };
 
diff --git a/WebCore/khtml/html/html_documentimpl.cpp b/WebCore/khtml/html/html_documentimpl.cpp
index 38fac7f..25f6e83 100644
--- a/WebCore/khtml/html/html_documentimpl.cpp
+++ b/WebCore/khtml/html/html_documentimpl.cpp
@@ -344,8 +344,6 @@ bool HTMLDocumentImpl::haveNamedImageOrForm(const QString &name)
     return namedImageAndFormCounts.find(name) != NULL;
 }
 
-
-
 const int PARSEMODE_HAVE_DOCTYPE	=	(1<<0);
 const int PARSEMODE_HAVE_PUBLIC_ID	=	(1<<1);
 const int PARSEMODE_HAVE_SYSTEM_ID	=	(1<<2);
@@ -566,6 +564,8 @@ void HTMLDocumentImpl::determineParseMode( const QString &str )
         hMode = Html3;
     }
   
+    m_styleSelector->strictParsing = !inCompatMode();
+
 //     kdDebug() << "DocumentImpl::determineParseMode: publicId =" << publicId << " systemId = " << systemId << endl;
 //     kdDebug() << "DocumentImpl::determineParseMode: htmlMode = " << hMode<< endl;
 //     if( pMode == Strict )
diff --git a/WebCore/khtml/html/html_documentimpl.h b/WebCore/khtml/html/html_documentimpl.h
index 065f6a3..1e22292 100644
--- a/WebCore/khtml/html/html_documentimpl.h
+++ b/WebCore/khtml/html/html_documentimpl.h
@@ -100,7 +100,7 @@ private:
      // we actually store ints inside the pointer value itself; would use void *
     // but that makes the template unhappy.
     QDict<char> namedImageAndFormCounts;
-    
+
 #if APPLE_CHANGES
     DOMString m_policyBaseURL;
 #endif
diff --git a/WebCore/khtml/html/html_elementimpl.cpp b/WebCore/khtml/html/html_elementimpl.cpp
index 545c38b..963bd3f 100644
--- a/WebCore/khtml/html/html_elementimpl.cpp
+++ b/WebCore/khtml/html/html_elementimpl.cpp
@@ -54,13 +54,84 @@
 using namespace DOM;
 using namespace khtml;
 
+CSSMappedAttributeDeclarationImpl::~CSSMappedAttributeDeclarationImpl() {
+    if (m_entryType != ePersistent)
+        HTMLElementImpl::removeMappedAttributeDecl(m_entryType, m_attrName, m_attrValue);
+}
+
+QPtrDict<QPtrDict<QPtrDict<CSSMappedAttributeDeclarationImpl> > >* HTMLElementImpl::m_mappedAttributeDecls = 0;
+
+CSSMappedAttributeDeclarationImpl* HTMLElementImpl::getMappedAttributeDecl(MappedAttributeEntry entryType, AttributeImpl* attr)
+{
+    if (!m_mappedAttributeDecls)
+        return 0;
+    
+    QPtrDict<QPtrDict<CSSMappedAttributeDeclarationImpl> >* attrNameDict = m_mappedAttributeDecls->find((void*)entryType);
+    if (attrNameDict) {
+        QPtrDict<CSSMappedAttributeDeclarationImpl>* attrValueDict = attrNameDict->find((void*)attr->id());
+        if (attrValueDict)
+            return attrValueDict->find(attr->value().implementation());
+    }
+    return 0;
+}
+
+void HTMLElementImpl::setMappedAttributeDecl(MappedAttributeEntry entryType, AttributeImpl* attr, CSSMappedAttributeDeclarationImpl* decl)
+{
+    if (!m_mappedAttributeDecls)
+        m_mappedAttributeDecls = new QPtrDict<QPtrDict<QPtrDict<CSSMappedAttributeDeclarationImpl> > >;
+    
+    QPtrDict<CSSMappedAttributeDeclarationImpl>* attrValueDict = 0;
+    QPtrDict<QPtrDict<CSSMappedAttributeDeclarationImpl> >* attrNameDict = m_mappedAttributeDecls->find((void*)entryType);
+    if (!attrNameDict) {
+        attrNameDict = new QPtrDict<QPtrDict<CSSMappedAttributeDeclarationImpl> >;
+        attrNameDict->setAutoDelete(true);
+        m_mappedAttributeDecls->insert((void*)entryType, attrNameDict);
+    }
+    else
+        attrValueDict = attrNameDict->find((void*)attr->id());
+    if (!attrValueDict) {
+        attrValueDict = new QPtrDict<CSSMappedAttributeDeclarationImpl>;
+        if (entryType == ePersistent)
+            attrValueDict->setAutoDelete(true);
+        attrNameDict->insert((void*)attr->id(), attrValueDict);
+    }
+    attrValueDict->replace(attr->value().implementation(), decl);
+}
+
+void HTMLElementImpl::removeMappedAttributeDecl(MappedAttributeEntry entryType, NodeImpl::Id attrName, const AtomicString& attrValue)
+{
+    if (!m_mappedAttributeDecls)
+        return;
+    
+    QPtrDict<QPtrDict<CSSMappedAttributeDeclarationImpl> >* attrNameDict = m_mappedAttributeDecls->find((void*)entryType);
+    if (!attrNameDict)
+        return;
+    QPtrDict<CSSMappedAttributeDeclarationImpl>* attrValueDict = attrNameDict->find((void*)attrName);
+    if (!attrValueDict)
+        return;
+    attrValueDict->remove(attrValue.implementation());
+}
+
+HTMLAttributeImpl::~HTMLAttributeImpl()
+{
+    if (m_styleDecl)
+        m_styleDecl->deref();
+}
+
+AttributeImpl* HTMLAttributeImpl::clone() const
+{
+    return new HTMLAttributeImpl(m_id, _value, m_styleDecl);
+}
+
 HTMLNamedAttrMapImpl::HTMLNamedAttrMapImpl(ElementImpl *e)
-:NamedAttrMapImpl(e)
+:NamedAttrMapImpl(e), m_mappedAttributeCount(0)
 {}
 
 void HTMLNamedAttrMapImpl::clearAttributes()
 {
     m_classList.clear();
+    m_mappedAttributeCount = 0;
+    NamedAttrMapImpl::clearAttributes();
 }
 
 bool HTMLNamedAttrMapImpl::isHTMLAttributeMap() const
@@ -108,15 +179,19 @@ HTMLElementImpl::HTMLElementImpl(DocumentPtr *doc)
     : ElementImpl(doc)
 {
     m_inlineStyleDecl = 0;
-    m_attributeStyleDecl = 0;    
 }
 
 HTMLElementImpl::~HTMLElementImpl()
 {
-    if (m_inlineStyleDecl)
+    if (m_inlineStyleDecl) {
+        m_inlineStyleDecl->setParent(0);
         m_inlineStyleDecl->deref();
-    if (m_attributeStyleDecl)
-        m_attributeStyleDecl->deref();
+    }
+}
+
+AttributeImpl* HTMLElementImpl::createAttribute(NodeImpl::Id id, DOMStringImpl* value)
+{
+    return new HTMLAttributeImpl(id, value);
 }
 
 bool HTMLElementImpl::isInline() const
@@ -166,35 +241,84 @@ void HTMLElementImpl::createInlineStyleDecl()
     m_inlineStyleDecl = new CSSStyleDeclarationImpl(0);
     m_inlineStyleDecl->ref();
     m_inlineStyleDecl->setParent(getDocument()->elementSheet());
-    m_inlineStyleDecl->parent()->ref();
     m_inlineStyleDecl->setNode(this);
     m_inlineStyleDecl->setStrictParsing(!getDocument()->inCompatMode());
 }
 
-void HTMLElementImpl::createMappedAttributeDecl()
+void HTMLElementImpl::attributeChanged(AttributeImpl* attr, bool preserveDecls)
 {
-    m_attributeStyleDecl = new CSSStyleDeclarationImpl(0);
-    m_attributeStyleDecl->ref();
-    m_attributeStyleDecl->setParent(getDocument()->elementSheet());
-    m_attributeStyleDecl->parent()->ref();
-    m_attributeStyleDecl->setNode(this);
-    m_attributeStyleDecl->setStrictParsing(!getDocument()->inCompatMode());
+    HTMLAttributeImpl* htmlAttr = static_cast<HTMLAttributeImpl*>(attr);
+    if (htmlAttr->decl() && !preserveDecls) {
+        htmlAttr->setDecl(0);
+        setChanged();
+        if (namedAttrMap)
+            static_cast<HTMLNamedAttrMapImpl*>(namedAttrMap)->declRemoved();
+    }
+
+    bool checkDecl = true;
+    MappedAttributeEntry entry;
+    bool needToParse = mapToEntry(attr, entry);
+    if (preserveDecls) {
+        if (htmlAttr->decl()) {
+            setChanged();
+            if (namedAttrMap)
+                static_cast<HTMLNamedAttrMapImpl*>(namedAttrMap)->declAdded();
+            checkDecl = false;
+        }
+    }
+    else if (!attr->isNull() && entry != eNone) {
+        CSSMappedAttributeDeclarationImpl* decl = getMappedAttributeDecl(entry, attr);
+        if (decl) {
+            htmlAttr->setDecl(decl);
+            setChanged();
+            if (namedAttrMap)
+                static_cast<HTMLNamedAttrMapImpl*>(namedAttrMap)->declAdded();
+            checkDecl = false;
+        } else
+            needToParse = true;
+    }
+
+    if (needToParse)
+        parseHTMLAttribute(htmlAttr);
+    
+    if (checkDecl && htmlAttr->decl()) {
+        // Add the decl to the table in the appropriate spot.
+        setMappedAttributeDecl(entry, attr, htmlAttr->decl());
+        htmlAttr->decl()->setMappedState(entry, attr->id(), attr->value());
+        htmlAttr->decl()->setParent(0);
+        htmlAttr->decl()->setNode(0);
+        if (namedAttrMap)
+            static_cast<HTMLNamedAttrMapImpl*>(namedAttrMap)->declAdded();
+    }
 }
 
-void HTMLElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch (attr->id())
+    {
+        case ATTR_ALIGN:
+        case ATTR_CONTENTEDITABLE:
+        case ATTR_DIR:
+            result = eUniversal;
+            return false;
+        default:
+            break;
+    }
+    
+    result = eNone;
+    return true;
+}
+    
+void HTMLElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     DOMString indexstring;
-    switch( attr->id() )
+    switch (attr->id())
     {
     case ATTR_ALIGN:
-        if (!attr->isNull()) {
-            if ( strcasecmp(attr->value(), "middle" ) == 0 )
-                addCSSProperty( CSS_PROP_TEXT_ALIGN, "center" );
-            else
-                addCSSProperty(CSS_PROP_TEXT_ALIGN, attr->value());
-        }
+        if (strcasecmp(attr->value(), "middle" ) == 0)
+            addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, "center");
         else
-            removeCSSProperty(CSS_PROP_TEXT_ALIGN);
+            addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, attr->value());
         break;
 // the core attributes...
     case ATTR_ID:
@@ -217,10 +341,7 @@ void HTMLElementImpl::parseAttribute(AttributeImpl *attr)
         setChanged();
         break;
     case ATTR_CONTENTEDITABLE:
-        if (!attr->isNull())
-            setContentEditable(attr->value());
-        else
-            removeCSSProperty(CSS_PROP__KHTML_USER_MODIFY);
+        setContentEditable(attr);
         break;
     case ATTR_STYLE:
         // ### we need to remove old style info in case there was any!
@@ -240,8 +361,8 @@ void HTMLElementImpl::parseAttribute(AttributeImpl *attr)
     case ATTR_LANG:
         break;
     case ATTR_DIR:
-        addCSSProperty(CSS_PROP_DIRECTION, attr->value());
-        addCSSProperty(CSS_PROP_UNICODE_BIDI, CSS_VAL_EMBED);
+        addCSSProperty(attr, CSS_PROP_DIRECTION, attr->value());
+        addCSSProperty(attr, CSS_PROP_UNICODE_BIDI, CSS_VAL_EMBED);
         break;
 // standard events
     case ATTR_ONCLICK:
@@ -308,16 +429,6 @@ void HTMLElementImpl::createAttributeMap() const
     namedAttrMap->ref();
 }
 
-CSSStyleDeclarationImpl* HTMLElementImpl::inlineStyleDecl() const
-{ 
-    return m_inlineStyleDecl;
-}
-
-CSSStyleDeclarationImpl* HTMLElementImpl::attributeStyleDecl() const
-{
-    return m_attributeStyleDecl;
-}
-
 CSSStyleDeclarationImpl* HTMLElementImpl::getInlineStyleDecl()
 {
     if (!m_inlineStyleDecl)
@@ -325,102 +436,101 @@ CSSStyleDeclarationImpl* HTMLElementImpl::getInlineStyleDecl()
     return m_inlineStyleDecl;
 }
 
+CSSStyleDeclarationImpl* HTMLElementImpl::additionalAttributeStyleDecl()
+{
+    return 0;
+}
+
 const AtomicStringList* HTMLElementImpl::getClassList() const
 {
     return namedAttrMap ? static_cast<HTMLNamedAttrMapImpl*>(namedAttrMap)->getClassList() : 0;
 }
 
-void HTMLElementImpl::addCSSProperty(int id, const DOMString &value)
+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 ) ) );
+}
+
+void HTMLElementImpl::addCSSProperty(HTMLAttributeImpl* attr, int id, const DOMString &value)
 {
-    if (!m_attributeStyleDecl) createMappedAttributeDecl();
-    m_attributeStyleDecl->setProperty(id, value, false);
-    setChanged();
+    if (!attr->decl()) createMappedDecl(attr);
+    attr->decl()->setProperty(id, value, false);
 }
 
-void HTMLElementImpl::addCSSProperty(int id, int value)
+void HTMLElementImpl::addCSSProperty(HTMLAttributeImpl* attr, int id, int value)
 {
-    if (!m_attributeStyleDecl) createMappedAttributeDecl();
-    m_attributeStyleDecl->setProperty(id, value, false);
-    setChanged();
+    if (!attr->decl()) createMappedDecl(attr);
+    attr->decl()->setProperty(id, value, false);
 }
 
-void HTMLElementImpl::addCSSStringProperty(int id, const DOMString &value, CSSPrimitiveValue::UnitTypes type)
+void HTMLElementImpl::addCSSStringProperty(HTMLAttributeImpl* attr, int id, const DOMString &value, CSSPrimitiveValue::UnitTypes type)
 {
-    if (!m_attributeStyleDecl) createMappedAttributeDecl();
-    m_attributeStyleDecl->setStringProperty(id, value, type, false);
-    setChanged();
+    if (!attr->decl()) createMappedDecl(attr);
+    attr->decl()->setStringProperty(id, value, type, false);
 }
 
-void HTMLElementImpl::addCSSImageProperty(int id, const DOMString &URL)
+void HTMLElementImpl::addCSSImageProperty(HTMLAttributeImpl* attr, int id, const DOMString &URL)
 {
-    if (!m_attributeStyleDecl) createMappedAttributeDecl();
-    m_attributeStyleDecl->setImageProperty(id, URL, false);
-    setChanged();
+    if (!attr->decl()) createMappedDecl(attr);
+    attr->decl()->setImageProperty(id, URL, false);
 }
 
-void HTMLElementImpl::addCSSLength(int id, const DOMString &value)
+void HTMLElementImpl::addCSSLength(HTMLAttributeImpl* attr, int id, const DOMString &value)
 {
     // FIXME: This function should not spin up the CSS parser, but should instead just figure out the correct
     // length unit and make the appropriate parsed value.
-    if (!m_attributeStyleDecl) createMappedAttributeDecl();
+    if (!attr->decl()) createMappedDecl(attr);
 
     // strip attribute garbage..
     DOMStringImpl* v = value.implementation();
     if ( v ) {
         unsigned int l = 0;
-
+        
         while ( l < v->l && v->s[l].unicode() <= ' ') l++;
-
+        
         for ( ;l < v->l; l++ ) {
             char cc = v->s[l].latin1();
             if ( cc > '9' || ( cc < '0' && cc != '*' && cc != '%' && cc != '.') )
                 break;
         }
         if ( l != v->l ) {
-            m_attributeStyleDecl->setLengthProperty(id, DOMString( v->s, l ), false);
-            setChanged();
+            attr->decl()->setLengthProperty(id, DOMString( v->s, l ), false);
             return;
         }
     }
-
-    m_attributeStyleDecl->setLengthProperty(id, value, false);
-    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 ) ) );
+    
+    attr->decl()->setLengthProperty(id, value, false);
 }
 
 /* color parsing that tries to match as close as possible IE 6. */
-void HTMLElementImpl::addHTMLColor( int id, const DOMString &c )
+void HTMLElementImpl::addHTMLColor(HTMLAttributeImpl* attr, int id, const DOMString &c)
 {
-    if (!m_attributeStyleDecl) createMappedAttributeDecl();
-
     // this is the only case no color gets applied in IE.
     if ( !c.length() )
         return;
 
-    if ( m_attributeStyleDecl->setProperty(id, c, false) )
+    if (!attr->decl()) createMappedDecl(attr);
+    
+    if (attr->decl()->setProperty(id, c, false) )
         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.
@@ -432,7 +542,7 @@ void HTMLElementImpl::addHTMLColor( int id, const DOMString &c )
     // 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 );
@@ -464,7 +574,7 @@ void HTMLElementImpl::addHTMLColor( int id, const DOMString &c )
             }
             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;
@@ -472,25 +582,23 @@ void HTMLElementImpl::addHTMLColor( int id, const DOMString &c )
             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_attributeStyleDecl->setProperty(id, DOMString(color), false) )
+            if ( attr->decl()->setProperty(id, DOMString(color), false) )
                 return;
         }
     }
-    m_attributeStyleDecl->setProperty(id, CSS_VAL_BLACK, false);
+    attr->decl()->setProperty(id, CSS_VAL_BLACK, false);
 }
 
-void HTMLElementImpl::removeCSSProperty(int id)
+void HTMLElementImpl::createMappedDecl(HTMLAttributeImpl* attr)
 {
-    if(!m_attributeStyleDecl)
-        return;
-    m_attributeStyleDecl->parent()->deref();
-    m_attributeStyleDecl->setParent(getDocument()->elementSheet());
-    m_attributeStyleDecl->parent()->ref();
-    m_attributeStyleDecl->removeProperty(id);
-    setChanged();
+    CSSMappedAttributeDeclarationImpl* decl = new CSSMappedAttributeDeclarationImpl(0);
+    attr->setDecl(decl);
+    decl->setParent(getDocument()->elementSheet());
+    decl->setNode(this);
+    decl->setStrictParsing(false); // Mapped attributes are just always quirky.
 }
 
 DOMString HTMLElementImpl::innerHTML() const
@@ -666,13 +774,14 @@ DOMString HTMLElementImpl::namespaceURI() const
         return XHTML_NAMESPACE;
 }
 
-void HTMLElementImpl::addHTMLAlignment( const DOMString& alignment )
+void HTMLElementImpl::addHTMLAlignment(HTMLAttributeImpl* attr)
 {
     //qDebug("alignment is %s", alignment.string().latin1() );
     // vertical alignment with respect to the current baseline of the text
     // right or left means floating images
     int propfloat = -1;
     int propvalign = -1;
+    const AtomicString& alignment = attr->value();
     if ( strcasecmp( alignment, "absmiddle" ) == 0 ) {
         propvalign = CSS_VAL_MIDDLE;
     } else if ( strcasecmp( alignment, "absbottom" ) == 0 ) {
@@ -694,11 +803,11 @@ void HTMLElementImpl::addHTMLAlignment( const DOMString& alignment )
     } else if ( strcasecmp ( alignment, "texttop") == 0 ) {
 	propvalign = CSS_VAL_TEXT_TOP;
     }
-
+    
     if ( propfloat != -1 )
-	addCSSProperty( CSS_PROP_FLOAT, propfloat );
+	addCSSProperty( attr, CSS_PROP_FLOAT, propfloat );
     if ( propvalign != -1 )
-	addCSSProperty( CSS_PROP_VERTICAL_ALIGN, propvalign );
+	addCSSProperty( attr, CSS_PROP_VERTICAL_ALIGN, propvalign );
 }
 
 bool HTMLElementImpl::isFocusable() const
@@ -725,16 +834,15 @@ DOMString HTMLElementImpl::contentEditable() const {
     return "inherit";
 }
 
-void HTMLElementImpl::setContentEditable(const DOMString &enabled) 
+void HTMLElementImpl::setContentEditable(HTMLAttributeImpl* attr) 
 {
+    const AtomicString& enabled = attr->value();
     if (strcasecmp(enabled, "true") == 0 || enabled.isEmpty())
-        addCSSProperty(CSS_PROP__KHTML_USER_MODIFY, CSS_VAL_READ_WRITE);
+        addCSSProperty(attr, CSS_PROP__KHTML_USER_MODIFY, CSS_VAL_READ_WRITE);
     else if (strcasecmp(enabled, "false") == 0)
-        addCSSProperty(CSS_PROP__KHTML_USER_MODIFY, CSS_VAL_READ_ONLY);
+        addCSSProperty(attr, CSS_PROP__KHTML_USER_MODIFY, CSS_VAL_READ_ONLY);
     else if (strcasecmp(enabled, "inherit") == 0)
-        addCSSProperty(CSS_PROP__KHTML_USER_MODIFY, CSS_VAL_INHERIT);
-    else
-        removeCSSProperty(CSS_PROP__KHTML_USER_MODIFY);
+        addCSSProperty(attr, CSS_PROP__KHTML_USER_MODIFY, CSS_VAL_INHERIT);
 }
 
 void HTMLElementImpl::click()
diff --git a/WebCore/khtml/html/html_elementimpl.h b/WebCore/khtml/html/html_elementimpl.h
index efaa98e..da161c3 100644
--- a/WebCore/khtml/html/html_elementimpl.h
+++ b/WebCore/khtml/html/html_elementimpl.h
@@ -25,6 +25,8 @@
 
 #include "xml/dom_elementimpl.h"
 #include "dom_atomicstringlist.h"
+#include "css/css_valueimpl.h"
+#include <qptrdict.h>
 
 namespace DOM {
 
@@ -33,6 +35,57 @@ class CSSStyleDeclarationImpl;
 class HTMLFormElementImpl;
 class DocumentFragmentImpl;
 
+enum MappedAttributeEntry { eNone, eUniversal, ePersistent, eReplaced, eBlock, eHR, eUnorderedList, eListItem,
+    eTable, eCell, eCaption };
+
+class CSSMappedAttributeDeclarationImpl : public CSSStyleDeclarationImpl
+{
+public:
+    CSSMappedAttributeDeclarationImpl(CSSRuleImpl *parentRule)
+    : CSSStyleDeclarationImpl(parentRule), m_entryType(eNone), m_attrName(0)
+    {}
+    
+    virtual ~CSSMappedAttributeDeclarationImpl();
+
+    void setMappedState(MappedAttributeEntry type, NodeImpl::Id attr, const AtomicString& val)
+    {
+        m_entryType = type;
+        m_attrName = attr;
+        m_attrValue = val;
+    }
+
+private:
+    MappedAttributeEntry m_entryType;
+    NodeImpl::Id m_attrName;
+    AtomicString m_attrValue;
+};
+
+class HTMLAttributeImpl : public AttributeImpl
+{
+public:
+    HTMLAttributeImpl(NodeImpl::Id _id, const AtomicString& value, CSSMappedAttributeDeclarationImpl* decl = 0)
+    : AttributeImpl(_id, value), m_styleDecl(decl)
+    {
+        if (decl)
+            decl->ref();
+    }
+
+    ~HTMLAttributeImpl();
+
+    virtual AttributeImpl* clone() const;
+
+    CSSMappedAttributeDeclarationImpl* decl() const { return m_styleDecl; }
+    void setDecl(CSSMappedAttributeDeclarationImpl* decl) 
+    { 
+        if (m_styleDecl) m_styleDecl->deref();
+        m_styleDecl = decl;
+        if (m_styleDecl) m_styleDecl->ref();
+    }
+
+private:
+    CSSMappedAttributeDeclarationImpl* m_styleDecl;
+};
+
 class HTMLNamedAttrMapImpl : public NamedAttrMapImpl
 {
 public:
@@ -45,8 +98,16 @@ public:
     virtual void parseClassAttribute(const DOMString& classAttr);
     const AtomicStringList* getClassList() const { return &m_classList; }
     
+    bool hasMappedAttributes() const { return m_mappedAttributeCount > 0; }
+    void declRemoved() { m_mappedAttributeCount--; }
+    void declAdded() { m_mappedAttributeCount++; }
+    
+    HTMLAttributeImpl* attributeItem(unsigned long index) const
+    { return attrs ? static_cast<HTMLAttributeImpl*>(attrs[index]) : 0; }
+    
 private:
     AtomicStringList m_classList;
+    int m_mappedAttributeCount;
 };
     
 class HTMLElementImpl : public ElementImpl
@@ -62,19 +123,24 @@ public:
      
     virtual Id id() const = 0;
 
-    virtual void parseAttribute(AttributeImpl *token);
+    virtual void attributeChanged(AttributeImpl* attr, bool preserveDecls = false);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl* attr);
     virtual void createAttributeMap() const;
 
-     virtual const AtomicStringList* getClassList() const;
-
-    void addCSSLength(int id, const DOMString &value); // FIXME: value will be parsed by the CSS parser
-    void addCSSProperty(int id, const DOMString &value); // value will be parsed by the CSS parser
-    void addCSSProperty(int id, int value);
-    void addCSSStringProperty(int id, const DOMString &value, DOM::CSSPrimitiveValue::UnitTypes = DOM::CSSPrimitiveValue::CSS_STRING);
-    void addCSSImageProperty(int id, const DOMString &URL);
-    void addHTMLColor( int id, const DOMString &c );
-    void removeCSSProperty(int id);
-
+    virtual const AtomicStringList* getClassList() const;
+
+    bool hasMappedAttributes() const { return namedAttrMap ? static_cast<HTMLNamedAttrMapImpl*>(namedAttrMap)->hasMappedAttributes() : false; }
+    const HTMLNamedAttrMapImpl* htmlAttributes() const { return static_cast<HTMLNamedAttrMapImpl*>(namedAttrMap); }
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+        
+    void addCSSLength(HTMLAttributeImpl* attr, int id, const DOMString &value);
+    void addCSSProperty(HTMLAttributeImpl* attr, int id, const DOMString &value);
+    void addCSSProperty(HTMLAttributeImpl* attr, int id, int value);
+    void addCSSStringProperty(HTMLAttributeImpl* attr, int id, const DOMString &value, DOM::CSSPrimitiveValue::UnitTypes = DOM::CSSPrimitiveValue::CSS_STRING);
+    void addCSSImageProperty(HTMLAttributeImpl* attr, int id, const DOMString &URL);
+    void addHTMLColor(HTMLAttributeImpl* attr, int id, const DOMString &c);
+    void createMappedDecl(HTMLAttributeImpl* attr);
+    
     DOMString innerHTML() const;
     DOMString innerText() const;
     DocumentFragmentImpl *createContextualFragment( const DOMString &html );
@@ -86,28 +152,33 @@ public:
     virtual bool isFocusable() const;
     virtual bool isContentEditable() const;
     virtual DOMString contentEditable() const;
-    virtual void setContentEditable(const DOMString &enabled);
+    virtual void setContentEditable(HTMLAttributeImpl* attr);
 
     virtual void click();
     
-    virtual CSSStyleDeclarationImpl* inlineStyleDecl() const;
-    virtual CSSStyleDeclarationImpl* attributeStyleDecl() const;
-    virtual CSSStyleDeclarationImpl* getInlineStyleDecl();
+    CSSStyleDeclarationImpl* inlineStyleDecl() const { return m_inlineStyleDecl; }
+    virtual CSSStyleDeclarationImpl* additionalAttributeStyleDecl();
+    CSSStyleDeclarationImpl* getInlineStyleDecl();
     void createInlineStyleDecl();
-    void createMappedAttributeDecl();
-    
+     
+    virtual AttributeImpl* createAttribute(NodeImpl::Id id, DOMStringImpl* value);
+
 #if APPLE_CHANGES
     virtual bool isGenericFormElement() const { return false; }
 #endif
 
     virtual DOMString toString() const;
 
+    static CSSMappedAttributeDeclarationImpl* getMappedAttributeDecl(MappedAttributeEntry type, AttributeImpl* attr);
+    static void setMappedAttributeDecl(MappedAttributeEntry type, AttributeImpl* attr, CSSMappedAttributeDeclarationImpl* decl);
+    static void removeMappedAttributeDecl(MappedAttributeEntry type, NodeImpl::Id attrName, const AtomicString& attrValue);
+    static QPtrDict<QPtrDict<QPtrDict<CSSMappedAttributeDeclarationImpl> > >* m_mappedAttributeDecls;
+
 protected:
     // for IMG, OBJECT and APPLET
-    void addHTMLAlignment( const DOMString& alignment );
-    
+    void addHTMLAlignment(HTMLAttributeImpl* htmlAttr);
+
     CSSStyleDeclarationImpl* m_inlineStyleDecl;
-    CSSStyleDeclarationImpl* m_attributeStyleDecl;
 };
 
 class HTMLGenericElementImpl : public HTMLElementImpl
diff --git a/WebCore/khtml/html/html_formimpl.cpp b/WebCore/khtml/html/html_formimpl.cpp
index 9832e53..b06ce61 100644
--- a/WebCore/khtml/html/html_formimpl.cpp
+++ b/WebCore/khtml/html/html_formimpl.cpp
@@ -595,7 +595,7 @@ void HTMLFormElementImpl::reset(  )
     m_inreset = false;
 }
 
-void HTMLFormElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLFormElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -670,7 +670,7 @@ void HTMLFormElementImpl::parseAttribute(AttributeImpl *attr)
 	}
 	// fall through
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -718,7 +718,7 @@ HTMLGenericFormElementImpl::~HTMLGenericFormElementImpl()
         m_form->removeFormElement(this);
 }
 
-void HTMLGenericFormElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLGenericFormElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -735,7 +735,7 @@ void HTMLGenericFormElementImpl::parseAttribute(AttributeImpl *attr)
         break;
     }
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -1013,7 +1013,7 @@ DOMString HTMLButtonElementImpl::type() const
     return getAttribute(ATTR_TYPE);
 }
 
-void HTMLButtonElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLButtonElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -1040,7 +1040,7 @@ void HTMLButtonElementImpl::parseAttribute(AttributeImpl *attr)
             getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     default:
-        HTMLGenericFormElementImpl::parseAttribute(attr);
+        HTMLGenericFormElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -1208,7 +1208,7 @@ void HTMLInputElementImpl::setType(const DOMString& t)
     if (m_type != newType) {
         if (newType == FILE && m_haveType) {
             // Set the attribute back to the old value.
-            // Useful in case we were called from inside parseAttribute.
+            // Useful in case we were called from inside parseHTMLAttribute.
             setAttribute(ATTR_TYPE, type());
         } else {
             m_type = newType;
@@ -1343,7 +1343,26 @@ void HTMLInputElementImpl::accessKeyAction()
     }
 }
 
-void HTMLInputElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLInputElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch (attr->id()) {
+        case ATTR_WIDTH:
+        case ATTR_HEIGHT:
+        case ATTR_VSPACE:
+        case ATTR_HSPACE:
+            result = eUniversal;
+            return false;
+        case ATTR_ALIGN:
+            result = eReplaced; // Share with <img> since the alignment behavior is the same.
+            return false;
+        default:
+            break;
+    }
+    
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLInputElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -1378,24 +1397,21 @@ void HTMLInputElementImpl::parseAttribute(AttributeImpl *attr)
         // ### ignore for the moment
         break;
     case ATTR_VSPACE:
-        addCSSLength(CSS_PROP_MARGIN_TOP, attr->value());
-        addCSSLength(CSS_PROP_MARGIN_BOTTOM, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());
         break;
     case ATTR_HSPACE:
-        addCSSLength(CSS_PROP_MARGIN_LEFT, attr->value());
-        addCSSLength(CSS_PROP_MARGIN_RIGHT, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value());
         break;        
     case ATTR_ALIGN:
-        addHTMLAlignment( attr->value() );
+        addHTMLAlignment(attr);
         break;
     case ATTR_WIDTH:
-        // ignore this attribute,  do _not_ add
-        // a CSS_PROP_WIDTH here (we will honor this attribute for input type=image
-        // in the attach call)!
-        // webdesigner are stupid - and IE/NS behave the same ( Dirk )
+        addCSSLength(attr, CSS_PROP_WIDTH, attr->value() );
         break;
     case ATTR_HEIGHT:
-        addCSSLength(CSS_PROP_HEIGHT, attr->value() );
+        addCSSLength(attr, CSS_PROP_HEIGHT, attr->value() );
         break;
     case ATTR_ONFOCUS:
         setHTMLEventListener(EventImpl::FOCUS_EVENT,
@@ -1414,7 +1430,7 @@ void HTMLInputElementImpl::parseAttribute(AttributeImpl *attr)
             getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     default:
-        HTMLGenericFormElementImpl::parseAttribute(attr);
+        HTMLGenericFormElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -1483,14 +1499,12 @@ void HTMLInputElementImpl::attach()
         m_inited = true;
     }
 
-    switch( m_type ) {
-    case HIDDEN:
-    case IMAGE:
-        if (!getAttribute(ATTR_WIDTH).isEmpty())
-            addCSSLength(CSS_PROP_WIDTH, getAttribute(ATTR_WIDTH));
-        break;
-    default:
-        break;
+    // Disallow the width attribute on inputs other than HIDDEN and IMAGE.
+    // Dumb Web sites will try to set the width as an attribute on form controls that aren't
+    // images or hidden.
+    if (hasMappedAttributes() && m_type != HIDDEN && m_type != IMAGE && !getAttribute(ATTR_WIDTH).isEmpty()) {
+        int excCode;
+        removeAttribute(ATTR_WIDTH, excCode);
     }
 
     HTMLGenericFormElementImpl::attach();
@@ -1867,7 +1881,7 @@ NodeImpl::Id HTMLLabelElementImpl::id() const
     return ID_LABEL;
 }
 
-void HTMLLabelElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLLabelElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -1880,7 +1894,7 @@ void HTMLLabelElementImpl::parseAttribute(AttributeImpl *attr)
             getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -2156,7 +2170,7 @@ NodeImpl* HTMLSelectElementImpl::addChild(NodeImpl* newChild)
     return HTMLGenericFormElementImpl::addChild(newChild);
 }
 
-void HTMLSelectElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLSelectElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -2185,7 +2199,7 @@ void HTMLSelectElementImpl::parseAttribute(AttributeImpl *attr)
             getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     default:
-        HTMLGenericFormElementImpl::parseAttribute(attr);
+        HTMLGenericFormElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -2395,7 +2409,7 @@ DOMString HTMLKeygenElementImpl::type() const
     return "keygen";
 }
 
-void HTMLKeygenElementImpl::parseAttribute(AttributeImpl* attr)
+void HTMLKeygenElementImpl::parseHTMLAttribute(HTMLAttributeImpl* attr)
 {
     switch(attr->id())
     {
@@ -2407,7 +2421,7 @@ void HTMLKeygenElementImpl::parseAttribute(AttributeImpl* attr)
         break;
     default:
         // skip HTMLSelectElementImpl parsing!
-        HTMLGenericFormElementImpl::parseAttribute(attr);
+        HTMLGenericFormElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -2509,9 +2523,9 @@ NodeImpl* HTMLOptGroupElementImpl::addChild(NodeImpl* newChild)
     return HTMLGenericFormElementImpl::addChild(newChild);
 }
 
-void HTMLOptGroupElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLOptGroupElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
-    HTMLGenericFormElementImpl::parseAttribute(attr);
+    HTMLGenericFormElementImpl::parseHTMLAttribute(attr);
     recalcSelectOptions();
 }
 
@@ -2596,7 +2610,7 @@ void HTMLOptionElementImpl::setIndex( long  )
     // ###
 }
 
-void HTMLOptionElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLOptionElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -2607,7 +2621,7 @@ void HTMLOptionElementImpl::parseAttribute(AttributeImpl *attr)
         m_value = attr->value();
         break;
     default:
-        HTMLGenericFormElementImpl::parseAttribute(attr);
+        HTMLGenericFormElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -2697,7 +2711,7 @@ void HTMLTextAreaElementImpl::select(  )
     onSelect();
 }
 
-void HTMLTextAreaElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLTextAreaElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -2739,7 +2753,7 @@ void HTMLTextAreaElementImpl::parseAttribute(AttributeImpl *attr)
 	    getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     default:
-        HTMLGenericFormElementImpl::parseAttribute(attr);
+        HTMLGenericFormElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -2862,16 +2876,16 @@ NodeImpl::Id HTMLIsIndexElementImpl::id() const
     return ID_ISINDEX;
 }
 
-void HTMLIsIndexElementImpl::parseAttribute(AttributeImpl* attr)
+void HTMLIsIndexElementImpl::parseHTMLAttribute(HTMLAttributeImpl* attr)
 {
     switch(attr->id())
     {
     case ATTR_PROMPT:
 	setValue(attr->value());
     default:
-        // don't call HTMLInputElement::parseAttribute here, as it would
+        // don't call HTMLInputElement::parseHTMLAttribute here, as it would
         // accept attributes this element does not support
-        HTMLGenericFormElementImpl::parseAttribute(attr);
+        HTMLGenericFormElementImpl::parseHTMLAttribute(attr);
     }
 }
 
diff --git a/WebCore/khtml/html/html_formimpl.h b/WebCore/khtml/html/html_formimpl.h
index 156752c..5855123 100644
--- a/WebCore/khtml/html/html_formimpl.h
+++ b/WebCore/khtml/html/html_formimpl.h
@@ -80,7 +80,7 @@ public:
 
     bool autoComplete() const { return m_autocomplete; }
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 
     void radioClicked( HTMLGenericFormElementImpl *caller );
 
@@ -142,7 +142,7 @@ public:
 
     virtual DOMString type() const = 0;
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     virtual void attach();
     virtual void reset() {}
 
@@ -212,7 +212,7 @@ public:
     virtual Id id() const;
     DOMString type() const;
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     virtual void defaultEventHandler(EventImpl *evt);
     virtual bool encoding(const QTextCodec*, khtml::encodingList&, bool);
 
@@ -308,7 +308,8 @@ public:
     virtual void click();
     virtual void accessKeyAction();
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 
     virtual void attach();
     virtual bool rendererIsNeeded(khtml::RenderStyle *);
@@ -360,7 +361,7 @@ public:
     
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 
     /**
      * the form element this label is associated to.
@@ -434,7 +435,7 @@ public:
 
     virtual void childrenChanged();
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 
     virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
     virtual bool encoding(const QTextCodec*, khtml::encodingList&, bool);
@@ -485,7 +486,7 @@ public:
     // ### this is just a rough guess
     virtual bool isEnumeratable() const { return false; }
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     virtual bool encoding(const QTextCodec*, khtml::encodingList&, bool);
 protected:
     AtomicString m_challenge;
@@ -510,7 +511,7 @@ public:
     virtual NodeImpl *removeChild ( NodeImpl *oldChild, int &exceptioncode );
     virtual NodeImpl *appendChild ( NodeImpl *newChild, int &exceptioncode );
     virtual NodeImpl *addChild( NodeImpl* newChild );
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     void recalcSelectOptions();
 
 };
@@ -535,7 +536,7 @@ public:
 
     long index() const;
     void setIndex( long );
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     DOMString value() const;
     void setValue(DOMStringImpl* value);
 
@@ -586,7 +587,7 @@ public:
 
     void select (  );
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
     virtual bool encoding(const QTextCodec*, khtml::encodingList&, bool);
     virtual void reset();
@@ -618,7 +619,7 @@ public:
     ~HTMLIsIndexElementImpl();
 
     virtual Id id() const;
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 
 protected:
     DOMString m_prompt;
diff --git a/WebCore/khtml/html/html_headimpl.cpp b/WebCore/khtml/html/html_headimpl.cpp
index 80d7824..de6e4cc 100644
--- a/WebCore/khtml/html/html_headimpl.cpp
+++ b/WebCore/khtml/html/html_headimpl.cpp
@@ -57,7 +57,7 @@ NodeImpl::Id HTMLBaseElementImpl::id() const
     return ID_BASE;
 }
 
-void HTMLBaseElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLBaseElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -70,7 +70,7 @@ void HTMLBaseElementImpl::parseAttribute(AttributeImpl *attr)
 	process();
 	break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -165,7 +165,7 @@ void HTMLLinkElementImpl::setDisabledState(bool _disabled)
     }
 }
 
-void HTMLLinkElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLLinkElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch (attr->id())
     {
@@ -189,7 +189,7 @@ void HTMLLinkElementImpl::parseAttribute(AttributeImpl *attr)
         setDisabledState(!attr->isNull());
         break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -313,7 +313,7 @@ NodeImpl::Id HTMLMetaElementImpl::id() const
     return ID_META;
 }
 
-void HTMLMetaElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLMetaElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -328,7 +328,7 @@ void HTMLMetaElementImpl::parseAttribute(AttributeImpl *attr)
     case ATTR_NAME:
       break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -380,7 +380,7 @@ NodeImpl::Id HTMLStyleElementImpl::id() const
 }
 
 // other stuff...
-void HTMLStyleElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLStyleElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch (attr->id())
     {
@@ -391,7 +391,7 @@ void HTMLStyleElementImpl::parseAttribute(AttributeImpl *attr)
         m_media = attr->value().string().lower();
         break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
diff --git a/WebCore/khtml/html/html_headimpl.h b/WebCore/khtml/html/html_headimpl.h
index 0707490..f870bab 100644
--- a/WebCore/khtml/html/html_headimpl.h
+++ b/WebCore/khtml/html/html_headimpl.h
@@ -52,7 +52,7 @@ public:
     DOMString target() const { return m_target; }
 
     virtual Id id() const;
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     virtual void insertedIntoDocument();
     virtual void removedFromDocument();
 
@@ -78,7 +78,7 @@ public:
     StyleSheetImpl* sheet() const { return m_sheet; }
 
     // overload from HTMLElementImpl
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 
     void process();
 
@@ -120,7 +120,7 @@ public:
     ~HTMLMetaElementImpl();
 
     virtual Id id() const;
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     virtual void insertedIntoDocument();
 
     void process();
@@ -155,7 +155,7 @@ public:
     StyleSheetImpl *sheet() const { return m_sheet; }
 
     // overload from HTMLElementImpl
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     virtual void insertedIntoDocument();
     virtual void removedFromDocument();
     virtual void childrenChanged();
diff --git a/WebCore/khtml/html/html_imageimpl.cpp b/WebCore/khtml/html/html_imageimpl.cpp
index 3d148d5..832c0fd 100644
--- a/WebCore/khtml/html/html_imageimpl.cpp
+++ b/WebCore/khtml/html/html_imageimpl.cpp
@@ -70,7 +70,29 @@ NodeImpl::Id HTMLImageElementImpl::id() const
     return ID_IMG;
 }
 
-void HTMLImageElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLImageElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch(attr->id())
+    {
+        case ATTR_WIDTH:
+        case ATTR_HEIGHT:
+        case ATTR_VSPACE:
+        case ATTR_HSPACE:
+        case ATTR_VALIGN:
+            result = eUniversal;
+            return false;
+        case ATTR_BORDER:
+        case ATTR_ALIGN:
+            result = eReplaced; // Shared with embeds and iframes
+            return false;
+        default:
+            break;
+    }
+
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLImageElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch (attr->id())
     {
@@ -79,34 +101,34 @@ void HTMLImageElementImpl::parseAttribute(AttributeImpl *attr)
         if (m_render) m_render->updateFromElement();
         break;
     case ATTR_WIDTH:
-        addCSSLength(CSS_PROP_WIDTH, attr->value());
+        addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
         break;
     case ATTR_HEIGHT:
-        addCSSLength(CSS_PROP_HEIGHT, attr->value());
+        addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
         break;
     case ATTR_BORDER:
         // border="noborder" -> border="0"
         if(attr->value().toInt()) {
-            addCSSLength(CSS_PROP_BORDER_WIDTH, attr->value());
-            addCSSProperty( CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID );
-            addCSSProperty( CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID );
-            addCSSProperty( CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID );
-            addCSSProperty( CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID );
+            addCSSLength(attr, CSS_PROP_BORDER_WIDTH, attr->value());
+            addCSSProperty(attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
+            addCSSProperty(attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
+            addCSSProperty(attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
+            addCSSProperty(attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
         }
         break;
     case ATTR_VSPACE:
-        addCSSLength(CSS_PROP_MARGIN_TOP, attr->value());
-        addCSSLength(CSS_PROP_MARGIN_BOTTOM, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());
         break;
     case ATTR_HSPACE:
-        addCSSLength(CSS_PROP_MARGIN_LEFT, attr->value());
-        addCSSLength(CSS_PROP_MARGIN_RIGHT, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value());
         break;
     case ATTR_ALIGN:
-	addHTMLAlignment( attr->value() );
+        addHTMLAlignment(attr);
 	break;
     case ATTR_VALIGN:
-	addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value());
+        addCSSProperty(attr, CSS_PROP_VERTICAL_ALIGN, attr->value());
         break;
     case ATTR_USEMAP:
         if ( attr->value().domString()[0] == '#' )
@@ -158,7 +180,7 @@ void HTMLImageElementImpl::parseAttribute(AttributeImpl *attr)
 	}
 	// fall through
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -330,7 +352,7 @@ HTMLMapElementImpl::mapMouseEvent(int x_, int y_, int width_, int height_,
     return false;
 }
 
-void HTMLMapElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLMapElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch (attr->id())
     {
@@ -350,7 +372,7 @@ void HTMLMapElementImpl::parseAttribute(AttributeImpl *attr)
         break;
     }
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -376,7 +398,7 @@ NodeImpl::Id HTMLAreaElementImpl::id() const
     return ID_AREA;
 }
 
-void HTMLAreaElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLAreaElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch (attr->id())
     {
@@ -405,7 +427,7 @@ void HTMLAreaElementImpl::parseAttribute(AttributeImpl *attr)
     case ATTR_ACCESSKEY:
         break;
     default:
-        HTMLAnchorElementImpl::parseAttribute(attr);
+        HTMLAnchorElementImpl::parseHTMLAttribute(attr);
     }
 }
 
diff --git a/WebCore/khtml/html/html_imageimpl.h b/WebCore/khtml/html/html_imageimpl.h
index b921e91..574fa4c 100644
--- a/WebCore/khtml/html/html_imageimpl.h
+++ b/WebCore/khtml/html/html_imageimpl.h
@@ -43,7 +43,8 @@ public:
 
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *);
 
     virtual void attach();
     virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
@@ -80,7 +81,7 @@ public:
 
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 
     bool isDefault() const { return shape==Default; }
 
@@ -113,7 +114,7 @@ public:
 
     virtual DOMString getName() const { return name; }
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 
     bool mapMouseEvent(int x_, int y_, int width_, int height_,
                        khtml::RenderObject::NodeInfo& info);
diff --git a/WebCore/khtml/html/html_inlineimpl.cpp b/WebCore/khtml/html/html_inlineimpl.cpp
index 61d2b8b..ebd1a06 100644
--- a/WebCore/khtml/html/html_inlineimpl.cpp
+++ b/WebCore/khtml/html/html_inlineimpl.cpp
@@ -210,7 +210,7 @@ void HTMLAnchorElementImpl::defaultEventHandler(EventImpl *evt)
 }
 
 
-void HTMLAnchorElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLAnchorElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -225,7 +225,7 @@ void HTMLAnchorElementImpl::parseAttribute(AttributeImpl *attr)
     case ATTR_REL:
 	break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -249,27 +249,35 @@ NodeImpl::Id HTMLBRElementImpl::id() const
     return ID_BR;
 }
 
-void HTMLBRElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLBRElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
 {
-    switch(attr->id())
+    if (attr->id() == ATTR_CLEAR) {
+        result = eUniversal;
+        return false;
+    }
+    
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLBRElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
+{
+    switch (attr->id())
     {
     case ATTR_CLEAR:
     {
         DOMString str = attr->value();
-        // If the string is empty, then remove the clear property. 
+        // If the string is empty, then don't add the clear property. 
         // <br clear> and <br clear=""> are just treated like <br> by Gecko,
         // Mac IE, etc. -dwh
-        if (str.isEmpty())
-            removeCSSProperty(CSS_PROP_CLEAR);
-        else {
-            if (strcasecmp (str,"all")==0) 
+        if (!str.isEmpty()) {
+            if (strcasecmp(str,"all") == 0) 
                 str = "both";
-            addCSSProperty(CSS_PROP_CLEAR, str);
+            addCSSProperty(attr, CSS_PROP_CLEAR, str);
         }
         break;
     }
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -340,7 +348,23 @@ static bool parseFontSizeNumber(const DOMString &s, int &size)
     return true;
 }
 
-void HTMLFontElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLFontElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch(attr->id())
+    {
+        case ATTR_SIZE:
+        case ATTR_COLOR:
+        case ATTR_FACE:
+            result = eUniversal;
+            return false;
+        default:
+            break;
+    }
+    
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLFontElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -363,19 +387,17 @@ void HTMLFontElementImpl::parseAttribute(AttributeImpl *attr)
                 else
                     size = CSS_VAL_X_SMALL;
             }
-            addCSSProperty(CSS_PROP_FONT_SIZE, size);
+            addCSSProperty(attr, CSS_PROP_FONT_SIZE, size);
         }
         break;
     }
     case ATTR_COLOR:
-        addHTMLColor(CSS_PROP_COLOR, attr->value());
+        addHTMLColor(attr, CSS_PROP_COLOR, attr->value());
         break;
     case ATTR_FACE:
-        addCSSProperty(CSS_PROP_FONT_FAMILY, attr->value());
+        addCSSProperty(attr, CSS_PROP_FONT_FAMILY, attr->value());
         break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
-
-
diff --git a/WebCore/khtml/html/html_inlineimpl.h b/WebCore/khtml/html/html_inlineimpl.h
index 95876e7..9dd48ec 100644
--- a/WebCore/khtml/html/html_inlineimpl.h
+++ b/WebCore/khtml/html/html_inlineimpl.h
@@ -42,7 +42,7 @@ public:
 #endif
     virtual bool isFocusable() const;
     virtual Id id() const;
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
     virtual void defaultEventHandler(EventImpl *evt);
     virtual void accessKeyAction();
 protected:
@@ -60,7 +60,10 @@ public:
     ~HTMLBRElementImpl();
 
     virtual Id id() const;
-    virtual void parseAttribute(AttributeImpl *attr);
+    
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
+    
     virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
 };
 
@@ -73,7 +76,9 @@ public:
     ~HTMLFontElementImpl();
 
     virtual Id id() const;
-    virtual void parseAttribute(AttributeImpl *attr);
+    
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 };
 
 }; //namespace
diff --git a/WebCore/khtml/html/html_listimpl.cpp b/WebCore/khtml/html/html_listimpl.cpp
index 90fb64d..47f7674 100644
--- a/WebCore/khtml/html/html_listimpl.cpp
+++ b/WebCore/khtml/html/html_listimpl.cpp
@@ -37,15 +37,28 @@ NodeImpl::Id HTMLUListElementImpl::id() const
     return ID_UL;
 }
 
-void HTMLUListElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLUListElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch (attr->id()) {
+        case ATTR_TYPE:
+            result = eUnorderedList;
+            return false;
+        default:
+            break;
+    }
+    
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLUListElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
     case ATTR_TYPE:
-        addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, attr->value());
+        addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, attr->value());
         break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -70,26 +83,39 @@ NodeImpl::Id HTMLOListElementImpl::id() const
     return ID_OL;
 }
 
-void HTMLOListElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLOListElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch (attr->id()) {
+        case ATTR_TYPE:
+            result = eListItem; // Share with <li>
+            return false;
+        default:
+            break;
+    }
+    
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLOListElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
     case ATTR_TYPE:
         if ( strcmp( attr->value(), "a" ) == 0 )
-            addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_LOWER_ALPHA);
+            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_LOWER_ALPHA);
         else if ( strcmp( attr->value(), "A" ) == 0 )
-            addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_UPPER_ALPHA);
+            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_UPPER_ALPHA);
         else if ( strcmp( attr->value(), "i" ) == 0 )
-            addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_LOWER_ROMAN);
+            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_LOWER_ROMAN);
         else if ( strcmp( attr->value(), "I" ) == 0 )
-            addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_UPPER_ROMAN);
+            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_UPPER_ROMAN);
         else if ( strcmp( attr->value(), "1" ) == 0 )
-            addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_DECIMAL);
+            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_DECIMAL);
         break;
     case ATTR_START:
             _start = !attr->isNull() ? attr->value().toInt() : 1;
     default:
-        HTMLUListElementImpl::parseAttribute(attr);
+        HTMLUListElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -100,8 +126,20 @@ NodeImpl::Id HTMLLIElementImpl::id() const
     return ID_LI;
 }
 
+bool HTMLLIElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch (attr->id()) {
+        case ATTR_TYPE:
+            result = eListItem; // Share with <ol> since all the values are the same
+            return false;
+        default:
+            break;
+    }
+    
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
 
-void HTMLLIElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLLIElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -119,20 +157,20 @@ void HTMLLIElementImpl::parseAttribute(AttributeImpl *attr)
         break;
     case ATTR_TYPE:
         if ( strcmp( attr->value(), "a" ) == 0 )
-            addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_LOWER_ALPHA);
+            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_LOWER_ALPHA);
         else if ( strcmp( attr->value(), "A" ) == 0 )
-            addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_UPPER_ALPHA);
+            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_UPPER_ALPHA);
         else if ( strcmp( attr->value(), "i" ) == 0 )
-            addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_LOWER_ROMAN);
+            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_LOWER_ROMAN);
         else if ( strcmp( attr->value(), "I" ) == 0 )
-            addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_UPPER_ROMAN);
+            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_UPPER_ROMAN);
         else if ( strcmp( attr->value(), "1" ) == 0 )
-            addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_DECIMAL);
+            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_DECIMAL);
         else
-            addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, attr->value());
+            addCSSProperty(attr, CSS_PROP_LIST_STYLE_TYPE, attr->value());
         break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
diff --git a/WebCore/khtml/html/html_listimpl.h b/WebCore/khtml/html/html_listimpl.h
index 679cb7d..cb6a989 100644
--- a/WebCore/khtml/html/html_listimpl.h
+++ b/WebCore/khtml/html/html_listimpl.h
@@ -42,7 +42,8 @@ public:
 
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *);
 
     virtual int start() const { return 1; }
 };
@@ -79,7 +80,9 @@ public:
     virtual ~HTMLOListElementImpl() {}
 
     virtual Id id() const;
-    virtual void parseAttribute(AttributeImpl *);
+    
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *);
 
     int start() const { return _start; }
 private:
@@ -97,7 +100,8 @@ public:
 
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 
     virtual void attach();
 
diff --git a/WebCore/khtml/html/html_objectimpl.cpp b/WebCore/khtml/html/html_objectimpl.cpp
index d53e5f0..65812c4 100644
--- a/WebCore/khtml/html/html_objectimpl.cpp
+++ b/WebCore/khtml/html/html_objectimpl.cpp
@@ -71,10 +71,26 @@ NodeImpl::Id HTMLAppletElementImpl::id() const
     return ID_APPLET;
 }
 
-void HTMLAppletElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLAppletElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
 {
-    switch( attr->id() )
-    {
+    switch (attr->id()) {
+        case ATTR_WIDTH:
+        case ATTR_HEIGHT:
+            result = eUniversal;
+            return false;
+        case ATTR_ALIGN:
+            result = eReplaced; // Share with <img> since the alignment behavior is the same.
+            return false;
+        default:
+            break;
+    }
+    
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLAppletElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
+{
+    switch (attr->id()) {
     case ATTR_ALT:
     case ATTR_ARCHIVE:
     case ATTR_CODE:
@@ -85,16 +101,16 @@ void HTMLAppletElementImpl::parseAttribute(AttributeImpl *attr)
     case ATTR_OBJECT:
         break;
     case ATTR_WIDTH:
-        addCSSLength(CSS_PROP_WIDTH, attr->value());
+        addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
         break;
     case ATTR_HEIGHT:
-        addCSSLength(CSS_PROP_HEIGHT, attr->value());
+        addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
         break;
     case ATTR_ALIGN:
-	addHTMLAlignment( attr->value() );
+	addHTMLAlignment(attr);
 	break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -201,9 +217,7 @@ KJS::Bindings::Instance *HTMLAppletElementImpl::getAppletInstance() const
 
 HTMLEmbedElementImpl::HTMLEmbedElementImpl(DocumentPtr *doc)
     : HTMLElementImpl(doc)
-{
-    hidden = false;
-}
+{}
 
 HTMLEmbedElementImpl::~HTMLEmbedElementImpl()
 {
@@ -214,7 +228,29 @@ NodeImpl::Id HTMLEmbedElementImpl::id() const
     return ID_EMBED;
 }
 
-void HTMLEmbedElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLEmbedElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch (attr->id()) {
+        case ATTR_WIDTH:
+        case ATTR_HEIGHT:
+        case ATTR_BORDER:
+        case ATTR_VSPACE:
+        case ATTR_HSPACE:
+        case ATTR_VALIGN:
+        case ATTR_HIDDEN:
+            result = eUniversal;
+            return false;
+        case ATTR_ALIGN:
+            result = eReplaced; // Share with <img> since the alignment behavior is the same.
+            return false;
+        default:
+            break;
+    }
+    
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLEmbedElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
   QString val = attr->value().string();
   
@@ -232,44 +268,46 @@ void HTMLEmbedElementImpl::parseAttribute(AttributeImpl *attr)
          url = khtml::parseURL(attr->value()).string();
          break;
      case ATTR_WIDTH:
-        addCSSLength( CSS_PROP_WIDTH, attr->value() );
+        addCSSLength( attr, CSS_PROP_WIDTH, attr->value() );
         break;
      case ATTR_HEIGHT:
-        addCSSLength( CSS_PROP_HEIGHT, attr->value());
+        addCSSLength( attr, CSS_PROP_HEIGHT, attr->value());
         break;
      case ATTR_BORDER:
-        addCSSLength(CSS_PROP_BORDER_WIDTH, attr->value());
-        addCSSProperty( CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID );
-        addCSSProperty( CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID );
-        addCSSProperty( CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID );
-        addCSSProperty( CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID );
+        addCSSLength(attr, CSS_PROP_BORDER_WIDTH, attr->value());
+        addCSSProperty( attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID );
+        addCSSProperty( attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID );
+        addCSSProperty( attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID );
+        addCSSProperty( attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID );
         break;
      case ATTR_VSPACE:
-        addCSSLength(CSS_PROP_MARGIN_TOP, attr->value());
-        addCSSLength(CSS_PROP_MARGIN_BOTTOM, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());
         break;
      case ATTR_HSPACE:
-        addCSSLength(CSS_PROP_MARGIN_LEFT, attr->value());
-        addCSSLength(CSS_PROP_MARGIN_RIGHT, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value());
         break;
      case ATTR_ALIGN:
-	addHTMLAlignment( attr->value() );
+	addHTMLAlignment(attr);
 	break;
      case ATTR_VALIGN:
-        addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value());
+        addCSSProperty(attr, CSS_PROP_VERTICAL_ALIGN, attr->value());
         break;
      case ATTR_PLUGINPAGE:
      case ATTR_PLUGINSPAGE:
         pluginPage = val;
         break;
      case ATTR_HIDDEN:
-        if (val.lower()=="yes" || val.lower()=="true")
-           hidden = true;
-        else
-           hidden = false;
+        if (val.lower()=="yes" || val.lower()=="true") {
+            // FIXME: Not dynamic, but it's not really important that such a rarely-used
+            // feature work dynamically.
+            addCSSLength( attr, CSS_PROP_WIDTH, "0" );
+            addCSSLength( attr, CSS_PROP_HEIGHT, "0" );
+        }
         break;
      default:
-        HTMLElementImpl::parseAttribute( attr );
+        HTMLElementImpl::parseHTMLAttribute( attr );
   }
 }
 
@@ -288,13 +326,6 @@ RenderObject *HTMLEmbedElementImpl::createRenderer(RenderArena *arena, RenderSty
 
 void HTMLEmbedElementImpl::attach()
 {
-    if (hidden) {
-        // FIXME: Not dynamic, but it's not really important that such a rarely-used
-        // feature work dynamically.
-        addCSSLength( CSS_PROP_WIDTH, "0" );
-        addCSSLength( CSS_PROP_HEIGHT, "0" );
-    }
-    
     HTMLElementImpl::attach();
     if (m_render) {
         static_cast<RenderPartObject*>(m_render)->updateWidget();
@@ -322,7 +353,21 @@ HTMLFormElementImpl *HTMLObjectElementImpl::form() const
   return 0;
 }
 
-void HTMLObjectElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLObjectElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch (attr->id()) {
+        case ATTR_WIDTH:
+        case ATTR_HEIGHT:
+            result = eUniversal;
+            return false;
+        default:
+            break;
+    }
+    
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLObjectElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
   QString val = attr->value().string();
   int pos;
@@ -340,10 +385,10 @@ void HTMLObjectElementImpl::parseAttribute(AttributeImpl *attr)
       needWidgetUpdate = true;
       break;
     case ATTR_WIDTH:
-      addCSSLength( CSS_PROP_WIDTH, attr->value());
+      addCSSLength( attr, CSS_PROP_WIDTH, attr->value());
       break;
     case ATTR_HEIGHT:
-      addCSSLength( CSS_PROP_HEIGHT, attr->value());
+      addCSSLength( attr, CSS_PROP_HEIGHT, attr->value());
       break;
     case ATTR_CLASSID:
       classId = val;
@@ -358,7 +403,7 @@ void HTMLObjectElementImpl::parseAttribute(AttributeImpl *attr)
 	    getDocument()->createHTMLEventListener(attr->value().string()));
         break;
     default:
-      HTMLElementImpl::parseAttribute( attr );
+      HTMLElementImpl::parseHTMLAttribute( attr );
   }
 }
 
@@ -456,7 +501,7 @@ NodeImpl::Id HTMLParamElementImpl::id() const
     return ID_PARAM;
 }
 
-void HTMLParamElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLParamElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch( attr->id() )
     {
diff --git a/WebCore/khtml/html/html_objectimpl.h b/WebCore/khtml/html/html_objectimpl.h
index 2a38122..0ee4431 100644
--- a/WebCore/khtml/html/html_objectimpl.h
+++ b/WebCore/khtml/html/html_objectimpl.h
@@ -51,7 +51,9 @@ public:
 
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *token);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *token);
+    
     virtual bool rendererIsNeeded(khtml::RenderStyle *);
     virtual khtml::RenderObject *createRenderer(RenderArena *, khtml::RenderStyle *);
 
@@ -81,7 +83,8 @@ public:
 
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 
     virtual void attach();
     virtual bool rendererIsNeeded(khtml::RenderStyle *);
@@ -90,7 +93,6 @@ public:
     QString url;
     QString pluginPage;
     QString serviceType;
-    bool hidden;
 };
 
 // -------------------------------------------------------------------------
@@ -106,7 +108,8 @@ public:
 
     HTMLFormElementImpl *form() const;
 
-    virtual void parseAttribute(AttributeImpl *token);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *token);
 
     virtual void attach();
     virtual bool rendererIsNeeded(khtml::RenderStyle *);
@@ -135,7 +138,7 @@ public:
 
     virtual Id id() const;
 
-    virtual void parseAttribute(AttributeImpl *token);
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *token);
 
     QString name() const { return m_name.string(); }
     QString value() const { return m_value.string(); }
diff --git a/WebCore/khtml/html/html_tableimpl.cpp b/WebCore/khtml/html/html_tableimpl.cpp
index ae951dc..b9e4ed6 100644
--- a/WebCore/khtml/html/html_tableimpl.cpp
+++ b/WebCore/khtml/html/html_tableimpl.cpp
@@ -61,9 +61,7 @@ HTMLTableElementImpl::HTMLTableElementImpl(DocumentPtr *doc)
     rules = None;
     frame = Void;
 #endif
-
-    m_sharedCellDecls = 0;
-    
+ 
     padding = 1;
     
     m_noBorder = true;
@@ -72,11 +70,6 @@ HTMLTableElementImpl::HTMLTableElementImpl(DocumentPtr *doc)
 
 HTMLTableElementImpl::~HTMLTableElementImpl()
 {
-    if (m_sharedCellDecls) {
-        m_sharedCellDecls->setNode(0);
-        m_sharedCellDecls->setParent(0);
-        m_sharedCellDecls->deref();
-    }
 }
 
 NodeImpl::Id HTMLTableElementImpl::id() const
@@ -84,31 +77,6 @@ NodeImpl::Id HTMLTableElementImpl::id() const
     return ID_TABLE;
 }
 
-DOM::CSSStyleDeclarationImpl* HTMLTableElementImpl::createSharedCellDecls()
-{
-    if (!m_sharedCellDecls) {
-        m_sharedCellDecls = new CSSStyleDeclarationImpl(0);
-        m_sharedCellDecls->ref();
-        m_sharedCellDecls->setParent(getDocument()->elementSheet());
-        m_sharedCellDecls->setNode(this);
-        m_sharedCellDecls->setStrictParsing( !getDocument()->inCompatMode() );
-
-        if (m_noBorder)
-            m_sharedCellDecls->setProperty(CSS_PROP_BORDER_WIDTH, "0", false);
-        else {
-            m_sharedCellDecls->setProperty(CSS_PROP_BORDER_WIDTH, "1px", false);
-            int v = m_solid ? CSS_VAL_SOLID : CSS_VAL_INSET;
-            m_sharedCellDecls->setProperty(CSS_PROP_BORDER_TOP_STYLE, v, false);
-            m_sharedCellDecls->setProperty(CSS_PROP_BORDER_BOTTOM_STYLE, v, false);
-            m_sharedCellDecls->setProperty(CSS_PROP_BORDER_LEFT_STYLE, v, false);
-            m_sharedCellDecls->setProperty(CSS_PROP_BORDER_RIGHT_STYLE, v, false);
-            m_sharedCellDecls->setProperty(CSS_PROP_BORDER_COLOR, "inherit", false);
-        }
-    }
-    
-    return m_sharedCellDecls;
-}
-
 NodeImpl* HTMLTableElementImpl::setCaption( HTMLTableCaptionElementImpl *c )
 {
     int exceptioncode = 0;
@@ -376,43 +344,73 @@ NodeImpl *HTMLTableElementImpl::addChild(NodeImpl *child)
     return retval;
 }
 
-void HTMLTableElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLTableElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch(attr->id()) {
+        case ATTR_WIDTH:
+        case ATTR_HEIGHT:
+        case ATTR_BGCOLOR:
+        case ATTR_BACKGROUND:
+        case ATTR_CELLSPACING:
+        case ATTR_VSPACE:
+        case ATTR_HSPACE:
+        case ATTR_VALIGN:
+            result = eUniversal;
+            return false;
+        case ATTR_BORDERCOLOR:
+            result = eUniversal;
+            return true;
+        case ATTR_BORDER:
+            result = eTable;
+            return true;
+        case ATTR_ALIGN:
+            result = eTable;
+            return false;
+        default:
+            break;
+    }
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLTableElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
-    // ### to CSS!!
     switch(attr->id())
     {
     case ATTR_WIDTH:
-        if (!attr->value().isEmpty())
-            addCSSLength( CSS_PROP_WIDTH, attr->value() );
-        else
-            removeCSSProperty(CSS_PROP_WIDTH);
+        addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
         break;
     case ATTR_HEIGHT:
-        if (!attr->value().isEmpty())
-            addCSSLength(CSS_PROP_HEIGHT, attr->value());
-        else
-            removeCSSProperty(CSS_PROP_HEIGHT);
+        addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
         break;
     case ATTR_BORDER:
     {
-        int border;
-        // ### this needs more work, as the border value is not only
-        //     the border of the box, but also between the cells
-        if (attr->isNull())
-            border = 0;
-        else if(attr->isEmpty())
-            border = 1;
-        else
-            border = attr->value().toInt();
+        m_noBorder = true;
+        if (attr->isNull()) break;
+        if (attr->decl()) {
+            CSSValueImpl* val = attr->decl()->getPropertyCSSValue(CSS_PROP_BORDER_LEFT_WIDTH);
+            if (val && val->isPrimitiveValue()) {
+                CSSPrimitiveValueImpl* primVal = static_cast<CSSPrimitiveValueImpl*>(val);
+                m_noBorder = !primVal->getFloatValue(CSSPrimitiveValue::CSS_NUMBER);
+            }
+        }
+        else {
+            // ### this needs more work, as the border value is not only
+            //     the border of the box, but also between the cells
+            int border = 0;
+            if (attr->isEmpty())
+                border = 1;
+            else
+                border = attr->value().toInt();
 #ifdef DEBUG_DRAW_BORDER
-        border=1;
+            border=1;
 #endif
-        m_noBorder = !border;
-        DOMString v = QString::number( border );
-        addCSSLength(CSS_PROP_BORDER_WIDTH, v );
+            m_noBorder = !border;
+            DOMString v = QString::number( border );
+            addCSSLength(attr, CSS_PROP_BORDER_WIDTH, v );
+        }
 #if 0
         // wanted by HTML4 specs
-        if(!border)
+        if (m_noBorder)
             frame = Void, rules = None;
         else
             frame = Box, rules = All;
@@ -420,18 +418,16 @@ void HTMLTableElementImpl::parseAttribute(AttributeImpl *attr)
         break;
     }
     case ATTR_BGCOLOR:
-        if (!attr->value().isEmpty())
-            addHTMLColor(CSS_PROP_BACKGROUND_COLOR, attr->value());
-        else
-            removeCSSProperty(CSS_PROP_BACKGROUND_COLOR);
+        addHTMLColor(attr, CSS_PROP_BACKGROUND_COLOR, attr->value());
         break;
     case ATTR_BORDERCOLOR:
-        if(!attr->value().isEmpty()) {
-            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);
-            addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
+        m_solid = attr->decl();
+        if (!attr->decl() && !attr->isEmpty()) {
+            addHTMLColor(attr, CSS_PROP_BORDER_COLOR, attr->value());
+            addCSSProperty(attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
+            addCSSProperty(attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
+            addCSSProperty(attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
+            addCSSProperty(attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
             m_solid = true;
         }
         break;
@@ -439,9 +435,7 @@ void HTMLTableElementImpl::parseAttribute(AttributeImpl *attr)
     {
         QString url = khtml::parseURL( attr->value() ).string();
         if (!url.isEmpty())
-            addCSSImageProperty(CSS_PROP_BACKGROUND_IMAGE, getDocument()->completeURL(url));
-        else
-            removeCSSProperty(CSS_PROP_BACKGROUND_IMAGE);
+            addCSSImageProperty(attr, CSS_PROP_BACKGROUND_IMAGE, getDocument()->completeURL(url));
         break;
     }
     case ATTR_FRAME:
@@ -482,9 +476,7 @@ void HTMLTableElementImpl::parseAttribute(AttributeImpl *attr)
         break;
    case ATTR_CELLSPACING:
         if (!attr->value().isEmpty())
-            addCSSLength(CSS_PROP_BORDER_SPACING, attr->value());
-        else
-            removeCSSProperty(CSS_PROP_BORDER_SPACING);
+            addCSSLength(attr, CSS_PROP_BORDER_SPACING, attr->value());
         break;
     case ATTR_CELLPADDING:
         if (!attr->value().isEmpty())
@@ -508,45 +500,93 @@ void HTMLTableElementImpl::parseAttribute(AttributeImpl *attr)
 #endif
     }
     case ATTR_VSPACE:
-        addCSSLength(CSS_PROP_MARGIN_TOP, attr->value());
-        addCSSLength(CSS_PROP_MARGIN_BOTTOM, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_TOP, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_BOTTOM, attr->value());
         break;
     case ATTR_HSPACE:
-        addCSSLength(CSS_PROP_MARGIN_LEFT, attr->value());
-        addCSSLength(CSS_PROP_MARGIN_RIGHT, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_LEFT, attr->value());
+        addCSSLength(attr, CSS_PROP_MARGIN_RIGHT, attr->value());
         break;
     case ATTR_ALIGN:
         if (!attr->value().isEmpty())
-            addCSSProperty(CSS_PROP_FLOAT, attr->value());
-        else
-            removeCSSProperty(CSS_PROP_FLOAT);
+            addCSSProperty(attr, CSS_PROP_FLOAT, attr->value());
         break;
     case ATTR_VALIGN:
         if (!attr->value().isEmpty())
-            addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value());
-        else
-            removeCSSProperty(CSS_PROP_VERTICAL_ALIGN);
+            addCSSProperty(attr, CSS_PROP_VERTICAL_ALIGN, attr->value());
         break;
     case ATTR_NOSAVE:
 	break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
-void HTMLTableElementImpl::attach()
+CSSStyleDeclarationImpl* HTMLTableElementImpl::additionalAttributeStyleDecl()
 {
-    assert(!m_attached);
-    if (parent()->renderer()) {
-        if (!m_noBorder) {
-            int v = m_solid ? CSS_VAL_SOLID : CSS_VAL_OUTSET;
-            addCSSProperty(CSS_PROP_BORDER_TOP_STYLE, v);
-            addCSSProperty(CSS_PROP_BORDER_BOTTOM_STYLE, v);
-            addCSSProperty(CSS_PROP_BORDER_LEFT_STYLE, v);
-            addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, v);
+    if (m_noBorder)
+        return 0;
+    HTMLAttributeImpl attr(ATTR_TABLEBORDER, m_solid ? "solid" : "outset");
+    CSSMappedAttributeDeclarationImpl* decl = getMappedAttributeDecl(ePersistent, &attr);
+    if (!decl) {
+        decl = new CSSMappedAttributeDeclarationImpl(0);
+        decl->setParent(getDocument()->elementSheet());
+        decl->parent()->ref();
+        decl->setNode(this);
+        decl->setStrictParsing(false); // Mapped attributes are just always quirky.
+        
+        decl->ref(); // This single ref pins us in the table until the document dies.
+
+        int v = m_solid ? CSS_VAL_SOLID : CSS_VAL_OUTSET;
+        decl->setProperty(CSS_PROP_BORDER_TOP_STYLE, v, false);
+        decl->setProperty(CSS_PROP_BORDER_BOTTOM_STYLE, v, false);
+        decl->setProperty(CSS_PROP_BORDER_LEFT_STYLE, v, false);
+        decl->setProperty(CSS_PROP_BORDER_RIGHT_STYLE, v, false);
+
+        setMappedAttributeDecl(ePersistent, &attr, decl);
+        decl->setParent(0);
+        decl->setNode(0);
+        decl->setMappedState(ePersistent, attr.id(), attr.value());
+    }
+    return decl;
+}
+
+CSSStyleDeclarationImpl* HTMLTableElementImpl::getSharedCellDecl()
+{
+    HTMLAttributeImpl attr(ATTR_CELLBORDER, m_noBorder ? "none" : (m_solid ? "solid" : "inset"));
+    CSSMappedAttributeDeclarationImpl* decl = getMappedAttributeDecl(ePersistent, &attr);
+    if (!decl) {
+        decl = new CSSMappedAttributeDeclarationImpl(0);
+        decl->setParent(getDocument()->elementSheet());
+        decl->parent()->ref();
+        decl->setNode(this);
+        decl->setStrictParsing(false); // Mapped attributes are just always quirky.
+        
+        decl->ref(); // This single ref pins us in the table until the table dies.
+        
+        if (m_noBorder)
+            decl->setProperty(CSS_PROP_BORDER_WIDTH, "0", false);
+        else {
+            decl->setProperty(CSS_PROP_BORDER_WIDTH, "1px", false);
+            int v = m_solid ? CSS_VAL_SOLID : CSS_VAL_INSET;
+            decl->setProperty(CSS_PROP_BORDER_TOP_STYLE, v, false);
+            decl->setProperty(CSS_PROP_BORDER_BOTTOM_STYLE, v, false);
+            decl->setProperty(CSS_PROP_BORDER_LEFT_STYLE, v, false);
+            decl->setProperty(CSS_PROP_BORDER_RIGHT_STYLE, v, false);
+            decl->setProperty(CSS_PROP_BORDER_COLOR, "inherit", false);
         }
+
+        setMappedAttributeDecl(ePersistent, &attr, decl);
+        decl->setParent(0);
+        decl->setNode(0);
+        decl->setMappedState(ePersistent, attr.id(), attr.value());
     }
+    return decl;
+}
 
+void HTMLTableElementImpl::attach()
+{
+    assert(!m_attached);
     HTMLElementImpl::attach();
     if ( m_render && m_render->isTable() )
 	static_cast<RenderTable *>(m_render)->setCellPadding( padding );
@@ -554,69 +594,79 @@ void HTMLTableElementImpl::attach()
 
 // --------------------------------------------------------------------------
 
-void HTMLTablePartElementImpl::parseAttribute(AttributeImpl *attr)
+bool HTMLTablePartElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch(attr->id()) {
+        case ATTR_BGCOLOR:
+        case ATTR_BACKGROUND:
+        case ATTR_BORDERCOLOR:
+        case ATTR_VALIGN:
+        case ATTR_HEIGHT:
+            result = eUniversal;
+            return false;
+        case ATTR_ALIGN:
+            result = eCell; // All table parts will just share in the TD space.
+            return false;
+        default:
+            break;
+    }
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLTablePartElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
     case ATTR_BGCOLOR:
-        if (!attr->isNull())
-            addHTMLColor(CSS_PROP_BACKGROUND_COLOR, attr->value() );
-        else
-            removeCSSProperty(CSS_PROP_BACKGROUND_COLOR);
+        addHTMLColor(attr, CSS_PROP_BACKGROUND_COLOR, attr->value() );
         break;
     case ATTR_BACKGROUND:
     {
         QString url = khtml::parseURL( attr->value() ).string();
         if (!url.isEmpty())
-            addCSSImageProperty(CSS_PROP_BACKGROUND_IMAGE, getDocument()->completeURL(url));
-        else
-            removeCSSProperty(CSS_PROP_BACKGROUND_IMAGE);
+            addCSSImageProperty(attr, CSS_PROP_BACKGROUND_IMAGE, getDocument()->completeURL(url));
         break;
     }
     case ATTR_BORDERCOLOR:
     {
-        if(!attr->value().isEmpty()) {
-            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);
-            addCSSProperty(CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
+        if (!attr->value().isEmpty()) {
+            addHTMLColor(attr, CSS_PROP_BORDER_COLOR, attr->value());
+            addCSSProperty(attr, CSS_PROP_BORDER_TOP_STYLE, CSS_VAL_SOLID);
+            addCSSProperty(attr, CSS_PROP_BORDER_BOTTOM_STYLE, CSS_VAL_SOLID);
+            addCSSProperty(attr, CSS_PROP_BORDER_LEFT_STYLE, CSS_VAL_SOLID);
+            addCSSProperty(attr, CSS_PROP_BORDER_RIGHT_STYLE, CSS_VAL_SOLID);
         }
         break;
     }
     case ATTR_VALIGN:
     {
         if (!attr->value().isEmpty())
-            addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value());
-        else
-            removeCSSProperty(CSS_PROP_VERTICAL_ALIGN);
+            addCSSProperty(attr, CSS_PROP_VERTICAL_ALIGN, attr->value());
         break;
     }
     case ATTR_ALIGN:
     {
         DOMString v = attr->value();
         if ( strcasecmp( attr->value(), "middle" ) == 0 || strcasecmp( attr->value(), "center" ) == 0 )
-            addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_CENTER);
+            addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_CENTER);
         else if (strcasecmp(attr->value(), "absmiddle") == 0)
-            addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL_CENTER);
+            addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL_CENTER);
         else if (strcasecmp(attr->value(), "left") == 0)
-            addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_LEFT);
+            addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_LEFT);
         else if (strcasecmp(attr->value(), "right") == 0)
-            addCSSProperty(CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_RIGHT);
+            addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, CSS_VAL__KHTML_RIGHT);
         else
-            addCSSProperty(CSS_PROP_TEXT_ALIGN, v);
+            addCSSProperty(attr, CSS_PROP_TEXT_ALIGN, v);
         break;
     }
     case ATTR_HEIGHT:
         if (!attr->value().isEmpty())
-            addCSSLength(CSS_PROP_HEIGHT, attr->value());
-        else
-            removeCSSProperty(CSS_PROP_HEIGHT);
+            addCSSLength(attr, CSS_PROP_HEIGHT, attr->value());
         break;
     case ATTR_NOSAVE:
 	break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -838,14 +888,27 @@ HTMLTableCellElementImpl::~HTMLTableCellElementImpl()
 {
 }
 
-void HTMLTableCellElementImpl::parseAttribute(AttributeImpl *attr)
+
+bool HTMLTableCellElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch(attr->id()) {
+        case ATTR_NOWRAP:
+            result = eUniversal;
+            return false;
+        case ATTR_WIDTH:
+        case ATTR_HEIGHT:
+            result = eCell; // Because of the quirky behavior of ignoring 0 values, cells are special.
+            return false;
+        default:
+            break;
+    }
+    return HTMLTablePartElementImpl::mapToEntry(attr, result);
+}
+
+void HTMLTableCellElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
-    case ATTR_BORDER:
-        // euhm? not supported by other browsers as far as I can see (Dirk)
-        //addCSSLength(CSS_PROP_BORDER_WIDTH, attr->value());
-        break;
     case ATTR_ROWSPAN:
         // ###
         rSpan = !attr->isNull() ? attr->value().toInt() : 1;
@@ -860,32 +923,26 @@ void HTMLTableCellElementImpl::parseAttribute(AttributeImpl *attr)
         break;
     case ATTR_NOWRAP:
         if (!attr->isNull())
-            addCSSProperty(CSS_PROP_WHITE_SPACE, CSS_VAL__KHTML_NOWRAP);
-        else
-            removeCSSProperty(CSS_PROP_WHITE_SPACE);
+            addCSSProperty(attr, CSS_PROP_WHITE_SPACE, CSS_VAL__KHTML_NOWRAP);
         break;
     case ATTR_WIDTH:
         if (!attr->value().isEmpty()) {
             int widthInt = attr->value().toInt();
             if (widthInt > 0) // width="0" is ignored for compatibility with WinIE.
-                addCSSLength( CSS_PROP_WIDTH, attr->value() );
+                addCSSLength( attr, CSS_PROP_WIDTH, attr->value() );
         }
-        else
-            removeCSSProperty(CSS_PROP_WIDTH);
         break;
     case ATTR_HEIGHT:
         if (!attr->value().isEmpty()) {
             int heightInt = attr->value().toInt();
             if (heightInt > 0) // height="0" is ignored for compatibility with WinIE.
-                addCSSLength( CSS_PROP_HEIGHT, attr->value() );
+                addCSSLength( attr, CSS_PROP_HEIGHT, attr->value() );
         }
-        else
-            removeCSSProperty(CSS_PROP_HEIGHT);
         break;
     case ATTR_NOSAVE:
 	break;
     default:
-        HTMLTablePartElementImpl::parseAttribute(attr);
+        HTMLTablePartElementImpl::parseHTMLAttribute(attr);
     }
 }
 
@@ -898,7 +955,7 @@ CSSStyleDeclarationImpl* HTMLTableCellElementImpl::additionalAttributeStyleDecl(
 
     if (p) {
         HTMLTableElementImpl* table = static_cast<HTMLTableElementImpl*>(p);
-        return table->m_sharedCellDecls;
+        return table->getSharedCellDecl();
     }
 
     return 0;
@@ -910,11 +967,6 @@ void HTMLTableCellElementImpl::attach()
     while(p && p->id() != ID_TABLE)
         p = static_cast<HTMLElementImpl*>(p->parentNode());
 
-    if (p) {
-        HTMLTableElementImpl* table = static_cast<HTMLTableElementImpl*>(p);
-        table->createSharedCellDecls();
-    }
-
     HTMLTablePartElementImpl::attach();
 }
 
@@ -932,8 +984,19 @@ NodeImpl::Id HTMLTableColElementImpl::id() const
     return _id;
 }
 
+bool HTMLTableColElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    switch(attr->id()) {
+        case ATTR_WIDTH:
+            result = eUniversal;
+            return false;
+        default:
+            break;
+    }
+    return HTMLTablePartElementImpl::mapToEntry(attr, result);
+}
 
-void HTMLTableColElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLTableColElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
@@ -942,18 +1005,10 @@ void HTMLTableColElementImpl::parseAttribute(AttributeImpl *attr)
         break;
     case ATTR_WIDTH:
         if (!attr->value().isEmpty())
-            addCSSLength(CSS_PROP_WIDTH, attr->value());
-        else
-            removeCSSProperty(CSS_PROP_WIDTH);
-        break;
-    case ATTR_VALIGN:
-        if (!attr->value().isEmpty())
-            addCSSProperty(CSS_PROP_VERTICAL_ALIGN, attr->value());
-        else
-            removeCSSProperty(CSS_PROP_VERTICAL_ALIGN);
+            addCSSLength(attr, CSS_PROP_WIDTH, attr->value());
         break;
     default:
-        HTMLTablePartElementImpl::parseAttribute(attr);
+        HTMLTablePartElementImpl::parseHTMLAttribute(attr);
     }
 
 }
@@ -965,19 +1020,25 @@ NodeImpl::Id HTMLTableCaptionElementImpl::id() const
     return ID_CAPTION;
 }
 
+bool HTMLTableCaptionElementImpl::mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const
+{
+    if (attr->id() == ATTR_ALIGN) {
+        result = eCaption;
+        return false;
+    }
+    return HTMLElementImpl::mapToEntry(attr, result);
+}
 
-void HTMLTableCaptionElementImpl::parseAttribute(AttributeImpl *attr)
+void HTMLTableCaptionElementImpl::parseHTMLAttribute(HTMLAttributeImpl *attr)
 {
     switch(attr->id())
     {
     case ATTR_ALIGN:
         if (!attr->value().isEmpty())
-            addCSSProperty(CSS_PROP_CAPTION_SIDE, attr->value());
-        else
-            removeCSSProperty(CSS_PROP_CAPTION_SIDE);
+            addCSSProperty(attr, CSS_PROP_CAPTION_SIDE, attr->value());
         break;
     default:
-        HTMLElementImpl::parseAttribute(attr);
+        HTMLElementImpl::parseHTMLAttribute(attr);
     }
 
 }
diff --git a/WebCore/khtml/html/html_tableimpl.h b/WebCore/khtml/html/html_tableimpl.h
index 813134f..6dac9ff 100644
--- a/WebCore/khtml/html/html_tableimpl.h
+++ b/WebCore/khtml/html/html_tableimpl.h
@@ -97,11 +97,16 @@ public:
 
     // overrides
     virtual NodeImpl *addChild(NodeImpl *child);
-    virtual void parseAttribute(AttributeImpl *attr);
+    
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
+
+    // Used to obtain either a solid or outset border decl.
+    virtual CSSStyleDeclarationImpl* additionalAttributeStyleDecl();
+    CSSStyleDeclarationImpl* getSharedCellDecl();
+
     virtual void attach();
 
-    DOM::CSSStyleDeclarationImpl* createSharedCellDecls();
-    
 protected:
     HTMLTableSectionElementImpl *head;
     HTMLTableSectionElementImpl *foot;
@@ -112,9 +117,7 @@ protected:
     Frame frame;
     Rules rules;
 #endif
-
-    DOM::CSSStyleDeclarationImpl *m_sharedCellDecls;
-    
+  
     bool m_noBorder     : 1;
     bool m_solid        : 1;
     uint unused		: 14;
@@ -132,7 +135,8 @@ public:
         : HTMLElementImpl(doc)
         { }
 
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 };
 
 // -------------------------------------------------------------------------
@@ -199,12 +203,15 @@ public:
     int rowSpan() const { return rSpan; }
     
     virtual Id id() const { return _id; }
-    virtual void parseAttribute(AttributeImpl *attr);
+    
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
+
     virtual void attach();
 
     // used by table cells to share style decls created by the enclosing table.
     virtual CSSStyleDeclarationImpl* additionalAttributeStyleDecl();
-    
+
 protected:
     int _row;
     int _col;
@@ -227,7 +234,8 @@ public:
     void setTable(HTMLTableElementImpl *t) { table = t; }
 
     // overrides
-    virtual void parseAttribute(AttributeImpl *attr);
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 
     int span() const { return _span; }
 
@@ -249,7 +257,9 @@ public:
         : HTMLTablePartElementImpl(doc) {}
 
     virtual Id id() const;
-    virtual void parseAttribute(AttributeImpl *attr);
+    
+    virtual bool mapToEntry(AttributeImpl* attr, MappedAttributeEntry& result) const;
+    virtual void parseHTMLAttribute(HTMLAttributeImpl *attr);
 };
 
 }; //namespace
diff --git a/WebCore/khtml/html/htmlparser.cpp b/WebCore/khtml/html/htmlparser.cpp
index 85d0bae..a2d63e6 100644
--- a/WebCore/khtml/html/htmlparser.cpp
+++ b/WebCore/khtml/html/htmlparser.cpp
@@ -399,7 +399,7 @@ bool KHTMLParser::insertNode(NodeImpl *n, bool flat)
 		    for (unsigned long l = 0; map && l < map->length(); ++l) {
 			AttributeImpl* it = map->attributeItem(l);
 			changed = !bmap->getAttributeItem(it->id());
-			bmap->insertAttribute(new AttributeImpl(it->id(), it->value()));
+			bmap->insertAttribute(it->clone());
 		    }
 		    if ( changed )
 			doc()->recalcStyle( NodeImpl::Inherit );
@@ -445,7 +445,7 @@ bool KHTMLParser::insertNode(NodeImpl *n, bool flat)
                 for (unsigned long l = 0; map && l < map->length(); ++l) {
                     AttributeImpl* it = map->attributeItem(l);
                     changed = !bmap->getAttributeItem(it->id());
-                    bmap->insertAttribute(new AttributeImpl(it->id(), it->value()));
+                    bmap->insertAttribute(it->clone());
                 }
                 if ( changed )
                     doc()->recalcStyle( NodeImpl::Inherit );
@@ -656,8 +656,7 @@ bool KHTMLParser::insertNode(NodeImpl *n, bool flat)
         case ID_OL:
         case ID_DIR:
         case ID_MENU:
-            e = new HTMLLIElementImpl(document);
-            e->addCSSProperty(CSS_PROP_LIST_STYLE_TYPE, CSS_VAL_NONE);
+            e = new HTMLDivElementImpl(document);
             insertNode(e);
             handled = true;
             break;
@@ -797,7 +796,7 @@ NodeImpl *KHTMLParser::getElement(Token* t)
             // no site actually relying on that detail (Dirk)
             if (static_cast<HTMLDocumentImpl*>(document->document())->body())
                 static_cast<HTMLDocumentImpl*>(document->document())->body()
-                    ->addCSSProperty(CSS_PROP_DISPLAY, "none");
+                    ->setAttribute(ATTR_STYLE, "display:none");
             inBody = false;
         }
         if ( (haveContent || haveFrameSet) && current->id() == ID_HTML)
diff --git a/WebCore/khtml/html/htmltokenizer.h b/WebCore/khtml/html/htmltokenizer.h
index 97f24dd..625d5c5 100644
--- a/WebCore/khtml/html/htmltokenizer.h
+++ b/WebCore/khtml/html/htmltokenizer.h
@@ -84,10 +84,10 @@ public:
     {
         DOM::AttributeImpl* a = 0;
         if(buffer->unicode())
-            a = new DOM::AttributeImpl(buffer->unicode(), v);
+            a = new DOM::HTMLAttributeImpl(buffer->unicode(), v);
         else if ( !attrName.isEmpty() && attrName != "/" )
-            a = new DOM::AttributeImpl(doc->attrId(0, DOM::DOMString(attrName).implementation(), false),
-                                       v);
+            a = new DOM::HTMLAttributeImpl(doc->attrId(0, DOM::DOMString(attrName).implementation(), false),
+                                           v);
 
         if (a) {
             if(!attrs) {
diff --git a/WebCore/khtml/misc/htmlattrs.c b/WebCore/khtml/misc/htmlattrs.c
index 8e1da55..2fdee55 100644
--- a/WebCore/khtml/misc/htmlattrs.c
+++ b/WebCore/khtml/misc/htmlattrs.c
@@ -8,7 +8,7 @@ struct attrs {
     const char *name;
     int id;
 };
-/* maximum key range = 1148, duplicates = 1 */
+/* maximum key range = 834, duplicates = 1 */
 
 #ifdef __GNUC__
 __inline
@@ -22,32 +22,32 @@ hash_attr (register const char *str, register unsigned int len)
 {
   static const unsigned short asso_values[] =
     {
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151,    5, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151,   45,   65,   10,
-        50,    0,  160,   80,   85,  175,    0,  115,    0,    0,
-         0,    0,    0,    5,   25,    5,    0,   30,  130,  205,
-        30,  240,   25, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151, 1151,
-      1151, 1151, 1151, 1151, 1151, 1151
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837,   0, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837,  50, 165,  10,
+       50,   0, 105,  80, 170,   0,   0, 135,   0, 175,
+        0,   0,   0,   0,  25,   5,   0,  90, 160, 275,
+       65,  25,   0, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837, 837, 837, 837, 837,
+      837, 837, 837, 837, 837, 837
     };
   register int hval = len;
 
@@ -97,292 +97,254 @@ findAttr (register const char *str, register unsigned int len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 154,
+      TOTAL_KEYWORDS = 156,
       MIN_WORD_LENGTH = 2,
       MAX_WORD_LENGTH = 15,
       MIN_HASH_VALUE = 3,
-      MAX_HASH_VALUE = 1150
+      MAX_HASH_VALUE = 836
     };
 
   static const struct attrs wordlist_attr[] =
     {
       {"top", ATTR_TOP},
       {"loop", ATTR_LOOP},
+      {"title", ATTR_TITLE},
+      {"size", ATTR_SIZE},
+      {"cite", ATTR_CITE},
       {"content", ATTR_CONTENT},
       {"cols", ATTR_COLS},
       {"scope", ATTR_SCOPE},
       {"onselect", ATTR_ONSELECT},
       {"rel", ATTR_REL},
-      {"prompt", ATTR_PROMPT},
-      {"text", ATTR_TEXT},
+      {"type", ATTR_TYPE},
+      {"style", ATTR_STYLE},
       {"onreset", ATTR_ONRESET},
+      {"noresize", ATTR_NORESIZE},
+      {"onresize", ATTR_ONRESIZE},
       {"color", ATTR_COLOR},
+      {"enctype", ATTR_ENCTYPE},
       {"src", ATTR_SRC},
+      {"id", ATTR_ID},
       {"alt", ATTR_ALT},
-      {"name", ATTR_NAME},
+      {"plain", ATTR_PLAIN},
       {"span", ATTR_SPAN},
       {"code", ATTR_CODE},
-      {"rules", ATTR_RULES},
+      {"action", ATTR_ACTION},
+      {"text", ATTR_TEXT},
       {"colspan", ATTR_COLSPAN},
+      {"selected", ATTR_SELECTED},
       {"class", ATTR_CLASS},
       {"accept", ATTR_ACCEPT},
-      {"compact", ATTR_COMPACT},
-      {"selected", ATTR_SELECTED},
-      {"onmouseup", ATTR_ONMOUSEUP},
-      {"onmouseout", ATTR_ONMOUSEOUT},
-      {"start", ATTR_START},
-      {"object", ATTR_OBJECT},
+      {"dir", ATTR_DIR},
       {"onerror", ATTR_ONERROR},
-      {"oncontextmenu", ATTR_ONCONTEXTMENU},
+      {"start", ATTR_START},
       {"clear", ATTR_CLEAR},
-      {"usemap", ATTR_USEMAP},
-      {"html", ATTR_HTML},
+      {"codetype", ATTR_CODETYPE},
+      {"direction", ATTR_DIRECTION},
       {"coords", ATTR_COORDS},
-      {"autocomplete", ATTR_AUTOCOMPLETE},
       {"onload", ATTR_ONLOAD},
-      {"scheme", ATTR_SCHEME},
-      {"label", ATTR_LABEL},
-      {"truespeed", ATTR_TRUESPEED},
-      {"onblur", ATTR_ONBLUR},
-      {"scrollamount", ATTR_SCROLLAMOUNT},
+      {"left", ATTR_LEFT},
+      {"z-index", ATTR_Z_INDEX},
+      {"axis", ATTR_AXIS},
+      {"rules", ATTR_RULES},
+      {"classid", ATTR_CLASSID},
+      {"scrolling", ATTR_SCROLLING},
+      {"for", ATTR_FOR},
       {"lang", ATTR_LANG},
-      {"onunload", ATTR_ONUNLOAD},
+      {"align", ATTR_ALIGN},
+      {"profile", ATTR_PROFILE},
+      {"link", ATTR_LINK},
       {"declare", ATTR_DECLARE},
-      {"shape", ATTR_SHAPE},
-      {"method", ATTR_METHOD},
-      {"onabort", ATTR_ONABORT},
-      {"data", ATTR_DATA},
-      {"hspace", ATTR_HSPACE},
       {"longdesc", ATTR_LONGDESC},
+      {"data", ATTR_DATA},
+      {"readonly", ATTR_READONLY},
+      {"pagey", ATTR_PAGEY},
       {"target", ATTR_TARGET},
+      {"onclick", ATTR_ONCLICK},
+      {"cellspacing", ATTR_CELLSPACING},
+      {"face", ATTR_FACE},
+      {"scrolldelay", ATTR_SCROLLDELAY},
+      {"truespeed", ATTR_TRUESPEED},
+      {"object", ATTR_OBJECT},
+      {"defer", ATTR_DEFER},
       {"rev", ATTR_REV},
+      {"alink", ATTR_ALINK},
+      {"keytype", ATTR_KEYTYPE},
+      {"version", ATTR_VERSION},
+      {"onunload", ATTR_ONUNLOAD},
       {"pagex", ATTR_PAGEX},
-      {"left", ATTR_LEFT},
-      {"char", ATTR_CHAR},
-      {"border", ATTR_BORDER},
-      {"onmousemove", ATTR_ONMOUSEMOVE},
-      {"charset", ATTR_CHARSET},
-      {"title", ATTR_TITLE},
-      {"codebase", ATTR_CODEBASE},
+      {"onkeypress", ATTR_ONKEYPRESS},
+      {"prompt", ATTR_PROMPT},
+      {"onfocus", ATTR_ONFOCUS},
+      {"label", ATTR_LABEL},
       {"nosave", ATTR_NOSAVE},
-      {"bgcolor", ATTR_BGCOLOR},
-      {"for", ATTR_FOR},
-      {"cite", ATTR_CITE},
-      {"noshade", ATTR_NOSHADE},
+      {"name", ATTR_NAME},
+      {"shape", ATTR_SHAPE},
       {"vspace", ATTR_VSPACE},
-      {"onmouseover", ATTR_ONMOUSEOVER},
       {"oversrc", ATTR_OVERSRC},
-      {"abbr", ATTR_ABBR},
-      {"size", ATTR_SIZE},
-      {"value", ATTR_VALUE},
-      {"bordercolor", ATTR_BORDERCOLOR},
-      {"onfocus", ATTR_ONFOCUS},
+      {"ismap", ATTR_ISMAP},
+      {"hspace", ATTR_HSPACE},
+      {"onabort", ATTR_ONABORT},
+      {"accesskey", ATTR_ACCESSKEY},
+      {"cellpadding", ATTR_CELLPADDING},
+      {"compact", ATTR_COMPACT},
+      {"onkeyup", ATTR_ONKEYUP},
+      {"char", ATTR_CHAR},
+      {"charset", ATTR_CHARSET},
+      {"border", ATTR_BORDER},
       {"multiple", ATTR_MULTIPLE},
+      {"hidden", ATTR_HIDDEN},
+      {"media", ATTR_MEDIA},
+      {"noshade", ATTR_NOSHADE},
+      {"datetime", ATTR_DATETIME},
+      {"cellborder", ATTR_CELLBORDER},
+      {"onblur", ATTR_ONBLUR},
+      {"bgcolor", ATTR_BGCOLOR},
+      {"codebase", ATTR_CODEBASE},
+      {"contenteditable", ATTR_CONTENTEDITABLE},
+      {"pluginurl", ATTR_PLUGINURL},
+      {"valign", ATTR_VALIGN},
+      {"mayscript", ATTR_MAYSCRIPT},
+      {"vlink", ATTR_VLINK},
+      {"standby", ATTR_STANDBY},
+      {"href", ATTR_HREF},
+      {"value", ATTR_VALUE},
+      {"nohref", ATTR_NOHREF},
       {"headers", ATTR_HEADERS},
-      {"face", ATTR_FACE},
-      {"plain", ATTR_PLAIN},
-      {"id", ATTR_ID},
+      {"rows", ATTR_ROWS},
+      {"pluginpage", ATTR_PLUGINPAGE},
+      {"bordercolor", ATTR_BORDERCOLOR},
+      {"bgproperties", ATTR_BGPROPERTIES},
+      {"pluginspage", ATTR_PLUGINSPAGE},
       {"onchange", ATTR_ONCHANGE},
       {"challenge", ATTR_CHALLENGE},
-      {"ismap", ATTR_ISMAP},
-      {"frame", ATTR_FRAME},
-      {"action", ATTR_ACTION},
-      {"noresize", ATTR_NORESIZE},
-      {"onresize", ATTR_ONRESIZE},
-      {"rows", ATTR_ROWS},
-      {"defer", ATTR_DEFER},
-      {"type", ATTR_TYPE},
-      {"maxlength", ATTR_MAXLENGTH},
-      {"style", ATTR_STYLE},
-      {"dir", ATTR_DIR},
+      {"usemap", ATTR_USEMAP},
+      {"disabled", ATTR_DISABLED},
+      {"valuetype", ATTR_VALUETYPE},
+      {"autocomplete", ATTR_AUTOCOMPLETE},
+      {"tabindex", ATTR_TABINDEX},
+      {"topmargin", ATTR_TOPMARGIN},
       {"accept-charset", ATTR_ACCEPT_CHARSET},
-      {"enctype", ATTR_ENCTYPE},
-      {"axis", ATTR_AXIS},
-      {"href", ATTR_HREF},
-      {"media", ATTR_MEDIA},
-      {"nohref", ATTR_NOHREF},
-      {"checked", ATTR_CHECKED},
-      {"datetime", ATTR_DATETIME},
+      {"html", ATTR_HTML},
+      {"oncontextmenu", ATTR_ONCONTEXTMENU},
       {"wrap", ATTR_WRAP},
       {"nowrap", ATTR_NOWRAP},
-      {"onsubmit", ATTR_ONSUBMIT},
-      {"rowspan", ATTR_ROWSPAN},
       {"language", ATTR_LANGUAGE},
-      {"z-index", ATTR_Z_INDEX},
-      {"link", ATTR_LINK},
-      {"classid", ATTR_CLASSID},
-      {"onmousedown", ATTR_ONMOUSEDOWN},
-      {"scrolling", ATTR_SCROLLING},
-      {"align", ATTR_ALIGN},
-      {"codetype", ATTR_CODETYPE},
-      {"onclick", ATTR_ONCLICK},
-      {"topmargin", ATTR_TOPMARGIN},
-      {"cellspacing", ATTR_CELLSPACING},
-      {"alink", ATTR_ALINK},
-      {"version", ATTR_VERSION},
-      {"pluginurl", ATTR_PLUGINURL},
-      {"summary", ATTR_SUMMARY},
-      {"unknown", ATTR_UNKNOWN},
-      {"contenteditable", ATTR_CONTENTEDITABLE},
-      {"hidden", ATTR_HIDDEN},
-      {"profile", ATTR_PROFILE},
-      {"readonly", ATTR_READONLY},
-      {"pagey", ATTR_PAGEY},
-      {"tabindex", ATTR_TABINDEX},
-      {"scrolldelay", ATTR_SCROLLDELAY},
-      {"bgproperties", ATTR_BGPROPERTIES},
-      {"onkeyup", ATTR_ONKEYUP},
-      {"disabled", ATTR_DISABLED},
-      {"onkeypress", ATTR_ONKEYPRESS},
-      {"hreflang", ATTR_HREFLANG},
-      {"frameborder", ATTR_FRAMEBORDER},
-      {"standby", ATTR_STANDBY},
-      {"pluginpage", ATTR_PLUGINPAGE},
-      {"cellpadding", ATTR_CELLPADDING},
-      {"vlink", ATTR_VLINK},
-      {"pluginspage", ATTR_PLUGINSPAGE},
-      {"background", ATTR_BACKGROUND},
-      {"height", ATTR_HEIGHT},
+      {"frame", ATTR_FRAME},
+      {"rowspan", ATTR_ROWSPAN},
+      {"visibility", ATTR_VISIBILITY},
+      {"scheme", ATTR_SCHEME},
+      {"scrollamount", ATTR_SCROLLAMOUNT},
+      {"onmouseup", ATTR_ONMOUSEUP},
+      {"onmouseout", ATTR_ONMOUSEOUT},
       {"ondblclick", ATTR_ONDBLCLICK},
-      {"valign", ATTR_VALIGN},
-      {"accesskey", ATTR_ACCESSKEY},
-      {"http-equiv", ATTR_HTTP_EQUIV},
-      {"direction", ATTR_DIRECTION},
-      {"valuetype", ATTR_VALUETYPE},
+      {"checked", ATTR_CHECKED},
+      {"method", ATTR_METHOD},
+      {"abbr", ATTR_ABBR},
       {"archive", ATTR_ARCHIVE},
-      {"charoff", ATTR_CHAROFF},
+      {"height", ATTR_HEIGHT},
+      {"http-equiv", ATTR_HTTP_EQUIV},
+      {"hreflang", ATTR_HREFLANG},
+      {"onsubmit", ATTR_ONSUBMIT},
       {"leftmargin", ATTR_LEFTMARGIN},
-      {"mayscript", ATTR_MAYSCRIPT},
+      {"onmouseover", ATTR_ONMOUSEOVER},
+      {"charoff", ATTR_CHAROFF},
+      {"tableborder", ATTR_TABLEBORDER},
+      {"onkeydown", ATTR_ONKEYDOWN},
       {"width", ATTR_WIDTH},
+      {"unknown", ATTR_UNKNOWN},
+      {"maxlength", ATTR_MAXLENGTH},
+      {"summary", ATTR_SUMMARY},
       {"behavior", ATTR_BEHAVIOR},
-      {"keytype", ATTR_KEYTYPE},
-      {"onkeydown", ATTR_ONKEYDOWN},
+      {"onmousedown", ATTR_ONMOUSEDOWN},
+      {"background", ATTR_BACKGROUND},
+      {"onmousemove", ATTR_ONMOUSEMOVE},
+      {"frameborder", ATTR_FRAMEBORDER},
       {"marginheight", ATTR_MARGINHEIGHT},
-      {"marginwidth", ATTR_MARGINWIDTH},
-      {"visibility", ATTR_VISIBILITY}
+      {"marginwidth", ATTR_MARGINWIDTH}
     };
 
   static const short lookup[] =
     {
-        -1,   -1,   -1,    0,    1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,    2,   -1,    3,    4,   -1,   -1,    5,
-        -1,   -1,   -1,   -1,    6,   -1,   -1,    7,
-        -1,   -1,    8,   -1,   -1,    9,   -1,   -1,
-        10,   -1,   -1,   11,   -1,   -1,   -1,   -1,
-        12,   13,   -1,   -1,   -1,   -1,   14,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        15,   16,   -1,   17,   -1,   -1,   18,   19,
-        20,   21,   22,   23,   -1,   -1,   -1,   -1,
-        24,   25,   26,   27,   -1,   28,   29,   -1,
-        -1,   30,   -1,   -1,   -1,   -1,   -1,   -1,
-        31,   32,   -1,   -1,   -1,   33,   -1,   -1,
-        -1,   -1,   34,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   35,   -1,   -1,   -1,   36,
-        -1,   -1,   -1,   -1,   -1,   -1,   37,   38,
-        -1,   39,   -1,   -1,   -1,   40,   -1,   -1,
-        -1,   41,   -1,   -1,   42,   43,   44,   -1,
-        45,   -1,   -1,   -1,   -1,   -1,   -1,   46,
-        -1,   47,   -1,   -1,   48,   -1,   49,   -1,
-        50,   -1,   -1,   -1,   51,   -1,   -1,   -1,
-        -1,   52,   -1,   53,   -1,   -1,   -1,   -1,
-        54,   55,   -1,   -1,   56,   -1,   -1,   57,
-        -1,   -1,   58,   59,   60,   61,   -1,   -1,
-        62,   -1,   -1,   -1,   63,   -1,   -1,   -1,
-        -1,   64,   65,   -1,   66,   -1,   -1,   -1,
-        -1,   67,   68,   69,   70,   71,   -1,   -1,
-        -1,   72,   -1,   73,   -1,   -1,   -1,   -1,
-        -1,   74,   -1,   75,   76,   77,   78,   -1,
-        -1,   -1,   -1,   79,   80,   -1, -396,   83,
-        84,  -73,   -2,   -1,   85,   -1,   -1,   -1,
-        -1,   86,   87,   -1,   -1,   88,   89,   -1,
-        -1,   90,   -1,   91,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   92,   93,   94,   95,   96,   97,
-        -1,   98,   -1,   99,   -1,   -1,   -1,  100,
-       101,   -1,   -1,   -1,  102,   -1,  103,   -1,
-        -1,  104,   -1,   -1,   -1,  105,   -1,   -1,
-       106,  107,   -1,   -1,  108,   -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,  110,   -1,
-       111,   -1,   -1,   -1,  112,   -1,  113,   -1,
-        -1,   -1,   -1,   -1,   -1,  114,   -1,   -1,
-       115,   -1,   -1,   -1,   -1,  116,   -1,   -1,
-       117,   -1,   -1,   -1,   -1,   -1,  118,  119,
-       120,   -1,  121,   -1,   -1,  122,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,  123,  124,   -1,   -1,   -1,   -1,
-       125,   -1,   -1,   -1,   -1,   -1,  126,   -1,
-       127,   -1,   -1,  128,   -1,   -1,  129,   -1,
-        -1,   -1,   -1,   -1,  130,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,  131,  132,   -1,   -1,
-        -1,  133,  134,   -1,   -1,   -1,  135,  136,
-        -1,   -1,   -1,  137,  138,   -1,   -1,  139,
-       140,   -1,   -1,   -1,  141,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,  142,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,  143,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,  144,   -1,   -1,  145,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,  146,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-       147,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,  148,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,    0,    1,    2,   -1,   -1,
+        -1,    3,   -1,   -1,   -1,   -1,    4,   -1,
+        -1,    5,   -1,    6,    7,   -1,   -1,    8,
+        -1,   -1,   -1,   -1,    9,   10,   -1,   -1,
+        -1,   -1,   -1,   11,   -1,   12, -201,   -1,
+        15,   -1,   16,   17, -143,   -2,   -1,   -1,
+        -1,   -1,   -1,   -1,   18,   19,   -1,   20,
+        -1,   -1,   -1,   21,   -1,   -1,   -1,   -1,
+        22,   -1,   23,   -1,   -1,   24,   -1,   -1,
+        25,   26,   -1,   27,   28,   -1,   29,   -1,
+        -1,   -1,   30,   -1,   -1,   31,   -1,   -1,
+        -1,   -1,   32,   -1,   -1,   33,   34,   -1,
+        35,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   36,   -1,   -1,   37,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   38,   -1,   39,   40,   -1,   41,
+        -1,   42,   -1,   -1,   -1,   43,   44,   45,
+        -1,   46,   -1,   47,   -1,   -1,   48,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   49,   50,   -1,   -1,   -1,   51,   -1,
+        52,   53,   54,   -1,   -1,   -1,   55,   -1,
+        -1,   56,   -1,   -1,   -1,   -1,   -1,   -1,
+        57,   -1,   -1,   58,   -1,   59,   -1,   -1,
+        -1,   60,   -1,   -1,   61,   -1,   62,   -1,
+        63,   -1,   -1,   -1,   -1,   64,   65,   -1,
+        66,   -1,   -1,   -1,   -1,   67,   68,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   69,   -1,   -1,   70,   71,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   72,   73,   74,
+        75,   -1,   -1,   76,   -1,   -1,   -1,   -1,
+        -1,   77,   -1,   -1,   -1,   -1,   -1,   78,
+        -1,   79,   -1,   80,   81,   -1,   -1,   -1,
+        -1,   82,   -1,   83,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   84,   -1,   -1,   -1,   85,
+        -1,   86,   -1,   -1,   87,   -1,   -1,   -1,
+        88,   -1,   89,   90,   -1,   91,   92,   93,
+        94,   -1,   95,   -1,   -1,   -1,   96,   -1,
+        97,   -1,   -1,   98,   99,   -1,  100,   -1,
+       101,  102,  103,  104,   -1,  105,  106,  107,
+       108,   -1,   -1,   -1,  109,   -1,  110,  111,
+        -1,   -1,   -1,   -1,   -1,   -1,  112,   -1,
+       113,   -1,   -1,   -1,   -1,   -1,  114,   -1,
+        -1,  115,  116,  117,   -1,   -1,   -1,   -1,
+       118,   -1,   -1,   -1,   -1,  119,   -1,   -1,
+        -1,  120,  121,   -1,  122,   -1,  123,   -1,
+       124,   -1,  125,   -1,   -1,  126,  127,  128,
+        -1,  129,  130,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,  131,   -1,  132,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,  133,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,  134,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,  135,   -1,
+        -1,   -1,  136,   -1,   -1,   -1,  137,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,  138,   -1,
+        -1,   -1,   -1,  139,   -1,  140,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,  141,   -1,   -1,   -1,   -1,   -1,
+       142,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,  143,   -1,   -1,  144,   -1,
+        -1,   -1,   -1,   -1,  145,   -1,   -1,   -1,
+        -1,   -1,   -1,  146,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,  147,   -1,   -1,
+       148,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,  149,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,  150,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,  151,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,  152,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
-        -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,  150,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,  151,
+       152,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
+        -1,   -1,   -1,   -1,   -1,   -1,   -1,  153,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
@@ -399,6 +361,7 @@ findAttr (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,  154,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
         -1,   -1,   -1,   -1,   -1,   -1,   -1,   -1,
@@ -407,7 +370,7 @@ findAttr (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,  153
+        -1,   -1,   -1,   -1,  155
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -471,6 +434,7 @@ static const char * const attrList[] = {
     "CHAROFF",
     "CHARSET",
     "CHECKED",
+    "CELLBORDER",
     "CITE",
     "CLASS",
     "CLASSID",
@@ -582,6 +546,7 @@ static const char * const attrList[] = {
     "STYLE",
     "SUMMARY",
     "TABINDEX",
+    "TABLEBORDER",
     "TARGET",
     "TEXT",
     "TITLE",
diff --git a/WebCore/khtml/misc/htmlattrs.h b/WebCore/khtml/misc/htmlattrs.h
index 54a84cf..877aef9 100644
--- a/WebCore/khtml/misc/htmlattrs.h
+++ b/WebCore/khtml/misc/htmlattrs.h
@@ -32,137 +32,139 @@ using namespace DOM;
 #define ATTR_CHAROFF 22
 #define ATTR_CHARSET 23
 #define ATTR_CHECKED 24
-#define ATTR_CITE 25
-#define ATTR_CLASS 26
-#define ATTR_CLASSID 27
-#define ATTR_CLEAR 28
-#define ATTR_CODE 29
-#define ATTR_CODEBASE 30
-#define ATTR_CODETYPE 31
-#define ATTR_COLOR 32
-#define ATTR_COLS 33
-#define ATTR_COLSPAN 34
-#define ATTR_COMPACT 35
-#define ATTR_CONTENT 36
-#define ATTR_CONTENTEDITABLE 37
-#define ATTR_COORDS 38
-#define ATTR_DATA 39
-#define ATTR_DATETIME 40
-#define ATTR_DECLARE 41
-#define ATTR_DEFER 42
-#define ATTR_DIR 43
-#define ATTR_DIRECTION 44
-#define ATTR_DISABLED 45
-#define ATTR_ENCTYPE 46
-#define ATTR_FACE 47
-#define ATTR_FOR 48
-#define ATTR_FRAME 49
-#define ATTR_FRAMEBORDER 50
-#define ATTR_HEADERS 51
-#define ATTR_HEIGHT 52
-#define ATTR_HIDDEN 53
-#define ATTR_HREF 54
-#define ATTR_HREFLANG 55
-#define ATTR_HSPACE 56
-#define ATTR_HTML 57
-#define ATTR_HTTP_EQUIV 58
-#define ATTR_ID 59
-#define ATTR_ISMAP 60
-#define ATTR_KEYTYPE 61
-#define ATTR_LABEL 62
-#define ATTR_LANG 63
-#define ATTR_LANGUAGE 64
-#define ATTR_LEFT 65
-#define ATTR_LEFTMARGIN 66
-#define ATTR_LINK 67
-#define ATTR_LONGDESC 68
-#define ATTR_LOOP 69
-#define ATTR_MARGINHEIGHT 70
-#define ATTR_MARGINWIDTH 71
-#define ATTR_MAXLENGTH 72
-#define ATTR_MAYSCRIPT 73
-#define ATTR_MEDIA 74
-#define ATTR_METHOD 75
-#define ATTR_MULTIPLE 76
-#define ATTR_NAME 77
-#define ATTR_NOHREF 78
-#define ATTR_NORESIZE 79
-#define ATTR_NOSAVE 80
-#define ATTR_NOSHADE 81
-#define ATTR_NOWRAP 82
-#define ATTR_OBJECT 83
-#define ATTR_ONABORT 84
-#define ATTR_ONBLUR 85
-#define ATTR_ONCHANGE 86
-#define ATTR_ONCLICK 87
-#define ATTR_ONCONTEXTMENU 88
-#define ATTR_ONDBLCLICK 89
-#define ATTR_ONERROR 90
-#define ATTR_ONFOCUS 91
-#define ATTR_ONKEYDOWN 92
-#define ATTR_ONKEYPRESS 93
-#define ATTR_ONKEYUP 94
-#define ATTR_ONLOAD 95
-#define ATTR_ONMOUSEDOWN 96
-#define ATTR_ONMOUSEMOVE 97
-#define ATTR_ONMOUSEOUT 98
-#define ATTR_ONMOUSEOVER 99
-#define ATTR_ONMOUSEUP 100
-#define ATTR_ONRESET 101
-#define ATTR_ONRESIZE 102
-#define ATTR_ONSELECT 103
-#define ATTR_ONSUBMIT 104
-#define ATTR_ONUNLOAD 105
-#define ATTR_OVERSRC 106
-#define ATTR_PAGEX 107
-#define ATTR_PAGEY 108
-#define ATTR_PLAIN 109
-#define ATTR_PLUGINPAGE 110
-#define ATTR_PLUGINSPAGE 111
-#define ATTR_PLUGINURL 112
-#define ATTR_PROFILE 113
-#define ATTR_PROMPT 114
-#define ATTR_READONLY 115
-#define ATTR_REL 116
-#define ATTR_REV 117
-#define ATTR_ROWS 118
-#define ATTR_ROWSPAN 119
-#define ATTR_RULES 120
-#define ATTR_SCHEME 121
-#define ATTR_SCOPE 122
-#define ATTR_SCROLLAMOUNT 123
-#define ATTR_SCROLLDELAY 124
-#define ATTR_SCROLLING 125
-#define ATTR_SELECTED 126
-#define ATTR_SHAPE 127
-#define ATTR_SIZE 128
-#define ATTR_SPAN 129
-#define ATTR_SRC 130
-#define ATTR_STANDBY 131
-#define ATTR_START 132
-#define ATTR_STYLE 133
-#define ATTR_SUMMARY 134
-#define ATTR_TABINDEX 135
-#define ATTR_TARGET 136
-#define ATTR_TEXT 137
-#define ATTR_TITLE 138
-#define ATTR_TOP 139
-#define ATTR_TOPMARGIN 140
-#define ATTR_TRUESPEED 141
-#define ATTR_TYPE 142
-#define ATTR_UNKNOWN 143
-#define ATTR_USEMAP 144
-#define ATTR_VALIGN 145
-#define ATTR_VALUE 146
-#define ATTR_VALUETYPE 147
-#define ATTR_VERSION 148
-#define ATTR_VISIBILITY 149
-#define ATTR_VLINK 150
-#define ATTR_VSPACE 151
-#define ATTR_WIDTH 152
-#define ATTR_WRAP 153
-#define ATTR_Z_INDEX 154
-#define ATTR_LAST_ATTR 154
+#define ATTR_CELLBORDER 25
+#define ATTR_CITE 26
+#define ATTR_CLASS 27
+#define ATTR_CLASSID 28
+#define ATTR_CLEAR 29
+#define ATTR_CODE 30
+#define ATTR_CODEBASE 31
+#define ATTR_CODETYPE 32
+#define ATTR_COLOR 33
+#define ATTR_COLS 34
+#define ATTR_COLSPAN 35
+#define ATTR_COMPACT 36
+#define ATTR_CONTENT 37
+#define ATTR_CONTENTEDITABLE 38
+#define ATTR_COORDS 39
+#define ATTR_DATA 40
+#define ATTR_DATETIME 41
+#define ATTR_DECLARE 42
+#define ATTR_DEFER 43
+#define ATTR_DIR 44
+#define ATTR_DIRECTION 45
+#define ATTR_DISABLED 46
+#define ATTR_ENCTYPE 47
+#define ATTR_FACE 48
+#define ATTR_FOR 49
+#define ATTR_FRAME 50
+#define ATTR_FRAMEBORDER 51
+#define ATTR_HEADERS 52
+#define ATTR_HEIGHT 53
+#define ATTR_HIDDEN 54
+#define ATTR_HREF 55
+#define ATTR_HREFLANG 56
+#define ATTR_HSPACE 57
+#define ATTR_HTML 58
+#define ATTR_HTTP_EQUIV 59
+#define ATTR_ID 60
+#define ATTR_ISMAP 61
+#define ATTR_KEYTYPE 62
+#define ATTR_LABEL 63
+#define ATTR_LANG 64
+#define ATTR_LANGUAGE 65
+#define ATTR_LEFT 66
+#define ATTR_LEFTMARGIN 67
+#define ATTR_LINK 68
+#define ATTR_LONGDESC 69
+#define ATTR_LOOP 70
+#define ATTR_MARGINHEIGHT 71
+#define ATTR_MARGINWIDTH 72
+#define ATTR_MAXLENGTH 73
+#define ATTR_MAYSCRIPT 74
+#define ATTR_MEDIA 75
+#define ATTR_METHOD 76
+#define ATTR_MULTIPLE 77
+#define ATTR_NAME 78
+#define ATTR_NOHREF 79
+#define ATTR_NORESIZE 80
+#define ATTR_NOSAVE 81
+#define ATTR_NOSHADE 82
+#define ATTR_NOWRAP 83
+#define ATTR_OBJECT 84
+#define ATTR_ONABORT 85
+#define ATTR_ONBLUR 86
+#define ATTR_ONCHANGE 87
+#define ATTR_ONCLICK 88
+#define ATTR_ONCONTEXTMENU 89
+#define ATTR_ONDBLCLICK 90
+#define ATTR_ONERROR 91
+#define ATTR_ONFOCUS 92
+#define ATTR_ONKEYDOWN 93
+#define ATTR_ONKEYPRESS 94
+#define ATTR_ONKEYUP 95
+#define ATTR_ONLOAD 96
+#define ATTR_ONMOUSEDOWN 97
+#define ATTR_ONMOUSEMOVE 98
+#define ATTR_ONMOUSEOUT 99
+#define ATTR_ONMOUSEOVER 100
+#define ATTR_ONMOUSEUP 101
+#define ATTR_ONRESET 102
+#define ATTR_ONRESIZE 103
+#define ATTR_ONSELECT 104
+#define ATTR_ONSUBMIT 105
+#define ATTR_ONUNLOAD 106
+#define ATTR_OVERSRC 107
+#define ATTR_PAGEX 108
+#define ATTR_PAGEY 109
+#define ATTR_PLAIN 110
+#define ATTR_PLUGINPAGE 111
+#define ATTR_PLUGINSPAGE 112
+#define ATTR_PLUGINURL 113
+#define ATTR_PROFILE 114
+#define ATTR_PROMPT 115
+#define ATTR_READONLY 116
+#define ATTR_REL 117
+#define ATTR_REV 118
+#define ATTR_ROWS 119
+#define ATTR_ROWSPAN 120
+#define ATTR_RULES 121
+#define ATTR_SCHEME 122
+#define ATTR_SCOPE 123
+#define ATTR_SCROLLAMOUNT 124
+#define ATTR_SCROLLDELAY 125
+#define ATTR_SCROLLING 126
+#define ATTR_SELECTED 127
+#define ATTR_SHAPE 128
+#define ATTR_SIZE 129
+#define ATTR_SPAN 130
+#define ATTR_SRC 131
+#define ATTR_STANDBY 132
+#define ATTR_START 133
+#define ATTR_STYLE 134
+#define ATTR_SUMMARY 135
+#define ATTR_TABINDEX 136
+#define ATTR_TABLEBORDER 137
+#define ATTR_TARGET 138
+#define ATTR_TEXT 139
+#define ATTR_TITLE 140
+#define ATTR_TOP 141
+#define ATTR_TOPMARGIN 142
+#define ATTR_TRUESPEED 143
+#define ATTR_TYPE 144
+#define ATTR_UNKNOWN 145
+#define ATTR_USEMAP 146
+#define ATTR_VALIGN 147
+#define ATTR_VALUE 148
+#define ATTR_VALUETYPE 149
+#define ATTR_VERSION 150
+#define ATTR_VISIBILITY 151
+#define ATTR_VLINK 152
+#define ATTR_VSPACE 153
+#define ATTR_WIDTH 154
+#define ATTR_WRAP 155
+#define ATTR_Z_INDEX 156
+#define ATTR_LAST_ATTR 156
 DOMString getAttrName(unsigned short id);
 
 #endif
diff --git a/WebCore/khtml/misc/htmlattrs.in b/WebCore/khtml/misc/htmlattrs.in
index 4758b9f..24c2063 100644
--- a/WebCore/khtml/misc/htmlattrs.in
+++ b/WebCore/khtml/misc/htmlattrs.in
@@ -22,6 +22,7 @@ challenge
 charoff
 charset
 checked
+cellborder
 cite
 class
 classid
@@ -133,6 +134,7 @@ start
 style
 summary
 tabindex
+tableborder
 target
 text
 title
diff --git a/WebCore/khtml/rendering/render_block.cpp b/WebCore/khtml/rendering/render_block.cpp
index fb71c30..3bf002a 100644
--- a/WebCore/khtml/rendering/render_block.cpp
+++ b/WebCore/khtml/rendering/render_block.cpp
@@ -82,7 +82,7 @@ void RenderBlock::setStyle(RenderStyle* _style)
     {
         if (child->isAnonymous() && child->style()->styleType() == RenderStyle::NOPSEUDO && !child->isListMarker())
         {
-            RenderStyle* newStyle = new RenderStyle();
+            RenderStyle* newStyle = new (renderArena()) RenderStyle();
             newStyle->inheritFrom(style());
             newStyle->setDisplay(BLOCK);
             child->setStyle(newStyle);
@@ -2610,7 +2610,7 @@ void RenderBlock::updateFirstLetter()
             
             RenderTextFragment* letter = 
                 new (renderArena()) RenderTextFragment(remainingText->node(), oldText, 0, length);
-            RenderStyle* newStyle = new RenderStyle();
+            RenderStyle* newStyle = new (renderArena()) RenderStyle();
             newStyle->inheritFrom(pseudoStyle);
             letter->setStyle(newStyle);
             firstLetter->addChild(letter);
diff --git a/WebCore/khtml/rendering/render_container.cpp b/WebCore/khtml/rendering/render_container.cpp
index 3c4a460..840f972 100644
--- a/WebCore/khtml/rendering/render_container.cpp
+++ b/WebCore/khtml/rendering/render_container.cpp
@@ -138,7 +138,7 @@ void RenderContainer::addChild(RenderObject *newChild, RenderObject *beforeChild
         else {
             //kdDebug( 6040 ) << "creating anonymous table" << endl;
             table = new (renderArena()) RenderTable(document() /* is anonymous */);
-            RenderStyle *newStyle = new RenderStyle();
+            RenderStyle *newStyle = new (renderArena()) RenderStyle();
             newStyle->inheritFrom(style());
             newStyle->setDisplay(TABLE);
             table->setStyle(newStyle);
@@ -271,7 +271,7 @@ void RenderContainer::updatePseudoChild(RenderStyle::PseudoId type, RenderObject
                     genChild->setStyle(pseudo);
                 else {
                     // Images get an empty style that inherits from the pseudo.
-                    RenderStyle* style = new RenderStyle();
+                    RenderStyle* style = new (renderArena()) RenderStyle();
                     style->inheritFrom(pseudo);
                     genChild->setStyle(style);
                 }
@@ -302,7 +302,7 @@ void RenderContainer::updatePseudoChild(RenderStyle::PseudoId type, RenderObject
         else if (contentData->contentType() == CONTENT_OBJECT)
         {
             RenderImage* img = new (renderArena()) RenderImage(document()); /* Anonymous object */
-            RenderStyle* style = new RenderStyle();
+            RenderStyle* style = new (renderArena()) RenderStyle();
             style->inheritFrom(pseudo);
             img->setStyle(style);
             img->setContentObject(contentData->contentObject());
diff --git a/WebCore/khtml/rendering/render_frames.cpp b/WebCore/khtml/rendering/render_frames.cpp
index 3935dc0..7bbf8d9 100644
--- a/WebCore/khtml/rendering/render_frames.cpp
+++ b/WebCore/khtml/rendering/render_frames.cpp
@@ -702,11 +702,11 @@ void RenderPartObject::updateWidget()
           embedOrObject = (HTMLElementImpl *)embed;
           DOMString attribute = embedOrObject->getAttribute(ATTR_WIDTH);
           if (!attribute.isEmpty()) {
-              o->addCSSLength(CSS_PROP_WIDTH, attribute);
+              o->setAttribute(ATTR_WIDTH, attribute);
           }
           attribute = embedOrObject->getAttribute(ATTR_HEIGHT);
           if (!attribute.isEmpty()) {
-              o->addCSSLength(CSS_PROP_HEIGHT, attribute);
+              o->setAttribute(ATTR_HEIGHT, attribute);
           }
           url = embed->url;
           serviceType = embed->serviceType;
diff --git a/WebCore/khtml/rendering/render_inline.cpp b/WebCore/khtml/rendering/render_inline.cpp
index 5ffbf3d..82f5470 100644
--- a/WebCore/khtml/rendering/render_inline.cpp
+++ b/WebCore/khtml/rendering/render_inline.cpp
@@ -86,7 +86,7 @@ void RenderInline::addChildToFlow(RenderObject* newChild, RenderObject* beforeCh
         // inline into continuations.  This involves creating an anonymous block box to hold
         // |newChild|.  We then make that block box a continuation of this inline.  We take all of
         // the children after |beforeChild| and put them in a clone of this object.
-        RenderStyle *newStyle = new RenderStyle();
+        RenderStyle *newStyle = new (renderArena()) RenderStyle();
         newStyle->inheritFrom(style());
         newStyle->setDisplay(BLOCK);
 
diff --git a/WebCore/khtml/rendering/render_list.cpp b/WebCore/khtml/rendering/render_list.cpp
index 4a20253..fd0a916 100644
--- a/WebCore/khtml/rendering/render_list.cpp
+++ b/WebCore/khtml/rendering/render_list.cpp
@@ -136,7 +136,7 @@ void RenderListItem::setStyle(RenderStyle *_style)
 
     if (style()->listStyleType() != LNONE ||
         (style()->listStyleImage() && !style()->listStyleImage()->isErrorImage())) {
-        RenderStyle *newStyle = new RenderStyle();
+        RenderStyle *newStyle = new (renderArena()) RenderStyle();
         newStyle->ref();
         // The marker always inherits from the list item, regardless of where it might end
         // up (e.g., in some deeply nested line box).  See CSS3 spec.
@@ -149,7 +149,7 @@ void RenderListItem::setStyle(RenderStyle *_style)
         }
         else
             m_marker->setStyle(newStyle);
-        newStyle->deref();
+        newStyle->deref(renderArena());
     } else if (m_marker) {
         m_marker->detach();
         m_marker = 0;
diff --git a/WebCore/khtml/rendering/render_object.cpp b/WebCore/khtml/rendering/render_object.cpp
index 9193ef2..46be85b 100644
--- a/WebCore/khtml/rendering/render_object.cpp
+++ b/WebCore/khtml/rendering/render_object.cpp
@@ -153,11 +153,6 @@ m_isSelectionBorder( false )
 
 RenderObject::~RenderObject()
 {
-    if(m_style->backgroundImage())
-        m_style->backgroundImage()->deref(this);
-
-    if (m_style)
-        m_style->deref();
 }
 
 bool RenderObject::isRoot() const
@@ -1335,7 +1330,7 @@ void RenderObject::selectionStartEnd(int& spos, int& epos)
 
 RenderBlock* RenderObject::createAnonymousBlock()
 {
-    RenderStyle *newStyle = new RenderStyle();
+    RenderStyle *newStyle = new (renderArena()) RenderStyle();
     newStyle->inheritFrom(m_style);
     newStyle->setDisplay(BLOCK);
 
@@ -1443,7 +1438,7 @@ void RenderObject::setStyle(RenderStyle *style)
     if (oldStyle)
     {
         ob = oldStyle->backgroundImage();
-        oldStyle->deref();
+        oldStyle->deref(renderArena());
     }
 
     if( ob != nb ) {
@@ -1681,6 +1676,12 @@ void RenderObject::remove()
     if (parent())
         //have parent, take care of the tree integrity
         parent()->removeChild(this);
+
+    if (m_style->backgroundImage())
+        m_style->backgroundImage()->deref(this);
+    if (m_style)
+        m_style->deref(renderArena());
+    m_style = 0;
 }
 
 void RenderObject::detach()
diff --git a/WebCore/khtml/rendering/render_style.cpp b/WebCore/khtml/rendering/render_style.cpp
index 80be39a..64301a0 100644
--- a/WebCore/khtml/rendering/render_style.cpp
+++ b/WebCore/khtml/rendering/render_style.cpp
@@ -25,6 +25,7 @@
 
 #include "render_style.h"
 #include "css/cssstyleselector.h"
+#include "render_arena.h"
 
 #include "kdebug.h"
 
@@ -299,11 +300,47 @@ bool StyleInheritedData::operator==(const StyleInheritedData& o) const
         page_break_inside == o.page_break_inside;
 }
 
+// ----------------------------------------------------------
+
+void* RenderStyle::operator new(size_t sz, RenderArena* renderArena) throw()
+{
+    return renderArena->allocate(sz);
+}
+
+void RenderStyle::operator delete(void* ptr, size_t sz)
+{
+    // Stash size where detach can find it.
+    *(size_t *)ptr = sz;
+}
+
+void RenderStyle::arenaDelete(RenderArena *arena)
+{
+    RenderStyle *ps = pseudoStyle;
+    RenderStyle *prev = 0;
+    
+    while (ps) {
+        prev = ps;
+        ps = ps->pseudoStyle;
+	// to prevent a double deletion.
+	// this works only because the styles below aren't really shared
+	// Dirk said we need another construct as soon as these are shared
+        prev->pseudoStyle = 0;
+        prev->deref(arena);
+    }
+    delete content;
+    
+    delete this;
+    
+    // Recover the size left there for us by operator delete and free the memory.
+    arena->free(*(size_t *)this, this);
+}
+
 RenderStyle::RenderStyle()
 {
-//    counter++;
+    m_ref = 0;
+    
     if (!_default)
-	_default = new RenderStyle(true);
+	_default = ::new RenderStyle(true);
 
     box = _default->box;
     visual = _default->visual;
@@ -336,15 +373,16 @@ RenderStyle::RenderStyle(bool)
 
     pseudoStyle = 0;
     content = 0;
+    m_ref = 1;
 }
 
 RenderStyle::RenderStyle(const RenderStyle& o)
-    : Shared<RenderStyle>(),
-      inherited_flags( o.inherited_flags ), noninherited_flags( o.noninherited_flags ),
+    : inherited_flags( o.inherited_flags ), noninherited_flags( o.noninherited_flags ),
       box( o.box ), visual( o.visual ), background( o.background ), surround( o.surround ),
       css3NonInheritedData( o.css3NonInheritedData ), css3InheritedData( o.css3InheritedData ),
       inherited( o.inherited ), pseudoStyle( 0 ), content( o.content )
 {
+    m_ref = 0;
 }
 
 void RenderStyle::inheritFrom(const RenderStyle* inheritParent)
@@ -356,19 +394,6 @@ void RenderStyle::inheritFrom(const RenderStyle* inheritParent)
 
 RenderStyle::~RenderStyle()
 {
-    RenderStyle *ps = pseudoStyle;
-    RenderStyle *prev = 0;
-
-    while (ps) {
-        prev = ps;
-        ps = ps->pseudoStyle;
-	// to prevent a double deletion.
-	// this works only because the styles below aren't really shared
-	// Dirk said we need another construct as soon as these are shared
-        prev->pseudoStyle = 0;
-        prev->deref();
-    }
-    delete content;
 }
 
 bool RenderStyle::operator==(const RenderStyle& o) const
@@ -447,23 +472,6 @@ void RenderStyle::addPseudoStyle(RenderStyle* pseudo)
     pseudoStyle = pseudo;
 }
 
-void RenderStyle::removePseudoStyle(PseudoId pid)
-{
-    RenderStyle *ps = pseudoStyle;
-    RenderStyle *prev = this;
-
-    while (ps) {
-        if (ps->noninherited_flags._styleType==pid) {
-            prev->pseudoStyle = ps->pseudoStyle;
-            ps->deref();
-            return;
-        }
-        prev = ps;
-        ps = ps->pseudoStyle;
-    }
-}
-
-
 bool RenderStyle::inheritedNotEqual( RenderStyle *other ) const
 {
     return inherited_flags != other->inherited_flags ||
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index 9bc4c5a..5be18c9 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -52,6 +52,8 @@
     if (!(group->variable == value)) \
         group.access()->variable = value;
 
+class RenderArena;
+
 namespace DOM {
     class DOMStringImpl;
     class ShadowValueImpl;
@@ -698,7 +700,7 @@ enum EDisplay {
     TABLE_CAPTION, BOX, INLINE_BOX, NONE
 };
 
-class RenderStyle : public Shared<RenderStyle>
+class RenderStyle
 {
     friend class CSSStyleSelector;
 public:
@@ -707,6 +709,25 @@ public:
     // static pseudo styles. Dynamic ones are produced on the fly.
     enum PseudoId { NOPSEUDO, FIRST_LINE, FIRST_LETTER, BEFORE, AFTER, SELECTION, FIRST_LINE_INHERITED };
 
+    void ref() { m_ref++;  }
+    void deref(RenderArena* arena) { 
+	if (m_ref) m_ref--; 
+	if (!m_ref)
+	    arenaDelete(arena);
+    }
+    bool hasOneRef() { return m_ref==1; }
+    int refCount() const { return m_ref; }
+    
+    // Overloaded new operator.  Derived classes must override operator new
+    // in order to allocate out of the RenderArena.
+    void* operator new(size_t sz, RenderArena* renderArena) throw();    
+    
+    // Overridden to prevent the normal delete from being called.
+    void operator delete(void* ptr, size_t sz);
+    
+private:
+    void arenaDelete(RenderArena *arena);
+
 protected:
 
 // !START SYNC!: Keep this in sync with the copy constructor in render_style.cpp
@@ -819,6 +840,9 @@ protected:
     // added this here, so we can get rid of the vptr in this class.
     // makes up for the same size.
     ContentData *content;
+    
+    int m_ref;
+    
 // !END SYNC!
 
 // static default style
@@ -877,7 +901,6 @@ public:
 
     RenderStyle* getPseudoStyle(PseudoId pi);
     void addPseudoStyle(RenderStyle* pseudo);
-    void removePseudoStyle(PseudoId pi);
 
     bool affectedByHoverRules() const { return  noninherited_flags._affectedByHover; }
     bool affectedByActiveRules() const { return  noninherited_flags._affectedByActive; }
diff --git a/WebCore/khtml/rendering/render_table.cpp b/WebCore/khtml/rendering/render_table.cpp
index 84b8934..afbb542 100644
--- a/WebCore/khtml/rendering/render_table.cpp
+++ b/WebCore/khtml/rendering/render_table.cpp
@@ -165,7 +165,7 @@ void RenderTable::addChild(RenderObject *child, RenderObject *beforeChild)
 		    beforeChild = 0;
   		//kdDebug( 6040 ) << this <<" creating anonymous table section beforeChild="<< beforeChild << endl;
 		o = new (renderArena()) RenderTableSection(document() /* anonymous */);
-		RenderStyle *newStyle = new RenderStyle();
+		RenderStyle *newStyle = new (renderArena()) RenderStyle();
 		newStyle->inheritFrom(style());
                 newStyle->setDisplay(TABLE_ROW_GROUP);
 		o->setStyle(newStyle);
@@ -924,7 +924,7 @@ void RenderTableSection::addChild(RenderObject *child, RenderObject *beforeChild
 	    } else {
 		//kdDebug( 6040 ) << "creating anonymous table row" << endl;
 		row = new (renderArena()) RenderTableRow(document() /* anonymous table */);
-		RenderStyle *newStyle = new RenderStyle();
+		RenderStyle *newStyle = new (renderArena()) RenderStyle();
 		newStyle->inheritFrom(style());
 		newStyle->setDisplay( TABLE_ROW );
 		row->setStyle(newStyle);
@@ -1539,7 +1539,7 @@ void RenderTableRow::addChild(RenderObject *child, RenderObject *beforeChild)
             cell = static_cast<RenderTableCell *>(last);
         else {
 	    cell = new (renderArena()) RenderTableCell(document() /* anonymous object */);
-	    RenderStyle *newStyle = new RenderStyle();
+	    RenderStyle *newStyle = new (renderArena()) RenderStyle();
 	    newStyle->inheritFrom(style());
 	    newStyle->setDisplay( TABLE_CELL );
 	    cell->setStyle(newStyle);
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 1cdd2c5..0f27a97 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -314,7 +314,7 @@ DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v)
 
     m_cssTarget = 0;
     m_accessKeyDictValid = false;
-    
+
     resetLinkColor();
     resetVisitedLinkColor();
     resetActiveLinkColor();
@@ -452,7 +452,9 @@ ProcessingInstructionImpl *DocumentImpl::createProcessingInstruction ( const DOM
 
 Attr DocumentImpl::createAttribute( NodeImpl::Id id )
 {
-    return new AttrImpl(0, docPtr(), new AttributeImpl(id, DOMString("").implementation()));
+    // Assume this is an HTML attribute, since createAttribute isn't namespace-aware.  There's no harm to XML
+    // documents if we're wrong.
+    return new AttrImpl(0, docPtr(), new HTMLAttributeImpl(id, DOMString("").implementation()));
 }
 
 EntityReferenceImpl *DocumentImpl::createEntityReference ( const DOMString &name )
@@ -1002,7 +1004,7 @@ void DocumentImpl::recalcStyle( StyleChange change )
     if ( change == Force ) {
         RenderStyle* oldStyle = m_render->style();
         if ( oldStyle ) oldStyle->ref();
-        RenderStyle* _style = new RenderStyle();
+        RenderStyle* _style = new (m_renderArena) RenderStyle();
         _style->setDisplay(BLOCK);
         _style->setVisuallyOrdered( visuallyOrdered );
         // ### make the font stuff _really_ work!!!!
@@ -1046,7 +1048,7 @@ void DocumentImpl::recalcStyle( StyleChange change )
             change = ch;
 
         if (oldStyle)
-            oldStyle->deref();
+            oldStyle->deref(m_renderArena);
     }
 
     NodeImpl *n;
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index c5457d9..3d5b1bb 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -76,6 +76,7 @@ namespace DOM {
     class AttrImpl;
     class CDATASectionImpl;
     class CSSStyleSheetImpl;
+    class CSSMappedAttributeDeclarationImpl;
     class CommentImpl;
     class DocumentFragmentImpl;
     class DocumentImpl;
diff --git a/WebCore/khtml/xml/dom_elementimpl.cpp b/WebCore/khtml/xml/dom_elementimpl.cpp
index a2c119c..c092540 100644
--- a/WebCore/khtml/xml/dom_elementimpl.cpp
+++ b/WebCore/khtml/xml/dom_elementimpl.cpp
@@ -49,6 +49,13 @@
 using namespace DOM;
 using namespace khtml;
 
+AttributeImpl* AttributeImpl::clone() const
+{
+    AttributeImpl* result = new AttributeImpl(m_id, _value);
+    result->setPrefix(_prefix);
+    return result;
+}
+
 void AttributeImpl::allocateImpl(ElementImpl* e) {
     _impl = new AttrImpl(e, e->docPtr(), this);
 }
@@ -121,7 +128,7 @@ void AttrImpl::setValue( const DOMString &v, int &exceptioncode )
 
     m_attribute->setValue(v.implementation());
     if (m_element)
-        m_element->parseAttribute(m_attribute);
+        m_element->attributeChanged(m_attribute);
 }
 
 void AttrImpl::setNodeValue( const DOMString &v, int &exceptioncode )
@@ -133,7 +140,7 @@ void AttrImpl::setNodeValue( const DOMString &v, int &exceptioncode )
 
 NodeImpl *AttrImpl::cloneNode ( bool /*deep*/)
 {
-	return new AttrImpl(0, docPtr(), new AttributeImpl(m_attribute->id(), m_attribute->value()));
+    return new AttrImpl(0, docPtr(), m_attribute->clone());
 }
 
 // DOM Section 1.1.1
@@ -221,26 +228,6 @@ unsigned short ElementImpl::nodeType() const
     return Node::ELEMENT_NODE;
 }
 
-CSSStyleDeclarationImpl* ElementImpl::inlineStyleDecl() const
-{
-    return 0;
-}
-
-CSSStyleDeclarationImpl* ElementImpl::attributeStyleDecl() const
-{
-    return 0;
-}
-
-CSSStyleDeclarationImpl* ElementImpl::getInlineStyleDecl()
-{
-    return 0;
-}
-
-CSSStyleDeclarationImpl* ElementImpl::additionalAttributeStyleDecl()
-{
-    return 0;
-}
-
 const AtomicStringList* ElementImpl::getClassList() const
 {
     return 0;
@@ -287,13 +274,18 @@ void ElementImpl::setAttribute(NodeImpl::Id id, DOMStringImpl* value, int &excep
     if (old && !value)
         namedAttrMap->removeAttribute(id);
     else if (!old && value)
-        namedAttrMap->addAttribute(new AttributeImpl(id, value));
+        namedAttrMap->addAttribute(createAttribute(id, value));
     else if (old && value) {
         old->setValue(value);
-        parseAttribute(old);
+        attributeChanged(old);
     }
 }
 
+AttributeImpl* ElementImpl::createAttribute(NodeImpl::Id id, DOMStringImpl* value)
+{
+    return new AttributeImpl(id, value);
+}
+
 void ElementImpl::setAttributeMap( NamedAttrMapImpl* list )
 {
     // If setting the whole map changes the id attribute, we need to
@@ -316,7 +308,7 @@ void ElementImpl::setAttributeMap( NamedAttrMapImpl* list )
         namedAttrMap->element = this;
         unsigned int len = namedAttrMap->length();
         for(unsigned int i = 0; i < len; i++)
-            parseAttribute(namedAttrMap->attrs[i]);
+            attributeChanged(namedAttrMap->attrs[i]);
     }
 }
 
@@ -499,7 +491,7 @@ void ElementImpl::recalcStyle( StyleChange change )
             // attach recalulates the style for all children. No need to do it twice.
             setChanged( false );
             setHasChangedChild( false );
-            newStyle->deref();
+            newStyle->deref(getDocument()->renderArena());
             return;
         }
         else if (ch != NoChange) {
@@ -508,7 +500,7 @@ void ElementImpl::recalcStyle( StyleChange change )
                 m_render->setStyle(newStyle);
             }
         }
-        newStyle->deref();
+        newStyle->deref(getDocument()->renderArena());
 
         if ( change != Force) {
             if (getDocument()->usesDescendantRules())
@@ -732,7 +724,7 @@ NamedAttrMapImpl::NamedAttrMapImpl(ElementImpl *e)
 
 NamedAttrMapImpl::~NamedAttrMapImpl()
 {
-    clearAttributes();
+    NamedAttrMapImpl::clearAttributes(); // virtual method, so qualify just to be explicit
 }
 
 bool NamedAttrMapImpl::isHTMLAttributeMap() const
@@ -845,11 +837,6 @@ AttrImpl *NamedAttrMapImpl::item ( unsigned long index ) const
     return attrs[index]->attrImpl();
 }
 
-unsigned long NamedAttrMapImpl::length(  ) const
-{
-    return len;
-}
-
 AttributeImpl* NamedAttrMapImpl::getAttributeItem(NodeImpl::Id id) const
 {
     bool matchAnyNamespace = (namespacePart(id) == anyNamespace);
@@ -915,17 +902,19 @@ NamedAttrMapImpl& NamedAttrMapImpl::operator=(const NamedAttrMapImpl& other)
     len = other.len;
     attrs = new AttributeImpl* [len];
 
-    // first initialize attrs vector, then call parseAttribute on it
-    // this allows parseAttribute to use getAttribute
+    // first initialize attrs vector, then call attributeChanged on it
+    // this allows attributeChanged to use getAttribute
     for (uint i = 0; i < len; i++) {
-        attrs[i] = new AttributeImpl(other.attrs[i]->id(), other.attrs[i]->value());
+        attrs[i] = other.attrs[i]->clone();
         attrs[i]->ref();
     }
 
+    // FIXME: This is wasteful.  The class list could be preserved on a copy, and we
+    // wouldn't have to waste time reparsing the attribute.
     // The derived class, HTMLNamedAttrMapImpl, which manages a parsed class list for the CLASS attribute,
     // will update its member variable when parse attribute is called.
     for(uint i = 0; i < len; i++)
-        element->parseAttribute(attrs[i]);
+        element->attributeChanged(attrs[i], true);
 
     return *this;
 }
@@ -950,7 +939,7 @@ void NamedAttrMapImpl::addAttribute(AttributeImpl *attr)
     // Notify the element that the attribute has been added, and dispatch appropriate mutation events
     // Note that element may be null here if we are called from insertAttr() during parsing
     if (element) {
-        element->parseAttribute(attr);
+        element->attributeChanged(attr);
         element->dispatchAttrAdditionEvent(attr);
         element->dispatchSubtreeModifiedEvent();
     }
@@ -993,7 +982,7 @@ void NamedAttrMapImpl::removeAttribute(NodeImpl::Id id)
     if (element && !attr->_value.isNull()) {
         AtomicString value = attr->_value;
         attr->_value = nullAtom;
-        element->parseAttribute(attr);
+        element->attributeChanged(attr);
         attr->_value = value;
     }
     if (element) {
diff --git a/WebCore/khtml/xml/dom_elementimpl.h b/WebCore/khtml/xml/dom_elementimpl.h
index 4068d07..08a5883 100644
--- a/WebCore/khtml/xml/dom_elementimpl.h
+++ b/WebCore/khtml/xml/dom_elementimpl.h
@@ -64,7 +64,8 @@ public:
     AttributeImpl(NodeImpl::Id id, const AtomicString& value)
         : m_id(id), _value(value), _impl(0)
         { };
-
+    virtual ~AttributeImpl() {};
+    
     const AtomicString& value() const { return _value; }
     const AtomicString& prefix() const { return _prefix; }
     NodeImpl::Id id() const { return m_id; }
@@ -73,6 +74,8 @@ public:
     bool isNull() const { return _value.isNull(); }
     bool isEmpty() const { return _value.isEmpty(); }
     
+    virtual AttributeImpl* clone() const;
+
 private:
     void setValue(const AtomicString& value) {
         _value = value;
@@ -163,7 +166,7 @@ public:
                                        const DOMString &localName) const;
     void setAttribute( NodeImpl::Id id, DOMStringImpl* value, int &exceptioncode );
     void removeAttribute( NodeImpl::Id id, int &exceptioncode );
-
+    
     DOMString prefix() const { return m_prefix; }
     void setPrefix(const DOMString &_prefix, int &exceptioncode );
 
@@ -183,8 +186,8 @@ public:
         return namedAttrMap;
     }
 
-    //This is always called, whenever an attribute changed
-    virtual void parseAttribute(AttributeImpl *) {}
+    // This method is called whenever an attribute is added, changed or removed.
+    virtual void attributeChanged(AttributeImpl* attr, bool preserveDecls = false) {}
 
     // not part of the DOM
     void setAttributeMap ( NamedAttrMapImpl* list );
@@ -201,13 +204,8 @@ public:
     virtual void mouseEventHandler( MouseEvent */*ev*/, bool /*inside*/ ) {};
     virtual bool childAllowed( NodeImpl *newChild );
     virtual bool childTypeAllowed( unsigned short type );
-
-    virtual CSSStyleDeclarationImpl* inlineStyleDecl() const;
-    virtual CSSStyleDeclarationImpl* attributeStyleDecl() const;
-    virtual CSSStyleDeclarationImpl* getInlineStyleDecl();
-    
-    // used by table cells to share style decls created by the enclosing table.
-    virtual CSSStyleDeclarationImpl* additionalAttributeStyleDecl();
+ 
+    virtual AttributeImpl* createAttribute(NodeImpl::Id id, DOMStringImpl* value);
     
     void dispatchAttrRemovalEvent(AttributeImpl *attr);
     void dispatchAttrAdditionEvent(AttributeImpl *attr);
@@ -275,7 +273,7 @@ public:
     virtual Node setNamedItem ( NodeImpl* arg, int &exceptioncode );
 
     virtual AttrImpl *item ( unsigned long index ) const;
-    virtual unsigned long length(  ) const;
+    unsigned long length() const { return len; }
 
     // Other methods (not part of DOM)
     virtual NodeImpl::Id mapId(const DOMString& namespaceURI,  const DOMString& localName,  bool readonly);
@@ -297,7 +295,7 @@ public:
     const AtomicString& id() const { return m_id; }
     void setID(const AtomicString& _id) { m_id = _id; }
     
-private:
+protected:
     // this method is internal, does no error checking at all
     void addAttribute(AttributeImpl* newAttribute);
     // this method is internal, does no error checking at all
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index a958128..69b1e22 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -1323,7 +1323,7 @@ void NodeImpl::createRendererIfNeeded()
             m_render->setStyle(style);
             parentRenderer->addChild(m_render, nextRenderer());
         }
-        style->deref();
+        style->deref(getDocument()->renderArena());
     }
 }
 

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list