diff options
author | Steve Block <steveblock@google.com> | 2010-11-11 18:48:01 +0000 |
---|---|---|
committer | Steve Block <steveblock@google.com> | 2010-11-11 20:05:56 +0000 |
commit | aca659c20748030c02d7ab31ff28f8293126092b (patch) | |
tree | b8058c323fa4b341a12b9dff982eb6ff1c446136 /tests/DumpRenderTree2 | |
parent | 6a108501b1b2106ebf36e89cf617ab780d477bf5 (diff) | |
download | frameworks_base-aca659c20748030c02d7ab31ff28f8293126092b.zip frameworks_base-aca659c20748030c02d7ab31ff28f8293126092b.tar.gz frameworks_base-aca659c20748030c02d7ab31ff28f8293126092b.tar.bz2 |
Refactor EventSenderImpl.MousePoint
This factors out a new Point class and a new
createViewPointFromContentCoordinates() method. This will allow Point
and the conversion method to be re-used with mouse events.
Change-Id: I2d689d0ffa0ad7ba01d0e90f78c812604ab96234
Diffstat (limited to 'tests/DumpRenderTree2')
-rw-r--r-- | tests/DumpRenderTree2/src/com/android/dumprendertree2/EventSenderImpl.java | 55 |
1 files changed, 32 insertions, 23 deletions
diff --git a/tests/DumpRenderTree2/src/com/android/dumprendertree2/EventSenderImpl.java b/tests/DumpRenderTree2/src/com/android/dumprendertree2/EventSenderImpl.java index 68bcf11..842bf2b 100644 --- a/tests/DumpRenderTree2/src/com/android/dumprendertree2/EventSenderImpl.java +++ b/tests/DumpRenderTree2/src/com/android/dumprendertree2/EventSenderImpl.java @@ -56,21 +56,38 @@ public class EventSenderImpl { private static final int MSG_SET_TOUCH_MODIFIER = 16; private static final int MSG_CANCEL_TOUCH_POINT = 17; - public static class TouchPoint { - WebView mWebView; - private int mId; + private static class Point { private int mX; private int mY; + + public Point(int x, int y) { + mX = x; + mY = y; + } + public int x() { + return mX; + } + public int y() { + return mY; + } + } + + private Point createViewPointFromContentCoordinates(int x, int y) { + return new Point((int)(x * mWebView.getScale()) - mWebView.getScrollX(), + (int)(y * mWebView.getScale()) - mWebView.getScrollY()); + } + + public static class TouchPoint { + private int mId; + private Point mPoint; private long mDownTime; private boolean mReleased = false; private boolean mMoved = false; private boolean mCancelled = false; - public TouchPoint(WebView webView, int id, int x, int y) { - mWebView = webView; + public TouchPoint(int id, Point point) { mId = id; - mX = scaleX(x); - mY = scaleY(y); + mPoint = point; } public int getId() { @@ -78,20 +95,19 @@ public class EventSenderImpl { } public int getX() { - return mX; + return mPoint.x(); } public int getY() { - return mY; + return mPoint.y(); } public boolean hasMoved() { return mMoved; } - public void move(int newX, int newY) { - mX = scaleX(newX); - mY = scaleY(newY); + public void move(Point point) { + mPoint = point; mMoved = true; } @@ -122,14 +138,6 @@ public class EventSenderImpl { public void cancel() { mCancelled = true; } - - private int scaleX(int x) { - return (int)(x * mWebView.getScale()) - mWebView.getScrollX(); - } - - private int scaleY(int y) { - return (int)(y * mWebView.getScale()) - mWebView.getScrollY(); - } } private List<TouchPoint> mTouchPoints; @@ -208,8 +216,8 @@ public class EventSenderImpl { } else { id = getTouchPoints().get(numPoints - 1).getId() + 1; } - getTouchPoints().add(new TouchPoint(mWebView, id, - msg.arg1, msg.arg2)); + getTouchPoints().add( + new TouchPoint(id, createViewPointFromContentCoordinates(msg.arg1, msg.arg2))); break; case MSG_TOUCH_START: @@ -232,7 +240,8 @@ public class EventSenderImpl { break; } - getTouchPoints().get(index).move(bundle.getInt("x"), bundle.getInt("y")); + getTouchPoints().get(index).move( + createViewPointFromContentCoordinates(bundle.getInt("x"), bundle.getInt("y"))); break; case MSG_TOUCH_MOVE: |