Beispiel #1
0
        public GeckoElement CreateElement(string namespaceUri, string qualifiedName)
        {
            if (string.IsNullOrEmpty(namespaceUri))
            {
                throw new ArgumentException("namespaceUri");
            }
            if (string.IsNullOrEmpty(qualifiedName))
            {
                throw new ArgumentException("qualifiedName");
            }

            var native = nsString.Pass <nsIDOMElement>(_domDocument.CreateElementNS, namespaceUri, qualifiedName);

            return(GeckoElement.Create(( nsIDOMHTMLElement )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));
        }
Beispiel #3
0
 /// <summary>
 /// Returns the element visible at the given point, relative to the upper-left-most visible point in the document.
 /// </summary>
 /// <param name="x"></param>
 /// <param name="y"></param>
 /// <returns></returns>
 public GeckoElement ElementFromPoint(int x, int y)
 {
     return(GeckoElement.Create((nsIDOMHTMLElement)_domDocument.ElementFromPoint(x, y)));
 }