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.
5 #include "ui/gfx/range/range.h"
9 #include "base/logging.h"
13 Range::Range(const NSRange& range) {
17 Range& Range::operator=(const NSRange& range) {
18 if (range.location == NSNotFound) {
19 DCHECK_EQ(0U, range.length);
20 *this = InvalidRange();
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);
30 NSRange Range::ToNSRange() const {
32 return NSMakeRange(NSNotFound, 0);
33 return NSMakeRange(GetMin(), length());