Index: content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java |
diff --git a/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java b/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java |
index 56a74a86d02612a88f3eab310031a593996f1b4d..4e53a684dac6b81cc539eb26495669e4a64fc961 100644 |
--- a/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java |
+++ b/content/public/android/java/src/org/chromium/content/browser/input/PopupTouchHandleDrawable.java |
@@ -143,10 +143,9 @@ public class PopupTouchHandleDrawable extends View { |
} |
@CalledByNative |
- private void setOrientation(int orientation) { |
+ private void setOrientation(int orientation, boolean mirrorVertical, boolean mirrorHorizontal) { |
assert (orientation >= TouchHandleOrientation.LEFT |
&& orientation <= TouchHandleOrientation.UNDEFINED); |
- if (mOrientation == orientation) return; |
final boolean hadValidOrientation = mOrientation != TouchHandleOrientation.UNDEFINED; |
mOrientation = orientation; |
@@ -156,19 +155,51 @@ public class PopupTouchHandleDrawable extends View { |
switch (orientation) { |
case TouchHandleOrientation.LEFT: { |
- mDrawable = HandleViewResources.getLeftHandleDrawable(mContext); |
- mHotspotX = (mDrawable.getIntrinsicWidth() * 3) / 4f; |
+ if (mirrorVertical && mirrorHorizontal) { |
+ // Inverted about both X and Y axes |
+ mDrawable = HandleViewResources.getLeftHandleDrawable(mContext, true); |
+ } else if (mirrorVertical) { |
+ // Inverted about X axis only |
+ mDrawable = HandleViewResources.getRightHandleDrawable(mContext, true); |
+ } else if (mirrorHorizontal) { |
+ // Inverted about Y axis only |
+ mDrawable = HandleViewResources.getRightHandleDrawable(mContext, false); |
+ } else { |
+ // Normal case |
+ mDrawable = HandleViewResources.getLeftHandleDrawable(mContext, false); |
+ } |
+ |
+ int drawableWidth = mDrawable.getIntrinsicWidth(); |
+ mHotspotX = mirrorHorizontal ? drawableWidth / 4f : (drawableWidth * 3) / 4f; |
break; |
} |
case TouchHandleOrientation.RIGHT: { |
- mDrawable = HandleViewResources.getRightHandleDrawable(mContext); |
- mHotspotX = mDrawable.getIntrinsicWidth() / 4f; |
+ if (mirrorVertical && mirrorHorizontal) { |
+ // Inverted about both X and Y axes |
+ mDrawable = HandleViewResources.getRightHandleDrawable(mContext, true); |
+ } else if (mirrorVertical) { |
+ // Inverted about X axis only |
+ mDrawable = HandleViewResources.getLeftHandleDrawable(mContext, true); |
+ } else if (mirrorHorizontal) { |
+ // Inverted about Y axis only |
+ mDrawable = HandleViewResources.getLeftHandleDrawable(mContext, false); |
+ } else { |
+ // Normal Case |
+ mDrawable = HandleViewResources.getRightHandleDrawable(mContext, false); |
+ } |
+ |
+ int drawableWidth = mDrawable.getIntrinsicWidth(); |
+ mHotspotX = mirrorHorizontal ? (drawableWidth * 3) / 4f : drawableWidth / 4f; |
break; |
} |
case TouchHandleOrientation.CENTER: { |
- mDrawable = HandleViewResources.getCenterHandleDrawable(mContext); |
+ if (mirrorVertical) { |
+ mDrawable = HandleViewResources.getCenterHandleDrawable(mContext, true); |
+ } else { |
+ mDrawable = HandleViewResources.getCenterHandleDrawable(mContext, false); |
+ } |
mHotspotX = mDrawable.getIntrinsicWidth() / 2f; |
break; |
} |
@@ -177,7 +208,8 @@ public class PopupTouchHandleDrawable extends View { |
default: |
break; |
} |
- mHotspotY = 0; |
+ |
+ mHotspotY = mirrorVertical ? mDrawable.getIntrinsicHeight() : 0; |
// Force handle repositioning to accommodate the new orientation's hotspot. |
if (hadValidOrientation) setFocus(oldAdjustedPositionX, oldAdjustedPositionY); |