Lines Matching refs:Range
16 #include "ui/gfx/range/gfx_range_export.h"
33 // A Range contains two integer values that represent a numeric range, like the
34 // range of characters in a text selection. A range is made of a start and end
35 // position; when they are the same, the Range is akin to a caret. Note that
37 // range.
38 class GFX_RANGE_EXPORT Range {
40 // Creates an empty range {0,0}.
41 constexpr Range() : Range(0) {}
43 // Initializes the range with a start and end.
44 constexpr Range(uint32_t start, uint32_t end) : start_(start), end_(end) {}
46 // Initializes the range with the same start and end positions.
47 constexpr explicit Range(uint32_t position) : Range(position, position) {}
51 explicit Range(const NSRange& range);
54 // {0,-1} to indicate the whole range.
55 Range(const CHARRANGE& range, LONG total_length = -1);
58 // Returns a range that is invalid, which is {UINT32_MAX,UINT32_MAX}.
59 static constexpr Range InvalidRange() {
60 return Range(std::numeric_limits<uint32_t>::max());
63 // Checks if the range is valid through comparison to InvalidRange().
87 constexpr bool operator==(const Range& other) const {
90 constexpr bool operator!=(const Range& other) const {
93 constexpr bool EqualsIgnoringDirection(const Range& other) const {
97 // Returns true if this range intersects the specified |range|.
98 constexpr bool Intersects(const Range& range) const {
99 return IsValid() && range.IsValid() &&
100 !(range.GetMax() < GetMin() || range.GetMin() >= GetMax());
103 // Returns true if this range contains the specified |range|.
104 constexpr bool Contains(const Range& range) const {
105 return IsValid() && range.IsValid() && GetMin() <= range.GetMin() &&
106 range.GetMax() <= GetMax();
109 // Computes the intersection of this range with the given |range|.
111 // The returned range is always empty or forward (never reversed).
112 Range Intersect(const Range& range) const;
115 Range& operator=(const NSRange& range);
117 // NSRange does not store the directionality of a range, so if this
118 // is_reversed(), the range will get flipped when converted to an NSRange.
123 // GTK+ has no concept of a range.
135 GFX_RANGE_EXPORT std::ostream& operator<<(std::ostream& os, const Range& range);