示例#1
0
        /// <summary>Called when this node has been created and is being added to the given lexer.
        /// Closely related to Element.OnLexerCloseNode.</summary>
        /// <returns>True if this element handled itself.</returns>
        public override bool OnLexerAddNode(HtmlLexer lexer, int mode)
        {
            // Most common case:
            if (mode == HtmlTreeMode.InTable)
            {
                // Caption in table:
                lexer.CloseToTableContext();

                lexer.AddScopeMarker();
                lexer.Push(this, true);
                lexer.CurrentMode = HtmlTreeMode.InCaption;
            }
            else if (mode == HtmlTreeMode.InBody)
            {
                // [Table component] - Parse error if this appears in the body.
                // Just ignore it.
            }
            else if (mode == HtmlTreeMode.InSelectInTable)
            {
                // [Table component] - Close a select (and reprocess) when it appears:
                lexer.CloseSelect(true, this, null);
            }
            else if (mode == HtmlTreeMode.InCaption)
            {
                // [Table component] - Close it and reprocess:
                lexer.CloseCaption(this, null);
            }
            else if (mode == HtmlTreeMode.InCell)
            {
                // [Table component] - Close to table cell if <th> or <td> is in scope and reprocess:
                lexer.CloseIfThOrTr(this, null);
            }
            else if (mode == HtmlTreeMode.InTableBody)
            {
                // [Table component] - Close to table if in a table body context and reprocess:
                lexer.CloseToTableBodyIfBody(this, null);
            }
            else if (mode == HtmlTreeMode.InRow)
            {
                // [Table component] - Close to table body if <tr> is in scope and reprocess:
                lexer.TableBodyIfTrInScope(this, null);
            }
            else if (mode == HtmlTreeMode.InTemplate)
            {
                // [Table component] - Step the template:
                lexer.TemplateStep(this, null, HtmlTreeMode.InTable);
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        /// <summary>Called when this node has been created and is being added to the given lexer.
        /// Closely related to Element.OnLexerCloseNode.</summary>
        /// <returns>True if this element handled itself.</returns>
        public override bool OnLexerAddNode(HtmlLexer lexer, int mode)
        {
            if ((mode & InHeadOpen) != 0)
            {
                // Opening a template
                lexer.Push(this, true);

                lexer.AddScopeMarker();
                lexer.FramesetOk  = false;
                lexer.CurrentMode = HtmlTreeMode.InTemplate;
                lexer.TemplateModes.Push(HtmlTreeMode.InTemplate);
            }
            else if (mode == HtmlTreeMode.AfterHead)
            {
                lexer.AfterHeadHeadTag(this);
            }
            else
            {
                return(false);
            }

            return(true);
        }
示例#3
0
文件: td.cs 项目: HippoAR/DemoPowerUI
        /// <summary>Called when this node has been created and is being added to the given lexer.
        /// Closely related to Element.OnLexerCloseNode.</summary>
        /// <returns>True if this element handled itself.</returns>
        public override bool OnLexerAddNode(HtmlLexer lexer, int mode)
        {
            // Most common:
            if (mode == HtmlTreeMode.InRow)
            {
                lexer.CloseToTableRowContext();

                lexer.Push(this, true);

                lexer.CurrentMode = HtmlTreeMode.InCell;

                lexer.AddScopeMarker();
            }
            else if (mode == HtmlTreeMode.InTableBody)
            {
                lexer.CloseToTableBodyContext();

                Element el = lexer.CreateTag("tr", true);
                lexer.Push(el, true);
                lexer.CurrentMode = HtmlTreeMode.InRow;

                // Reproc:
                lexer.Process(this, null);
            }
            else if (mode == HtmlTreeMode.InTable)
            {
                lexer.CloseToTableContext();

                // Create a tbody:
                Element el = lexer.CreateTag("tbody", true);
                lexer.Push(el, true);
                lexer.CurrentMode = HtmlTreeMode.InTableBody;

                // Reproc:
                lexer.Process(this, null);
            }
            else if (mode == HtmlTreeMode.InCell)
            {
                // [Table component] - Close to table cell if <th> or <td> is in scope and reprocess:
                lexer.CloseIfThOrTr(this, null);
            }
            else if (mode == HtmlTreeMode.InSelectInTable)
            {
                // [Table component] - Close a select (and reprocess) when it appears:
                lexer.CloseSelect(true, this, null);
            }
            else if (mode == HtmlTreeMode.InTemplate)
            {
                // [Table component] - Step the template:
                lexer.TemplateStep(this, null, HtmlTreeMode.InRow);
            }
            else if (mode == HtmlTreeMode.InCaption)
            {
                // [Table component] - Close it and reprocess:
                lexer.CloseCaption(this, null);
            }
            else if (mode == HtmlTreeMode.InBody)
            {
                // [Table component] - Parse error if this appears in the body.
                // Just ignore it.
            }
            else
            {
                return(false);
            }

            return(true);
        }