Beispiel #1
0
        /// <summary>Gets all inputs from the given element, adding the results to the given list.</summary>
        /// <param name="results">The list that all results are added to.</param>
        /// <param name="element">The element to check.</param>
        public static void GetAllInputs(INodeList results, HtmlElement element, InputSearchMode mode)
        {
            NodeList kids = element.childNodes_;

            if (kids == null)
            {
                return;
            }

            for (int i = 0; i < kids.length; i++)
            {
                HtmlElement child = kids[i] as HtmlElement;

                if (child == null || child.Tag == "form")
                {
                    // Don't go into child forms.
                    continue;
                }

                if (
                    (mode == InputSearchMode.Submittable && child.IsFormSubmittable) ||
                    (mode == InputSearchMode.Listed && child.IsFormListed) ||
                    (mode == InputSearchMode.Resettable && child.IsFormResettable)
                    )
                {
                    results.push(child);
                }
                else
                {
                    GetAllInputs(results, child, mode);
                }
            }
        }
Beispiel #2
0
        /// <summary>Collects all option elements that are child nodes (including inside optgroups).</summary>
        public static void CollectOptions(Node parent, INodeList hoc)
        {
            if (parent.childNodes_ == null)
            {
                return;
            }

            // For each child node..
            for (int i = 0; i < parent.childNodes_.length; i++)
            {
                // Get it:
                Node child = parent.childNodes_[i];

                // Option?
                if (child is HtmlOptionElement)
                {
                    hoc.push(child);
                    continue;
                }

                if (child.childNodes_ != null)
                {
                    // Go recursive:
                    CollectOptions(child, hoc);
                }
            }
        }
        /// <summary>Gets all child elements with the given tag.</summary>
        /// <param name="selectors">The selectors to match.</param>
        /// <returns>The set of all tags with this tag.</returns>
        public void querySelectorAll(Selector[] selectors, INodeList results, CssEvent e, bool one)
        {
            if (childNodes_ == null)
            {
                return;
            }

            for (int i = 0; i < childNodes_.length; i++)
            {
                Node            node  = childNodes_[i];
                Element         child = node as Element;
                IRenderableNode irn   = (child as IRenderableNode);

                if (child == null || irn == null)
                {
                    continue;
                }

                ComputedStyle cs = irn.ComputedStyle;

                for (int s = 0; s < selectors.Length; s++)
                {
                    // Match?
                    if (selectors[s].StructureMatch(cs, e))
                    {
                        // Yep!
                        results.push(node);

                        if (one)
                        {
                            return;
                        }
                    }
                }

                irn.querySelectorAll(selectors, results, e, one);

                if (one && results.length == 1)
                {
                    return;
                }
            }
        }