summaryrefslogtreecommitdiffstats
path: root/WebCore/dom/XMLDocumentParserLibxml2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/dom/XMLDocumentParserLibxml2.cpp')
-rw-r--r--WebCore/dom/XMLDocumentParserLibxml2.cpp27
1 files changed, 15 insertions, 12 deletions
diff --git a/WebCore/dom/XMLDocumentParserLibxml2.cpp b/WebCore/dom/XMLDocumentParserLibxml2.cpp
index 37da83c..db94c50 100644
--- a/WebCore/dom/XMLDocumentParserLibxml2.cpp
+++ b/WebCore/dom/XMLDocumentParserLibxml2.cpp
@@ -361,6 +361,17 @@ private:
unsigned m_currentOffset;
};
+static void switchToUTF16(xmlParserCtxtPtr ctxt)
+{
+ // Hack around libxml2's lack of encoding overide support by manually
+ // resetting the encoding to UTF-16 before every chunk. Otherwise libxml
+ // will detect <?xml version="1.0" encoding="<encoding name>"?> blocks
+ // and switch encodings, causing the parse to fail.
+ const UChar BOM = 0xFEFF;
+ const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
+ xmlSwitchEncoding(ctxt, BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE : XML_CHAR_ENCODING_UTF16BE);
+}
+
static bool shouldAllowExternalLoad(const KURL& url)
{
String urlString = url.string();
@@ -476,9 +487,7 @@ PassRefPtr<XMLParserContext> XMLParserContext::createStringParser(xmlSAXHandlerP
xmlParserCtxtPtr parser = xmlCreatePushParserCtxt(handlers, 0, 0, 0, 0);
parser->_private = userData;
parser->replaceEntities = true;
- const UChar BOM = 0xFEFF;
- const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
- xmlSwitchEncoding(parser, BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE : XML_CHAR_ENCODING_UTF16BE);
+ switchToUTF16(parser);
return adoptRef(new XMLParserContext(parser));
}
@@ -645,14 +654,7 @@ void XMLDocumentParser::doWrite(const String& parseString)
// keep this alive until this function is done.
RefPtr<XMLDocumentParser> protect(this);
- // Hack around libxml2's lack of encoding overide support by manually
- // resetting the encoding to UTF-16 before every chunk. Otherwise libxml
- // will detect <?xml version="1.0" encoding="<encoding name>"?> blocks
- // and switch encodings, causing the parse to fail.
- const UChar BOM = 0xFEFF;
- const unsigned char BOMHighByte = *reinterpret_cast<const unsigned char*>(&BOM);
- xmlSwitchEncoding(context->context(), BOMHighByte == 0xFF ? XML_CHAR_ENCODING_UTF16LE : XML_CHAR_ENCODING_UTF16BE);
-
+ switchToUTF16(context->context());
XMLDocumentParserScope scope(document()->docLoader());
xmlParseChunk(context->context(), reinterpret_cast<const char*>(parseString.characters()), sizeof(UChar) * parseString.length(), 0);
@@ -1231,6 +1233,7 @@ static xmlEntityPtr getEntityHandler(void* closure, const xmlChar* name)
static void startDocumentHandler(void* closure)
{
xmlParserCtxt* ctxt = static_cast<xmlParserCtxt*>(closure);
+ switchToUTF16(ctxt);
getParser(closure)->startDocument(ctxt->version, ctxt->encoding, ctxt->standalone);
xmlSAX2StartDocument(closure);
}
@@ -1313,7 +1316,7 @@ void XMLDocumentParser::doEnd()
document()->setTransformSource(new TransformSource(doc));
document()->setParsing(false); // Make the doc think it's done, so it will apply xsl sheets.
- document()->updateStyleSelector();
+ document()->styleSelectorChanged(RecalcStyleImmediately);
document()->setParsing(true);
m_parserStopped = true;
}