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

Side by Side Diff: ui/base/range/range_mac.mm

Issue 24012002: Move Range code to gfx. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: d Created 7 years, 3 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 | « ui/base/range/range.cc ('k') | ui/base/range/range_mac_unittest.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ui/base/range/range.h"
6
7 #include <limits>
8
9 #include "base/logging.h"
10
11 namespace ui {
12
13 Range::Range(const NSRange& range) {
14 *this = range;
15 }
16
17 Range& Range::operator=(const NSRange& range) {
18 if (range.location == NSNotFound) {
19 DCHECK_EQ(0U, range.length);
20 *this = InvalidRange();
21 } else {
22 set_start(range.location);
23 // Don't overflow |end_|.
24 DCHECK_LE(range.length, std::numeric_limits<size_t>::max() - start());
25 set_end(start() + range.length);
26 }
27 return *this;
28 }
29
30 NSRange Range::ToNSRange() const {
31 if (!IsValid())
32 return NSMakeRange(NSNotFound, 0);
33 return NSMakeRange(GetMin(), length());
34 }
35
36 } // namespace gfx
OLDNEW
« no previous file with comments | « ui/base/range/range.cc ('k') | ui/base/range/range_mac_unittest.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698