Removed these files so they can be replaced with the actual Mozilla DOM wrapper

classes following the Mozilla* naming convention.
This commit is contained in:
tomk%mitre.org 2000-02-02 18:32:45 +00:00
Родитель 968ad90110
Коммит 47a8eab4e9
17 изменённых файлов: 0 добавлений и 2035 удалений

Просмотреть файл

@ -1,143 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the Attr class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
// LF 08/06/1999 fixed typo: defalut to default
//
#include "dom.h"
//
//Construct an Attribute object using the specified name and document owner
//
Attr::Attr(const DOMString& name, Document* owner):
NodeDefinition(Node::ATTRIBUTE_NODE, name, NULL_STRING, owner)
{
specified = MB_FALSE;
}
//
//Retrieve the name of the attribute from the nodeName data member
//
const DOMString& Attr::getName() const
{
return nodeName;
}
//
//Retrieve the specified flag
//
MBool Attr::getSpecified() const
{
return specified;
}
//
//Retrieve the value of the attribute. This is a comma-deliminated string
//representation of the Attribute's children.
//
const DOMString& Attr::getValue()
{
Int32 valueLoop;
nodeValue = NULL_STRING;
NodeList* childList = getChildNodes();
Int32 numChildren = childList->getLength();
for (valueLoop=0;valueLoop<numChildren;valueLoop++)
{
if (childList->item(valueLoop)->getNodeType() != Node::ENTITY_REFERENCE_NODE)
{
nodeValue.append(childList->item(valueLoop)->getNodeValue());
if (valueLoop < (numChildren-1))
nodeValue.append(",");
}
}
return nodeValue;
}
//
//Create a new Text node and add it to the Attribute's list of children. Also
//set the Specified flag to true.
//
void Attr::setValue(const DOMString& newValue)
{
NodeDefinition::DeleteChildren();
appendChild(getOwnerDocument()->createTextNode(newValue));
specified = MB_TRUE;
}
//
//Override the set node value member function to create a new TEXT node with
//the DOMString and to add it as the Attribute's child.
// NOTE: Not currently impemented, just execute the default setNodeValue
//
void Attr::setNodeValue(const DOMString& nodeValue)
{
setValue(nodeValue);
}
//
//Return a DOMString represening the value of this node. If the value is an
//Entity Reference then return the value of the reference. Otherwise, it is a
//simple conversion of the text value.
// NOTE: Not currently implemented, just execute the default getNodeValue
//
const DOMString& Attr::getNodeValue()
{
return getValue();
}
//
//First check to see if the new node is an allowable child for an Attr. If it
//is, call NodeDefinition's implementation of Insert Before. If not, return
//null as an error.
//
Node* Attr::insertBefore(Node* newChild, Node* refChild)
{
Node* returnVal = NULL;
switch (newChild->getNodeType())
{
case Node::TEXT_NODE :
case Node::ENTITY_REFERENCE_NODE:
returnVal = NodeDefinition::insertBefore(newChild, refChild);
if (returnVal)
specified = MB_TRUE;
break;
default:
returnVal = NULL;
}
return returnVal;
}

Просмотреть файл

@ -1,64 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the CDATASection class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
//
//Construct a text object with the specified document owner and data
//
CDATASection::CDATASection(const DOMString& theData, Document* owner) :
Text(Node::CDATA_SECTION_NODE, "#cdata-section", theData, owner)
{
}
//
//CDATASection nodes can not have any children, so just return null from all child
//manipulation functions.
//
Node* CDATASection::insertBefore(Node* newChild, Node* refChild)
{
return NULL;
}
Node* CDATASection::replaceChild(Node* newChild, Node* oldChild)
{
return NULL;
}
Node* CDATASection::removeChild(Node* oldChild)
{
return NULL;
}
Node* CDATASection::appendChild(Node* newChild)
{
return NULL;
}

Просмотреть файл

@ -1,113 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the CharacterData class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
//
//Protected constructor. Just pass parameters onto NodeDefinition.
//
CharacterData::CharacterData(NodeType type, const DOMString& name,
const DOMString& value, Document* owner) :
NodeDefinition(type, name, value, owner)
{
}
//
//Return a constant reference to the data stored by this object.
//
const DOMString& CharacterData::getData() const
{
return nodeValue;
}
//
//Set the data stored by this object to the string represented by "source".
//
void CharacterData::setData(const DOMString& source)
{
nodeValue = source;
}
//
//Returns the length of the data object.
//
Int32 CharacterData::getLength() const
{
return nodeValue.length();
}
//
//Retreive the substring starting at offset anc ending count number of
//characters away.
// NOTE: An empty string will be returned in the event of an error.
//
DOMString& CharacterData::substringData(Int32 offset, Int32 count, DOMString& dest)
{
if ((offset >= 0) && (offset < nodeValue.length()) && (count > 0))
return nodeValue.subString(offset, offset+count, dest);
else
{
dest.clear();
return dest;
}
}
void CharacterData::appendData(const DOMString& arg)
{
nodeValue.append(arg);
}
void CharacterData::insertData(Int32 offset, const DOMString& arg)
{
if ((offset >= 0) && (offset < nodeValue.length()))
nodeValue.insert(offset, arg);
}
void CharacterData::deleteData(Int32 offset, Int32 count)
{
if ((offset >= 0) && (offset < nodeValue.length()) && (count > 0))
nodeValue.deleteChars(offset, count);
}
void CharacterData::replaceData(Int32 offset, Int32 count, const DOMString& arg)
{
DOMString tempString;
if ((offset >= 0) && (offset < nodeValue.length()) && (count > 0))
{
if (count < arg.length())
{
tempString = arg.subString(0, count, tempString);
nodeValue.replace(offset, tempString);
}
else
nodeValue.replace(offset, arg);
}
}

Просмотреть файл

@ -1,64 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the Comment class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
//
//Construct a text object with the specified document owner and data
//
Comment::Comment(const DOMString& theData, Document* owner) :
CharacterData(Node::COMMENT_NODE, "#comment", theData, owner)
{
}
//
//Comment nodes can not have any children, so just return null from all child
//manipulation functions.
//
Node* Comment::insertBefore(Node* newChild, Node* refChild)
{
return NULL;
}
Node* Comment::replaceChild(Node* newChild, Node* oldChild)
{
return NULL;
}
Node* Comment::removeChild(Node* oldChild)
{
return NULL;
}
Node* Comment::appendChild(Node* newChild)
{
return NULL;
}

Просмотреть файл

@ -1,56 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the DOMImplementation class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
DOMImplementation::DOMImplementation()
{
implFeature = "XML";
implVersion = "1.0";
}
DOMImplementation::~DOMImplementation()
{
}
//
//Perform a case insensitive comparison between "feature" and the
//functionality of this DOM implementation/version.
//
MBool DOMImplementation::hasFeature(DOMString feature,
const DOMString& version) const
{
feature.toUpperCase();
if (feature.isEqual(implFeature) && version.isEqual(implVersion))
return MB_TRUE;
else
return MB_FALSE;
}

Просмотреть файл

@ -1,258 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the Document class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
// LF 08/06/1999 Removed Default argument initializer from
// Document() constructor
// LF 08/06/1999 fixed typo: defalut to default
//
#include "dom.h"
//
//Construct a Document. Currently no parameters are required, but the the
//node constructor is called to identify the node type.
//
Document::Document(DocumentType* theDoctype) :
NodeDefinition(Node::DOCUMENT_NODE, "#document", NULL_STRING, NULL)
{
documentElement = NULL;
doctype = theDoctype;
}
//
//Return the one and only element for this document
//
Element* Document::getDocumentElement()
{
return documentElement;
}
//
//Return the document type of this document object
//
DocumentType* Document::getDoctype()
{
return doctype;
}
//
//Return a constant reference to the DOM's Implementation
//
const DOMImplementation& Document::getImplementation()
{
return implementation;
}
//
//Ensure that no Element node is inserted if the document already has an
//associated Element child.
//
Node* Document::insertBefore(Node* newChild, Node* refChild)
{
Node* returnVal = NULL;
NodeDefinition* pCurrentNode = NULL;
NodeDefinition* pNextNode = NULL;
//Convert to a NodeDefinition Pointer
NodeDefinition* pNewChild = (NodeDefinition*)newChild;
NodeDefinition* pRefChild = (NodeDefinition*)refChild;
//Check to see if the reference node is a child of this node
if ((refChild != NULL) && (pRefChild->getParentNode() != this))
return NULL;
switch (pNewChild->getNodeType())
{
case Node::DOCUMENT_FRAGMENT_NODE :
pCurrentNode = (NodeDefinition*)pNewChild->getFirstChild();
while (pCurrentNode)
{
pNextNode = (NodeDefinition*)pCurrentNode->getNextSibling();
//Make sure that if the current node is an Element, the document
//doesn't already have one.
if ((pCurrentNode->getNodeType() != Node::ELEMENT_NODE) ||
((pCurrentNode->getNodeType() == Node::ELEMENT_NODE) &&
(documentElement == NULL)))
{
pCurrentNode = (NodeDefinition*)pNewChild->removeChild(pCurrentNode);
implInsertBefore(pCurrentNode, pRefChild);
if (pCurrentNode->getNodeType() == Node::ELEMENT_NODE)
documentElement = (Element*)pCurrentNode;
}
pCurrentNode = pNextNode;
}
returnVal = newChild;
break;
case Node::PROCESSING_INSTRUCTION_NODE :
case Node::COMMENT_NODE :
case Node::DOCUMENT_TYPE_NODE :
returnVal = implInsertBefore(pNewChild, pRefChild);
break;
case Node::ELEMENT_NODE :
if (!documentElement)
{
documentElement = (Element*)pNewChild;
returnVal = implInsertBefore(pNewChild, pRefChild);
}
else
returnVal = NULL;
break;
default:
returnVal = NULL;
}
return returnVal;
}
//
//Ensure that if the newChild is an Element and the Document already has an
//element, then oldChild should be specifying the existing element. If not
//then the replacement can not take place.
//
Node* Document::replaceChild(Node* newChild, Node* oldChild)
{
Node* replacedChild = NULL;
if (newChild->getNodeType() != Node::ELEMENT_NODE)
{
//The new child is not an Element, so perform replacement
replacedChild = NodeDefinition::replaceChild(newChild, oldChild);
//If old node was an Element, then the document's element has been
//replaced with a non-element node. Therefore clear the documentElement
//pointer
if (replacedChild && (oldChild->getNodeType() == Node::ELEMENT_NODE))
documentElement = NULL;
return replacedChild;
}
else
{
//A node is being replaced with an Element. If the document does not
//have an elemet yet, then just allow the replacemetn to take place.
if (!documentElement)
replacedChild = NodeDefinition::replaceChild(newChild, oldChild);
else if (oldChild->getNodeType() == Node::ELEMENT_NODE)
replacedChild = NodeDefinition::replaceChild(newChild, oldChild);
if (replacedChild)
documentElement = (Element*)newChild;
return replacedChild;
}
}
//
//Update the documentElement pointer if the associated Element node is being
//removed.
//
Node* Document::removeChild(Node* oldChild)
{
Node* removedChild = NULL;
removedChild = NodeDefinition::removeChild(oldChild);
if (removedChild && (removedChild->getNodeType() == Node::ELEMENT_NODE))
documentElement = NULL;
return removedChild;
}
//
//Construct an empty document fragment.
// NOTE: The caller is responsible for cleaning up this fragment's memory
// when it is no longer needed.
//
DocumentFragment* Document::createDocumentFragment()
{
return new DocumentFragment("#document-fragment", NULL_STRING, this);
}
//
//Construct an element with the specified tag name.
// NOTE: The caller is responsible for cleaning up the element's menory
//
Element* Document::createElement(const DOMString& tagName)
{
return new Element(tagName, this);
}
//
//Construct an attribute with the specified name
//
Attr* Document::createAttribute(const DOMString& name)
{
return new Attr(name, this);
}
//
//Construct a text node with the given data
//
Text* Document::createTextNode(const DOMString& theData)
{
return new Text(theData, this);
}
//
//Construct a comment node with the given data
//
Comment* Document::createComment(const DOMString& theData)
{
return new Comment(theData, this);
}
//
//Construct a CDATASection node with the given data
//
CDATASection* Document::createCDATASection(const DOMString& theData)
{
return new CDATASection(theData, this);
}
//
//Construct a ProcessingInstruction node with the given targe and data.
//
ProcessingInstruction*
Document::createProcessingInstruction(const DOMString& target,
const DOMString& data)
{
return new ProcessingInstruction(target, data, this);
}
//
//Construct an EntityReference with the given name
//
EntityReference* Document::createEntityReference(const DOMString& name)
{
return new EntityReference(name, this);
}

Просмотреть файл

@ -1,68 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the DocumentFragment class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
// LF 08/06/1999 fixed typo: defalut to default
//
#include "dom.h"
//
//Construct a DocumentFragment with the specified name and value. Call the
//constructor for NodeDefinition and specify the DocumentFragment Type.
//
DocumentFragment::DocumentFragment(const DOMString& name,
const DOMString& value, Document* owner) :
NodeDefinition(Node::DOCUMENT_FRAGMENT_NODE, name, value, owner)
{
}
//
//First check to see if the new node is an allowable child for a
//DocumentFragment. If it is, call NodeDefinition's implementation of Insert
//Before. If not, return null as an error.
//
Node* DocumentFragment::insertBefore(Node* newChild, Node* refChild)
{
Node* returnVal = NULL;
switch (newChild->getNodeType())
{
case Node::ELEMENT_NODE :
case Node::PROCESSING_INSTRUCTION_NODE :
case Node::COMMENT_NODE :
case Node::TEXT_NODE :
case Node::CDATA_SECTION_NODE :
case Node::ENTITY_REFERENCE_NODE:
returnVal = NodeDefinition::insertBefore(newChild, refChild);
break;
default:
returnVal = NULL;
}
return returnVal;
}

Просмотреть файл

@ -1,96 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the DocumentType class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
//
//Construct a text object with the specified document owner and data
//
DocumentType::DocumentType(const DOMString& name, NamedNodeMap* theEntities,
NamedNodeMap* theNotations) :
NodeDefinition(Node::DOCUMENT_TYPE_NODE, name, NULL_STRING, NULL)
{
entities = theEntities;
notations = theNotations;
}
//
//When destroying the DocumentType, the entities and notations must be
//destroyed too.
//
DocumentType::~DocumentType()
{
if (entities)
delete entities;
if (notations)
delete notations;
}
//
//Return a pointer to the entities contained in this Document Type
//
NamedNodeMap* DocumentType::getEntities()
{
return entities;
}
//
//Return a pointer to the notations contained in this Document Type
//
NamedNodeMap* DocumentType::getNotations()
{
return notations;
}
//
//Comment nodes can not have any children, so just return null from all child
//manipulation functions.
//
Node* DocumentType::insertBefore(Node* newChild, Node* refChild)
{
return NULL;
}
Node* DocumentType::replaceChild(Node* newChild, Node* oldChild)
{
return NULL;
}
Node* DocumentType::removeChild(Node* oldChild)
{
return NULL;
}
Node* DocumentType::appendChild(Node* newChild)
{
return NULL;
}

Просмотреть файл

@ -1,161 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the Element class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
// LF 08/06/1999 fixed typo: defalut to default
//
#include "dom.h"
//
//Construct a new element with the specified tagName and Document owner.
//Simply call the constructor for NodeDefinition, and specify the proper node
//type.
//
Element::Element(const DOMString& tagName, Document* owner) :
NodeDefinition(Node::ELEMENT_NODE, tagName, NULL_STRING, owner)
{
}
//
//First check to see if the new node is an allowable child for an Element. If
//it is, call NodeDefinition's implementation of Insert Before. If not, return
//null as an error
//
Node* Element::insertBefore(Node* newChild, Node* refChild)
{
Node* returnVal = NULL;
switch (newChild->getNodeType())
{
case Node::ELEMENT_NODE :
case Node::TEXT_NODE :
case Node::COMMENT_NODE :
case Node::PROCESSING_INSTRUCTION_NODE :
case Node::CDATA_SECTION_NODE :
case Node::ENTITY_REFERENCE_NODE:
returnVal = NodeDefinition::insertBefore(newChild, refChild);
break;
default:
returnVal = NULL;
}
return returnVal;
}
//
//Return the tagName for this element. This is simply the nodeName.
//
const DOMString& Element::getTagName()
{
return nodeName;
}
//
//Retreive an attribute's value by name. If the attribute does not exist,
//return a reference to the pre-created, constatnt "NULL STRING".
//
const DOMString& Element::getAttribute(const DOMString& name)
{
Node* tempNode = attributes.getNamedItem(name);
if (tempNode)
return attributes.getNamedItem(name)->getNodeValue();
else
return NULL_STRING;
}
//
//Add an attribute to this Element. Create a new Attr object using the
//name and value specified. Then add the Attr to the the Element's
//attributes NamedNodeMap.
//
void Element::setAttribute(const DOMString& name, const DOMString& value)
{
Attr* tempAttribute;
//Check to see if an attribute with this name already exists. If it does
//over write its value, if not, add it.
tempAttribute = getAttributeNode(name);
if (tempAttribute)
tempAttribute->setNodeValue(value);
else
{
tempAttribute = getOwnerDocument()->createAttribute(name);
tempAttribute->setNodeValue(value);
attributes.setNamedItem(tempAttribute);
}
}
//
//Remove an attribute from the attributes NamedNodeMap, and free its memory.
// NOTE: How do default values enter into this picture
//
void Element::removeAttribute(const DOMString& name)
{
delete attributes.removeNamedItem(name);
}
//
//Return the attribute specified by name
//
Attr* Element::getAttributeNode(const DOMString& name)
{
return (Attr*)attributes.getNamedItem(name);
}
//
//Set a new attribute specifed by the newAttr node. If an attribute with that
//name already exists, the existing Attr is removed from the list and return to
//the caller, else NULL is returned.
//
Attr* Element::setAttributeNode(Attr* newAttr)
{
Attr* pOldAttr = (Attr*)attributes.removeNamedItem(newAttr->getNodeName());
attributes.setNamedItem(newAttr);
return pOldAttr;
}
//
//Remove the Attribute from the attributes list and return to the caller. If
//the node is not found, return NULL.
//
Attr* Element::removeAttributeNode(Attr* oldAttr)
{
return (Attr*)attributes.removeNamedItem(oldAttr->getNodeName());
}
NodeList* Element::getElementsByTagName(const DOMString& name)
{
return 0;
}
void Element::normalize()
{
}

Просмотреть файл

@ -1,95 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the Entity class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
// LF 08/06/1999 fixed typo: defalut to default
//
#include "dom.h"
//
//Construct a text object with the specified document owner and data
//
Entity::Entity(const DOMString& name, const DOMString& pubID,
const DOMString& sysID, const DOMString& notName) :
NodeDefinition(Node::ENTITY_NODE, name, NULL_STRING, NULL)
{
publicId = pubID;
systemId = sysID;
notationName = notName;
}
//
//Return the Public ID of the Entity
//
const DOMString& Entity::getPublicId() const
{
return publicId;
}
//
//Return the System ID of the Entity
//
const DOMString& Entity::getSystemId() const
{
return systemId;
}
//
//Return the Notation Name of the Entity
//
const DOMString& Entity::getNotationName() const
{
return notationName;
}
//
//First check to see if the new node is an allowable child for an Entity. If
//it is, call NodeDefinition's implementation of Insert Before. If not, return
//null as an error.
//
Node* Entity::insertBefore(Node* newChild, Node* refChild)
{
Node* returnVal = NULL;
switch (newChild->getNodeType())
{
case Node::ELEMENT_NODE:
case Node::PROCESSING_INSTRUCTION_NODE:
case Node::COMMENT_NODE:
case Node::TEXT_NODE :
case Node::CDATA_SECTION_NODE:
case Node::ENTITY_REFERENCE_NODE:
returnVal = NodeDefinition::insertBefore(newChild, refChild);
break;
default:
returnVal = NULL;
}
return returnVal;
}

Просмотреть файл

@ -1,66 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the EntityReference class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
// LF 08/06/1999 fixed typo: defalut to default
//
#include "dom.h"
//
//Construct a text object with the specified document owner and data
//
EntityReference::EntityReference(const DOMString& name, Document* owner) :
NodeDefinition(Node::ENTITY_REFERENCE_NODE, name, NULL_STRING, owner)
{
}
//
//First check to see if the new node is an allowable child for an
//EntityReference. If it is, call NodeDefinition's implementation of Insert
//Before. If not, return null as an error.
//
Node* EntityReference::insertBefore(Node* newChild, Node* refChild)
{
Node* returnVal = NULL;
switch (newChild->getNodeType())
{
case Node::ELEMENT_NODE:
case Node::PROCESSING_INSTRUCTION_NODE:
case Node::COMMENT_NODE:
case Node::TEXT_NODE :
case Node::CDATA_SECTION_NODE:
case Node::ENTITY_REFERENCE_NODE:
returnVal = NodeDefinition::insertBefore(newChild, refChild);
break;
default:
returnVal = NULL;
}
return returnVal;
}

Просмотреть файл

@ -1,111 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the NamedNodeMap class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
NamedNodeMap::NamedNodeMap()
{
}
NamedNodeMap::~NamedNodeMap()
{
}
Node* NamedNodeMap::getNamedItem(const DOMString& name)
{
ListItem* pSearchItem = findListItemByName(name);
if (pSearchItem)
return pSearchItem->node;
else
return NULL;
}
Node* NamedNodeMap::setNamedItem(Node* arg)
{
//Since the DOM does not specify any ording for the NamedNodeMap, just
//try and remove the new node (arg). If successful, return a pointer to
//the removed item. Reguardless of wheter the node already existed or not,
//insert the new node at the end of the list.
Node* pReplacedNode = removeNamedItem(arg->getNodeName());
NodeListDefinition::append(arg);
return pReplacedNode;
}
Node* NamedNodeMap::removeNamedItem(const DOMString& name)
{
NodeListDefinition::ListItem* pSearchItem;
Node* returnNode;
pSearchItem = findListItemByName(name);
if (pSearchItem)
{
if (pSearchItem != firstItem)
pSearchItem->prev->next = pSearchItem->next;
else
firstItem = pSearchItem->next;
if (pSearchItem != lastItem)
pSearchItem->next->prev = pSearchItem->prev;
else
lastItem = pSearchItem->prev;
pSearchItem->next = NULL;
pSearchItem->prev = NULL;
length--;
returnNode = pSearchItem->node;
delete pSearchItem;
return returnNode;
}
return NULL;
}
NodeListDefinition::ListItem*
NamedNodeMap::findListItemByName(const DOMString& name)
{
NodeListDefinition::ListItem* pSearchItem = firstItem;
while (pSearchItem)
{
if (name.isEqual(pSearchItem->node->getNodeName()))
return pSearchItem;
pSearchItem = pSearchItem->next;
}
return NULL;
}

Просмотреть файл

@ -1,356 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the NodeDefinition Class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
NodeDefinition::NodeDefinition(NodeType type, const DOMString& name,
const DOMString& value, Document* owner)
{
nodeName = name;
nodeValue = value;
nodeType = type;
parentNode = NULL;
previousSibling = NULL;
nextSibling = NULL;;
firstChild = NULL;
lastChild = NULL;
ownerDocument = owner;
length = 0;
}
//
// This node is being destroyed, so loop through and destroy all the children.
// Also, destroy all attributes stored in the attributes NamedNodeMap.
//
NodeDefinition::~NodeDefinition()
{
Int32 numAttributes = attributes.getLength();
Int32 killAttrLoop;
DeleteChildren();
for (killAttrLoop=0;killAttrLoop<numAttributes;killAttrLoop++)
delete attributes.removeNamedItem(attributes.item(0)->getNodeName());
}
//
//Remove and delete all children of this node
//
void NodeDefinition::DeleteChildren()
{
NodeDefinition* pCurrent = firstChild;
NodeDefinition* pDestroyer;
while (pCurrent)
{
pDestroyer = pCurrent;
pCurrent = pCurrent->nextSibling;
delete pDestroyer;
}
length = 0;
firstChild = NULL;
lastChild = NULL;
}
const DOMString& NodeDefinition::getNodeName() const
{
return nodeName;
}
const DOMString& NodeDefinition::getNodeValue() const
{
return nodeValue;
}
const DOMString& NodeDefinition::getNodeValue()
{
return nodeValue;
}
unsigned short NodeDefinition::getNodeType() const
{
return nodeType;
}
Node* NodeDefinition::getParentNode() const
{
return parentNode;
}
NodeList* NodeDefinition::getChildNodes()
{
return this;
}
Node* NodeDefinition::getFirstChild() const
{
return firstChild;
}
Node* NodeDefinition::getLastChild() const
{
return lastChild;
}
Node* NodeDefinition::getPreviousSibling() const
{
return previousSibling;
}
Node* NodeDefinition::getNextSibling() const
{
return nextSibling;
}
NamedNodeMap* NodeDefinition::getAttributes()
{
return &attributes;
}
Document* NodeDefinition::getOwnerDocument() const
{
return ownerDocument;
}
Node* NodeDefinition::item(Int32 index)
{
Int32 selectLoop;
NodeDefinition* pSelectNode = firstChild;
if (index < length)
{
for (selectLoop=0;selectLoop<index;selectLoop++)
pSelectNode = pSelectNode->nextSibling;
return pSelectNode;
}
return NULL;
}
Int32 NodeDefinition::getLength()
{
return length;
}
void NodeDefinition::setNodeValue(const DOMString& newNodeValue)
{
nodeValue = newNodeValue;
}
//
//Insert the "newChild" node before the "refChild" node. Return a pointer to
//the inserted child. If the node to insert is a document fragment, then
//insert each child of the document fragment, and return the document fragment
//which should be empty if all the inserts suceeded.
//This function's responsibility is to check for and handle document fragments
//vs. plain nodes.
// *** NOTE: Need to check the document types before inserting.
//
// The decision to return the possibly empty document fragment
// was an implementation choice. The spec did not dictate what
// whould occur.
//
Node* NodeDefinition::insertBefore(Node* newChild,
Node* refChild)
{
NodeDefinition* pCurrentNode = NULL;
NodeDefinition* pNextNode = NULL;
//Convert to a NodeDefinition Pointer
NodeDefinition* pNewChild = (NodeDefinition*)newChild;
NodeDefinition* pRefChild = (NodeDefinition*)refChild;
//Check to see if the reference node is a child of this node
if ((refChild != NULL) && (pRefChild->parentNode != this))
return NULL;
if (pNewChild->getNodeType() == Node::DOCUMENT_FRAGMENT_NODE)
{
pCurrentNode = pNewChild->firstChild;
while (pCurrentNode)
{
pNextNode = pCurrentNode->nextSibling;
pCurrentNode = (NodeDefinition*)pNewChild->removeChild(pCurrentNode);
implInsertBefore(pCurrentNode, pRefChild);
pCurrentNode = pNextNode;
}
return newChild;
}
else
return implInsertBefore(pNewChild, pRefChild);
}
//
//The code that actually insert one node before another.
//
Node* NodeDefinition::implInsertBefore(NodeDefinition* pNewChild,
NodeDefinition* pRefChild)
{
//Remove the "newChild" if it is already a child of this node
if (pNewChild->parentNode == this)
pNewChild = (NodeDefinition*)removeChild(pNewChild);
//The new child should not be a child of any other node
if ((pNewChild->previousSibling == NULL) &&
(pNewChild->nextSibling == NULL) &&
(pNewChild->parentNode == NULL))
{
if (pRefChild == NULL)
{
//Append
pNewChild->previousSibling = lastChild;
if (lastChild)
lastChild->nextSibling = pNewChild;
lastChild = pNewChild;
}
else
{
//Insert before the reference node
if (pRefChild->previousSibling)
pRefChild->previousSibling->nextSibling = pNewChild;
pNewChild->nextSibling = pRefChild;
pNewChild->previousSibling = pRefChild->previousSibling;
pRefChild->previousSibling = pNewChild;
}
pNewChild->parentNode = this;
if (pNewChild->previousSibling == NULL)
firstChild = pNewChild;
length++;
return pNewChild;
}
return NULL;
}
//
//Replace "oldChild" with "newChild". Return the replaced node, or NULL
//otherwise.
// *** NOTE: Need to check that the documents match ***
//
Node* NodeDefinition::replaceChild(Node* newChild,
Node* oldChild)
{
NodeDefinition* pOldChild = (NodeDefinition*)oldChild;
NodeDefinition* pNextSibling = NULL;
//If the newChild is replacing itself then we don't need to do anything
if (pOldChild == newChild)
return pOldChild;
//If "oldChild" is a child of this node, remove it from the list.
pOldChild = (NodeDefinition*)removeChild(oldChild);
//If the removal was successful... Else, return null
if (pOldChild)
{
//Try to insert the new node before the old node's next sibling. If
//successful, just returned the replaced child. If not succesful,
//reinsert the old node, and return NULL.
pNextSibling = pOldChild->nextSibling;
if (!insertBefore(newChild, pNextSibling))
{
insertBefore(pOldChild, pNextSibling);
pOldChild = NULL;
}
}
return pOldChild;
}
//
//Remove the specified "oldChild" from this node's children. First make sure
//the specified node is a child of this node. Return the removed node, NULL
//otherwise.
//
Node* NodeDefinition::removeChild(Node* oldChild)
{
NodeDefinition* pOldChild = (NodeDefinition*)oldChild;
//If "oldChild" is a child of this node, adjust pointers to remove it, and
//clear "oldChild"'s sibling and parent pointers.
if (pOldChild->parentNode == this)
{
if (pOldChild != firstChild)
pOldChild->previousSibling->nextSibling = pOldChild->nextSibling;
else
firstChild = pOldChild->nextSibling;
if (pOldChild != lastChild)
pOldChild->nextSibling->previousSibling = pOldChild->previousSibling;
else
lastChild = pOldChild->previousSibling;
pOldChild->nextSibling = NULL;
pOldChild->previousSibling = NULL;
pOldChild->parentNode = NULL;
length--;
return pOldChild;
}
return NULL;
}
//
//Append a new child node. First make sure the new child is not already a
//child of another node. Return the appended node.
// *** NOTE *** Need to eventually check to make sure the documents match ***
//
Node* NodeDefinition::appendChild(Node* newChild)
{
return insertBefore(newChild, NULL);
}
Node* NodeDefinition::cloneNode(MBool deep, Node* dest)
{
return 0;
}
MBool NodeDefinition::hasChildNodes() const
{
if (firstChild != NULL)
return MB_TRUE;
else
return MB_FALSE;
}

Просмотреть файл

@ -1,117 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the NodeListDefinition class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
//
//Create an empty node list.
//
NodeListDefinition::NodeListDefinition()
{
firstItem = NULL;
lastItem = NULL;
length = 0;
}
//
//Free up the memory used by the List of Items. Don't delete the actual nodes
//though.
//
NodeListDefinition::~NodeListDefinition()
{
ListItem* pDeleteItem;
ListItem* pListTraversal = firstItem;
while (pListTraversal)
{
pDeleteItem = pListTraversal;
pListTraversal = pListTraversal->next;
delete pDeleteItem;
}
}
//
//Create a new ListItem, point it to the newNode, and append it to the current
//list of nodes.
//
void NodeListDefinition::append(Node* newNode)
{
append(*newNode);
}
void NodeListDefinition::append(Node& newNode)
{
ListItem* newListItem = new ListItem;
// Setup the new list item
newListItem->node = &newNode;
newListItem->prev = lastItem;
newListItem->next = NULL;
//Append the list item
if (lastItem)
lastItem->next = newListItem;
lastItem = newListItem;
//Adjust firstItem if this new item is being added to an empty list
if (!firstItem)
firstItem = lastItem;
//Need to increment the length of the list. Inherited from NodeList
length++;
}
//
// Return the Node contained in the item specified
//
Node* NodeListDefinition::item(Int32 index)
{
Int32 selectLoop;
ListItem* pListItem = firstItem;
if (index < length)
{
for (selectLoop=0;selectLoop<index;selectLoop++)
pListItem = pListItem->next;
return pListItem->node;
}
return NULL;
}
//
// Return the number of items in the list
//
Int32 NodeListDefinition::getLength()
{
return length;
}

Просмотреть файл

@ -1,81 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the Notation class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
//
//Construct a text object with the specified document owner and data
//
Notation::Notation(const DOMString& name, const DOMString& pubID,
const DOMString& sysID) :
NodeDefinition(Node::NOTATION_NODE, name, NULL_STRING, NULL)
{
publicId = pubID;
systemId = sysID;
}
//
//Return the Public ID of the Notation
//
const DOMString& Notation::getPublicId() const
{
return publicId;
}
//Return the System ID of the Notation
const DOMString& Notation::getSystemId() const
{
return systemId;
}
//
//Notation nodes can not have any children, so just return null from all child
//manipulation functions.
//
Node* Notation::insertBefore(Node* newChild, Node* refChild)
{
return NULL;
}
Node* Notation::replaceChild(Node* newChild, Node* oldChild)
{
return NULL;
}
Node* Notation::removeChild(Node* oldChild)
{
return NULL;
}
Node* Notation::appendChild(Node* newChild)
{
return NULL;
}

Просмотреть файл

@ -1,93 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the ProcessingInstruction class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
//
//Construct a text object with the specified document owner and data
//
ProcessingInstruction::ProcessingInstruction(const DOMString& theTarget,
const DOMString& theData,
Document* owner) :
NodeDefinition(Node::PROCESSING_INSTRUCTION_NODE,
theTarget, theData, owner)
{
}
//
//Return the Target of the processing instruction. This is simply the
//nodeName.
//
const DOMString& ProcessingInstruction::getTarget() const
{
return nodeName;
}
//
//Return the Data of the processing instruction. This is simply the value
//of the node, "nodeValue"
//
const DOMString& ProcessingInstruction::getData() const
{
return nodeValue;
}
//
//Set the Data element of the processing instruction.
void ProcessingInstruction::setData(const DOMString& theData)
{
nodeValue = theData;
}
//
//ProcessingInstruction nodes can not have any children, so just return null
//from all child manipulation functions.
//
Node* ProcessingInstruction::insertBefore(Node* newChild, Node* refChild)
{
return NULL;
}
Node* ProcessingInstruction::replaceChild(Node* newChild, Node* oldChild)
{
return NULL;
}
Node* ProcessingInstruction::removeChild(Node* oldChild)
{
return NULL;
}
Node* ProcessingInstruction::appendChild(Node* newChild)
{
return NULL;
}

Просмотреть файл

@ -1,93 +0,0 @@
/*
* (C) Copyright The MITRE Corporation 1999 All rights reserved.
*
* The contents of this file are subject to the Mozilla Public License
* Version 1.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* The program provided "as is" without any warranty express or
* implied, including the warranty of non-infringement and the implied
* warranties of merchantibility and fitness for a particular purpose.
* The Copyright owner will not be liable for any damages suffered by
* you as a result of using the Program. In no event will the Copyright
* owner be liable for any special, indirect or consequential damages or
* lost profits even if the Copyright owner has been advised of the
* possibility of their occurrence.
*
* Please see release.txt distributed with this file for more information.
*
*/
// Tom Kneeland (3/29/99)
//
// Implementation of the Document Object Model Level 1 Core
// Implementation of the Text class
//
// Modification History:
// Who When What
// TK 03/29/99 Created
//
#include "dom.h"
//
//Construct a text object with the specified document owner and data
//
Text::Text(const DOMString& theData, Document* owner) :
CharacterData(Node::TEXT_NODE, "#text", theData, owner)
{
}
//
//Protected constructor for children of the Text Class. Currently only
//CDATASection needs to use this function.
Text::Text(NodeType type, const DOMString& name, const DOMString& value,
Document* owner) :
CharacterData(type, name, value, owner)
{
}
//
//Split the text node at Offset into two siblings. Return a pointer to the new
//sibling.
//
Text* Text::splitText(Int32 offset)
{
Text* newTextSibling = NULL;
DOMString newData;
if ((offset >= 0) && (offset < nodeValue.length()))
{
newTextSibling = getOwnerDocument()->createTextNode(nodeValue.subString(offset, newData));
getParentNode()->insertBefore(newTextSibling, getNextSibling());
nodeValue.deleteChars(offset, nodeValue.length() - offset);
}
return newTextSibling;
}
//
//Text nodes can not have any children, so just return null from all child
//manipulation functions.
//
Node* Text::insertBefore(Node* newChild, Node* refChild)
{
return NULL;
}
Node* Text::replaceChild(Node* newChild, Node* oldChild)
{
return NULL;
}
Node* Text::removeChild(Node* oldChild)
{
return NULL;
}
Node* Text::appendChild(Node* newChild)
{
return NULL;
}