/// <summary> /// See 8.2.5.4.12 The "in column group" insertion mode. /// </summary> /// <param name="token">The passed token.</param> void InColumnGroup(HtmlToken token) { if (token.Type == HtmlTokenType.Character) { var chars = (HtmlCharacterToken)token; var str = chars.TrimStart(); InsertCharacters(str); } else if (token.Type == HtmlTokenType.Comment) AddComment(CurrentNode, token); else if (token.Type == HtmlTokenType.DOCTYPE) RaiseErrorOccurred(ErrorCode.DoctypeTagInappropriate); else if (token.IsStartTag(HTMLHtmlElement.Tag)) InBody(token); else if (token.IsStartTag(HTMLTableColElement.ColTag)) { var element = new HTMLTableColElement(); AddElementToCurrentNode(element, token, true); CloseCurrentNode(); } else if (token.IsEndTag(HTMLTableColElement.ColgroupTag)) InColumnGroupEndTagColgroup(); else if (token.IsEndTag(HTMLTableColElement.ColTag)) RaiseErrorOccurred(ErrorCode.TagClosedWrong); else if (token.Type == HtmlTokenType.EOF && CurrentNode == doc.DocumentElement) End(); else if (InColumnGroupEndTagColgroup()) InTable(token); }
/// <summary> /// See 8.2.5.4.9 The "in table" insertion mode. /// </summary> /// <param name="token">The passed token.</param> void InTable(HtmlToken token) { if (token.Type == HtmlTokenType.Comment) { AddComment(CurrentNode, token); } else if (token.Type == HtmlTokenType.DOCTYPE) { RaiseErrorOccurred(ErrorCode.DoctypeTagInappropriate); } else if (token.Type == HtmlTokenType.StartTag) { var tag = (HtmlTagToken)token; switch (tag.Name) { case HTMLTableCaptionElement.Tag: { ClearStackBackToTable(); InsertScopeMarker(); var element = new HTMLTableCaptionElement(); AddElementToCurrentNode(element, token); insert = HtmlTreeMode.InCaption; break; } case HTMLTableColElement.ColgroupTag: { ClearStackBackToTable(); var element = new HTMLTableColElement(); AddElementToCurrentNode(element, token); insert = HtmlTreeMode.InColumnGroup; break; } case HTMLTableColElement.ColTag: { InTable(HtmlToken.OpenTag(HTMLTableColElement.ColgroupTag)); InColumnGroup(token); break; } case HTMLTableSectionElement.BodyTag: case HTMLTableSectionElement.HeadTag: case HTMLTableSectionElement.FootTag: { ClearStackBackToTable(); var element = new HTMLTableSectionElement(); AddElementToCurrentNode(element, token); insert = HtmlTreeMode.InTableBody; break; } case HTMLTableCellElement.NormalTag: case HTMLTableCellElement.HeadTag: case HTMLTableRowElement.Tag: { InTable(HtmlToken.OpenTag(HTMLTableSectionElement.BodyTag)); InTableBody(token); break; } case HTMLTableElement.Tag: { RaiseErrorOccurred(ErrorCode.TableNesting); if (InTableEndTagTable()) Consume(token); break; } case HTMLScriptElement.Tag: case HTMLStyleElement.Tag: { InHead(token); break; } case HTMLInputElement.Tag: { if (tag.GetAttribute("type").Equals("hidden", StringComparison.OrdinalIgnoreCase)) { RaiseErrorOccurred(ErrorCode.InputUnexpected); var element = new HTMLInputElement(); AddElementToCurrentNode(element, token, true); CloseCurrentNode(); } else { RaiseErrorOccurred(ErrorCode.TokenNotPossible); InBodyWithFoster(token); } break; } case HTMLFormElement.Tag: { RaiseErrorOccurred(ErrorCode.FormInappropriate); if (form == null) { var element = new HTMLFormElement(); AddElementToCurrentNode(element, token); form = element; CloseCurrentNode(); } break; } default: { RaiseErrorOccurred(ErrorCode.IllegalElementInTableDetected); InBodyWithFoster(token); break; } } } else if (token.Type == HtmlTokenType.EndTag) { var tag = (HtmlTagToken)token; switch (tag.Name) { case HTMLTableElement.Tag: { InTableEndTagTable(); break; } case HTMLBodyElement.Tag: case HTMLTableColElement.ColgroupTag: case HTMLTableColElement.ColTag: case HTMLTableCaptionElement.Tag: case HTMLHtmlElement.Tag: case HTMLTableSectionElement.BodyTag: case HTMLTableRowElement.Tag: case HTMLTableSectionElement.HeadTag: case HTMLTableCellElement.HeadTag: case HTMLTableSectionElement.FootTag: case HTMLTableCellElement.NormalTag: { RaiseErrorOccurred(ErrorCode.TagCannotEndHere); break; } default: { RaiseErrorOccurred(ErrorCode.IllegalElementInTableDetected); InBodyWithFoster(token); break; } } } else if (token.Type == HtmlTokenType.Character && CurrentNode != null && CurrentNode.IsTableElement()) { InTableText((HtmlCharacterToken)token); } else if (token.Type == HtmlTokenType.EOF) { if (CurrentNode != doc.DocumentElement) RaiseErrorOccurred(ErrorCode.CurrentNodeIsNotRoot); End(); } else { RaiseErrorOccurred(ErrorCode.TokenNotPossible); InBodyWithFoster(token); } }
/// <summary> /// See 8.2.5.4.12 The "in column group" insertion mode. /// </summary> /// <param name="token">The passed token.</param> void InColumnGroup(HtmlToken token) { if (token.IsIgnorable) InsertCharacter(((HtmlCharacterToken)token).Data); else if (token.Type == HtmlTokenType.Comment) AddComment(CurrentNode, token); else if (token.Type == HtmlTokenType.DOCTYPE) RaiseErrorOccurred(ErrorCode.DoctypeTagInappropriate); else if (token.Type == HtmlTokenType.StartTag && (((HtmlTagToken)token).Name == HTMLHtmlElement.Tag)) InBody(token); else if (token.Type == HtmlTokenType.StartTag && (((HtmlTagToken)token).Name == HTMLTableColElement.ColTag)) { var element = new HTMLTableColElement(); AddElementToCurrentNode(element, token, true); CloseCurrentNode(); } else if (token.Type == HtmlTokenType.EndTag && (((HtmlTagToken)token).Name == HTMLTableColElement.ColgroupTag)) InColumnGroupEndTagColgroup(); else if (token.Type == HtmlTokenType.EndTag && (((HtmlTagToken)token).Name == HTMLTableColElement.ColTag)) RaiseErrorOccurred(ErrorCode.TagClosedWrong); else if (token.Type == HtmlTokenType.EOF && CurrentNode == doc.DocumentElement) End(); else if (InColumnGroupEndTagColgroup()) InTable(token); }