|
@@ -3,59 +3,12 @@
|
|
#include <AK/StringBuilder.h>
|
|
#include <AK/StringBuilder.h>
|
|
#include <LibHTML/DOM/DocumentType.h>
|
|
#include <LibHTML/DOM/DocumentType.h>
|
|
#include <LibHTML/DOM/Element.h>
|
|
#include <LibHTML/DOM/Element.h>
|
|
-#include <LibHTML/DOM/HTMLAnchorElement.h>
|
|
|
|
-#include <LibHTML/DOM/HTMLBlinkElement.h>
|
|
|
|
-#include <LibHTML/DOM/HTMLBodyElement.h>
|
|
|
|
-#include <LibHTML/DOM/HTMLFontElement.h>
|
|
|
|
-#include <LibHTML/DOM/HTMLHRElement.h>
|
|
|
|
-#include <LibHTML/DOM/HTMLHeadElement.h>
|
|
|
|
-#include <LibHTML/DOM/HTMLHeadingElement.h>
|
|
|
|
-#include <LibHTML/DOM/HTMLHtmlElement.h>
|
|
|
|
-#include <LibHTML/DOM/HTMLImageElement.h>
|
|
|
|
-#include <LibHTML/DOM/HTMLLinkElement.h>
|
|
|
|
-#include <LibHTML/DOM/HTMLStyleElement.h>
|
|
|
|
-#include <LibHTML/DOM/HTMLTitleElement.h>
|
|
|
|
|
|
+#include <LibHTML/DOM/ElementFactory.h>
|
|
#include <LibHTML/DOM/Text.h>
|
|
#include <LibHTML/DOM/Text.h>
|
|
#include <LibHTML/Parser/HTMLParser.h>
|
|
#include <LibHTML/Parser/HTMLParser.h>
|
|
#include <ctype.h>
|
|
#include <ctype.h>
|
|
#include <stdio.h>
|
|
#include <stdio.h>
|
|
|
|
|
|
-static NonnullRefPtr<Element> create_element(Document& document, const String& tag_name)
|
|
|
|
-{
|
|
|
|
- auto lowercase_tag_name = tag_name.to_lowercase();
|
|
|
|
- if (lowercase_tag_name == "a")
|
|
|
|
- return adopt(*new HTMLAnchorElement(document, tag_name));
|
|
|
|
- if (lowercase_tag_name == "html")
|
|
|
|
- return adopt(*new HTMLHtmlElement(document, tag_name));
|
|
|
|
- if (lowercase_tag_name == "head")
|
|
|
|
- return adopt(*new HTMLHeadElement(document, tag_name));
|
|
|
|
- if (lowercase_tag_name == "body")
|
|
|
|
- return adopt(*new HTMLBodyElement(document, tag_name));
|
|
|
|
- if (lowercase_tag_name == "font")
|
|
|
|
- return adopt(*new HTMLFontElement(document, tag_name));
|
|
|
|
- if (lowercase_tag_name == "hr")
|
|
|
|
- return adopt(*new HTMLHRElement(document, tag_name));
|
|
|
|
- if (lowercase_tag_name == "style")
|
|
|
|
- return adopt(*new HTMLStyleElement(document, tag_name));
|
|
|
|
- if (lowercase_tag_name == "title")
|
|
|
|
- return adopt(*new HTMLTitleElement(document, tag_name));
|
|
|
|
- if (lowercase_tag_name == "link")
|
|
|
|
- return adopt(*new HTMLLinkElement(document, tag_name));
|
|
|
|
- if (lowercase_tag_name == "img")
|
|
|
|
- return adopt(*new HTMLImageElement(document, tag_name));
|
|
|
|
- if (lowercase_tag_name == "blink")
|
|
|
|
- return adopt(*new HTMLBlinkElement(document, tag_name));
|
|
|
|
- if (lowercase_tag_name == "h1"
|
|
|
|
- || lowercase_tag_name == "h2"
|
|
|
|
- || lowercase_tag_name == "h3"
|
|
|
|
- || lowercase_tag_name == "h4"
|
|
|
|
- || lowercase_tag_name == "h5"
|
|
|
|
- || lowercase_tag_name == "h6") {
|
|
|
|
- return adopt(*new HTMLHeadingElement(document, tag_name));
|
|
|
|
- }
|
|
|
|
- return adopt(*new Element(document, tag_name));
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
static bool is_valid_in_attribute_name(char ch)
|
|
static bool is_valid_in_attribute_name(char ch)
|
|
{
|
|
{
|
|
return isalnum(ch) || ch == '_' || ch == '-';
|
|
return isalnum(ch) || ch == '_' || ch == '-';
|