Search in sources :

Example 1 with UnknownElementFactory

use of com.gargoylesoftware.htmlunit.html.UnknownElementFactory in project htmlunit by HtmlUnit.

the class HtmlUnitNekoHTMLErrorHandler method getElementFactory.

/**
 * <span style="color:red">INTERNAL API - SUBJECT TO CHANGE AT ANY TIME - USE AT YOUR OWN RISK.</span><br>
 *
 * Returns the pre-registered element factory corresponding to the specified tag, or an UnknownElementFactory.
 * @param page the page
 * @param namespaceURI the namespace URI
 * @param qualifiedName the qualified name
 * @param insideSvg is the node inside an SVG node or not
 * @param svgSupport true if called from javascript createElementNS
 * @return the pre-registered element factory corresponding to the specified tag, or an UnknownElementFactory
 */
@Override
public ElementFactory getElementFactory(final SgmlPage page, final String namespaceURI, final String qualifiedName, final boolean insideSvg, final boolean svgSupport) {
    if (insideSvg) {
        return SVG_FACTORY;
    }
    if (namespaceURI == null || namespaceURI.isEmpty() || Html.XHTML_NAMESPACE.equals(namespaceURI) || Html.SVG_NAMESPACE.equals(namespaceURI) || !qualifiedName.contains(":")) {
        String tagName = qualifiedName;
        final int index = tagName.indexOf(':');
        if (index == -1) {
            tagName = tagName.toLowerCase(Locale.ROOT);
        } else {
            tagName = tagName.substring(index + 1);
        }
        final ElementFactory factory;
        if (svgSupport && !"svg".equals(tagName) && Html.SVG_NAMESPACE.equals(namespaceURI)) {
            factory = SVG_FACTORY;
        } else {
            factory = ELEMENT_FACTORIES.get(tagName);
        }
        if (factory != null) {
            return factory;
        }
    }
    return UnknownElementFactory.instance;
}
Also used : UnknownElementFactory(com.gargoylesoftware.htmlunit.html.UnknownElementFactory) SvgElementFactory(com.gargoylesoftware.htmlunit.svg.SvgElementFactory) DefaultElementFactory(com.gargoylesoftware.htmlunit.html.DefaultElementFactory) ElementFactory(com.gargoylesoftware.htmlunit.html.ElementFactory)

Aggregations

DefaultElementFactory (com.gargoylesoftware.htmlunit.html.DefaultElementFactory)1 ElementFactory (com.gargoylesoftware.htmlunit.html.ElementFactory)1 UnknownElementFactory (com.gargoylesoftware.htmlunit.html.UnknownElementFactory)1 SvgElementFactory (com.gargoylesoftware.htmlunit.svg.SvgElementFactory)1