Index: chrome/android/java/src/org/chromium/chrome/browser/widget/ContextMenuDialog.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/ContextMenuDialog.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/ContextMenuDialog.java |
index ba82c24abd058a9d08c9cde0ce3f9bdc7a12024e..d67b0aa335baf3ba529fde0c32b662f91f5869e5 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/ContextMenuDialog.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/ContextMenuDialog.java |
@@ -22,6 +22,8 @@ import android.view.animation.ScaleAnimation; |
import org.chromium.chrome.browser.contextmenu.TabularContextMenuViewPager; |
import org.chromium.content.browser.RenderCoordinates; |
+import javax.annotation.Nullable; |
+ |
/** |
* ContextMenuDialog is a subclass of AlwaysDismissedDialog that ensures that the proper scale |
* animation is played upon calling {@link #show()} and {@link #dismiss()}. |
@@ -49,10 +51,11 @@ public class ContextMenuDialog extends AlwaysDismissedDialog { |
* @param touchPointXPx The x-coordinate of the touch that triggered the context menu. |
* @param touchPointYPx The y-coordinate of the touch that triggered the context menu. |
* @param contentView The The {@link TabularContextMenuViewPager} to display on the dialog. |
- * @param renderCoordinates The render coordinates to get the y offset of the window. |
+ * @param renderCoordinates The render coordinates to get the y offset of the window. This could |
+ * be null if ContentViewCore is not available. |
*/ |
public ContextMenuDialog(Activity ownerActivity, int theme, float touchPointXPx, |
- float touchPointYPx, View contentView, RenderCoordinates renderCoordinates) { |
+ float touchPointYPx, View contentView, @Nullable RenderCoordinates renderCoordinates) { |
super(ownerActivity, theme); |
mActivity = ownerActivity; |
mTouchPointXPx = touchPointXPx; |
@@ -95,7 +98,9 @@ public class ContextMenuDialog extends AlwaysDismissedDialog { |
window.getDecorView().getWindowVisibleDisplayFrame(rectangle); |
float xOffsetPx = rectangle.left; |
- float yOffsetPx = rectangle.top + mRenderCoordinates.getContentOffsetYPix(); |
+ float contentOffsetYPx = |
+ mRenderCoordinates != null ? mRenderCoordinates.getContentOffsetYPix() : 0; |
+ float yOffsetPx = rectangle.top + contentOffsetYPx; |
int[] currentLocationOnScreenPx = new int[2]; |
mContentView.getLocationOnScreen(currentLocationOnScreenPx); |
@@ -159,8 +164,14 @@ public class ContextMenuDialog extends AlwaysDismissedDialog { |
float fromY = fromX; |
float toY = toX; |
- ScaleAnimation animation = new ScaleAnimation( |
- fromX, toX, fromY, toY, Animation.ABSOLUTE, pivotX, Animation.ABSOLUTE, pivotY); |
+ ScaleAnimation animation; |
+ if (mRenderCoordinates == null) { |
+ animation = new ScaleAnimation(fromX, toX, fromY, toY, Animation.RELATIVE_TO_SELF, 0.5f, |
+ Animation.RELATIVE_TO_SELF, 0.5f); |
Theresa
2017/06/22 23:33:41
I think ideally we would skip calculating the pivo
|
+ } else { |
+ animation = new ScaleAnimation( |
+ fromX, toX, fromY, toY, Animation.ABSOLUTE, pivotX, Animation.ABSOLUTE, pivotY); |
+ } |
long duration = isEnterAnimation ? ENTER_ANIMATION_DURATION_MS : EXIT_ANIMATION_DURATION_MS; |