Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(67)

Unified Diff: third_party/WebKit/Source/wtf/text/TextPosition.h

Issue 1611343002: wtf reformat test Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: pydent Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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
« no previous file with comments | « third_party/WebKit/Source/wtf/text/TextEncodingRegistry.cpp ('k') | third_party/WebKit/Source/wtf/text/TextPosition.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698