| Differences between
and this patch
- a/JavaScriptCore/ChangeLog +17 lines
Lines 1-3 a/JavaScriptCore/ChangeLog_sec1
1
2010-12-28  Joone Hur  <joone@kldp.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        WML Parser should treat line/column number in a consistent way
6
        https://bugs.webkit.org/show_bug.cgi?id=51601
7
8
        Add the equality operators to TextPosition class.
9
10
        * wtf/text/TextPosition.h:
11
        (WTF::TextPosition::operator==): Added.
12
        (WTF::TextPosition::operator!=): Added.
13
        (WTF::ZeroBasedNumber::operator==): Added.
14
        (WTF::ZeroBasedNumber::operator!=): Added.
15
        (WTF::OneBasedNumber::operator==): Added.
16
        (WTF::OneBasedNumber::operator!=): Added.
17
1
2010-12-28  Helder Correia  <helder@sencha.com>
18
2010-12-28  Helder Correia  <helder@sencha.com>
2
19
3
        Reviewed by Eric Seidel.
20
        Reviewed by Eric Seidel.
- a/JavaScriptCore/wtf/text/TextPosition.h +9 lines
Lines 66-71 public: a/JavaScriptCore/wtf/text/TextPosition.h_sec1
66
    }
66
    }
67
    TextPosition() {}
67
    TextPosition() {}
68
68
69
    bool operator==(const TextPosition& other) { return m_line == other.m_line && m_column == other.m_column; }
70
    bool operator!=(const TextPosition& other) { return !((*this) == other); }
71
69
    // A 'minimum' value of position, used as a default value.
72
    // A 'minimum' value of position, used as a default value.
70
    static TextPosition<NUMBER> minimumPosition() { return TextPosition<NUMBER>(NUMBER::base(), NUMBER::base()); }
73
    static TextPosition<NUMBER> minimumPosition() { return TextPosition<NUMBER>(NUMBER::base(), NUMBER::base()); }
71
74
Lines 89-94 public: a/JavaScriptCore/wtf/text/TextPosition.h_sec2
89
92
90
    OneBasedNumber convertToOneBased() const;
93
    OneBasedNumber convertToOneBased() const;
91
94
95
    bool operator==(ZeroBasedNumber other) { return m_value == other.m_value; }
96
    bool operator!=(ZeroBasedNumber other) { return !((*this) == other); }
97
92
    static ZeroBasedNumber base() { return 0; }
98
    static ZeroBasedNumber base() { return 0; }
93
    static ZeroBasedNumber belowBase() { return -1; }
99
    static ZeroBasedNumber belowBase() { return -1; }
94
100
Lines 107-112 public: a/JavaScriptCore/wtf/text/TextPosition.h_sec3
107
    int convertAsZeroBasedInt() const { return m_value - 1; }
113
    int convertAsZeroBasedInt() const { return m_value - 1; }
108
    ZeroBasedNumber convertToZeroBased() const { return ZeroBasedNumber::fromZeroBasedInt(m_value - 1); }
114
    ZeroBasedNumber convertToZeroBased() const { return ZeroBasedNumber::fromZeroBasedInt(m_value - 1); }
109
115
116
    bool operator==(OneBasedNumber other) { return m_value == other.m_value; }
117
    bool operator!=(OneBasedNumber other) { return !((*this) == other); }
118
110
    static OneBasedNumber base() { return 1; }
119
    static OneBasedNumber base() { return 1; }
111
    static OneBasedNumber belowBase() { return 0; }
120
    static OneBasedNumber belowBase() { return 0; }
112
121
- a/WebCore/ChangeLog +20 lines
Lines 1-3 a/WebCore/ChangeLog_sec1
1
2010-12-28  Joone Hur  <joone@kldp.org>
2
3
        Reviewed by NOBODY (OOPS!).
4
5
        WML Parser should treat line/column number in a consistent way
6
        https://bugs.webkit.org/show_bug.cgi?id=51601
7
8
        XML Parser treats line/column number as 1-based values, but WML ErrorHandler treat them as 0-based.
9
        Therefore, this patch allows WML ErrorHandler to use 1-based values.
10
11
        * dom/XMLDocumentParser.cpp:
12
        (WebCore::XMLDocumentParser::handleError): Treat line/column number as 1 based values.
13
        * dom/XMLDocumentParser.h: Make textPositionOneBased public and Add TextPosition1(m_lastErrorPosition) to keep error line/column number.
14
        * dom/XMLDocumentParserLibxml2.cpp:
15
        (WebCore::XMLDocumentParser::XMLDocumentParser): Initialize m_lastErrorPosition. 
16
        * dom/XMLDocumentParserQt.cpp:
17
        (WebCore::XMLDocumentParser::XMLDocumentParser): Initialize m_lastErrorPosition. 
18
        * wml/WMLErrorHandling.cpp:
19
        (WebCore::reportWMLError): Use 1 based value instead of 0 based value to report error line/column number.
20
1
2010-12-28  Jan Erik Hanssen  <jhanssen@sencha.com>
21
2010-12-28  Jan Erik Hanssen  <jhanssen@sencha.com>
2
22
3
        Reviewed by Eric Seidel.
23
        Reviewed by Eric Seidel.
- a/WebCore/dom/XMLDocumentParser.cpp -5 / +9 lines
Lines 148-165 void XMLDocumentParser::append(const SegmentedString& s) a/WebCore/dom/XMLDocumentParser.cpp_sec1
148
148
149
void XMLDocumentParser::handleError(ErrorType type, const char* m, int lineNumber, int columnNumber)
149
void XMLDocumentParser::handleError(ErrorType type, const char* m, int lineNumber, int columnNumber)
150
{
150
{
151
    if (type == fatal || (m_errorCount < maxErrors && m_lastErrorLine != lineNumber && m_lastErrorColumn != columnNumber)) {
151
    handleError(type, m, TextPosition1(WTF::OneBasedNumber::fromOneBasedInt(lineNumber), WTF::OneBasedNumber::fromOneBasedInt(columnNumber)));
152
}
153
154
void XMLDocumentParser::handleError(ErrorType type, const char* m, TextPosition1 position)
155
{
156
    if (type == fatal || (m_errorCount < maxErrors && m_lastErrorPosition != position)) {
152
        switch (type) {
157
        switch (type) {
153
            case warning:
158
            case warning:
154
                m_errorMessages += makeString("warning on line ", String::number(lineNumber), " at column ", String::number(columnNumber), ": ", m);
159
                m_errorMessages += makeString("warning on line ", String::number(position.m_line.oneBasedInt()), " at column ", String::number(position.m_column.oneBasedInt()), ": ", m);
155
                break;
160
                break;
156
            case fatal:
161
            case fatal:
157
            case nonFatal:
162
            case nonFatal:
158
                m_errorMessages += makeString("error on line ", String::number(lineNumber), " at column ", String::number(columnNumber), ": ", m);
163
                m_errorMessages += makeString("error on line ", String::number(position.m_line.oneBasedInt()), " at column ", String::number(position.m_column.oneBasedInt()), ": ", m);
159
        }
164
        }
160
165
161
        m_lastErrorLine = lineNumber;
166
        m_lastErrorPosition = position;
162
        m_lastErrorColumn = columnNumber;
163
        ++m_errorCount;
167
        ++m_errorCount;
164
    }
168
    }
165
169
- a/WebCore/dom/XMLDocumentParser.h -9 / +4 lines
Lines 86-91 namespace WebCore { a/WebCore/dom/XMLDocumentParser.h_sec1
86
        // Exposed for callbacks:
86
        // Exposed for callbacks:
87
        enum ErrorType { warning, nonFatal, fatal };
87
        enum ErrorType { warning, nonFatal, fatal };
88
        void handleError(ErrorType, const char* message, int lineNumber, int columnNumber);
88
        void handleError(ErrorType, const char* message, int lineNumber, int columnNumber);
89
        void handleError(ErrorType, const char* message, TextPosition1);
89
90
90
        void setIsXHTMLDocument(bool isXHTML) { m_isXHTMLDocument = isXHTML; }
91
        void setIsXHTMLDocument(bool isXHTML) { m_isXHTMLDocument = isXHTML; }
91
        bool isXHTMLDocument() const { return m_isXHTMLDocument; }
92
        bool isXHTMLDocument() const { return m_isXHTMLDocument; }
Lines 101-107 namespace WebCore { a/WebCore/dom/XMLDocumentParser.h_sec2
101
102
102
        // WMLErrorHandling uses these functions.
103
        // WMLErrorHandling uses these functions.
103
        virtual bool wellFormed() const { return !m_sawError; }
104
        virtual bool wellFormed() const { return !m_sawError; }
105
104
        TextPosition0 textPosition() const;
106
        TextPosition0 textPosition() const;
107
        TextPosition1 textPositionOneBased() const;
105
108
106
        static bool supportsXMLVersion(const String&);
109
        static bool supportsXMLVersion(const String&);
107
110
Lines 130-142 namespace WebCore { a/WebCore/dom/XMLDocumentParser.h_sec3
130
133
131
        bool appendFragmentSource(const String&);
134
        bool appendFragmentSource(const String&);
132
135
133
134
        // This method is introduced to temporary legalize existing line/column
135
        // coordinate bug: it is believed that numbers that originally were zero-based
136
        // eventually becomes one-based.
137
        // FIXME: Investigate and get rid of this method.
138
        TextPosition1 textPositionOneBased() const;
139
140
#if USE(QXMLSTREAM)
136
#if USE(QXMLSTREAM)
141
private:
137
private:
142
        void parse();
138
        void parse();
Lines 210-217 public: a/WebCore/dom/XMLDocumentParser.h_sec4
210
        bool m_finishCalled;
206
        bool m_finishCalled;
211
207
212
        int m_errorCount;
208
        int m_errorCount;
213
        int m_lastErrorLine;
209
        TextPosition1 m_lastErrorPosition;
214
        int m_lastErrorColumn;
215
        String m_errorMessages;
210
        String m_errorMessages;
216
211
217
        CachedResourceHandle<CachedScript> m_pendingScript;
212
        CachedResourceHandle<CachedScript> m_pendingScript;
- a/WebCore/dom/XMLDocumentParserLibxml2.cpp -4 / +2 lines
Lines 557-564 XMLDocumentParser::XMLDocumentParser(Document* document, FrameView* frameView) a/WebCore/dom/XMLDocumentParserLibxml2.cpp_sec1
557
    , m_requestingScript(false)
557
    , m_requestingScript(false)
558
    , m_finishCalled(false)
558
    , m_finishCalled(false)
559
    , m_errorCount(0)
559
    , m_errorCount(0)
560
    , m_lastErrorLine(0)
560
    , m_lastErrorPosition(TextPosition1::belowRangePosition())
561
    , m_lastErrorColumn(0)
562
    , m_pendingScript(0)
561
    , m_pendingScript(0)
563
    , m_scriptStartPosition(TextPosition1::belowRangePosition())
562
    , m_scriptStartPosition(TextPosition1::belowRangePosition())
564
    , m_parsingFragment(false)
563
    , m_parsingFragment(false)
Lines 584-591 XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parent a/WebCore/dom/XMLDocumentParserLibxml2.cpp_sec2
584
    , m_requestingScript(false)
583
    , m_requestingScript(false)
585
    , m_finishCalled(false)
584
    , m_finishCalled(false)
586
    , m_errorCount(0)
585
    , m_errorCount(0)
587
    , m_lastErrorLine(0)
586
    , m_lastErrorPosition(TextPosition1::belowRangePosition())
588
    , m_lastErrorColumn(0)
589
    , m_pendingScript(0)
587
    , m_pendingScript(0)
590
    , m_scriptStartPosition(TextPosition1::belowRangePosition())
588
    , m_scriptStartPosition(TextPosition1::belowRangePosition())
591
    , m_parsingFragment(true)
589
    , m_parsingFragment(true)
- a/WebCore/dom/XMLDocumentParserQt.cpp -4 / +2 lines
Lines 102-109 XMLDocumentParser::XMLDocumentParser(Document* document, FrameView* frameView) a/WebCore/dom/XMLDocumentParserQt.cpp_sec1
102
    , m_requestingScript(false)
102
    , m_requestingScript(false)
103
    , m_finishCalled(false)
103
    , m_finishCalled(false)
104
    , m_errorCount(0)
104
    , m_errorCount(0)
105
    , m_lastErrorLine(0)
105
    , m_lastErrorPosition(TextPosition1::belowRangePosition())
106
    , m_lastErrorColumn(0)
107
    , m_pendingScript(0)
106
    , m_pendingScript(0)
108
    , m_scriptStartPosition(TextPosition1::belowRangePosition())
107
    , m_scriptStartPosition(TextPosition1::belowRangePosition())
109
    , m_parsingFragment(false)
108
    , m_parsingFragment(false)
Lines 129-136 XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parent a/WebCore/dom/XMLDocumentParserQt.cpp_sec2
129
    , m_requestingScript(false)
128
    , m_requestingScript(false)
130
    , m_finishCalled(false)
129
    , m_finishCalled(false)
131
    , m_errorCount(0)
130
    , m_errorCount(0)
132
    , m_lastErrorLine(0)
131
    , m_lastErrorPosition(TextPosition1::belowRangePosition())
133
    , m_lastErrorColumn(0)
134
    , m_pendingScript(0)
132
    , m_pendingScript(0)
135
    , m_scriptStartPosition(TextPosition1::belowRangePosition())
133
    , m_scriptStartPosition(TextPosition1::belowRangePosition())
136
    , m_parsingFragment(true)
134
    , m_parsingFragment(true)
- a/WebCore/wml/WMLErrorHandling.cpp -1 / +1 lines
Lines 48-54 void reportWMLError(Document* doc, WMLErrorCode error) a/WebCore/wml/WMLErrorHandling.cpp_sec1
48
        if (!parser->wellFormed())
48
        if (!parser->wellFormed())
49
            return;
49
            return;
50
50
51
        parser->handleError(XMLDocumentParser::fatal, errorMessage.latin1().data(), parser->textPosition().m_line.zeroBasedInt(), parser->textPosition().m_column.zeroBasedInt());
51
        parser->handleError(XMLDocumentParser::fatal, errorMessage.latin1().data(), parser->textPositionOneBased());
52
    } else {
52
    } else {
53
        Frame* frame = doc->frame();
53
        Frame* frame = doc->frame();
54
        if (!frame)
54
        if (!frame)

Return to Bug 51601