/// <summary>Searches a document for any sub-documents (inside iframes).</summary>
        public static void Search(Document doc, string name, List <DocumentEntry> results)
        {
            if (doc == null)
            {
                return;
            }

            // Add it:
            results.Add(new DocumentEntry(doc, name));

            // Search for iframe's:
            Dom.HTMLCollection set = doc.getElementsByTagName("iframe");

            foreach (Element node in set)
            {
                // Get as a HTML element:
                HtmlElement htmlElement = node as HtmlElement;

                // Double check it's not some evil iframe twin:
                if (htmlElement != null)
                {
                    string src = htmlElement.getAttribute("src");

                    // Search content doc:
                    Search(htmlElement.contentDocument, src, results);
                }
            }
        }
        public override void OnFollowLink(HtmlElement linkElement, Location path)
        {
            string target = linkElement.getAttribute("target");

            if (target != null && target == "_blank")
            {
                // Open the given url.
                Application.OpenURL(path.absolute);
                return;
            }

            // Apply location:
            linkElement.htmlDocument.location = path;
        }
示例#3
0
        protected override bool HandleLocalEvent(Dom.Event e, bool bubblePhase)
        {
            if (base.HandleLocalEvent(e, bubblePhase))
            {
                // It was blocked. Don't run the default.
                return(true);
            }

            if (e.type == "dragstart")
            {
                if (ToResize == null)
                {
                    ToResize_ = parentElement as HtmlElement;
                }
                else
                {
                    ToResize_ = ToResize;
                }

                // Get the CSS resize property:
                if (ToResize_ != null)
                {
                    // Obtain its values:
                    Css.Properties.Resize.Compute(ToResize_.ComputedStyle, out AllowX, out AllowY);

                    // Does it explicitly change the resize target?
                    while (ToResize_ != null)
                    {
                        // Get the target attrib:
                        string attr = ToResize_.getAttribute("resize-target");

                        if (attr != null)
                        {
                            if (attr == "parent")
                            {
                                // Update to resize:
                                ToResize_ = ToResize_.parentElement as HtmlElement;

                                // Loop again; that might also specify a target.
                                continue;
                            }
                        }

                        break;
                    }
                }
            }

            return(false);
        }
示例#4
0
        /// <summary>Gets an attribute value which may be overriden in the given element.</summary>
        private string GetOverriden(string name, HtmlElement button)
        {
            // Get from this element:
            string current = getAttribute(name);

            // Got an override?
            if (button != null)
            {
                string overriden = button.getAttribute("form" + name);

                if (overriden != null)
                {
                    return(overriden);
                }
            }

            return(current);
        }
示例#5
0
        /// <summary>Gets the location now.</summary>
        private Location GetLocation()
        {
            if (Href_ != null)
            {
                return(Href_);
            }

            // The target:
            string href = getAttribute("href");

                        #if MOBILE || UNITY_METRO
            // First, look for <source> elements.

            // Grab the kids:
            NodeList kids = childNodes_;

            if (kids != null)
            {
                // For each child, grab it's src value. Favours the most suitable protocol for this platform (e.g. market:// on android).

                foreach (Node child in kids)
                {
                    HtmlElement el = child as HtmlElement;

                    if (el == null || el.Tag != "source")
                    {
                        continue;
                    }

                    // Grab the src:
                    string childSrc = el.getAttribute("src");

                    if (childSrc == null)
                    {
                        continue;
                    }

                    // Get the optional type - it can be Android,W8,IOS,Blackberry:
                    string type = el.getAttribute("type");

                    if (type != null)
                    {
                        type = type.Trim().ToLower();
                    }

                                        #if UNITY_ANDROID
                    if (type == "android" || childSrc.StartsWith("market:"))
                    {
                        href = childSrc;
                    }
                                        #elif UNITY_WP8 || UNITY_METRO
                    if (type == "w8" || type == "wp8" || type == "windows" || childSrc.StartsWith("ms-windows-store:"))
                    {
                        href = childSrc;
                    }
                                        #elif UNITY_IPHONE
                    if (type == "ios" || childSrc.StartsWith("itms:") || childSrc.StartsWith("itms-apps:"))
                    {
                        href = childSrc;
                    }
                                        #endif
                }
            }
                        #endif

            if (href == null)
            {
                // Refresh.
                href = "";
            }

            Href_ = new Location(href, document.basepath);
            return(Href_);
        }