Inheritance: LayoutFarm.WebDom.Impl.HtmlElement
        public static CssBox CreateTableColumnOrColumnGroup(CssBox parent,
            HtmlElement childElement, bool fixDisplayType, CssDisplay selectedCssDisplayType)
        {
            CssBox col = null;
            if (fixDisplayType)
            {
                col = new CssBox(childElement.Spec, parent.RootGfx, selectedCssDisplayType);
            }
            else
            {
                col = new CssBox(childElement.Spec, parent.RootGfx);
            }
            col.SetController(childElement);
            parent.AppendChild(col);
            string spanValue;
            int spanNum = 1;//default
            if (childElement.TryGetAttribute(WellknownName.Span, out spanValue))
            {
                if (!int.TryParse(spanValue, out spanNum))
                {
                    spanNum = 1;
                }
                if (spanNum < 0)
                {
                    spanNum = -spanNum;
                }
            }

            col.SetRowSpanAndColSpan(1, spanNum);
            return col;
        }
 public static CssBox CreateOtherPredefinedTableElement(CssBox parent,
     HtmlElement childElement, CssDisplay selectedCssDisplayType)
 {
     var newBox = new CssBox(childElement.Spec, parent.RootGfx, selectedCssDisplayType);
     newBox.SetController(childElement);
     parent.AppendChild(newBox);
     return newBox;
 }
Exemple #3
0
 public static CssBoxSvgRoot CreateSvgBox(CssBox parentBox,
     HtmlElement elementNode,
     Css.BoxSpec spec)
 {
     SvgFragment fragment = new SvgFragment();
     SvgRootEventPortal svgRootController = new SvgRootEventPortal(elementNode);
     CssBoxSvgRoot svgRoot = new CssBoxSvgRoot(
         elementNode.Spec,
         parentBox.RootGfx,
         fragment);
     svgRoot.SetController(svgRootController);
     svgRootController.SvgRoot = svgRoot;
     parentBox.AppendChild(svgRoot);
     CreateSvgBoxContent(fragment, elementNode);
     return svgRoot;
 }
        public static CssBox CreateTableCell(CssBox parent, HtmlElement childElement, bool fixDisplayType)
        {
            CssBox tableCell = null;
            if (fixDisplayType)
            {
                tableCell = new CssBox(childElement.Spec, parent.RootGfx, CssDisplay.TableCell);
            }
            else
            {
                tableCell = new CssBox(childElement.Spec, parent.RootGfx);
            }
            tableCell.SetController(childElement);
            parent.AppendChild(tableCell);
            //----------------------------------------------------------------------------------------------


            //----------------------------------------------------------------------------------------------
            //get rowspan and colspan here 
            int nRowSpan = 1;
            int nColSpan = 1;
            string rowspan;
            if (childElement.TryGetAttribute(WellknownName.RowSpan, out rowspan))
            {
                if (!int.TryParse(rowspan, out nRowSpan))
                {
                    nRowSpan = 1;
                }
            }
            string colspan;
            if (childElement.TryGetAttribute(WellknownName.ColSpan, out colspan))
            {
                if (!int.TryParse(colspan, out nColSpan))
                {
                    nColSpan = 1;
                }
            }
            //---------------------------------------------------------- 
            tableCell.SetRowSpanAndColSpan(nRowSpan, nColSpan);
            return tableCell;
        }
 public EaseScriptElement(DomElement elem)
 {
     this.elem = elem as HtmlElement;
 }
        static void AssignStylesFromTranslatedAttributesHTML5(HtmlElement tag)
        {
            //some html attr contains css value   
            if (tag.AttributeCount > 0)
            {
                foreach (var attr in tag.GetAttributeIterForward())
                {
                    //attr switch by wellknown property name 
                    switch ((WebDom.WellknownName)attr.LocalNameIndex)
                    {
                        case WebDom.WellknownName.Align:
                            {
                                //deprecated in HTML4.1
                                //string value = attr.Value.ToLower();
                                //if (value == "left"
                                //    || value == "center"
                                //    || value == "right"
                                //    || value == "justify")
                                //{
                                //    WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
                                //        value, WebDom.CssValueHint.Iden);

                                //    box.CssTextAlign = UserMapUtil.GetTextAlign(propValue);
                                //}
                                //else
                                //{
                                //    WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
                                //     value, WebDom.CssValueHint.Iden);
                                //    box.VerticalAlign = UserMapUtil.GetVerticalAlign(propValue);
                                //}
                                //break;
                            }
                            break;
                        case WebDom.WellknownName.Background:
                            //deprecated in HTML4.1
                            //box.BackgroundImageBinder = new ImageBinder(attr.Value.ToLower());
                            break;
                        case WebDom.WellknownName.BackgroundColor:
                            //deprecated in HTML5
                            //box.BackgroundColor = CssValueParser.GetActualColor(attr.Value.ToLower());
                            break;
                        case WebDom.WellknownName.Border:
                            {
                                //not support in HTML5 
                                //CssLength borderLen = TranslateLength(UserMapUtil.MakeBorderLength(attr.Value.ToLower()));
                                //if (!borderLen.HasError)
                                //{

                                //    if (borderLen.Number > 0)
                                //    {
                                //        box.BorderLeftStyle =
                                //            box.BorderTopStyle =
                                //            box.BorderRightStyle =
                                //            box.BorderBottomStyle = CssBorderStyle.Solid;
                                //    }

                                //    box.BorderLeftWidth =
                                //    box.BorderTopWidth =
                                //    box.BorderRightWidth =
                                //    box.BorderBottomWidth = borderLen;

                                //    if (tag.WellknownTagName == WellknownHtmlTagName.TABLE && borderLen.Number > 0)
                                //    {
                                //        //Cascades to the TD's the border spacified in the TABLE tag.
                                //        var borderWidth = CssLength.MakePixelLength(1);
                                //        ForEachCellInTable(box, cell =>
                                //        {
                                //            //for all cells
                                //            cell.BorderLeftStyle = cell.BorderTopStyle = cell.BorderRightStyle = cell.BorderBottomStyle = CssBorderStyle.Solid; // CssConstants.Solid;
                                //            cell.BorderLeftWidth = cell.BorderTopWidth = cell.BorderRightWidth = cell.BorderBottomWidth = borderWidth;
                                //        });

                                //    }

                                //}
                            }
                            break;
                        case WebDom.WellknownName.BorderColor:

                            //box.BorderLeftColor =
                            //    box.BorderTopColor =
                            //    box.BorderRightColor =
                            //    box.BorderBottomColor = CssValueParser.GetActualColor(attr.Value.ToLower());

                            break;
                        case WebDom.WellknownName.CellSpacing:

                            //html5 not support in HTML5, use CSS instead
                            //box.BorderSpacingHorizontal = box.BorderSpacingVertical = TranslateLength(attr);

                            break;
                        case WebDom.WellknownName.CellPadding:
                            {
                                //html5 not support in HTML5, use CSS instead ***

                                //                                CssLength len01 = UserMapUtil.ParseGenericLength(attr.Value.ToLower());
                                //                                if (len01.HasError && (len01.Number > 0))
                                //                                {
                                //                                    CssLength len02 = CssLength.MakePixelLength(len01.Number);
                                //                                    ForEachCellInTable(box, cell =>
                                //                                    {
                                //#if DEBUG
                                //                                        // cell.dbugBB = dbugTT++;
                                //#endif
                                //                                        cell.PaddingLeft = cell.PaddingTop = cell.PaddingRight = cell.PaddingBottom = len02;
                                //                                    });

                                //                                }
                                //                                else
                                //                                {
                                //                                    ForEachCellInTable(box, cell =>
                                //                                         cell.PaddingLeft = cell.PaddingTop = cell.PaddingRight = cell.PaddingBottom = len01);
                                //                                }

                            }
                            break;
                        case WebDom.WellknownName.Color:

                            //deprecate  
                            // box.Color = CssValueParser.GetActualColor(attr.Value.ToLower());
                            break;
                        case WebDom.WellknownName.Dir:
                            {
                                WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
                                        attr.Value.ToLower(), WebDom.CssValueHint.Iden);
                                //assign 
                                var spec = tag.Spec;
                                spec.CssDirection = UserMapUtil.GetCssDirection(propValue);
                            }
                            break;
                        case WebDom.WellknownName.Face:
                            //deprecate
                            //box.FontFamily = CssParser.ParseFontFamily(attr.Value.ToLower());
                            break;
                        case WebDom.WellknownName.Height:
                            {
                                var spec = tag.Spec;
                                spec.Height = TranslateLength(attr);
                            }
                            break;
                        case WebDom.WellknownName.HSpace:
                            //deprecated
                            //box.MarginRight = box.MarginLeft = TranslateLength(attr);
                            break;
                        case WebDom.WellknownName.Nowrap:
                            //deprecate
                            //box.WhiteSpace = CssWhiteSpace.NoWrap;
                            break;
                        case WebDom.WellknownName.Size:
                            {
                                //deprecate 
                                //switch (tag.WellknownTagName)
                                //{
                                //    case WellknownHtmlTagName.HR:
                                //        {
                                //            box.Height = TranslateLength(attr);
                                //        } break;
                                //    case WellknownHtmlTagName.FONT:
                                //        {
                                //            var ruleset = activeTemplate.ParseCssBlock("", attr.Value.ToLower());
                                //            foreach (WebDom.CssPropertyDeclaration propDecl in ruleset.GetAssignmentIter())
                                //            {
                                //                //assign each property
                                //                AssignPropertyValue(box, box.ParentBox, propDecl);
                                //            }
                                //            //WebDom.CssCodePrimitiveExpression prim = new WebDom.CssCodePrimitiveExpression(value, 
                                //            //box.SetFontSize(value);
                                //        } break;
                                //}
                            }
                            break;
                        case WebDom.WellknownName.VAlign:
                            {
                                //w3.org 
                                //valign for table display elements:
                                //col,colgroup,tbody,td,tfoot,th,thead,tr

                                WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
                                          attr.Value.ToLower(), WebDom.CssValueHint.Iden);
                                tag.Spec.VerticalAlign = UserMapUtil.GetVerticalAlign(propValue);
                            }
                            break;
                        case WebDom.WellknownName.VSpace:
                            //deprecated
                            //box.MarginTop = box.MarginBottom = TranslateLength(attr);
                            break;
                        case WebDom.WellknownName.Width:
                            {
                                var spec = tag.Spec;
                                spec.Width = TranslateLength(attr);
                            }
                            break;
                        case WellknownName.Src:
                            {
                                var cssBoxImage = HtmlElement.InternalGetPrincipalBox(tag) as CssBoxImage;
                                if (cssBoxImage != null)
                                {
                                    string imgsrc;
                                    //ImageBinder imgBinder = null;
                                    if (tag.TryGetAttribute(WellknownName.Src, out imgsrc))
                                    {
                                        var cssBoxImage1 = HtmlElement.InternalGetPrincipalBox(tag) as CssBoxImage;
                                        var imgbinder1 = cssBoxImage1.ImageBinder;
                                        if (imgbinder1.ImageSource != imgsrc)
                                        {
                                            var clientImageBinder = new ClientImageBinder(imgsrc);
                                            imgbinder1 = clientImageBinder;
                                            clientImageBinder.SetOwner(tag);
                                            cssBoxImage1.ImageBinder = clientImageBinder;
                                        }
                                    }
                                    else
                                    {
                                        //var clientImageBinder = new ClientImageBinder(null);
                                        //imgBinder = clientImageBinder;
                                        //clientImageBinder.SetOwner(tag);

                                    }
                                }
                            }
                            break;
                    }
                }
            }
        }
        //        static void AssignStylesFromTranslatedAttributes_Old(CssBox box, ActiveCssTemplate activeTemplate)
        //        {
        //            //some html attr contains css value 
        //            IHtmlElement tag = box.HtmlElement;
        //            if (tag.HasAttributes())
        //            {
        //                foreach (IHtmlAttribute attr in tag.GetAttributeIter())
        //                {
        //                    //attr switch by wellknown property name 
        //                    switch ((WebDom.WellknownHtmlName)attr.LocalNameIndex)
        //                    {
        //                        case WebDom.WellknownHtmlName.Align:
        //                            {
        //                                //align attribute -- deprecated in HTML5

        //                                string value = attr.Value.ToLower();
        //                                if (value == "left"
        //                                    || value == "center"
        //                                    || value == "right"
        //                                    || value == "justify")
        //                                {
        //                                    WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
        //                                        value, WebDom.CssValueHint.Iden);

        //                                    box.CssTextAlign = UserMapUtil.GetTextAlign(propValue);
        //                                }
        //                                else
        //                                {
        //                                    WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
        //                                     value, WebDom.CssValueHint.Iden);
        //                                    box.VerticalAlign = UserMapUtil.GetVerticalAlign(propValue);
        //                                }
        //                                break;
        //                            }
        //                        case WebDom.WellknownHtmlName.Background:
        //                            box.BackgroundImageBinder = new ImageBinder(attr.Value.ToLower());
        //                            break;
        //                        case WebDom.WellknownHtmlName.BackgroundColor:
        //                            box.BackgroundColor = CssValueParser.GetActualColor(attr.Value.ToLower());
        //                            break;
        //                        case WebDom.WellknownHtmlName.Border:
        //                            {
        //                                //not support in HTML5 
        //                                CssLength borderLen = TranslateLength(UserMapUtil.MakeBorderLength(attr.Value.ToLower()));
        //                                if (!borderLen.HasError)
        //                                {

        //                                    if (borderLen.Number > 0)
        //                                    {
        //                                        box.BorderLeftStyle =
        //                                            box.BorderTopStyle =
        //                                            box.BorderRightStyle =
        //                                            box.BorderBottomStyle = CssBorderStyle.Solid;
        //                                    }

        //                                    box.BorderLeftWidth =
        //                                    box.BorderTopWidth =
        //                                    box.BorderRightWidth =
        //                                    box.BorderBottomWidth = borderLen;

        //                                    if (tag.WellknownTagName == WellknownHtmlTagName.table && borderLen.Number > 0)
        //                                    {
        //                                        //Cascades to the TD's the border spacified in the TABLE tag.
        //                                        var borderWidth = CssLength.MakePixelLength(1);
        //                                        ForEachCellInTable(box, cell =>
        //                                        {
        //                                            //for all cells
        //                                            cell.BorderLeftStyle = cell.BorderTopStyle = cell.BorderRightStyle = cell.BorderBottomStyle = CssBorderStyle.Solid; // CssConstants.Solid;
        //                                            cell.BorderLeftWidth = cell.BorderTopWidth = cell.BorderRightWidth = cell.BorderBottomWidth = borderWidth;
        //                                        });

        //                                    }

        //                                }
        //                            } break;
        //                        case WebDom.WellknownHtmlName.BorderColor:

        //                            box.BorderLeftColor =
        //                                box.BorderTopColor =
        //                                box.BorderRightColor =
        //                                box.BorderBottomColor = CssValueParser.GetActualColor(attr.Value.ToLower());

        //                            break;
        //                        case WebDom.WellknownHtmlName.CellSpacing:

        //                            //html5 not support in HTML5, use CSS instead
        //                            box.BorderSpacingHorizontal = box.BorderSpacingVertical = TranslateLength(attr);

        //                            break;
        //                        case WebDom.WellknownHtmlName.CellPadding:
        //                            {
        //                                //html5 not support in HTML5, use CSS instead ***

        //                                CssLength len01 = UserMapUtil.ParseGenericLength(attr.Value.ToLower());
        //                                if (len01.HasError && (len01.Number > 0))
        //                                {
        //                                    CssLength len02 = CssLength.MakePixelLength(len01.Number);
        //                                    ForEachCellInTable(box, cell =>
        //                                    {
        //#if DEBUG
        //                                        // cell.dbugBB = dbugTT++;
        //#endif
        //                                        cell.PaddingLeft = cell.PaddingTop = cell.PaddingRight = cell.PaddingBottom = len02;
        //                                    });

        //                                }
        //                                else
        //                                {
        //                                    ForEachCellInTable(box, cell =>
        //                                         cell.PaddingLeft = cell.PaddingTop = cell.PaddingRight = cell.PaddingBottom = len01);
        //                                }

        //                            } break;
        //                        case WebDom.WellknownHtmlName.Color:

        //                            box.Color = CssValueParser.GetActualColor(attr.Value.ToLower());
        //                            break;
        //                        case WebDom.WellknownHtmlName.Dir:
        //                            {
        //                                WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
        //                                        attr.Value.ToLower(), WebDom.CssValueHint.Iden);
        //                                box.CssDirection = UserMapUtil.GetCssDirection(propValue);
        //                            }
        //                            break;
        //                        case WebDom.WellknownHtmlName.Face:
        //                            box.FontFamily = CssParser.ParseFontFamily(attr.Value.ToLower());
        //                            break;
        //                        case WebDom.WellknownHtmlName.Height:
        //                            box.Height = TranslateLength(attr);
        //                            break;
        //                        case WebDom.WellknownHtmlName.HSpace:
        //                            box.MarginRight = box.MarginLeft = TranslateLength(attr);
        //                            break;
        //                        case WebDom.WellknownHtmlName.Nowrap:
        //                            box.WhiteSpace = CssWhiteSpace.NoWrap;
        //                            break;
        //                        case WebDom.WellknownHtmlName.Size:
        //                            {
        //                                switch (tag.WellknownTagName)
        //                                {
        //                                    case WellknownHtmlTagName.hr:
        //                                        {
        //                                            box.Height = TranslateLength(attr);
        //                                        } break;
        //                                    case WellknownHtmlTagName.font:
        //                                        {
        //                                            //font tag is not support in Html5
        //                                            var ruleset = activeTemplate.ParseCssBlock("", attr.Value.ToLower());
        //                                            foreach (WebDom.CssPropertyDeclaration propDecl in ruleset.GetAssignmentIter())
        //                                            {
        //                                                //assign each property
        //                                                CssPropSetter.AssignPropertyValue(
        //                                                    box.Spec,
        //                                                    box.ParentBox.Spec,
        //                                                    propDecl);
        //                                            }

        //                                        } break;
        //                                }
        //                            } break;
        //                        case WebDom.WellknownHtmlName.VAlign:
        //                            {
        //                                WebDom.CssCodePrimitiveExpression propValue = new WebDom.CssCodePrimitiveExpression(
        //                                          attr.Value.ToLower(), WebDom.CssValueHint.Iden);
        //                                box.VerticalAlign = UserMapUtil.GetVerticalAlign(propValue);
        //                            } break;
        //                        case WebDom.WellknownHtmlName.VSpace:
        //                            box.MarginTop = box.MarginBottom = TranslateLength(attr);
        //                            break;
        //                        case WebDom.WellknownHtmlName.Width:
        //                            box.Width = TranslateLength(attr);
        //                            break;
        //                    }
        //                }
        //            }
        //        }

        static void AssignSvgAttributes(HtmlElement tag)
        {
            Svg.SvgCreator.TranslateSvgAttributesMain(tag);
        }
        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();
            }
        }
Exemple #9
0
 internal static CssBox InternalGetPrincipalBox(HtmlElement element)
 {
     return(element.principalBox);
 }
Exemple #10
0
        internal CssBox CreateBox(CssBox parentBox, HtmlElement childElement, bool fullmode)
        {
            //----------------------------------------- 
            //1. create new box
            //----------------------------------------- 
            //some box has predefined behaviour 
            CssBox newBox = null;
            switch (childElement.WellknownElementName)
            {
                case WellKnownDomNodeName.br:
                    //special treatment for br
                    newBox = new CssBox(childElement.Spec, parentBox.RootGfx);
                    newBox.SetController(childElement);
                    CssBox.SetAsBrBox(newBox);
                    CssBox.ChangeDisplayType(newBox, CssDisplay.Block);
                    parentBox.AppendChild(newBox);
                    childElement.SetPrincipalBox(newBox);
                    return newBox;
                case WellKnownDomNodeName.img:

                    //auto append newBox to parentBox
                    newBox = CreateImageBox(parentBox, childElement);
                    childElement.SetPrincipalBox(newBox);
                    return newBox;
                case WellKnownDomNodeName.hr:
                    newBox = new CssBoxHr(childElement.Spec, parentBox.RootGfx);
                    newBox.SetController(childElement);
                    parentBox.AppendChild(newBox);
                    childElement.SetPrincipalBox(newBox);
                    return newBox;
                //-----------------------------------------------------
                //TODO: simplify this ...
                //table-display elements, fix display type
                case WellKnownDomNodeName.td:
                case WellKnownDomNodeName.th:
                    newBox = TableBoxCreator.CreateTableCell(parentBox, childElement, true);
                    break;
                case WellKnownDomNodeName.col:
                    newBox = TableBoxCreator.CreateTableColumnOrColumnGroup(parentBox, childElement, true, CssDisplay.TableColumn);
                    break;
                case WellKnownDomNodeName.colgroup:
                    newBox = TableBoxCreator.CreateTableColumnOrColumnGroup(parentBox, childElement, true, CssDisplay.TableColumnGroup);
                    break;
                case WellKnownDomNodeName.tr:
                    newBox = TableBoxCreator.CreateOtherPredefinedTableElement(parentBox, childElement, CssDisplay.TableRow);
                    break;
                case WellKnownDomNodeName.tbody:
                    newBox = TableBoxCreator.CreateOtherPredefinedTableElement(parentBox, childElement, CssDisplay.TableRowGroup);
                    break;
                case WellKnownDomNodeName.table:
                    newBox = TableBoxCreator.CreateOtherPredefinedTableElement(parentBox, childElement, CssDisplay.Table);
                    break;
                case WellKnownDomNodeName.caption:
                    newBox = TableBoxCreator.CreateOtherPredefinedTableElement(parentBox, childElement, CssDisplay.TableCaption);
                    break;
                case WellKnownDomNodeName.thead:
                    newBox = TableBoxCreator.CreateOtherPredefinedTableElement(parentBox, childElement, CssDisplay.TableHeaderGroup);
                    break;
                case WellKnownDomNodeName.tfoot:
                    newBox = TableBoxCreator.CreateOtherPredefinedTableElement(parentBox, childElement, CssDisplay.TableFooterGroup);
                    break;
                //---------------------------------------------------
                case WellKnownDomNodeName.canvas:
                case WellKnownDomNodeName.input:

                    newBox = this.CreateCustomCssBox(parentBox, childElement, childElement.Spec);
                    if (newBox != null)
                    {
                        childElement.SetPrincipalBox(newBox);
                        return newBox;
                    }
                    goto default; //else goto default *** 
                //---------------------------------------------------
                case WellKnownDomNodeName.svg:
                    {
                        //1. create svg container node 
                        newBox = Svg.SvgCreator.CreateSvgBox(parentBox, childElement, childElement.Spec);
                        childElement.SetPrincipalBox(newBox);
                        return newBox;
                    }
                case WellKnownDomNodeName.NotAssign:
                case WellKnownDomNodeName.Unknown:
                    {
                        //custom tag
                        //check if this is tag is registered as custom element
                        //-----------------------------------------------
                        if (childElement.HasCustomPrincipalBoxGenerator)
                        {
                            var childbox = childElement.GetPrincipalBox(parentBox, this);
                            parentBox.AppendChild(childbox);
                            return childbox;
                        }

                        //----------------------------------------------- 
                        LayoutFarm.Composers.CreateCssBoxDelegate foundBoxGen;
                        if (((HtmlDocument)childElement.OwnerDocument).TryGetCustomBoxGenerator(childElement.Name, out foundBoxGen))
                        {
                            //create custom box 
                            newBox = foundBoxGen(childElement, parentBox, childElement.Spec, this);
                        }
                        if (newBox == null)
                        {
                            goto default;
                        }
                        else
                        {
                            childElement.SetPrincipalBox(newBox);
                            return newBox;
                        }
                    }
                default:
                    {
                        BoxSpec childSpec = childElement.Spec;
                        switch (childSpec.CssDisplay)
                        {
                            //not fixed display type
                            case CssDisplay.TableCell:
                                newBox = TableBoxCreator.CreateTableCell(parentBox, childElement, false);
                                break;
                            case CssDisplay.TableColumn:
                                newBox = TableBoxCreator.CreateTableColumnOrColumnGroup(parentBox, childElement, false, CssDisplay.TableColumn);
                                break;
                            case CssDisplay.TableColumnGroup:
                                newBox = TableBoxCreator.CreateTableColumnOrColumnGroup(parentBox, childElement, false, CssDisplay.TableColumnGroup);
                                break;
                            case CssDisplay.ListItem:
                                newBox = ListItemBoxCreator.CreateListItemBox(parentBox, childElement);
                                break;
                            default:
                                newBox = new CssBox(childSpec, parentBox.RootGfx);
                                newBox.SetController(childElement);
                                parentBox.AppendChild(newBox);
                                break;
                        }
                    }
                    break;
            }

            childElement.SetPrincipalBox(newBox);
            UpdateChildBoxes(childElement, fullmode);
            return newBox;
        }
Exemple #11
0
        static void CreateSvgGroupElement(SvgElement parentNode, HtmlElement elem)
        {
            SvgVisualSpec spec = new SvgVisualSpec();
            SvgGroupElement svgGroupElement = new SvgGroupElement(spec, elem);
            parentNode.AddChild(svgGroupElement);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                    case WebDom.WellknownName.Svg_Fill:
                        {
                            spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Stroke:
                        {
                            spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Stroke_Width:
                        {
                            spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    default:
                        {
                            //other attrs
                        }
                        break;
                }
            }

            CreateSvgBoxContent(svgGroupElement, elem);
        }
        /// <summary>
        /// Gets the index of the box to be used on a (ordered) list
        /// </summary>
        /// <returns></returns>
        static int GetIndexForList(CssBox box, HtmlElement childElement)
        {
            HtmlElement parentNode = childElement.ParentNode as HtmlElement;
            int index = 1;
            string reversedAttrValue;
            bool reversed = false;
            if (parentNode.TryGetAttribute(WellknownName.Reversed, out reversedAttrValue))
            {
                reversed = true;
            }
            string startAttrValue;
            if (!parentNode.TryGetAttribute(WellknownName.Start, out startAttrValue))
            {
                //if not found
                //TODO: not to loop count ?

                if (reversed)
                {
                    index = 0;
                    foreach (CssBox b in box.ParentBox.GetChildBoxIter())
                    {
                        if (b.CssDisplay == CssDisplay.ListItem)
                        {
                            index++;
                        }
                    }
                }
                else
                {
                    index = 1;
                }
            }
            foreach (CssBox b in box.ParentBox.GetChildBoxIter())
            {
                if (b == box)
                    return index;
                if (b.CssDisplay == CssDisplay.ListItem)
                    index += reversed ? -1 : 1;
            }
            return index;
        }
Exemple #13
0
        static void CreateSvgPath(SvgElement parentNode, HtmlElement elem)
        {
            SvgPathSpec spec = new SvgPathSpec();
            SvgPath svgPath = new SvgPath(spec, elem);
            parentNode.AddChild(svgPath);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                    case WebDom.WellknownName.Svg_X:
                        {
                            spec.X = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Y:
                        {
                            spec.Y = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Width:
                        {
                            spec.Width = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Height:
                        {
                            spec.Height = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Fill:
                        {
                            spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Stroke:
                        {
                            spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Stroke_Width:
                        {
                            spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WebDom.WellknownName.Svg_Transform:
                        {
                            //TODO: parse svg transform function   


                        }
                        break;
                    default:
                        {
                            //other attrs
                            switch (attr.Name)
                            {
                                case "d":
                                    {
                                        //parse vertex commands 
                                        Svg.Pathing.SvgPathDataParser parser = new Svg.Pathing.SvgPathDataParser();
                                        svgPath.Segments = parser.Parse(attr.Value.ToCharArray());
                                    }
                                    break;
                            }
                        }
                        break;
                }
            }
        }
Exemple #14
0
 static void CreateSvgPolyline(SvgElement parentNode, HtmlElement elem)
 {
     SvgPolylineSpec spec = new SvgPolylineSpec();
     SvgPolyline shape = new SvgPolyline(spec, elem);
     parentNode.AddChild(shape);
     foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
     {
         WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
         switch (wellknownName)
         {
             case WebDom.WellknownName.Svg_Points:
                 {
                     //parse points
                     spec.Points = ParsePointList(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Fill:
                 {
                     spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Stroke:
                 {
                     spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Stroke_Width:
                 {
                     spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Transform:
                 {
                     //TODO: parse svg transform function  
                 }
                 break;
             default:
                 {
                     //other attrs
                 }
                 break;
         }
     }
 }
Exemple #15
0
 static void CreateSvgBoxContent(
   SvgElement parentElement,
   HtmlElement elementNode)
 {
     int j = elementNode.ChildrenCount;
     for (int i = 0; i < j; ++i)
     {
         HtmlElement node = elementNode.GetChildNode(i) as HtmlElement;
         if (node == null)
         {
             continue;
         }
         switch (node.WellknownElementName)
         {
             case WellKnownDomNodeName.svg_rect:
                 {
                     CreateSvgRect(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_circle:
                 {
                     //sample circle from 
                     //www.svgbasics.com/shapes.html
                     CreateSvgCircle(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_ellipse:
                 {
                     CreateSvgEllipse(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_polygon:
                 {
                     CreateSvgPolygon(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_polyline:
                 {
                     CreateSvgPolyline(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_defs:
                 {
                     CreateSvgDefs(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_linearGradient:
                 {
                     CreateSvgLinearGradient(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_path:
                 {
                     CreateSvgPath(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_image:
                 {
                     CreateSvgImage(parentElement, node);
                 }
                 break;
             case WellKnownDomNodeName.svg_g:
                 {
                     CreateSvgGroupElement(parentElement, node);
                 }
                 break;
             default:
                 {
                 }
                 break;
         }
     }
 }
Exemple #16
0
        static void CreateSvgLinearGradient(SvgElement parentNode, HtmlElement elem)
        {
            //linear gradient definition

            SvgLinearGradient linearGradient = new SvgLinearGradient(elem);
            foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                switch (wellknownName)
                {
                    case WellknownName.Svg_X1:
                        {
                            linearGradient.X1 = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WellknownName.Svg_X2:
                        {
                            linearGradient.X2 = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WellknownName.Svg_Y1:
                        {
                            linearGradient.Y1 = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                    case WellknownName.Svg_Y2:
                        {
                            linearGradient.Y2 = UserMapUtil.ParseGenericLength(attr.Value);
                        }
                        break;
                }
            }
            //------------------------------------------------------------
            int j = elem.ChildrenCount;
            List<StopColorPoint> stopColorPoints = new List<StopColorPoint>(j);
            for (int i = 0; i < j; ++i)
            {
                HtmlElement node = elem.GetChildNode(i) as HtmlElement;
                if (node == null)
                {
                    continue;
                }
                switch (node.WellknownElementName)
                {
                    case WellKnownDomNodeName.svg_stop:
                        {
                            //stop point
                            StopColorPoint stopPoint = new StopColorPoint();
                            foreach (WebDom.DomAttribute attr in node.GetAttributeIterForward())
                            {
                                WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
                                switch (wellknownName)
                                {
                                    case WellknownName.Svg_StopColor:
                                        {
                                            stopPoint.StopColor = CssValueParser.GetActualColor(attr.Value);
                                        }
                                        break;
                                    case WellknownName.Svg_Offset:
                                        {
                                            stopPoint.Offset = UserMapUtil.ParseGenericLength(attr.Value);
                                        }
                                        break;
                                }
                            }
                            stopColorPoints.Add(stopPoint);
                        }
                        break;
                }
            }
        }
Exemple #17
0
 static void CreateSvgDefs(SvgElement parentNode, HtmlElement elem)
 {
     //inside single definition
     SvgDefinitionList svgDefList = new SvgDefinitionList(elem);
     parentNode.AddChild(svgDefList);
     CreateSvgBoxContent(svgDefList, elem);
 }
 public static CssBox CreateListItemBox(CssBox parent, HtmlElement childElement)
 {
     var spec = childElement.Spec;
     var newBox = new CssBoxListItem(spec, parent.RootGfx);
     newBox.SetController(childElement);
     parent.AppendChild(newBox);
     if (spec.ListStyleType != CssListStyleType.None)
     {
         //create sub item collection 
         var itemBulletBox = new CssBox(spec.GetAnonVersion(), parent.RootGfx);
         newBox.BulletBox = itemBulletBox;
         CssBox.UnsafeSetParent(itemBulletBox, newBox);
         CssBox.ChangeDisplayType(itemBulletBox, CssDisplay.Inline);
         //---------------------------------------------------------------
         //set content of bullet 
         char[] text_content = null;
         switch (spec.ListStyleType)
         {
             case CssListStyleType.Disc:
                 {
                     text_content = discItem;
                 }
                 break;
             case CssListStyleType.Circle:
                 {
                     text_content = circleItem;
                 }
                 break;
             case CssListStyleType.Square:
                 {
                     text_content = squareItem;
                 }
                 break;
             case CssListStyleType.Decimal:
                 {
                     text_content = (GetIndexForList(newBox, childElement).ToString(CultureInfo.InvariantCulture) + ".").ToCharArray();
                 }
                 break;
             case CssListStyleType.DecimalLeadingZero:
                 {
                     text_content = (GetIndexForList(newBox, childElement).ToString("00", CultureInfo.InvariantCulture) + ".").ToCharArray();
                 }
                 break;
             default:
                 {
                     text_content = (BulletNumberFormatter.ConvertToAlphaNumber(GetIndexForList(newBox, childElement), spec.ListStyleType) + ".").ToCharArray();
                 }
                 break;
         }
         //--------------------------------------------------------------- 
         CssBox.UnsafeSetTextBuffer(itemBulletBox, text_content);
         List<CssRun> runlist = new List<CssRun>();
         bool hasSomeCharacter;
         splitter.ParseWordContent(text_content, spec, itemBulletBox.IsBlock, runlist, out hasSomeCharacter);
         RunListHelper.AddRunList(itemBulletBox, spec, runlist, text_content, false);
     }
     return newBox;
 }
Exemple #19
0
 static void CreateSvgImage(SvgElement parentNode, HtmlElement elem)
 {
     SvgImageSpec spec = new SvgImageSpec();
     SvgImage svgImage = new SvgImage(spec, elem);
     parentNode.AddChild(svgImage);
     foreach (WebDom.DomAttribute attr in elem.GetAttributeIterForward())
     {
         WebDom.WellknownName wellknownName = (WebDom.WellknownName)attr.LocalNameIndex;
         switch (wellknownName)
         {
             case WebDom.WellknownName.Svg_X:
                 {
                     spec.X = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Y:
                 {
                     spec.Y = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Width:
                 {
                     spec.Width = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Height:
                 {
                     spec.Height = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Fill:
                 {
                     spec.ActualColor = CssValueParser.GetActualColor(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Stroke:
                 {
                     spec.StrokeColor = CssValueParser.GetActualColor(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Stroke_Width:
                 {
                     spec.StrokeWidth = UserMapUtil.ParseGenericLength(attr.Value);
                 }
                 break;
             case WebDom.WellknownName.Svg_Transform:
                 {
                     //TODO: parse svg transform function    
                 }
                 break;
             case WellknownName.Href:
                 {
                     //image src***
                     spec.ImageSrc = attr.Value;
                 }
                 break;
             default:
                 {
                 }
                 break;
         }
     }
 }
 public SvgRootEventPortal(HtmlElement elementNode)
 {
     this.elementNode = elementNode;
 }
Exemple #21
0
 public static void TranslateSvgAttributesMain(HtmlElement elem)
 {
 }
Exemple #22
0
 public EaseScriptElement(DomElement elem)
 {
     this.elem = elem as HtmlElement;
 }
Exemple #23
0
        /// update some or generate all cssbox
        /// </summary>
        /// <param name="parentElement"></param>
        /// <param name="fullmode">update all nodes (true) or somenode (false)</param>
        internal void UpdateChildBoxes(HtmlElement parentElement, bool fullmode)
        {
            //recursive ***  
            //first just generate into primary pricipal box
            //layout process  will correct it later  

            switch (parentElement.ChildrenCount)
            {
                case 0: { } break;
                case 1:
                    {
                        CssBox hostBox = HtmlElement.InternalGetPrincipalBox(parentElement);
                        //only one child -- easy 
                        DomNode child = parentElement.GetChildNode(0);
                        int newBox = 0;
                        switch (child.NodeType)
                        {
                            case HtmlNodeType.TextNode:
                                {
                                    HtmlTextNode singleTextNode = (HtmlTextNode)child;
                                    RunListHelper.AddRunList(hostBox, parentElement.Spec, singleTextNode);
                                }
                                break;
                            case HtmlNodeType.ShortElement:
                            case HtmlNodeType.OpenElement:
                                {
                                    HtmlElement childElement = (HtmlElement)child;
                                    var spec = childElement.Spec;
                                    if (spec.CssDisplay == CssDisplay.None)
                                    {
                                        return;
                                    }

                                    newBox++;
                                    //-------------------------------------------------- 
                                    if (fullmode)
                                    {
                                        CssBox newbox = CreateBox(hostBox, childElement, fullmode);
                                        childElement.SetPrincipalBox(newbox);
                                    }
                                    else
                                    {
                                        CssBox existing = HtmlElement.InternalGetPrincipalBox(childElement);
                                        if (existing == null)
                                        {
                                            CssBox box = CreateBox(hostBox, childElement, fullmode);
                                            childElement.SetPrincipalBox(box);
                                        }
                                        else
                                        {
                                            //just insert                                                 
                                            hostBox.AppendChild(existing);
                                            if (!childElement.SkipPrincipalBoxEvalulation)
                                            {
                                                existing.Clear();
                                                UpdateChildBoxes(childElement, fullmode);
                                                childElement.SkipPrincipalBoxEvalulation = true;
                                            }
                                        }
                                    }
                                }
                                break;
                        }
                    }
                    break;
                default:
                    {
                        CssBox hostBox = HtmlElement.InternalGetPrincipalBox(parentElement);
                        CssWhiteSpace ws = parentElement.Spec.WhiteSpace;
                        int childCount = parentElement.ChildrenCount;
                        int newBox = 0;
                        for (int i = 0; i < childCount; ++i)
                        {
                            var childNode = parentElement.GetChildNode(i);
                            switch (childNode.NodeType)
                            {
                                case HtmlNodeType.TextNode:
                                    {
                                        HtmlTextNode textNode = (HtmlTextNode)childNode;
                                        switch (ws)
                                        {
                                            case CssWhiteSpace.Pre:
                                            case CssWhiteSpace.PreWrap:
                                                {
                                                    RunListHelper.AddRunList(
                                                        CssBox.AddNewAnonInline(hostBox),
                                                        parentElement.Spec, textNode);
                                                }
                                                break;
                                            case CssWhiteSpace.PreLine:
                                                {
                                                    if (newBox == 0 && textNode.IsWhiteSpace)
                                                    {
                                                        continue;//skip
                                                    }

                                                    RunListHelper.AddRunList(
                                                        CssBox.AddNewAnonInline(hostBox),
                                                        parentElement.Spec, textNode);
                                                }
                                                break;
                                            default:
                                                {
                                                    if (textNode.IsWhiteSpace)
                                                    {
                                                        continue;//skip
                                                    }
                                                    RunListHelper.AddRunList(
                                                        CssBox.AddNewAnonInline(hostBox),
                                                        parentElement.Spec, textNode);
                                                }
                                                break;
                                        }

                                        newBox++;
                                    }
                                    break;
                                case HtmlNodeType.ShortElement:
                                case HtmlNodeType.OpenElement:
                                    {
                                        HtmlElement childElement = (HtmlElement)childNode;
                                        var spec = childElement.Spec;
                                        if (spec.CssDisplay == CssDisplay.None)
                                        {
                                            continue;
                                        }

                                        if (fullmode)
                                        {
                                            CssBox box = CreateBox(hostBox, childElement, fullmode);
                                        }
                                        else
                                        {
                                            CssBox existingCssBox = HtmlElement.InternalGetPrincipalBox(childElement);
                                            if (existingCssBox == null)
                                            {
                                                CssBox box = CreateBox(hostBox, childElement, fullmode);
                                            }
                                            else
                                            {
                                                //just insert           
                                                hostBox.AppendChild(existingCssBox);
                                                if (!childElement.SkipPrincipalBoxEvalulation)
                                                {
                                                    existingCssBox.Clear();
                                                    UpdateChildBoxes(childElement, fullmode);
                                                    childElement.SkipPrincipalBoxEvalulation = true;
                                                }
                                            }
                                        }
                                        newBox++;
                                    }
                                    break;
                                default:
                                    {
                                    }
                                    break;
                            }
                        }
                    }
                    break;
            }
            //----------------------------------
            //summary formatting context
            //that will be used on layout process 
            //---------------------------------- 
        }
        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(); //***
            //===================== 
        }
Exemple #25
0
        CssBox CreateImageBox(CssBox parent, HtmlElement childElement)
        {
            string imgsrc;
            ImageBinder imgBinder = null;
            if (childElement.TryGetAttribute(WellknownName.Src, out imgsrc))
            {
                var clientImageBinder = new ClientImageBinder(imgsrc);
                imgBinder = clientImageBinder;
                clientImageBinder.SetOwner(childElement);
            }
            else
            {
                var clientImageBinder = new ClientImageBinder(null);
                imgBinder = clientImageBinder;
                clientImageBinder.SetOwner(childElement);
            }

            CssBoxImage boxImage = new CssBoxImage(childElement.Spec, parent.RootGfx, imgBinder);
            boxImage.SetController(childElement);
            parent.AppendChild(boxImage);
            return boxImage;
        }
Exemple #26
0
 internal static CssBox InternalGetPrincipalBox(HtmlElement element)
 {
     return element.principalBox;
 }