Beispiel #1
0
        public CssBox BuildCssRenderTree(WebDocument webdoc,
                                         CssActiveSheet cssActiveSheet,
                                         RenderElement containerElement)
        {
            HtmlDocument htmldoc = webdoc as HtmlDocument;

            if (htmldoc == null)
            {
                //TODO: fixed here
                throw new NotSupportedException();
            }
            htmldoc.CssActiveSheet = cssActiveSheet;
            htmldoc.SetDocumentState(DocumentState.Building);
            //----------------------------------------------------------------

            TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(cssActiveSheet);

            PrepareStylesAndContentOfChildNodes((HtmlElement)htmldoc.RootNode, activeTemplate);
            //----------------------------------------------------------------


            //TODO: review here, we should create cssbox at  document.body?
            CssBox bridgeBox = HtmlHost.CreateBridgeBox(_htmlHost.GetHtmlTextService(), containerElement);

            ((HtmlElement)htmldoc.RootNode).SetPrincipalBox(bridgeBox);//set bridgeBox as principal box of root node
            _htmlHost.UpdateChildBoxes((HtmlRootElement)htmldoc.RootNode, true);
            htmldoc.SetDocumentState(DocumentState.Idle);
            //----------------------------------------------------------------
            //SetTextSelectionStyle(htmlCont, cssData);
            return(bridgeBox);
        }
        //public CssBox BuildCssRenderTree(
        //   HtmlElement hostElement,
        //   HtmlElement domElement,
        //   RenderElement containerElement)
        //{
        //    var rootgfx = containerElement.Root;
        //    IFonts ifonts = rootgfx.SampleIFonts;
        //    HtmlDocument htmldoc = domElement.OwnerDocument as HtmlDocument;
        //    HtmlElement startAtHtmlElement = (HtmlElement)domElement;

        //    htmldoc.SetDocumentState(DocumentState.Building);
        //    TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(htmldoc.CssActiveSheet);
        //    PrepareStylesAndContentOfChildNodes(startAtHtmlElement, activeTemplate);

        //    //1.css box for doc root: create new if not exist
        //    CssBox docRoot = HtmlElement.InternalGetPrincipalBox((HtmlElement)htmldoc.RootNode);
        //    if (docRoot == null)
        //    {
        //        docRoot = HtmlHost.CreateBridgeBox(ifonts, containerElement, rootgfx);
        //        ((HtmlElement)htmldoc.RootNode).SetPrincipalBox(docRoot);
        //    }

        //    //----------------------------------------------------------------
        //    CssBox bridgeBox = HtmlHost.CreateBridgeBox(ifonts, containerElement, rootgfx);
        //    docRoot.AppendChild(bridgeBox);
        //    domElement.SetPrincipalBox(bridgeBox);
        //    //----------------------------------------------------------------

        //    this.htmlHost.UpdateChildBoxes(startAtHtmlElement, true);
        //    htmldoc.SetDocumentState(DocumentState.Idle);
        //    //----------------------------------------------------------------
        //    //SetTextSelectionStyle(htmlCont, cssData);
        //    return bridgeBox;
        //}


        //----------------------------------------------------------------
        public void RefreshCssTree(DomElement startAt)
        {
            HtmlElement startAtElement = (HtmlElement)startAt;

            startAtElement.OwnerDocument.SetDocumentState(DocumentState.Building);
            //----------------------------------------------------------------
            //clear active template

            TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(((HtmlDocument)startAtElement.OwnerDocument).CssActiveSheet);

            PrepareStylesAndContentOfChildNodes(startAtElement, activeTemplate);

            CssBox existingCssBox = HtmlElement.InternalGetPrincipalBox(startAtElement);

            if (existingCssBox != null)
            {
                existingCssBox.Clear();
            }
            //----------------------------------------------------------------


            this.htmlHost.UpdateChildBoxes(startAtElement, false);

            startAtElement.OwnerDocument.SetDocumentState(DocumentState.Idle);
            //----------------------------------------------------------------
        }
Beispiel #3
0
        ///// <summary>
        ///// Set the selected text style (selection text color and background color).
        ///// </summary>
        ///// <param name="htmlContainer"> </param>
        ///// <param name="cssData">the style data</param>
        //static void SetTextSelectionStyle(HtmlIsland htmlContainer, CssActiveSheet cssData)
        //{
        //    //comment out for another technique


        //    //foreach (var block in cssData.GetCssRuleSetIter("::selection"))
        //    //{
        //    //    if (block.Properties.ContainsKey("color"))
        //    //        htmlContainer.SelectionForeColor = CssValueParser.GetActualColor(block.GetPropertyValueAsString("color"));
        //    //    if (block.Properties.ContainsKey("background-color"))
        //    //        htmlContainer.SelectionBackColor = CssValueParser.GetActualColor(block.GetPropertyValueAsString("background-color"));
        //    //}

        //    //if (cssData.ContainsCssBlock("::selection"))
        //    //{
        //    //    var blocks = cssData.GetCssBlock("::selection");
        //    //    foreach (var block in blocks)
        //    //    {

        //    //    }
        //    //}
        //}
        private static void AssignStylesForElementId(CssBox box, TopDownActiveCssTemplate activeCssTemplate, string elementId)
        {
            throw new NotSupportedException();
            //foreach (var ruleSet in cssData.GetCssRuleSetIter(elementId))
            //{
            //    if (IsBlockAssignableToBox(box, ruleSet))
            //    {
            //        AssignStyleToCssBox(box, ruleSet);
            //    }
            //}
        }
Beispiel #4
0
        public CssBox BuildCssRenderTree2(
            LayoutFarm.WebDom.Impl.HtmlDocument htmldoc,
            CssActiveSheet cssActiveSheet)
        {
            htmldoc.CssActiveSheet = cssActiveSheet;
            htmldoc.SetDocumentState(DocumentState.Building);
            TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(cssActiveSheet);

            PrepareStylesAndContentOfChildNodes((HtmlElement)htmldoc.RootNode, activeTemplate);
            //TODO: review here, we should create cssbox at document.body?
            CssBox rootBox = HtmlHost.CreateIsolateBox(_htmlHost.GetHtmlTextService());

            ((HtmlElement)htmldoc.RootNode).SetPrincipalBox(rootBox);
            _htmlHost.UpdateChildBoxes((HtmlRootElement)htmldoc.RootNode, true);
            htmldoc.SetDocumentState(DocumentState.Idle);
            return(rootBox);
        }
Beispiel #5
0
        void PrepareStylesAndContentOfChildNodes(
            HtmlElement parentElement,
            TopDownActiveCssTemplate activeCssTemplate)
        {
            //recursive
            CssBox principalCssBox = parentElement.CurrentPrincipalBox;
            bool   isblockContext  = true;//default

            if (principalCssBox != null)
            {
                isblockContext = principalCssBox.IsBlock;
            }

            foreach (WebDom.DomNode node in parentElement.GetChildNodeIterForward())
            {
                activeCssTemplate.EnterLevel();
                switch (node.NodeKind)
                {
                case WebDom.HtmlNodeKind.OpenElement:
                case WebDom.HtmlNodeKind.ShortElement:
                {
                    HtmlElement htmlElement = (HtmlElement)node;
                    htmlElement.WellknownElementName = WellKnownDomNodeMap.EvaluateTagName(htmlElement.LocalName);
                    switch (htmlElement.WellknownElementName)
                    {
                    case WellKnownDomNodeName.style:
                    {
                        //style element should have textnode child
                        int j = htmlElement.ChildrenCount;
                        for (int i = 0; i < j; ++i)
                        {
                            var ch = htmlElement.GetChildNode(i);
                            switch (ch.NodeKind)
                            {
                            case HtmlNodeKind.TextNode:
                            {
                                HtmlTextNode textNode = (HtmlTextNode)htmlElement.GetChildNode(0);
                                activeCssTemplate.LoadRawStyleElementContent(new string(textNode.GetOriginalBuffer()));
                                //break
                                i = j;
                            }
                            break;
                            }
                        }
                        activeCssTemplate.ExitLevel();
                        continue;
                    }

                    case WellKnownDomNodeName.link:
                    {
                        //<link rel="stylesheet"
                        DomAttribute relAttr;
                        if (htmlElement.TryGetAttribute(WellknownName.Rel, out relAttr))
                        {
                            //switch link type
                            switch (relAttr.Value.ToLower())
                            {
                            case "stylesheet":
                            {
                                //if found
                                DomAttribute hrefAttr;
                                if (htmlElement.TryGetAttribute(WellknownName.Href, out hrefAttr))
                                {
                                    string stylesheet = RaiseRequestStyleSheet(hrefAttr.Value);
                                    if (stylesheet != null)
                                    {
                                        activeCssTemplate.LoadRawStyleElementContent(stylesheet);
                                    }
                                }
                            }
                            break;

                            case "import":
                            {
                                //load data canbe sync or async
                                DomAttribute hrefAttr;
                                if (htmlElement.TryGetAttribute(WellknownName.Href, out hrefAttr))
                                {
                                    //import other html, reuseable html component
                                    //TODO: implement import request algo here
                                }
                            }
                            break;
                            }
                        }
                        activeCssTemplate.ExitLevel();
                        continue;
                    }
                    }
                    //-----------------------------
                    //apply style for this node
                    ApplyStyleSheetForSingleHtmlElement(htmlElement, parentElement.Spec, activeCssTemplate);
                    //-----------------------------

                    //recursive
                    PrepareStylesAndContentOfChildNodes(htmlElement, activeCssTemplate);
                    //-----------------------------
                }
                break;

                case WebDom.HtmlNodeKind.TextNode:
                {
                    UpdateTextNode(parentElement, (HtmlTextNode)node, isblockContext);
                }
                break;
                }

                activeCssTemplate.ExitLevel();
            }
        }
Beispiel #6
0
        void ApplyStyleSheetForSingleHtmlElement(
            HtmlElement element,
            BoxSpec parentSpec,
            TopDownActiveCssTemplate activeCssTemplate)
        {
            BoxSpec curSpec = element.Spec;

            BoxSpec.InheritStyles(curSpec, parentSpec);
            //--------------------------------
            string classValue = null;

            if (element.HasAttributeClass)
            {
                classValue = element.AttrClassValue;
            }
            //--------------------------------
            //1. apply style
            activeCssTemplate.ApplyCacheTemplate(element.LocalName,
                                                 classValue,//class
                                                 curSpec,
                                                 parentSpec);
            //-------------------------------------------------------------------
            //2. specific id
            if (element.HasAttributeElementId)
            {
                // element.ElementId;
                activeCssTemplate.ApplyActiveTemplateForSpecificElementId(element);
            }
            //3. some html translate attributes

            if (element.WellknownElementName != WellKnownDomNodeName.svg)
            {
                //translate svg attributes
                AssignStylesFromTranslatedAttributesHTML5(element);
            }
            else
            {
                AssignSvgAttributes(element);
            }
            //-------------------------------------------------------------------
            //4. style attribute value
            //'style' object of this element
            if (!element.IsStyleEvaluated)
            {
                CssRuleSet parsedRuleSet = null;
                string     attrStyleValue;
                if (element.TryGetAttribute(WellknownName.Style, out attrStyleValue))
                {
                    //parse and evaluate the ruleset
                    parsedRuleSet = _miniCssParser.ParseCssPropertyDeclarationList(attrStyleValue.ToCharArray());
                    foreach (WebDom.CssPropertyDeclaration propDecl in parsedRuleSet.GetAssignmentIter())
                    {
                        SpecSetter.AssignPropertyValue(
                            curSpec,
                            parentSpec,
                            propDecl);
                    }
                }
                else
                {
                }
                //----------------------------------------------------------------
                element.IsStyleEvaluated = true;
                element.ElementRuleSet   = parsedRuleSet;
            }
            else
            {
                var elemRuleSet = element.ElementRuleSet;
                if (elemRuleSet != null)
                {
                    if (curSpec.IsFreezed)
                    {
                        curSpec.Defreeze();
                        //var newspec = new BoxSpec();
                        //BoxSpec.CloneAllStyles(newspec, curSpec);
                        //curSpec = newspec;
                        //element.Spec = curSpec;
                    }

                    foreach (WebDom.CssPropertyDeclaration propDecl in elemRuleSet.GetAssignmentIter())
                    {
                        SpecSetter.AssignPropertyValue(
                            curSpec,
                            parentSpec,
                            propDecl);
                    }
                }
            }
            //=====================
            curSpec.Freeze(); //***
            //=====================
        }
        void PrepareStylesAndContentOfChildNodes(
           HtmlElement parentElement,
           TopDownActiveCssTemplate activeCssTemplate)
        {
            //recursive 
            CssBox principalCssBox = parentElement.CurrentPrincipalBox;
            bool isblockContext = true;//default
            if (principalCssBox != null)
            {
                isblockContext = principalCssBox.IsBlock;
            }

            foreach (WebDom.DomNode node in parentElement.GetChildNodeIterForward())
            {
                activeCssTemplate.EnterLevel();
                switch (node.NodeType)
                {
                    case WebDom.HtmlNodeType.OpenElement:
                    case WebDom.HtmlNodeType.ShortElement:
                        {
                            HtmlElement htmlElement = (HtmlElement)node;
                            htmlElement.WellknownElementName = UserMapUtil.EvaluateTagName(htmlElement.LocalName);
                            switch (htmlElement.WellknownElementName)
                            {
                                case WellKnownDomNodeName.style:
                                    {
                                        //style element should have textnode child
                                        int j = htmlElement.ChildrenCount;
                                        for (int i = 0; i < j; ++i)
                                        {
                                            var ch = htmlElement.GetChildNode(i);
                                            switch (ch.NodeType)
                                            {
                                                case HtmlNodeType.TextNode:
                                                    {
                                                        HtmlTextNode textNode = (HtmlTextNode)htmlElement.GetChildNode(0);
                                                        activeCssTemplate.LoadRawStyleElementContent(new string(textNode.GetOriginalBuffer()));
                                                        //break
                                                        i = j;
                                                    }
                                                    break;
                                            }
                                        }
                                        activeCssTemplate.ExitLevel();
                                        continue;
                                    }
                                case WellKnownDomNodeName.link:
                                    {
                                        //<link rel="stylesheet"
                                        DomAttribute relAttr;
                                        if (htmlElement.TryGetAttribute(WellknownName.Rel, out relAttr))
                                        {
                                            //switch link type
                                            switch (relAttr.Value.ToLower())
                                            {
                                                case "stylesheet":
                                                    {
                                                        //if found
                                                        DomAttribute hrefAttr;
                                                        if (htmlElement.TryGetAttribute(WellknownName.Href, out hrefAttr))
                                                        {
                                                            string stylesheet = RaiseRequestStyleSheet(hrefAttr.Value);
                                                            if (stylesheet != null)
                                                            {
                                                                activeCssTemplate.LoadRawStyleElementContent(stylesheet);
                                                            }
                                                        }
                                                    }
                                                    break;
                                                case "import":
                                                    {
                                                        //load data canbe sync or async
                                                        DomAttribute hrefAttr;
                                                        if (htmlElement.TryGetAttribute(WellknownName.Href, out hrefAttr))
                                                        {
                                                            //import other html, reuseable html component
                                                            //TODO: implement import request algo here
                                                        }
                                                    }
                                                    break;
                                            }
                                        }
                                        activeCssTemplate.ExitLevel();
                                        continue;
                                    }
                            }
                            //-----------------------------                            
                            //apply style for this node  
                            ApplyStyleSheetForSingleHtmlElement(htmlElement, parentElement.Spec, activeCssTemplate);
                            //-----------------------------

                            //recursive 
                            PrepareStylesAndContentOfChildNodes(htmlElement, activeCssTemplate);
                            //-----------------------------
                        }
                        break;
                    case WebDom.HtmlNodeType.TextNode:
                        {
                            HtmlTextNode textnode = (HtmlTextNode)node;
                            //inner content is parsed here 

                            var parentSpec = parentElement.Spec;
                            char[] originalBuffer = textnode.GetOriginalBuffer();
                            List<CssRun> runlist = new List<CssRun>();
                            bool hasSomeCharacter;
                            contentTextSplitter.ParseWordContent(originalBuffer, parentSpec, isblockContext, runlist, out hasSomeCharacter);
                            textnode.SetSplitParts(runlist, hasSomeCharacter);
                        }
                        break;
                }

                activeCssTemplate.ExitLevel();
            }
        }
        ///// <summary>
        ///// Set the selected text style (selection text color and background color).
        ///// </summary>
        ///// <param name="htmlContainer"> </param>
        ///// <param name="cssData">the style data</param>
        //static void SetTextSelectionStyle(HtmlIsland htmlContainer, CssActiveSheet cssData)
        //{
        //    //comment out for another technique


        //    //foreach (var block in cssData.GetCssRuleSetIter("::selection"))
        //    //{
        //    //    if (block.Properties.ContainsKey("color"))
        //    //        htmlContainer.SelectionForeColor = CssValueParser.GetActualColor(block.GetPropertyValueAsString("color"));
        //    //    if (block.Properties.ContainsKey("background-color"))
        //    //        htmlContainer.SelectionBackColor = CssValueParser.GetActualColor(block.GetPropertyValueAsString("background-color"));
        //    //}

        //    //if (cssData.ContainsCssBlock("::selection"))
        //    //{
        //    //    var blocks = cssData.GetCssBlock("::selection");
        //    //    foreach (var block in blocks)
        //    //    {

        //    //    }
        //    //}
        //}
        private static void AssignStylesForElementId(CssBox box, TopDownActiveCssTemplate activeCssTemplate, string elementId)
        {
            throw new NotSupportedException();
            //foreach (var ruleSet in cssData.GetCssRuleSetIter(elementId))
            //{
            //    if (IsBlockAssignableToBox(box, ruleSet))
            //    {
            //        AssignStyleToCssBox(box, ruleSet);
            //    }
            //}
        }
        void ApplyStyleSheetForSingleHtmlElement(
          HtmlElement element,
          BoxSpec parentSpec,
          TopDownActiveCssTemplate activeCssTemplate)
        {
            BoxSpec curSpec = element.Spec;
            BoxSpec.InheritStyles(curSpec, parentSpec);
            //--------------------------------
            string classValue = null;
            if (element.HasAttributeClass)
            {
                classValue = element.AttrClassValue;
            }
            //-------------------------------- 
            //1. apply style  
            activeCssTemplate.ApplyCacheTemplate(element.LocalName,
                 classValue,//class
                 curSpec,
                 parentSpec);
            //-------------------------------------------------------------------  
            //2. specific id 
            if (element.HasAttributeElementId)
            {
                // element.ElementId;
                activeCssTemplate.ApplyActiveTemplateForSpecificElementId(element);
            }
            //3. some html translate attributes

            if (element.WellknownElementName != WellKnownDomNodeName.svg)
            {
                //translate svg attributes
                AssignStylesFromTranslatedAttributesHTML5(element);
            }
            else
            {
                AssignSvgAttributes(element);
            }
            //------------------------------------------------------------------- 
            //4. style attribute value 
            //'style' object of this element
            if (!element.IsStyleEvaluated)
            {
                CssRuleSet parsedRuleSet = null;
                string attrStyleValue;
                if (element.TryGetAttribute(WellknownName.Style, out attrStyleValue))
                {
                    //parse and evaluate the ruleset
                    parsedRuleSet = miniCssParser.ParseCssPropertyDeclarationList(attrStyleValue.ToCharArray());
                    foreach (WebDom.CssPropertyDeclaration propDecl in parsedRuleSet.GetAssignmentIter())
                    {
                        SpecSetter.AssignPropertyValue(
                            curSpec,
                            parentSpec,
                            propDecl);
                    }
                }
                else
                {
                }
                //----------------------------------------------------------------
                element.IsStyleEvaluated = true;
                element.ElementRuleSet = parsedRuleSet;
            }
            else
            {
                var elemRuleSet = element.ElementRuleSet;
                if (elemRuleSet != null)
                {
                    if (curSpec.IsFreezed)
                    {
                        curSpec.Defreeze();
                        //var newspec = new BoxSpec();
                        //BoxSpec.CloneAllStyles(newspec, curSpec);
                        //curSpec = newspec;
                        //element.Spec = curSpec;
                    }

                    foreach (WebDom.CssPropertyDeclaration propDecl in elemRuleSet.GetAssignmentIter())
                    {
                        SpecSetter.AssignPropertyValue(
                            curSpec,
                            parentSpec,
                            propDecl);
                    }
                }
            }
            //===================== 
            curSpec.Freeze(); //***
            //===================== 
        }
        //public CssBox BuildCssRenderTree(
        //   HtmlElement hostElement,
        //   HtmlElement domElement,
        //   RenderElement containerElement)
        //{
        //    var rootgfx = containerElement.Root;
        //    IFonts ifonts = rootgfx.SampleIFonts;
        //    HtmlDocument htmldoc = domElement.OwnerDocument as HtmlDocument;
        //    HtmlElement startAtHtmlElement = (HtmlElement)domElement;

        //    htmldoc.SetDocumentState(DocumentState.Building);
        //    TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(htmldoc.CssActiveSheet);
        //    PrepareStylesAndContentOfChildNodes(startAtHtmlElement, activeTemplate);

        //    //1.css box for doc root: create new if not exist
        //    CssBox docRoot = HtmlElement.InternalGetPrincipalBox((HtmlElement)htmldoc.RootNode);
        //    if (docRoot == null)
        //    {
        //        docRoot = HtmlHost.CreateBridgeBox(ifonts, containerElement, rootgfx);
        //        ((HtmlElement)htmldoc.RootNode).SetPrincipalBox(docRoot);
        //    }

        //    //----------------------------------------------------------------  
        //    CssBox bridgeBox = HtmlHost.CreateBridgeBox(ifonts, containerElement, rootgfx);
        //    docRoot.AppendChild(bridgeBox);
        //    domElement.SetPrincipalBox(bridgeBox);
        //    //----------------------------------------------------------------  

        //    this.htmlHost.UpdateChildBoxes(startAtHtmlElement, true);
        //    htmldoc.SetDocumentState(DocumentState.Idle);
        //    //----------------------------------------------------------------  
        //    //SetTextSelectionStyle(htmlCont, cssData);
        //    return bridgeBox;
        //}


        //----------------------------------------------------------------
        public void RefreshCssTree(DomElement startAt)
        {
            HtmlElement startAtElement = (HtmlElement)startAt;
            startAtElement.OwnerDocument.SetDocumentState(DocumentState.Building);
            //----------------------------------------------------------------     
            //clear active template

            TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(((HtmlDocument)startAtElement.OwnerDocument).CssActiveSheet);
            PrepareStylesAndContentOfChildNodes(startAtElement, activeTemplate);
            CssBox existingCssBox = HtmlElement.InternalGetPrincipalBox(startAtElement);
            if (existingCssBox != null)
            {
                existingCssBox.Clear();
            }
            //----------------------------------------------------------------  


            this.htmlHost.UpdateChildBoxes(startAtElement, false);
            startAtElement.OwnerDocument.SetDocumentState(DocumentState.Idle);
            //----------------------------------------------------------------   
        }
 public CssBox BuildCssRenderTree2(
    LayoutFarm.WebDom.Impl.HtmlDocument htmldoc,
    CssActiveSheet cssActiveSheet,
    RootGraphic rootgfx)
 {
     htmldoc.CssActiveSheet = cssActiveSheet;
     htmldoc.SetDocumentState(DocumentState.Building);
     TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(cssActiveSheet);
     PrepareStylesAndContentOfChildNodes((HtmlElement)htmldoc.RootNode, activeTemplate);
     //TODO: review here, we should create cssbox at document.body?  
     CssBox rootBox = HtmlHost.CreateIsolateBox(TextServices.IFonts, rootgfx);
     ((HtmlElement)htmldoc.RootNode).SetPrincipalBox(rootBox);
     htmlHost.UpdateChildBoxes((HtmlRootElement)htmldoc.RootNode, true);
     htmldoc.SetDocumentState(DocumentState.Idle);
     return rootBox;
 }
        public CssBox BuildCssRenderTree(WebDocument webdoc,
            CssActiveSheet cssActiveSheet,
            RenderElement containerElement)
        {
            HtmlDocument htmldoc = webdoc as HtmlDocument;
            if (htmldoc == null)
            {
                //TODO: fixed here
                throw new NotSupportedException();
            }
            htmldoc.CssActiveSheet = cssActiveSheet;
            htmldoc.SetDocumentState(DocumentState.Building);
            //----------------------------------------------------------------  

            TopDownActiveCssTemplate activeTemplate = new TopDownActiveCssTemplate(cssActiveSheet);
            PrepareStylesAndContentOfChildNodes((HtmlElement)htmldoc.RootNode, activeTemplate);
            //----------------------------------------------------------------  
            RootGraphic rootgfx = (containerElement != null) ? containerElement.Root : null;
            //TODO: review here, we should create cssbox at  document.body? 
            CssBox bridgeBox = HtmlHost.CreateBridgeBox(TextServices.IFonts, containerElement, rootgfx);
            ((HtmlElement)htmldoc.RootNode).SetPrincipalBox(bridgeBox);
            htmlHost.UpdateChildBoxes((HtmlRootElement)htmldoc.RootNode, true);
            htmldoc.SetDocumentState(DocumentState.Idle);
            //----------------------------------------------------------------  
            //SetTextSelectionStyle(htmlCont, cssData);
            return bridgeBox;
        }