internal void SetFormElement(FormElement formElement) { this.formElement = formElement; }
internal IReadOnlyList<Node> ParseFragment(string inputFragment, Element context, string baseUri, ParseErrorList errors) { // context may be null state = HtmlTreeBuilderState.Initial; InitialiseParse(inputFragment, baseUri, errors); contextElement = context; fragmentParsing = true; Element root = null; if (context != null) { if (context.OwnerDocument != null) { // quirks setup: doc.QuirksMode = context.OwnerDocument.QuirksMode; } // initialise the tokeniser state: string contextTag = context.TagName; if (StringUtil.In(contextTag, "title", "textarea")) { tokeniser.Transition(TokeniserState.Rcdata); } else if (StringUtil.In(contextTag, "iframe", "noembed", "noframes", "style", "xmp")) { tokeniser.Transition(TokeniserState.Rawtext); } else if (contextTag.Equals("script")) { tokeniser.Transition(TokeniserState.ScriptData); } else if (contextTag.Equals(("noscript"))) { tokeniser.Transition(TokeniserState.Data); // if scripting enabled, rawtext } else if (contextTag.Equals("plaintext")) { tokeniser.Transition(TokeniserState.Data); } else { tokeniser.Transition(TokeniserState.Data); } // default root = new Element(Tag.ValueOf("html"), baseUri); doc.AppendChild(root); stack.Push(root); ResetInsertionMode(); // setup form element to nearest form on context (up ancestor chain). ensures form controls are associated // with form correctly Elements contextChain = context.Parents; contextChain.Insert(0, context); foreach (Element parent in contextChain) { if (parent is FormElement) { formElement = (FormElement)parent; break; } } } RunParser(); if (context != null) { return root.ChildNodes; } else { return doc.ChildNodes; } }
internal FormElement InsertForm(Token.StartTag startTag, bool onStack) { Tag tag = Tag.ValueOf(startTag.Name()); FormElement el = new FormElement(tag, baseUri, startTag.attributes); SetFormElement(el); InsertNode(el); if (onStack) { stack.AddLast(el); } return el; }