/// <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);
 }
Esempio n. 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)));
        }
Esempio n. 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;
 }
Esempio n. 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);
        }
Esempio n. 9
0
        public GeckoNode RemoveChild(GeckoNode node)
        {
            if (node == null)
            {
                throw new ArgumentNullException(nameof(node));
            }

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

            _domNode.Instance.AppendChild(node._domNode.Instance);
            return(node);
        }
Esempio n. 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);
        }
Esempio n. 15
0
        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);
        }
Esempio n. 16
0
        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);
        }
Esempio n. 17
0
 public bool IsPointInRange(GeckoNode node, int offset)
 {
     return(DomNsRange.IsPointInRange(node.DomObject, offset));
 }
Esempio n. 18
0
 public void SelectNodeContents(GeckoNode node)
 {
     _range.Instance.SelectNodeContents((nsIDOMNode)node.DomObject);
 }
Esempio n. 19
0
		public void InsertNode(GeckoNode newNode)
		{
			DomRange.InsertNode((nsIDOMNode)newNode.DomObject);
		}
Esempio n. 20
0
		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));
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
 public void InsertNode(GeckoNode newNode)
 {
     _range.Instance.InsertNode(newNode.DomObject);
 }
Esempio n. 24
0
 public int CompareDocumentPosition(GeckoNode other)
 {
     return(_node.Value.CompareDocumentPosition(other.DomObject));
 }
Esempio n. 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;
		}
Esempio n. 26
0
 public void SurroundContents(GeckoNode newParent)
 {
     _range.Instance.SurroundContents(newParent.DomObject);
 }
Esempio n. 27
0
 public void SetStartBefore(GeckoNode node)
 {
     _range.Instance.SetStartBefore(node.DomObject);
 }
Esempio n. 28
0
 public void SetStartAfter(GeckoNode node)
 {
     _range.Instance.SetStartAfter(node.DomObject);
 }
Esempio n. 29
0
 public void SetStart(GeckoNode node, int offset)
 {
     _range.Instance.SetStart(node.DomObject, offset);
 }
Esempio n. 30
0
		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);
 }
Esempio n. 33
0
 public GeckoNode CloneNode(bool deep)
 {
     return(GeckoNode.Create(_domNode.Instance.CloneNode(deep, 1)));
 }
Esempio n. 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);
 }
Esempio n. 36
0
		public void SelectNodeContents(GeckoNode node)
		{
			DomRange.SelectNodeContents((nsIDOMNode)node.DomObject);
		}
Esempio n. 37
0
 /// <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;
 }
Esempio n. 38
0
 public void SetEndAfter(GeckoNode node)
 {
     DomRange.SetEndAfter((nsIDOMNode)node.DomObject);
 }
Esempio n. 39
0
 public GeckoNode ExtractContents()
 {
     return(GeckoNode.Create(DomRange.ExtractContents()));
 }
Esempio n. 40
0
 public void InsertNode(GeckoNode newNode)
 {
     DomRange.InsertNode((nsIDOMNode)newNode.DomObject);
 }
Esempio n. 41
0
		public GeckoNode RemoveChild(GeckoNode node)
		{
			if (node == null)
				throw new ArgumentNullException("node");

			_domNode.Instance.RemoveChild(node._domNode.Instance);
			return node;
		}
Esempio n. 42
0
 public bool IsPointInRange(GeckoNode node, int offset)
 {
     return DomRange.IsPointInRange(node.DomObject, offset);
 }
Esempio n. 43
0
		public void SetEndBefore(GeckoNode node)
		{
			DomRange.SetEndBefore((nsIDOMNode)node.DomObject);
		}
Esempio n. 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;
		}
Esempio n. 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));
 }
Esempio n. 46
0
 public void SetEnd(GeckoNode node, int offset)
 {
     DomRange.SetEnd((nsIDOMNode)node.DomObject, offset);
 }
Esempio n. 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);
 }
Esempio n. 48
0
		public void SetEndAfter(GeckoNode node)
		{
			DomRange.SetEndAfter((nsIDOMNode)node.DomObject);
		}
Esempio n. 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);
		}
Esempio n. 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);
		}
Esempio n. 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);
		}
Esempio n. 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);
		}
Esempio n. 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;
        }
Esempio n. 60
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);
		}