JavaScriptCore/ChangeLog

 12010-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
1182010-12-28 Helder Correia <helder@sencha.com>
219
320 Reviewed by Eric Seidel.

JavaScriptCore/wtf/text/TextPosition.h

@@public:
6666 }
6767 TextPosition() {}
6868
 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
6972 // A 'minimum' value of position, used as a default value.
7073 static TextPosition<NUMBER> minimumPosition() { return TextPosition<NUMBER>(NUMBER::base(), NUMBER::base()); }
7174

@@public:
8992
9093 OneBasedNumber convertToOneBased() const;
9194
 95 bool operator==(ZeroBasedNumber other) { return m_value == other.m_value; }
 96 bool operator!=(ZeroBasedNumber other) { return !((*this) == other); }
 97
9298 static ZeroBasedNumber base() { return 0; }
9399 static ZeroBasedNumber belowBase() { return -1; }
94100

@@public:
107113 int convertAsZeroBasedInt() const { return m_value - 1; }
108114 ZeroBasedNumber convertToZeroBased() const { return ZeroBasedNumber::fromZeroBasedInt(m_value - 1); }
109115
 116 bool operator==(OneBasedNumber other) { return m_value == other.m_value; }
 117 bool operator!=(OneBasedNumber other) { return !((*this) == other); }
 118
110119 static OneBasedNumber base() { return 1; }
111120 static OneBasedNumber belowBase() { return 0; }
112121

WebCore/ChangeLog

 12010-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
1212010-12-28 Jan Erik Hanssen <jhanssen@sencha.com>
222
323 Reviewed by Eric Seidel.

WebCore/dom/XMLDocumentParser.cpp

@@void XMLDocumentParser::append(const SegmentedString& s)
148148
149149void XMLDocumentParser::handleError(ErrorType type, const char* m, int lineNumber, int columnNumber)
150150{
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
 154void XMLDocumentParser::handleError(ErrorType type, const char* m, TextPosition1 position)
 155{
 156 if (type == fatal || (m_errorCount < maxErrors && m_lastErrorPosition != position)) {
152157 switch (type) {
153158 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);
155160 break;
156161 case fatal:
157162 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);
159164 }
160165
161  m_lastErrorLine = lineNumber;
162  m_lastErrorColumn = columnNumber;
 166 m_lastErrorPosition = position;
163167 ++m_errorCount;
164168 }
165169

WebCore/dom/XMLDocumentParser.h

@@namespace WebCore {
8686 // Exposed for callbacks:
8787 enum ErrorType { warning, nonFatal, fatal };
8888 void handleError(ErrorType, const char* message, int lineNumber, int columnNumber);
 89 void handleError(ErrorType, const char* message, TextPosition1);
8990
9091 void setIsXHTMLDocument(bool isXHTML) { m_isXHTMLDocument = isXHTML; }
9192 bool isXHTMLDocument() const { return m_isXHTMLDocument; }

@@namespace WebCore {
101102
102103 // WMLErrorHandling uses these functions.
103104 virtual bool wellFormed() const { return !m_sawError; }
 105
104106 TextPosition0 textPosition() const;
 107 TextPosition1 textPositionOneBased() const;
105108
106109 static bool supportsXMLVersion(const String&);
107110

@@namespace WebCore {
130133
131134 bool appendFragmentSource(const String&);
132135
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 
140136#if USE(QXMLSTREAM)
141137private:
142138 void parse();

@@public:
210206 bool m_finishCalled;
211207
212208 int m_errorCount;
213  int m_lastErrorLine;
214  int m_lastErrorColumn;
 209 TextPosition1 m_lastErrorPosition;
215210 String m_errorMessages;
216211
217212 CachedResourceHandle<CachedScript> m_pendingScript;

WebCore/dom/XMLDocumentParserLibxml2.cpp

@@XMLDocumentParser::XMLDocumentParser(Document* document, FrameView* frameView)
557557 , m_requestingScript(false)
558558 , m_finishCalled(false)
559559 , m_errorCount(0)
560  , m_lastErrorLine(0)
561  , m_lastErrorColumn(0)
 560 , m_lastErrorPosition(TextPosition1::belowRangePosition())
562561 , m_pendingScript(0)
563562 , m_scriptStartPosition(TextPosition1::belowRangePosition())
564563 , m_parsingFragment(false)

@@XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parent
584583 , m_requestingScript(false)
585584 , m_finishCalled(false)
586585 , m_errorCount(0)
587  , m_lastErrorLine(0)
588  , m_lastErrorColumn(0)
 586 , m_lastErrorPosition(TextPosition1::belowRangePosition())
589587 , m_pendingScript(0)
590588 , m_scriptStartPosition(TextPosition1::belowRangePosition())
591589 , m_parsingFragment(true)

WebCore/dom/XMLDocumentParserQt.cpp

@@XMLDocumentParser::XMLDocumentParser(Document* document, FrameView* frameView)
102102 , m_requestingScript(false)
103103 , m_finishCalled(false)
104104 , m_errorCount(0)
105  , m_lastErrorLine(0)
106  , m_lastErrorColumn(0)
 105 , m_lastErrorPosition(TextPosition1::belowRangePosition())
107106 , m_pendingScript(0)
108107 , m_scriptStartPosition(TextPosition1::belowRangePosition())
109108 , m_parsingFragment(false)

@@XMLDocumentParser::XMLDocumentParser(DocumentFragment* fragment, Element* parent
129128 , m_requestingScript(false)
130129 , m_finishCalled(false)
131130 , m_errorCount(0)
132  , m_lastErrorLine(0)
133  , m_lastErrorColumn(0)
 131 , m_lastErrorPosition(TextPosition1::belowRangePosition())
134132 , m_pendingScript(0)
135133 , m_scriptStartPosition(TextPosition1::belowRangePosition())
136134 , m_parsingFragment(true)

WebCore/wml/WMLErrorHandling.cpp

@@void reportWMLError(Document* doc, WMLErrorCode error)
4848 if (!parser->wellFormed())
4949 return;
5050
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());
5252 } else {
5353 Frame* frame = doc->frame();
5454 if (!frame)