Diff
Modified: trunk/Source/WebCore/ChangeLog (140466 => 140467)
--- trunk/Source/WebCore/ChangeLog 2013-01-22 22:04:41 UTC (rev 140466)
+++ trunk/Source/WebCore/ChangeLog 2013-01-22 22:12:52 UTC (rev 140467)
@@ -1,3 +1,26 @@
+2013-01-22 Tony Gentilcore <to...@chromium.org>
+
+ Make BackgroundHTMLParser track line/column numbers
+ https://bugs.webkit.org/show_bug.cgi?id=107561
+
+ Reviewed by Adam Barth.
+
+ No new tests because covered by existing fast/parser tests.
+
+ * html/parser/BackgroundHTMLParser.cpp:
+ (WebCore::BackgroundHTMLParser::pumpTokenizer):
+ * html/parser/CompactHTMLToken.cpp:
+ (WebCore::CompactHTMLToken::CompactHTMLToken):
+ * html/parser/CompactHTMLToken.h:
+ (CompactHTMLToken):
+ (WebCore::CompactHTMLToken::textPosition):
+ * html/parser/HTMLDocumentParser.cpp:
+ (WebCore::HTMLDocumentParser::didReceiveTokensFromBackgroundParser):
+ (WebCore::HTMLDocumentParser::lineNumber):
+ (WebCore::HTMLDocumentParser::textPosition):
+ * html/parser/HTMLDocumentParser.h:
+ (HTMLDocumentParser):
+
2013-01-22 Alec Flett <alecfl...@chromium.org>
IndexedDB: Don't assert when deprecated setCallbacks is called
Modified: trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp (140466 => 140467)
--- trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp 2013-01-22 22:04:41 UTC (rev 140466)
+++ trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp 2013-01-22 22:12:52 UTC (rev 140467)
@@ -37,6 +37,7 @@
#include "SVGNames.h"
#include <wtf/MainThread.h>
#include <wtf/Vector.h>
+#include <wtf/text/TextPosition.h>
namespace WebCore {
@@ -170,7 +171,7 @@
return;
while (m_tokenizer->nextToken(m_input, m_token)) {
- m_pendingTokens.append(CompactHTMLToken(m_token));
+ m_pendingTokens.append(CompactHTMLToken(m_token, TextPosition(m_input.currentLine(), m_input.currentColumn())));
m_token.clear();
simulateTreeBuilder(m_pendingTokens.last());
Modified: trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp (140466 => 140467)
--- trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp 2013-01-22 22:04:41 UTC (rev 140466)
+++ trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp 2013-01-22 22:12:52 UTC (rev 140467)
@@ -37,12 +37,14 @@
unsigned bitfields;
String name;
Vector<CompactAttribute> vector;
+ TextPosition textPosition;
};
COMPILE_ASSERT(sizeof(CompactHTMLToken) == sizeof(SameSizeAsCompactHTMLToken), CompactHTMLToken_should_stay_small);
-CompactHTMLToken::CompactHTMLToken(const HTMLToken& token)
+CompactHTMLToken::CompactHTMLToken(const HTMLToken& token, const TextPosition& textPosition)
: m_type(token.type())
+ , m_textPosition(textPosition)
{
switch (m_type) {
case HTMLTokenTypes::Uninitialized:
Modified: trunk/Source/WebCore/html/parser/CompactHTMLToken.h (140466 => 140467)
--- trunk/Source/WebCore/html/parser/CompactHTMLToken.h 2013-01-22 22:04:41 UTC (rev 140466)
+++ trunk/Source/WebCore/html/parser/CompactHTMLToken.h 2013-01-22 22:12:52 UTC (rev 140467)
@@ -32,6 +32,7 @@
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/Vector.h>
+#include <wtf/text/TextPosition.h>
#include <wtf/text/WTFString.h>
namespace WebCore {
@@ -56,7 +57,7 @@
class CompactHTMLToken {
public:
- explicit CompactHTMLToken(const HTMLToken&);
+ explicit CompactHTMLToken(const HTMLToken&, const TextPosition&);
bool isSafeToSendToAnotherThread() const;
@@ -64,6 +65,7 @@
const String& data() const { return m_data; }
bool selfClosing() const { return m_selfClosing; }
const Vector<CompactAttribute>& attributes() const { return m_attributes; }
+ const TextPosition& textPosition() const { return m_textPosition; }
// There is only 1 DOCTYPE token per document, so to avoid increasing the
// size of CompactHTMLToken, we just use the m_attributes vector.
@@ -76,6 +78,7 @@
String m_data; // "name", "characters", or "data" depending on m_type
Vector<CompactAttribute> m_attributes;
+ TextPosition m_textPosition;
};
}
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp (140466 => 140467)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2013-01-22 22:04:41 UTC (rev 140466)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp 2013-01-22 22:12:52 UTC (rev 140467)
@@ -276,6 +276,7 @@
ASSERT(!isWaitingForScripts());
// FIXME: Call m_xssAuditor.filterToken(*it).
+ m_textPosition = it->textPosition();
constructTreeFromCompactHTMLToken(*it);
if (isStopped())
@@ -613,11 +614,21 @@
OrdinalNumber HTMLDocumentParser::lineNumber() const
{
+#if ENABLE(THREADED_HTML_PARSER)
+ if (shouldUseThreading())
+ return m_textPosition.m_line;
+#endif
+
return m_input.current().currentLine();
}
TextPosition HTMLDocumentParser::textPosition() const
{
+#if ENABLE(THREADED_HTML_PARSER)
+ if (shouldUseThreading())
+ return m_textPosition;
+#endif
+
const SegmentedString& currentString = m_input.current();
OrdinalNumber line = currentString.currentLine();
OrdinalNumber column = currentString.currentColumn();
Modified: trunk/Source/WebCore/html/parser/HTMLDocumentParser.h (140466 => 140467)
--- trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2013-01-22 22:04:41 UTC (rev 140466)
+++ trunk/Source/WebCore/html/parser/HTMLDocumentParser.h 2013-01-22 22:12:52 UTC (rev 140467)
@@ -38,6 +38,7 @@
#include "Timer.h"
#include "XSSAuditor.h"
#include <wtf/OwnPtr.h>
+#include <wtf/text/TextPosition.h>
namespace WebCore {
@@ -163,6 +164,7 @@
OwnPtr<HTMLPreloadScanner> m_insertionPreloadScanner;
OwnPtr<HTMLParserScheduler> m_parserScheduler;
HTMLSourceTracker m_sourceTracker;
+ TextPosition m_textPosition;
XSSAuditor m_xssAuditor;
bool m_endWasDelayed;