Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java |
| index dd27eb5a348b6694b942383d1dd42eaa7d3bef88..895881a4333e138f7b4f8e65c88e634376552f26 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/compositor/bottombar/contextualsearch/ContextualSearchPanel.java |
| @@ -230,10 +230,9 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
| */ |
| public void handleClick(long time, float x, float y) { |
| mHasDetectedTouchGesture = true; |
| - if (isYCoordinateInsideBasePage(y)) { |
| + if (isYCoordinateInsideBasePage(x, y)) { |
| closePanel(StateChangeReason.BASE_PAGE_TAP, true); |
| - } else if (isYCoordinateInsideSearchBar(y)) { |
| - // TODO(pedrosimonetti): handle click in the close button here. |
| + } else if (isYCoordinateInsideSearchBar(x, y)) { |
| if (isPeeking()) { |
| if (mManagementDelegate.isRunningInCompatibilityMode()) { |
| mManagementDelegate.openResolvedSearchUrlInNewTab(); |
| @@ -259,35 +258,49 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
| // ============================================================================================ |
| /** |
| + * @param x The x coordinate in dp. |
| * @param y The y coordinate in dp. |
| - * @return Whether the given |y| coordinate is inside the Search Bar area. |
| + * @return Whether the given coordinate is inside the Search Panel area. |
| */ |
| - public boolean isYCoordinateInsideSearchBar(float y) { |
| - return y >= getOffsetY() && y <= (getOffsetY() + getSearchBarHeight()); |
| + private boolean isCoordinateInsideSearchPanel(float x, float y) { |
| + return y >= getOffsetY() && y <= (getOffsetY() + getHeight()) |
| + && x >= getOffsetX() && x <= (getOffsetX() + getWidth()); |
| } |
| /** |
| + * @param x The x coordinate in dp. |
| * @param y The y coordinate in dp. |
| - * @return Whether the given |y| coordinate is inside the Search Content |
| - * View area. |
| + * @return Whether the given coordinate is inside the Base Page area. |
| */ |
| - public boolean isYCoordinateInsideSearchContentView(float y) { |
| - return y > getSearchContentViewOffsetY(); |
| + private boolean isYCoordinateInsideBasePage(float x, float y) { |
|
David Trainor- moved to gerrit
2015/07/14 23:12:00
Should this still have Y in the name? It seems to
pedro (no code reviews)
2015/07/15 00:19:16
Good catch! Thanks!
|
| + return !isCoordinateInsideSearchPanel(x, y); |
| } |
| /** |
| - * @return The vertical offset of the Search Content View in dp. |
| + * @param x The x coordinate in dp. |
| + * @param y The y coordinate in dp. |
| + * @return Whether the given coordinate is inside the Search Bar area. |
| */ |
| - public float getSearchContentViewOffsetY() { |
| - return getOffsetY() + getSearchBarHeight() + getPromoHeight(); |
| + public boolean isYCoordinateInsideSearchBar(float x, float y) { |
| + return isCoordinateInsideSearchPanel(x, y) |
| + && y >= getOffsetY() && y <= (getOffsetY() + getSearchBarHeight()); |
| } |
| /** |
| + * @param x The x coordinate in dp. |
| * @param y The y coordinate in dp. |
| - * @return Whether the given |y| coordinate is inside the Base Page area. |
| + * @return Whether the given coordinate is inside the Search Content View area. |
| */ |
| - private boolean isYCoordinateInsideBasePage(float y) { |
| - return y < getOffsetY(); |
| + public boolean isYCoordinateInsideSearchContentView(float x, float y) { |
| + return isCoordinateInsideSearchPanel(x, y) |
| + && y > getSearchContentViewOffsetY(); |
| + } |
| + |
| + /** |
| + * @return The vertical offset of the Search Content View in dp. |
| + */ |
| + public float getSearchContentViewOffsetY() { |
| + return getOffsetY() + getSearchBarHeight() + getPromoHeight(); |
| } |
| /** |
| @@ -364,6 +377,18 @@ public class ContextualSearchPanel extends ContextualSearchPanelAnimation |
| } |
| @Override |
| + public int getMaximumWidthPx() { |
| + // NOTE(pedrosimonetti): exposing superclass method to the interface. |
| + return super.getMaximumWidthPx(); |
| + } |
| + |
| + @Override |
| + public int getMaximumHeightPx() { |
| + // NOTE(pedrosimonetti): exposing superclass method to the interface. |
| + return super.getMaximumHeightPx(); |
| + } |
| + |
| + @Override |
| public void maximizePanelThenPromoteToTab(StateChangeReason reason) { |
| mShouldPromoteToTabAfterMaximizing = true; |
| maximizePanel(reason); |