Changeset 140467 in webkit


Ignore:
Timestamp:
Jan 22, 2013 2:12:52 PM (11 years ago)
Author:
tonyg@chromium.org
Message:

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):

Location:
trunk/Source/WebCore
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r140465 r140467  
     12013-01-22  Tony Gentilcore  <tonyg@chromium.org>
     2
     3        Make BackgroundHTMLParser track line/column numbers
     4        https://bugs.webkit.org/show_bug.cgi?id=107561
     5
     6        Reviewed by Adam Barth.
     7
     8        No new tests because covered by existing fast/parser tests.
     9
     10        * html/parser/BackgroundHTMLParser.cpp:
     11        (WebCore::BackgroundHTMLParser::pumpTokenizer):
     12        * html/parser/CompactHTMLToken.cpp:
     13        (WebCore::CompactHTMLToken::CompactHTMLToken):
     14        * html/parser/CompactHTMLToken.h:
     15        (CompactHTMLToken):
     16        (WebCore::CompactHTMLToken::textPosition):
     17        * html/parser/HTMLDocumentParser.cpp:
     18        (WebCore::HTMLDocumentParser::didReceiveTokensFromBackgroundParser):
     19        (WebCore::HTMLDocumentParser::lineNumber):
     20        (WebCore::HTMLDocumentParser::textPosition):
     21        * html/parser/HTMLDocumentParser.h:
     22        (HTMLDocumentParser):
     23
    1242013-01-22  Alec Flett  <alecflett@chromium.org>
    225
  • trunk/Source/WebCore/html/parser/BackgroundHTMLParser.cpp

    r140446 r140467  
    3838#include <wtf/MainThread.h>
    3939#include <wtf/Vector.h>
     40#include <wtf/text/TextPosition.h>
    4041
    4142namespace WebCore {
     
    171172
    172173    while (m_tokenizer->nextToken(m_input, m_token)) {
    173         m_pendingTokens.append(CompactHTMLToken(m_token));
     174        m_pendingTokens.append(CompactHTMLToken(m_token, TextPosition(m_input.currentLine(), m_input.currentColumn())));
    174175        m_token.clear();
    175176
  • trunk/Source/WebCore/html/parser/CompactHTMLToken.cpp

    r140453 r140467  
    3838    String name;
    3939    Vector<CompactAttribute> vector;
     40    TextPosition textPosition;
    4041};
    4142
    4243COMPILE_ASSERT(sizeof(CompactHTMLToken) == sizeof(SameSizeAsCompactHTMLToken), CompactHTMLToken_should_stay_small);
    4344
    44 CompactHTMLToken::CompactHTMLToken(const HTMLToken& token)
     45CompactHTMLToken::CompactHTMLToken(const HTMLToken& token, const TextPosition& textPosition)
    4546    : m_type(token.type())
     47    , m_textPosition(textPosition)
    4648{
    4749    switch (m_type) {
  • trunk/Source/WebCore/html/parser/CompactHTMLToken.h

    r140453 r140467  
    3333#include <wtf/RefPtr.h>
    3434#include <wtf/Vector.h>
     35#include <wtf/text/TextPosition.h>
    3536#include <wtf/text/WTFString.h>
    3637
     
    5758class CompactHTMLToken {
    5859public:
    59     explicit CompactHTMLToken(const HTMLToken&);
     60    explicit CompactHTMLToken(const HTMLToken&, const TextPosition&);
    6061
    6162    bool isSafeToSendToAnotherThread() const;
     
    6566    bool selfClosing() const { return m_selfClosing; }
    6667    const Vector<CompactAttribute>& attributes() const { return m_attributes; }
     68    const TextPosition& textPosition() const { return m_textPosition; }
    6769
    6870    // There is only 1 DOCTYPE token per document, so to avoid increasing the
     
    7779    String m_data; // "name", "characters", or "data" depending on m_type
    7880    Vector<CompactAttribute> m_attributes;
     81    TextPosition m_textPosition;
    7982};
    8083
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.cpp

    r140402 r140467  
    277277
    278278        // FIXME: Call m_xssAuditor.filterToken(*it).
     279        m_textPosition = it->textPosition();
    279280        constructTreeFromCompactHTMLToken(*it);
    280281
     
    614615OrdinalNumber HTMLDocumentParser::lineNumber() const
    615616{
     617#if ENABLE(THREADED_HTML_PARSER)
     618    if (shouldUseThreading())
     619        return m_textPosition.m_line;
     620#endif
     621
    616622    return m_input.current().currentLine();
    617623}
     
    619625TextPosition HTMLDocumentParser::textPosition() const
    620626{
     627#if ENABLE(THREADED_HTML_PARSER)
     628    if (shouldUseThreading())
     629        return m_textPosition;
     630#endif
     631
    621632    const SegmentedString& currentString = m_input.current();
    622633    OrdinalNumber line = currentString.currentLine();
  • trunk/Source/WebCore/html/parser/HTMLDocumentParser.h

    r140055 r140467  
    3939#include "XSSAuditor.h"
    4040#include <wtf/OwnPtr.h>
     41#include <wtf/text/TextPosition.h>
    4142
    4243namespace WebCore {
     
    164165    OwnPtr<HTMLParserScheduler> m_parserScheduler;
    165166    HTMLSourceTracker m_sourceTracker;
     167    TextPosition m_textPosition;
    166168    XSSAuditor m_xssAuditor;
    167169
Note: See TracChangeset for help on using the changeset viewer.