Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1192)

Unified Diff: chrome/android/java/src/org/chromium/chrome/browser/widget/textbubble/TextBubble.java

Issue 2815653003: IPH - connect data saver previews (Closed)
Patch Set: Addressed comments Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/android/java/src/org/chromium/chrome/browser/widget/textbubble/TextBubble.java
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/textbubble/TextBubble.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/textbubble/TextBubble.java
index 752e673d46b0dc56eff172374289be3f19be8226..bc5e7b004b4edfebc3085777e0640c8ad56db7d1 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/textbubble/TextBubble.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/textbubble/TextBubble.java
@@ -249,15 +249,19 @@ public class TextBubble implements OnTouchListener {
int spaceAboveAnchor = mAnchorRect.top - mCachedWindowRect.top - paddingY - mMarginPx;
int spaceBelowAnchor = mCachedWindowRect.bottom - mAnchorRect.bottom - paddingY - mMarginPx;
- // Position the bubble below the anchor if it fits or, if not, it's the largest space
- // available. This does bias the bubbles to show below the anchors if possible.
+ // Bias based on the center of the bubble and where it is on the screen.
+ boolean idealFitsBelow = idealHeight <= spaceBelowAnchor;
+ boolean idealFitsAbove = idealHeight <= spaceAboveAnchor;
+
+ // Position the bubble in the largest available space where it can fit. This will bias the
+ // bubbles to show below the anchor if it will not fit in either place.
boolean positionBelow =
- idealHeight <= spaceBelowAnchor || spaceBelowAnchor >= spaceAboveAnchor;
+ (idealFitsBelow && spaceBelowAnchor >= spaceAboveAnchor) || !idealFitsAbove;
// Override the ideal bubble orientation if we are trying to maintain the current one.
if (preferCurrentOrientation && currentPositionBelow != positionBelow) {
- if (currentPositionBelow && idealHeight <= spaceBelowAnchor) positionBelow = true;
- if (!currentPositionBelow && idealHeight <= spaceAboveAnchor) positionBelow = false;
+ if (currentPositionBelow && idealFitsBelow) positionBelow = true;
+ if (!currentPositionBelow && idealFitsAbove) positionBelow = false;
}
int maxContentHeight = positionBelow ? spaceBelowAnchor : spaceAboveAnchor;

Powered by Google App Engine
This is Rietveld 408576698