Skip to content

Commit

Permalink
If floating paste menu creation fails don't try to use legacy one.
Browse files Browse the repository at this point in the history
This is related to crrev.com/2582933002.

Review-Url: https://codereview.chromium.org/2610733002
Cr-Commit-Position: refs/heads/master@{#441225}
  • Loading branch information
amaralp authored and Commit bot committed Jan 3, 2017
1 parent e112d40 commit b19680f
Showing 1 changed file with 2 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,6 @@ public class FloatingPastePopupMenu implements PastePopupMenu {
private int mRawPositionX;
private int mRawPositionY;

// Embedders may not support floating ActionModes, in which case we should
// use the legacy menu as a fallback.
private LegacyPastePopupMenu mFallbackPastePopupMenu;

public FloatingPastePopupMenu(Context context, View parent, PastePopupMenuDelegate delegate) {
assert Build.VERSION.SDK_INT >= Build.VERSION_CODES.M;

Expand All @@ -63,11 +59,6 @@ public FloatingPastePopupMenu(Context context, View parent, PastePopupMenuDelega

@Override
public void show(int x, int y) {
if (mFallbackPastePopupMenu != null) {
mFallbackPastePopupMenu.show(x, y);
return;
}

if (isShowing()) {
int dx = mRawPositionX - x;
int dy = mRawPositionY - y;
Expand All @@ -81,16 +72,11 @@ public void show(int x, int y) {
return;
}

ensureActionModeOrFallback();
ensureActionMode();
}

@Override
public void hide() {
if (mFallbackPastePopupMenu != null) {
mFallbackPastePopupMenu.hide();
return;
}

if (mActionMode != null) {
mActionMode.finish();
mActionMode = null;
Expand All @@ -99,13 +85,11 @@ public void hide() {

@Override
public boolean isShowing() {
if (mFallbackPastePopupMenu != null) return mFallbackPastePopupMenu.isShowing();
return mActionMode != null;
}

private void ensureActionModeOrFallback() {
private void ensureActionMode() {
if (mActionMode != null) return;
if (mFallbackPastePopupMenu != null) return;

ActionMode actionMode = mParent.startActionMode(
new ActionModeCallback(), ActionMode.TYPE_FLOATING);
Expand All @@ -115,9 +99,6 @@ private void ensureActionModeOrFallback() {

assert actionMode.getType() == ActionMode.TYPE_FLOATING;
mActionMode = actionMode;
} else {
mFallbackPastePopupMenu = new LegacyPastePopupMenu(mContext, mParent, mDelegate);
mFallbackPastePopupMenu.show(mRawPositionX, mRawPositionY);
}
}

Expand Down

0 comments on commit b19680f

Please sign in to comment.