| Index: chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/InnerNode.java
|
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/InnerNode.java b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/InnerNode.java
|
| index 0c57425be4eae349cdee5aaf94c3c5987a1a61da..f54db9da5637255947a33701d2119168626456af 100644
|
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/InnerNode.java
|
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ntp/cards/InnerNode.java
|
| @@ -4,6 +4,7 @@
|
|
|
| package org.chromium.chrome.browser.ntp.cards;
|
|
|
| +import org.chromium.base.Callback;
|
| import org.chromium.base.VisibleForTesting;
|
| import org.chromium.chrome.browser.ntp.snippets.SnippetArticle;
|
|
|
| @@ -17,16 +18,16 @@ public class InnerNode extends ChildNode implements NodeParent {
|
| private final List<TreeNode> mChildren = new ArrayList<>();
|
|
|
| private int getChildIndexForPosition(int position) {
|
| - if (position < 0) {
|
| - throw new IndexOutOfBoundsException(Integer.toString(position));
|
| - }
|
| + checkIndex(position);
|
| int numItems = 0;
|
| int numChildren = mChildren.size();
|
| for (int i = 0; i < numChildren; i++) {
|
| numItems += mChildren.get(i).getItemCount();
|
| if (position < numItems) return i;
|
| }
|
| - throw new IndexOutOfBoundsException(position + "/" + numItems);
|
| + // checkIndex() will have caught this case already.
|
| + assert false;
|
| + return -1;
|
| }
|
|
|
| private int getStartingOffsetForChildIndex(int childIndex) {
|
| @@ -84,6 +85,13 @@ public class InnerNode extends ChildNode implements NodeParent {
|
| }
|
|
|
| @Override
|
| + public void dismissItem(int position, Callback<String> itemRemovedCallback) {
|
| + int index = getChildIndexForPosition(position);
|
| + getChildren().get(index).dismissItem(
|
| + position - getStartingOffsetForChildIndex(index), itemRemovedCallback);
|
| + }
|
| +
|
| + @Override
|
| public int getDismissSiblingPosDelta(int position) {
|
| int index = getChildIndexForPosition(position);
|
| return mChildren.get(index).getDismissSiblingPosDelta(
|
|
|