OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef UI_GFX_RANGE_RANGE_H_ | 5 #ifndef UI_GFX_RANGE_RANGE_H_ |
6 #define UI_GFX_RANGE_RANGE_H_ | 6 #define UI_GFX_RANGE_RANGE_H_ |
7 | 7 |
8 #include <stddef.h> | 8 #include <stddef.h> |
9 #include <stdint.h> | 9 #include <stdint.h> |
10 | 10 |
11 #include <ostream> | 11 #include <ostream> |
12 #include <string> | 12 #include <string> |
13 | 13 |
14 #include "build/build_config.h" | 14 #include "build/build_config.h" |
15 #include "ui/gfx/gfx_export.h" | 15 #include "ui/gfx/range/gfx_range_export.h" |
16 | 16 |
17 #if defined(OS_MACOSX) | 17 #if defined(OS_MACOSX) |
18 #if __OBJC__ | 18 #if __OBJC__ |
19 #import <Foundation/Foundation.h> | 19 #import <Foundation/Foundation.h> |
20 #else | 20 #else |
21 typedef struct _NSRange NSRange; | 21 typedef struct _NSRange NSRange; |
22 #endif | 22 #endif |
23 #endif // defined(OS_MACOSX) | 23 #endif // defined(OS_MACOSX) |
24 | 24 |
25 #if defined(OS_WIN) | 25 #if defined(OS_WIN) |
26 #include <windows.h> | 26 #include <windows.h> |
27 #include <richedit.h> | 27 #include <richedit.h> |
28 #endif | 28 #endif |
29 | 29 |
30 namespace gfx { | 30 namespace gfx { |
31 | 31 |
32 // A Range contains two integer values that represent a numeric range, like the | 32 // A Range contains two integer values that represent a numeric range, like the |
33 // range of characters in a text selection. A range is made of a start and end | 33 // range of characters in a text selection. A range is made of a start and end |
34 // position; when they are the same, the Range is akin to a caret. Note that | 34 // position; when they are the same, the Range is akin to a caret. Note that |
35 // |start_| can be greater than |end_| to respect the directionality of the | 35 // |start_| can be greater than |end_| to respect the directionality of the |
36 // range. | 36 // range. |
37 class GFX_EXPORT Range { | 37 class GFX_RANGE_EXPORT Range { |
38 public: | 38 public: |
39 // Creates an empty range {0,0}. | 39 // Creates an empty range {0,0}. |
40 Range(); | 40 Range(); |
41 | 41 |
42 // Initializes the range with a start and end. | 42 // Initializes the range with a start and end. |
43 Range(uint32_t start, uint32_t end); | 43 Range(uint32_t start, uint32_t end); |
44 | 44 |
45 // Initializes the range with the same start and end positions. | 45 // Initializes the range with the same start and end positions. |
46 explicit Range(uint32_t position); | 46 explicit Range(uint32_t position); |
47 | 47 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
108 std::string ToString() const; | 108 std::string ToString() const; |
109 | 109 |
110 private: | 110 private: |
111 // Note: we use uint32_t instead of size_t because this struct is sent over | 111 // Note: we use uint32_t instead of size_t because this struct is sent over |
112 // IPC which could span 32 & 64 bit processes. This is fine since text spans | 112 // IPC which could span 32 & 64 bit processes. This is fine since text spans |
113 // shouldn't exceed UINT32_MAX even on 64 bit builds. | 113 // shouldn't exceed UINT32_MAX even on 64 bit builds. |
114 uint32_t start_; | 114 uint32_t start_; |
115 uint32_t end_; | 115 uint32_t end_; |
116 }; | 116 }; |
117 | 117 |
118 GFX_EXPORT std::ostream& operator<<(std::ostream& os, const Range& range); | 118 GFX_RANGE_EXPORT std::ostream& operator<<(std::ostream& os, const Range& range); |
119 | 119 |
120 } // namespace gfx | 120 } // namespace gfx |
121 | 121 |
122 #endif // UI_GFX_RANGE_RANGE_H_ | 122 #endif // UI_GFX_RANGE_RANGE_H_ |
OLD | NEW |