コード例 #1
0
        public string toDataURLAs(string mimeType, string encoderOptions)
        {
            var retval = new nsAString();

            DOMHTMLElement.ToDataURLAs(new nsAString(mimeType), new nsAString(encoderOptions), retval);
            return(retval.ToString());
        }
コード例 #2
0
        public string toDataURLAs(string mimeType, string encoderOptions)
        {
            nsAString result = new nsAString();

            DOMHTMLElement.toDataURLAs(new nsAString(mimeType), new nsAString(encoderOptions), result);
            return(result.ToString());
        }
コード例 #3
0
        public string toDataURL()
        {
            var retval = new nsAString();

            DOMHTMLElement.ToDataURL(null, null, retval);
            return(retval.ToString());
        }
コード例 #4
0
		public void SetData_ToEmptyString_ToStringReturnsEmptyString()
		{
			var objectUnderTest = new nsAString();
			objectUnderTest.SetData(String.Empty);

			Assert.AreEqual(String.Empty, objectUnderTest.ToString());
		}
コード例 #5
0
		public void SetData_ToTestValue_ToStringReturnsTestValue()
		{
			var objectUnderTest = new nsAString();
			objectUnderTest.SetData("hello world");

			Assert.AreEqual("hello world", objectUnderTest.ToString());
		}
コード例 #6
0
ファイル: XPathResult.cs プロジェクト: git-thinh/limada
 public string GetStringValue()
 {
     using (var str = new nsAString()) {
         xpathResult.GetStringValueAttribute(str);
         return(str.ToString());
     }
 }
コード例 #7
0
		public void SetData_ToNull_ToStringReturnsNull()
		{
			var objectUnderTest = new nsAString();
			objectUnderTest.SetData(null);

			Assert.AreEqual(null, objectUnderTest.ToString());
		}
コード例 #8
0
 public string toDataURL(string type)
 {
     using (nsAString retval = new nsAString(), param = new nsAString(type))
     {
         DOMHTMLElement.ToDataURL(param, null, 2, retval);
         return retval.ToString();
     }
 }
コード例 #9
0
 /// <summary>
 /// Function to get metadata associated with the window's current document
 /// @param aName the name of the metadata.  This should be all lowercase.
 /// @return the value of the metadata, or the empty string if it's not set
 ///
 /// Will throw a DOM security error if called without UniversalXPConnect
 /// privileges.
 /// </summary>
 public string GetDocumentMetadata(string name)
 {
     using (nsAString tempName = new nsAString(name), ret = new nsAString())
     {
         _windowUtils.GetDocumentMetadata(tempName, ret);
         return(ret.ToString());
     }
 }
コード例 #10
0
        public void SetData_ToTestValue_ToStringReturnsTestValue()
        {
            var objectUnderTest = new nsAString();

            objectUnderTest.SetData("hello world");

            Assert.AreEqual("hello world", objectUnderTest.ToString());
        }
コード例 #11
0
 public void OutputToString_OutputEditableBody_BodyAndContentWrittenToString()
 {
     using (nsAString formatType = new nsAString("text/html"), retval = new nsAString())
     {
         _editor.OutputToString(formatType, 8, retval);
         Assert.AreEqual("<body contenteditable=\"true\"><div>hello world</div></body>", retval.ToString());
     }
 }
コード例 #12
0
 public string toDataURL(string type)
 {
     using (nsAString retval = new nsAString(), param = new nsAString(type))
     {
         DOMHTMLElement.ToDataURL(param, null, 2, retval);
         return(retval.ToString());
     }
 }
コード例 #13
0
        public void SetData_ToNull_ToStringReturnsNull()
        {
            var objectUnderTest = new nsAString();

            objectUnderTest.SetData(null);

            Assert.AreEqual(null, objectUnderTest.ToString());
        }
コード例 #14
0
        public void SetData_ToEmptyString_ToStringReturnsEmptyString()
        {
            var objectUnderTest = new nsAString();

            objectUnderTest.SetData(String.Empty);

            Assert.AreEqual(String.Empty, objectUnderTest.ToString());
        }
コード例 #15
0
		public string ToDataURL(string type)
		{
			using (var context = new AutoJSContext(GlobalJSContextHolder.BackstageJSContext))
			using (nsAString retval = new nsAString(), param = new nsAString(type))
			{
				JsVal js = default(JsVal);
				DOMHTMLElement.ToDataURL(param, ref js, context.ContextPointer, retval);
				return retval.ToString();
			}
		}
コード例 #16
0
 public string toDataURL(string type)
 {
     using (nsAString retval = new nsAString(), param = new nsAString(type))
     {
         var instance = Xpcom.CreateInstance<nsIVariant>(Contracts.Variant);
         DOMHTMLElement.ToDataURL(param, instance, 2, retval);
         Marshal.ReleaseComObject(instance);
         return retval.ToString();
     }
 }
コード例 #17
0
 public string toDataURL(string type)
 {
     using (nsAString retval = new nsAString(), param = new nsAString(type))
     {
         var instance = Xpcom.CreateInstance <nsIVariant>(Contracts.Variant);
         DOMHTMLElement.ToDataURL(param, instance, 2, retval);
         Marshal.ReleaseComObject(instance);
         return(retval.ToString());
     }
 }
コード例 #18
0
 public string ToDataURL(string type)
 {
     using (var context = new AutoJSContext(GlobalJSContextHolder.BackstageJSContext))
         using (nsAString retval = new nsAString(), param = new nsAString(type))
         {
             JsVal js = default(JsVal);
             DOMHTMLElement.ToDataURL(param, ref js, context.ContextPointer, retval);
             return(retval.ToString());
         }
 }
コード例 #19
0
        public string GetUsagesString(bool localOnly, ref uint verified)
        {
            string ret = null;

            using (nsAString str = new nsAString())
            {
                _cert.Instance.GetUsagesString(localOnly, ref verified, str);
                ret = str.ToString();
            }
            return(ret);
        }
コード例 #20
0
 public string toDataURLAs(string mimeType, string encoderOptions)
 {
     var retval = new nsAString();
     DOMHTMLElement.ToDataURLAs(new nsAString(mimeType), new nsAString(encoderOptions), retval);
     return retval.ToString();
 }
コード例 #21
0
		public override string ToString()
		{
			using (nsAString retval = new nsAString())
			{
				DomRange.ToString(retval);
				return retval.ToString();
			}
		}
コード例 #22
0
        public void ConstructorWithString_ToTestValue_ToStringReturnsTestValue()
        {
            var objectUnderTest = new nsAString("Hello world");

            Assert.AreEqual("Hello world", objectUnderTest.ToString());
        }
コード例 #23
0
		public void ConstructorWithString_ToTestValue_ToStringReturnsTestValue()
		{
			var objectUnderTest = new nsAString("Hello world");
			Assert.AreEqual("Hello world", objectUnderTest.ToString());
		}
コード例 #24
0
 /// <summary>
 /// Function to get metadata associated with the window's current document
 /// @param aName the name of the metadata.  This should be all lowercase.
 /// @return the value of the metadata, or the empty string if it's not set
 ///
 /// Will throw a DOM security error if called without UniversalXPConnect
 /// privileges.
 /// </summary>		
 public string GetDocumentMetadata(string name)
 {
     using (nsAString tempName = new nsAString(name), ret = new nsAString())
     {
         _windowUtils.GetDocumentMetadata(tempName, ret);
         return ret.ToString();
     }
 }
コード例 #25
0
        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.GetTargetNodeAttribute() == 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(); };

                GeckoDomDocument doc = GeckoDomDocument.CreateDomDocumentWraper(info.GetTargetNodeAttribute().GetOwnerDocumentAttribute());

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

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

                MenuItem mnuOpenInSystemBrowser = new MenuItem("View In System Browser");//nice for debugging with firefox/firebug
                mnuOpenInSystemBrowser.Enabled = !string.IsNullOrEmpty(viewSourceUrl);
                mnuOpenInSystemBrowser.Click += delegate { ViewInSystemBrowser(viewSourceUrl); };

                string properties = (doc != null && doc.Uri == Document.Uri) ? "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(mnuOpenInSystemBrowser);
                menu.MenuItems.Add(mnuProperties);
            }

            // get image urls
            Uri backgroundImageSrc = null, imageSrc = null;
            nsIURI src;
            try
            {
                src = info.GetBackgroundImageSrcAttribute();
                backgroundImageSrc = new Uri(new nsURI(src).Spec);
            }
            catch (COMException comException)
            {
                if ((comException.ErrorCode & 0xFFFFFFFF) != 0x80004005)
                    throw comException;
            }

            try
            {
                src = info.GetImageSrcAttribute();
                if (src != null)
                    imageSrc = new Uri(new nsURI(src).Spec);
            }
            catch (COMException comException)
            {
                if ((comException.ErrorCode & 0xFFFFFFFF) != 0x80004005)
                    throw comException;
            }

            // 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;
            try
            {
                using (nsAString str = new nsAString())
                {
                    info.GetAssociatedLinkAttribute(str);
                    associatedLink = str.ToString();
                }
            }
            catch (COMException comException) { }

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

            //OnShowContextMenu(e);

            //if (e.ContextMenu != null && e.ContextMenu.MenuItems.Count > 0)
            //{
            //    e.ContextMenu.Show(this, e.Location);
            //}
        }
コード例 #26
0
 public void OutputToString_OutputEditableBody_BodyAndContentWrittenToString()
 {
     using (nsAString formatType = new nsAString("text/html"), retval = new nsAString())
     {
         _editor.OutputToString(formatType, 8, retval);
         Assert.AreEqual("<body contenteditable=\"true\"><div>hello world</div></body>", retval.ToString());
     }
 }
コード例 #27
0
 public string toDataURL()
 {
     var retval = new nsAString();
     DOMHTMLElement.ToDataURL(null, null, retval);
     return retval.ToString();
 }
コード例 #28
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();
        }
コード例 #29
0
		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.GetTargetNodeAttribute() == 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(); };

				GeckoDomDocument doc = GeckoDomDocument.CreateDomDocumentWraper(info.GetTargetNodeAttribute().GetOwnerDocumentAttribute());

				string viewSourceUrl = (doc == null) ? null : Convert.ToString(doc.Uri);
				
				MenuItem mnuViewSource = new MenuItem("View Source");
				mnuViewSource.Enabled = !string.IsNullOrEmpty(viewSourceUrl);
				mnuViewSource.Click += delegate { ViewSource(viewSourceUrl); };

				MenuItem mnuOpenInSystemBrowser = new MenuItem("View In System Browser");//nice for debugging with firefox/firebug
				mnuOpenInSystemBrowser.Enabled = !string.IsNullOrEmpty(viewSourceUrl);
				mnuOpenInSystemBrowser.Click += delegate { ViewInSystemBrowser(viewSourceUrl); };


				string properties = (doc != null && doc.Uri == Document.Uri) ? "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(mnuOpenInSystemBrowser);
				menu.MenuItems.Add(mnuProperties);
			}

			// get image urls
			Uri backgroundImageSrc = null, imageSrc = null;
			nsIURI src;
			try
			{
				src = info.GetBackgroundImageSrcAttribute();
				backgroundImageSrc = src.ToUri();
				Marshal.ReleaseComObject( src );
			}
			catch (COMException comException)
			{
				if ((comException.ErrorCode & 0xFFFFFFFF) != 0x80004005)
					throw comException;
			}

			try
			{
				src = info.GetImageSrcAttribute();
				if ( src != null )
				{
					imageSrc = src.ToUri();
					Marshal.ReleaseComObject( src );
				}
			}
			catch (COMException comException)
			{
				if ((comException.ErrorCode & 0xFFFFFFFF) != 0x80004005)
					throw comException;
			}
			
			// 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;
			try
			{
				using (nsAString str = new nsAString())
				{
					info.GetAssociatedLinkAttribute(str);
					associatedLink = str.ToString();
				}
			}
			catch (COMException comException) { }			
			
			GeckoContextMenuEventArgs e = new GeckoContextMenuEventArgs(
				PointToClient(MousePosition), menu, associatedLink, backgroundImageSrc, imageSrc,
				GeckoNode.Create(Xpcom.QueryInterface<nsIDOMNode>(info.GetTargetNodeAttribute()))
				);
			
			OnShowContextMenu(e);
			
			if (e.ContextMenu != null && e.ContextMenu.MenuItems.Count > 0)
			{
#if GTK
				// When using GTK we can't use SWF to display the context menu: SWF displays
				// the context menu and then tries to track the mouse so that it knows when to
				// close the context menu. However, GTK intercepts the mouse click before SWF gets
				// it, so the menu never closes. Instead we display a GTK menu and translate
				// the SWF menu items into Gtk.MenuItems.
				// TODO: currently this code only handles text menu items. Would be nice to also
				// translate images etc.
				var popupMenu = new Gtk.Menu();

				foreach (MenuItem swfMenuItem in e.ContextMenu.MenuItems)
				{
					var gtkMenuItem = new Gtk.MenuItem(swfMenuItem.Text);
					gtkMenuItem.Sensitive = swfMenuItem.Enabled;
					MenuItem origMenuItem = swfMenuItem;
					gtkMenuItem.Activated += (sender, ev) => origMenuItem.PerformClick();
					popupMenu.Append(gtkMenuItem);
				}
				popupMenu.ShowAll();
				popupMenu.Popup();
#else
				e.ContextMenu.Show(this, e.Location);
#endif
			}
		}