Chromium Code Reviews| Index: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| diff --git a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| index b5068b0eec0471e4408badf0edd6072d8d6e6ba9..0a56c620c911f86fd124b6929090ec85bae9b3f4 100644 |
| --- a/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| +++ b/content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java |
| @@ -44,6 +44,7 @@ import android.view.accessibility.AccessibilityNodeProvider; |
| import android.view.inputmethod.EditorInfo; |
| import android.view.inputmethod.InputConnection; |
| import android.view.inputmethod.InputMethodManager; |
| +import android.widget.AdapterView; |
| import android.widget.FrameLayout; |
| import com.google.common.annotations.VisibleForTesting; |
| @@ -70,6 +71,9 @@ import org.chromium.content.browser.input.SelectionHandleController; |
| import org.chromium.content.common.ContentSwitches; |
| import org.chromium.content_public.browser.GestureStateListener; |
| import org.chromium.content_public.browser.WebContents; |
| +import org.chromium.ui.DropdownAdapter; |
| +import org.chromium.ui.DropdownItem; |
| +import org.chromium.ui.DropdownPopupWindow; |
| import org.chromium.ui.base.ViewAndroid; |
| import org.chromium.ui.base.ViewAndroidDelegate; |
| import org.chromium.ui.base.WindowAndroid; |
| @@ -320,6 +324,7 @@ public class ContentViewCore |
| private PopupZoomer mPopupZoomer; |
| private SelectPopupDialog mSelectPopupDialog; |
| + private DropdownPopupWindow mSingleSelectPopup; |
| private Runnable mFakeMouseMoveRunnable = null; |
| @@ -1551,7 +1556,6 @@ public class ContentViewCore |
| mInputMethodManagerWrapper.restartInput(mContainerView); |
| } |
| mContainerViewInternals.super_onConfigurationChanged(newConfig); |
| - |
| // To request layout has side effect, but it seems OK as it only happen in |
| // onConfigurationChange and layout has to be changed in most case. |
| mContainerView.requestLayout(); |
| @@ -2388,20 +2392,48 @@ public class ContentViewCore |
| */ |
| @SuppressWarnings("unused") |
| @CalledByNative |
| - private void showSelectPopup(String[] items, int[] enabled, boolean multiple, |
| + private void showSelectPopup(Rect bounds, String[] items, int[] enabled, boolean multiple, |
|
aurimas (slooooooooow)
2014/04/16 17:36:48
Can we move most of the code in this method to Sel
keishi
2014/04/17 12:25:40
Done.
|
| int[] selectedIndices) { |
| if (mContainerView.getParent() == null || mContainerView.getVisibility() != View.VISIBLE) { |
| selectPopupMenuItems(null); |
| return; |
| } |
| - |
| - hideSelectPopup(); |
| assert items.length == enabled.length; |
| List<SelectPopupItem> popupItems = new ArrayList<SelectPopupItem>(); |
| for (int i = 0; i < items.length; i++) { |
| popupItems.add(new SelectPopupItem(items[i], enabled[i])); |
| } |
| - mSelectPopupDialog = SelectPopupDialog.show(this, popupItems, multiple, selectedIndices); |
| + |
| + hidePopupDialog(); |
| + if (DeviceUtils.isTablet(mContext) && !multiple) { |
| + mSingleSelectPopup = new DropdownPopupWindow(getContext(), getViewAndroidDelegate()); |
| + mSingleSelectPopup.setOnItemClickListener(new AdapterView.OnItemClickListener() { |
| + @Override |
| + public void onItemClick(AdapterView<?> parent, View view, int position, long id) { |
| + int[] selectedIndices = {position}; |
| + selectPopupMenuItems(selectedIndices); |
| + hideSelectPopup(); |
| + } |
| + }); |
| + List<DropdownItem> dropdownItems = new ArrayList<DropdownItem>(); |
| + for (int i = 0; i < popupItems.size(); i++) { |
|
aurimas (slooooooooow)
2014/04/16 17:36:48
We are copying items for the second time now (line
keishi
2014/04/17 12:25:40
Done.
|
| + dropdownItems.add((DropdownItem) popupItems.get(i)); |
| + } |
| + mSingleSelectPopup.setAdapter(new DropdownAdapter(getContext(), dropdownItems, null)); |
| + float anchorX = mRenderCoordinates.fromPixToDip( |
| + mRenderCoordinates.fromLocalCssToPix(bounds.left)); |
| + float anchorY = mRenderCoordinates.fromPixToDip( |
| + mRenderCoordinates.fromLocalCssToPix(bounds.top)); |
| + float anchorWidth = mRenderCoordinates.fromPixToDip( |
| + mRenderCoordinates.fromLocalCssToPix(bounds.right)) - anchorX; |
| + float anchorHeight = mRenderCoordinates.fromPixToDip( |
| + mRenderCoordinates.fromLocalCssToPix(bounds.bottom)) - anchorY; |
| + mSingleSelectPopup.setAnchorRect(anchorX, anchorY, anchorWidth, anchorHeight); |
| + mSingleSelectPopup.show(); |
| + } else { |
| + mSelectPopupDialog = |
| + SelectPopupDialog.show(this, popupItems, multiple, selectedIndices); |
| + } |
| } |
| /** |
| @@ -2413,6 +2445,10 @@ public class ContentViewCore |
| mSelectPopupDialog.hide(); |
| mSelectPopupDialog = null; |
| } |
| + if (mSingleSelectPopup != null) { |
| + mSingleSelectPopup.dismiss(); |
| + mSingleSelectPopup = null; |
| + } |
| } |
| /** |