Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 5 #ifndef VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| 6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 6 #define VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 | 10 |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 62 | 62 |
| 63 // Returns true if the selection is made in reverse order. | 63 // Returns true if the selection is made in reverse order. |
| 64 bool is_reverse() const { return start_ > end_; } | 64 bool is_reverse() const { return start_ > end_; } |
| 65 | 65 |
| 66 // Returns the min of selected range. | 66 // Returns the min of selected range. |
| 67 size_t GetMin() const; | 67 size_t GetMin() const; |
| 68 | 68 |
| 69 // Returns the max of selected range. | 69 // Returns the max of selected range. |
| 70 size_t GetMax() const; | 70 size_t GetMax() const; |
| 71 | 71 |
| 72 // Returns true if |range| has same start, end position. | 72 // Returns true if the selected text will be the same. |
|
Peter Kasting
2011/01/21 19:10:10
I think the functionality here is confusing. I'd
oshima
2011/01/21 20:05:01
moved empty check to caller, but i prefer to keep
| |
| 73 bool Equals(const TextRange& range) const { | 73 // That is, if both range are empty, or both have same min and max; |
| 74 return start_ == range.start_ && end_ == range.end_; | 74 bool HasSameSelectionWith(const TextRange& range) const { |
| 75 return (is_empty() && range.is_empty()) || | |
| 76 (GetMin() == range.GetMin() && GetMax() == range.GetMax()); | |
| 75 } | 77 } |
| 76 | 78 |
| 77 // Set the range with |start| and |end|. | 79 // Set the range with |start| and |end|. |
| 78 void SetRange(size_t start, size_t end); | 80 void SetRange(size_t start, size_t end); |
| 79 | 81 |
| 80 private: | 82 private: |
| 81 size_t start_; | 83 size_t start_; |
| 82 size_t end_; | 84 size_t end_; |
| 83 | 85 |
| 84 // No assign. | 86 // No assign. |
| (...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 340 | 342 |
| 341 // Text to display when empty. | 343 // Text to display when empty. |
| 342 string16 text_to_display_when_empty_; | 344 string16 text_to_display_when_empty_; |
| 343 | 345 |
| 344 DISALLOW_COPY_AND_ASSIGN(Textfield); | 346 DISALLOW_COPY_AND_ASSIGN(Textfield); |
| 345 }; | 347 }; |
| 346 | 348 |
| 347 } // namespace views | 349 } // namespace views |
| 348 | 350 |
| 349 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ | 351 #endif // VIEWS_CONTROLS_TEXTFIELD_TEXTFIELD_H_ |
| OLD | NEW |