Inheritance: HtmlContainer
Exemplo n.º 1
0
        public static MyHtmlContainer CreateHtmlContainer(
            HtmlHost htmlHost,
            WebDom.WebDocument htmldoc,
            HtmlRenderBox htmlFrgmentRenderBox)
        {
            //1. builder
            var renderTreeBuilder = htmlHost.GetRenderTreeBuilder();
            //-------------------------------------------------------------------


            //2. generate render tree
            ////build rootbox from htmldoc

            var rootElement = renderTreeBuilder.BuildCssRenderTree(htmldoc,
                                                                   htmlHost.BaseStylesheet,
                                                                   htmlFrgmentRenderBox);
            //3. create small htmlContainer

            var htmlContainer = new MyHtmlContainer(htmlHost);

            htmlContainer.WebDocument = htmldoc;
            htmlContainer.RootCssBox  = rootElement;
            htmlContainer.SetMaxSize(htmlFrgmentRenderBox.Width, 0);
            var lay = htmlHost.GetSharedHtmlLayoutVisitor(htmlContainer);

            htmlContainer.PerformLayout(lay);
            htmlHost.ReleaseHtmlLayoutVisitor(lay);
            htmlFrgmentRenderBox.SetHtmlContainer(htmlContainer, rootElement);
            return(htmlContainer);
        }
Exemplo n.º 2
0
        public static MyHtmlContainer CreateHtmlContainerFromFullHtml(
            HtmlHost htmlHost,
            string fullHtmlString,
            HtmlRenderBox htmlFrgmentRenderBox)
        {
            var htmldoc = WebDocumentParser.ParseDocument(
                 new LayoutFarm.WebDom.Parser.TextSource(fullHtmlString.ToCharArray()));
            //1. builder 
            var renderTreeBuilder = htmlHost.GetRenderTreeBuilder();
            //------------------------------------------------------------------- 
            //2. generate render tree
            ////build rootbox from htmldoc

            var rootElement = renderTreeBuilder.BuildCssRenderTree(htmldoc,
                htmlHost.BaseStylesheet,
                htmlFrgmentRenderBox);
            //3. create small htmlContainer

            var htmlContainer = new MyHtmlContainer(htmlHost);
            htmlContainer.WebDocument = htmldoc;
            htmlContainer.RootCssBox = rootElement;
            htmlContainer.SetMaxSize(htmlFrgmentRenderBox.Width, 0);
            var lay = htmlHost.GetSharedHtmlLayoutVisitor(htmlContainer);
            htmlContainer.PerformLayout(lay);
            htmlHost.ReleaseHtmlLayoutVisitor(lay);
            htmlFrgmentRenderBox.SetHtmlContainer(htmlContainer, rootElement);
            return htmlContainer;
        }
Exemplo n.º 3
0
        public static MyHtmlContainer CreateHtmlContainerFromFullHtml(
            HtmlHost htmlHost,
            string fullHtmlString,
            HtmlRenderBox htmlFrgmentRenderBox)
        {
            var htmldoc = WebDocumentParser.ParseDocument(
                new LayoutFarm.WebDom.Parser.TextSource(fullHtmlString.ToCharArray()));
            //1. builder
            var renderTreeBuilder = htmlHost.GetRenderTreeBuilder();
            //-------------------------------------------------------------------
            //2. generate render tree
            ////build rootbox from htmldoc

            var rootElement = renderTreeBuilder.BuildCssRenderTree(htmldoc,
                                                                   htmlHost.BaseStylesheet,
                                                                   htmlFrgmentRenderBox);
            //3. create small htmlContainer

            var htmlContainer = new MyHtmlContainer(htmlHost);

            htmlContainer.WebDocument = htmldoc;
            htmlContainer.RootCssBox  = rootElement;
            htmlContainer.SetMaxSize(htmlFrgmentRenderBox.Width, 0);
            var lay = htmlHost.GetSharedHtmlLayoutVisitor(htmlContainer);

            htmlContainer.PerformLayout(lay);
            htmlHost.ReleaseHtmlLayoutVisitor(lay);
            htmlFrgmentRenderBox.SetHtmlContainer(htmlContainer, rootElement);
            return(htmlContainer);
        }
Exemplo n.º 4
0
 /// <summary>
 /// Release the html container resources.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (htmlContainer != null)
     {
         this.timer01.Stop();
         htmlContainer.DetachEssentialHandlers();
         htmlContainer.Dispose();
         htmlContainer = null;
     }
     base.Dispose(disposing);
 }
Exemplo n.º 5
0
        void SetHtml(LayoutFarm.HtmlBoxes.MyHtmlContainer htmlContainer, string html, CssActiveSheet cssData)
        {
            //-----------------------------------------------------------------
            var htmldoc = this.currentDoc =
                LayoutFarm.Composers.WebDocumentParser.ParseDocument(
                    new WebDom.Parser.TextSource(html.ToCharArray()));
            //build rootbox from htmldoc
            var rootBox = this.htmlhost.GetRenderTreeBuilder().BuildCssRenderTree(htmldoc,
                                                                                  cssData,
                                                                                  null);

            htmlContainer.WebDocument = htmldoc;
            htmlContainer.RootCssBox  = rootBox;
        }
Exemplo n.º 6
0
        public void SetHtmlHost(HtmlHost htmlhost)
        {
            this.htmlhost = htmlhost;

            htmlhost.SetHtmlContainerUpdateHandler(htmlCont =>
            {
                var updatedHtmlCont = htmlCont as MyHtmlContainer;
                if (updatedHtmlCont != null && !updatedHtmlCont.IsInUpdateQueue)
                {
                    updatedHtmlCont.IsInUpdateQueue = true;
                    waitingUpdateList.Add(updatedHtmlCont);
                }
            });

            htmlContainer = new MyHtmlContainer(htmlhost);
            htmlContainer.AttachEssentialHandlers(
                OnRefresh,
                myHtmlContainer_NeedUpdateDom,
                OnRefresh,
                null);

            htmlLayoutVisitor = new LayoutVisitor(this.gfxPlatform);
            htmlLayoutVisitor.Bind(htmlContainer);


            //-------------------------------------------------------
            timer01.Interval = 20;//20ms?
            timer01.Tick    += (s, e) =>
            {
                //clear waiting
                int j = waitingUpdateList.Count;
                for (int i = 0; i < j; ++i)
                {
                    var htmlCont = waitingUpdateList[i];
                    htmlCont.IsInUpdateQueue = false;
                    htmlCont.RefreshDomIfNeed();
                }
                for (int i = j - 1; i >= 0; --i)
                {
                    waitingUpdateList.RemoveAt(i);
                }
            };
            timer01.Enabled = true;
            //-------------------------------------------
            _htmlInputEventAdapter = new HtmlInputEventAdapter(gfxPlatform.SampleIFonts);
            _htmlInputEventAdapter.Bind(htmlContainer);
            //-------------------------------------------
        }
Exemplo n.º 7
0
        public static MyHtmlContainer CreateHtmlContainerFromFragmentHtml(
            HtmlHost htmlHost,
            string htmlFragment,
            HtmlRenderBox htmlFrgmentRenderBox)
        {
            var htmldoc           = htmlHost.CreateNewSharedHtmlDoc();
            var myHtmlBodyElement = htmldoc.CreateElement("body");

            htmldoc.RootNode.AddChild(myHtmlBodyElement);

            //data is wraped up within div?
            //TODO: review this, use shadow dom instead
            var newDivHost = htmldoc.CreateElement("div");

            myHtmlBodyElement.AddChild(newDivHost);
            WebDocumentParser.ParseHtmlDom(
                new LayoutFarm.WebDom.Parser.TextSource(htmlFragment.ToCharArray()),
                htmldoc,
                newDivHost);

            //1. builder
            var renderTreeBuilder = htmlHost.GetRenderTreeBuilder();
            //-------------------------------------------------------------------
            //2. generate render tree
            var rootElement = renderTreeBuilder.BuildCssRenderTree(
                htmldoc,
                htmldoc.CssActiveSheet,
                htmlFrgmentRenderBox);

            //3. create small htmlContainer

            var htmlContainer = new MyHtmlContainer(htmlHost);

            htmlContainer.WebDocument = newDivHost.OwnerDocument;
            htmlContainer.RootCssBox  = rootElement;
            htmlContainer.SetMaxSize(htmlFrgmentRenderBox.Width, 0);

            var lay = htmlHost.GetSharedHtmlLayoutVisitor(htmlContainer);

            htmlContainer.PerformLayout(lay);
            htmlHost.ReleaseHtmlLayoutVisitor(lay);


            htmlFrgmentRenderBox.SetHtmlContainer(htmlContainer, rootElement);
            return(htmlContainer);
        }
Exemplo n.º 8
0
        public static MyHtmlContainer CreateHtmlContainerFromFragmentHtml(
            HtmlHost htmlHost,
            string htmlFragment,
            HtmlRenderBox htmlFrgmentRenderBox)
        {
            var htmldoc = htmlHost.CreateNewSharedHtmlDoc();
            var myHtmlBodyElement = htmldoc.CreateElement("body");
            htmldoc.RootNode.AddChild(myHtmlBodyElement);
            //data is wraped up within div?
            //TODO: review this, use shadow dom instead
            var newDivHost = htmldoc.CreateElement("div");
            myHtmlBodyElement.AddChild(newDivHost);
            WebDocumentParser.ParseHtmlDom(
                     new LayoutFarm.WebDom.Parser.TextSource(htmlFragment.ToCharArray()),
                     htmldoc,
                     newDivHost);
            //1. builder 
            var renderTreeBuilder = htmlHost.GetRenderTreeBuilder();
            //-------------------------------------------------------------------
            //2. generate render tree  
            var rootElement = renderTreeBuilder.BuildCssRenderTree(
                 htmldoc,
                 htmldoc.CssActiveSheet,
                 htmlFrgmentRenderBox);
            //3. create small htmlContainer

            var htmlContainer = new MyHtmlContainer(htmlHost);
            htmlContainer.WebDocument = newDivHost.OwnerDocument;
            htmlContainer.RootCssBox = rootElement;
            htmlContainer.SetMaxSize(htmlFrgmentRenderBox.Width, 0);
            var lay = htmlHost.GetSharedHtmlLayoutVisitor(htmlContainer);
            htmlContainer.PerformLayout(lay);
            htmlHost.ReleaseHtmlLayoutVisitor(lay);
            htmlFrgmentRenderBox.SetHtmlContainer(htmlContainer, rootElement);
            return htmlContainer;
        }
Exemplo n.º 9
0
 public void SetHtmlContainer(MyHtmlContainer htmlCont, CssBox box)
 {
     this.myHtmlCont = htmlCont;
     this.cssBox     = box;
 }
Exemplo n.º 10
0
 public void SetHtmlContainer(MyHtmlContainer htmlCont, CssBox box)
 {
     this.myHtmlCont = htmlCont;
     this.cssBox = box;
 }
Exemplo n.º 11
0
 public void SetHtmlHost(HtmlHost htmlhost)
 {
     this.htmlhost = htmlhost;
     htmlhost.SetHtmlContainerUpdateHandler(htmlCont =>
     {
         var updatedHtmlCont = htmlCont as MyHtmlContainer;
         if (updatedHtmlCont != null && !updatedHtmlCont.IsInUpdateQueue)
         {
             updatedHtmlCont.IsInUpdateQueue = true;
             waitingUpdateList.Add(updatedHtmlCont);
         }
     });
     htmlContainer = new MyHtmlContainer(htmlhost);
     htmlContainer.AttachEssentialHandlers(
         OnRefresh,
         myHtmlContainer_NeedUpdateDom,
         OnRefresh,
         null);
     htmlLayoutVisitor = new LayoutVisitor();
     htmlLayoutVisitor.Bind(htmlContainer);
     //------------------------------------------------------- 
     timer01.Interval = 20;//20ms?
     timer01.Tick += (s, e) =>
     {
         //clear waiting
         int j = waitingUpdateList.Count;
         for (int i = 0; i < j; ++i)
         {
             var htmlCont = waitingUpdateList[i];
             htmlCont.IsInUpdateQueue = false;
             htmlCont.RefreshDomIfNeed();
         }
         for (int i = j - 1; i >= 0; --i)
         {
             waitingUpdateList.RemoveAt(i);
         }
     };
     timer01.Enabled = true;
     //-------------------------------------------
     _htmlInputEventAdapter = new HtmlInputEventAdapter();
     _htmlInputEventAdapter.Bind(htmlContainer);
     //-------------------------------------------
 }
Exemplo n.º 12
0
 /// <summary>
 /// Release the html container resources.
 /// </summary>
 protected override void Dispose(bool disposing)
 {
     if (htmlContainer != null)
     {
         this.timer01.Stop();
         htmlContainer.DetachEssentialHandlers();
         htmlContainer.Dispose();
         htmlContainer = null;
     }
     base.Dispose(disposing);
 }
Exemplo n.º 13
0
 void BuildCssBoxTree(MyHtmlContainer htmlCont, CssActiveSheet cssData)
 {
     var rootBox = this.htmlhost.GetRenderTreeBuilder().BuildCssRenderTree(
         this.currentDoc,
         cssData,
         null);
     htmlCont.RootCssBox = rootBox;
 }
Exemplo n.º 14
0
 public void LoadHtmlFragmentString(string fragmentHtmlString)
 {
     if (htmlRenderBox == null)
     {
         this.waitingContentKind = WaitingContentKind.HtmlFragmentString;
         this.waitingHtmlString = fragmentHtmlString;
     }
     else
     {
         //just parse content and load 
         this.myHtmlCont = HtmlContainerHelper.CreateHtmlContainerFromFragmentHtml(this.htmlhost, fragmentHtmlString, htmlRenderBox);
         SetHtmlContainerEventHandlers();
         ClearWaitingContent();
     }
 }
Exemplo n.º 15
0
 public void LoadHtmlDom(HtmlDocument htmldoc)
 {
     if (htmlRenderBox == null)
     {
         this.waitingContentKind = WaitingContentKind.HtmlDocument;
         this.waitingHtmlDoc = htmldoc;
     }
     else
     {
         //just parse content and load 
         this.myHtmlCont = HtmlContainerHelper.CreateHtmlContainer(this.htmlhost, htmldoc, htmlRenderBox);
         SetHtmlContainerEventHandlers();
         ClearWaitingContent();
         RaiseLayoutFinished();
     }
 }
Exemplo n.º 16
0
        public static MyHtmlContainer CreateHtmlContainer(
            HtmlHost htmlHost,
            WebDom.WebDocument htmldoc,
            HtmlRenderBox htmlFrgmentRenderBox)
        {
            //1. builder 
            var renderTreeBuilder = htmlHost.GetRenderTreeBuilder();
            //-------------------------------------------------------------------


            //2. generate render tree
            ////build rootbox from htmldoc

            var rootElement = renderTreeBuilder.BuildCssRenderTree(htmldoc,
                htmlHost.BaseStylesheet,
                htmlFrgmentRenderBox);
            //3. create small htmlContainer

            var htmlContainer = new MyHtmlContainer(htmlHost);
            htmlContainer.WebDocument = htmldoc;
            htmlContainer.RootCssBox = rootElement;
            htmlContainer.SetMaxSize(htmlFrgmentRenderBox.Width, 0);
            var lay = htmlHost.GetSharedHtmlLayoutVisitor(htmlContainer);
            htmlContainer.PerformLayout(lay);
            htmlHost.ReleaseHtmlLayoutVisitor(lay);
            htmlFrgmentRenderBox.SetHtmlContainer(htmlContainer, rootElement);
            return htmlContainer;
        }