Esempio n. 1
0
        public void PrepareCSS()
        {
            HtmlTag.GetChildByName("echo")[0].Run();

            DOMObject      child          = HtmlTag.GetChildByName("echo")[0];
            EchoDefinition echoDefinition = child.ProcessedTag as EchoDefinition;

            ClientRectangle = new System.Drawing.RectangleF(
                Document.LastDocumentX, Document.LastDocumentY,
                echoDefinition.MeasuredStringLength.Width, echoDefinition.MeasuredStringLength.Height);
        }
Esempio n. 2
0
        public static DOMObject GetElementById(string id)
        {
            DOMObject tag = null;

            for (int i = 0; i < DOMModel.Childs.Count; i++)
            {
                tag = DOMModel.Childs[i].Find(id);
                if (tag != null)
                {
                    return(tag);
                }
            }


            return(null);
        }
Esempio n. 3
0
        public Document(Muktashif renderer, string raw)
            : base(Global.JSExecutor)
        {
            DocumentStyles = new List <Style>();

            Renderer = renderer;
            PopulateFunctions();

            Stopwatch sw = new Stopwatch();

            sw.Start();
            HtmlTokenizer = new HtmlTokenizer(raw);
            HtmlTokenizer.Tokenize();
            HtmlTokenizer.Analyze();

            DOMModel = new DOMObject(this);
            DOMModel.Process();

            sw.Stop();

            Console.WriteLine(sw.Elapsed.TotalMilliseconds + " ms.");
        }
Esempio n. 4
0
 public ScriptDefinition(DOMObject tag)
 {
     Events  = new Dictionary <string, Delegate>();
     HtmlTag = tag;
 }
Esempio n. 5
0
        static void Button_OnClick(DOMObject sender, DOMEventArgs args)
        {
            var button = (HTMLButtonElement)sender;

            button.TextContent = "Clicked";
        }
Esempio n. 6
0
 public TagProcessor(DOMObject tag)
 {
     Tag = tag;
 }
Esempio n. 7
0
        public Style GetStyle(DOMObject tag)
        {
            foreach (var style in DocumentStyles)
            {
                char[]    selectorArray = style.Selector.ToCharArray();
                char      op            = selectorArray[0];
                Attribute t             = null;

                switch (op)
                {
                case '.':
                    string className = style.Selector.Split('.')[1];
                    t = tag.Attributes.Find(p => p.AttributeName.Equals("class"));
                    if (t != null && t.Value.Equals(className))
                    {
                        return(style);
                    }
                    break;

                case '#':
                    string id = style.Selector.Split('#')[1];
                    t = tag.Attributes.Find(p => p.AttributeName.Equals("id"));
                    if (t != null && t.Value.Equals(id))
                    {
                        return(style);
                    }
                    break;

                default:
                    if (char.IsLetter(op))
                    {
                        SearchKernel _searchKernel = new SearchKernel("~(,| |>|+|~)");
                        var          m             = _searchKernel.Search(style.Selector);

                        string[] ab = style.Selector.Split(new string[] { m[0].GetText() }, StringSplitOptions.RemoveEmptyEntries);

                        switch (m[0].GetText())
                        {
                        case ",":
                            for (int i = 0; i < ab.Length; i++)
                            {
                                if (tag.Token.Name.Contains(ab[i]))
                                {
                                    return(style);
                                }
                            }
                            break;

                        case " ":
                            break;

                        case ">":
                            break;

                        case "+":
                            break;

                        case "~":
                            break;

                        default:
                            if (tag.Token.Name.Contains(m[0].GetText()))
                            {
                                return(style);
                            }
                            break;
                        }
                    }

                    break;
                }
            }

            return(null);
        }