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

Side by Side Diff: content/public/android/java/src/org/chromium/content/browser/input/Range.java

Issue 1278593004: Introduce ThreadedInputConnection behind a switch (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fixed release test failures Created 4 years, 11 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
OLDNEW
(Empty)
1 // Copyright 2015 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 package org.chromium.content.browser.input;
6
7 /**
8 * A simple class to set start and end in int type.
9 * TODO(changwan): replace this with android.util.Range when the default SDK
10 * version becomes 21 or higher.
11 */
12 public class Range {
13 private int mStart;
14 private int mEnd;
15
16 public Range(int start, int end) {
17 mStart = Math.min(start, end);
18 mEnd = Math.max(start, end);
19 }
20
21 public int start() {
22 return mStart;
23 }
24
25 public int end() {
26 return mEnd;
27 }
28
29 public void clamp(int start, int end) {
30 if (mStart < start) mStart = start;
31 if (mStart > end) mStart = end;
32 if (mEnd > end) mEnd = end;
33 if (mEnd < start) mEnd = start;
34 }
35
36 @Override
37 public boolean equals(Object o) {
38 if (!(o instanceof Range)) return false;
39 if (o == this) return true;
40 Range r = (Range) o;
41 return mStart == r.mStart && mEnd == r.mEnd;
42 }
43
44 @Override
45 public int hashCode() {
46 return 11 * mStart + 31 * mEnd;
47 }
48
49 @Override
50 public String toString() {
51 return "[ " + mStart + ", " + mEnd + " ]";
52 }
53 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698