+2007-10-31 Lars Knoll <lars@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes in the XML tokenizer when using QXmlStream.
+
+ Use new functionality of QXmlStream in Qt 4.4 to simplify
+ the code (but keep the old code for now to still support Qt 4.3).
+
+ Add proper support for namespace handling when parsing into
+ a document fragment.
+
+ * platform/qt/Skipped:
+ * platform/qt/dom/xhtml/level3/core/canonicalform10-expected.txt: Removed.
+ * platform/qt/dom/xhtml/level3/core/canonicalform11-expected.txt: Removed.
+
2007-10-31 Alexey Proskuryakov <ap@webkit.org>
Reviewed by Darin.
editing/selection/5354455-2.html
editing/selection/caret-and-focus-ring.html
-# ------- crashes
-editing/execCommand/copy-without-selection.html
-
# ------- failing editing tests
editing/pasteboard/
editing/undo/undo-typing-001.html
editing/unsupported-content
-
-# ------- tests that fail against Qt 4.3 due to bugs and missing features in QXmlStream
-fast/dom/set-innerHTML.xhtml
-fast/encoding/css-charset-default.xhtml
-fast/encoding/default-xhtml-encoding.xhtml
-fast/encoding/meta-in-xhtml.xhtml
-
# ------- failures due to missing XSLT support
fast/dom/Window/get-set-properties.html
fast/dom/Window/window-properties.html
+++ /dev/null
-layer at (0,0) size 800x600
- RenderView at (0,0) size 800x600
-layer at (0,0) size 800x126
- RenderBlock {html} at (0,0) size 800x126
- RenderBody {body} at (8,16) size 784x94
- RenderBlock (anonymous) at (0,0) size 784x0
- RenderInline {parsererror} at (0,0) size 0x0 [bgcolor=#FFDDDD] [border: (2px solid #CC7777)]
- RenderBlock (anonymous) at (0,0) size 784x94
- RenderBlock {h3} at (0,0) size 784x23
- RenderText {#text} at (0,0) size 301x22
- text run at (0,0) width 301: "This page contains the following errors:"
- RenderBlock {div} at (0,39) size 784x16
- RenderText {#text} at (0,0) size 315x15
- text run at (0,0) width 315: "error on line 1 at column 58: Invalid DOCTYPE"
- RenderBlock {h3} at (0,71) size 784x23
- RenderText {#text} at (0,0) size 393x22
- text run at (0,0) width 393: "Below is a rendering of the page up to the first error."
- RenderBlock (anonymous) at (0,110) size 784x0
- RenderInline {parsererror} at (0,0) size 0x0 [bgcolor=#FFDDDD] [border: (2px solid #CC7777)]
+++ /dev/null
-layer at (0,0) size 800x600
- RenderView at (0,0) size 800x600
-layer at (0,0) size 800x126
- RenderBlock {html} at (0,0) size 800x126
- RenderBody {body} at (8,16) size 784x94
- RenderBlock (anonymous) at (0,0) size 784x0
- RenderInline {parsererror} at (0,0) size 0x0 [bgcolor=#FFDDDD] [border: (2px solid #CC7777)]
- RenderBlock (anonymous) at (0,0) size 784x94
- RenderBlock {h3} at (0,0) size 784x23
- RenderText {#text} at (0,0) size 301x22
- text run at (0,0) width 301: "This page contains the following errors:"
- RenderBlock {div} at (0,39) size 784x16
- RenderText {#text} at (0,0) size 315x15
- text run at (0,0) width 315: "error on line 1 at column 58: Invalid DOCTYPE"
- RenderBlock {h3} at (0,71) size 784x23
- RenderText {#text} at (0,0) size 393x22
- text run at (0,0) width 393: "Below is a rendering of the page up to the first error."
- RenderBlock (anonymous) at (0,110) size 784x0
- RenderInline {parsererror} at (0,0) size 0x0 [bgcolor=#FFDDDD] [border: (2px solid #CC7777)]
+2007-10-31 Lars Knoll <lars@trolltech.com>
+
+ Reviewed by Simon.
+
+ Fixes in the XML tokenizer when using QXmlStream.
+
+ Use new functionality of QXmlStream in Qt 4.4 to simplify
+ the code (but keep the old code for now to still support Qt 4.3).
+
+ Add proper support for namespace handling when parsing into
+ a document fragment.
+
+ * dom/XMLTokenizer.cpp:
+ (WebCore::XMLTokenizer::XMLTokenizer):
+ (WebCore::XMLTokenizer::write):
+ (WebCore::XMLTokenizer::startElementNs):
+ (WebCore::):
+ * dom/XMLTokenizer.h:
+
2007-10-31 Lars Knoll <lars@trolltech.com>
Reviewed by Simon.
XMLTokenizer::XMLTokenizer(DocumentFragment* fragment, Element* parentElement)
: m_doc(fragment->document())
, m_view(0)
-#ifndef USE_QXMLSTREAM
+#ifdef USE_QXMLSTREAM
+ , m_wroteText(false)
+#else
, m_context(0)
#endif
, m_currentNode(fragment)
if (elemStack.isEmpty())
return;
+#ifndef USE_QXMLSTREAM
for (Element* element = elemStack.last(); !elemStack.isEmpty(); elemStack.removeLast()) {
if (NamedAttrMap* attrs = element->attributes()) {
for (unsigned i = 0; i < attrs->length(); i++) {
}
}
}
+#else
+ QXmlStreamNamespaceDeclarations namespaces;
+ for (Element* element = elemStack.last(); !elemStack.isEmpty(); elemStack.removeLast()) {
+ if (NamedAttrMap* attrs = element->attributes()) {
+ for (unsigned i = 0; i < attrs->length(); i++) {
+ Attribute* attr = attrs->attributeItem(i);
+ if (attr->localName() == "xmlns")
+ m_defaultNamespaceURI = attr->value();
+ else if (attr->prefix() == "xmlns")
+ namespaces.append(QXmlStreamNamespaceDeclaration(attr->localName(), attr->value()));
+ }
+ }
+ }
+#if QT_VERSION >= 0x040400
+ m_stream.addExtraNamespaceDeclarations(namespaces);
+#endif
+#endif
}
XMLTokenizer::~XMLTokenizer()
m_wroteText = true;
QString data(parseString);
if (!data.isEmpty()) {
+#if QT_VERSION < 0x040400
if (!m_sawFirstElement) {
int idx = data.indexOf(QLatin1String("<?xml"));
if (idx != -1) {
}
}
}
+#endif
m_stream.addData(data);
parse();
}
String localName = toString(xmlLocalName);
String uri = toString(xmlURI);
String prefix = toString(xmlPrefix);
-
+
if (m_parsingFragment && uri.isNull()) {
if (!prefix.isNull())
uri = m_prefixToNamespaceMap.get(prefix);
int result = xmlParseBalancedChunkMemory(0, &sax, &tokenizer, 0, (const xmlChar*)string.utf8().data(), 0);
return result == 0;
#else
+ tokenizer.write(String("<qxmlstreamdummyelement>"), false);
tokenizer.write(string, false);
+ tokenizer.write(String("</qxmlstreamdummyelement>"), false);
tokenizer.finish();
- return tokenizer.hasError();
+ return !tokenizer.hasError();
#endif
}
initializeParserContext();
ExceptionCode ec = 0;
- if (!m_parsingFragment)
+ if (!m_parsingFragment) {
m_doc->setXMLStandalone(m_stream.isStandaloneDocument(), ec);
+
+#if QT_VERSION >= 0x040400
+ QStringRef version = m_stream.documentVersion();
+ if (!version.isEmpty())
+ m_doc->setXMLVersion(version, ec);
+ QStringRef encoding = m_stream.documentEncoding();
+ if (!encoding.isEmpty())
+ m_doc->setXMLEncoding(encoding);
+#endif
+ }
}
void XMLTokenizer::parseStartElement()
{
+ if (!m_sawFirstElement && m_parsingFragment) {
+ // skip dummy element for fragments
+ m_sawFirstElement = true;
+ return;
+ }
m_sawFirstElement = true;
exitText();
String prefix = prefixFromQName(m_stream.qualifiedName().toString());
if (m_parsingFragment && uri.isNull()) {
- if (!prefix.isNull())
- uri = m_prefixToNamespaceMap.get(prefix);
- else
- uri = m_defaultNamespaceURI;
+ Q_ASSERT (prefix.isNull());
+ uri = m_defaultNamespaceURI;
}
ExceptionCode ec = 0;
exitText();
Node* n = m_currentNode;
+
+ // skip end of dummy element
+// if (m_parsingFragment & n->nodeType() == Node::DOCUMENT_FRAGMENT_NODE)
+// return;
+
RefPtr<Node> parent = n->parentNode();
n->finishedParsing();
return m_stream.hasError();
}
+#if QT_VERSION < 0x040400
static QString parseId(const QString &dtd, int *pos, bool *ok)
{
*ok = true;
*pos = end + 1;
return dtd.mid(start, end - start);
}
+#endif
void XMLTokenizer::parseDtd()
{
+#if QT_VERSION >= 0x040400
+ QStringRef name = m_stream.dtdName();
+ QStringRef publicId = m_stream.dtdPublicId();
+ QStringRef systemId = m_stream.dtdSystemId();
+#else
QString dtd = m_stream.text().toString();
int start = dtd.indexOf("<!DOCTYPE ") + 10;
handleError(fatal, "Invalid DOCTYPE", lineNumber(), columnNumber());
return;
}
-
- //qDebug() << dtd << name << publicId << systemId;
- const QXmlStreamNotationDeclarations& decls = m_stream.notationDeclarations();
+#endif
+ //qDebug() << dtd << name << publicId << systemId;
if ((publicId == "-//W3C//DTD XHTML 1.0 Transitional//EN")
|| (publicId == "-//W3C//DTD XHTML 1.1//EN")
|| (publicId == "-//W3C//DTD XHTML 1.0 Strict//EN")
String m_defaultNamespaceURI;
typedef HashMap<String, String> PrefixForNamespaceMap;
- PrefixForNamespaceMap m_prefixToNamespaceMap;
#ifndef USE_QXMLSTREAM
+ PrefixForNamespaceMap m_prefixToNamespaceMap;
OwnPtr<PendingCallbacks> m_pendingCallbacks;
#endif
SegmentedString m_pendingSrc;