void XMLTreeBuilder::processStartTag(const AtomicXMLToken& token) { exitText(); bool isFirstElement = !m_sawFirstElement; m_sawFirstElement = true; NodeStackItem top = m_currentNodeStack.last(); processNamespaces(token, top); QualifiedName qName(token.prefix(), token.name(), top.namespaceForPrefix(token.prefix(), top.namespaceURI())); RefPtr<Element> newElement = m_document->createElement(qName, true); processAttributes(token, top, newElement); newElement->beginParsingChildren(); m_currentNodeStack.last().node()->parserAddChild(newElement.get()); top.setNode(newElement); pushCurrentNode(top); if (!newElement->attached()) newElement->attach(); if (isFirstElement && m_document->frame()) m_document->frame()->loader()->dispatchDocumentElementAvailable(); if (token.selfClosing()) closeElement(newElement); }
void XMLTreeBuilder::processEndTag(const AtomicXMLToken& token) { exitText(); RefPtr<ContainerNode> node = m_currentNodeStack.last().node(); if (!node->hasTagName(QualifiedName(token.prefix(), token.name(), m_currentNodeStack.last().namespaceForPrefix(token.prefix(), m_currentNodeStack.last().namespaceURI())))) m_parser->stopParsing(); closeElement(toElement(node.get())); }