示例#1
0
        // tree DOM handling
        private static void AddElement(SciterElement tree_el_parent, SciterElement origin_el_add)
        {
            SciterNode origin_nd = origin_el_add.ToNode();

            Debug.Assert(origin_nd.IsElement);

            string        tag         = origin_el_add.Tag;
            SciterElement tree_el_new = SciterElement.Create("option");

            tree_el_parent.Append(tree_el_new);
            uint uid = origin_el_add.UID; Debug.Assert(uid != 0);

            tree_el_new.SetAttribute("value", uid.ToString());
            tree_el_new.SetHTML(UI_ElementCaption(origin_el_add));


            bool has_real_childs = false;
            uint nchilds         = origin_nd.ChildrenCount;

            for (uint i = 0; i < nchilds; i++)
            {
                SciterNode nd = origin_nd[i];
                if (nd.IsElement)
                {
                    AddElement(tree_el_new, nd.ToElement());
                    has_real_childs = true;
                }
                else
                {
                    bool new_option = AddNode(tree_el_new, uid, nd);
                    if (new_option)
                    {
                        has_real_childs = true;
                    }
                }
            }

            if (has_real_childs)
            {
                if (tag == "html" || tag == "body")
                {
                    tree_el_new.SetState(SciterXDom.ELEMENT_STATE_BITS.STATE_EXPANDED);                    //tree_el_new.set_attribute("expanded", "");
                }
                else
                {
                    tree_el_new.SetState(SciterXDom.ELEMENT_STATE_BITS.STATE_COLLAPSED);
                }
            }
        }
示例#2
0
        public static void CountElements()
        {
            g_dom_count_elem = 0;
            g_dom_count_node = 0;

            Action <SciterNode> f_VisitNode = (SciterNode origin_nd) =>
            {
                g_dom_count_node++;
                Debug.Assert(origin_nd.ChildrenCount == 0);
            };

            Action <SciterElement> f_VisitElement = null;

            f_VisitElement = (SciterElement origin_el) =>
            {
                g_dom_count_elem++;

                SciterNode origin_nd = origin_el.ToNode();
                uint       nchilds   = origin_nd.ChildrenCount;
                for (uint i = 0; i < nchilds; i++)
                {
                    SciterNode nd = origin_nd[i];
                    if (nd.IsElement)
                    {
                        f_VisitElement(nd.ToElement());
                    }
                    else
                    {
                        f_VisitNode(nd);
                    }
                }
            };

            SciterElement origin_el_root = State.g_el_frameroot[0];

            //debug assert(origin_el_root);
            if (origin_el_root != null)
            {
                f_VisitElement(origin_el_root);
            }
        }