| Index: third_party/WebKit/Source/wtf/text/TextPosition.h
|
| diff --git a/third_party/WebKit/Source/wtf/text/TextPosition.h b/third_party/WebKit/Source/wtf/text/TextPosition.h
|
| index 17140c3a7c30d678722c72a494f8f902fce9f188..9a39e0a6650d6b7a4682a8ed2b1059809cb6f860 100644
|
| --- a/third_party/WebKit/Source/wtf/text/TextPosition.h
|
| +++ b/third_party/WebKit/Source/wtf/text/TextPosition.h
|
| @@ -37,58 +37,73 @@ namespace WTF {
|
| // This type should be used instead of integer because 2 contradicting traditions can
|
| // call a first element '0' or '1' which makes integer type ambiguous.
|
| class OrdinalNumber final {
|
| - DISALLOW_NEW();
|
| -public:
|
| - static OrdinalNumber fromZeroBasedInt(int zeroBasedInt) { return OrdinalNumber(zeroBasedInt); }
|
| - static OrdinalNumber fromOneBasedInt(int oneBasedInt) { return OrdinalNumber(oneBasedInt - 1); }
|
| - OrdinalNumber() : m_zeroBasedValue(0) { }
|
| -
|
| - int zeroBasedInt() const { return m_zeroBasedValue; }
|
| - int oneBasedInt() const { return m_zeroBasedValue + 1; }
|
| -
|
| - bool operator==(OrdinalNumber other) const { return m_zeroBasedValue == other.m_zeroBasedValue; }
|
| - bool operator!=(OrdinalNumber other) const { return !((*this) == other); }
|
| -
|
| - static OrdinalNumber first() { return OrdinalNumber(0); }
|
| - static OrdinalNumber beforeFirst() { return OrdinalNumber(-1); }
|
| -
|
| -private:
|
| - OrdinalNumber(int zeroBasedInt) : m_zeroBasedValue(zeroBasedInt) { }
|
| - int m_zeroBasedValue;
|
| + DISALLOW_NEW();
|
| +
|
| + public:
|
| + static OrdinalNumber fromZeroBasedInt(int zeroBasedInt) {
|
| + return OrdinalNumber(zeroBasedInt);
|
| + }
|
| + static OrdinalNumber fromOneBasedInt(int oneBasedInt) {
|
| + return OrdinalNumber(oneBasedInt - 1);
|
| + }
|
| + OrdinalNumber() : m_zeroBasedValue(0) {}
|
| +
|
| + int zeroBasedInt() const { return m_zeroBasedValue; }
|
| + int oneBasedInt() const { return m_zeroBasedValue + 1; }
|
| +
|
| + bool operator==(OrdinalNumber other) const {
|
| + return m_zeroBasedValue == other.m_zeroBasedValue;
|
| + }
|
| + bool operator!=(OrdinalNumber other) const { return !((*this) == other); }
|
| +
|
| + static OrdinalNumber first() { return OrdinalNumber(0); }
|
| + static OrdinalNumber beforeFirst() { return OrdinalNumber(-1); }
|
| +
|
| + private:
|
| + OrdinalNumber(int zeroBasedInt) : m_zeroBasedValue(zeroBasedInt) {}
|
| + int m_zeroBasedValue;
|
| };
|
|
|
| -
|
| // TextPosition structure specifies coordinates within an text resource. It is used mostly
|
| // for saving script source position.
|
| class TextPosition final {
|
| - DISALLOW_NEW();
|
| -public:
|
| - TextPosition(OrdinalNumber line, OrdinalNumber column)
|
| - : m_line(line)
|
| - , m_column(column)
|
| - {
|
| - }
|
| - TextPosition() { }
|
| - bool operator==(const TextPosition& other) const { return m_line == other.m_line && m_column == other.m_column; }
|
| - bool operator!=(const TextPosition& other) const { return !((*this) == other); }
|
| - WTF_EXPORT OrdinalNumber toOffset(const Vector<unsigned>&);
|
| -
|
| - // A 'minimum' value of position, used as a default value.
|
| - static TextPosition minimumPosition() { return TextPosition(OrdinalNumber::first(), OrdinalNumber::first()); }
|
| -
|
| - // A value with line value less than a minimum; used as an impossible position.
|
| - static TextPosition belowRangePosition() { return TextPosition(OrdinalNumber::beforeFirst(), OrdinalNumber::beforeFirst()); }
|
| -
|
| - // A value corresponding to a position with given offset within text having the specified line ending offsets.
|
| - WTF_EXPORT static TextPosition fromOffsetAndLineEndings(unsigned, const Vector<unsigned>&);
|
| -
|
| - OrdinalNumber m_line;
|
| - OrdinalNumber m_column;
|
| + DISALLOW_NEW();
|
| +
|
| + public:
|
| + TextPosition(OrdinalNumber line, OrdinalNumber column)
|
| + : m_line(line), m_column(column) {}
|
| + TextPosition() {}
|
| + bool operator==(const TextPosition& other) const {
|
| + return m_line == other.m_line && m_column == other.m_column;
|
| + }
|
| + bool operator!=(const TextPosition& other) const {
|
| + return !((*this) == other);
|
| + }
|
| + WTF_EXPORT OrdinalNumber toOffset(const Vector<unsigned>&);
|
| +
|
| + // A 'minimum' value of position, used as a default value.
|
| + static TextPosition minimumPosition() {
|
| + return TextPosition(OrdinalNumber::first(), OrdinalNumber::first());
|
| + }
|
| +
|
| + // A value with line value less than a minimum; used as an impossible position.
|
| + static TextPosition belowRangePosition() {
|
| + return TextPosition(OrdinalNumber::beforeFirst(),
|
| + OrdinalNumber::beforeFirst());
|
| + }
|
| +
|
| + // A value corresponding to a position with given offset within text having the specified line ending offsets.
|
| + WTF_EXPORT static TextPosition fromOffsetAndLineEndings(
|
| + unsigned,
|
| + const Vector<unsigned>&);
|
| +
|
| + OrdinalNumber m_line;
|
| + OrdinalNumber m_column;
|
| };
|
|
|
| WTF_EXPORT PassOwnPtr<Vector<unsigned>> lineEndings(const String&);
|
|
|
| -} // namespace WTF
|
| +} // namespace WTF
|
|
|
| using WTF::OrdinalNumber;
|
|
|
| @@ -96,4 +111,4 @@ using WTF::TextPosition;
|
|
|
| using WTF::lineEndings;
|
|
|
| -#endif // TextPosition_h
|
| +#endif // TextPosition_h
|
|
|