/// <summary>
 /// Performs recursive search in all <paramref name="element"/> ChildNodes elements
 /// Returns first match
 /// </summary>
 /// <param name="element"></param>
 /// <param name="predicate"></param>
 /// <returns></returns>
 public static T FindFirstChildInTree <T>(this GeckoNode element, Predicate <T> predicate)
     where T : GeckoNode
 {
     for (int i = 0; i < element.ChildNodes.Length; i++)
     {
         var node = element.ChildNodes[i];
         if (!(node is T))
         {
             continue;
         }
         var childElement = (T)node;
         if (predicate(childElement))
         {
             return(childElement);
         }
         if (childElement.HasChildNodes)
         {
             var ret = FindFirstChildInTree(childElement, predicate);
             if (ret != null)
             {
                 return(ret);
             }
         }
     }
     return(null);
 }
Exemple #2
0
        public GeckoNode ImportNode(GeckoNode node, bool deep)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            return(GeckoNode.Create(_domDocument.ImportNode(node.DomObject, deep, 1)));
        }
Exemple #3
0
        public GeckoNode ImportNode(GeckoNode node, bool deep)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            return(Gecko.Interop.ExtensionMethods.Wrap(_domDocument.ImportNode(node.DomObject, deep, 1), Create));
        }
 /// <summary>Creates a new instance of a <see cref="GeckoContextMenuEventArgs"/> object.</summary>
 public GeckoContextMenuEventArgs(Point location, ContextMenu contextMenu, string associatedLink, Uri backgroundImageSrc, Uri imageSrc, GeckoNode targetNode)
 {
     Location           = location;
     _contextMenu       = contextMenu;
     AssociatedLink     = associatedLink;
     BackgroundImageSrc = backgroundImageSrc;
     ImageSrc           = imageSrc;
     _targetNode        = targetNode;
 }
        public GeckoNode ImportNode(GeckoNode node, bool deep)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            return(Doc.Value.ImportNode(node.DomObject, deep).Wrap(Window, Create));
        }
 /// <summary>Creates a new instance of a <see cref="GeckoContextMenuEventArgs"/> object.</summary>
 public GeckoContextMenuEventArgs(Point location, ContextMenu contextMenu, string associatedLink, Uri backgroundImageSrc, Uri imageSrc, GeckoNode targetNode)
 {
     Location = location;
     _contextMenu = contextMenu;
     AssociatedLink = associatedLink;
     BackgroundImageSrc = backgroundImageSrc;
     ImageSrc = imageSrc;
     _targetNode = targetNode;
 }
Exemple #7
0
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            nsIDOMNode node;

            while ((node = xpathResult.IterateNext()) != null)
            {
                yield return(GeckoNode.Create(node));
            }
        }
        public GeckoNode RemoveChild(GeckoNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            _DomObject.RemoveChild(node._DomObject);
            return(node);
        }
        public GeckoNode RemoveChild(GeckoNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

            _node.Value.RemoveChild(node._domNode.Instance);
            return(node);
        }
Exemple #10
0
        public GeckoNode AppendChild(GeckoNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException("node");
            }

            _domNode.Instance.AppendChild(node._domNode.Instance);
            return(node);
        }
Exemple #11
0
        public virtual GeckoHtmlElement this[uint index]
        {
            get
            {
                if (index >= Length)
                {
                    throw new ArgumentOutOfRangeException(nameof(index));
                }

                return((GeckoHtmlElement)GeckoNode.Create(_window, List.Item(index)));
            }
        }
        System.Collections.IEnumerator System.Collections.IEnumerable.GetEnumerator()
        {
            nsIDOMNode node;

#if NEED_WEBIDL
            while ((node = xpathResult.IterateNext()) != null)
            {
                yield return(GeckoNode.Create(node));
            }
#else
            return(null);
#endif
        }
        public GeckoNode ReplaceChild(GeckoNode newChild, GeckoNode oldChild)
        {
            if (newChild == null)
            {
                throw new ArgumentNullException("newChild");
            }
            if (oldChild == null)
            {
                throw new ArgumentNullException("oldChild");
            }

            _DomObject.ReplaceChild(newChild._DomObject, oldChild._DomObject);
            return(newChild);
        }
        public GeckoNode InsertBefore(GeckoNode newChild, GeckoNode before)
        {
            if (newChild == null)
            {
                throw new ArgumentNullException("newChild");
            }
            if (before == null)
            {
                throw new ArgumentNullException("before");
            }

            _DomObject.InsertBefore(newChild._DomObject, before._DomObject);
            return(newChild);
        }
        public GeckoNode ReplaceChild(GeckoNode newChild, GeckoNode oldChild)
        {
            if (newChild == null)
            {
                throw new ArgumentNullException(nameof(newChild));
            }
            if (oldChild == null)
            {
                throw new ArgumentNullException(nameof(oldChild));
            }

            _node.Value.ReplaceChild(newChild._domNode.Instance, oldChild._domNode.Instance);
            return(newChild);
        }
        public GeckoNode InsertBefore(GeckoNode newChild, GeckoNode before)
        {
            if (newChild == null)
            {
                throw new ArgumentNullException(nameof(newChild));
            }
            if (before == null)
            {
                throw new ArgumentNullException(nameof(before));
            }

            _node.Value.InsertBefore(newChild._domNode.Instance, before._domNode.Instance);
            return(newChild);
        }
Exemple #17
0
 public bool IsPointInRange(GeckoNode node, int offset)
 {
     return(DomNsRange.IsPointInRange(node.DomObject, offset));
 }
Exemple #18
0
 public void SelectNodeContents(GeckoNode node)
 {
     _range.Instance.SelectNodeContents((nsIDOMNode)node.DomObject);
 }
		public void InsertNode(GeckoNode newNode)
		{
			DomRange.InsertNode((nsIDOMNode)newNode.DomObject);
		}
		public void SurroundContents(GeckoNode newParent)
		{
			DomRange.SurroundContents((nsIDOMNode)newParent.DomObject);
		}
        public GeckoNode ImportNode(GeckoNode node, bool deep)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            return GeckoNode.Create(_domDocument.ImportNode(node.DomObject, deep, 1));
        }
        public GeckoNode ImportNode(GeckoNode node, bool deep)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            return ExtensionMethods.Wrap(_domDocument.ImportNode(node.DomObject, deep, 1),
                  Create);
            //return _domDocument.ImportNode(node.DomObject, deep, 1)
            //    .Wrap(Create);
        }
Exemple #23
0
 public void InsertNode(GeckoNode newNode)
 {
     _range.Instance.InsertNode(newNode.DomObject);
 }
 public int CompareDocumentPosition(GeckoNode other)
 {
     return(_node.Value.CompareDocumentPosition(other.DomObject));
 }
Exemple #25
0
		public GeckoNode InsertBefore(GeckoNode newChild, GeckoNode before)
		{
			if (newChild == null)
				throw new ArgumentNullException("newChild");
			if (before == null)
				throw new ArgumentNullException("before");

			_domNode.Instance.InsertBefore(newChild._domNode.Instance, before._domNode.Instance);
			return newChild;
		}
Exemple #26
0
 public void SurroundContents(GeckoNode newParent)
 {
     _range.Instance.SurroundContents(newParent.DomObject);
 }
Exemple #27
0
 public void SetStartBefore(GeckoNode node)
 {
     _range.Instance.SetStartBefore(node.DomObject);
 }
Exemple #28
0
 public void SetStartAfter(GeckoNode node)
 {
     _range.Instance.SetStartAfter(node.DomObject);
 }
Exemple #29
0
 public void SetStart(GeckoNode node, int offset)
 {
     _range.Instance.SetStart(node.DomObject, offset);
 }
		public void SetEnd(GeckoNode node, int offset)
		{
			DomRange.SetEnd((nsIDOMNode)node.DomObject, offset);
		}
        public GeckoNode ReplaceChild(GeckoNode newChild, GeckoNode oldChild)
        {
            if (newChild == null)
                throw new ArgumentNullException("newChild");
            if (oldChild == null)
                throw new ArgumentNullException("oldChild");

            _DomObject.ReplaceChild(newChild._DomObject, oldChild._DomObject);
            return newChild;
        }
 /// <summary>
 ///Scrolls to a given DOM content node.
 ///	</summary>
 public void ScrollToNode(GeckoNode node)
 {
     m_markupDocumentViewer.ScrollToNode(node.DomObject);
 }
Exemple #33
0
 public GeckoNode CloneNode(bool deep)
 {
     return(GeckoNode.Create(_domNode.Instance.CloneNode(deep, 1)));
 }
Exemple #34
0
 /// <summary>
 /// Collapses the selection to a single point, at the specified offset in the given DOM node. When the selection is collapsed, and the content is focused and editable, the caret will blink there.
 /// </summary>
 /// <param name="parentNode"></param>
 /// <param name="offset"></param>
 public void Collapse(GeckoNode parentNode, int offset)
 {
     Selection.Collapse((nsIDOMNode)parentNode.DomObject, offset);
 }
 /// <summary>
 ///Scrolls to a given DOM content node.
 ///	</summary>
 public void ScrollToNode(GeckoNode node)
 {
     _docViewer.Instance.ScrollToNode(node.DomObject);
 }
		public void SelectNodeContents(GeckoNode node)
		{
			DomRange.SelectNodeContents((nsIDOMNode)node.DomObject);
		}
 /// <summary>
 /// Given a particular node (typically one the user right-clicked), determine whether it is clearly part of
 /// a particular page (inside a PageContainerClass div).
 /// If so, return the corresponding Page object. If not, return null.
 /// </summary>
 /// <param name="clickNode"></param>
 /// <returns></returns>
 internal IPage GetPageContaining(GeckoNode clickNode)
 {
     bool gotPageElt = false;
     for (var elt = clickNode as GeckoElement ?? clickNode.ParentElement; elt != null; elt = elt.ParentElement)
     {
         var classAttr = elt.Attributes["class"];
         if (classAttr != null)
         {
             var className = " " + classAttr.NodeValue + " ";
             if (className.Contains(" " + PageContainerClass + " "))
             {
                 // Click is inside a page element: can succeed. But it's not this one.
                 gotPageElt = true;
                 continue;
             }
             if (className.Contains(" " + ClassForGridItem + " "))
             {
                 if (!gotPageElt)
                     return null; // clicked somewhere in a grid, but not actually on the page: intended page may be ambiguous.
                 var id = elt.Attributes["id"].NodeValue;
                 IPage page;
                 _pageMap.TryGetValue(id, out page);
                 return page;
             }
         }
     }
     return null;
 }
Exemple #38
0
 public void SetEndAfter(GeckoNode node)
 {
     DomRange.SetEndAfter((nsIDOMNode)node.DomObject);
 }
Exemple #39
0
 public GeckoNode ExtractContents()
 {
     return(GeckoNode.Create(DomRange.ExtractContents()));
 }
Exemple #40
0
 public void InsertNode(GeckoNode newNode)
 {
     DomRange.InsertNode((nsIDOMNode)newNode.DomObject);
 }
Exemple #41
0
		public GeckoNode RemoveChild(GeckoNode node)
		{
			if (node == null)
				throw new ArgumentNullException("node");

			_domNode.Instance.RemoveChild(node._domNode.Instance);
			return node;
		}
Exemple #42
0
 public bool IsPointInRange(GeckoNode node, int offset)
 {
     return DomRange.IsPointInRange(node.DomObject, offset);
 }
		public void SetEndBefore(GeckoNode node)
		{
			DomRange.SetEndBefore((nsIDOMNode)node.DomObject);
		}
Exemple #44
0
		public GeckoNode ReplaceChild(GeckoNode newChild, GeckoNode oldChild)
		{
			if (newChild == null)
				throw new ArgumentNullException("newChild");
			if (oldChild == null)
				throw new ArgumentNullException("oldChild");

			_domNode.Instance.ReplaceChild(newChild._domNode.Instance, oldChild._domNode.Instance);
			return newChild;
		}
Exemple #45
0
 /// <summary>
 /// Returns whether the specified node is part of the selection.
 /// </summary>
 /// <param name="node"></param>
 /// <param name="partlyContained">True if the function should return true when some part of the node is contained with the selection; when false, the function only returns true when the entire node is contained within the selection.</param>
 /// <returns></returns>
 public bool ContainsNode(GeckoNode node, bool partlyContained)
 {
     return(Selection.ContainsNode((nsIDOMNode)node.DomObject, partlyContained));
 }
Exemple #46
0
 public void SetEnd(GeckoNode node, int offset)
 {
     DomRange.SetEnd((nsIDOMNode)node.DomObject, offset);
 }
Exemple #47
0
 /// <summary>
 /// Extends the selection by moving the selection end to the specified node and offset, preserving the selection begin position. The new selection end result will always be from the anchorNode to the new focusNode, regardless of direction.
 /// </summary>
 /// <param name="parentNode">The node where the selection will be extended to.</param>
 /// <param name="offset">Where in node to place the offset in the new selection end.</param>
 public void Extend(GeckoNode parentNode, int offset)
 {
     Selection.Extend((nsIDOMNode)parentNode.DomObject, offset);
 }
		public void SetEndAfter(GeckoNode node)
		{
			DomRange.SetEndAfter((nsIDOMNode)node.DomObject);
		}
Exemple #49
0
 /// <summary>
 /// Adds all children of the specified node to the selection.
 /// </summary>
 /// <param name="parentNode"></param>
 public void SelectAllChildren(GeckoNode parentNode)
 {
     Selection.SelectAllChildren((nsIDOMNode)parentNode.DomObject);
 }
		/// <summary>
		/// Collapses the selection to a single point, at the specified offset in the given DOM node. When the selection is collapsed, and the content is focused and editable, the caret will blink there.
		/// </summary>
		/// <param name="parentNode"></param>
		/// <param name="offset"></param>
		public void Collapse(GeckoNode parentNode, int offset)
		{
			_selection.Instance.Collapse(parentNode.DomObject, offset);
		}
Exemple #51
0
 public void SetEndBefore(GeckoNode node)
 {
     DomRange.SetEndBefore((nsIDOMNode)node.DomObject);
 }
		/// <summary>
		/// Extends the selection by moving the selection end to the specified node and offset, preserving the selection begin position. The new selection end result will always be from the anchorNode to the new focusNode, regardless of direction.
		/// </summary>
		/// <param name="parentNode">The node where the selection will be extended to.</param>
		/// <param name="offset">Where in node to place the offset in the new selection end.</param>
		public void Extend(GeckoNode parentNode, int offset)
		{
			_selection.Instance.Extend(parentNode.DomObject, offset);
		}
Exemple #53
0
 public void SelectNodeContents(GeckoNode node)
 {
     DomRange.SelectNodeContents((nsIDOMNode)node.DomObject);
 }
		/// <summary>
		/// Returns whether the specified node is part of the selection.
		/// </summary>
		/// <param name="node"></param>
		/// <param name="partlyContained">True if the function should return true when some part of the node is contained with the selection; when false, the function only returns true when the entire node is contained within the selection.</param>
		/// <returns></returns>
		public bool ContainsNode(GeckoNode node, bool partlyContained)
		{
			return _selection.Instance.ContainsNode(node.DomObject, partlyContained);
		}
Exemple #55
0
 public GeckoNode CloneContents()
 {
     return(GeckoNode.Create(DomRange.CloneContents()));
 }
		/// <summary>
		/// Adds all children of the specified node to the selection.
		/// </summary>
		/// <param name="parentNode"></param>
		public void SelectAllChildren(GeckoNode parentNode)
		{
			_selection.Instance.SelectAllChildren(parentNode.DomObject);
		}
Exemple #57
0
 public void SurroundContents(GeckoNode newParent)
 {
     DomRange.SurroundContents((nsIDOMNode)newParent.DomObject);
 }
        public GeckoNode InsertBefore(GeckoNode newChild, GeckoNode before)
        {
            if (newChild == null)
                throw new ArgumentNullException("newChild");
            if (before == null)
                throw new ArgumentNullException("before");

            _DomObject.InsertBefore(newChild._DomObject, before._DomObject);
            return newChild;
        }
        public GeckoNode RemoveChild(GeckoNode node)
        {
            if (node == null)
                throw new ArgumentNullException("node");

            _DomObject.RemoveChild(node._DomObject);
            return node;
        }
		/// <summary>
		/// Adds all children of the specified node to the selection.
		/// </summary>
		/// <param name="parentNode"></param>
		public void SelectAllChildren(GeckoNode parentNode)
		{
			Selection.SelectAllChildren((nsIDOMNode)parentNode.DomObject);
		}