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

Side by Side Diff: ui/base/range/range.cc

Issue 7248068: Rename range.mm to range_mac.mm. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 5 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | ui/base/range/range.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #include "ui/base/range/range.h" 5 #include "ui/base/range/range.h"
6 6
7 #include <limits> 7 #include <limits>
8 #include <ostream> 8 #include <ostream>
9 9
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 Range Range::Intersect(const Range& range) const { 68 Range Range::Intersect(const Range& range) const {
69 size_t min = std::max(GetMin(), range.GetMin()); 69 size_t min = std::max(GetMin(), range.GetMin());
70 size_t max = std::min(GetMax(), range.GetMax()); 70 size_t max = std::min(GetMax(), range.GetMax());
71 71
72 if (min >= max) // No intersection. 72 if (min >= max) // No intersection.
73 return InvalidRange(); 73 return InvalidRange();
74 74
75 return Range(min, max); 75 return Range(min, max);
76 } 76 }
77 77
78 #if defined(OS_WIN)
79 Range::Range(const CHARRANGE& range, LONG total_length) {
80 // Check if this is an invalid range.
81 if (range.cpMin == -1 && range.cpMax == -1) {
82 *this = InvalidRange();
83 } else {
84 DCHECK_GE(range.cpMin, 0);
85 set_start(range.cpMin);
86 // {0,-1} is the "whole range" but that doesn't mean much out of context,
87 // so use the |total_length| parameter.
88 if (range.cpMax == -1) {
89 DCHECK_EQ(0, range.cpMin);
90 DCHECK_NE(-1, total_length);
91 set_end(total_length);
92 } else {
93 set_end(range.cpMax);
94 }
95 }
96 }
97
98 CHARRANGE Range::ToCHARRANGE() const {
99 CHARRANGE r = { -1, -1 };
100 if (!IsValid())
101 return r;
102
103 const LONG kLONGMax = std::numeric_limits<LONG>::max();
104 DCHECK_LE(static_cast<LONG>(start()), kLONGMax);
105 DCHECK_LE(static_cast<LONG>(end()), kLONGMax);
106 r.cpMin = start();
107 r.cpMax = end();
108 return r;
109 }
110 #endif // defined(OS_WIN)
111
112 std::ostream& operator<<(std::ostream& out, const ui::Range& range) { 78 std::ostream& operator<<(std::ostream& out, const ui::Range& range) {
113 return out << "{" << range.start() << "," << range.end() << "}"; 79 return out << "{" << range.start() << "," << range.end() << "}";
114 } 80 }
115 81
116 } // namespace gfx 82 } // namespace gfx
OLDNEW
« no previous file with comments | « no previous file | ui/base/range/range.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698