diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WTF/wtf/text/TextPosition.h | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WTF/wtf/text/TextPosition.h')
-rw-r--r-- | Source/WTF/wtf/text/TextPosition.h | 37 |
1 files changed, 3 insertions, 34 deletions
diff --git a/Source/WTF/wtf/text/TextPosition.h b/Source/WTF/wtf/text/TextPosition.h index be49c157a..2f108b038 100644 --- a/Source/WTF/wtf/text/TextPosition.h +++ b/Source/WTF/wtf/text/TextPosition.h @@ -22,37 +22,12 @@ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef TextPosition_h -#define TextPosition_h +#pragma once -#include <wtf/Assertions.h> +#include "OrdinalNumber.h" namespace WTF { -// An abstract number of element in a sequence. The sequence has a first element. -// 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 { -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) { return m_zeroBasedValue == other.m_zeroBasedValue; } - bool operator!=(OrdinalNumber other) { 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 { @@ -62,13 +37,11 @@ public: , m_column(column) { } + TextPosition() { } bool operator==(const TextPosition& other) { return m_line == other.m_line && m_column == other.m_column; } bool operator!=(const TextPosition& other) { return !((*this) == other); } - // 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()); } @@ -78,8 +51,4 @@ public: } -using WTF::OrdinalNumber; - using WTF::TextPosition; - -#endif // TextPosition_h |