Ejemplo n.º 1
0
 /// <summary>
 /// 添加子元素
 /// </summary>
 /// <param name="e">要添加的子元素</param>
 /// <returns>操作是否成功</returns>
 public override bool AppendChild(HTMLElement e)
 {
     if (e == this)
     {
         return(true);
     }
     if (this.PrivateCheckChildTagName(e.TagName))
     {
         return(base.AppendChild(e));
     }
     else
     {
         foreach (HTMLElement element in myChildNodes)
         {
             if (element is HTMLContainer)
             {
                 HTMLContainer c = ( HTMLContainer )element;
                 if (c.InnerAppendChild(e))
                 {
                     return(true);
                 }
             }
         }
     }
     return(false);
 }
Ejemplo n.º 2
0
 internal override bool CheckParent(HTMLContainer vParent)
 {
     return(vParent is HTMLIEDeviceRect);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// 创建元素对象实例
        /// </summary>
        /// <param name="TagName">HTML标签名称</param>
        /// <param name="vParent">创建的元素的父节点</param>
        /// <returns>创建的HTML元素对象</returns>
        internal HTMLElement InnerCreateElement(string TagName, HTMLContainer vParent)
        {
            if (HTMLTextReader.isBlankString(TagName))
            {
                return(null);
            }
            HTMLElement NewElement = null;

            TagName = TagName.ToLower().Trim();
            switch (TagName)
            {
            case StringConstTagName.HTML:
                if (vParent == null || vParent == this)
                {
                    NewElement = this;
                }
                else
                {
                    NewElement = new HTMLDivElement();
                }
                break;

            case StringConstTagName.Head:
                if (vParent is HTMLDocument)
                {
                    NewElement = this.Head;
                    if (NewElement == null)
                    {
                        NewElement = new HTMLHeadElement();
                    }
                }
                break;

            case StringConstTagName.Body:
                if (vParent is HTMLDocument)
                {
                    NewElement = this.Body;
                    if (NewElement == null)
                    {
                        NewElement = new HTMLBodyElement();
                    }
                }
                else
                {
                    NewElement = new HTMLDivElement();
                }
                break;

            case StringConstTagName.IEDevicerect:
                NewElement = new HTMLIEDeviceRect();
                break;

            case StringConstTagName.IEHeaderFooter:
                NewElement = new HTMLIEHeaderfooter();
                break;

            case StringConstTagName.IELayoutrect:
                NewElement = new HTMLIELayoutrect();
                break;

            case StringConstTagName.IETemplatePrinter:
                NewElement = new HTMLIETemplateprinter();
                break;

            case StringConstTagName.H1:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 1;
                break;

            case StringConstTagName.H2:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 2;
                break;

            case StringConstTagName.H3:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 3;
                break;

            case StringConstTagName.H4:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 4;
                break;

            case StringConstTagName.H5:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 5;
                break;

            case StringConstTagName.H6:
                NewElement = new HTMLHnElement();
                ((HTMLHnElement)NewElement).Level = 6;
                break;

            case StringConstTagName.Input:
                NewElement = new HTMLInputElement();
                break;

            case StringConstTagName.TextArea:
                NewElement = new HTMLTextAreaElement();
                break;

            case StringConstTagName.Select:
                NewElement = new HTMLSelectElement();
                break;

            case StringConstTagName.Option:
                NewElement = new HTMLOptionElement();
                break;

            case StringConstTagName.Form:
                NewElement = new HTMLFormElement();
                break;

            case StringConstTagName.A:
                NewElement = new HTMLAElement();
                break;

            case StringConstTagName.B:
                NewElement = new HTMLBElement();
                break;

            case StringConstTagName.Pre:
                NewElement = new HTMLPreElement();
                break;

            case StringConstTagName.Span:
                NewElement = new HTMLSpanElement();
                break;

            case StringConstTagName.Div:
                NewElement = new HTMLDivElement();
                break;

            case StringConstTagName.P:
                NewElement = new HTMLPElement();
                break;

            case StringConstTagName.Br:
                NewElement = new HTMLBRElement();
                break;

            case StringConstTagName.Applet:
                NewElement = new HTMLAppletElement();
                break;

            case StringConstTagName.TextNode:
                NewElement = new HTMLTextNodeElement();
                break;

            case StringConstTagName.Object:
                NewElement = new HTMLObjectElement();
                break;

            case StringConstTagName.Script:
                NewElement = new HTMLScriptElement();
                break;

            case StringConstTagName.Link:
                NewElement = new HTMLLinkElement();
                break;

            case StringConstTagName.Font:
                NewElement = new HTMLFontElement();
                break;

            case StringConstTagName.Meta:
                NewElement = new HTMLMetaElement();
                break;

            case StringConstTagName.BGSound:
                NewElement = new HTMLBGSoundElement();
                break;

            case StringConstTagName.Param:
                NewElement = new HTMLParamElement();
                break;

            case StringConstTagName.Comment:
                NewElement = new HTMLCommentElement();
                break;

            case StringConstTagName.Hr:
                NewElement = new HTMLHRElement();
                break;

            case StringConstTagName.Table:
                NewElement = new HTMLTableElement();
                break;

            case StringConstTagName.TBody:
                NewElement = new HTMLTBodyElement();
                break;

            case StringConstTagName.Tr:
                NewElement = new HTMLTRElement();
                break;

            case StringConstTagName.Td:
                NewElement = new HTMLTDElement();
                break;

            case StringConstTagName.Col:
                NewElement = new HTMLColElement();
                break;

            case StringConstTagName.Style:
                NewElement = new HTMLStyleElement();
                break;

            case StringConstTagName.Img:
                NewElement = new HTMLImgElement();
                break;

            case StringConstTagName.Title:
                NewElement = new HTMLTitleElement();
                break;

            case StringConstTagName.UL:
                NewElement = new HTMLULElement();
                break;

            case StringConstTagName.LI:
                NewElement = new HTMLLIElement();
                break;

            case StringConstTagName.Map:
                NewElement = new HTMLMapElement();
                break;

            case StringConstTagName.Area:
                NewElement = new HTMLAreaElement();
                break;

            case StringConstTagName.HTAApplication:
                NewElement = new HTMLHTAApplicationElement();
                break;

            case StringConstTagName.FrameSet:
                NewElement = new HTMLFrameSetElement();
                break;

            case StringConstTagName.Frame:
                NewElement = new HTMLFrameElement();
                break;

            case StringConstTagName.Label:
                NewElement = new HTMLLabelElement();
                break;

            case StringConstTagName.Marquee:
                NewElement = new HTMLMarqueeElement();
                break;

            case StringConstTagName.IFrame:
                NewElement = new HTMLIFrameElement();
                break;

            case StringConstTagName.XML:
                NewElement = new HTMLXMLElement();
                break;

            case StringConstTagName.Sup:
                NewElement = new HTMLSupElement();
                break;

            case StringConstTagName.Sub:
                NewElement = new HTMLSubElement();
                break;

            case StringConstTagName.Nobr:
                NewElement = new HTMLNobarElement();
                break;

            default:
                NewElement = new HTMLUnknowElement();
                (( HTMLUnknowElement)NewElement).SetTagName(TagName);
                break;
            }
            if (NewElement != null)
            {
                NewElement.OwnerDocument = this;
                NewElement.Parent        = vParent;
            }
            return(NewElement);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// 检查指定的容器元素,判断当前元素是否可以为该元素的子元素
 /// </summary>
 /// <param name="vParent">容器元素</param>
 /// <returns>是否可为该元素的子元素</returns>
 internal virtual bool CheckParent(HTMLContainer vParent)
 {
     return(true);
 }