Exemple #1
0
        /// <seealso cref="Comzept.Genesis.Tidy.Dom.Node.removeChild">
        /// </seealso>
        public virtual Comzept.Genesis.Tidy.Dom.Node removeChild(Comzept.Genesis.Tidy.Dom.Node oldChild)
        {
            if (oldChild == null)
            {
                return(null);
            }

            Node ref_Renamed = this.adaptee.content;

            while (ref_Renamed != null)
            {
                if (ref_Renamed.Adapter == oldChild)
                {
                    break;
                }
                ref_Renamed = ref_Renamed.next;
            }
            if (ref_Renamed == null)
            {
                throw new DOMExceptionImpl(DOMException.NOT_FOUND_ERR, "refChild not found");
            }
            Node.discardElement(ref_Renamed);

            if (this.adaptee.content == null && this.adaptee.type == Node.StartTag)
            {
                this.adaptee.Type = Node.StartEndTag;
            }

            return(oldChild);
        }
Exemple #2
0
        /* --------------------- DOM ---------------------------- */

        /// <seealso cref="Comzept.Genesis.Tidy.Dom.Node.insertBefore">
        /// </seealso>
        public virtual Comzept.Genesis.Tidy.Dom.Node insertBefore(Comzept.Genesis.Tidy.Dom.Node newChild, Comzept.Genesis.Tidy.Dom.Node refChild)
        {
            // TODO - handle newChild already in tree

            if (newChild == null)
            {
                return(null);
            }
            if (!(newChild is DOMNodeImpl))
            {
                throw new DOMExceptionImpl(DOMException.WRONG_DOCUMENT_ERR, "newChild not instanceof DOMNodeImpl");
            }
            DOMNodeImpl newCh = (DOMNodeImpl)newChild;

            if (this.adaptee.type == Node.RootNode)
            {
                if (newCh.adaptee.type != Node.DocTypeTag && newCh.adaptee.type != Node.ProcInsTag)
                {
                    throw new DOMExceptionImpl(DOMException.HIERARCHY_REQUEST_ERR, "newChild cannot be a child of this node");
                }
            }
            else if (this.adaptee.type == Node.StartTag)
            {
                if (newCh.adaptee.type != Node.StartTag && newCh.adaptee.type != Node.StartEndTag && newCh.adaptee.type != Node.CommentTag && newCh.adaptee.type != Node.TextNode && newCh.adaptee.type != Node.CDATATag)
                {
                    throw new DOMExceptionImpl(DOMException.HIERARCHY_REQUEST_ERR, "newChild cannot be a child of this node");
                }
            }
            if (refChild == null)
            {
                Node.insertNodeAtEnd(this.adaptee, newCh.adaptee);
                if (this.adaptee.type == Node.StartEndTag)
                {
                    this.adaptee.Type = Node.StartTag;
                }
            }
            else
            {
                Node ref_Renamed = this.adaptee.content;
                while (ref_Renamed != null)
                {
                    if (ref_Renamed.Adapter == refChild)
                    {
                        break;
                    }
                    ref_Renamed = ref_Renamed.next;
                }
                if (ref_Renamed == null)
                {
                    throw new DOMExceptionImpl(DOMException.NOT_FOUND_ERR, "refChild not found");
                }
                Node.insertNodeBeforeElement(ref_Renamed, newCh.adaptee);
            }
            return(newChild);
        }
Exemple #3
0
        /// <seealso cref="Comzept.Genesis.Tidy.Dom.Node.appendChild">
        /// </seealso>
        public virtual Comzept.Genesis.Tidy.Dom.Node appendChild(Comzept.Genesis.Tidy.Dom.Node newChild)
        {
            // TODO - handle newChild already in tree

            if (newChild == null)
            {
                return(null);
            }
            if (!(newChild is DOMNodeImpl))
            {
                throw new DOMExceptionImpl(DOMException.WRONG_DOCUMENT_ERR, "newChild not instanceof DOMNodeImpl");
            }
            DOMNodeImpl newCh = (DOMNodeImpl)newChild;

            if (this.adaptee.type == Node.RootNode)
            {
                if (newCh.adaptee.type != Node.DocTypeTag && newCh.adaptee.type != Node.ProcInsTag)
                {
                    throw new DOMExceptionImpl(DOMException.HIERARCHY_REQUEST_ERR, "newChild cannot be a child of this node");
                }
            }
            else if (this.adaptee.type == Node.StartTag)
            {
                if (newCh.adaptee.type != Node.StartTag && newCh.adaptee.type != Node.StartEndTag && newCh.adaptee.type != Node.CommentTag && newCh.adaptee.type != Node.TextNode && newCh.adaptee.type != Node.CDATATag)
                {
                    throw new DOMExceptionImpl(DOMException.HIERARCHY_REQUEST_ERR, "newChild cannot be a child of this node");
                }
            }
            Node.insertNodeAtEnd(this.adaptee, newCh.adaptee);

            if (this.adaptee.type == Node.StartEndTag)
            {
                this.adaptee.Type = Node.StartTag;
            }

            return(newChild);
        }
 /// <summary> DOM2 - not implemented.</summary>
 /// <exception cref="Comzept.Genesis.Tidy.Dom.DOMException">
 /// </exception>
 public virtual Comzept.Genesis.Tidy.Dom.Node importNode(Comzept.Genesis.Tidy.Dom.Node importedNode, bool deep)
 {
     return(null);
 }
 /// <seealso cref="Comzept.Genesis.Tidy.Dom.NamedNodeMap.setNamedItem">
 /// </seealso>
 public virtual Comzept.Genesis.Tidy.Dom.Node setNamedItem(Comzept.Genesis.Tidy.Dom.Node arg)
 {
     // NOT SUPPORTED
     return(null);
 }
 /// <summary> DOM2 - not implemented.</summary>
 /// <exception cref="Comzept.Genesis.Tidy.Dom.DOMException">
 /// </exception>
 public virtual Comzept.Genesis.Tidy.Dom.Node setNamedItemNS(Comzept.Genesis.Tidy.Dom.Node arg)
 {
     return(null);
 }
Exemple #7
0
        /// <seealso cref="Comzept.Genesis.Tidy.Dom.Node.replaceChild">
        /// </seealso>
        public virtual Comzept.Genesis.Tidy.Dom.Node replaceChild(Comzept.Genesis.Tidy.Dom.Node newChild, Comzept.Genesis.Tidy.Dom.Node oldChild)
        {
            // TODO - handle newChild already in tree

            if (newChild == null)
            {
                return(null);
            }
            if (!(newChild is DOMNodeImpl))
            {
                throw new DOMExceptionImpl(DOMException.WRONG_DOCUMENT_ERR, "newChild not instanceof DOMNodeImpl");
            }
            DOMNodeImpl newCh = (DOMNodeImpl)newChild;

            if (this.adaptee.type == Node.RootNode)
            {
                if (newCh.adaptee.type != Node.DocTypeTag && newCh.adaptee.type != Node.ProcInsTag)
                {
                    throw new DOMExceptionImpl(DOMException.HIERARCHY_REQUEST_ERR, "newChild cannot be a child of this node");
                }
            }
            else if (this.adaptee.type == Node.StartTag)
            {
                if (newCh.adaptee.type != Node.StartTag && newCh.adaptee.type != Node.StartEndTag && newCh.adaptee.type != Node.CommentTag && newCh.adaptee.type != Node.TextNode && newCh.adaptee.type != Node.CDATATag)
                {
                    throw new DOMExceptionImpl(DOMException.HIERARCHY_REQUEST_ERR, "newChild cannot be a child of this node");
                }
            }
            if (oldChild == null)
            {
                throw new DOMExceptionImpl(DOMException.NOT_FOUND_ERR, "oldChild not found");
            }
            else
            {
                Node n;
                Node ref_Renamed = this.adaptee.content;
                while (ref_Renamed != null)
                {
                    if (ref_Renamed.Adapter == oldChild)
                    {
                        break;
                    }
                    ref_Renamed = ref_Renamed.next;
                }
                if (ref_Renamed == null)
                {
                    throw new DOMExceptionImpl(DOMException.NOT_FOUND_ERR, "oldChild not found");
                }
                newCh.adaptee.next    = ref_Renamed.next;
                newCh.adaptee.prev    = ref_Renamed.prev;
                newCh.adaptee.last    = ref_Renamed.last;
                newCh.adaptee.parent  = ref_Renamed.parent;
                newCh.adaptee.content = ref_Renamed.content;
                if (ref_Renamed.parent != null)
                {
                    if (ref_Renamed.parent.content == ref_Renamed)
                    {
                        ref_Renamed.parent.content = newCh.adaptee;
                    }
                    if (ref_Renamed.parent.last == ref_Renamed)
                    {
                        ref_Renamed.parent.last = newCh.adaptee;
                    }
                }
                if (ref_Renamed.prev != null)
                {
                    ref_Renamed.prev.next = newCh.adaptee;
                }
                if (ref_Renamed.next != null)
                {
                    ref_Renamed.next.prev = newCh.adaptee;
                }
                for (n = ref_Renamed.content; n != null; n = n.next)
                {
                    if (n.parent == ref_Renamed)
                    {
                        n.parent = newCh.adaptee;
                    }
                }
            }
            return(oldChild);
        }
Exemple #8
0
 public override Comzept.Genesis.Tidy.Dom.Node appendChild(Comzept.Genesis.Tidy.Dom.Node newChild)
 {
     throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Not supported");
 }
Exemple #9
0
 public override Comzept.Genesis.Tidy.Dom.Node insertBefore(Comzept.Genesis.Tidy.Dom.Node newChild, Comzept.Genesis.Tidy.Dom.Node refChild)
 {
     throw new DOMExceptionImpl(DOMException.NO_MODIFICATION_ALLOWED_ERR, "Not supported");
 }