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

Unified Diff: content/public/android/java/src/org/chromium/content/browser/ContentViewCore.java

Issue 2106753004: Introduce bottom controls to CC and let it respond to scrolling (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change to height and ratio Created 4 years, 5 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: 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 561c165b60f2c86a6f85b863d47b8af4410740b7..16335a0b4b47ccdfab270d44da8bfed8c0162b00 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
@@ -230,7 +230,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
// The anchor view should not go outside the bounds of the ContainerView.
int leftMargin = Math.round(x * scale);
- int topMargin = Math.round(mRenderCoordinates.getContentOffsetYPix() + y * scale);
+ int topMargin = Math.round(mRenderCoordinates.getTopControlsShownYPix() + y * scale);
int scaledWidth = Math.round(width * scale);
// ContentViewCore currently only supports these two container view types.
if (containerView instanceof FrameLayout) {
@@ -504,6 +504,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
private int mPhysicalBackingWidthPix;
private int mPhysicalBackingHeightPix;
private int mTopControlsHeightPix;
+ private int mBottomControlsHeightPix;
private boolean mTopControlsShrinkBlinkSize;
// Cached copy of all positions and scales as reported by the renderer.
@@ -701,6 +702,15 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
}
/**
+ * Sets the height of the bottom controls. If necessary, triggers a renderer resize.
+ */
+ public void setBottomControlsHeight(int bottomControlHeightPix) {
+ if (mBottomControlsHeightPix == bottomControlHeightPix) return;
+ mBottomControlsHeightPix = bottomControlHeightPix;
+ if (mNativeContentViewCore != 0) nativeWasResized(mNativeContentViewCore);
+ }
+
+ /**
* Returns a delegate that can be used to add and remove views from the current
* container view. Clients can safely hold to instances of this class as it handles the
* replacement of container views transparently.
@@ -1099,6 +1109,11 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
return mTopControlsHeightPix;
}
+ @CalledByNative
+ public int getBottomControlsHeightPix() {
+ return mBottomControlsHeightPix;
+ }
+
/**
* @return Current device scale factor (maps DIP pixels to physical pixels).
*/
@@ -2131,7 +2146,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
// The selection coordinates are relative to the content viewport, but we need
// coordinates relative to the containing View.
outRect.set(mSelectionRect);
- outRect.offset(0, (int) mRenderCoordinates.getContentOffsetYPix());
+ outRect.offset(0, (int) mRenderCoordinates.getTopControlsShownYPix());
}
@Override
@@ -2377,7 +2392,8 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
float pageScaleFactor, float minPageScaleFactor, float maxPageScaleFactor,
float contentWidth, float contentHeight,
float viewportWidth, float viewportHeight,
- float controlsOffsetYCss, float contentOffsetYCss,
+ float topControlsHeightDp, float topControlsShownRatio,
+ float bottomControlsHeightDp, float bottomControlsShownRatio,
boolean isMobileOptimizedHint,
boolean hasInsertionMarker, boolean isInsertionMarkerVisible,
float insertionMarkerHorizontal, float insertionMarkerTop,
@@ -2391,7 +2407,9 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
mViewportWidthPix / (deviceScale * pageScaleFactor));
contentHeight = Math.max(contentHeight,
mViewportHeightPix / (deviceScale * pageScaleFactor));
- final float contentOffsetYPix = mRenderCoordinates.fromDipToPix(contentOffsetYCss);
+ final float topBarShownPix = topControlsHeightDp * deviceScale * topControlsShownRatio;
+ final float bottomBarShownPix = bottomControlsHeightDp * deviceScale
+ * bottomControlsShownRatio;
final boolean contentSizeChanged =
contentWidth != mRenderCoordinates.getContentWidthCss()
@@ -2405,8 +2423,10 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
pageScaleChanged
|| scrollOffsetX != mRenderCoordinates.getScrollX()
|| scrollOffsetY != mRenderCoordinates.getScrollY();
- final boolean contentOffsetChanged =
- contentOffsetYPix != mRenderCoordinates.getContentOffsetYPix();
+ final boolean topBarChanged = topBarShownPix != mRenderCoordinates
+ .getTopControlsShownYPix();
+ final boolean bottomBarChanged = bottomBarShownPix != mRenderCoordinates
+ .getBottomControlsShownYPix();
final boolean needHidePopupZoomer = contentSizeChanged || scrollChanged;
final boolean needUpdateZoomControls = scaleLimitsChanged || scrollChanged;
@@ -2426,9 +2446,9 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
contentWidth, contentHeight,
viewportWidth, viewportHeight,
pageScaleFactor, minPageScaleFactor, maxPageScaleFactor,
- contentOffsetYPix);
+ topBarShownPix, bottomBarShownPix);
- if (scrollChanged || contentOffsetChanged) {
+ if (scrollChanged || topBarChanged) {
for (mGestureStateListenersIterator.rewind();
mGestureStateListenersIterator.hasNext();) {
mGestureStateListenersIterator.next().onScrollOffsetOrExtentChanged(
@@ -2439,11 +2459,14 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
if (needUpdateZoomControls) mZoomControlsDelegate.updateZoomControls();
- // Update offsets for fullscreen.
- final float controlsOffsetPix = controlsOffsetYCss * deviceScale;
- // TODO(aelias): Remove last argument after downstream removes it.
- getContentViewClient().onOffsetsForFullscreenChanged(
- controlsOffsetPix, contentOffsetYPix);
+ if (topBarChanged) {
+ float topBarTranslate = topBarShownPix - topControlsHeightDp * deviceScale;
+ getContentViewClient().onTopControlsChanged(topBarTranslate, topBarShownPix);
+ }
+ if (bottomBarChanged) {
+ float bottomBarTranslate = bottomControlsHeightDp * deviceScale - bottomBarShownPix;
+ getContentViewClient().onBottomControlsChanged(bottomBarTranslate, bottomBarShownPix);
+ }
if (mBrowserAccessibilityManager != null) {
mBrowserAccessibilityManager.notifyFrameInfoInitialized();
@@ -2654,11 +2677,11 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
}
if (!mHasInsertion || !canPaste()) return false;
- final float contentOffsetYPix = mRenderCoordinates.getContentOffsetYPix();
+ final float topControlsShown = mRenderCoordinates.getTopControlsShownYPix();
PastePopupMenu pastePopupMenu = getPastePopup();
if (pastePopupMenu == null) return false;
try {
- pastePopupMenu.show(x, (int) (y + contentOffsetYPix));
+ pastePopupMenu.show(x, (int) (y + topControlsShown));
} catch (WindowManager.BadTokenException e) {
return false;
}
@@ -3111,7 +3134,7 @@ public class ContentViewCore implements AccessibilityStateChangeListener, Screen
Rect boundsInParent = new Rect(left, top, left + width, top + height);
if (node.isRootNode) {
// Offset of the web content relative to the View.
- boundsInParent.offset(0, (int) mRenderCoordinates.getContentOffsetYPix());
+ boundsInParent.offset(0, (int) mRenderCoordinates.getTopControlsShownYPix());
if (!ignoreScrollOffset) {
boundsInParent.offset(-(int) mRenderCoordinates.getScrollXPix(),
-(int) mRenderCoordinates.getScrollYPix());

Powered by Google App Engine
This is Rietveld 408576698