NodeImpl *KHTMLParser::handleIsindex( Token *t )
{
    NodeImpl *n;
    HTMLFormElementImpl *myform = form;
    if ( !myform ) {
        myform = new HTMLFormElementImpl(document, true);
        n = myform;
    } else
        n = new HTMLDivElementImpl( document, ID_DIV );
    NodeImpl *child = new HTMLHRElementImpl( document );
    n->addChild( child );
    AttributeImpl* a = t->attrs ? t->attrs->getAttributeItem(ATTR_PROMPT) : 0;
    DOMString text = i18n("This is a searchable index. Enter search keywords: ");
    if (a)
        text = a->value();
    child = new TextImpl(document, text.implementation());
    n->addChild( child );
    child = new HTMLIsIndexElementImpl(document, myform);
    static_cast<ElementImpl *>(child)->setAttribute(ATTR_TYPE, "khtml_isindex");
    n->addChild( child );
    child = new HTMLHRElementImpl( document );
    n->addChild( child );

    return n;
}
NodeImpl *KHTMLParser::handleIsindex( Token *t )
{
    NodeImpl *n;
    HTMLFormElementImpl *myform = form;
    if ( !myform ) {
        myform = new HTMLFormElementImpl(document);
        n = myform;
    } else
        n = new HTMLDivElementImpl( document );
    NodeImpl *child = new HTMLHRElementImpl( document );
    n->addChild( child );
    AttributeImpl* a = t->attrs ? t->attrs->getAttributeItem(ATTR_PROMPT) : 0;
#if APPLE_CHANGES && !KWIQ
    DOMString text = searchableIndexIntroduction();
#elif KWIQ // FIXME: KWIQ: Internationalization. Hardcoded string.
    DOMString text = "This is a searchable index. Enter search keywords: ";
#else
    DOMString text = i18n("This is a searchable index. Enter search keywords: ");
#endif
    if (a)
        text = DOMString(a->value()) + " ";
    child = new TextImpl(document, text);
    n->addChild( child );
    child = new HTMLIsIndexElementImpl(document, myform);
    static_cast<ElementImpl *>(child)->setAttribute(ATTR_TYPE, "khtml_isindex");
    n->addChild( child );
    child = new HTMLHRElementImpl( document );
    n->addChild( child );

    return n;
}
Beispiel #3
0
bool XMLHandler::startElement(const QString &namespaceURI, const QString & /*localName*/, const QString &qName, const QXmlAttributes &atts)
{
    if(currentNode()->nodeType() == Node::TEXT_NODE)
        exitText();

    DOMString nsURI;
    if(!namespaceURI.isNull())
        nsURI = DOMString(namespaceURI);
    else
        // No namespace declared, default to the no namespace
        nsURI = DOMString("");
    ElementImpl *newElement = m_doc->createElementNS(nsURI, qName);
    if(!newElement)
        return false;
    int i;
    for(i = 0; i < atts.length(); i++)
    {
        int exceptioncode = 0;
        QString uriString = atts.uri(i);
        QString qnString = atts.qName(i);
        fixUpNSURI(uriString, qnString);
        DOMString uri(uriString);
        DOMString qn(qnString);
        DOMString val(atts.value(i));
        newElement->setAttributeNS(uri, qn, val, exceptioncode);
        if(exceptioncode) // exception setting attributes
            return false;
    }

    if(newElement->id() == ID_SCRIPT || newElement->id() == makeId(xhtmlNamespace, ID_SCRIPT))
        static_cast< HTMLScriptElementImpl * >(newElement)->setCreatedByParser(true);

    // this is tricky. in general the node doesn't have to attach to the one it's in. as far
    // as standards go this is wrong, but there's literally thousands of documents where
    // we see <p><ul>...</ul></p>. the following code is there for those cases.
    // when we can't attach to the currently holding us node we try to attach to its parent
    bool attached = false;
    for(NodeImpl *current = currentNode(); current; current = current->parent())
    {
        attached = current->addChild(newElement);
        if(attached)
            break;
    }
    if(attached)
    {
        if(m_view && !newElement->attached() && !m_doc->hasPendingSheets())
            newElement->attach();
        pushNode(newElement);
        return true;
    }
    else
    {
        delete newElement;
        return false;
    }

    // ### DOM spec states: "if there is no markup inside an element's content, the text is contained in a
    // single object implementing the Text interface that is the only child of the element."... do we
    // need to ensure that empty elements always have an empty text child?
}