internal static GeckoNode OldCreateWrapper(nsIDOMNode domObject)
        {
            if (domObject == null)
            {
                return(null);
            }
            nsIDOMHTMLElement element = Xpcom.QueryInterface <nsIDOMHTMLElement>(domObject);

            if (element != null)
            {
                return(GeckoElement.Create(element));
            }

            nsIDOMAttr attr = Xpcom.QueryInterface <nsIDOMAttr>(domObject);

            if (attr != null)
            {
                return(GeckoAttribute.CreateAttributeWrapper(attr));
            }

            nsIDOMComment comment = domObject as nsIDOMComment;

            if (comment != null)
            {
                return(GeckoComment.CreateCommentWrapper(comment));
            }

            return(new GeckoNode(domObject));
        }
Example #2
0
        public GeckoAttribute GetAttributeNodeNS(string namespaceUri, string localName)
        {
            if (string.IsNullOrEmpty(namespaceUri))
            {
                return(GetAttributeNode(localName));
            }

            return(GeckoAttribute.CreateAttributeWrapper(Window, (nsIDOMElement)_element.Value.GetAttributeNodeNS(namespaceUri, localName)));
        }
Example #3
0
        //[return: MarshalAs(UnmanagedType.Interface)]
        //[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
        //nsIDOMCDATASection CreateCDATASection([MarshalAs(UnmanagedType.LPStruct)] nsAStringBase data);

        //[return: MarshalAs(UnmanagedType.Interface)]
        //[MethodImpl(MethodImplOptions.InternalCall, MethodCodeType = MethodCodeType.Runtime)]
        //nsIDOMProcessingInstruction CreateProcessingInstruction([MarshalAs(UnmanagedType.LPStruct)] nsAStringBase target, [MarshalAs(UnmanagedType.LPStruct)] nsAStringBase data);

        public GeckoAttribute CreateAttribute(string name)
        {
            if (string.IsNullOrEmpty(name))
            {
                throw new ArgumentException("name");
            }
            var native = nsString.Pass <nsIDOMAttr>(_domDocument.CreateAttribute, name);

            return(GeckoAttribute.CreateAttributeWrapper(native));
        }
Example #4
0
        public GeckoAttribute CreateAttribute(string namespaceUri, string qualifiedName)
        {
            if (string.IsNullOrEmpty(namespaceUri))
            {
                throw new ArgumentException("namespaceUri");
            }
            if (string.IsNullOrEmpty(qualifiedName))
            {
                throw new ArgumentException("qualifiedName");
            }

            var native = nsString.Pass <nsIDOMAttr>(_domDocument.CreateAttributeNS, namespaceUri, qualifiedName);

            return(GeckoAttribute.CreateAttributeWrapper(native));
        }
        internal static GeckoNode CreateNodeWrapper(nsIDOMNode domObject)
        {
            // if null -> return null
            if (domObject == null)
            {
                return(null);
            }
            var nodeType = ( NodeType )domObject.GetNodeTypeAttribute();

            // by nodeType we can find proper wrapper faster, than perform QueryInterface
            switch (nodeType)
            {
            case NodeType.Element:
                nsIDOMHTMLElement element = Xpcom.QueryInterface <nsIDOMHTMLElement>(domObject);
                if (element != null)
                {
                    return(GeckoElement.Create(element));
                }
                break;

            case NodeType.Attribute:
                nsIDOMAttr attr = Xpcom.QueryInterface <nsIDOMAttr>(domObject);
                if (attr != null)
                {
                    return(GeckoAttribute.CreateAttributeWrapper(attr));
                }
                break;

            case NodeType.Comment:
                nsIDOMComment comment = Xpcom.QueryInterface <nsIDOMComment>(domObject);
                if (comment != null)
                {
                    return(GeckoComment.CreateCommentWrapper(comment));
                }
                break;

            case NodeType.DocumentFragment:
                nsIDOMDocumentFragment fragment = Xpcom.QueryInterface <nsIDOMDocumentFragment>(domObject);
                if (fragment != null)
                {
                    return(DOM.DocumentFragment.CreateDocumentFragmentWrapper(fragment));
                }
                break;
            }
            // if fast method is unsuccessful try old method :)
            return(OldCreateWrapper(domObject));
        }
Example #6
0
        public GeckoAttribute SetAttributeNodeNS(GeckoAttribute attribute)
        {
            var ret = _domElement.SetAttributeNodeNS(attribute.DomAttr);

            return((ret == null) ? null : new GeckoAttribute(ret));
        }
Example #7
0
        public GeckoAttribute RemoveAttributeNode(GeckoAttribute newAttr)
        {
            var ret = _domElement.RemoveAttributeNode(newAttr.DomAttr);

            return(ret == null ? null : new GeckoAttribute(ret));
        }
 public GeckoAttribute SetAttributeNodeNS(GeckoAttribute attribute)
 {
     var ret = _domElement.SetAttributeNodeNS( attribute.DomAttr );
     return (ret == null) ? null : new GeckoAttribute(ret);
 }
 public GeckoAttribute SetAttributeNode(GeckoAttribute newAttr)
 {
     var ret = _domElement.SetAttributeNode(newAttr.DomAttr);
     return ret == null ? null : new GeckoAttribute(ret);
 }
Example #10
0
 public GeckoAttribute SetAttributeNodeNS(GeckoAttribute attribute)
 {
     return(GeckoAttribute.CreateAttributeWrapper(Window, (nsIDOMElement)_element.Value.SetAttributeNodeNS((nsISupports)attribute.DomAttr)));
 }
Example #11
0
 public GeckoAttribute RemoveAttributeNode(GeckoAttribute newAttr)
 {
     //var ret = _domElement.RemoveAttributeNode(newAttr.DomAttr);
     //return ret == null ? null : new GeckoAttribute(ret);
     throw new NotImplementedException();
 }