Exemple #1
0
        protected void DisplayElements(GeckoElement g)
        {
            while (g != null)
            {
                Console.WriteLine("tag = {0} value = {1}", g.TagName, g.TextContent);
                DisplayElements(g.FirstChild as GeckoElement);
                g = (g.NextSibling as GeckoElement);
            }

        }
Exemple #2
0
 protected void ModifyElements(GeckoElement element, string tagName, Action<GeckoElement> mod)
 {
     while (element != null)
     {
         if (element.TagName == tagName)
         {
             mod(element);
         }
         ModifyElements(element.FirstChild as GeckoElement, tagName, mod);
         element = (element.NextSibling as GeckoElement);
     }
 }
        /// <summary>
        /// An example event handler for the DomClick event.
        /// Prevents a link click from navigating.
        /// </summary>
        void StopLinksNavigating(object sender, GeckoDomEventArgs e)
        {
            if (sender != null && e != null && e.Target != null && e.Target.TagName != null)
            {
                GeckoElement clicked = e.Target;

                // prevent clicking on Links from navigation to the
                if (clicked.TagName == "A")
                {
                    e.Handled = true;
                    MessageBox.Show(sender as IWin32Window, String.Format("You clicked on Link {0}", clicked.GetAttribute("href")));
                }
            }
        }
Exemple #4
0
        private static bool IsElementSplitLine(GeckoElement geckoElement, out int splitId)
        {
            splitId = -1;
            var geckoDivElement = geckoElement as GeckoDivElement;

            if (geckoDivElement != null && geckoDivElement.ClassName.StartsWith("split-line"))
            {
                string splitIdStr    = geckoDivElement.ClassName.Equals("split-line") ? geckoDivElement.Id : geckoDivElement.Parent.Id;
                string splitIdNumber = splitIdStr.Substring(Block.kSplitElementIdPrefix.Length);
                splitId = Int32.Parse(splitIdNumber);
                return(true);
            }
            return(false);
        }
Exemple #5
0
        protected void TestModifyingDom(GeckoWebBrowser browser)
        {
            GeckoElement g = browser.Document.DocumentElement;

            ModifyElements(g, "BODY", e =>
            {
                for (int i = 1; i < 4; ++i)
                {
                    var newElement         = g.OwnerDocument.CreateElement(String.Format("h{0}", i));
                    newElement.TextContent = "Geckofx added this text.";
                    g.InsertBefore(newElement, e);
                }
            });
        }
Exemple #6
0
        private void _okButton_Click(object sender, EventArgs e)
        {
            GeckoDocument doc = _browser.WebBrowser.Document;

            var          body = doc.GetElementsByTagName("body").First();
            GeckoElement div  = doc.CreateElement("div");

            div.Id = "output";
            body.AppendChild(div);

            _browser.RunJavaScript("gatherSettings()");

            FormData     = div.InnerHtml;
            DialogResult = DialogResult.OK;
            Close();
        }
Exemple #7
0
        internal static GeckoElement CreateGeckoElementWrapper(nsIDOMHTMLElement instance)
        {
            var            lowerTagName = nsString.Get(instance.GetTagNameAttribute).ToLower();
            GeckoClassDesc desc;

            if (_dictionary.TryGetValue(lowerTagName, out desc))
            {
                object HTMLElement = Xpcom.QueryInterface(instance, desc.InterfaceType.GUID);
                if (HTMLElement != null)
                {
                    GeckoElement e = desc.CreationMethod(HTMLElement);
                    return(e);
                }
            }
            return(null);
        }
        /// <summary>
        /// UI specific implementation extension method GetBoundingClientRect()
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static System.Windows.Int32Rect GetBoundingClientRectInt32(this GeckoElement element)
        {
            nsIDOMClientRect domRect = element.DOMElement.GetBoundingClientRect();

            if (domRect == null)
            {
                return(System.Windows.Int32Rect.Empty);
            }
            var r = new System.Windows.Int32Rect(
                ( int )domRect.GetLeftAttribute(),
                ( int )domRect.GetTopAttribute(),
                ( int )domRect.GetWidthAttribute(),
                ( int )domRect.GetHeightAttribute());

            return(r);
        }
        protected void HandleDomClick(object sender, GeckoDomEventArgs e)
        {
            if (sender == null || e == null || e.Target == null)
            {
                return;
            }

            GeckoElement parentTable = GetParentTable(e.Target);

            if (parentTable == null)
            {
                return;
            }

            GeckoNode onClick = parentTable.Attributes["onclick"];

            // The next two lines are needed to fix FWNX-725, but if they're not commented out, the
            // program silently disappears shortly after the TryAWordDlg dialog is closed *if this
            // method is ever invoked by clicking on the HTML control anywhere*.  Somehow, either
            // e.Target.Attributes["onclick"] or onClick.TextContent must set some state in the browser
            // that causes this horrendous behavior.
            //if (onClick == null)
            //	onClick = e.Target.Attributes["onclick"];
            if (onClick == null)
            {
                return;
            }

            var js = onClick.TextContent;

            if (js.Contains("JumpToToolBasedOnHvo"))
            {
                JumpToToolBasedOnHvo(Int32.Parse(GetParameterFromJavaScriptFunctionCall(js)));
            }
            if (js.Contains("ShowWordGrammarDetail") || js.Contains("ButtonShowWGDetails"))
            {
                ShowWordGrammarDetail(GetParameterFromJavaScriptFunctionCall(js));
            }
            if (js.Contains("TryWordGrammarAgain"))
            {
                TryWordGrammarAgain(GetParameterFromJavaScriptFunctionCall(js));
            }
            if (js.Contains("GoToPreviousWordGrammarPage"))
            {
                GoToPreviousWordGrammarPage();
            }
        }
Exemple #10
0
 private void MakeEncashmentClick(GeckoElement clicked)
 {
     try {
         if (clicked.HasAttribute("id") && !clicked.HasAttribute("disabled"))
         {
             if (clicked.GetAttribute("id").Equals("next"))
             {
             }
             else if (clicked.GetAttribute("id").Equals("back"))
             {
                 Util.NavigateTo(_browser, CurrentWindow.Main);
             }
         }
     } catch (Exception exception) {
         Log.Error(exception);
     }
 }
Exemple #11
0
        /// <summary>
        /// UI specific implementation extension method GetBoundingClientRect()
        /// </summary>
        /// <param name="element"></param>
        /// <returns></returns>
        public static System.Drawing.Rectangle GetBoundingClientRect(this GeckoElement element)
        {
            nsIDOMClientRect domRect = element.DOMElement.GetBoundingClientRect();

            if (domRect == null)
            {
                return(Rectangle.Empty);
            }
            var r = new Rectangle(
                ( int )domRect.GetLeftAttribute(),
                ( int )domRect.GetTopAttribute(),
                ( int )domRect.GetWidthAttribute(),
                ( int )domRect.GetHeightAttribute());

            Marshal.ReleaseComObject(domRect);
            return(r);
        }
Exemple #12
0
 private void DependentClick(GeckoElement clicked)
 {
     try {
         if (clicked.HasAttribute("id"))
         {
             if (clicked.GetAttribute("id").Equals("back"))
             {
                 Util.NavigateTo(_browser, CurrentWindow.Main);
             }
             else
             {
                 _payment.id_uslugi = short.Parse(clicked.GetAttribute("id"));
                 Log.Debug(String.Format("Clicked service with id {0}", clicked.GetAttribute("id")));
                 Util.NavigateTo(_browser, CurrentWindow.EnterNumber);
             }
         }
     } catch (Exception exception) {
         Log.Error(exception);
     }
 }
Exemple #13
0
        private static GeckoElement GetImageNode(GeckoDomEventArgs ge)
        {
            GeckoElement imageElement = null;

            foreach (var n in ge.Target.Parent.ChildNodes)
            {
                if (n is GeckoElement && ((GeckoElement)n).TagName.ToLower() == "img")
                {
                    imageElement = (GeckoElement)n;
                    break;
                }
            }

            if (imageElement == null)
            {
                Debug.Fail("Could not find image element");
                return(null);
            }
            return(imageElement);
        }
Exemple #14
0
        void geckoWebBrowser1_DocumentCompleted(object sender, EventArgs e)
        {
            txt_Title.Text = "";

            GeckoDocument doc = geckoWebBrowser1.Document;

            titleElem = FindTagContainingText(doc, originalTitleContent);
            entryElem = FindTagContainingText(doc, originalBodyContent);


            if (titleElem != null && entryElem != null)
            {
                titleElem.InnerHtml = txt_Title.Text;
                entryElem.InnerHtml = txt_Content.Text;
            }
            geckoWebBrowser1.DocumentCompleted -= new EventHandler(geckoWebBrowser1_DocumentCompleted);

            txt_Title.Enabled   = true;
            txt_Content.Enabled = true;
        }
Exemple #15
0
        public bool setFieldValue(String cField, String cKeyValue)
        {
            GeckoElement voGecko = getGeckoElement(cField);

            if (voGecko != null)
            {
                voGecko.SetAttribute("value", cKeyValue);
                return(true);
            }

            HtmlElement voHtml = getHtmlElement(cField);

            if (voHtml != null)
            {
                voHtml.SetAttribute("value", cKeyValue);
                return(true);
            }

            return(false);
        }
        public static void TranslateDocument(GeckoWebBrowser wb, string language)
        {
            try
            {
                string jso = "function googleTranslateElementInit()" + " { new google.translate.TranslateElement({  " + "pageLanguage: '" + language + "'" + "  }, 'google_translate_element');" + "}";

                GeckoElement el = wb.Document.CreateElement("DIV");
                el.SetAttribute("id", "google_translate_element");
                wb.Document.Body.AppendChild(el);
                GeckoElement sco = wb.Document.CreateElement("SCRIPT");
                sco.TextContent = jso;
                wb.Document.Body.AppendChild(sco);

                GeckoElement sct = wb.Document.CreateElement("SCRIPT");
                sct.SetAttribute("src", "http://translate.google.com/translate_a/element.js?cb=googleTranslateElementInit");
                wb.Document.Body.AppendChild(sct);
            }
            catch
            {
            }
        }
Exemple #17
0
        /// <summary>
        /// 根据ID获取数据信息。
        /// </summary>
        /// <param name="cKeyID"></param>
        /// <returns></returns>
        public String getFieldValue(String cField)
        {
            GeckoElement voGecko = getGeckoElement(cField);

            if (voGecko != null)
            {
                if (voGecko.Attributes["value"] != null)
                {
                    return(StringEx.getString(voGecko.Attributes["value"].TextContent));
                }
            }

            HtmlElement voHtml = getHtmlElement(cField);

            if (voHtml != null)
            {
                return(StringEx.getString(voHtml.GetAttribute("value")));
            }

            return(null);
        }
Exemple #18
0
 private void PayClick(GeckoElement clicked)
 {
     try {
         if (clicked.HasAttribute("id") && !clicked.HasAttribute("disabled"))
         {
             if (clicked.GetAttribute("id").Equals("next"))
             {
                 _payment.Save();
                 _payment = new Payment();
                 Util.NavigateTo(_browser, CurrentWindow.Main);
             }
             else if (clicked.GetAttribute("id").Equals("back"))
             {
                 Util.NavigateTo(_browser, CurrentWindow.EnterNumber);
             }
             _cashCode.DisableBillTypes();
         }
     } catch (Exception exception) {
         Log.Error(exception);
     }
 }
Exemple #19
0
        public void SignIn(string userId, string passId, string buttonId)
        {
            GeckoElement elementById = this.geckoWeb.Document.GetElementById("Userid");

            if (elementById != null)
            {
                elementById.SetAttribute("value", "AVTORITET");
            }
            GeckoElement element2 = this.geckoWeb.Document.GetElementById("Passwd");

            if (element2 != null)
            {
                element2.SetAttribute("value", "Hugoboss2030");
            }
            GeckoElement element3 = this.geckoWeb.Document.GetElementById("LoginButton");

            if (element3 != null)
            {
                new GeckoInputElement(element3.DomObject).Click();
            }
        }
        void browser_DocumentCompleted(object sender, System.EventArgs e)
        {
            //unsubscribe
            _browser.DocumentCompleted -= browser_DocumentCompleted;
            GeckoElement rt = _browser.Document.CreateElement("div");

            rt.SetAttribute("id", "blocker");
            rt.SetAttribute
            (
                "style",
                "position: fixed;"
                + "top: 0px;"
                + "left: 0px;"
                + "width: 100%;"
                + "height: 100%;"
                + "opacity: 0.0;"
                + "background-color: #111;"
                + "z-index: 9000;"
                + "overflow: auto;"
            );
            _browser.Document.Body.AppendChild(rt);
        }
Exemple #21
0
        protected bool TryGetHvo(GeckoElement element, out int hvo)
        {
            while (element != null)
            {
                switch (element.TagName.ToLowerInvariant())
                {
                case "table":
                case "span":
                case "th":
                case "td":
                    string id = element.GetAttribute("id");
                    if (!string.IsNullOrEmpty(id))
                    {
                        return(int.TryParse(id, out hvo));
                    }
                    break;
                }
                element = element.ParentElement;
            }

            hvo = 0;
            return(false);
        }
Exemple #22
0
        public void ChangePicture(GeckoElement img, PalasoImage imageInfo, IProgress progress)
        {
            try
            {
                Logger.WriteMinorEvent("Starting ChangePicture {0}...", imageInfo.FileName);
                var editor = new PageEditingModel();
                editor.ChangePicture(_bookSelection.CurrentSelection.FolderPath, img, imageInfo, progress);

                //we have to save so that when asked by the thumbnailer, the book will give the proper image
                SaveNow();
                //but then, we need the non-cleaned version back there
                _view.UpdateSingleDisplayedPage(_pageSelection.CurrentSelection);

                _view.UpdateThumbnailAsync(_pageSelection.CurrentSelection);
                Logger.WriteMinorEvent("Finished ChangePicture {0} (except for async thumbnail) ...", imageInfo.FileName);
                Analytics.Track("Change Picture");
                Logger.WriteEvent("ChangePicture {0}...", imageInfo.FileName);
            }
            catch (Exception e)
            {
                ErrorReport.NotifyUserOfProblem(e, "Could not change the picture");
            }
        }
        protected void HandleHtmlControlBrowserDomMouseMove(object sender, GeckoDomMouseEventArgs e)
        {
            if (sender == null || e == null || e.Target == null)
            {
                return;
            }

            GeckoElement parentTable = GetParentTable(e.Target);

            if (parentTable == null)
            {
                return;
            }

            GeckoNode onMouseMove = parentTable.Attributes["onmousemove"];

            if (onMouseMove == null)
            {
                return;
            }

            MouseMove();
        }
        protected override void OnDocumentCompleted(Gecko.Events.GeckoDocumentCompletedEventArgs e)
        {
            base.OnDocumentCompleted(e);
            try
            {
                Func <GeckoDocument, Uri, Boolean> action = flow.Procedure(e.Uri);
                GeckoElement script = this.Document.CreateElement("script");
                script.SetAttribute("type", "text/javascript");
                script.TextContent = "window.alert = function(){};";
                this.Document.Head.AppendChild(script);

                if (!action(this.Document, e.Uri))
                {
                    flow.End();
                    Scraper.Exit();
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex.ToString());
                Scraper.Exit();
            }
        }
Exemple #25
0
        private void MainClick(GeckoElement clicked)
        {
            try {
                if (clicked.HasAttribute("data-type"))
                {
                    switch (clicked.GetAttribute("data-type"))
                    {
                    case "service":
                        short.TryParse(clicked.GetAttribute("id"), out _mainServiceId);
                        Log.Debug(String.Format("Clicked service with id {0}", clicked.GetAttribute("id")));
                        Util.NavigateTo(_browser, CurrentWindow.Dependent);
                        _clickedTopButton = false;
                        break;

                    case "top-service":
                        try {
                            _payment.id_uslugi = short.Parse(clicked.GetAttribute("id"));
                            Log.Debug(String.Format("Clicked top-service with id {0}", clicked.GetAttribute("id")));
                            Util.NavigateTo(_browser, CurrentWindow.EnterNumber);
                            _clickedTopButton = true;
                        } catch (Exception ex) {
                            Log.Error("Incorrect service id format", ex, clicked);
                        }
                        break;

                    default:
                        Log.Debug("Clicked element was null");
                        return;
                    }
                }
                else if (clicked.HasAttribute("language"))
                {
                }
            } catch (Exception exception) {
                Log.Error(exception);
            }
        }
Exemple #26
0
        public static ScrapTable SelectTableByClass(this GeckoDocument document, String classname, int index = 0)
        {
            ScrapTable   ret        = new ScrapTable();
            GeckoElement element    = document.GetElementsByClassName(classname)[index] as GeckoElement;
            var          collection = element.GetElementsByTagName("TR");

            foreach (var row in collection)
            {
                foreach (var col in row.ChildNodes)
                {
                    if (!(col is GeckoHtmlElement))
                    {
                        continue;
                    }
                    var buffer = col as GeckoHtmlElement;
                    if ("TD".Equals(buffer.TagName) || "TH".Equals(buffer.TagName))
                    {
                        ret.Set(col as GeckoHtmlElement);
                    }
                }
                ret.Next();
            }
            return(ret);
        }
 /// <summary>
 /// Focus the element aElement. The element should be in the same document
 /// that the window is displaying. Pass null to blur the element, if any,
 /// that currently has focus, and focus the document.
 ///
 /// Cannot be accessed from unprivileged context (not content-accessible)
 /// Will throw a DOM security error if called without UniversalXPConnect
 /// privileges.
 ///
 /// @param aElement the element to focus
 ///
 /// Do not use this method. Just use element.focus if available or
 /// nsIFocusManager::SetFocus instead.
 ///
 /// </summary>		
 public void Focus(GeckoElement aElement)
 {
     _windowUtils.Instance.Focus(aElement.DOMElement);
 }
Exemple #28
0
        protected void TestQueryingOfDom(GeckoWebBrowser browser)
        {
            GeckoElement g = browser.Document.DocumentElement;

            DisplayElements(g);
        }
Exemple #29
0
 /// <summary>
 /// See nsIWidget::SynthesizeNativeMouseEvent
 ///
 /// Will be called on the widget that contains aElement.
 /// Cannot be accessed from unprivileged context (not content-accessible)
 /// Will throw a DOM security error if called without UniversalXPConnect
 /// privileges.
 /// </summary>
 public void SendNativeMouseEvent(int aScreenX, int aScreenY, int aNativeMessage, int aModifierFlags, GeckoElement aElement)
 {
     _windowUtils.SendNativeMouseEvent(aScreenX, aScreenY, aNativeMessage, aModifierFlags, (nsIDOMElement)aElement.DomObject);
 }
Exemple #30
0
 /// <summary>
 /// For any scrollable element, this allows you to override the
 /// visible region and draw more than what is visible, which is
 /// useful for asynchronous drawing. The "displayport" will be
 /// <xPx, yPx, widthPx, heightPx> in units of CSS pixels,
 /// regardless of the size of the enclosing container.  This
 /// will *not* trigger reflow.
 ///
 /// For the root scroll area, pass in the root document element.
 /// For scrollable elements, pass in the container element (for
 /// instance, the element with overflow: scroll).
 ///
 /// <x, y> is relative to the top-left of what would normally be
 /// the visible area of the element. This means that the pixels
 /// rendered to the displayport take scrolling into account,
 /// for example.
 ///
 /// It's legal to set a displayport that extends beyond the overflow
 /// area in any direction (left/right/top/bottom).
 ///
 /// It's also legal to set a displayport that extends beyond the
 /// area's bounds.  No pixels are rendered outside the area bounds.
 ///
 /// The caller of this method must have UniversalXPConnect
 /// privileges.
 /// </summary>
 public void SetDisplayPortForElement(float aXPx, float aYPx, float aWidthPx, float aHeightPx, GeckoElement aElement)
 {
     _windowUtils.SetDisplayPortForElement(aXPx, aYPx, aWidthPx, aHeightPx, (nsIDOMElement)aElement.DomObject);
 }
Exemple #31
0
        private void gecko_Navigated(object sender, GeckoNavigatedEventArgs e)
        {
            GeckoElement gaia_loginbox = gecko.Document.GetElementById("gaia_loginbox");

            if (gaia_loginbox == null)
            {
                GeckoElement header = gecko.Document.GetElementById("header");
                if (header != null)
                {
                    header.SetAttribute("style", "display:none;");
                }

                GeckoElement oneGoogleWrapper = gecko.Document.GetElementById("oneGoogleWrapper");
                if (oneGoogleWrapper != null)
                {
                    oneGoogleWrapper.SetAttribute("style", "display:none;");
                }

                GeckoElement coloredBar = gecko.Document.GetElementById("coloredBar");
                if (coloredBar != null)
                {
                    coloredBar.SetAttribute("style", "display:none;");
                }

                GeckoElement headerBar = gecko.Document.GetElementById("headerBar");
                if (headerBar != null)
                {
                    headerBar.SetAttribute("style", "padding-top:0px;");
                    GeckoElement gUser = gecko.Document.GetElementById("guser");

                    GeckoElement username = (GeckoElement)gUser.FirstChild.ChildNodes[2];
                    username.SetAttribute("style", "display:none;");

                    foreach (GeckoNode el in gUser.FirstChild.ChildNodes)
                    {
                        if ((el.HasAttributes) && (el.Attributes["id"] != null))
                        {
                            {
                                GeckoElement element = (GeckoElement)el;
                                if (element.Id != "gb_71")
                                {
                                    element.SetAttribute("style", "display:none;");
                                }
                            }
                        }
                        if (el.TextContent.Contains("|"))
                        {
                            el.TextContent = "";
                        }
                    }

                    GeckoElement breadcrumbs = gecko.Document.GetElementById("breadcrumbs");
                    breadcrumbs.SetAttribute("style", "margin-left:176px;");

                    GeckoElement parentEl = breadcrumbs.Parent;
                    parentEl.InsertBefore((GeckoNode)gUser, (GeckoNode)breadcrumbs);

                    GeckoNode navtab = (GeckoNode)headerBar.LastChild.FirstChild;
                    if (navtab != null)
                    {
                        GeckoElement navtabEl = (GeckoElement)navtab;
                        navtabEl.SetAttribute("style", "width:171px;margin-top:25px;");
                    }
                }

                GeckoElement nav = gecko.Document.GetElementById("nav");
                if (nav != null)
                {
                    nav.SetAttribute("style", "width:151px;");
                }
            }
        }
Exemple #32
0
        void geckoWebBrowser1_DocumentCompleted(object sender, EventArgs e)
        {
            txt_Title.Text = "";

            GeckoDocument doc = geckoWebBrowser1.Document;
            titleElem = FindTagContainingText(doc, originalTitleContent);
            entryElem = FindTagContainingText(doc, originalBodyContent);

            if (titleElem != null && entryElem != null)
            {
                titleElem.InnerHtml = txt_Title.Text;
                entryElem.InnerHtml = txt_Content.Text;
            }
            geckoWebBrowser1.DocumentCompleted -= new EventHandler(geckoWebBrowser1_DocumentCompleted);

            txt_Title.Enabled = true;
            txt_Content.Enabled = true;
        }
Exemple #33
0
 public O2Form(GeckoElement _geckoElement)
 {
     geckoElement = _geckoElement;
     //populateFieldsFromHtmlElementData(heForm);
 }
Exemple #34
0
 public static String GetElementByTagNameToNodeValue(this GeckoElement element, String tag, int index = 0)
 {
     return(element.GetElementsByTagName(tag)[index].FirstChild.NodeValue);
 }
Exemple #35
0
 public static T GetElementByTagName <T>(this GeckoElement element, String tag, int index = 0) where T : GeckoElement
 {
     return(element.GetElementsByTagName(tag)[index] as T);
 }
 /// <summary>
 /// For any scrollable element, this allows you to override the
 /// visible region and draw more than what is visible, which is
 /// useful for asynchronous drawing. The "displayport" will be
 /// <xPx, yPx, widthPx, heightPx> in units of CSS pixels,
 /// regardless of the size of the enclosing container.  This
 /// will *not* trigger reflow.
 ///
 /// For the root scroll area, pass in the root document element.
 /// For scrollable elements, pass in the container element (for
 /// instance, the element with overflow: scroll).
 ///
 /// <x, y> is relative to the top-left of what would normally be
 /// the visible area of the element. This means that the pixels
 /// rendered to the displayport take scrolling into account,
 /// for example.
 ///
 /// It's legal to set a displayport that extends beyond the overflow
 /// area in any direction (left/right/top/bottom).
 ///
 /// It's also legal to set a displayport that extends beyond the
 /// area's bounds.  No pixels are rendered outside the area bounds.
 ///
 /// The caller of this method must have UniversalXPConnect
 /// privileges.
 /// </summary>		
 public void SetDisplayPortForElement(float aXPx, float aYPx, float aWidthPx, float aHeightPx, GeckoElement aElement)
 {
     _windowUtils.SetDisplayPortForElement(aXPx, aYPx, aWidthPx, aHeightPx, (nsIDOMElement)aElement.DomObject);
 }
 /// <summary>
 /// See nsIWidget::SynthesizeNativeMouseEvent
 ///
 /// Will be called on the widget that contains aElement.
 /// Cannot be accessed from unprivileged context (not content-accessible)
 /// Will throw a DOM security error if called without UniversalXPConnect
 /// privileges.
 /// </summary>
 public void SendNativeMouseEvent(int aScreenX, int aScreenY, int aNativeMessage, int aModifierFlags, GeckoElement aElement)
 {
     _windowUtils.SendNativeMouseEvent(aScreenX, aScreenY, aNativeMessage, aModifierFlags, (nsIDOMElement)aElement.DomObject);
 }
 public void add(GeckoElement element, GeckoElement before)
 {
     DOMHTMLElement.Add(element.DomObject as nsIDOMHTMLElement, before.DomObject as nsIVariant);
 }
Exemple #39
0
        /// <summary>
        /// Scrolls the renderer's content so that a GeckoElement is in the center.
        /// </summary>
        /// <param name="element">The GeckoElement to bring to the center.</param>
        private void ScrollTo(GeckoElement element)
        {
            if (element == null) return;

            GeckoElement document = renderer.Document.DocumentElement;
            int x = document.ScrollLeft + (int)(element.BoundingClientRect.Left) + (element.ClientWidth / 2);
            int y = document.ScrollTop + (int) (element.BoundingClientRect.Top) + (element.ClientHeight / 2);

            // x, y should end up being as close to the middle of the viewport as possible
            // this just sets x, y at upper left corner. how do we compensate?
            x -= renderer.ClientSize.Width / 2;
            y -= renderer.ClientSize.Height / 2;

            document.ScrollLeft = x;
            document.ScrollTop = y;
            System.Diagnostics.Trace.TraceInformation ("Scrolled to {0}, {1}", x, y);
        }