diff --git a/src/dom/AttrImpl.cpp b/src/dom/AttrImpl.cpp index 4a6312f06175646d0f49add940b98200f4ebf1f8..02aeaca57661f3c105bf8d27bb494065c5780065 100644 --- a/src/dom/AttrImpl.cpp +++ b/src/dom/AttrImpl.cpp @@ -69,7 +69,7 @@ #define null 0 AttrImpl::AttrImpl(DocumentImpl *ownerDoc, const DOMString &aName) - : NodeContainer (ownerDoc, DOMString()) + : NodeContainer (ownerDoc) { name = aName.clone(); specified = true; diff --git a/src/dom/CDATASectionImpl.cpp b/src/dom/CDATASectionImpl.cpp index 026bba313721beb1c5b9ea3f9ff1a07f26ba366f..6f3580ac5107bec2d753c4febd6fda71331d88c3 100644 --- a/src/dom/CDATASectionImpl.cpp +++ b/src/dom/CDATASectionImpl.cpp @@ -65,7 +65,7 @@ CDATASectionImpl::CDATASectionImpl(DocumentImpl *ownerDoc, const DOMString &data) - : TextImpl(ownerDoc,data) + : TextImpl(ownerDoc, data) { }; diff --git a/src/dom/CharacterDataImpl.cpp b/src/dom/CharacterDataImpl.cpp index 6f03596ddc2b12e841cb3103632cfe3098415fa9..9a311cc50cb7cbae28765c679ba61ebe47c5e9ed 100644 --- a/src/dom/CharacterDataImpl.cpp +++ b/src/dom/CharacterDataImpl.cpp @@ -64,13 +64,15 @@ CharacterDataImpl::CharacterDataImpl(DocumentImpl *ownerDoc, const DOMString &data) - : NodeImpl(ownerDoc, data) + : NodeImpl(ownerDoc) { + this->data = data.clone(); }; CharacterDataImpl::CharacterDataImpl(const CharacterDataImpl &other, bool deep) : NodeImpl(other) { + data = other.data.clone(); }; @@ -78,6 +80,20 @@ CharacterDataImpl::~CharacterDataImpl() { }; +DOMString CharacterDataImpl::getNodeValue() +{ + return data; +}; + + +void CharacterDataImpl::setNodeValue(const DOMString &value) +{ + if (readOnly) + throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, + null); + data = value.clone(); +}; + void CharacterDataImpl::appendData(const DOMString &data) { @@ -85,7 +101,7 @@ void CharacterDataImpl::appendData(const DOMString &data) throw DOM_DOMException( DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); - value.appendData(data); + this->data.appendData(data); }; @@ -98,14 +114,14 @@ void CharacterDataImpl::deleteData(unsigned int offset, unsigned int count) // Note: the C++ DOMString operation throws the correct DOMExceptions // when parameter values are bad. // - value.deleteData(offset, count); + data.deleteData(offset, count); }; DOMString &CharacterDataImpl::getData() { - return value; + return data; }; @@ -121,7 +137,7 @@ DOMString &CharacterDataImpl::getData() // unsigned int CharacterDataImpl::getCharDataLength() { - return value.length(); + return data.length(); }; @@ -136,12 +152,13 @@ void CharacterDataImpl::insertData(unsigned int offset, const DOMString &data) // Note: the C++ DOMString operation throws the correct DOMExceptions // when parameter values are bad. // - value.insertData(offset, data); + this->data.insertData(offset, data); } -void CharacterDataImpl::replaceData(unsigned int offset, unsigned int count, const DOMString &data) +void CharacterDataImpl::replaceData(unsigned int offset, unsigned int count, + const DOMString &data) { if (readOnly) throw DOM_DOMException( @@ -156,20 +173,22 @@ void CharacterDataImpl::replaceData(unsigned int offset, unsigned int count, con void CharacterDataImpl::setData(const DOMString &arg) { if (readOnly) - throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); - value = arg.clone(); + throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, + null); + data = arg.clone(); }; -DOMString CharacterDataImpl::substringData(unsigned int offset, unsigned int count) +DOMString CharacterDataImpl::substringData(unsigned int offset, + unsigned int count) { // Note: the C++ DOMString operation throws the correct DOMExceptions // when parameter values are bad. // - return value.substringData(offset, count); + return data.substringData(offset, count); }; diff --git a/src/dom/CharacterDataImpl.hpp b/src/dom/CharacterDataImpl.hpp index fa2643b993f9afb8ce4548eb7d785217cee6d037..a77ea0386c2c2206ea015faa6afc7cbe232f66fb 100644 --- a/src/dom/CharacterDataImpl.hpp +++ b/src/dom/CharacterDataImpl.hpp @@ -77,10 +77,15 @@ class CDOM_EXPORT CharacterDataImpl: public NodeImpl { +protected: + DOMString data; + public: CharacterDataImpl(DocumentImpl *ownerDocument, const DOMString &data); CharacterDataImpl(const CharacterDataImpl &other, bool deep = false); virtual ~CharacterDataImpl(); + virtual DOMString getNodeValue(); + virtual void setNodeValue(const DOMString &value); virtual void appendData(const DOMString &data); virtual void deleteData(unsigned int offset, unsigned int count); virtual DOMString &getData(); diff --git a/src/dom/DocumentFragmentImpl.cpp b/src/dom/DocumentFragmentImpl.cpp index 7061bcfcb961a32402748a63d9f10fb4f5b261c6..9d0266c0b08261e266788312c8146494ff6f4f5f 100644 --- a/src/dom/DocumentFragmentImpl.cpp +++ b/src/dom/DocumentFragmentImpl.cpp @@ -67,7 +67,7 @@ static DOMString *nam; // Will be lazily initialized to "#document-fragment" DocumentFragmentImpl::DocumentFragmentImpl(DocumentImpl *masterDoc) - : NodeContainer(masterDoc, null) + : NodeContainer(masterDoc) { }; diff --git a/src/dom/DocumentImpl.cpp b/src/dom/DocumentImpl.cpp index f12c3e3b9eb24cb0e58380994b06f348886197a0..8efe2ab8ecd828e748cae7dc18a0d1b5069b0022 100644 --- a/src/dom/DocumentImpl.cpp +++ b/src/dom/DocumentImpl.cpp @@ -113,7 +113,7 @@ const XMLCh* DocumentImpl::PoolElem::getKey() const DocumentImpl::DocumentImpl() - : NodeContainer(null, null) + : NodeContainer(null) { docType=null; docElement=null; @@ -128,7 +128,7 @@ DocumentImpl::DocumentImpl() DocumentImpl::DocumentImpl(const DOMString &fNamespaceURI, const DOMString &qualifiedName, DocumentTypeImpl *doctype) - : NodeContainer(null, null) + : NodeContainer(null) { if (doctype != null && doctype->getOwnerDocument() != null) // a doctype can belong to only one DocumentImpl diff --git a/src/dom/DocumentTypeImpl.cpp b/src/dom/DocumentTypeImpl.cpp index 8a3e9f943e526714edea1411dc77a7d5872f5b3c..fbc9e2a29cb730b54a694b89eb5637e860d27ab3 100644 --- a/src/dom/DocumentTypeImpl.cpp +++ b/src/dom/DocumentTypeImpl.cpp @@ -67,7 +67,7 @@ DocumentTypeImpl::DocumentTypeImpl(DocumentImpl *ownerDoc, const DOMString &dtName) - : NodeContainer(ownerDoc,null), + : NodeContainer(ownerDoc), publicId(null), systemId(null) //DOM Level 2 { name = dtName.clone(); @@ -82,7 +82,7 @@ DocumentTypeImpl::DocumentTypeImpl(DocumentImpl *ownerDoc, //Introduced in DOM Level 2 DocumentTypeImpl::DocumentTypeImpl(const DOMString &qualifiedName, const DOMString &fPublicId, const DOMString &fSystemId) - : NodeContainer(null, null), + : NodeContainer(null), publicId(fPublicId), systemId(fSystemId) { name = qualifiedName.clone(); @@ -98,7 +98,7 @@ DocumentTypeImpl::DocumentTypeImpl(const DOMString &qualifiedName, DocumentTypeImpl::DocumentTypeImpl(const DocumentTypeImpl &other, bool deep) -: NodeContainer(other) + : NodeContainer(other) { name = other.name.clone(); if (deep) diff --git a/src/dom/ElementDefinitionImpl.cpp b/src/dom/ElementDefinitionImpl.cpp index f7eca1005803ad2d8ee507ce069d7513779f697d..9dca28118ca20fd589d203274fa7f6e9710b6342 100644 --- a/src/dom/ElementDefinitionImpl.cpp +++ b/src/dom/ElementDefinitionImpl.cpp @@ -65,7 +65,7 @@ ElementDefinitionImpl::ElementDefinitionImpl(DocumentImpl *ownerDoc, const DOMString &nam) - : NodeImpl(ownerDoc, null) + : NodeImpl(ownerDoc) { name = name.clone(); attributes = 0; diff --git a/src/dom/ElementImpl.cpp b/src/dom/ElementImpl.cpp index 1a6f6afab91339347687b1673da58f25cb65f4e8..7c08848916694044d24dcf956f4533062c002f7f 100644 --- a/src/dom/ElementImpl.cpp +++ b/src/dom/ElementImpl.cpp @@ -70,7 +70,7 @@ ElementImpl::ElementImpl(DocumentImpl *ownerDoc, const DOMString &eName) - : NodeContainer(ownerDoc, null) + : NodeContainer(ownerDoc) { name = eName.clone(); diff --git a/src/dom/EntityImpl.cpp b/src/dom/EntityImpl.cpp index 09666ccd30e1d7c5ac86f1cf39a8b6add4e6d8fd..a27fcab3d1135ec31b27820d9b958b99733d8692 100644 --- a/src/dom/EntityImpl.cpp +++ b/src/dom/EntityImpl.cpp @@ -64,7 +64,7 @@ EntityImpl::EntityImpl(DocumentImpl *ownerDoc, const DOMString &eName) - : NodeContainer(ownerDoc, null) + : NodeContainer(ownerDoc) { name = eName.clone(); }; diff --git a/src/dom/EntityReferenceImpl.cpp b/src/dom/EntityReferenceImpl.cpp index 6fd5acedba63f2147a017c39fad7488cf7be9e02..e31b10bd21e5c93d7b281181f0c745c897f32c9b 100644 --- a/src/dom/EntityReferenceImpl.cpp +++ b/src/dom/EntityReferenceImpl.cpp @@ -122,7 +122,7 @@ EntityReferenceImpl::EntityReferenceImpl(DocumentImpl *ownerDoc, const DOMString &entityName) - : NodeContainer(ownerDoc, null) + : NodeContainer(ownerDoc) { name = entityName.clone(); // EntityReference behaves as a read-only node, since its contents diff --git a/src/dom/NodeContainer.cpp b/src/dom/NodeContainer.cpp index 63d6b8ee8d2172b9b8a7b20a7bd74523fe1dc373..f65eb7a7085e2f29ecee19395588028f14b44872 100644 --- a/src/dom/NodeContainer.cpp +++ b/src/dom/NodeContainer.cpp @@ -73,9 +73,8 @@ static DOMString *s_xmlURI = null; static DOMString *s_xmlns = null; static DOMString *s_xmlnsURI = null; -NodeContainer::NodeContainer(DocumentImpl *ownerDoc, - const DOMString &initValue) - : NodeImpl(ownerDoc, initValue) +NodeContainer::NodeContainer(DocumentImpl *ownerDoc) + : NodeImpl(ownerDoc) { this->firstChild = null; this->lastChild = null; diff --git a/src/dom/NodeContainer.hpp b/src/dom/NodeContainer.hpp index 539f89f34aff9b8d4da67993fe24f33a16f95219..6af4aaa98ba4763385f10cc91f65193a128762b9 100644 --- a/src/dom/NodeContainer.hpp +++ b/src/dom/NodeContainer.hpp @@ -87,8 +87,7 @@ public: NodeImpl *lastChild; public: - NodeContainer(DocumentImpl *ownerDocument, - const DOMString &initValue); + NodeContainer(DocumentImpl *ownerDocument); NodeContainer(const NodeContainer &other); virtual NodeImpl *appendChild(NodeImpl *newChild); diff --git a/src/dom/NodeImpl.cpp b/src/dom/NodeImpl.cpp index b6b9aa068e24fa65de98c24bc7988667a7e5b8c8..47f82668da5252ecfdf74f037536f677aaed1cca 100644 --- a/src/dom/NodeImpl.cpp +++ b/src/dom/NodeImpl.cpp @@ -77,12 +77,9 @@ static DOMString *s_xmlURI = null; static DOMString *s_xmlns = null; static DOMString *s_xmlnsURI = null; -NodeImpl::NodeImpl(DocumentImpl *ownerDoc, - const DOMString &initValue) +NodeImpl::NodeImpl(DocumentImpl *ownerDoc) { this->ownerDocument=ownerDoc; - this->value=initValue.clone(); - this->changes = 0; this->userData = null; this->readOnly = false; @@ -98,7 +95,6 @@ NodeImpl::NodeImpl(DocumentImpl *ownerDoc, // This only makes a shallow copy, cloneChildren must also be called for a // deep clone NodeImpl::NodeImpl(const NodeImpl &other) { - this->value = other.value.clone(); this->readOnly = false; this->ownerDocument = other.ownerDocument; this->userData = other.userData; @@ -219,7 +215,7 @@ NodeImpl * NodeImpl::getNextSibling() { DOMString NodeImpl::getNodeValue() { - return value; + return null; // overridden in some subclasses }; @@ -298,21 +294,18 @@ NodeImpl *NodeImpl::replaceChild(NodeImpl *newChild, NodeImpl *oldChild) // the entire document will be deleted as well. RefCountedImpl::removeRef(doc); }; - - - void NodeImpl::setNodeValue(const DOMString &val) - { - if (readOnly) - throw DOM_DOMException( - DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); - - // Default behavior, overridden in some subclasses - this->value = val.clone(); - }; - - - + +void NodeImpl::setNodeValue(const DOMString &val) +{ + if (readOnly) + throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, + null); + // Default behavior is to do nothing, overridden in some subclasses +}; + + + void NodeImpl::setReadOnly(bool readOnl, bool deep) { this->readOnly = readOnl; diff --git a/src/dom/NodeImpl.hpp b/src/dom/NodeImpl.hpp index a9fcc27edb3e752b3e37016a65e32028af4ecf76..b5d5167eba1338c041e9eec205bed5781cc13688 100644 --- a/src/dom/NodeImpl.hpp +++ b/src/dom/NodeImpl.hpp @@ -99,21 +99,19 @@ const int null = 0; class CDOM_EXPORT NodeImpl: public NodeListImpl { public: - DOMString value; // String value (not used in all nodes) bool readOnly; - DocumentImpl *ownerDocument; // Document this node belongs to + DocumentImpl *ownerDocument; // Document this node belongs to NodeImpl *previousSibling; NodeImpl *nextSibling; NodeImpl *ownerNode; // typically the parent but not always! int changes; void *userData; - static int gLiveNodeImpls; // Counters for debug & tuning. + static int gLiveNodeImpls; // Counters for debug & tuning. static int gTotalNodeImpls; public: - NodeImpl(DocumentImpl *ownerDocument, - const DOMString &initValue); + NodeImpl(DocumentImpl *ownerDocument); NodeImpl(const NodeImpl &other); virtual ~NodeImpl(); diff --git a/src/dom/NotationImpl.cpp b/src/dom/NotationImpl.cpp index 92adbd96577079eb6d4854bced39f42b757b9eb4..b5701b0fdeaa045968bc739e8aeaed92f6d5dd14 100644 --- a/src/dom/NotationImpl.cpp +++ b/src/dom/NotationImpl.cpp @@ -87,7 +87,7 @@ */ NotationImpl::NotationImpl(DocumentImpl *ownerDoc, const DOMString &nName) - : NodeImpl(ownerDoc, null) + : NodeImpl(ownerDoc) { name = nName.clone(); }; diff --git a/src/dom/ProcessingInstructionImpl.cpp b/src/dom/ProcessingInstructionImpl.cpp index c350e5e584c11590d23ba17a5cd0d008ae9bb844..7d91bb981be36a8c2fe80662a454996f93a9177b 100644 --- a/src/dom/ProcessingInstructionImpl.cpp +++ b/src/dom/ProcessingInstructionImpl.cpp @@ -67,9 +67,10 @@ ProcessingInstructionImpl::ProcessingInstructionImpl(DocumentImpl *ownerDoc, const DOMString &target, const DOMString &data) - : NodeImpl(ownerDoc,data) + : NodeImpl(ownerDoc) { - name = target.clone(); + this->target = target.clone(); + this->data = data.clone(); }; @@ -78,7 +79,8 @@ ProcessingInstructionImpl::ProcessingInstructionImpl( bool deep) : NodeImpl(other) { - name = other.name.clone(); + target = other.target.clone(); + data = other.data.clone(); }; @@ -95,7 +97,7 @@ NodeImpl *ProcessingInstructionImpl::cloneNode(bool deep) DOMString ProcessingInstructionImpl::getNodeName() { - return name; + return target; }; @@ -104,9 +106,24 @@ short ProcessingInstructionImpl::getNodeType() { }; +DOMString ProcessingInstructionImpl::getNodeValue() +{ + return data.clone(); +}; + + +void ProcessingInstructionImpl::setNodeValue(const DOMString &value) +{ + if (readOnly) + throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, + null); + data = value.clone(); +}; + + DOMString ProcessingInstructionImpl::getData() { - return value.clone(); + return data.clone(); }; @@ -122,7 +139,7 @@ should be directed to. It is defined differently in HTML and XML. */ DOMString ProcessingInstructionImpl::getTarget() { - return name.clone(); + return target.clone(); }; @@ -134,9 +151,8 @@ DOMString ProcessingInstructionImpl::getTarget() */ void ProcessingInstructionImpl::setData(const DOMString &arg) { - if(readOnly) - throw DOM_DOMException( - DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR,null); - - value = arg; + if (readOnly) + throw DOM_DOMException(DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, + null); + data = arg.clone(); }; diff --git a/src/dom/ProcessingInstructionImpl.hpp b/src/dom/ProcessingInstructionImpl.hpp index 0841a268122aaba96600a94fbf79cf577abd624e..8e809aeb25bf0a9a97669e9ef1f69f830b512b66 100644 --- a/src/dom/ProcessingInstructionImpl.hpp +++ b/src/dom/ProcessingInstructionImpl.hpp @@ -77,7 +77,8 @@ class DocumentImpl; class CDOM_EXPORT ProcessingInstructionImpl: public NodeImpl { protected: - DOMString name; + DOMString target; + DOMString data; public: ProcessingInstructionImpl(DocumentImpl *ownerDoc, @@ -87,6 +88,8 @@ public: bool deep=false); virtual ~ProcessingInstructionImpl(); virtual NodeImpl *cloneNode(bool deep); + virtual DOMString getNodeValue(); + virtual void setNodeValue(const DOMString &value); virtual DOMString getNodeName(); virtual short getNodeType(); virtual DOMString getData(); diff --git a/src/dom/TextImpl.cpp b/src/dom/TextImpl.cpp index ecbcb4b87e948ca9c9a28f817f575100dd114d80..57d2ccee4931ec291d8890259740b60668f585fe 100644 --- a/src/dom/TextImpl.cpp +++ b/src/dom/TextImpl.cpp @@ -92,7 +92,7 @@ bool TextImpl::isTextImpl() NodeImpl *TextImpl::cloneNode(bool deep) { - return ownerDocument->createTextNode(value); + return ownerDocument->createTextNode(data); }; @@ -112,18 +112,18 @@ TextImpl *TextImpl::splitText(unsigned int offset) throw DOM_DOMException( DOM_DOMException::NO_MODIFICATION_ALLOWED_ERR, null); } - unsigned int len = value.length(); + unsigned int len = data.length(); if (offset >= len) throw DOM_DOMException(DOM_DOMException::INDEX_SIZE_ERR, null); TextImpl *newText = (TextImpl *) ownerDocument->createTextNode( - value.substringData(offset, value.length() - offset)); + data.substringData(offset, data.length() - offset)); NodeImpl *parent = getParentNode(); if (parent != null) parent->insertBefore(newText, getNextSibling()); - value = value.substringData(0, offset); + data = data.substringData(0, offset); return newText; };