[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:23:16 UTC 2009


The following commit has been merged in the debian/unstable branch:
commit 9f2aef1413663208d0b0ef5627bb83d73e310f63
Author: hyatt <hyatt at 268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date:   Fri Jan 23 01:53:13 2004 +0000

    	(1) Implement better XML error handling.
    	(2) Fix a minor z-index bug with the 'initial' value.
    	(3) Initial landing of XBL support.  Code is all ifnef KHTML_NO_XBL so that it can be turned off easily if
    	XBL never comes to fruition.
    
            Reviewed by darin
    
            * ForwardingHeaders/xbl/xbl_binding_manager.h: Added.
            * ForwardingHeaders/xbl/xbl_docimpl.h: Added.
            * WebCore.pbproj/project.pbxproj:
            * khtml/css/cssparser.cpp:
            (CSSParser::parseValue):
            * khtml/css/cssproperties.c:
            (hash_prop):
            (findProp):
            * khtml/css/cssproperties.h:
            * khtml/css/cssproperties.in:
            * khtml/css/cssstyleselector.cpp:
            (khtml::CSSStyleSelector::applyRule):
            * khtml/dom/dom_element.cpp:
            (Element::getAttributeNS):
            * khtml/misc/loader.cpp:
            (CachedXBLDocument::CachedXBLDocument):
            (CachedXBLDocument::~CachedXBLDocument):
            (CachedXBLDocument::ref):
            (CachedXBLDocument::deref):
            (CachedXBLDocument::data):
            (CachedXBLDocument::checkNotify):
            (CachedXBLDocument::error):
            (DocLoader::requestXBLDocument):
            (Cache::requestXBLDocument):
            (CachedObjectClient::setXBLDocument):
            (Cache::getStatistics):
            * khtml/misc/loader.h:
            (khtml::CachedObject::):
            (khtml::CachedXBLDocument::document):
            (khtml::CachedXBLDocument::schedule):
            * khtml/misc/loader_client.h:
            * khtml/rendering/render_style.cpp:
            (bindingURI):
            (marquee):
            (StyleCSS3NonInheritedData::~StyleCSS3NonInheritedData):
            (StyleCSS3NonInheritedData::bindingsEquivalent):
            (StyleCSS3NonInheritedData::operator==):
            (:m_next):
            (BindingURI::~BindingURI):
            (BindingURI::copy):
            (BindingURI::operator==):
            (RenderStyle::addBindingURI):
            * khtml/rendering/render_style.h:
            (khtml::BindingURI::operator!=):
            (khtml::BindingURI::next):
            (khtml::BindingURI::setNext):
            (khtml::BindingURI::uri):
            (khtml::RenderStyle::bindingURIs):
            (khtml::RenderStyle::setHasAutoZIndex):
            (khtml::RenderStyle::setZIndex):
            (khtml::RenderStyle::deleteBindingURIs):
            (khtml::RenderStyle::inheritBindingURIs):
            * khtml/xbl/xbl_binding.cpp: Added.
            (XBL::m_markedForDeath):
            (XBL::XBLBindingChain::~XBLBindingChain):
            (XBL::XBLBindingChain::firstStyleBindingChain):
            (XBL::XBLBindingChain::lastBindingChain):
            (XBL::XBLBindingChain::insertBindingChain):
            (XBL::XBLBindingChain::markForDeath):
            (XBL::XBLBindingChain::loaded):
            (XBL::XBLBindingChain::hasStylesheets):
            (XBL::XBLBindingChain::failed):
            (XBL::m_nextBinding):
            (XBL::XBLBinding::~XBLBinding):
            (XBL::XBLBinding::loaded):
            (XBL::XBLBinding::setXBLDocument):
            * khtml/xbl/xbl_binding.h: Added.
            (XBL::):
            (XBL::XBLBindingChain::uri):
            (XBL::XBLBindingChain::nextChain):
            (XBL::XBLBindingChain::previousChain):
            (XBL::XBLBindingChain::setNextBindingChain):
            (XBL::XBLBindingChain::setPreviousBindingChain):
            (XBL::XBLBindingChain::markedForDeath):
            (XBL::XBLBindingChain::element):
            * khtml/xbl/xbl_binding_manager.cpp: Added.
            (XBL::m_bindingChainTable):
            (XBL::XBLBindingManager::~XBLBindingManager):
            (XBL::XBLBindingManager::getBindingChain):
            (XBL::XBLBindingManager::setBindingChain):
            (XBL::XBLBindingManager::loadBindings):
            (XBL::XBLBindingManager::checkLoadState):
            * khtml/xbl/xbl_binding_manager.h: Added.
            * khtml/xbl/xbl_docimpl.cpp: Added.
            (XBL:::DocumentImpl):
            (XBL::XBLDocumentImpl::~XBLDocumentImpl):
            (XBL::XBLDocumentImpl::createTokenHandler):
            (XBL::XBLDocumentImpl::setPrototypeBinding):
            (XBL::XBLDocumentImpl::prototypeBinding):
            * khtml/xbl/xbl_docimpl.h: Added.
            (XBL::):
            * khtml/xbl/xbl_protobinding.cpp: Added.
            (XBL::m_handler):
            (XBL::XBLPrototypeBinding::initialize):
            (XBL::XBLPrototypeBinding::document):
            (XBL::XBLPrototypeBinding::addResource):
            * khtml/xbl/xbl_protobinding.h: Added.
            (XBL::XBLPrototypeBinding::element):
            (XBL::XBLPrototypeBinding::setHandler):
            (XBL::XBLPrototypeBinding::handler):
            * khtml/xbl/xbl_protohandler.cpp: Added.
            (XBL::m_unused):
            (XBL::XBLPrototypeHandler::~XBLPrototypeHandler):
            (XBL::XBLPrototypeHandler::appendData):
            * khtml/xbl/xbl_protohandler.h: Added.
            (XBL::XBLPrototypeHandler::setNext):
            (XBL::XBLPrototypeHandler::next):
            * khtml/xbl/xbl_protoimplementation.cpp: Added.
            (XBL::m_compiled):
            (XBL::m_next):
            (XBL::XBLPrototypeMember::appendData):
            (XBL:::XBLPrototypeMember):
            (XBL::XBLPrototypeMethod::isConstructor):
            (XBL::XBLPrototypeMethod::isDestructor):
            (XBL::XBLPrototypeMethod::addParameter):
            (XBL:::XBLPrototypeMethod):
            (XBL::XBLPrototypeConstructor::isConstructor):
            (XBL::XBLPrototypeDestructor::isDestructor):
            (XBL::m_readonly):
            (XBL::XBLPrototypeProperty::appendGetterText):
            (XBL::XBLPrototypeProperty::appendSetterText):
            * khtml/xbl/xbl_protoimplementation.h: Added.
            (XBL::XBLPrototypeMember::~XBLPrototypeMember):
            (XBL::XBLPrototypeMember::setNext):
            (XBL::XBLPrototypeMember::next):
            (XBL::XBLPrototypeImplementation::~XBLPrototypeImplementation):
            (XBL::XBLPrototypeImplementation::setMember):
            (XBL::XBLPrototypeParameter::m_next):
            (XBL::XBLPrototypeParameter::~XBLPrototypeParameter):
            (XBL::XBLPrototypeParameter::next):
            (XBL::XBLPrototypeParameter::setNext):
            (XBL::):
            * khtml/xbl/xbl_tokenizer.cpp: Added.
            (XBL::XBLTokenHandler::XBLTokenHandler):
            (XBL::XBLTokenHandler::~XBLTokenHandler):
            (XBL::XBLTokenHandler::xblDocument):
            (XBL::XBLTokenHandler::startElement):
            (XBL::XBLTokenHandler::endElement):
            (XBL::XBLTokenHandler::characters):
            (XBL::XBLTokenHandler::createBinding):
            (XBL::XBLTokenHandler::createHandler):
            (XBL::XBLTokenHandler::createResource):
            (XBL::XBLTokenHandler::createImplementation):
            (XBL::XBLTokenHandler::addMember):
            (XBL::XBLTokenHandler::createConstructor):
            (XBL::XBLTokenHandler::createDestructor):
            (XBL::XBLTokenHandler::createField):
            (XBL::XBLTokenHandler::createProperty):
            (XBL::XBLTokenHandler::createMethod):
            (XBL::XBLTokenHandler::createParameter):
            * khtml/xbl/xbl_tokenizer.h: Added.
            (XBL::):
            * khtml/xml/dom_docimpl.cpp:
            (DocumentImpl::DocumentImpl):
            (DocumentImpl::~DocumentImpl):
            (DocumentImpl::createTokenHandler):
            (DocumentTypeImpl::DocumentTypeImpl):
            (DocumentTypeImpl::~DocumentTypeImpl):
            * khtml/xml/dom_docimpl.h:
            (DOM::DocumentImpl::bindingManager):
            * khtml/xml/dom_elementimpl.cpp:
            (ElementImpl::getAttributeNS):
            (ElementImpl::childAllowed):
            * khtml/xml/dom_elementimpl.h:
            (DOM::ElementImpl::getAttribute):
            * khtml/xml/dom_nodeimpl.cpp:
            * khtml/xml/xml_tokenizer.cpp:
            (XMLHandler::XMLHandler):
            (XMLHandler::startDocument):
            (XMLHandler::startElement):
            (XMLHandler::endElement):
            (XMLHandler::startCDATA):
            (XMLHandler::endCDATA):
            (XMLHandler::characters):
            (XMLHandler::comment):
            (XMLHandler::processingInstruction):
            (XMLHandler::warning):
            (XMLHandler::error):
            (XMLHandler::fatalError):
            (XMLTokenizer::finish):
            * khtml/xml/xml_tokenizer.h:
            * kwq/KWQXmlSimpleReader.h:
            (QXmlSimpleReader::sawError):
            (QXmlSimpleReader::recordError):
            * kwq/KWQXmlSimpleReader.mm:
            (warningHandler):
            (fatalErrorHandler):
            (normalErrorHandler):
            (QXmlSimpleReader::parse):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@5967 268f45cc-cd09-0410-ab3c-d52691b4dbfc

diff --git a/WebCore/ChangeLog-2005-08-23 b/WebCore/ChangeLog-2005-08-23
index 58f441d..76d5213 100644
--- a/WebCore/ChangeLog-2005-08-23
+++ b/WebCore/ChangeLog-2005-08-23
@@ -1,3 +1,202 @@
+2004-01-22  David Hyatt  <hyatt at apple.com>
+
+	(1) Implement better XML error handling.
+	(2) Fix a minor z-index bug with the 'initial' value.
+	(3) Initial landing of XBL support.  Code is all ifnef KHTML_NO_XBL so that it can be turned off easily if
+	XBL never comes to fruition.
+	
+        Reviewed by darin
+
+        * ForwardingHeaders/xbl/xbl_binding_manager.h: Added.
+        * ForwardingHeaders/xbl/xbl_docimpl.h: Added.
+        * WebCore.pbproj/project.pbxproj:
+        * khtml/css/cssparser.cpp:
+        (CSSParser::parseValue):
+        * khtml/css/cssproperties.c:
+        (hash_prop):
+        (findProp):
+        * khtml/css/cssproperties.h:
+        * khtml/css/cssproperties.in:
+        * khtml/css/cssstyleselector.cpp:
+        (khtml::CSSStyleSelector::applyRule):
+        * khtml/dom/dom_element.cpp:
+        (Element::getAttributeNS):
+        * khtml/misc/loader.cpp:
+        (CachedXBLDocument::CachedXBLDocument):
+        (CachedXBLDocument::~CachedXBLDocument):
+        (CachedXBLDocument::ref):
+        (CachedXBLDocument::deref):
+        (CachedXBLDocument::data):
+        (CachedXBLDocument::checkNotify):
+        (CachedXBLDocument::error):
+        (DocLoader::requestXBLDocument):
+        (Cache::requestXBLDocument):
+        (CachedObjectClient::setXBLDocument):
+        (Cache::getStatistics):
+        * khtml/misc/loader.h:
+        (khtml::CachedObject::):
+        (khtml::CachedXBLDocument::document):
+        (khtml::CachedXBLDocument::schedule):
+        * khtml/misc/loader_client.h:
+        * khtml/rendering/render_style.cpp:
+        (bindingURI):
+        (marquee):
+        (StyleCSS3NonInheritedData::~StyleCSS3NonInheritedData):
+        (StyleCSS3NonInheritedData::bindingsEquivalent):
+        (StyleCSS3NonInheritedData::operator==):
+        (:m_next):
+        (BindingURI::~BindingURI):
+        (BindingURI::copy):
+        (BindingURI::operator==):
+        (RenderStyle::addBindingURI):
+        * khtml/rendering/render_style.h:
+        (khtml::BindingURI::operator!=):
+        (khtml::BindingURI::next):
+        (khtml::BindingURI::setNext):
+        (khtml::BindingURI::uri):
+        (khtml::RenderStyle::bindingURIs):
+        (khtml::RenderStyle::setHasAutoZIndex):
+        (khtml::RenderStyle::setZIndex):
+        (khtml::RenderStyle::deleteBindingURIs):
+        (khtml::RenderStyle::inheritBindingURIs):
+        * khtml/xbl/xbl_binding.cpp: Added.
+        (XBL::m_markedForDeath):
+        (XBL::XBLBindingChain::~XBLBindingChain):
+        (XBL::XBLBindingChain::firstStyleBindingChain):
+        (XBL::XBLBindingChain::lastBindingChain):
+        (XBL::XBLBindingChain::insertBindingChain):
+        (XBL::XBLBindingChain::markForDeath):
+        (XBL::XBLBindingChain::loaded):
+        (XBL::XBLBindingChain::hasStylesheets):
+        (XBL::XBLBindingChain::failed):
+        (XBL::m_nextBinding):
+        (XBL::XBLBinding::~XBLBinding):
+        (XBL::XBLBinding::loaded):
+        (XBL::XBLBinding::setXBLDocument):
+        * khtml/xbl/xbl_binding.h: Added.
+        (XBL::):
+        (XBL::XBLBindingChain::uri):
+        (XBL::XBLBindingChain::nextChain):
+        (XBL::XBLBindingChain::previousChain):
+        (XBL::XBLBindingChain::setNextBindingChain):
+        (XBL::XBLBindingChain::setPreviousBindingChain):
+        (XBL::XBLBindingChain::markedForDeath):
+        (XBL::XBLBindingChain::element):
+        * khtml/xbl/xbl_binding_manager.cpp: Added.
+        (XBL::m_bindingChainTable):
+        (XBL::XBLBindingManager::~XBLBindingManager):
+        (XBL::XBLBindingManager::getBindingChain):
+        (XBL::XBLBindingManager::setBindingChain):
+        (XBL::XBLBindingManager::loadBindings):
+        (XBL::XBLBindingManager::checkLoadState):
+        * khtml/xbl/xbl_binding_manager.h: Added.
+        * khtml/xbl/xbl_docimpl.cpp: Added.
+        (XBL:::DocumentImpl):
+        (XBL::XBLDocumentImpl::~XBLDocumentImpl):
+        (XBL::XBLDocumentImpl::createTokenHandler):
+        (XBL::XBLDocumentImpl::setPrototypeBinding):
+        (XBL::XBLDocumentImpl::prototypeBinding):
+        * khtml/xbl/xbl_docimpl.h: Added.
+        (XBL::):
+        * khtml/xbl/xbl_protobinding.cpp: Added.
+        (XBL::m_handler):
+        (XBL::XBLPrototypeBinding::initialize):
+        (XBL::XBLPrototypeBinding::document):
+        (XBL::XBLPrototypeBinding::addResource):
+        * khtml/xbl/xbl_protobinding.h: Added.
+        (XBL::XBLPrototypeBinding::element):
+        (XBL::XBLPrototypeBinding::setHandler):
+        (XBL::XBLPrototypeBinding::handler):
+        * khtml/xbl/xbl_protohandler.cpp: Added.
+        (XBL::m_unused):
+        (XBL::XBLPrototypeHandler::~XBLPrototypeHandler):
+        (XBL::XBLPrototypeHandler::appendData):
+        * khtml/xbl/xbl_protohandler.h: Added.
+        (XBL::XBLPrototypeHandler::setNext):
+        (XBL::XBLPrototypeHandler::next):
+        * khtml/xbl/xbl_protoimplementation.cpp: Added.
+        (XBL::m_compiled):
+        (XBL::m_next):
+        (XBL::XBLPrototypeMember::appendData):
+        (XBL:::XBLPrototypeMember):
+        (XBL::XBLPrototypeMethod::isConstructor):
+        (XBL::XBLPrototypeMethod::isDestructor):
+        (XBL::XBLPrototypeMethod::addParameter):
+        (XBL:::XBLPrototypeMethod):
+        (XBL::XBLPrototypeConstructor::isConstructor):
+        (XBL::XBLPrototypeDestructor::isDestructor):
+        (XBL::m_readonly):
+        (XBL::XBLPrototypeProperty::appendGetterText):
+        (XBL::XBLPrototypeProperty::appendSetterText):
+        * khtml/xbl/xbl_protoimplementation.h: Added.
+        (XBL::XBLPrototypeMember::~XBLPrototypeMember):
+        (XBL::XBLPrototypeMember::setNext):
+        (XBL::XBLPrototypeMember::next):
+        (XBL::XBLPrototypeImplementation::~XBLPrototypeImplementation):
+        (XBL::XBLPrototypeImplementation::setMember):
+        (XBL::XBLPrototypeParameter::m_next):
+        (XBL::XBLPrototypeParameter::~XBLPrototypeParameter):
+        (XBL::XBLPrototypeParameter::next):
+        (XBL::XBLPrototypeParameter::setNext):
+        (XBL::):
+        * khtml/xbl/xbl_tokenizer.cpp: Added.
+        (XBL::XBLTokenHandler::XBLTokenHandler):
+        (XBL::XBLTokenHandler::~XBLTokenHandler):
+        (XBL::XBLTokenHandler::xblDocument):
+        (XBL::XBLTokenHandler::startElement):
+        (XBL::XBLTokenHandler::endElement):
+        (XBL::XBLTokenHandler::characters):
+        (XBL::XBLTokenHandler::createBinding):
+        (XBL::XBLTokenHandler::createHandler):
+        (XBL::XBLTokenHandler::createResource):
+        (XBL::XBLTokenHandler::createImplementation):
+        (XBL::XBLTokenHandler::addMember):
+        (XBL::XBLTokenHandler::createConstructor):
+        (XBL::XBLTokenHandler::createDestructor):
+        (XBL::XBLTokenHandler::createField):
+        (XBL::XBLTokenHandler::createProperty):
+        (XBL::XBLTokenHandler::createMethod):
+        (XBL::XBLTokenHandler::createParameter):
+        * khtml/xbl/xbl_tokenizer.h: Added.
+        (XBL::):
+        * khtml/xml/dom_docimpl.cpp:
+        (DocumentImpl::DocumentImpl):
+        (DocumentImpl::~DocumentImpl):
+        (DocumentImpl::createTokenHandler):
+        (DocumentTypeImpl::DocumentTypeImpl):
+        (DocumentTypeImpl::~DocumentTypeImpl):
+        * khtml/xml/dom_docimpl.h:
+        (DOM::DocumentImpl::bindingManager):
+        * khtml/xml/dom_elementimpl.cpp:
+        (ElementImpl::getAttributeNS):
+        (ElementImpl::childAllowed):
+        * khtml/xml/dom_elementimpl.h:
+        (DOM::ElementImpl::getAttribute):
+        * khtml/xml/dom_nodeimpl.cpp:
+        * khtml/xml/xml_tokenizer.cpp:
+        (XMLHandler::XMLHandler):
+        (XMLHandler::startDocument):
+        (XMLHandler::startElement):
+        (XMLHandler::endElement):
+        (XMLHandler::startCDATA):
+        (XMLHandler::endCDATA):
+        (XMLHandler::characters):
+        (XMLHandler::comment):
+        (XMLHandler::processingInstruction):
+        (XMLHandler::warning):
+        (XMLHandler::error):
+        (XMLHandler::fatalError):
+        (XMLTokenizer::finish):
+        * khtml/xml/xml_tokenizer.h:
+        * kwq/KWQXmlSimpleReader.h:
+        (QXmlSimpleReader::sawError):
+        (QXmlSimpleReader::recordError):
+        * kwq/KWQXmlSimpleReader.mm:
+        (warningHandler):
+        (fatalErrorHandler):
+        (normalErrorHandler):
+        (QXmlSimpleReader::parse):
+
 2004-01-22  Chris Blumenberg  <cblu at apple.com>
 
 	Fixed: <rdar://problem/3537542>: support for copying HTML
diff --git a/WebCore/ForwardingHeaders/xbl/xbl_binding_manager.h b/WebCore/ForwardingHeaders/xbl/xbl_binding_manager.h
new file mode 100644
index 0000000..a367713
--- /dev/null
+++ b/WebCore/ForwardingHeaders/xbl/xbl_binding_manager.h
@@ -0,0 +1,2 @@
+#include <xbl_binding_manager.h>
+
diff --git a/WebCore/ForwardingHeaders/xbl/xbl_docimpl.h b/WebCore/ForwardingHeaders/xbl/xbl_docimpl.h
new file mode 100644
index 0000000..6cf3018
--- /dev/null
+++ b/WebCore/ForwardingHeaders/xbl/xbl_docimpl.h
@@ -0,0 +1,2 @@
+#include <xbl_docimpl.h>
+
diff --git a/WebCore/WebCore.pbproj/project.pbxproj b/WebCore/WebCore.pbproj/project.pbxproj
index 2f3f2d0..bd68a2a 100644
--- a/WebCore/WebCore.pbproj/project.pbxproj
+++ b/WebCore/WebCore.pbproj/project.pbxproj
@@ -125,9 +125,9 @@
 				F5C2869402846DCD018635CA,
 				F5C2869502846DCD018635CA,
 				F8216299029F4FB501000131,
-				93F1D31A0558CC5C00821BC0,
-				BCF0B2FA05BF7694003F612A,
 				704FD2FE056972FA003DBED9,
+				93F1D31A0558CC5C00821BC0,
+				BC8CAEC705BF251000E11F1B,
 				848A320F057E688B001A2362,
 			);
 			isa = PBXGroup;
@@ -511,6 +511,13 @@
 				84B2B1F9056BEF3A00D2B771,
 				65912B110586921000123A69,
 				65912B120586921000123A69,
+				BC41978F059293F30016347F,
+				BCEACC910592E0AD009D6AEF,
+				BCD990DE0594B9FC00AB848D,
+				BC74596505954CC80058C893,
+				BC745A1D05955F390058C893,
+				BCBDB03A0597B36E00B83B92,
+				BCBDB096059A28B100B83B92,
 			);
 			isa = PBXHeadersBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -774,6 +781,13 @@
 				84B2B1FA056BEF3A00D2B771,
 				84B2B250056BF15F00D2B771,
 				65912B100586921000123A69,
+				BC419796059294CA0016347F,
+				BCEACC900592E0AD009D6AEF,
+				BCD990DA0594B9E500AB848D,
+				BC74596405954CC80058C893,
+				BC745A1C05955F390058C893,
+				BCBDB0390597B36E00B83B92,
+				BCBDB095059A28B100B83B92,
 			);
 			isa = PBXSourcesBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -788,7 +802,7 @@
 				93F1D31B0558CC5C00821BC0,
 				704FD2FF056972FA003DBED9,
 				848A3210057E688B001A2362,
-				BCF0B2FB05BF7694003F612A,
+				BC8CAEC805BF251000E11F1B,
 			);
 			isa = PBXFrameworksBuildPhase;
 			runOnlyForDeploymentPostprocessing = 0;
@@ -1828,6 +1842,59 @@
 			settings = {
 			};
 		};
+		BC41978B059293BE0016347F = {
+			children = (
+				BC41978E059293F30016347F,
+				BC419795059294CA0016347F,
+				BCBDB094059A28B100B83B92,
+				BCBDB093059A28B100B83B92,
+				BCEACC8F0592E0AD009D6AEF,
+				BCEACC8E0592E0AD009D6AEF,
+				BCD990DD0594B9FC00AB848D,
+				BCD990D90594B9E500AB848D,
+				BC74596305954CC80058C893,
+				BC74596205954CC80058C893,
+				BC745A1B05955F390058C893,
+				BC745A1A05955F380058C893,
+				BCBDB0380597B36E00B83B92,
+				BCBDB0370597B36E00B83B92,
+			);
+			isa = PBXGroup;
+			name = xbl;
+			path = khtml;
+			refType = 2;
+			sourceTree = SOURCE_ROOT;
+		};
+		BC41978E059293F30016347F = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.c.h;
+			name = xbl_binding_manager.h;
+			path = xbl/xbl_binding_manager.h;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BC41978F059293F30016347F = {
+			fileRef = BC41978E059293F30016347F;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BC419795059294CA0016347F = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.cpp.cpp;
+			name = xbl_binding_manager.cpp;
+			path = xbl/xbl_binding_manager.cpp;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BC419796059294CA0016347F = {
+			fileRef = BC419795059294CA0016347F;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		BC7294F703804B3C00A80166 = {
 			fileEncoding = 30;
 			isa = PBXFileReference;
@@ -1884,6 +1951,66 @@
 			settings = {
 			};
 		};
+		BC74596205954CC80058C893 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.cpp.cpp;
+			name = xbl_protobinding.cpp;
+			path = xbl/xbl_protobinding.cpp;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BC74596305954CC80058C893 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.c.h;
+			name = xbl_protobinding.h;
+			path = xbl/xbl_protobinding.h;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BC74596405954CC80058C893 = {
+			fileRef = BC74596205954CC80058C893;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BC74596505954CC80058C893 = {
+			fileRef = BC74596305954CC80058C893;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BC745A1A05955F380058C893 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.cpp.cpp;
+			name = xbl_protohandler.cpp;
+			path = xbl/xbl_protohandler.cpp;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BC745A1B05955F390058C893 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.c.h;
+			name = xbl_protohandler.h;
+			path = xbl/xbl_protohandler.h;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BC745A1C05955F390058C893 = {
+			fileRef = BC745A1A05955F380058C893;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BC745A1D05955F390058C893 = {
+			fileRef = BC745A1B05955F390058C893;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		BC7B2AF80450824100A8000F = {
 			fileEncoding = 30;
 			isa = PBXFileReference;
@@ -1996,6 +2123,20 @@
 			settings = {
 			};
 		};
+		BC8CAEC705BF251000E11F1B = {
+			isa = PBXFileReference;
+			lastKnownFileType = "compiled.mach-o.dylib";
+			name = libxml2.dylib;
+			path = /usr/lib/libxml2.dylib;
+			refType = 0;
+			sourceTree = "<absolute>";
+		};
+		BC8CAEC805BF251000E11F1B = {
+			fileRef = BC8CAEC705BF251000E11F1B;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		BC8F61850405949900A80004 = {
 			fileEncoding = 30;
 			isa = PBXFileReference;
@@ -2075,6 +2216,66 @@
 			settings = {
 			};
 		};
+		BCBDB0370597B36E00B83B92 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.cpp.cpp;
+			name = xbl_protoimplementation.cpp;
+			path = xbl/xbl_protoimplementation.cpp;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BCBDB0380597B36E00B83B92 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.c.h;
+			name = xbl_protoimplementation.h;
+			path = xbl/xbl_protoimplementation.h;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BCBDB0390597B36E00B83B92 = {
+			fileRef = BCBDB0370597B36E00B83B92;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BCBDB03A0597B36E00B83B92 = {
+			fileRef = BCBDB0380597B36E00B83B92;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BCBDB093059A28B100B83B92 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.cpp.cpp;
+			name = xbl_binding.cpp;
+			path = xbl/xbl_binding.cpp;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BCBDB094059A28B100B83B92 = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.c.h;
+			name = xbl_binding.h;
+			path = xbl/xbl_binding.h;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BCBDB095059A28B100B83B92 = {
+			fileRef = BCBDB093059A28B100B83B92;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BCBDB096059A28B100B83B92 = {
+			fileRef = BCBDB094059A28B100B83B92;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		BCC60E5603F5055A00A80004 = {
 			fileEncoding = 30;
 			isa = PBXFileReference;
@@ -2103,6 +2304,66 @@
 			settings = {
 			};
 		};
+		BCD990D90594B9E500AB848D = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.cpp.cpp;
+			name = xbl_tokenizer.cpp;
+			path = xbl/xbl_tokenizer.cpp;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BCD990DA0594B9E500AB848D = {
+			fileRef = BCD990D90594B9E500AB848D;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BCD990DD0594B9FC00AB848D = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.c.h;
+			name = xbl_tokenizer.h;
+			path = xbl/xbl_tokenizer.h;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BCD990DE0594B9FC00AB848D = {
+			fileRef = BCD990DD0594B9FC00AB848D;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BCEACC8E0592E0AD009D6AEF = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.cpp.cpp;
+			name = xbl_docimpl.cpp;
+			path = xbl/xbl_docimpl.cpp;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BCEACC8F0592E0AD009D6AEF = {
+			fileEncoding = 30;
+			isa = PBXFileReference;
+			lastKnownFileType = sourcecode.c.h;
+			name = xbl_docimpl.h;
+			path = xbl/xbl_docimpl.h;
+			refType = 4;
+			sourceTree = "<group>";
+		};
+		BCEACC900592E0AD009D6AEF = {
+			fileRef = BCEACC8E0592E0AD009D6AEF;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
+		BCEACC910592E0AD009D6AEF = {
+			fileRef = BCEACC8F0592E0AD009D6AEF;
+			isa = PBXBuildFile;
+			settings = {
+			};
+		};
 		BCF0192403D3802200B2D04D = {
 			fileEncoding = 30;
 			isa = PBXFileReference;
@@ -2131,20 +2392,6 @@
 			settings = {
 			};
 		};
-		BCF0B2FA05BF7694003F612A = {
-			isa = PBXFileReference;
-			lastKnownFileType = "compiled.mach-o.dylib";
-			name = libxml2.dylib;
-			path = /usr/lib/libxml2.dylib;
-			refType = 0;
-			sourceTree = "<absolute>";
-		};
-		BCF0B2FB05BF7694003F612A = {
-			fileRef = BCF0B2FA05BF7694003F612A;
-			isa = PBXBuildFile;
-			settings = {
-			};
-		};
 //BC0
 //BC1
 //BC2
@@ -2439,6 +2686,7 @@
 				F523D27702DE4398018635CA,
 				F523D29C02DE43D9018635CA,
 				F523D2F302DE443B018635CA,
+				BC41978B059293BE0016347F,
 				F523D32402DE4478018635CA,
 				F523D15202DE42AD018635CA,
 				F523D15102DE42AD018635CA,
diff --git a/WebCore/khtml/css/cssparser.cpp b/WebCore/khtml/css/cssparser.cpp
index 4a06beb..783d7ea 100644
--- a/WebCore/khtml/css/cssparser.cpp
+++ b/WebCore/khtml/css/cssparser.cpp
@@ -978,6 +978,38 @@ bool CSSParser::parseValue( int propId, bool important )
 	break;
 
     /* CSS3 properties */
+    case CSS_PROP__KHTML_BINDING:
+#ifndef KHTML_NO_XBL
+        if (id == CSS_VAL_NONE)
+            valid_primitive = true;
+        else {
+            CSSValueListImpl* values = new CSSValueListImpl();
+            Value* val;
+            CSSValueImpl* parsedValue = 0;
+            while ((val = valueList->current())) {
+                if (val->unit == CSSPrimitiveValue::CSS_URI) {
+                    DOMString value = khtml::parseURL(domString(val->string));
+                    parsedValue = new CSSPrimitiveValueImpl(
+                                    DOMString(KURL(styleElement->baseURL().string(), value.string()).url()), 
+                                    CSSPrimitiveValue::CSS_URI);
+                } 
+                
+                if (parsedValue)
+                    values->append(parsedValue);
+                else
+                    break;
+                valueList->next();
+            }
+            if ( values->length() ) {
+                addProperty( propId, values, important );
+                valueList->next();
+                return true;
+            }
+            delete values;
+            return false;
+        }
+#endif
+        break;
     case CSS_PROP_OUTLINE_OFFSET:
         valid_primitive = validUnit(value, FLength, strict&(!nonCSSHint));
         break;
diff --git a/WebCore/khtml/css/cssproperties.c b/WebCore/khtml/css/cssproperties.c
index c08691c..51c7939 100644
--- a/WebCore/khtml/css/cssproperties.c
+++ b/WebCore/khtml/css/cssproperties.c
@@ -7,7 +7,7 @@ struct props {
     const char *name;
     int id;
 };
-/* maximum key range = 988, duplicates = 0 */
+/* maximum key range = 1007, duplicates = 0 */
 
 #ifdef __GNUC__
 __inline
@@ -21,32 +21,32 @@ hash_prop (register const char *str, register unsigned int len)
 {
   static const unsigned short asso_values[] =
     {
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993,   0, 993, 993, 993, 993,
-      993,   5, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993,  15,  10,   0,
-        0,   0, 180,  35,   0,   0,   0,   0,   0,  10,
-      315,   0,  65,  25,   0,  25,   0,  20,  30, 240,
-      125, 155,   5, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993, 993, 993, 993, 993,
-      993, 993, 993, 993, 993, 993
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012,    0, 1012, 1012, 1012, 1012,
+      1012,    0, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012,   15,   10,    0,
+         0,    0,  100,   50,    0,    0,   10,   10,    0,   10,
+       310,    0,   60,   50,    0,   30,    0,    5,    5,  260,
+       165,  190,    0, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012, 1012,
+      1012, 1012, 1012, 1012, 1012, 1012
     };
   register int hval = len;
 
@@ -130,11 +130,11 @@ findProp (register const char *str, register unsigned int len)
 {
   enum
     {
-      TOTAL_KEYWORDS = 129,
+      TOTAL_KEYWORDS = 130,
       MIN_WORD_LENGTH = 3,
       MAX_WORD_LENGTH = 32,
       MIN_HASH_VALUE = 5,
-      MAX_HASH_VALUE = 992
+      MAX_HASH_VALUE = 1011
     };
 
   static const struct props wordlist_prop[] =
@@ -145,129 +145,130 @@ findProp (register const char *str, register unsigned int len)
       {"border-color", CSS_PROP_BORDER_COLOR},
       {"bottom", CSS_PROP_BOTTOM},
       {"size", CSS_PROP_SIZE},
-      {"right", CSS_PROP_RIGHT},
-      {"height", CSS_PROP_HEIGHT},
+      {"cursor", CSS_PROP_CURSOR},
       {"border-bottom", CSS_PROP_BORDER_BOTTOM},
       {"border-bottom-color", CSS_PROP_BORDER_BOTTOM_COLOR},
-      {"cursor", CSS_PROP_CURSOR},
-      {"border-right", CSS_PROP_BORDER_RIGHT},
-      {"border-right-color", CSS_PROP_BORDER_RIGHT_COLOR},
+      {"right", CSS_PROP_RIGHT},
+      {"height", CSS_PROP_HEIGHT},
       {"top", CSS_PROP_TOP},
       {"clip", CSS_PROP_CLIP},
-      {"quotes", CSS_PROP_QUOTES},
+      {"border-right", CSS_PROP_BORDER_RIGHT},
+      {"border-right-color", CSS_PROP_BORDER_RIGHT_COLOR},
       {"border-top", CSS_PROP_BORDER_TOP},
-      {"scrollbar-track-color", CSS_PROP_SCROLLBAR_TRACK_COLOR},
       {"border-top-color", CSS_PROP_BORDER_TOP_COLOR},
+      {"quotes", CSS_PROP_QUOTES},
+      {"scrollbar-track-color", CSS_PROP_SCROLLBAR_TRACK_COLOR},
+      {"left", CSS_PROP_LEFT},
       {"-khtml-marquee", CSS_PROP__KHTML_MARQUEE},
+      {"float", CSS_PROP_FLOAT},
+      {"border-left", CSS_PROP_BORDER_LEFT},
+      {"border-left-color", CSS_PROP_BORDER_LEFT_COLOR},
       {"scrollbar-3dlight-color", CSS_PROP_SCROLLBAR_3DLIGHT_COLOR},
       {"page", CSS_PROP_PAGE},
       {"border-collapse", CSS_PROP_BORDER_COLLAPSE},
       {"scrollbar-highlight-color", CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR},
-      {"left", CSS_PROP_LEFT},
+      {"scrollbar-face-color", CSS_PROP_SCROLLBAR_FACE_COLOR},
       {"-khtml-marquee-speed", CSS_PROP__KHTML_MARQUEE_SPEED},
-      {"max-height", CSS_PROP_MAX_HEIGHT},
-      {"float", CSS_PROP_FLOAT},
-      {"border-left", CSS_PROP_BORDER_LEFT},
       {"border-style", CSS_PROP_BORDER_STYLE},
-      {"border-left-color", CSS_PROP_BORDER_LEFT_COLOR},
-      {"list-style", CSS_PROP_LIST_STYLE},
+      {"visibility", CSS_PROP_VISIBILITY},
       {"table-layout", CSS_PROP_TABLE_LAYOUT},
+      {"max-height", CSS_PROP_MAX_HEIGHT},
+      {"list-style", CSS_PROP_LIST_STYLE},
+      {"width", CSS_PROP_WIDTH},
       {"border-bottom-style", CSS_PROP_BORDER_BOTTOM_STYLE},
-      {"visibility", CSS_PROP_VISIBILITY},
-      {"-khtml-box-pack", CSS_PROP__KHTML_BOX_PACK},
       {"opacity", CSS_PROP_OPACITY},
-      {"border-right-style", CSS_PROP_BORDER_RIGHT_STYLE},
-      {"width", CSS_PROP_WIDTH},
       {"border-width", CSS_PROP_BORDER_WIDTH},
-      {"scrollbar-face-color", CSS_PROP_SCROLLBAR_FACE_COLOR},
+      {"page-break-before", CSS_PROP_PAGE_BREAK_BEFORE},
+      {"page-break-after", CSS_PROP_PAGE_BREAK_AFTER},
+      {"-khtml-box-pack", CSS_PROP__KHTML_BOX_PACK},
+      {"border-right-style", CSS_PROP_BORDER_RIGHT_STYLE},
       {"empty-cells", CSS_PROP_EMPTY_CELLS},
       {"display", CSS_PROP_DISPLAY},
       {"border-top-style", CSS_PROP_BORDER_TOP_STYLE},
-      {"-khtml-marquee-style", CSS_PROP__KHTML_MARQUEE_STYLE},
-      {"list-style-image", CSS_PROP_LIST_STYLE_IMAGE},
       {"border-bottom-width", CSS_PROP_BORDER_BOTTOM_WIDTH},
-      {"border-right-width", CSS_PROP_BORDER_RIGHT_WIDTH},
       {"direction", CSS_PROP_DIRECTION},
-      {"scrollbar-arrow-color", CSS_PROP_SCROLLBAR_ARROW_COLOR},
-      {"border-top-width", CSS_PROP_BORDER_TOP_WIDTH},
       {"outline", CSS_PROP_OUTLINE},
-      {"page-break-before", CSS_PROP_PAGE_BREAK_BEFORE},
       {"outline-color", CSS_PROP_OUTLINE_COLOR},
-      {"page-break-after", CSS_PROP_PAGE_BREAK_AFTER},
-      {"scrollbar-shadow-color", CSS_PROP_SCROLLBAR_SHADOW_COLOR},
-      {"white-space", CSS_PROP_WHITE_SPACE},
       {"unicode-bidi", CSS_PROP_UNICODE_BIDI},
+      {"border-right-width", CSS_PROP_BORDER_RIGHT_WIDTH},
+      {"-khtml-marquee-style", CSS_PROP__KHTML_MARQUEE_STYLE},
+      {"list-style-image", CSS_PROP_LIST_STYLE_IMAGE},
+      {"border-top-width", CSS_PROP_BORDER_TOP_WIDTH},
+      {"border-left-style", CSS_PROP_BORDER_LEFT_STYLE},
+      {"scrollbar-arrow-color", CSS_PROP_SCROLLBAR_ARROW_COLOR},
+      {"counter-reset", CSS_PROP_COUNTER_RESET},
       {"line-height", CSS_PROP_LINE_HEIGHT},
+      {"overflow", CSS_PROP_OVERFLOW},
+      {"white-space", CSS_PROP_WHITE_SPACE},
       {"min-height", CSS_PROP_MIN_HEIGHT},
-      {"scrollbar-darkshadow-color", CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR},
-      {"counter-reset", CSS_PROP_COUNTER_RESET},
+      {"scrollbar-shadow-color", CSS_PROP_SCROLLBAR_SHADOW_COLOR},
+      {"border-left-width", CSS_PROP_BORDER_LEFT_WIDTH},
       {"margin", CSS_PROP_MARGIN},
-      {"border-left-style", CSS_PROP_BORDER_LEFT_STYLE},
-      {"max-width", CSS_PROP_MAX_WIDTH},
-      {"background", CSS_PROP_BACKGROUND},
-      {"margin-bottom", CSS_PROP_MARGIN_BOTTOM},
-      {"background-color", CSS_PROP_BACKGROUND_COLOR},
+      {"-khtml-flow-mode", CSS_PROP__KHTML_FLOW_MODE},
       {"position", CSS_PROP_POSITION},
-      {"text-shadow", CSS_PROP_TEXT_SHADOW},
-      {"-khtml-marquee-direction", CSS_PROP__KHTML_MARQUEE_DIRECTION},
-      {"margin-right", CSS_PROP_MARGIN_RIGHT},
       {"vertical-align", CSS_PROP_VERTICAL_ALIGN},
+      {"background", CSS_PROP_BACKGROUND},
+      {"scrollbar-darkshadow-color", CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR},
+      {"font", CSS_PROP_FONT},
+      {"background-color", CSS_PROP_BACKGROUND_COLOR},
+      {"margin-bottom", CSS_PROP_MARGIN_BOTTOM},
       {"orphans", CSS_PROP_ORPHANS},
       {"caption-side", CSS_PROP_CAPTION_SIDE},
+      {"-khtml-marquee-direction", CSS_PROP__KHTML_MARQUEE_DIRECTION},
       {"padding", CSS_PROP_PADDING},
-      {"list-style-type", CSS_PROP_LIST_STYLE_TYPE},
-      {"border-left-width", CSS_PROP_BORDER_LEFT_WIDTH},
+      {"margin-right", CSS_PROP_MARGIN_RIGHT},
+      {"font-size", CSS_PROP_FONT_SIZE},
+      {"font-stretch", CSS_PROP_FONT_STRETCH},
       {"margin-top", CSS_PROP_MARGIN_TOP},
-      {"z-index", CSS_PROP_Z_INDEX},
-      {"-khtml-flow-mode", CSS_PROP__KHTML_FLOW_MODE},
-      {"overflow", CSS_PROP_OVERFLOW},
+      {"max-width", CSS_PROP_MAX_WIDTH},
       {"padding-bottom", CSS_PROP_PADDING_BOTTOM},
       {"-khtml-box-flex", CSS_PROP__KHTML_BOX_FLEX},
       {"letter-spacing", CSS_PROP_LETTER_SPACING},
-      {"text-decoration", CSS_PROP_TEXT_DECORATION},
+      {"text-shadow", CSS_PROP_TEXT_SHADOW},
+      {"z-index", CSS_PROP_Z_INDEX},
+      {"border-spacing", CSS_PROP_BORDER_SPACING},
       {"background-image", CSS_PROP_BACKGROUND_IMAGE},
+      {"background-repeat", CSS_PROP_BACKGROUND_REPEAT},
+      {"-khtml-marquee-repetition", CSS_PROP__KHTML_MARQUEE_REPETITION},
+      {"margin-left", CSS_PROP_MARGIN_LEFT},
+      {"padding-right", CSS_PROP_PADDING_RIGHT},
+      {"text-decoration", CSS_PROP_TEXT_DECORATION},
+      {"padding-top", CSS_PROP_PADDING_TOP},
       {"text-decoration-color", CSS_PROP_TEXT_DECORATION_COLOR},
+      {"list-style-type", CSS_PROP_LIST_STYLE_TYPE},
+      {"font-size-adjust", CSS_PROP_FONT_SIZE_ADJUST},
+      {"page-break-inside", CSS_PROP_PAGE_BREAK_INSIDE},
       {"-khtml-box-orient", CSS_PROP__KHTML_BOX_ORIENT},
-      {"padding-right", CSS_PROP_PADDING_RIGHT},
-      {"border-spacing", CSS_PROP_BORDER_SPACING},
       {"-khtml-box-direction", CSS_PROP__KHTML_BOX_DIRECTION},
-      {"-khtml-marquee-repetition", CSS_PROP__KHTML_MARQUEE_REPETITION},
-      {"background-repeat", CSS_PROP_BACKGROUND_REPEAT},
-      {"page-break-inside", CSS_PROP_PAGE_BREAK_INSIDE},
-      {"font", CSS_PROP_FONT},
+      {"-khtml-border-vertical-spacing", CSS_PROP__KHTML_BORDER_VERTICAL_SPACING},
+      {"padding-left", CSS_PROP_PADDING_LEFT},
+      {"outline-style", CSS_PROP_OUTLINE_STYLE},
       {"text-align", CSS_PROP_TEXT_ALIGN},
       {"-khtml-box-lines", CSS_PROP__KHTML_BOX_LINES},
-      {"padding-top", CSS_PROP_PADDING_TOP},
       {"widows", CSS_PROP_WIDOWS},
+      {"outline-offset", CSS_PROP_OUTLINE_OFFSET},
       {"-khtml-box-align", CSS_PROP__KHTML_BOX_ALIGN},
-      {"outline-style", CSS_PROP_OUTLINE_STYLE},
-      {"font-stretch", CSS_PROP_FONT_STRETCH},
-      {"font-size", CSS_PROP_FONT_SIZE},
-      {"-khtml-border-vertical-spacing", CSS_PROP__KHTML_BORDER_VERTICAL_SPACING},
-      {"margin-left", CSS_PROP_MARGIN_LEFT},
-      {"min-width", CSS_PROP_MIN_WIDTH},
       {"outline-width", CSS_PROP_OUTLINE_WIDTH},
+      {"min-width", CSS_PROP_MIN_WIDTH},
       {"-khtml-box-flex-group", CSS_PROP__KHTML_BOX_FLEX_GROUP},
-      {"font-size-adjust", CSS_PROP_FONT_SIZE_ADJUST},
-      {"-khtml-box-ordinal-group", CSS_PROP__KHTML_BOX_ORDINAL_GROUP},
-      {"padding-left", CSS_PROP_PADDING_LEFT},
-      {"list-style-position", CSS_PROP_LIST_STYLE_POSITION},
       {"content", CSS_PROP_CONTENT},
-      {"text-transform", CSS_PROP_TEXT_TRANSFORM},
       {"font-style", CSS_PROP_FONT_STYLE},
+      {"text-transform", CSS_PROP_TEXT_TRANSFORM},
+      {"-khtml-box-ordinal-group", CSS_PROP__KHTML_BOX_ORDINAL_GROUP},
+      {"list-style-position", CSS_PROP_LIST_STYLE_POSITION},
+      {"-khtml-binding", CSS_PROP__KHTML_BINDING},
+      {"font-weight", CSS_PROP_FONT_WEIGHT},
+      {"font-family", CSS_PROP_FONT_FAMILY},
       {"word-spacing", CSS_PROP_WORD_SPACING},
-      {"outline-offset", CSS_PROP_OUTLINE_OFFSET},
       {"-khtml-marquee-increment", CSS_PROP__KHTML_MARQUEE_INCREMENT},
-      {"text-indent", CSS_PROP_TEXT_INDENT},
+      {"font-variant", CSS_PROP_FONT_VARIANT},
       {"background-attachment", CSS_PROP_BACKGROUND_ATTACHMENT},
-      {"font-weight", CSS_PROP_FONT_WEIGHT},
+      {"text-indent", CSS_PROP_TEXT_INDENT},
       {"background-position", CSS_PROP_BACKGROUND_POSITION},
       {"-khtml-border-horizontal-spacing", CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING},
-      {"font-family", CSS_PROP_FONT_FAMILY},
-      {"font-variant", CSS_PROP_FONT_VARIANT},
+      {"counter-increment", CSS_PROP_COUNTER_INCREMENT},
       {"background-position-x", CSS_PROP_BACKGROUND_POSITION_X},
-      {"background-position-y", CSS_PROP_BACKGROUND_POSITION_Y},
-      {"counter-increment", CSS_PROP_COUNTER_INCREMENT}
+      {"background-position-y", CSS_PROP_BACKGROUND_POSITION_Y}
     };
 
   static const short lookup[] =
@@ -276,102 +277,104 @@ findProp (register const char *str, register unsigned int len)
        -1,  -1,  -1,  -1,  -1,  -1,   1,  -1,  -1,  -1,
         2,  -1,   3,  -1,  -1,  -1,   4,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,   5,  -1,  -1,  -1,  -1,  -1,
-        6,   7,  -1,   8,  -1,  -1,  -1,  -1,  -1,   9,
-       -1,  10,  -1,  -1,  -1,  -1,  -1,  11,  -1,  -1,
-       -1,  -1,  -1,  12,  -1,  -1,  -1,  -1,  13,  14,
-       -1,  -1,  -1,  -1,  -1,  -1,  15,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  16,  17,  -1,  -1,  -1,
+       -1,   6,  -1,   7,  -1,  -1,  -1,  -1,  -1,   8,
+       -1,  -1,  -1,  -1,  -1,   9,  10,  -1,  -1,  -1,
+       -1,  -1,  -1,  11,  12,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  13,  -1,  -1,  -1,  -1,  -1,  14,  -1,
+       15,  -1,  -1,  -1,  -1,  -1,  16,  -1,  -1,  -1,
+       -1,  17,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  18,  -1,  -1,  19,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  20,  -1,  -1,  -1,  -1,  -1,
+       21,  22,  -1,  -1,  -1,  -1,  -1,  23,  24,  25,
+       26,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  20,  -1,  -1,  -1,  -1,  -1,  21,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       22,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  23,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       27,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       28,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       29,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  24,  -1,  -1,  -1,  -1,  -1,
-       25,  -1,  -1,  -1,  -1,  26,  -1,  -1,  -1,  -1,
-       27,  28,  29,  -1,  -1,  -1,  -1,  30,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  31,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  32,  -1,  33,
-       34,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       35,  -1,  36,  37,  -1,  38,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  39,  -1,  -1,  40,  41,  42,  -1,  -1,
-       -1,  43,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       44,  45,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  46,
+       -1,  -1,  30,  -1,  -1,  31,  -1,  32,  -1,  -1,
+       33,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       34,  -1,  -1,  -1,  -1,  35,  -1,  -1,  -1,  36,
+       -1,  -1,  37,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  38,  -1,  -1,  -1,  -1,  39,  -1,  -1,
+       -1,  40,  -1,  -1,  -1,  41,  -1,  -1,  42,  -1,
+       -1,  43,  44,  -1,  -1,  -1,  45,  -1,  -1,  46,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  47,
+       -1,  -1,  48,  -1,  -1,  -1,  -1,  -1,  49,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  50,  51,  -1,
+       52,  53,  -1,  -1,  -1,  -1,  54,  55,  -1,  -1,
+       -1,  56,  -1,  -1,  -1,  -1,  -1,  -1,  57,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  47,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  58,  -1,  59,  -1,  -1,  60,  -1,  -1,  -1,
+       61,  -1,  62,  -1,  -1,  -1,  -1,  63,  -1,  -1,
+       -1,  64,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  65,  -1,  66,  67,
+       68,  69,  -1,  -1,  70,  -1,  71,  -1,  72,  -1,
+       -1,  -1,  73,  -1,  -1,  -1,  -1,  74,  -1,  -1,
+       -1,  -1,  -1,  -1,  75,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  76,  -1,  -1,  -1,  -1,  77,  -1,  78,
+       -1,  -1,  79,  -1,  -1,  80,  -1,  -1,  -1,  81,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  82,
+       -1,  -1,  -1,  -1,  -1,  83,  -1,  -1,  -1,  84,
+       -1,  85,  86,  -1,  -1,  -1,  -1,  -1,  -1,  87,
+       -1,  88,  89,  -1,  -1,  90,  91,  -1,  92,  -1,
+       -1,  -1,  -1,  -1,  -1,  93,  94,  -1,  -1,  -1,
+       -1,  95,  -1,  -1,  -1,  96,  97,  98,  -1,  -1,
+       -1,  -1,  99,  -1,  -1, 100,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  48,  -1,  49,  -1,  -1,  -1,
-       -1,  50,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  51,  -1,  -1,  -1,  -1,  52,  53,  -1,
-       -1,  54,  55,  -1,  -1,  -1,  56,  57,  -1,  -1,
-       -1,  58,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       59,  60,  -1,  61,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  62,  -1,  -1,  -1,  -1,  -1,  63,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  64,
-       -1,  -1,  -1,  -1,  -1,  65,  -1,  -1,  66,  -1,
-       -1,  67,  -1,  68,  -1,  -1,  69,  -1,  -1,  70,
-       -1,  -1,  71,  -1,  72,  -1,  -1,  73,  -1,  -1,
-       -1,  -1,  74,  -1,  -1,  -1,  -1,  75,  -1,  -1,
-       76,  -1,  -1,  -1,  -1,  -1,  -1,  77,  -1,  -1,
-       78,  -1,  79,  -1,  -1,  -1,  80,  -1,  81,  -1,
-       -1,  -1,  -1,  -1,  82,  83,  -1,  -1,  -1,  84,
-       85,  86,  -1,  -1,  -1,  -1,  87,  88,  89,  90,
-       91,  -1,  -1,  -1,  -1,  92,  -1,  -1,  -1,  -1,
-       -1,  -1,  93,  -1,  -1,  -1,  -1,  94,  -1,  95,
-       96,  97,  -1,  -1,  -1,  -1,  98,  -1,  -1,  -1,
-       -1,  99,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1, 100,  -1, 101,  -1,
-       -1,  -1, 102,  -1, 103,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1, 101,  -1, 102, 103,  -1,
+      104, 105,  -1,  -1,  -1,  -1, 106,  -1,  -1, 107,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-      104,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1, 105,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1, 106,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 107,  -1,
-       -1, 108,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1, 109,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 110,
-       -1,  -1, 111,  -1,  -1,  -1,  -1,  -1,  -1, 112,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1, 113,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1, 108,  -1, 109, 110,
+       -1,  -1,  -1,  -1,  -1,  -1, 111,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1, 112,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+      113,  -1,  -1,  -1, 114,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 115,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 116,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1, 114, 115,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1, 116,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1, 117,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1, 118,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1, 119,  -1,  -1,  -1,
-       -1, 120,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1, 121,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1, 118,  -1,  -1,  -1,  -1, 119, 120,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1, 121,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1, 122,  -1,  -1,
+       -1, 123,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1, 124,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 125,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1, 126,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1, 122,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1, 123,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1, 124,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1, 125,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1, 126,  -1,  -1,  -1,
+       -1,  -1, 127,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
+       -1,  -1,  -1,  -1,  -1,  -1, 128,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1,  -1,  -1,  -1,  -1, 127,  -1,  -1,  -1,
        -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,  -1,
-       -1,  -1, 128
+       -1, 129
     };
 
   if (len <= MAX_WORD_LENGTH && len >= MIN_WORD_LENGTH)
@@ -402,6 +405,7 @@ static const char * const propertyList[] = {
 "background-position", 
 "background-position-x", 
 "background-position-y", 
+"-khtml-binding", 
 "border-collapse", 
 "border-spacing", 
 "-khtml-border-horizontal-spacing", 
diff --git a/WebCore/khtml/css/cssproperties.h b/WebCore/khtml/css/cssproperties.h
index 5681fc2..9a5d082 100644
--- a/WebCore/khtml/css/cssproperties.h
+++ b/WebCore/khtml/css/cssproperties.h
@@ -14,130 +14,131 @@
 #define CSS_PROP_BACKGROUND_POSITION 5
 #define CSS_PROP_BACKGROUND_POSITION_X 6
 #define CSS_PROP_BACKGROUND_POSITION_Y 7
-#define CSS_PROP_BORDER_COLLAPSE 8
-#define CSS_PROP_BORDER_SPACING 9
-#define CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING 10
-#define CSS_PROP__KHTML_BORDER_VERTICAL_SPACING 11
-#define CSS_PROP_BORDER_TOP_COLOR 12
-#define CSS_PROP_BORDER_RIGHT_COLOR 13
-#define CSS_PROP_BORDER_BOTTOM_COLOR 14
-#define CSS_PROP_BORDER_LEFT_COLOR 15
-#define CSS_PROP_BORDER_TOP_STYLE 16
-#define CSS_PROP_BORDER_RIGHT_STYLE 17
-#define CSS_PROP_BORDER_BOTTOM_STYLE 18
-#define CSS_PROP_BORDER_LEFT_STYLE 19
-#define CSS_PROP_BORDER_TOP_WIDTH 20
-#define CSS_PROP_BORDER_RIGHT_WIDTH 21
-#define CSS_PROP_BORDER_BOTTOM_WIDTH 22
-#define CSS_PROP_BORDER_LEFT_WIDTH 23
-#define CSS_PROP_BOTTOM 24
-#define CSS_PROP__KHTML_BOX_ALIGN 25
-#define CSS_PROP__KHTML_BOX_DIRECTION 26
-#define CSS_PROP__KHTML_BOX_FLEX 27
-#define CSS_PROP__KHTML_BOX_FLEX_GROUP 28
-#define CSS_PROP__KHTML_BOX_LINES 29
-#define CSS_PROP__KHTML_BOX_ORDINAL_GROUP 30
-#define CSS_PROP__KHTML_BOX_ORIENT 31
-#define CSS_PROP__KHTML_BOX_PACK 32
-#define CSS_PROP_CAPTION_SIDE 33
-#define CSS_PROP_CLEAR 34
-#define CSS_PROP_CLIP 35
-#define CSS_PROP_COLOR 36
-#define CSS_PROP_CONTENT 37
-#define CSS_PROP_COUNTER_INCREMENT 38
-#define CSS_PROP_COUNTER_RESET 39
-#define CSS_PROP_CURSOR 40
-#define CSS_PROP_DIRECTION 41
-#define CSS_PROP_DISPLAY 42
-#define CSS_PROP_EMPTY_CELLS 43
-#define CSS_PROP_FLOAT 44
-#define CSS_PROP_FONT_FAMILY 45
-#define CSS_PROP_FONT_SIZE 46
-#define CSS_PROP_FONT_SIZE_ADJUST 47
-#define CSS_PROP_FONT_STRETCH 48
-#define CSS_PROP_FONT_STYLE 49
-#define CSS_PROP_FONT_VARIANT 50
-#define CSS_PROP_FONT_WEIGHT 51
-#define CSS_PROP_HEIGHT 52
-#define CSS_PROP_LEFT 53
-#define CSS_PROP_LETTER_SPACING 54
-#define CSS_PROP_LINE_HEIGHT 55
-#define CSS_PROP_LIST_STYLE_IMAGE 56
-#define CSS_PROP_LIST_STYLE_POSITION 57
-#define CSS_PROP_LIST_STYLE_TYPE 58
-#define CSS_PROP_MARGIN_TOP 59
-#define CSS_PROP_MARGIN_RIGHT 60
-#define CSS_PROP_MARGIN_BOTTOM 61
-#define CSS_PROP_MARGIN_LEFT 62
-#define CSS_PROP__KHTML_MARQUEE 63
-#define CSS_PROP__KHTML_MARQUEE_DIRECTION 64
-#define CSS_PROP__KHTML_MARQUEE_INCREMENT 65
-#define CSS_PROP__KHTML_MARQUEE_REPETITION 66
-#define CSS_PROP__KHTML_MARQUEE_SPEED 67
-#define CSS_PROP__KHTML_MARQUEE_STYLE 68
-#define CSS_PROP_MAX_HEIGHT 69
-#define CSS_PROP_MAX_WIDTH 70
-#define CSS_PROP_MIN_HEIGHT 71
-#define CSS_PROP_MIN_WIDTH 72
-#define CSS_PROP_OPACITY 73
-#define CSS_PROP_ORPHANS 74
-#define CSS_PROP_OUTLINE_COLOR 75
-#define CSS_PROP_OUTLINE_OFFSET 76
-#define CSS_PROP_OUTLINE_STYLE 77
-#define CSS_PROP_OUTLINE_WIDTH 78
-#define CSS_PROP_OVERFLOW 79
-#define CSS_PROP_PADDING_TOP 80
-#define CSS_PROP_PADDING_RIGHT 81
-#define CSS_PROP_PADDING_BOTTOM 82
-#define CSS_PROP_PADDING_LEFT 83
-#define CSS_PROP_PAGE 84
-#define CSS_PROP_PAGE_BREAK_AFTER 85
-#define CSS_PROP_PAGE_BREAK_BEFORE 86
-#define CSS_PROP_PAGE_BREAK_INSIDE 87
-#define CSS_PROP_POSITION 88
-#define CSS_PROP_QUOTES 89
-#define CSS_PROP_RIGHT 90
-#define CSS_PROP_SIZE 91
-#define CSS_PROP_TABLE_LAYOUT 92
-#define CSS_PROP_TEXT_ALIGN 93
-#define CSS_PROP_TEXT_DECORATION 94
-#define CSS_PROP_TEXT_DECORATION_COLOR 95
-#define CSS_PROP_TEXT_INDENT 96
-#define CSS_PROP_TEXT_SHADOW 97
-#define CSS_PROP_TEXT_TRANSFORM 98
-#define CSS_PROP_TOP 99
-#define CSS_PROP_UNICODE_BIDI 100
-#define CSS_PROP_VERTICAL_ALIGN 101
-#define CSS_PROP_VISIBILITY 102
-#define CSS_PROP_WHITE_SPACE 103
-#define CSS_PROP_WIDOWS 104
-#define CSS_PROP_WIDTH 105
-#define CSS_PROP_WORD_SPACING 106
-#define CSS_PROP_Z_INDEX 107
-#define CSS_PROP_BACKGROUND 108
-#define CSS_PROP_BORDER 109
-#define CSS_PROP_BORDER_COLOR 110
-#define CSS_PROP_BORDER_STYLE 111
-#define CSS_PROP_BORDER_TOP 112
-#define CSS_PROP_BORDER_RIGHT 113
-#define CSS_PROP_BORDER_BOTTOM 114
-#define CSS_PROP_BORDER_LEFT 115
-#define CSS_PROP_BORDER_WIDTH 116
-#define CSS_PROP_FONT 117
-#define CSS_PROP_LIST_STYLE 118
-#define CSS_PROP_MARGIN 119
-#define CSS_PROP_OUTLINE 120
-#define CSS_PROP_PADDING 121
-#define CSS_PROP_SCROLLBAR_FACE_COLOR 122
-#define CSS_PROP_SCROLLBAR_SHADOW_COLOR 123
-#define CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR 124
-#define CSS_PROP_SCROLLBAR_3DLIGHT_COLOR 125
-#define CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR 126
-#define CSS_PROP_SCROLLBAR_TRACK_COLOR 127
-#define CSS_PROP_SCROLLBAR_ARROW_COLOR 128
-#define CSS_PROP__KHTML_FLOW_MODE 129
+#define CSS_PROP__KHTML_BINDING 8
+#define CSS_PROP_BORDER_COLLAPSE 9
+#define CSS_PROP_BORDER_SPACING 10
+#define CSS_PROP__KHTML_BORDER_HORIZONTAL_SPACING 11
+#define CSS_PROP__KHTML_BORDER_VERTICAL_SPACING 12
+#define CSS_PROP_BORDER_TOP_COLOR 13
+#define CSS_PROP_BORDER_RIGHT_COLOR 14
+#define CSS_PROP_BORDER_BOTTOM_COLOR 15
+#define CSS_PROP_BORDER_LEFT_COLOR 16
+#define CSS_PROP_BORDER_TOP_STYLE 17
+#define CSS_PROP_BORDER_RIGHT_STYLE 18
+#define CSS_PROP_BORDER_BOTTOM_STYLE 19
+#define CSS_PROP_BORDER_LEFT_STYLE 20
+#define CSS_PROP_BORDER_TOP_WIDTH 21
+#define CSS_PROP_BORDER_RIGHT_WIDTH 22
+#define CSS_PROP_BORDER_BOTTOM_WIDTH 23
+#define CSS_PROP_BORDER_LEFT_WIDTH 24
+#define CSS_PROP_BOTTOM 25
+#define CSS_PROP__KHTML_BOX_ALIGN 26
+#define CSS_PROP__KHTML_BOX_DIRECTION 27
+#define CSS_PROP__KHTML_BOX_FLEX 28
+#define CSS_PROP__KHTML_BOX_FLEX_GROUP 29
+#define CSS_PROP__KHTML_BOX_LINES 30
+#define CSS_PROP__KHTML_BOX_ORDINAL_GROUP 31
+#define CSS_PROP__KHTML_BOX_ORIENT 32
+#define CSS_PROP__KHTML_BOX_PACK 33
+#define CSS_PROP_CAPTION_SIDE 34
+#define CSS_PROP_CLEAR 35
+#define CSS_PROP_CLIP 36
+#define CSS_PROP_COLOR 37
+#define CSS_PROP_CONTENT 38
+#define CSS_PROP_COUNTER_INCREMENT 39
+#define CSS_PROP_COUNTER_RESET 40
+#define CSS_PROP_CURSOR 41
+#define CSS_PROP_DIRECTION 42
+#define CSS_PROP_DISPLAY 43
+#define CSS_PROP_EMPTY_CELLS 44
+#define CSS_PROP_FLOAT 45
+#define CSS_PROP_FONT_FAMILY 46
+#define CSS_PROP_FONT_SIZE 47
+#define CSS_PROP_FONT_SIZE_ADJUST 48
+#define CSS_PROP_FONT_STRETCH 49
+#define CSS_PROP_FONT_STYLE 50
+#define CSS_PROP_FONT_VARIANT 51
+#define CSS_PROP_FONT_WEIGHT 52
+#define CSS_PROP_HEIGHT 53
+#define CSS_PROP_LEFT 54
+#define CSS_PROP_LETTER_SPACING 55
+#define CSS_PROP_LINE_HEIGHT 56
+#define CSS_PROP_LIST_STYLE_IMAGE 57
+#define CSS_PROP_LIST_STYLE_POSITION 58
+#define CSS_PROP_LIST_STYLE_TYPE 59
+#define CSS_PROP_MARGIN_TOP 60
+#define CSS_PROP_MARGIN_RIGHT 61
+#define CSS_PROP_MARGIN_BOTTOM 62
+#define CSS_PROP_MARGIN_LEFT 63
+#define CSS_PROP__KHTML_MARQUEE 64
+#define CSS_PROP__KHTML_MARQUEE_DIRECTION 65
+#define CSS_PROP__KHTML_MARQUEE_INCREMENT 66
+#define CSS_PROP__KHTML_MARQUEE_REPETITION 67
+#define CSS_PROP__KHTML_MARQUEE_SPEED 68
+#define CSS_PROP__KHTML_MARQUEE_STYLE 69
+#define CSS_PROP_MAX_HEIGHT 70
+#define CSS_PROP_MAX_WIDTH 71
+#define CSS_PROP_MIN_HEIGHT 72
+#define CSS_PROP_MIN_WIDTH 73
+#define CSS_PROP_OPACITY 74
+#define CSS_PROP_ORPHANS 75
+#define CSS_PROP_OUTLINE_COLOR 76
+#define CSS_PROP_OUTLINE_OFFSET 77
+#define CSS_PROP_OUTLINE_STYLE 78
+#define CSS_PROP_OUTLINE_WIDTH 79
+#define CSS_PROP_OVERFLOW 80
+#define CSS_PROP_PADDING_TOP 81
+#define CSS_PROP_PADDING_RIGHT 82
+#define CSS_PROP_PADDING_BOTTOM 83
+#define CSS_PROP_PADDING_LEFT 84
+#define CSS_PROP_PAGE 85
+#define CSS_PROP_PAGE_BREAK_AFTER 86
+#define CSS_PROP_PAGE_BREAK_BEFORE 87
+#define CSS_PROP_PAGE_BREAK_INSIDE 88
+#define CSS_PROP_POSITION 89
+#define CSS_PROP_QUOTES 90
+#define CSS_PROP_RIGHT 91
+#define CSS_PROP_SIZE 92
+#define CSS_PROP_TABLE_LAYOUT 93
+#define CSS_PROP_TEXT_ALIGN 94
+#define CSS_PROP_TEXT_DECORATION 95
+#define CSS_PROP_TEXT_DECORATION_COLOR 96
+#define CSS_PROP_TEXT_INDENT 97
+#define CSS_PROP_TEXT_SHADOW 98
+#define CSS_PROP_TEXT_TRANSFORM 99
+#define CSS_PROP_TOP 100
+#define CSS_PROP_UNICODE_BIDI 101
+#define CSS_PROP_VERTICAL_ALIGN 102
+#define CSS_PROP_VISIBILITY 103
+#define CSS_PROP_WHITE_SPACE 104
+#define CSS_PROP_WIDOWS 105
+#define CSS_PROP_WIDTH 106
+#define CSS_PROP_WORD_SPACING 107
+#define CSS_PROP_Z_INDEX 108
+#define CSS_PROP_BACKGROUND 109
+#define CSS_PROP_BORDER 110
+#define CSS_PROP_BORDER_COLOR 111
+#define CSS_PROP_BORDER_STYLE 112
+#define CSS_PROP_BORDER_TOP 113
+#define CSS_PROP_BORDER_RIGHT 114
+#define CSS_PROP_BORDER_BOTTOM 115
+#define CSS_PROP_BORDER_LEFT 116
+#define CSS_PROP_BORDER_WIDTH 117
+#define CSS_PROP_FONT 118
+#define CSS_PROP_LIST_STYLE 119
+#define CSS_PROP_MARGIN 120
+#define CSS_PROP_OUTLINE 121
+#define CSS_PROP_PADDING 122
+#define CSS_PROP_SCROLLBAR_FACE_COLOR 123
+#define CSS_PROP_SCROLLBAR_SHADOW_COLOR 124
+#define CSS_PROP_SCROLLBAR_HIGHLIGHT_COLOR 125
+#define CSS_PROP_SCROLLBAR_3DLIGHT_COLOR 126
+#define CSS_PROP_SCROLLBAR_DARKSHADOW_COLOR 127
+#define CSS_PROP_SCROLLBAR_TRACK_COLOR 128
+#define CSS_PROP_SCROLLBAR_ARROW_COLOR 129
+#define CSS_PROP__KHTML_FLOW_MODE 130
 
 #define CSS_PROP_MAX CSS_PROP_Z_INDEX
-#define CSS_PROP_TOTAL 130
+#define CSS_PROP_TOTAL 131
 #endif
 
diff --git a/WebCore/khtml/css/cssproperties.in b/WebCore/khtml/css/cssproperties.in
index c341e6b..10f4bfd 100644
--- a/WebCore/khtml/css/cssproperties.in
+++ b/WebCore/khtml/css/cssproperties.in
@@ -19,7 +19,7 @@ background-position
 # IE Extensions
 background-position-x
 background-position-y
-
+-khtml-binding
 border-collapse
 border-spacing
 -khtml-border-horizontal-spacing
diff --git a/WebCore/khtml/css/cssstyleselector.cpp b/WebCore/khtml/css/cssstyleselector.cpp
index 02a199e..e996e9d 100644
--- a/WebCore/khtml/css/cssstyleselector.cpp
+++ b/WebCore/khtml/css/cssstyleselector.cpp
@@ -2714,7 +2714,6 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
         HANDLE_INHERIT(zIndex, ZIndex)
         else if (isInitial) {
             style->setHasAutoZIndex();
-            style->setZIndex(0);
             return;
         }
         
@@ -3195,6 +3194,38 @@ void CSSStyleSelector::applyRule( int id, DOM::CSSValueImpl *value )
         break;
 
     // CSS3 Properties
+    case CSS_PROP__KHTML_BINDING: {
+#ifndef KHTML_NO_XBL
+        if (isInitial || (primitiveValue && primitiveValue->getIdent() == CSS_VAL_NONE)) {
+            style->deleteBindingURIs();
+            return;
+        }
+        else if (isInherit) {
+            if (parentStyle->bindingURIs())
+                style->inheritBindingURIs(parentStyle->bindingURIs());
+            else
+                style->deleteBindingURIs();
+            return;
+        }
+
+        if (!value->isValueList()) return;
+        CSSValueListImpl* list = static_cast<CSSValueListImpl*>(value);
+        bool firstBinding = true;
+        for (unsigned int i = 0; i < list->length(); i++) {
+            CSSValueImpl *item = list->item(i);
+            CSSPrimitiveValueImpl *val = static_cast<CSSPrimitiveValueImpl *>(item);
+            if (val->primitiveType() == CSSPrimitiveValue::CSS_URI) {
+                if (firstBinding) {
+                    firstBinding = false;
+                    style->deleteBindingURIs();
+                }
+                style->addBindingURI(val->getStringValue());
+            }
+        }
+#endif
+        break;
+    }
+
     case CSS_PROP_OUTLINE_OFFSET: {
         HANDLE_INHERIT_AND_INITIAL(outlineOffset, OutlineOffset)
 
diff --git a/WebCore/khtml/dom/dom_element.cpp b/WebCore/khtml/dom/dom_element.cpp
index 5d141ab..3a5ce0a 100644
--- a/WebCore/khtml/dom/dom_element.cpp
+++ b/WebCore/khtml/dom/dom_element.cpp
@@ -203,10 +203,7 @@ DOMString Element::getAttributeNS( const DOMString &namespaceURI,
                                    const DOMString &localName)
 {
     if (!impl) throw DOMException(DOMException::NOT_FOUND_ERR);
-    NodeImpl::Id id = impl->getDocument()->attrId(namespaceURI.implementation(),
-                                                 localName.implementation(), true);
-    if (!id) return DOMString();
-    return static_cast<ElementImpl*>(impl)->getAttribute(id);
+    return static_cast<ElementImpl*>(impl)->getAttributeNS(namespaceURI, localName);
 }
 
 void Element::setAttributeNS( const DOMString &namespaceURI,
diff --git a/WebCore/khtml/misc/loader.cpp b/WebCore/khtml/misc/loader.cpp
index 828ba67..03b53d9 100644
--- a/WebCore/khtml/misc/loader.cpp
+++ b/WebCore/khtml/misc/loader.cpp
@@ -55,7 +55,10 @@
 
 #include "html/html_documentimpl.h"
 #include "css/css_stylesheetimpl.h"
-#include "xml/dom_docimpl.h"
+
+#ifndef KHTML_NO_XBL
+#include "xbl/xbl_docimpl.h"
+#endif
 
 #if APPLE_CHANGES
 #include "KWQAssertions.h"
@@ -980,6 +983,84 @@ void CachedImage::checkNotify()
         c->notifyFinished(this);
 }
 
+// -------------------------------------------------------------------------------------------
+
+#ifndef KHTML_NO_XBL
+CachedXBLDocument::CachedXBLDocument(DocLoader* dl, const DOMString &url, KIO::CacheControl _cachePolicy, time_t _expireDate)
+: CachedObject(url, XBL, _cachePolicy, _expireDate), m_document(0)
+{
+    // It's XML we want.
+    setAccept( QString::fromLatin1("text/xml, application/xml, application/xml+xhtml") );
+    
+    // Load the file
+    Cache::loader()->load(dl, this, false);
+    m_loading = true;
+    m_codec = QTextCodec::codecForName("iso8859-1");
+}
+
+CachedXBLDocument::~CachedXBLDocument()
+{
+    if (m_document)
+        m_document->deref();
+}
+
+void CachedXBLDocument::ref(CachedObjectClient *c)
+{
+    CachedObject::ref(c);
+    if (!m_loading)
+        c->setXBLDocument(m_url, m_document);
+}
+
+void CachedXBLDocument::deref(CachedObjectClient *c)
+{
+    Cache::flush();
+    CachedObject::deref(c);
+    if (canDelete() && m_free)
+        delete this;
+}
+
+void CachedXBLDocument::data( QBuffer &buffer, bool eof )
+{
+    if (!eof) return;
+    
+    assert(!m_document);
+    
+    m_document =  new XBL::XBLDocumentImpl();
+    m_document->ref();
+    m_document->open();
+    
+    QString data = m_codec->toUnicode(buffer.buffer().data(), buffer.buffer().size());
+    m_document->write(data);
+    setSize(buffer.buffer().size());
+    buffer.close();
+    
+    m_document->finishParsing();
+    m_document->close();
+    m_loading = false;
+    checkNotify();
+}
+
+void CachedXBLDocument::checkNotify()
+{
+    if(m_loading) return;
+    
+#ifdef CACHE_DEBUG
+    kdDebug( 6060 ) << "CachedXBLDocument:: finishedLoading " << m_url.string() << endl;
+#endif
+    
+    CachedObjectClientWalker w(m_clients);
+    while (CachedObjectClient *c = w.next())
+        c->setXBLDocument(m_url, m_document);
+}
+
+
+void CachedXBLDocument::error( int /*err*/, const char */*text*/ )
+{
+    m_loading = false;
+    checkNotify();
+}
+#endif
+
 // ------------------------------------------------------------------------------------------
 
 Request::Request(DocLoader* dl, CachedObject *_object, bool _incremental)
@@ -1120,6 +1201,32 @@ CachedScript *DocLoader::requestScript( const DOM::DOMString &url, const QString
 #endif
 }
 
+#ifndef KHTML_NO_XBL
+CachedXBLDocument* DocLoader::requestXBLDocument(const DOM::DOMString &url)
+{
+    KURL fullURL = m_doc->completeURL(url.string());
+    
+    // FIXME: Is this right for XBL?
+    if (m_part && m_part->onlyLocalReferences() && fullURL.protocol() != "file") return 0;
+    
+#if APPLE_CHANGES
+    if (KWQCheckIfReloading(this)) {
+        setCachePolicy(KIO::CC_Reload);
+    }
+#endif
+    
+    bool reload = needReload(fullURL);
+    
+#if APPLE_CHANGES
+    CachedXBLDocument *cachedObject = Cache::requestXBLDocument(this, url, reload, m_expireDate);
+    KWQCheckCacheObjectStatus(this, cachedObject);
+    return cachedObject;
+#else
+    return Cache::requestXBLDocument(this, url, reload, m_expireDate);
+#endif
+}
+#endif
+
 void DocLoader::setAutoloadImages( bool enable )
 {
     if ( enable == m_bautoloadImages )
@@ -1714,6 +1821,83 @@ void Cache::preloadScript( const QString &url, const QString &script_data)
     cache->insert( url, script );
 }
 
+#ifndef KHTML_NO_XBL
+CachedXBLDocument* Cache::requestXBLDocument(DocLoader* dl, const DOMString & url, bool reload, 
+                                             time_t _expireDate)
+{
+    // this brings the _url to a standard form...
+    KURL kurl;
+    KIO::CacheControl cachePolicy;
+    if (dl) {
+        kurl = dl->m_doc->completeURL(url.string());
+        cachePolicy = dl->cachePolicy();
+    }
+    else {
+        kurl = url.string();
+        cachePolicy = KIO::CC_Verify;
+    }
+    
+#if APPLE_CHANGES
+    // Checking if the URL is malformed is lots of extra work for little benefit.
+#else
+    if( kurl.isMalformed() )
+    {
+        kdDebug( 6060 ) << "Cache: Malformed url: " << kurl.url() << endl;
+        return 0;
+    }
+#endif
+    
+    CachedObject *o = cache->find(kurl.url());
+    if(!o)
+    {
+#ifdef CACHE_DEBUG
+        kdDebug( 6060 ) << "Cache: new: " << kurl.url() << endl;
+#endif
+        CachedXBLDocument* doc = new CachedXBLDocument(dl, kurl.url(), cachePolicy, _expireDate);
+#if APPLE_CHANGES
+        if (cacheDisabled)
+            doc->setFree(true);
+        else {
+#endif
+            cache->insert(kurl.url(), doc);
+            moveToHeadOfLRUList(doc);
+#if APPLE_CHANGES
+        }
+#endif
+        o = doc;
+    }
+    
+#if !APPLE_CHANGES
+    o->setExpireDate(_expireDate, true);
+#endif
+    
+    if(o->type() != CachedObject::XBL)
+    {
+#ifdef CACHE_DEBUG
+        kdDebug( 6060 ) << "Cache::Internal Error in requestXBLDocument url=" << kurl.url() << "!" << endl;
+#endif
+        return 0;
+    }
+    
+#ifdef CACHE_DEBUG
+    if( o->status() == CachedObject::Pending )
+        kdDebug( 6060 ) << "Cache: loading in progress: " << kurl.url() << endl;
+    else
+        kdDebug( 6060 ) << "Cache: using cached: " << kurl.url() << endl;
+#endif
+    
+    moveToHeadOfLRUList(o);
+    if ( dl ) {
+        dl->m_docObjects.remove( o );
+#if APPLE_CHANGES
+        if (!cacheDisabled)
+#endif
+            dl->m_docObjects.append( o );
+    }
+    return static_cast<CachedXBLDocument*>(o);
+}
+#endif
+
 void Cache::flush(bool force)
 {
     if (force)
@@ -1990,6 +2174,9 @@ CachedObjectClient *CachedObjectClientWalker::next()
 
 void CachedObjectClient::setPixmap(const QPixmap &, const QRect&, CachedImage *) {}
 void CachedObjectClient::setStyleSheet(const DOM::DOMString &/*url*/, const DOM::DOMString &/*sheet*/) {}
+#ifndef KHTML_NO_XBL
+void CachedObjectClient::setXBLDocument(const DOM::DOMString& url, XBL::XBLDocumentImpl* doc) {}
+#endif
 void CachedObjectClient::notifyFinished(CachedObject * /*finishedObj*/) {}
 
 #include "loader.moc"
@@ -2027,7 +2214,12 @@ Cache::Statistics Cache::getStatistics()
                 stats.scripts.count++;
                 stats.scripts.size += o->size();
                 break;
-
+#ifndef KHTML_NO_XBL
+            case CachedObject::XBL:
+                stats.xblDocs.count++;
+                stats.xblDocs.size += o->size();
+                break;
+#endif
             default:
                 stats.other.count++;
                 stats.other.size += o->size();
diff --git a/WebCore/khtml/misc/loader.h b/WebCore/khtml/misc/loader.h
index ff26696..8821cd6 100644
--- a/WebCore/khtml/misc/loader.h
+++ b/WebCore/khtml/misc/loader.h
@@ -101,7 +101,10 @@ namespace khtml
 	enum Type {
 	    Image,
 	    CSSStyleSheet,
-	    Script
+	    Script,
+#ifndef KHTML_NO_XBL
+            XBL
+#endif
 	};
 
 	enum Status {
@@ -359,6 +362,31 @@ namespace khtml
 #endif
     };
 
+#ifndef KHTML_NO_XBL
+    class CachedXBLDocument : public CachedObject
+    {
+    public:
+        CachedXBLDocument(DocLoader* dl, const DOM::DOMString &url, KIO::CacheControl cachePolicy, time_t _expireDate);
+        virtual ~CachedXBLDocument();
+        
+        XBL::XBLDocumentImpl* document() const { return m_document; }
+        
+        virtual void ref(CachedObjectClient *consumer);
+        virtual void deref(CachedObjectClient *consumer);
+        
+        virtual void data( QBuffer &buffer, bool eof );
+        virtual void error( int err, const char *text );
+        
+        virtual bool schedule() const { return true; }
+        
+        void checkNotify();
+        
+protected:
+        XBL::XBLDocumentImpl* m_document;
+        QTextCodec* m_codec;
+    };
+#endif
+
     /**
      * @internal
      *
@@ -373,7 +401,8 @@ namespace khtml
 	CachedImage *requestImage( const DOM::DOMString &url);
 	CachedCSSStyleSheet *requestStyleSheet( const DOM::DOMString &url, const QString& charset);
         CachedScript *requestScript( const DOM::DOMString &url, const QString& charset);
-
+        CachedXBLDocument* requestXBLDocument(const DOM::DOMString &url);
+        
 	bool autoloadImages() const { return m_bautoloadImages; }
         KIO::CacheControl cachePolicy() const { return m_cachePolicy; }
         KHTMLSettings::KAnimationAdvice showAnimations() const { return m_showAnimations; }
@@ -494,6 +523,12 @@ namespace khtml
 	 */
 	static CachedCSSStyleSheet *requestStyleSheet( DocLoader* l, const DOM::DOMString &url, bool reload=false, time_t _expireDate=0, const QString& charset = QString::null);
 
+#ifndef KHTML_NO_XBL
+        // Ask the cache for an XBL document.
+        static CachedXBLDocument* requestXBLDocument(DocLoader* l, const DOM::DOMString &url, 
+                                                     bool reload=false, time_t _expireDate=0);
+#endif
+
         /**
          * Pre-loads a stylesheet into the cache.
          */
@@ -556,6 +591,9 @@ namespace khtml
             TypeStatistic movies;
             TypeStatistic styleSheets;
             TypeStatistic scripts;
+#ifndef KHTML_NO_XBL
+            TypeStatistic xblDocs;
+#endif
             TypeStatistic other;
         };
 
diff --git a/WebCore/khtml/misc/loader_client.h b/WebCore/khtml/misc/loader_client.h
index 261af98..400c63a 100644
--- a/WebCore/khtml/misc/loader_client.h
+++ b/WebCore/khtml/misc/loader_client.h
@@ -5,6 +5,12 @@
 #include <qpixmap.h>
 #include "dom/dom_string.h"
 
+#ifndef KHTML_NO_XBL
+namespace XBL {
+    class XBLDocumentImpl;
+};
+#endif
+
 namespace khtml {
     class CachedObject;
     class CachedImage;
@@ -26,6 +32,9 @@ namespace khtml {
         // return whether we need manual update
 	virtual void setPixmap(const QPixmap &, const QRect&, CachedImage *);
 	virtual void setStyleSheet(const DOM::DOMString &/*url*/, const DOM::DOMString &/*sheet*/);
+#ifndef KHTML_NO_XBL
+        virtual void setXBLDocument(const DOM::DOMString& url, XBL::XBLDocumentImpl* doc);
+#endif
 	virtual void notifyFinished(CachedObject * /*finishedObj*/);
     };
 };
diff --git a/WebCore/khtml/rendering/render_block.cpp b/WebCore/khtml/rendering/render_block.cpp
index f150d04..719548f 100644
--- a/WebCore/khtml/rendering/render_block.cpp
+++ b/WebCore/khtml/rendering/render_block.cpp
@@ -622,7 +622,8 @@ void RenderBlock::layoutBlockChildren( bool relayoutChildren )
                     child->setStaticX(borderRight()+paddingRight());
             }
             if (child->hasStaticY()) {
-                int yPosEstimate = m_height + (!topMarginContributor ? (prevPosMargin - prevNegMargin) : 0);
+                int marginOffset = (!topMarginContributor || !canCollapseTopWithChildren) ? (prevPosMargin - prevNegMargin) : 0;
+                int yPosEstimate = m_height + marginOffset;
                 child->setStaticY(yPosEstimate);
             }
             child = child->nextSibling();
@@ -1044,7 +1045,7 @@ void RenderBlock::layoutBlockChildren( bool relayoutChildren )
     if (m_overflowHeight < m_height)
         m_overflowHeight = m_height;
 
-    if (canCollapseBottomWithChildren && !topMarginContributor) {
+    if (canCollapseBottomWithChildren && (!topMarginContributor || !canCollapseTopWithChildren)) {
         // Update our max pos/neg bottom margins, since we collapsed our bottom margins
         // with our children.
         if (prevPosMargin > m_maxBottomPosMargin)
diff --git a/WebCore/khtml/rendering/render_style.cpp b/WebCore/khtml/rendering/render_style.cpp
index 3497733..fcd8bcb 100644
--- a/WebCore/khtml/rendering/render_style.cpp
+++ b/WebCore/khtml/rendering/render_style.cpp
@@ -181,17 +181,46 @@ bool StyleFlexibleBoxData::operator==(const StyleFlexibleBoxData& o) const
 
 StyleCSS3NonInheritedData::StyleCSS3NonInheritedData()
 :Shared<StyleCSS3NonInheritedData>(), opacity(RenderStyle::initialOpacity())
+#ifndef KHTML_NO_XBL
+, bindingURI(0)
+#endif
 {
 }
 
 StyleCSS3NonInheritedData::StyleCSS3NonInheritedData(const StyleCSS3NonInheritedData& o)
 :Shared<StyleCSS3NonInheritedData>(), opacity(o.opacity), flexibleBox(o.flexibleBox), marquee(o.marquee)
 {
+#ifndef KHTML_NO_XBL
+    bindingURI = o.bindingURI ? o.bindingURI->copy() : 0;
+#endif
 }
 
+StyleCSS3NonInheritedData::~StyleCSS3NonInheritedData()
+{
+#ifndef KHTML_NO_XBL
+    delete bindingURI;
+#endif
+}
+
+#ifndef KHTML_NO_XBL
+bool StyleCSS3NonInheritedData::bindingsEquivalent(const StyleCSS3NonInheritedData& o) const
+{
+    if (this == &o) return true;
+    if (!bindingURI && o.bindingURI || bindingURI && !o.bindingURI)
+        return false;
+    if (bindingURI && o.bindingURI && (*bindingURI != *o.bindingURI))
+        return false;
+    return true;
+}
+#endif
+
 bool StyleCSS3NonInheritedData::operator==(const StyleCSS3NonInheritedData& o) const
 {
-    return opacity == o.opacity && flexibleBox == o.flexibleBox && marquee == o.marquee;
+    return opacity == o.opacity && flexibleBox == o.flexibleBox && marquee == o.marquee
+#ifndef KHTML_NO_XBL
+           && bindingsEquivalent(o)
+#endif
+    ;
 }
 
 StyleCSS3InheritedData::StyleCSS3InheritedData()
@@ -742,6 +771,59 @@ void ContentData::clearContent()
     }
 }
 
+#ifndef KHTML_NO_XBL
+BindingURI::BindingURI(DOM::DOMStringImpl* uri) 
+:m_next(0)
+{ 
+    m_uri = uri;
+    if (uri) uri->ref();
+}
+
+BindingURI::~BindingURI()
+{
+    if (m_uri)
+        m_uri->deref();
+    delete m_next;
+}
+
+BindingURI* BindingURI::copy()
+{
+    BindingURI* newBinding = new BindingURI(m_uri);
+    if (next()) {
+        BindingURI* nextCopy = next()->copy();
+        newBinding->setNext(nextCopy);
+    }
+    
+    return newBinding;
+}
+
+bool BindingURI::operator==(const BindingURI& o) const
+{
+    if ((m_next && !o.m_next) || (!m_next && o.m_next) ||
+        (m_next && o.m_next && *m_next != *o.m_next))
+        return false;
+    
+    if (m_uri == o.m_uri)
+        return true;
+    if (!m_uri || !o.m_uri)
+        return false;
+    
+    return DOMString(m_uri) == DOMString(o.m_uri);
+}
+
+void RenderStyle::addBindingURI(DOM::DOMStringImpl* uri)
+{
+    BindingURI* binding = new BindingURI(uri);
+    if (!bindingURIs())
+        SET_VAR(css3NonInheritedData, bindingURI, binding)
+    else 
+        for (BindingURI* b = bindingURIs(); b; b = b->next()) {
+            if (!b->next())
+                b->setNext(binding);
+        }
+}
+#endif
+
 void RenderStyle::setTextShadow(ShadowData* val, bool add)
 {
     StyleCSS3InheritedData* css3Data = css3InheritedData.access(); 
diff --git a/WebCore/khtml/rendering/render_style.h b/WebCore/khtml/rendering/render_style.h
index 3561dde..415ce6a 100644
--- a/WebCore/khtml/rendering/render_style.h
+++ b/WebCore/khtml/rendering/render_style.h
@@ -495,6 +495,28 @@ struct ShadowData {
     ShadowData* next;
 };
 
+#ifndef KHTML_NO_XBL
+struct BindingURI {
+    BindingURI(DOM::DOMStringImpl*);
+    ~BindingURI();
+
+    BindingURI* copy();
+
+    bool operator==(const BindingURI& o) const;
+    bool operator!=(const BindingURI& o) const {
+        return !(*this == o);
+    }
+    
+    BindingURI* next() { return m_next; }
+    void setNext(BindingURI* n) { m_next = n; }
+    
+    DOM::DOMStringImpl* uri() { return m_uri; }
+    
+    BindingURI* m_next;
+    DOM::DOMStringImpl* m_uri;
+};
+#endif
+
 // This struct is for rarely used non-inherited CSS3 properties.  By grouping them together,
 // we save space, and only allocate this object when someone actually uses
 // a non-inherited CSS3 property.
@@ -502,9 +524,13 @@ class StyleCSS3NonInheritedData : public Shared<StyleCSS3NonInheritedData>
 {
 public:
     StyleCSS3NonInheritedData();
-    ~StyleCSS3NonInheritedData() {}
+    ~StyleCSS3NonInheritedData();
     StyleCSS3NonInheritedData(const StyleCSS3NonInheritedData& o);
 
+#ifndef KHTML_NO_XBL
+    bool bindingsEquivalent(const StyleCSS3NonInheritedData& o) const;
+#endif
+
     bool operator==(const StyleCSS3NonInheritedData& o) const;
     bool operator!=(const StyleCSS3NonInheritedData &o) const {
         return !(*this == o);
@@ -513,6 +539,9 @@ public:
     float opacity;         // Whether or not we're transparent.
     DataRef<StyleFlexibleBoxData> flexibleBox; // Flexible box properties 
     DataRef<StyleMarqueeData> marquee; // Marquee properties
+#ifndef KHTML_NO_XBL
+    BindingURI* bindingURI; // The XBL binding URI list.
+#endif
 };
 
 // This struct is for rarely used inherited CSS3 properties.  By grouping them together,
@@ -650,7 +679,7 @@ struct ContentData {
 
     ContentData* _nextContent;
 };
-    
+
 //------------------------------------------------
 
 enum EDisplay {
@@ -997,6 +1026,9 @@ public:
     EPageBreak pageBreakAfter() const { return noninherited_flags._page_break_after; }
     
     // CSS3 Getter Methods
+#ifndef KHTML_NO_XBL
+    BindingURI* bindingURIs() const { return css3NonInheritedData->bindingURI; }
+#endif
     int outlineOffset() const { 
         if (background->outline.style == BNONE) return 0; return background->outline._offset;
     }
@@ -1149,9 +1181,9 @@ public:
     void setHtmlHacks(bool b=true) { inherited_flags._htmlHacks = b; }
 
     bool hasAutoZIndex() { return box->z_auto; }
-    void setHasAutoZIndex() { SET_VAR(box, z_auto, true) }
+    void setHasAutoZIndex() { SET_VAR(box, z_auto, true); SET_VAR(box, z_index, 0) }
     int zIndex() const { return box->z_index; }
-    void setZIndex(int v) { SET_VAR(box, z_auto, false); SET_VAR(box,z_index,v) }
+    void setZIndex(int v) { SET_VAR(box, z_auto, false); SET_VAR(box, z_index, v) }
 
     void setWidows(short w) { SET_VAR(inherited, widows, w); }
     void setOrphans(short o) { SET_VAR(inherited, orphans, o); }
@@ -1160,6 +1192,16 @@ public:
     void setPageBreakAfter(EPageBreak b) { noninherited_flags._page_break_after = b; }
     
     // CSS3 Setters
+#ifndef KHTML_NO_XBL
+    void deleteBindingURIs() { 
+        delete css3NonInheritedData->bindingURI; 
+        SET_VAR(css3NonInheritedData, bindingURI, 0);
+    }
+    void inheritBindingURIs(BindingURI* other) {
+        SET_VAR(css3NonInheritedData, bindingURI, other->copy());
+    }
+    void addBindingURI(DOM::DOMStringImpl* uri);
+#endif
     void setOutlineOffset(unsigned short v) {  SET_VAR(background,outline._offset,v) }
     void setTextShadow(ShadowData* val, bool add=false);
     void setOpacity(float f) { SET_VAR(css3NonInheritedData, opacity, f); }
diff --git a/WebCore/khtml/xbl/xbl_binding.cpp b/WebCore/khtml/xbl/xbl_binding.cpp
new file mode 100644
index 0000000..6ced43e
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_binding.cpp
@@ -0,0 +1,173 @@
+#include <kurl.h>
+#include "xbl_protobinding.h"
+#include "xbl_binding.h"
+#include "xbl_docimpl.h"
+#include "xbl_binding_manager.h"
+#include "misc/loader.h"
+
+using DOM::DOMString;
+using DOM::ElementImpl;
+using DOM::DocumentImpl;
+using khtml::CachedXBLDocument;
+
+namespace XBL
+{
+
+XBLBindingChain::XBLBindingChain(ElementImpl* elt, const DOMString& uri, bool isStyleChain)
+:m_uri(uri), m_element(elt), m_previousChain(0), m_nextChain(0), m_isStyleChain(isStyleChain), 
+ m_markedForDeath(false)
+{
+    m_binding = new XBLBinding(this, uri);
+}
+
+XBLBindingChain::~XBLBindingChain()
+{
+    delete m_binding;
+    delete m_nextChain;
+}
+
+XBLBindingChain* XBLBindingChain::firstStyleBindingChain()
+{
+    if (m_isStyleChain)
+        return this;
+    if (m_nextChain)
+        return m_nextChain->firstStyleBindingChain();
+    return 0;
+}
+
+XBLBindingChain* XBLBindingChain::lastBindingChain()
+{
+    if (m_nextChain)
+        return m_nextChain->lastBindingChain();
+    return this;
+}
+
+void XBLBindingChain::insertBindingChain(XBLBindingChain* bindingChain)
+{
+    if (m_nextChain) {
+        m_nextChain->setPreviousBindingChain(bindingChain);
+        bindingChain->setNextBindingChain(m_nextChain);
+    }
+    
+    if (bindingChain)
+        bindingChain->setPreviousBindingChain(this);
+    setNextBindingChain(bindingChain);
+}
+
+void XBLBindingChain::markForDeath()
+{
+    m_markedForDeath = true;
+    if (m_nextChain && m_isStyleChain)
+        m_nextChain->markForDeath();
+
+    // FIXME: Schedule a timer that will fire as soon as possible and destroy the binding.
+}
+
+bool XBLBindingChain::loaded() const
+{
+    if (m_binding && !m_binding->loaded())
+        return false;
+    if (m_nextChain)
+        return m_nextChain->loaded();
+    return true;
+}
+
+bool XBLBindingChain::hasStylesheets() const
+{
+    if (m_binding && m_binding->hasStylesheets())
+        return true;
+    if (m_nextChain)
+        return m_nextChain->hasStylesheets();
+    return false;
+}
+
+void XBLBindingChain::failed()
+{
+    delete m_binding;
+    m_binding = 0;
+    
+    element()->getDocument()->bindingManager()->checkLoadState(element());
+}
+
+// ==========================================================================================
+
+XBLBinding::XBLBinding(XBLBindingChain* ch, const DOMString& uri, XBLBinding* derivedBinding)
+:m_chain(ch), m_xblDocument(0), m_prototype(0), m_previousBinding(0), m_nextBinding(0)
+{
+    if (derivedBinding)
+        derivedBinding->setNextBinding(this);
+    setPreviousBinding(derivedBinding);
+    
+    // Parse the URL into a document URI and a binding id.  Kick off the load of
+    // the XBL document here, and cache the id that we hope to find once the document
+    // has loaded in m_id.
+    DOMString docURL = uri;
+    int hashIndex = uri.find('#');
+    if (hashIndex != -1) {
+        QString url = uri.string();
+        docURL = url.left(hashIndex);
+        if (int(url.length()) > hashIndex+1)
+            m_id = url.right(url.length()-hashIndex-1);
+    }
+    else
+        m_id = "_xbl_first_binding";
+    
+    // Now kick off the load of the XBL document.
+    DocumentImpl* doc = chain()->element()->getDocument();
+    m_xblDocument = doc->docLoader()->requestXBLDocument(docURL);
+    if (m_xblDocument)
+        m_xblDocument->ref(this);
+}
+
+XBLBinding::~XBLBinding()
+{
+    delete m_nextBinding;
+    if (m_xblDocument)
+        m_xblDocument->deref(this);
+}
+
+bool XBLBinding::loaded() const
+{
+    // If our prototype document hasn't loaded, then we aren't ready yet.
+    if (!m_prototype)
+        return false;
+    
+    // FIXME: If all our resources haven't loaded, then we aren't ready.
+    
+    // If our base binding hasn't loaded, then we also aren't ready yet.
+    if (m_nextBinding && !m_nextBinding->loaded())
+        return false;
+
+    // We're ready.
+    return true;
+}
+
+void XBLBinding::setXBLDocument(const DOMString& url, XBLDocumentImpl* doc) 
+{
+    // Locate the prototype binding.  If it doesn't exist in the XBLDocument, then the entire binding
+    // chain is considered invalid and should be destroyed.
+    if (m_id == "_xbl_first_binding") {
+        // FIXME: Obtain the ID of the first binding by examining the DOM.
+    }
+    
+    // Obtain our prototype from the XBL document.
+    m_prototype = doc->prototypeBinding(m_id);
+    
+    if (!m_prototype)
+        return chain()->failed(); // This binding chain failed to load. Discard the chain.
+    
+    // See if we have an "extends" attribute.  If so, load that binding.
+    DOMString extends = m_prototype->element()->getAttribute("extends");
+    if (!extends.isEmpty()) {
+        // FIXME: Add support for : extension for built-in types, e.g., "html:img".
+        // Resolve to an absolute URL.
+        new XBLBinding(chain(), 
+                       KURL(m_prototype->document()->baseURL(), extends.string()).url(),
+                       this);
+        return;
+    }
+    
+    chain()->element()->getDocument()->bindingManager()->checkLoadState(chain()->element());
+}
+
+}
diff --git a/WebCore/khtml/xbl/xbl_binding.h b/WebCore/khtml/xbl/xbl_binding.h
new file mode 100644
index 0000000..a6e3865
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_binding.h
@@ -0,0 +1,85 @@
+#include "misc/loader_client.h"
+#include "dom/dom_string.h"
+
+namespace khtml
+{
+    class CachedXBLDocument;
+}
+
+namespace DOM
+{
+    class ElementImpl;
+}
+
+namespace XBL
+{
+class XBLPrototypeBinding;
+class XBLBindingChain;
+
+class XBLBinding: public khtml::CachedObjectClient
+{
+public:
+    XBLBinding(XBLBindingChain* chain, const DOM::DOMString& uri, XBLBinding* derivedBinding = 0);
+    virtual ~XBLBinding();
+
+    bool loaded() const;
+    bool hasStylesheets() const { return false; } // FIXME: Implement scoped sheets.
+    
+    XBLBindingChain* chain() const { return m_chain; }
+
+    void setNextBinding(XBLBinding* n) { m_nextBinding = n; }
+    void setPreviousBinding(XBLBinding* p) { m_previousBinding = p; }
+    
+    // CachedObjectClient
+    void setXBLDocument(const DOM::DOMString& url, XBL::XBLDocumentImpl* doc);
+    
+private:
+    XBLBindingChain* m_chain; // The owning binding chain.
+    khtml::CachedXBLDocument* m_xblDocument; // The prototype XBL document.
+    XBLPrototypeBinding* m_prototype; // The prototype binding that corresponds to our binding.
+    DOM::DOMString m_id; // The id of the binding.
+
+    XBLBinding* m_previousBinding; // The previous explicit connection.
+    XBLBinding* m_nextBinding; // The next explicit connection (e.g., a base binding specified via the extends attribute).
+};
+
+class XBLBindingChain
+{
+public:
+    XBLBindingChain(DOM::ElementImpl* elt, const DOM::DOMString& uri, bool isStyleChain);
+    ~XBLBindingChain();
+    
+    const DOM::DOMString& uri() const { return m_uri; }
+    
+    XBLBindingChain* firstStyleBindingChain();
+    XBLBindingChain* lastBindingChain() ;
+    void insertBindingChain(XBLBindingChain* bindingChain);
+    
+    XBLBindingChain* nextChain() const { return m_nextChain; }
+    XBLBindingChain* previousChain() const { return m_previousChain; }
+    
+    void setNextBindingChain(XBLBindingChain* bindingChain) { m_nextChain = bindingChain; }
+    void setPreviousBindingChain(XBLBindingChain* bindingChain) { m_previousChain = bindingChain; }
+    
+    bool markedForDeath() const { return m_markedForDeath; }
+    void markForDeath();
+
+    bool loaded() const;
+    bool hasStylesheets() const;
+    
+    DOM::ElementImpl* element() const { return m_element; }
+    
+    void failed();
+    
+private:
+    DOM::DOMString m_uri; // The URI of the binding that is the leaf of this chain.
+    DOM::ElementImpl* m_element; // The bound element. All the bindings in the chain are attached to this element.
+    XBLBinding* m_binding; // The bindings contained within this chain.
+    XBLBindingChain* m_previousChain; // The previous implicit connection.
+    XBLBindingChain* m_nextChain; // The next implicit connection (e.g., from addBinding or multiple urls in a CSS binding declaration).
+    
+    bool m_isStyleChain : 1;
+    bool m_markedForDeath : 1;
+};
+
+}
\ No newline at end of file
diff --git a/WebCore/khtml/xbl/xbl_binding_manager.cpp b/WebCore/khtml/xbl/xbl_binding_manager.cpp
new file mode 100644
index 0000000..b836340
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_binding_manager.cpp
@@ -0,0 +1,118 @@
+#include "qptrdict.h"
+#include "xml/dom_docimpl.h"
+#include "xml/dom_elementimpl.h"
+#include "rendering/render_style.h"
+#include "xbl_binding_manager.h"
+#include "xbl_binding.h"
+
+using DOM::DocumentImpl;
+using DOM::NodeImpl;
+using DOM::ElementImpl;
+using khtml::BindingURI;
+
+namespace XBL {
+
+XBLBindingManager::XBLBindingManager(DocumentImpl* doc)
+:m_document(doc), m_bindingChainTable(0)
+{
+}
+
+XBLBindingManager::~XBLBindingManager()
+{
+    if (m_bindingChainTable) {
+        m_bindingChainTable->setAutoDelete(true);
+        delete m_bindingChainTable;
+    }
+}
+
+XBLBindingChain* XBLBindingManager::getBindingChain(NodeImpl* node)
+{
+    if (!m_bindingChainTable)
+        return 0;
+    
+    return m_bindingChainTable->find(node);
+}
+
+void XBLBindingManager::setBindingChain(NodeImpl* node, XBLBindingChain* bindingChain)
+{
+    if (!m_bindingChainTable)
+        m_bindingChainTable = new QPtrDict<XBLBindingChain>;
+    
+    if (bindingChain)
+        m_bindingChainTable->replace(node, bindingChain);
+    else
+        m_bindingChainTable->remove(node);
+}
+
+bool XBLBindingManager::loadBindings(NodeImpl* node, BindingURI* bindingURIs, 
+                                     bool isStyleBinding, bool* resolveStyle)
+{
+    if (resolveStyle) *resolveStyle = false;
+    if (!node->isElementNode()) return true;
+    bool dirty = false;
+    XBLBindingChain* bindingChain = getBindingChain(node);
+    if (bindingChain && isStyleBinding) {
+        // Check to see if the binding is already installed.  If so, then we don't need
+        // to do anything.
+        XBLBindingChain* styleBindingChain = bindingChain->firstStyleBindingChain();
+        if (styleBindingChain) {
+            if (styleBindingChain->markedForDeath())
+                return false; // The old bindings haven't destroyed themselves/fired their destructors yet.
+            
+            // See if the URIs match.
+            BindingURI* currURI = bindingURIs;
+            XBLBindingChain* currBindingChain = styleBindingChain;
+            for ( ; currURI && currBindingChain;
+                  currURI = currURI->next(), currBindingChain = currBindingChain->nextChain()) {
+                if (currBindingChain->uri() != currURI->uri()) {
+                    styleBindingChain->markForDeath();
+                    return false;
+                }
+            }
+            if ((currURI && !currBindingChain) || (currBindingChain && !currURI)) {
+                styleBindingChain->markForDeath();
+                return false;
+            }
+            
+            return bindingChain->loaded();
+        }
+    }
+
+    bindingChain = getBindingChain(node);
+    ElementImpl* elt = static_cast<ElementImpl*>(node);
+    for (BindingURI* currURI = bindingURIs; currURI; currURI = currURI->next()) {
+        XBLBindingChain* newBindingChain = new XBLBindingChain(elt, currURI->uri(), isStyleBinding);
+        if (newBindingChain) {
+            if (bindingChain && isStyleBinding)
+                // Style bindings go on the end.  Regular bindings go on the front.
+                bindingChain->lastBindingChain()->insertBindingChain(newBindingChain);
+            else {
+                // Place on the front.
+                newBindingChain->insertBindingChain(bindingChain);
+                setBindingChain(node, newBindingChain); 
+            }
+            
+            dirty = true;
+        }
+        
+        bindingChain = newBindingChain;
+    }
+    
+    if (!bindingChain) return true; // We did nothing.
+    
+    // If the binding is completely loaded, then return true.  Otherwise return false.
+    bindingChain = getBindingChain(node);
+    bool loaded = bindingChain->loaded();
+    if (loaded && resolveStyle)
+        *resolveStyle = bindingChain->hasStylesheets();
+    return loaded;
+}
+
+void XBLBindingManager::checkLoadState(ElementImpl* elt)
+{
+    XBLBindingChain* chain = getBindingChain(elt);
+    if (chain && chain->loaded())
+        elt->setChanged();
+}
+
+}
\ No newline at end of file
diff --git a/WebCore/khtml/xbl/xbl_binding_manager.h b/WebCore/khtml/xbl/xbl_binding_manager.h
new file mode 100644
index 0000000..7f8a99b
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_binding_manager.h
@@ -0,0 +1,62 @@
+#include "qptrdict.h"
+
+namespace khtml {
+    class CachedXBLDocument;
+    class BindingURI;
+}
+
+namespace DOM {
+    class DocumentImpl;
+    class NodeImpl;
+    class ElementImpl;
+}
+
+namespace XBL {
+
+class XBLBindingChain;
+class XBLChildNodeList;
+    
+// This class handles all access to XBL bindings and XBL binding information.  It also handles the loading/installation of XBL
+// bindings.  In the comments below, the term "decorated DOM" is used to describe the final DOM that can be walked after all
+// bindings have been installed.
+class XBLBindingManager
+{
+public:
+    XBLBindingManager(DOM::DocumentImpl* doc);
+    ~XBLBindingManager();
+    
+    bool loadBindings(DOM::NodeImpl* node, khtml::BindingURI* bindingURIs, bool isStyleBinding, bool* resolveStyle);
+    void checkLoadState(DOM::ElementImpl* elt);
+    
+    XBLBindingChain* getBindingChain(DOM::NodeImpl* node);
+    void setBindingChain(DOM::NodeImpl* node, XBLBindingChain* binding);
+
+private:
+    // The document whose bindings we manage.
+    DOM::DocumentImpl* m_document;
+
+    // A mapping from a DOM::NodeImpl* to the XBL::XBLBindingChain* that is
+    // installed on that element.
+    QPtrDict<XBLBindingChain>* m_bindingChainTable;
+    
+    // A mapping from DOM::NodeImpl* to an XBLChildNodeListImpl*.  
+    // This list contains an accurate reflection of our *explicit* children (once intermingled with
+    // insertion points) in the decorated DOM.
+    QPtrDict<XBLChildNodeList>* m_explicitChildNodesTable;
+    
+    // A mapping from DOM::NodeImpl* to an XBLChildNodeListImpl*.  This list contains an accurate
+    // reflection of our *anonymous* children (if and only if they are
+    // intermingled with insertion points) in the decorated DOM.  This
+    // table is not used if no insertion points were defined directly
+    // underneath a <content> tag in a binding.  The NodeList from the
+    // binding's cloned <content> element is used instead as a performance optimization.
+    QPtrDict<XBLChildNodeList>* m_anonymousChildNodesTable;
+    
+    // A mapping from a DOM::NodeImpl* to a DOM::NodeImpl*.  Used to obtain the node's parent
+    // element in the decorated DOM.
+    QPtrDict<DOM::NodeImpl>* m_parentElementTable;
+    
+    // A mapping from 
+};
+
+}
diff --git a/WebCore/khtml/xbl/xbl_docimpl.cpp b/WebCore/khtml/xbl/xbl_docimpl.cpp
new file mode 100644
index 0000000..bdb55ff
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_docimpl.cpp
@@ -0,0 +1,37 @@
+#include "xbl_docimpl.h"
+#include "xbl_tokenizer.h"
+#include "xbl_protobinding.h"
+
+using DOM::DocumentImpl;
+
+namespace XBL {
+
+XBLDocumentImpl::XBLDocumentImpl()
+:DocumentImpl(0,0)
+{
+    m_prototypeBindingTable.setAutoDelete(true); // The prototype bindings will be deleted when the XBL document dies.
+}
+
+XBLDocumentImpl::~XBLDocumentImpl()
+{
+}
+
+XMLHandler* XBLDocumentImpl::createTokenHandler()
+{
+    return new XBLTokenHandler(docPtr());
+}
+
+void XBLDocumentImpl::setPrototypeBinding(const DOM::DOMString& id, XBLPrototypeBinding* binding)
+{
+    m_prototypeBindingTable.replace(id.string(), binding);
+}
+
+XBLPrototypeBinding* XBLDocumentImpl::prototypeBinding(const DOM::DOMString& id)
+{
+    if (id.length() == 0)
+        return 0;
+    
+    return m_prototypeBindingTable.find(id.string());
+}
+
+}
\ No newline at end of file
diff --git a/WebCore/khtml/xbl/xbl_docimpl.h b/WebCore/khtml/xbl/xbl_docimpl.h
new file mode 100644
index 0000000..4bdecd3
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_docimpl.h
@@ -0,0 +1,30 @@
+#include "qptrdict.h"
+#include "xml/dom_docimpl.h"
+
+namespace DOM {
+    class DOMString;
+}
+
+namespace XBL {
+    class XBLPrototypeBinding;
+    
+// This class represents an XBL document.  It subclasses XML documents and holds references to prototype bindings.
+// The DOM of an XBL document is optimized to avoid creating full-blown DOM elements for most sections of the various
+// bindings.  Custom prototype binding data structures are created instead.
+class XBLDocumentImpl: public DOM::DocumentImpl
+{
+public:
+    XBLDocumentImpl();
+    ~XBLDocumentImpl();
+    
+    virtual XMLHandler* createTokenHandler();
+
+    void setPrototypeBinding(const DOM::DOMString& id, XBLPrototypeBinding* binding);
+    XBLPrototypeBinding* prototypeBinding(const DOM::DOMString& id);
+    
+private:
+    // A mapping from URIs to bindings.  Used to look up specific prototype binding objects.
+    QDict<XBLPrototypeBinding> m_prototypeBindingTable;
+};
+
+}
diff --git a/WebCore/khtml/xbl/xbl_protobinding.cpp b/WebCore/khtml/xbl/xbl_protobinding.cpp
new file mode 100644
index 0000000..66a1a94
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_protobinding.cpp
@@ -0,0 +1,31 @@
+#include "xbl_protobinding.h"
+#include "xbl_docimpl.h"
+
+using DOM::DOMString;
+using DOM::ElementImpl;
+
+namespace XBL
+{
+
+XBLPrototypeBinding::XBLPrototypeBinding(const DOMString& id, ElementImpl* elt)
+:m_id(id), m_element(elt), m_handler(0)
+{
+    // Add ourselves to the document's prototype table.
+    document()->setPrototypeBinding(id, this);
+}
+
+void XBLPrototypeBinding::initialize()
+{
+}
+
+XBLDocumentImpl* XBLPrototypeBinding::document() const
+{
+    return static_cast<XBLDocumentImpl*>(m_element->getDocument());
+}
+
+void XBLPrototypeBinding::addResource(const DOMString& type, const DOMString& src)
+{
+    // FIXME: Implement!
+}
+
+}
\ No newline at end of file
diff --git a/WebCore/khtml/xbl/xbl_protobinding.h b/WebCore/khtml/xbl/xbl_protobinding.h
new file mode 100644
index 0000000..ffcc059
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_protobinding.h
@@ -0,0 +1,35 @@
+#include "dom/dom_string.h"
+
+namespace DOM
+{
+    class ElementImpl;
+    class DOMString;
+}
+
+namespace XBL
+{
+    class XBLDocumentImpl;
+    class XBLPrototypeHandler;
+    
+class XBLPrototypeBinding
+{
+public:
+    XBLPrototypeBinding(const DOM::DOMString& bindingID, DOM::ElementImpl* bindingElt);
+    void initialize(); // Called once the binding and all its child elements have been parsed.
+    
+    XBLDocumentImpl* document() const;
+    DOM::ElementImpl* element() const { return m_element; }
+    
+    void setHandler(XBLPrototypeHandler* handler) { m_handler = handler; }
+    XBLPrototypeHandler* handler() const { return m_handler; }
+    
+    void addResource(const DOM::DOMString& type, const DOM::DOMString& src);
+
+private:
+    DOM::DOMString m_id;
+    DOM::ElementImpl* m_element;
+    
+    XBLPrototypeHandler* m_handler; // Our event handlers (prototypes).
+};
+
+}
\ No newline at end of file
diff --git a/WebCore/khtml/xbl/xbl_protohandler.cpp b/WebCore/khtml/xbl/xbl_protohandler.cpp
new file mode 100644
index 0000000..379e74d
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_protohandler.cpp
@@ -0,0 +1,90 @@
+#include "qstringlist.h"
+#include "qstring.h"
+#include "xbl_protohandler.h"
+
+using DOM::DOMString;
+
+namespace XBL {
+
+const int XBLPrototypeHandler::shiftKey = (1<<1);
+const int XBLPrototypeHandler::altKey = (1<<2);
+const int XBLPrototypeHandler::ctrlKey = (1<<3);
+const int XBLPrototypeHandler::metaKey = (1<<4);
+const int XBLPrototypeHandler::allKeys = shiftKey | altKey | ctrlKey | metaKey;
+
+const int XBLPrototypeHandler::bubblingPhase = 0;
+const int XBLPrototypeHandler::capturingPhase = 1;
+const int XBLPrototypeHandler::targetPhase = 2;
+
+XBLPrototypeHandler::XBLPrototypeHandler(const DOMString& event,
+                                         const DOMString& phase,
+                                         const DOMString& action,
+                                         const DOMString& keycode,
+                                         const DOMString& charcode,
+                                         const DOMString& modifiers,
+                                         const DOMString& button,
+                                         const DOMString& clickcount,
+                                         const DOMString& preventdefault,
+                                         XBLPrototypeBinding* binding)
+:m_binding(binding), m_next(0), m_eventName(event), 
+ m_phase(bubblingPhase), m_preventDefault(false), m_keyMask(0), m_misc(0), m_button(-1), m_unused(0)
+{
+    if (event.isEmpty())
+        return;
+
+    if (phase == "capturing")
+        m_phase = capturingPhase;
+    else if (phase == "target")
+        m_phase = targetPhase;
+
+    if (!action.isEmpty())
+        m_handlerText = action;
+
+    if (!modifiers.isEmpty()) {
+        QStringList result = QStringList::split(",", modifiers.string());
+        for (QStringList::Iterator it = result.begin(); it != result.end(); ++it) {
+            QString modifier = (*it).stripWhiteSpace();
+            if (modifier == "shift")
+                m_keyMask |= shiftKey;
+            else if (modifier == "alt")
+                m_keyMask |= altKey;
+            else if (modifier == "control")
+                m_keyMask |= ctrlKey;
+            else if (modifier == "meta" || modifier == "accel" || modifier == "access")
+                m_keyMask |= metaKey; // FIXME: For Apple, accel is like meta, and access really has no equivalent.
+                                      // If/when KDE adopts this code, use the appropriate defaults for the
+                                      // platform (probably ctrl for accel and alt for access if they match Win32).
+        }
+    }
+
+    if (!charcode.isEmpty()) {
+        // Normalize the character based off case (and whether the shift key has to be down).
+        m_key = charcode;
+        if ((m_keyMask & shiftKey) != 0)
+            m_key = m_key.upper();
+        else
+            m_key = m_key.lower();
+         
+        // We have a charcode.
+        m_misc = 1;
+    }
+    else if (!keycode.isEmpty())
+        m_key = keycode;
+     
+    if (!clickcount.isEmpty())
+        m_misc = clickcount.toInt();
+    if (!button.isEmpty())
+        m_button = button.toInt();
+}
+
+XBLPrototypeHandler::~XBLPrototypeHandler()
+{
+    delete m_next;
+}
+
+void XBLPrototypeHandler::appendData(const QString& ch)
+{
+    m_handlerText += ch;
+}
+
+}
\ No newline at end of file
diff --git a/WebCore/khtml/xbl/xbl_protohandler.h b/WebCore/khtml/xbl/xbl_protohandler.h
new file mode 100644
index 0000000..10e553d
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_protohandler.h
@@ -0,0 +1,64 @@
+#include "dom/dom_string.h"
+
+namespace DOM
+{
+    class ElementImpl;
+    class DOMString;
+}
+
+namespace XBL
+{
+    class XBLPrototypeBinding;
+
+class XBLPrototypeHandler
+{
+public:
+    XBLPrototypeHandler(const DOM::DOMString& event,
+                        const DOM::DOMString& phase,
+                        const DOM::DOMString& action,
+                        const DOM::DOMString& keycode,
+                        const DOM::DOMString& charcode,
+                        const DOM::DOMString& modifiers,
+                        const DOM::DOMString& button,
+                        const DOM::DOMString& clickcount,
+                        const DOM::DOMString& preventdefault,
+                        XBLPrototypeBinding* binding);
+    ~XBLPrototypeHandler();
+    
+    void setNext(XBLPrototypeHandler* handler) { m_next = handler; }
+    XBLPrototypeHandler* next() const { return m_next; }
+    
+    void appendData(const QString& ch);
+    
+    static const int shiftKey;
+    static const int altKey;
+    static const int ctrlKey;
+    static const int metaKey;
+    static const int allKeys;
+    
+    static const int bubblingPhase;
+    static const int capturingPhase;
+    static const int targetPhase;
+    
+private:
+    DOM::DOMString m_handlerText; // The text for the event handler.
+    XBLPrototypeBinding* m_binding; // The binding that owns us.
+    XBLPrototypeHandler* m_next; // Our next event handler.
+
+    DOM::DOMString m_eventName; // The name of the event.
+
+    // The following values make up 32 bits.
+    int m_phase : 2;            // The phase (capturing, bubbling, target)
+    bool m_preventDefault : 1;  // Whether or not to preventDefault after executing the event handler.
+    int m_keyMask : 4;          // Which modifier keys this event handler expects to have down
+                                // in order to be matched.
+    int m_misc : 8;             // Miscellaneous extra information.  For key events,
+                                // stores whether or not we're a key code or char code.
+                                // For mouse events, stores the clickCount.
+    // The primary filter information for mouse/key events.
+    short m_button;             // For mouse events, stores the button info.
+    int m_unused: 1;
+    DOM::DOMString m_key;            // The keycode/charcode we want to match for key events
+};
+
+}
\ No newline at end of file
diff --git a/WebCore/khtml/xbl/xbl_protoimplementation.cpp b/WebCore/khtml/xbl/xbl_protoimplementation.cpp
new file mode 100644
index 0000000..49a6dd6
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_protoimplementation.cpp
@@ -0,0 +1,93 @@
+#include "xbl_protoimplementation.h"
+#include "xbl_protobinding.h"
+
+using DOM::DOMString;
+
+namespace XBL
+{
+
+XBLPrototypeImplementation::XBLPrototypeImplementation(const DOM::DOMString& name, XBLPrototypeBinding* binding)
+:m_name(name), m_binding(binding), m_member(0), m_compiled(false)
+{
+
+}
+
+
+XBLPrototypeMember::XBLPrototypeMember(const DOMString& name)
+:m_name(name), m_next(0)
+{
+}
+
+void XBLPrototypeMember::appendData(const DOM::DOMString& data)
+{
+    m_data += data;
+}
+
+XBLPrototypeMethod::XBLPrototypeMethod(const DOM::DOMString& name)
+:XBLPrototypeMember(name)
+{
+}
+
+bool XBLPrototypeMethod::isConstructor() const
+{
+    return false;
+}
+
+bool XBLPrototypeMethod::isDestructor() const
+{
+    return false;
+}
+
+void XBLPrototypeMethod::addParameter(const DOM::DOMString& name)
+{
+    XBLPrototypeParameter* last = 0;
+    for (XBLPrototypeParameter* curr = m_parameter; curr; curr = curr->next())
+        last = curr;
+    if (last)
+        m_parameter = new XBLPrototypeParameter(name);
+    else
+        last->setNext(new XBLPrototypeParameter(name));
+}
+
+XBLPrototypeConstructor::XBLPrototypeConstructor()
+:XBLPrototypeMethod("_constructor")
+{}
+
+bool XBLPrototypeConstructor::isConstructor() const
+{
+    return true;
+}
+
+XBLPrototypeDestructor::XBLPrototypeDestructor()
+:XBLPrototypeMethod("_destructor")
+{}
+
+bool XBLPrototypeDestructor::isDestructor() const
+{
+    return true;
+}
+
+XBLPrototypeField::XBLPrototypeField(const DOM::DOMString& name, bool readonly)
+:XBLPrototypeMember(name), m_readonly(readonly)
+{
+}
+
+XBLPrototypeProperty::XBLPrototypeProperty(const DOM::DOMString& name, bool readonly, 
+                                           const DOM::DOMString& onget,
+                                           const DOM::DOMString& onset)
+:XBLPrototypeMember(name), m_setter(onset), m_readonly(readonly)
+{
+    m_data = onget;
+}
+
+void XBLPrototypeProperty::appendGetterText(const DOM::DOMString& text)
+{
+    return appendData(text);
+}
+
+void XBLPrototypeProperty::appendSetterText(const DOM::DOMString& text)
+{
+    m_setter += text;
+}
+
+}
diff --git a/WebCore/khtml/xbl/xbl_protoimplementation.h b/WebCore/khtml/xbl/xbl_protoimplementation.h
new file mode 100644
index 0000000..6736e0b
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_protoimplementation.h
@@ -0,0 +1,113 @@
+namespace DOM {
+    class DOMString;
+}
+
+#include "dom/dom_string.h"
+
+namespace XBL
+{
+
+class XBLPrototypeBinding;
+
+class XBLPrototypeMember
+{
+public:
+    XBLPrototypeMember(const DOM::DOMString& name);
+    virtual ~XBLPrototypeMember() { delete m_next; }
+        
+    void appendData(const DOM::DOMString& data);
+        
+    void setNext(XBLPrototypeMember* next) { m_next = next; }
+    XBLPrototypeMember* next() const { return m_next; }
+        
+protected:
+    DOM::DOMString m_name;
+    DOM::DOMString m_data;
+    XBLPrototypeMember* m_next;
+};
+    
+class XBLPrototypeImplementation
+{
+public:
+    XBLPrototypeImplementation(const DOM::DOMString& name, XBLPrototypeBinding* binding);
+    ~XBLPrototypeImplementation() { delete m_member; }
+    
+    void setMember(XBLPrototypeMember* m) { m_member = m; }
+    
+private:
+    DOM::DOMString m_name;
+    XBLPrototypeBinding* m_binding;
+    XBLPrototypeMember* m_member;
+    bool m_compiled;
+};
+
+class XBLPrototypeParameter
+{
+public:
+    XBLPrototypeParameter(const DOM::DOMString& name) :m_name(name), m_next(0) {}
+    ~XBLPrototypeParameter() { delete m_next; }
+    
+    XBLPrototypeParameter* next() const { return m_next; }
+    void setNext(XBLPrototypeParameter* next) { m_next = next; }
+
+private:
+    DOM::DOMString m_name;
+    XBLPrototypeParameter* m_next;
+};
+
+class XBLPrototypeMethod: public XBLPrototypeMember
+{
+public:
+    XBLPrototypeMethod(const DOM::DOMString& name);
+    virtual ~XBLPrototypeMethod() { delete m_parameter; }
+    
+    virtual bool isConstructor() const;
+    virtual bool isDestructor() const;
+    
+    void addParameter(const DOM::DOMString& name);
+    XBLPrototypeParameter* parameter() const { return m_parameter; }
+    
+private:
+    XBLPrototypeParameter* m_parameter;
+};
+
+class XBLPrototypeConstructor: public XBLPrototypeMethod
+{
+public:
+    XBLPrototypeConstructor();
+    virtual bool isConstructor() const;
+};
+
+class XBLPrototypeDestructor: public XBLPrototypeMethod
+{
+public:
+    XBLPrototypeDestructor();
+    virtual bool isDestructor() const;
+};
+
+class XBLPrototypeField : public XBLPrototypeMember
+{
+public:
+    XBLPrototypeField(const DOM::DOMString& name, bool readonly);
+    
+private:
+    bool m_readonly;
+};
+
+class XBLPrototypeProperty : public XBLPrototypeMember
+{
+public:
+    XBLPrototypeProperty(const DOM::DOMString& name, bool readonly, 
+                         const DOM::DOMString& onget,
+                         const DOM::DOMString& onset);
+    
+    void appendGetterText(const DOM::DOMString& text);
+    void appendSetterText(const DOM::DOMString& text);
+
+private:
+    DOM::DOMString m_setter;
+    bool m_readonly;
+};
+
+
+}
diff --git a/WebCore/khtml/xbl/xbl_tokenizer.cpp b/WebCore/khtml/xbl/xbl_tokenizer.cpp
new file mode 100644
index 0000000..64f314b
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_tokenizer.cpp
@@ -0,0 +1,414 @@
+#include "dom/dom_node.h"
+#include "xml/dom_elementimpl.h"
+#include "misc/htmlattrs.h"
+
+#include "xbl_tokenizer.h"
+#include "xbl_docimpl.h"
+#include "xbl_protobinding.h"
+#include "xbl_protohandler.h"
+#include "xbl_protoimplementation.h"
+
+using DOM::DocumentPtr;
+using DOM::ElementImpl;
+using DOM::Node;
+
+namespace XBL {
+
+const char xblNS[] = "http://www.mozilla.org/xbl";
+    
+XBLTokenHandler::XBLTokenHandler(DocumentPtr* doc)
+:   XMLHandler(doc, 0),
+    m_state(eXBL_InDocument),
+    m_secondaryState(eXBL_None),
+    m_binding(0),
+    m_handler(0),
+    m_implementation(0),
+    m_member(0),
+    m_property(0),
+    m_method(0),
+    m_field(0)
+{
+}
+
+XBLTokenHandler::~XBLTokenHandler()
+{
+}
+
+XBLDocumentImpl* XBLTokenHandler::xblDocument() const
+{
+    return static_cast<XBLDocumentImpl*>(m_doc->document());
+}
+
+bool XBLTokenHandler::startElement(const QString& namespaceURI, const QString& localName, const QString& qName, 
+                                   const QXmlAttributes& attrs)
+{
+    if (namespaceURI == xblNS) {
+        if (localName == "binding")
+            m_state = eXBL_InBinding;
+        else if (localName == "content")
+            m_state = eXBL_InContent;
+        else if (localName == "handlers") {
+            m_state = eXBL_InHandlers;
+            return true;
+        }
+        else if (localName == "handler") {
+            m_secondaryState = eXBL_InHandler;
+            createHandler(attrs);
+            return true;
+        }
+        else if (localName == "resources") {
+            m_state = eXBL_InResources;
+            return true;
+        }
+        else if (m_state == eXBL_InResources) {
+            if (localName == "stylesheet" || localName == "image")
+                createResource(localName, attrs);
+            return true;
+        }
+        else if (localName == "implementation") {
+            m_state = eXBL_InImplementation;
+            createImplementation(attrs);
+            return true;
+        }
+        else if (m_state == eXBL_InImplementation) {
+            if (localName == "constructor") {
+                m_secondaryState = eXBL_InConstructor;
+                createConstructor();
+            }
+            else if (localName == "destructor") {
+                m_secondaryState = eXBL_InDestructor;
+                createDestructor();
+            }
+            else if (localName == "field") {
+                m_secondaryState = eXBL_InField;
+                createField(attrs);
+            }
+            else if (localName == "property") {
+                m_secondaryState = eXBL_InProperty;
+                createProperty(attrs);
+            }
+            else if (localName == "getter")
+                m_secondaryState = eXBL_InGetter;
+            else if (localName == "setter")
+                m_secondaryState = eXBL_InSetter;
+            else if (localName == "method") {
+                m_secondaryState = eXBL_InMethod;
+                createMethod(attrs);
+            }
+            else if (localName == "parameter")
+                createParameter(attrs);
+            else if (localName == "body")
+                m_secondaryState = eXBL_InBody;
+            
+            return true; // Ignore everything we encounter inside an <implementation> block.
+        }        
+    }
+    
+    if (!XMLHandler::startElement(namespaceURI, localName, qName, attrs))
+        return false;
+    
+    // Create our binding if it doesn't exist already.
+    if (m_state == eXBL_InBinding && !m_binding)
+        createBinding();
+    
+    return true;
+}
+
+bool XBLTokenHandler::endElement(const QString& namespaceURI, const QString& localName, const QString& qName)
+{
+    if (m_state != eXBL_InDocument) {
+        if (namespaceURI == xblNS) {
+            if (m_state == eXBL_InContent && localName == "content")
+                m_state = eXBL_InBinding;
+            else if (m_state == eXBL_InHandlers) {
+                if (localName == "handlers") {
+                    m_state = eXBL_InBinding;
+                    m_handler = 0;
+                }
+                else if (localName == "handler")
+                    m_secondaryState = eXBL_None;
+                return true;
+            }
+            else if (m_state == eXBL_InResources) {
+                if (localName == "resources")
+                    m_state = eXBL_InBinding;
+                return true;
+            }
+            else if (m_state == eXBL_InImplementation) {
+                if (localName == "implementation")
+                    m_state = eXBL_InBinding;
+                else if (localName == "property") {
+                    m_secondaryState = eXBL_None;
+                    m_property = 0;
+                }
+                else if (localName == "method") {
+                    m_secondaryState = eXBL_None;
+                    m_method = 0;
+                }
+                else if (localName == "field") {
+                    m_secondaryState = eXBL_None;
+                    m_field = 0;
+                }
+                else if (localName == "constructor" ||
+                         localName == "destructor")
+                    m_secondaryState = eXBL_None;
+                else if (localName == "getter" ||
+                         localName == "setter")
+                    m_secondaryState = eXBL_InProperty;
+                else if (localName == "parameter" ||
+                         localName == "body")
+                    m_secondaryState = eXBL_InMethod;
+                return true;
+            }
+            
+            if (!XMLHandler::endElement(namespaceURI, localName, qName))
+                return false;
+            
+            if (m_state == eXBL_InImplementation && localName == "implementation")
+                m_state = eXBL_InBinding;
+            else if (m_state == eXBL_InBinding && localName == "binding") {
+                m_state = eXBL_InDocument;
+                m_binding->initialize();
+                m_binding = 0;
+            }
+            return true;
+        }
+    }
+    
+    return XMLHandler::endElement(namespaceURI, localName, qName);
+}
+
+bool XBLTokenHandler::characters(const QString& text)
+{
+    if (text.length() == 0)
+        return true;
+    
+    if (m_state == eXBL_InHandlers) {
+        // Get the text and add it to the event handler.
+        if (m_secondaryState == eXBL_InHandler)
+            m_handler->appendData(text);
+        return true;
+    }
+    else if (m_state == eXBL_InImplementation) {
+        if (m_secondaryState == eXBL_InConstructor || m_secondaryState == eXBL_InDestructor || m_secondaryState == eXBL_InBody) {
+            if (m_method)
+                m_method->appendData(text);
+        }
+        else if (m_secondaryState == eXBL_InGetter)
+            m_property->appendGetterText(text);
+        else if (m_secondaryState == eXBL_InSetter)
+            m_property->appendSetterText(text);
+        else if (m_secondaryState == eXBL_InField)
+            m_field->appendData(text);
+        return true;
+    }
+
+    // XBL files munch all whitespace, except when inside an anonymous content template (<content>).
+    if (m_state != eXBL_InContent) {
+        uint l = text.length();
+        uint i;
+        for (i = 0; i < l; i++) {
+	    if (!isspace(text[i].unicode()))
+	        break;
+	}
+        if (i == l)
+            return true;
+    }
+    
+    return XMLHandler::characters(text);
+}
+
+void XBLTokenHandler::createBinding()
+{
+    if (!m_currentNode || m_currentNode->nodeType() != Node::ELEMENT_NODE)
+        return;
+    
+    ElementImpl* elt = static_cast<ElementImpl*>(m_currentNode);
+    DOMString id = elt->getAttribute(ATTR_ID);
+    if (!id.isEmpty()) {
+        m_binding = new XBLPrototypeBinding(id, elt);
+        int exCode;
+        elt->removeAttribute(ATTR_ID, exCode);
+    }
+}
+
+void XBLTokenHandler::createHandler(const QXmlAttributes& attrs)
+{
+    DOMString event;
+    DOMString modifiers;
+    DOMString button;
+    DOMString clickcount;
+    DOMString keycode;
+    DOMString charcode;
+    DOMString phase;
+    DOMString action;
+    DOMString preventdefault;
+    
+    int i;
+    for (i = 0; i < attrs.length(); i++) {
+        if (attrs.uri(i).length() > 0)
+            continue; // Only care about attributes with no namespace.
+        
+        if (attrs.qName(i) == "event")
+            event = attrs.value(i);
+        else if (attrs.qName(i) == "modifiers")
+            modifiers = attrs.value(i);
+        else if (attrs.qName(i) == "button")
+            button = attrs.value(i);
+        else if (attrs.qName(i) == "clickcount")
+            clickcount = attrs.value(i);
+        else if (attrs.qName(i) == "keycode")
+            keycode = attrs.value(i);
+        else if (attrs.qName(i) == "key" || attrs.qName(i) == "charcode")
+            charcode = attrs.value(i);
+        else if (attrs.qName(i) == "phase")
+            phase = attrs.value(i);
+        else if (attrs.qName(i) == "action")
+            action = attrs.value(i);
+        else if (attrs.qName(i) == "preventdefault")
+            preventdefault = attrs.value(i);
+    }
+    
+    XBLPrototypeHandler* newHandler = new XBLPrototypeHandler(event, phase, action, keycode, 
+                                                              charcode, modifiers, button,
+                                                              clickcount, preventdefault, m_binding);
+    if (newHandler) {
+        // Add this handler to our chain of handlers.
+        if (m_handler)
+            m_handler->setNext(newHandler); // Already have a chain. Just append to the end.
+        else
+            m_binding->setHandler(newHandler); // We're the first handler in the chain.
+        m_handler = newHandler; // Adjust our m_handler pointer to point to the new last handler in the chain.
+    }
+}
+
+void XBLTokenHandler::createResource(const QString& localName, const QXmlAttributes& attrs)
+{
+    if (!m_binding)
+        return;
+    
+    for (int i = 0; i < attrs.length(); i++) {
+        if (attrs.uri(i).length() > 0)
+            continue;
+        
+        if (attrs.qName(i) == "src") {
+            m_binding->addResource(localName, attrs.value(i));
+            break;
+        }
+    }
+}
+
+void XBLTokenHandler::createImplementation(const QXmlAttributes& attrs)
+{
+    m_implementation = 0;
+    m_member = 0;
+    
+    if (!m_binding)
+        return;
+    
+    DOMString name;    
+    for (int i = 0; i < attrs.length(); i++) {
+        if (attrs.uri(i).length() > 0)
+            continue;
+        
+        if (attrs.qName(i) == "name")
+            name = attrs.value(i);
+        else if (attrs.qName(i) == "implements") {
+            // FIXME: If we implement any sort of interface language binding, then we can parse the list of
+            // implemented interfaces here.
+            // m_binding->constructInterfaceTable(attrs.value(i));
+        }
+    }
+    
+    m_implementation = new XBLPrototypeImplementation(name, m_binding);
+}
+
+void XBLTokenHandler::addMember(XBLPrototypeMember* member)
+{
+    if (m_member)
+        m_member->setNext(member);
+    else
+        m_implementation->setMember(member);
+    m_member = member;
+}
+
+void XBLTokenHandler::createConstructor()
+{
+    m_method = new XBLPrototypeConstructor();
+    addMember(m_method);
+}
+
+void XBLTokenHandler::createDestructor()
+{
+    m_method = new XBLPrototypeDestructor();
+    addMember(m_method);
+}
+
+void XBLTokenHandler::createField(const QXmlAttributes& attrs)
+{
+    DOMString name;
+    bool readonly = false;
+    for (int i = 0; i < attrs.length(); i++) {
+        if (attrs.uri(i).length() > 0)
+            continue;
+        if (attrs.qName(i) == "name")
+            name = attrs.value(i);
+        else if (attrs.qName(i) == "readonly")
+            readonly = !(strcasecmp(attrs.value(i), "true"));
+    }
+    
+    m_field = new XBLPrototypeField(name, readonly);
+    addMember(m_field);
+}
+
+void XBLTokenHandler::createProperty(const QXmlAttributes& attrs)
+{
+    DOMString name, onget, onset;
+    bool readonly = false;
+    for (int i = 0; i < attrs.length(); i++) {
+        if (attrs.uri(i).length() > 0)
+            continue;
+        if (attrs.qName(i) == "name")
+            name = attrs.value(i);
+        else if (attrs.qName(i) == "readonly")
+            readonly = !(strcasecmp(attrs.value(i), "true"));
+        else if (attrs.qName(i) == "onget")
+            onget = attrs.value(i);
+        else if (attrs.qName(i) == "onset")
+            onset = attrs.value(i);
+    }
+    
+    m_property = new XBLPrototypeProperty(name, readonly, onget, onset);
+    addMember(m_property);
+}
+
+void XBLTokenHandler::createMethod(const QXmlAttributes& attrs)
+{
+    DOMString name;
+    for (int i = 0; i < attrs.length(); i++) {
+        if (attrs.uri(i).length() > 0)
+            continue;
+        if (attrs.qName(i) == "name")
+            name = attrs.value(i);
+    }
+    
+    m_method = new XBLPrototypeMethod(name);
+    addMember(m_method);
+}
+
+void XBLTokenHandler::createParameter(const QXmlAttributes& attrs)
+{
+    if (!m_method) return;
+
+    for (int i = 0; i < attrs.length(); i++) {
+        if (attrs.uri(i).length() > 0)
+            continue;
+        
+        if (attrs.qName(i) == "name") {
+            m_method->addParameter(attrs.value(i));
+            break;
+        }
+    }
+}
+
+}
diff --git a/WebCore/khtml/xbl/xbl_tokenizer.h b/WebCore/khtml/xbl/xbl_tokenizer.h
new file mode 100644
index 0000000..ea97a41
--- /dev/null
+++ b/WebCore/khtml/xbl/xbl_tokenizer.h
@@ -0,0 +1,83 @@
+#include "xml/xml_tokenizer.h"
+
+namespace XBL {
+
+class XBLPrototypeBinding;
+class XBLPrototypeHandler;
+class XBLPrototypeImplementation;
+class XBLPrototypeMember;
+class XBLPrototypeMethod;
+class XBLPrototypeParameter;
+class XBLPrototypeProperty;
+class XBLPrototypeField;
+class XBLPrototypeConstructor;
+class XBLPrototypeDestructor;
+class XBLDocument;
+
+// This class is used to handle tokens returned from an XML parser for the purpose of building the
+// custom data structures required by an XBL document.
+class XBLTokenHandler: public XMLHandler
+{
+typedef enum {
+    eXBL_InDocument,
+    eXBL_InBinding,
+    eXBL_InResources,
+    eXBL_InImplementation,
+    eXBL_InHandlers,
+    eXBL_InContent
+} XBLPrimaryState;
+
+typedef enum {
+    eXBL_None,
+    eXBL_InHandler,
+    eXBL_InMethod,
+    eXBL_InProperty,
+    eXBL_InField,
+    eXBL_InBody,
+    eXBL_InGetter,
+    eXBL_InSetter,
+    eXBL_InConstructor,
+    eXBL_InDestructor
+} XBLSecondaryState;
+
+public:
+    XBLTokenHandler(DOM::DocumentPtr *_doc);
+    ~XBLTokenHandler();
+    
+    XBLDocumentImpl* xblDocument() const;
+    
+    // Overrides from XMLTokenizer
+    bool startElement(const QString& namespaceURI, const QString& localName, const QString& qName, 
+                      const QXmlAttributes& attrs);
+    bool endElement(const QString& namespaceURI, const QString& localName, const QString& qName);
+    bool characters(const QString& ch);
+
+protected:
+    // Helper methods.
+    void createBinding();
+    void createHandler(const QXmlAttributes& attrs);
+    void createResource(const QString& localName, const QXmlAttributes& attrs);
+    void createImplementation(const QXmlAttributes& attrs);
+    void createConstructor();
+    void createDestructor();
+    void createField(const QXmlAttributes& attrs);
+    void createProperty(const QXmlAttributes& attrs);
+    void createMethod(const QXmlAttributes& attrs);
+    void createParameter(const QXmlAttributes& attrs);
+
+    void addMember(XBLPrototypeMember* member);
+
+private:
+    XBLPrimaryState m_state;
+    XBLSecondaryState m_secondaryState;
+    
+    XBLPrototypeBinding* m_binding;
+    XBLPrototypeHandler* m_handler;
+    XBLPrototypeImplementation* m_implementation;
+    XBLPrototypeMember* m_member;
+    XBLPrototypeProperty* m_property;
+    XBLPrototypeMethod* m_method;
+    XBLPrototypeField* m_field;
+};
+
+}
diff --git a/WebCore/khtml/xml/dom_docimpl.cpp b/WebCore/khtml/xml/dom_docimpl.cpp
index 7048776..0c59213 100644
--- a/WebCore/khtml/xml/dom_docimpl.cpp
+++ b/WebCore/khtml/xml/dom_docimpl.cpp
@@ -72,6 +72,11 @@
 
 #include <kio/job.h>
 
+#ifndef KHTML_NO_XBL
+#include "xbl/xbl_binding_manager.h"
+using XBL::XBLBindingManager;
+#endif
+
 #if APPLE_CHANGES
 #include "KWQAccObjectCache.h"
 #endif
@@ -227,7 +232,10 @@ QPtrList<DocumentImpl> * DocumentImpl::changedDocuments = 0;
 // KHTMLView might be 0
 DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v)
     : NodeBaseImpl( new DocumentPtr() )
-    , m_imageLoadEventTimer(0)
+      , m_imageLoadEventTimer(0)
+#ifndef KHTML_NO_XBL
+      , m_bindingManager(new XBLBindingManager(this))
+#endif
 #if APPLE_CHANGES
     , m_finishedParsing(this, SIGNAL(finishedParsing()))
     , m_inPageCache(false), m_savedRenderer(0)
@@ -271,7 +279,8 @@ DocumentImpl::DocumentImpl(DOMImplementationImpl *_implementation, KHTMLView *v)
     m_doctype->ref();
 
     m_implementation = _implementation;
-    m_implementation->ref();
+    if (m_implementation)
+        m_implementation->ref();
     pMode = Strict;
     hMode = XHtml;
     m_textColor = Qt::black;
@@ -332,7 +341,8 @@ DocumentImpl::~DocumentImpl()
     if (m_elemSheet )  m_elemSheet->deref();
     if (m_doctype)
         m_doctype->deref();
-    m_implementation->deref();
+    if (m_implementation)
+        m_implementation->deref();
     delete m_paintDeviceMetrics;
 
     if (m_elementNames) {
@@ -361,6 +371,10 @@ DocumentImpl::~DocumentImpl()
         m_renderArena = 0;
     }
 
+#ifndef KHTML_NO_XBL
+    delete m_bindingManager;
+#endif
+
 #if APPLE_CHANGES
     if (m_accCache){
         delete m_accCache;
@@ -1187,6 +1201,11 @@ Tokenizer *DocumentImpl::createTokenizer()
     return new XMLTokenizer(docPtr(),m_view);
 }
 
+XMLHandler* DocumentImpl::createTokenHandler()
+{
+    return new XMLHandler(docPtr(), m_view);
+}
+
 void DocumentImpl::setPaintDevice( QPaintDevice *dev )
 {
     if (m_paintDevice == dev) {
@@ -2680,7 +2699,8 @@ DocumentTypeImpl::DocumentTypeImpl(DOMImplementationImpl *implementation, Docume
     : NodeImpl(doc), m_implementation(implementation),
       m_qualifiedName(qualifiedName), m_publicId(publicId), m_systemId(systemId)
 {
-    m_implementation->ref();
+    if (m_implementation)
+        m_implementation->ref();
 
     m_entities = 0;
     m_notations = 0;
@@ -2691,7 +2711,8 @@ DocumentTypeImpl::DocumentTypeImpl(DOMImplementationImpl *implementation, Docume
 
 DocumentTypeImpl::~DocumentTypeImpl()
 {
-    m_implementation->deref();
+    if (m_implementation)
+        m_implementation->deref();
     if (m_entities)
         m_entities->deref();
     if (m_notations)
diff --git a/WebCore/khtml/xml/dom_docimpl.h b/WebCore/khtml/xml/dom_docimpl.h
index 7ce8e0f..3836a25 100644
--- a/WebCore/khtml/xml/dom_docimpl.h
+++ b/WebCore/khtml/xml/dom_docimpl.h
@@ -48,6 +48,7 @@ class QPaintDeviceMetrics;
 class KHTMLView;
 class KHTMLPart;
 class Tokenizer;
+class XMLHandler;
 class RenderArena;
 
 #if APPLE_CHANGES
@@ -61,8 +62,13 @@ namespace khtml {
     class RenderImage;
 }
 
-namespace DOM {
+#ifndef KHTML_NO_XBL
+namespace XBL {
+    class XBLBindingManager;
+}
+#endif
 
+namespace DOM {
     class AbstractViewImpl;
     class AttrImpl;
     class CDATASectionImpl;
@@ -291,7 +297,8 @@ public:
     CSSStyleSheetImpl* elementSheet();
     virtual Tokenizer *createTokenizer();
     Tokenizer *tokenizer() { return m_tokenizer; }
-
+    virtual XMLHandler* createTokenHandler();
+    
     QPaintDeviceMetrics *paintDeviceMetrics() { return m_paintDeviceMetrics; }
     QPaintDevice *paintDevice() const { return m_paintDevice; }
     void setPaintDevice( QPaintDevice *dev );
@@ -472,6 +479,11 @@ public:
 
     DOMString toString() const;
     
+#ifndef KHTML_NO_XBL
+    // XBL methods
+    XBL::XBLBindingManager* bindingManager() const { return m_bindingManager; }
+#endif
+
 signals:
     void finishedParsing();
 
@@ -566,6 +578,10 @@ protected:
     bool m_processingLoadEvent;
     QTime m_startTime;
 
+#ifndef KHTML_NO_XBL
+    XBL::XBLBindingManager* m_bindingManager; // The access point through which documents and elements communicate with XBL.
+#endif
+    
 #if APPLE_CHANGES
 public:
     KWQSignal m_finishedParsing;
diff --git a/WebCore/khtml/xml/dom_elementimpl.cpp b/WebCore/khtml/xml/dom_elementimpl.cpp
index 33c8cd5..563153e 100644
--- a/WebCore/khtml/xml/dom_elementimpl.cpp
+++ b/WebCore/khtml/xml/dom_elementimpl.cpp
@@ -240,6 +240,15 @@ DOMString ElementImpl::getAttribute(NodeImpl::Id id) const
     return defattr->val();
 }
 
+DOMString ElementImpl::getAttributeNS(const DOMString &namespaceURI,
+                                      const DOMString &localName) const
+{
+    NodeImpl::Id id = getDocument()->attrId(namespaceURI.implementation(),
+                                            localName.implementation(), true);
+    if (!id) return DOMString();
+    return getAttribute(id);
+}
+
 void ElementImpl::setAttribute(NodeImpl::Id id, DOMStringImpl* value, int &exceptioncode )
 {
     // allocate attributemap if necessary
@@ -464,14 +473,10 @@ bool ElementImpl::childAllowed( NodeImpl *newChild )
     if (!childTypeAllowed(newChild->nodeType()))
         return false;
 
-    // ### check xml element allowedness according to DTD
-
-    // If either this node or the other node is an XML element node, allow regardless (we don't do DTD checks for XML
-    // yet)
-    if (isXMLElementNode() || newChild->isXMLElementNode())
-	return true;
-    else
-	return checkChild(id(), newChild->id());
+    // For XML documents, we are non-validating and do not check against a DTD, even for HTML elements.
+    if (getDocument()->isHTMLDocument())
+        return checkChild(id(), newChild->id());
+    return true;
 }
 
 bool ElementImpl::childTypeAllowed( unsigned short type )
diff --git a/WebCore/khtml/xml/dom_elementimpl.h b/WebCore/khtml/xml/dom_elementimpl.h
index ac89f15..9ef4c67 100644
--- a/WebCore/khtml/xml/dom_elementimpl.h
+++ b/WebCore/khtml/xml/dom_elementimpl.h
@@ -162,6 +162,9 @@ public:
     ~ElementImpl();
 
     DOMString getAttribute( NodeImpl::Id id ) const;
+    DOMString getAttribute(const DOMString& localName) const { return getAttributeNS(QString::null, localName); }
+    DOMString getAttributeNS(const DOMString &namespaceURI,
+                             const DOMString &localName) const;
     void setAttribute( NodeImpl::Id id, DOMStringImpl* value, int &exceptioncode );
     void removeAttribute( NodeImpl::Id id, int &exceptioncode );
 
diff --git a/WebCore/khtml/xml/dom_nodeimpl.cpp b/WebCore/khtml/xml/dom_nodeimpl.cpp
index 17d0bff..764d408 100644
--- a/WebCore/khtml/xml/dom_nodeimpl.cpp
+++ b/WebCore/khtml/xml/dom_nodeimpl.cpp
@@ -43,6 +43,9 @@
 #include "khtmlview.h"
 #include "khtml_part.h"
 
+#ifndef KHTML_NO_XBL
+#include "xbl/xbl_binding_manager.h"
+#endif
 
 using namespace DOM;
 using namespace khtml;
@@ -1245,7 +1248,17 @@ void NodeImpl::createRendererIfNeeded()
     if (parentRenderer && parentRenderer->canHaveChildren()) {
         RenderStyle *style = styleForRenderer(parentRenderer);
         style->ref();
+#ifndef KHTML_NO_XBL
+        bool resolveStyle = false;
+        if (getDocument()->bindingManager()->loadBindings(this, style->bindingURIs(), true, &resolveStyle) && 
+            rendererIsNeeded(style)) {
+            if (resolveStyle) {
+                style->deref();
+                style = styleForRenderer(parentRenderer);
+            }
+#else
         if (rendererIsNeeded(style)) {
+#endif
             m_render = createRenderer(getDocument()->renderArena(), style);
             m_render->setStyle(style);
             parentRenderer->addChild(m_render, nextRenderer());
diff --git a/WebCore/khtml/xml/xml_tokenizer.cpp b/WebCore/khtml/xml/xml_tokenizer.cpp
index 29a3e11..016c829 100644
--- a/WebCore/khtml/xml/xml_tokenizer.cpp
+++ b/WebCore/khtml/xml/xml_tokenizer.cpp
@@ -40,8 +40,10 @@
 using namespace DOM;
 using namespace khtml;
 
+const int maxErrors = 25;
+
 XMLHandler::XMLHandler(DocumentPtr *_doc, KHTMLView *_view)
-    : errorLine(0)
+    : errorLine(0), m_errorCount(0)
 {
     m_doc = _doc;
     if ( m_doc ) m_doc->ref();
@@ -66,6 +68,7 @@ bool XMLHandler::startDocument()
 {
     // at the beginning of parsing: do some initialization
     errorProt = "";
+    m_errorCount = 0;
     state = StateInit;
 
     return true;
@@ -74,6 +77,8 @@ bool XMLHandler::startDocument()
 
 bool XMLHandler::startElement( const QString& namespaceURI, const QString& /*localName*/, const QString& qName, const QXmlAttributes& atts )
 {
+    if (m_errorCount) return true;
+    
     if (m_currentNode->nodeType() == Node::TEXT_NODE)
         exitText();
 
@@ -84,6 +89,7 @@ bool XMLHandler::startElement( const QString& namespaceURI, const QString& /*loc
 
     int i;
     for (i = 0; i < atts.length(); i++) {
+        // FIXME: qualified name not supported for attributes! The prefix has been lost.
         DOMString uri(atts.uri(i));
         DOMString ln(atts.localName(i));
         DOMString val(atts.value(i));
@@ -129,6 +135,8 @@ bool XMLHandler::startElement( const QString& namespaceURI, const QString& /*loc
 
 bool XMLHandler::endElement( const QString& /*namespaceURI*/, const QString& /*localName*/, const QString& /*qName*/ )
 {
+    if (m_errorCount) return true;
+    
     if (m_currentNode->nodeType() == Node::TEXT_NODE)
         exitText();
     if (m_currentNode->parentNode() != 0) {
@@ -145,6 +153,8 @@ bool XMLHandler::endElement( const QString& /*namespaceURI*/, const QString& /*l
 
 bool XMLHandler::startCDATA()
 {
+    if (m_errorCount) return true;
+    
     if (m_currentNode->nodeType() == Node::TEXT_NODE)
         exitText();
 
@@ -164,6 +174,8 @@ bool XMLHandler::startCDATA()
 
 bool XMLHandler::endCDATA()
 {
+    if (m_errorCount) return true;
+    
     if (m_currentNode->parentNode() != 0)
         m_currentNode = m_currentNode->parentNode();
     return true;
@@ -171,6 +183,8 @@ bool XMLHandler::endCDATA()
 
 bool XMLHandler::characters( const QString& ch )
 {
+    if (m_errorCount) return true;
+    
     if (m_currentNode->nodeType() == Node::TEXT_NODE ||
         m_currentNode->nodeType() == Node::CDATA_SECTION_NODE ||
         enterText()) {
@@ -187,6 +201,8 @@ bool XMLHandler::characters( const QString& ch )
 
 bool XMLHandler::comment(const QString & ch)
 {
+    if (m_errorCount) return true;
+    
     if (m_currentNode->nodeType() == Node::TEXT_NODE)
         exitText();
     // ### handle exceptions
@@ -196,6 +212,8 @@ bool XMLHandler::comment(const QString & ch)
 
 bool XMLHandler::processingInstruction(const QString &target, const QString &data)
 {
+    if (m_errorCount) return true;
+    
     if (m_currentNode->nodeType() == Node::TEXT_NODE)
         exitText();
     // ### handle exceptions
@@ -219,14 +237,53 @@ QString XMLHandler::errorString()
 #endif
 }
 
+bool XMLHandler::warning( const QXmlParseException& exception )
+{
+#if APPLE_CHANGES
+    errorProt += QString("warning on line %2 at column %3: %1")
+#else
+    errorProt += i18n( "warning: %1 in line %2, column %3\n" )
+#endif
+        .arg( exception.message() )
+        .arg( exception.lineNumber() )
+        .arg( exception.columnNumber() );
+    
+    errorLine = exception.lineNumber();
+    errorCol = exception.columnNumber();
+    
+    return true;
+}
+
+bool XMLHandler::error( const QXmlParseException& exception )
+{
+    if (m_errorCount >= maxErrors) return true;
+    
+    if (errorLine == exception.lineNumber() && errorCol == exception.columnNumber())
+        return true; // Only report 1 error for any given line/col position to reduce noise.
+    
+    m_errorCount++;
+    
+#if APPLE_CHANGES
+    errorProt += QString("error on line %2 at column %3: %1")
+#else
+    errorProt += i18n( "error: %1 in line %2, column %3\n" )
+#endif
+        .arg( exception.message() )
+        .arg( exception.lineNumber() )
+        .arg( exception.columnNumber() );
+    
+    errorLine = exception.lineNumber();
+    errorCol = exception.columnNumber();
+    
+    return true;
+}
 
 bool XMLHandler::fatalError( const QXmlParseException& exception )
 {
 #if APPLE_CHANGES
-    // FIXME: Does the user ever see this?
-    errorProt += QString("fatal parsing error: %1 in line %2, column %3")
+    errorProt += QString("error on line %2 at column %3: %1")
 #else
-    errorProt += i18n( "fatal parsing error: %1 in line %2, column %3" )
+    errorProt += i18n( "fatal error: %1 in line %2, column %3\n" )
 #endif
         .arg( exception.message() )
         .arg( exception.lineNumber() )
@@ -343,85 +400,42 @@ void XMLTokenizer::end()
 void XMLTokenizer::finish()
 {
     // parse xml file
-    XMLHandler handler(m_doc,m_view);
+    XMLHandler* handler = m_doc->document()->createTokenHandler();
     QXmlInputSource source;
     source.setData(m_xmlCode);
     QXmlSimpleReader reader;
-    reader.setContentHandler( &handler );
-    reader.setLexicalHandler( &handler );
-    reader.setErrorHandler( &handler );
-    reader.setDeclHandler( &handler );
-    reader.setDTDHandler( &handler );
+    reader.setContentHandler( handler );
+    reader.setLexicalHandler( handler );
+    reader.setErrorHandler( handler );
+    reader.setDeclHandler( handler );
+    reader.setDTDHandler( handler );
     bool ok = reader.parse( source );
 
     if (!ok) {
-        // An error occurred during parsing of the code. Display an error page to the user (the DOM
-        // tree is created manually and includes an excerpt from the code where the error is located)
-
-        // ### for multiple error messages, display the code for each (can this happen?)
-
-        // Clear the document
-        int exceptioncode = 0;
-        while (m_doc->document()->hasChildNodes())
-            static_cast<NodeImpl*>(m_doc->document())->removeChild(m_doc->document()->firstChild(),exceptioncode);
-
-        QString line;
-        QString errorLocPtr;
-        if (handler.errorLine) {
-            QTextIStream stream(&m_xmlCode);
-            for (unsigned long lineno = 0; lineno < handler.errorLine-1; lineno++)
-                stream.readLine();
-            line = stream.readLine();
-    
-            for (unsigned long colno = 0; colno < handler.errorCol-1; colno++)
-                errorLocPtr += " ";
-            errorLocPtr += "^";
-        }
+        // One or more errors occurred during parsing of the code. Display an error block to the user above
+        // the normal content (the DOM tree is created manually and includes line/col info regarding 
+        // where the errors are located)
 
         // Create elements for display
+        int exceptioncode = 0;
         DocumentImpl *doc = m_doc->document();
-        NodeImpl *html = doc->createElementNS(XHTML_NAMESPACE,"html",exceptioncode);
-        NodeImpl   *body = doc->createElementNS(XHTML_NAMESPACE,"body",exceptioncode);
-        NodeImpl     *h1 = doc->createElementNS(XHTML_NAMESPACE,"h1",exceptioncode);
-#if APPLE_CHANGES
-        // FIXME: Is there some alternative to having this text hardcoded here?
-        NodeImpl       *headingText = doc->createTextNode("XML parsing error");
-#else
-        NodeImpl       *headingText = doc->createTextNode(i18n("XML parsing error"));
-#endif
-        NodeImpl     *errorText = doc->createTextNode(handler.errorProtocol());
-        NodeImpl     *hr = 0;
-        NodeImpl     *pre = 0;
-        NodeImpl       *lineText = 0;
-        NodeImpl       *errorLocText = 0;
-        if (!line.isNull()) {
-                      hr = doc->createElementNS(XHTML_NAMESPACE,"hr",exceptioncode);
-                      pre = doc->createElementNS(XHTML_NAMESPACE,"pre",exceptioncode);
-                        lineText = doc->createTextNode(line+"\n");
-                        errorLocText = doc->createTextNode(errorLocPtr);
-        }
-
-        // Construct DOM tree. We ignore exceptions as we assume they will not be thrown here (due to the
-        // fact we are using a known tag set)
-        doc->appendChild(html,exceptioncode);
-        html->appendChild(body,exceptioncode);
-        body->appendChild(h1,exceptioncode);
-        h1->appendChild(headingText,exceptioncode);
-        body->appendChild(errorText,exceptioncode);
-        if (hr)
-            body->appendChild(hr,exceptioncode);
-        if (pre) {
-            body->appendChild(pre,exceptioncode);
-            pre->appendChild(lineText,exceptioncode);
-            pre->appendChild(errorLocText,exceptioncode);
+        NodeImpl* root = doc->documentElement();
+        if (!root) {
+            root = doc->createElementNS(XHTML_NAMESPACE, "html", exceptioncode);
+            NodeImpl* body = doc->createElementNS(XHTML_NAMESPACE, "body", exceptioncode);
+            root->appendChild(body, exceptioncode);
+            doc->appendChild(root, exceptioncode);
+            root = body;
         }
 
-        // Close the renderers so that they update their display correctly
-        // ### this should not be necessary, but requires changes in the rendering code...
-        h1->closeRenderer();
-        if (pre)
-            pre->closeRenderer();
-        body->closeRenderer();
+        ElementImpl* reportDiv = doc->createElementNS(XHTML_NAMESPACE, "div", exceptioncode);
+        reportDiv->setAttribute(ATTR_STYLE, "white-space: pre; border: 2px solid #c77; padding: 0 1em 1em 1em; margin: 1em; background-color: #fdd; color: black");
+        NodeImpl* h3 = doc->createElementNS(XHTML_NAMESPACE, "h3", exceptioncode);
+        h3->appendChild(doc->createTextNode("This page contains the following errors:"), exceptioncode);
+        reportDiv->appendChild(h3, exceptioncode);
+        NodeImpl* textNode = doc->createTextNode(handler->errorProtocol());
+        reportDiv->appendChild(textNode, exceptioncode);
+        root->insertBefore(reportDiv, root->firstChild(), exceptioncode);
 
         m_doc->document()->recalcStyle( NodeImpl::Inherit );
         m_doc->document()->updateRendering();
@@ -436,6 +450,7 @@ void XMLTokenizer::finish()
         executeScripts();
     }
 
+    delete handler;
 }
 
 void XMLTokenizer::addScripts(NodeImpl *n)
diff --git a/WebCore/khtml/xml/xml_tokenizer.h b/WebCore/khtml/xml/xml_tokenizer.h
index 1d3ce8e..e0c2f2b 100644
--- a/WebCore/khtml/xml/xml_tokenizer.h
+++ b/WebCore/khtml/xml/xml_tokenizer.h
@@ -82,13 +82,16 @@ public:
 
     QString errorString();
 
+    bool error( const QXmlParseException& exception );
     bool fatalError( const QXmlParseException& exception );
+    bool warning( const QXmlParseException& exception );
+    
+    int errorLine;
+    int errorCol;
 
-    unsigned long errorLine;
-    unsigned long errorCol;
-
-private:
+protected:
     QString errorProt;
+    int m_errorCount;
     DOM::DocumentPtr *m_doc;
     KHTMLView *m_view;
     DOM::NodeImpl *m_currentNode;
diff --git a/WebCore/kwq/KWQXmlSimpleReader.h b/WebCore/kwq/KWQXmlSimpleReader.h
index c421a1a..644badd 100644
--- a/WebCore/kwq/KWQXmlSimpleReader.h
+++ b/WebCore/kwq/KWQXmlSimpleReader.h
@@ -153,6 +153,9 @@ public:
     bool parserStopped() const { return m_parserStopped; }
     void stopParsing();
 
+    bool sawError() const { return m_sawError; }
+    void recordError() { m_sawError = true; }
+    
     int lineNumber() const;
     int columnNumber() const;
     
@@ -163,8 +166,9 @@ private:
     QXmlErrorHandler *_errorHandler;
     QXmlLexicalHandler *_lexicalHandler;
     QPtrStack<KWQXmlNamespace> m_namespaceStack;
-    bool m_parserStopped;
     struct _xmlParserCtxt *m_context;
+    bool m_parserStopped : 1;
+    bool m_sawError : 1;
 };
 
 #endif
diff --git a/WebCore/kwq/KWQXmlSimpleReader.mm b/WebCore/kwq/KWQXmlSimpleReader.mm
index 8307453..2aa4a1a 100644
--- a/WebCore/kwq/KWQXmlSimpleReader.mm
+++ b/WebCore/kwq/KWQXmlSimpleReader.mm
@@ -136,7 +136,7 @@ static void warningHandler(void *userData, const char *message, ...)
         va_start(args, message);
         vasprintf(&m, message, args);
         va_end(args);
-        if (!reader->errorHandler()->warning(QXmlParseException(m, reader->lineNumber(), reader->columnNumber()))) {
+        if (!reader->errorHandler()->warning(QXmlParseException(m, reader->columnNumber(), reader->lineNumber()))) {
             reader->stopParsing();
         }
         free(m);
@@ -157,9 +157,32 @@ static void fatalErrorHandler(void *userData, const char *message, ...)
         va_start(args, message);
         vasprintf(&m, message, args);
         va_end(args);
-        if (!reader->errorHandler()->fatalError(QXmlParseException(m, reader->lineNumber(), reader->columnNumber()))) {
+        if (!reader->errorHandler()->fatalError(QXmlParseException(m, reader->columnNumber(), reader->lineNumber()))) {
             reader->stopParsing();
         }
+        reader->recordError();
+        free(m);
+    }
+}
+
+static void normalErrorHandler(void *userData, const char *message, ...)
+{
+    QXmlSimpleReader *reader = static_cast<QXmlSimpleReader *>(userData);
+    if (reader->parserStopped()) {
+        return;
+    }
+    if (!reader->errorHandler()) {
+        reader->stopParsing();
+    } else {
+        char *m;
+        va_list args;
+        va_start(args, message);
+        vasprintf(&m, message, args);
+        va_end(args);
+        if (!reader->errorHandler()->error(QXmlParseException(m, reader->columnNumber(), reader->lineNumber()))) {
+            reader->stopParsing();
+        }
+        reader->recordError();
         free(m);
     }
 }
@@ -212,7 +235,7 @@ bool QXmlSimpleReader::parse(const QXmlInputSource &input)
     xmlSAXHandler handler = {
         NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
         NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL,
-        NULL, NULL, NULL, NULL, NULL, NULL, fatalErrorHandler, fatalErrorHandler,
+        NULL, NULL, NULL, NULL, NULL, NULL, normalErrorHandler, fatalErrorHandler,
         NULL, NULL, NULL,
         0
     };
@@ -230,6 +253,7 @@ bool QXmlSimpleReader::parse(const QXmlInputSource &input)
         handler.warning = warningHandler;
     }
     m_parserStopped = false;
+    m_sawError = false;
     m_context = xmlCreatePushParserCtxt(&handler, this, NULL, 0, NULL);
     const QChar BOM(0xFEFF);
     const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char *>(&BOM);
@@ -239,7 +263,7 @@ bool QXmlSimpleReader::parse(const QXmlInputSource &input)
         input.data().length() * sizeof(QChar), 1);
     xmlFreeParserCtxt(m_context);
     m_context = NULL;
-    return !m_parserStopped;
+    return !m_sawError;
 }
 
 void QXmlSimpleReader::stopParsing()

-- 
WebKit Debian packaging



More information about the Pkg-webkit-commits mailing list