• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright (c) 2012 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/gfx/range/range.h"
6 
7 #include <inttypes.h>
8 
9 #include <algorithm>
10 
11 #include "base/logging.h"
12 #include "base/strings/stringprintf.h"
13 
14 namespace gfx {
15 
Intersect(const Range & range) const16 Range Range::Intersect(const Range& range) const {
17   uint32_t min = std::max(GetMin(), range.GetMin());
18   uint32_t max = std::min(GetMax(), range.GetMax());
19 
20   if (min >= max)  // No intersection.
21     return InvalidRange();
22 
23   return Range(min, max);
24 }
25 
ToString() const26 std::string Range::ToString() const {
27   return base::StringPrintf("{%" PRIu32 ",%" PRIu32 "}", start(), end());
28 }
29 
operator <<(std::ostream & os,const Range & range)30 std::ostream& operator<<(std::ostream& os, const Range& range) {
31   return os << range.ToString();
32 }
33 
34 }  // namespace gfx
35