Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(644)

Unified Diff: Source/core/dom/DecodedDataDocumentParser.cpp

Issue 73293003: Moved setting of visual ordering from DocumentWriter to DecodedDataDocument (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@parserthread_decoderownership
Patch Set: Rebase Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: Source/core/dom/DecodedDataDocumentParser.cpp
diff --git a/Source/core/dom/DecodedDataDocumentParser.cpp b/Source/core/dom/DecodedDataDocumentParser.cpp
index d6c8f89b45f03f82afd6d2866967a03d1b4dbfc9..a396e50ad667ec49266a77b5c0d2a978d2a7ffc9 100644
--- a/Source/core/dom/DecodedDataDocumentParser.cpp
+++ b/Source/core/dom/DecodedDataDocumentParser.cpp
@@ -34,6 +34,7 @@ namespace WebCore {
DecodedDataDocumentParser::DecodedDataDocumentParser(Document* document)
: DocumentParser(document)
+ , m_hasAppendedData(false)
{
}
@@ -51,60 +52,61 @@ PassRefPtr<TextResourceDecoder> DecodedDataDocumentParser::decoder()
return m_decoder;
}
-size_t DecodedDataDocumentParser::appendBytes(const char* data, size_t length)
+void DecodedDataDocumentParser::setHasAppendedData()
+{
+ m_hasAppendedData = true;
+}
+
+void DecodedDataDocumentParser::appendBytes(const char* data, size_t length)
{
if (!length)
- return 0;
+ return;
// This should be checking isStopped(), but XMLDocumentParser prematurely
// stops parsing when handling an XSLT processing instruction and still
// needs to receive decoded bytes.
if (isDetached())
- return 0;
+ return;
String decoded = m_decoder->decode(data, length);
- updateDocumentEncoding();
-
- if (decoded.isEmpty())
- return 0;
-
- size_t consumedChars = decoded.length();
- append(decoded.releaseImpl());
-
- return consumedChars;
+ updateDocument(decoded);
}
-size_t DecodedDataDocumentParser::flush()
+void DecodedDataDocumentParser::flush()
{
// This should be checking isStopped(), but XMLDocumentParser prematurely
// stops parsing when handling an XSLT processing instruction and still
// needs to receive decoded bytes.
if (isDetached())
- return 0;
+ return;
// null decoder indicates there is no data received.
// We have nothing to do in that case.
if (!m_decoder)
- return 0;
- String remainingData = m_decoder->flush();
- updateDocumentEncoding();
-
- if (remainingData.isEmpty())
- return 0;
-
- size_t consumedChars = remainingData.length();
- append(remainingData.releaseImpl());
+ return;
- return consumedChars;
+ String remainingData = m_decoder->flush();
+ updateDocument(remainingData);
}
-void DecodedDataDocumentParser::updateDocumentEncoding()
+void DecodedDataDocumentParser::updateDocument(String& decodedData)
{
DocumentEncodingData encodingData;
encodingData.encoding = m_decoder->encoding();
encodingData.wasDetectedHeuristically = m_decoder->encodingWasDetectedHeuristically();
encodingData.sawDecodingError = m_decoder->sawError();
document()->setEncodingData(encodingData);
+
+ if (decodedData.isEmpty())
+ return;
+
+ append(decodedData.releaseImpl());
+ // FIXME: Should be removed as part of https://code.google.com/p/chromium/issues/detail?id=319643
+ if (!m_hasAppendedData) {
+ m_hasAppendedData = true;
+ if (m_decoder->encoding().usesVisualOrdering())
+ document()->setVisuallyOrdered();
+ }
}
};

Powered by Google App Engine
This is Rietveld 408576698