상속: INode
예제 #1
0
        void CreateBoxContent(HtmlElement elem)
        {
            //recursive ***

            _docBuilder.OnVisitNewElement(elem.Name);
            //
            _docBuilder.CurrentMathNode.SetController(elem); //**

            //some nodes have special content
            //linear gradient
            foreach (LayoutFarm.WebDom.DomAttribute attr in elem.GetAttributeIterForward())
            {
                _docBuilder.OnAttribute(attr.Name, attr.Value);
            }

            _docBuilder.OnEnteringElementBody();
            int j = elem.ChildrenCount;

            for (int i = 0; i < j; ++i)
            {
                LayoutFarm.WebDom.DomNode childNode = elem.GetChildNode(i);
                switch (childNode.NodeKind)
                {
                case LayoutFarm.WebDom.HtmlNodeKind.OpenElement:
                {
                    if (childNode is HtmlElement htmlElem)
                    {
                        //recursive ***
                        CreateBoxContent(htmlElem);
                    }
                }
                break;

                case LayoutFarm.WebDom.HtmlNodeKind.TextNode:
                {
                    if (childNode is HtmlTextNode textnode)
                    {
                        if (elem.WellknownElementName == LayoutFarm.WebDom.WellKnownDomNodeName.style)
                        {
                            //content of style node
                            MathStyleSpec styleSpec = (MathStyleSpec)_docBuilder.CurrentMathNode.ElemSpec;
                            //content of the style elem
                            //parse
                            styleSpec.RawTextContent = new string(textnode.GetOriginalBuffer());
                            //parse css content of the style element

                            //TODO: review this again
                            //LayoutFarm.WebDom.Parser.CssParserHelper.ParseStyleSheet(styleSpec.CssSheet = new LayoutFarm.WebDom.CssActiveSheet(), styleSpec.RawTextContent);
                            //_currentDoc.CssActiveSheet.Combine(styleSpec.CssSheet);
                            //TODO: review Combine again
                        }
                    }
                }
                break;
                }
            }
            _docBuilder.OnExitingElementBody();
        }
예제 #2
0
 public override void AddChild(DomNode childNode)
 {
     //add dom node to this node
     if (childNode.ParentNode != null)
     {
         throw new NotSupportedException("remove from its parent first");
     }
     shadowDoc.RootNode.AddChild(childNode);
 }
예제 #3
0
 void DescibeNode(DomNode node, TreeNode parentNode)
 {
     var node_info = node.ToString();
     var treeNode = new TreeNode(node_info);
     parentNode.Nodes.Add(treeNode);
     var domElt = node as DomElement;
     if (domElt != null)
     {
         var childCount = domElt.ChildrenCount;
         for (int i = 0; i < childCount; ++i)
         {
             DescibeNode(domElt.GetChildNode(i), treeNode);
         }
     }
 }
예제 #4
0
 internal void SetParent(DomNode parentNode)
 {
     this.parentNode = parentNode;
 }
예제 #5
0
 internal void SetParent(DomNode parentNode)
 {
     this.parentNode = parentNode;
 }
예제 #6
0
 internal void SetParent(DomNode parentNode)
 {
     _parentNode = parentNode;
 }
예제 #7
0
 public void SetSubParentNode(DomNode subParentNode)
 {
     _subParentNode = subParentNode;
 }
예제 #8
0
 public virtual bool RemoveChild(DomNode childNode)
 {
     switch (childNode.NodeType)
     {
         case HtmlNodeType.Attribute:
             {
                 //TODO: support remove attribute
                 return false;
             }
         default:
             {
                 if (myChildrenNodes != null)
                 {
                     bool result = myChildrenNodes.Remove(childNode);
                     if (result)
                     {
                         childNode.SetParent(null);
                         NotifyChange(ElementChangeKind.RemoveChild);
                     }
                     return result;
                 }
                 return false;
             }
     }
 }
예제 #9
0
 public virtual void AddChild(DomNode childNode)
 {
     switch (childNode.NodeType)
     {
         case HtmlNodeType.Attribute:
             {
                 AddAttribute((DomAttribute)childNode);
             }
             break;
         default:
             {
                 if (myChildrenNodes == null)
                 {
                     myChildrenNodes = new List<DomNode>();
                 }
                 myChildrenNodes.Add((DomNode)childNode);
                 childNode.SetParent(this);
                 NotifyChange(ElementChangeKind.AddChild);
             }
             break;
     }
 }
예제 #10
0
 public override bool RemoveChild(DomNode childNode)
 {
     //remove presentation
     var childElement = childNode as HtmlElement;
     if (childElement != null && childElement.ParentNode == this)
     {
         if (this.principalBox != null)
         {
             var cssbox = childElement.CurrentPrincipalBox;
             if (cssbox != null)
             {
                 //remove from parent
                 principalBox.RemoveChild(cssbox);
             }
         }
     }
     return base.RemoveChild(childNode);
 }