| Index: chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java
|
| index 640aabe91a27fc70069f04302a0b1facb4ccb1db..a42332357e082bd914cdcfb43eaab5ba098c1d1c 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/contextmenu/TabularContextMenuViewPager.java
|
| @@ -30,24 +30,29 @@ public class TabularContextMenuViewPager extends ViewPager {
|
| */
|
| @Override
|
| protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
| - int maxHeight = 0;
|
| + int menuHeight = 0;
|
| int tabHeight = 0;
|
| + // getCurrentItem() does not take into account the tab layout unlike getChildCount().
|
| + int currentItemsIndex = getCurrentItem() + 1;
|
| +
|
| for (int i = 0; i < getChildCount(); i++) {
|
| View child = getChildAt(i);
|
| - child.measure(widthMeasureSpec,
|
| - MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.UNSPECIFIED));
|
| + child.measure(
|
| + widthMeasureSpec, MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
|
| int measuredHeight = child.getMeasuredHeight();
|
|
|
| // The ViewPager also considers the tab layout one of its children, and needs to be
|
| // treated separately from getting the largest height.
|
| if (child.getId() == R.id.tab_layout && child.getVisibility() != GONE) {
|
| tabHeight = measuredHeight;
|
| - } else {
|
| - maxHeight = Math.max(maxHeight, child.getMeasuredHeight());
|
| + } else if (i == currentItemsIndex) {
|
| + menuHeight = child.getMeasuredHeight();
|
| + break;
|
| }
|
| }
|
| - maxHeight += tabHeight;
|
| - heightMeasureSpec = MeasureSpec.makeMeasureSpec(maxHeight, MeasureSpec.EXACTLY);
|
| + int fullHeight = menuHeight + tabHeight;
|
| +
|
| + heightMeasureSpec = MeasureSpec.makeMeasureSpec(fullHeight, MeasureSpec.EXACTLY);
|
| super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
| }
|
| }
|
|
|