Exemple #1
0
        /// <summary>
        /// Get the value of a specfic Css Property.
        /// </summary>
        public string GetPropertyValue(string propertyName)
        {
            var retval = new nsAString();

            StyleDelcaration.GetPropertyValue(new nsAString(propertyName), retval);
            return(retval.ToString());
        }
 public string SubstringData(uint offset, uint count)
 {
     using (nsAString retval = new nsAString())
     {
         DomComment.SubstringData(offset, count, retval);
         return retval.ToString();
     }
 }
Exemple #3
0
		public static string Get(StringAttributeUnicode getter)
		{
			using (nsAString str = new nsAString())
			{
				getter(str);
				return str.ToString();
			}
		}
Exemple #4
0
 public static string Get(StringAttributeUnicode getter)
 {
     using (nsAString str = new nsAString())
     {
         getter(str);
         return(str.ToString());
     }
 }
Exemple #5
0
 /// <summary>
 /// Get property name by index
 /// </summary>
 public string this[int index]
 {
     get {
         var retval = new nsAString();
         StyleDelcaration.Item((uint)index, retval);
         return(retval.ToString());
     }
 }
Exemple #6
0
 public override string ToString()
 {
     using (nsAString retval = new nsAString())
     {
         DomRange.ToString(retval);
         return(retval.ToString());
     }
 }
Exemple #7
0
 public string SubstringData(uint offset, uint count)
 {
     using (nsAString retval = new nsAString())
     {
         DomComment.SubstringData(offset, count, retval);
         return(retval.ToString());
     }
 }
Exemple #8
0
        /// <summary>
        /// Gets the value of an attribute on this element with the specified name.
        /// </summary>
        /// <param name="attributeName"></param>
        /// <returns></returns>
        public string GetAttribute(string attributeName)
        {
            if (string.IsNullOrEmpty(attributeName))
            {
                throw new ArgumentException("attributeName");
            }

            var retval = new nsAString();

            DomElement.GetAttribute(new nsAString(attributeName), retval);
            return(retval.ToString());
        }
Exemple #9
0
 /// <summary>
 /// Returns the medium at the given index in the list.
 /// </summary>
 /// <param name="index"></param>
 /// <returns></returns>
 public string this[int index]
 {
     get
     {
         if (index < 0 || index >= Count)
         {
             throw new ArgumentOutOfRangeException("index");
         }
         var retval = new nsAString();
         MediaList.Item((uint)index, retval);
         return(retval.ToString());
     }
 }
Exemple #10
0
        /// <summary>
        /// Returns the medium at the given index in the list.
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public string this[int index]
        {
            get
            {
                if (index < 0 || index >= Count)
                {
                    throw new ArgumentOutOfRangeException("index");
                }

                using (nsAString str = new nsAString())
                {
                    MediaList.Item(index, str);
                    return(str.ToString());
                }
            }
        }
Exemple #11
0
        /// <summary>
        /// Gets the value of an attribute on this element with the specified name and namespace.
        /// </summary>
        /// <param name="attributeName"></param>
        /// <returns></returns>
        public string GetAttributeNS(string namespaceUri, string attributeName)
        {
            if (string.IsNullOrEmpty(namespaceUri))
            {
                return(GetAttribute(attributeName));
            }

            if (string.IsNullOrEmpty(attributeName))
            {
                throw new ArgumentException("attributeName");
            }
            nsAString retval = new nsAString();

            DomElement.GetAttributeNS(new nsAString(namespaceUri), new nsAString(attributeName), retval);
            return(retval.ToString());
        }
        void nsIDOMEventListener.HandleEvent(nsIDOMEvent e)
        {
            string type;
            using (nsAString str = new nsAString())
            {
                e.GetType(str);
                type = str.ToString();
            }

            GeckoDomEventArgs ea = null;

            switch (type)
            {
                case "keydown": OnDomKeyDown((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;
                case "keyup": OnDomKeyUp((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;

                case "mousedown": OnDomMouseDown((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseup": OnDomMouseUp((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mousemove": OnDomMouseMove((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseover": OnDomMouseOver((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseout": OnDomMouseOut((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "click": OnDomClick(ea = new GeckoDomEventArgs(e)); break;
                case "submit": OnDomSubmit(ea = new GeckoDomEventArgs(e)); break;
            }

            if (ea != null && ea.Cancelable && ea.Handled)
                e.PreventDefault();
        }
        void nsIContextMenuListener2.OnShowContextMenu(uint aContextFlags, nsIContextMenuInfo info)
        {
            // if we don't have a target node, we can't do anything by default.  this happens in XUL forms (i.e. about:config)
            if (info.GetTargetNode() == null)
                return;

            ContextMenu menu = new ContextMenu();

            // no default items are added when the context menu is disabled
            if (!this.NoDefaultContextMenu)
            {
                List<MenuItem> optionals = new List<MenuItem>();

                if (this.CanUndo || this.CanRedo)
                {
                    optionals.Add(new MenuItem("Undo", delegate { Undo(); }));
                    optionals.Add(new MenuItem("Redo", delegate { Redo(); }));

                    optionals[0].Enabled = this.CanUndo;
                    optionals[1].Enabled = this.CanRedo;
                }
                else
                {
                    optionals.Add(new MenuItem("Back", delegate { GoBack(); }));
                    optionals.Add(new MenuItem("Forward", delegate { GoForward(); }));

                    optionals[0].Enabled = this.CanGoBack;
                    optionals[1].Enabled = this.CanGoForward;
                }

                optionals.Add(new MenuItem("-"));

                if (this.CanCopyImageContents)
                    optionals.Add(new MenuItem("Copy Image Contents", delegate { CopyImageContents(); }));

                if (this.CanCopyImageLocation)
                    optionals.Add(new MenuItem("Copy Image Location", delegate { CopyImageLocation(); }));

                if (this.CanCopyLinkLocation)
                    optionals.Add(new MenuItem("Copy Link Location", delegate { CopyLinkLocation(); }));

                if (this.CanCopySelection)
                    optionals.Add(new MenuItem("Copy Selection", delegate { CopySelection(); }));

                MenuItem mnuSelectAll = new MenuItem("Select All");
                mnuSelectAll.Click += delegate { SelectAll(); };

                GeckoDocument doc = GeckoDocument.Create((nsIDOMHTMLDocument)info.GetTargetNode().GetOwnerDocument());

                string viewSourceUrl = (doc == null) ? null : Convert.ToString(doc.Url);

                MenuItem mnuViewSource = new MenuItem("View Source");
                mnuViewSource.Enabled = !string.IsNullOrEmpty(viewSourceUrl);
                mnuViewSource.Click += delegate { ViewSource(viewSourceUrl); };

                string properties = (doc != null && doc.Url == Document.Url) ? "Page Properties" : "IFRAME Properties";

                MenuItem mnuProperties = new MenuItem(properties);
                mnuProperties.Enabled = doc != null;
                mnuProperties.Click += delegate { ShowPageProperties(doc); };

                menu.MenuItems.AddRange(optionals.ToArray());
                menu.MenuItems.Add(mnuSelectAll);
                menu.MenuItems.Add("-");
                menu.MenuItems.Add(mnuViewSource);
                menu.MenuItems.Add(mnuProperties);
            }

            // get image urls
            Uri backgroundImageSrc = null, imageSrc = null;
            nsIURI src;

            if (info.GetBackgroundImageSrc(out src) == 0)
            {
                backgroundImageSrc = new Uri(new nsURI(src).Spec);
            }

            if (info.GetImageSrc(out src) == 0)
            {
                imageSrc = new Uri(new nsURI(src).Spec);
            }

            // get associated link.  note that this needs to be done manually because GetAssociatedLink returns a non-zero
            // result when no associated link is available, so an exception would be thrown by nsString.Get()
            string associatedLink = null;
            using (nsAString str = new nsAString())
            {
                if (info.GetAssociatedLink(str) == 0)
                {
                    associatedLink = str.ToString();
                }
            }

            GeckoContextMenuEventArgs e = new GeckoContextMenuEventArgs(
                PointToClient(MousePosition), menu, associatedLink, backgroundImageSrc, imageSrc,
                GeckoNode.Create(Xpcom.QueryInterface<nsIDOMNode>(info.GetTargetNode()))
                );

            OnShowContextMenu(e);

            if (e.ContextMenu != null && e.ContextMenu.MenuItems.Count > 0)
            {
                e.ContextMenu.Show(this, e.Location);
            }
        }
 public DOMJSONStringEventArgs(nsAString JSEventName, nsAString strJSONString)
 {
     this.strJSEventName = JSEventName.ToString();
     this.strJSONString  = strJSONString.ToString();
 }
 public DOMJSONStringEventArgs(nsAString JSEventName, nsAString strJSONString)
 {
     this.strJSEventName = JSEventName.ToString();
     this.strJSONString = strJSONString.ToString();
 }
        void nsIDOMEventListener.HandleEvent(nsIDOMEvent e)
        {
            string type;
            using (nsAString str = new nsAString())
            {
                e.GetTypeAttribute(str);
                type = str.ToString();
            }

            GeckoDomEventArgs ea = null;

            switch (type)
            {
                case "keydown": OnDomKeyDown((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;
                case "keyup": OnDomKeyUp((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;
                case "keypress": OnDomKeyPress((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;

                case "mousedown": OnDomMouseDown((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseup": OnDomMouseUp((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mousemove": OnDomMouseMove((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseover": OnDomMouseOver((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseout": OnDomMouseOut((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "click": OnDomClick(ea = new GeckoDomEventArgs(e)); break;
                case "submit": OnDomSubmit(ea = new GeckoDomEventArgs(e)); break;
                case "compositionstart": OnDomCompositionStart(ea = new GeckoDomEventArgs(e)); break;
                case "compositionend": OnDomCompositionEnd(ea = new GeckoDomEventArgs(e)); break;
                case "contextmenu": OnDomContextMenu((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "DOMMouseScroll": OnDomMouseScroll((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "focus": OnDomFocus(ea = new GeckoDomEventArgs(e)); break;
            }

            if (ea != null && ea.Cancelable && ea.Handled)
                e.PreventDefault();
        }
		void nsIDOMEventListener.HandleEvent(nsIDOMEvent e)
		{
			string type;
			using (nsAString str = new nsAString())
			{
				e.GetType(str);
				type = str.ToString();
			}
			
			switch (type)
			{
				case "keydown": OnDomKeyDown(new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e)); break;
				case "keyup": OnDomKeyUp(new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e)); break;
				
				case "mousedown": OnDomMouseDown(new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e)); break;
				case "mouseup": OnDomMouseUp(new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e)); break;
				case "mousemove": OnDomMouseMove(new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e)); break;
				case "mouseover": OnDomMouseOver(new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e)); break;
				case "mouseout": OnDomMouseOut(new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e)); break;
				
				case "submit":
					//TEMP: disable this because it's causing crashes
					//MessageBox.Show("Form submission has been disabled to improve stability in this version.", "Gecko", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
					
					//e.PreventDefault();
					//e.StopPropagation();
					break;
			}
		}
 public override string ToString()
 {
     using (nsAString retval = new nsAString())
     {
         DomRange.ToString(retval);
         return retval.ToString();
     }
 }
        void nsIDOMEventListener.HandleEvent(nsIDOMEvent e)
        {
            string type;
            using (nsAString str = new nsAString())
            {
                e.GetTypeAttribute(str);
                type = str.ToString();
            }

            GeckoDomEventArgs ea = null;

            switch (type)
            {
                case "keydown": OnDomKeyDown((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;
                case "keyup": OnDomKeyUp((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;
                case "keypress": OnDomKeyPress((GeckoDomKeyEventArgs)(ea = new GeckoDomKeyEventArgs((nsIDOMKeyEvent)e))); break;

                case "mousedown": OnDomMouseDown((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseup": OnDomMouseUp((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mousemove": OnDomMouseMove((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseover": OnDomMouseOver((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "mouseout": OnDomMouseOut((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "click": OnDomClick(ea = new GeckoDomEventArgs(e)); break;
                case "dblclick": OnDomDoubleClick(ea = new GeckoDomEventArgs(e)); break;
                case "submit": OnDomSubmit(ea = new GeckoDomEventArgs(e)); break;
                case "compositionstart": OnDomCompositionStart(ea = new GeckoDomEventArgs(e)); break;
                case "compositionend": OnDomCompositionEnd(ea = new GeckoDomEventArgs(e)); break;
                case "contextmenu": OnDomContextMenu((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "DOMMouseScroll": OnDomMouseScroll((GeckoDomMouseEventArgs)(ea = new GeckoDomMouseEventArgs((nsIDOMMouseEvent)e))); break;
                case "focus": OnDomFocus(ea = new GeckoDomEventArgs(e)); break;
                case "load": OnLoad(ea = new GeckoDomEventArgs(e)); break;
                case "change": OnDomContentChanged(ea = new GeckoDomEventArgs(e)); break;

                default:
                    Action<string> action;
                    if(_messageEventListeners.TryGetValue(type, out action))
                    {

                        action.Invoke(new GeckoDomMessageEventArgs((nsIDOMMessageEvent)e).Message);
                    }
                    break;
            }

            if (ea != null && ea.Cancelable && ea.Handled)
                e.PreventDefault();
        }