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

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: removed ImeTest#testDoesNotHang_rendererCrashes which does not test anything Created 4 years, 9 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 2016 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 import org.chromium.base.VisibleForTesting;
8
9 /**
10 * A simple class to set start and end in int type.
11 * TODO(changwan): replace this with android.util.Range when the default SDK
12 * version becomes 21 or higher.
13 */
14 public class Range {
15 private int mStart;
16 private int mEnd;
17
18 public Range(int start, int end) {
19 set(start, end);
20 }
21
22 public int start() {
23 return mStart;
24 }
25
26 public int end() {
27 return mEnd;
28 }
29
30 @VisibleForTesting
31 public void set(int start, int end) {
32 mStart = Math.min(start, end);
33 mEnd = Math.max(start, end);
34 }
35
36 public void clamp(int start, int end) {
37 mStart = Math.min(Math.max(mStart, start), end);
38 mEnd = Math.max(Math.min(mEnd, end), start);
39 }
40
41 @Override
42 public boolean equals(Object o) {
43 if (!(o instanceof Range)) return false;
44 if (o == this) return true;
45 Range r = (Range) o;
46 return mStart == r.mStart && mEnd == r.mEnd;
47 }
48
49 @Override
50 public int hashCode() {
51 return 11 * mStart + 31 * mEnd;
52 }
53
54 @Override
55 public String toString() {
56 return "[ " + mStart + ", " + mEnd + " ]";
57 }
58 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698