123456789101112131415161718192021222324252627282930313233343536 |
- // Copyright (c) 2011 The Chromium Authors. All rights reserved.
- // Use of this source code is governed by a BSD-style license that can be
- // found in the LICENSE file.
- #include "ui/gfx/range/range.h"
- #include <stddef.h>
- #include <limits>
- #include "base/check_op.h"
- namespace gfx {
- Range::Range(const NSRange& range) {
- *this = range;
- }
- Range& Range::operator=(const NSRange& range) {
- if (range.location == NSNotFound) {
- DCHECK_EQ(0U, range.length);
- *this = InvalidRange();
- } else {
- set_start(range.location);
- set_end(start() + range.length);
- }
- return *this;
- }
- NSRange Range::ToNSRange() const {
- if (!IsValid())
- return NSMakeRange(NSNotFound, 0);
- return NSMakeRange(GetMin(), length());
- }
- } // namespace gfx
|