Commit 94f2c19f authored by Donn Denman's avatar Donn Denman Committed by Commit Bot

[TTS][Overlay] Fix base-scroll during expansion.

Fixes the scrolling of the base page during the expansion of the panel.
There were several problems:
1) The SelectionPopupController was not returning the x,y value when
the selection handles are shown.
2) The Overlay panel was mixing dps and pixels in the offsetting
calculation.
3) The Contextual Search panel didn't know about the layout adjustment.
Now the selection should end up centered when the panel is expanded.

BUG=1012274,1011021

Change-Id: I16d69b8b2b4e14d9b3207d0f42ab0a8eb869b230
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1845790
Commit-Queue: Donn Denman <donnd@chromium.org>
Commit-Queue: Matthew Jones <mdjones@chromium.org>
Commit-Queue: Bo <boliu@chromium.org>
Auto-Submit: Donn Denman <donnd@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarBo <boliu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#703798}
parent b604a0cc
...@@ -361,6 +361,11 @@ abstract class OverlayPanelBase { ...@@ -361,6 +361,11 @@ abstract class OverlayPanelBase {
&& ChromeFeatureList.isEnabled(ChromeFeatureList.OVERLAY_NEW_LAYOUT); && ChromeFeatureList.isEnabled(ChromeFeatureList.OVERLAY_NEW_LAYOUT);
} }
/** @return The offset for the page content in DPs. */
protected float getLayoutOffsetYDps() {
return mLayoutYOffset * mPxToDp;
}
// ============================================================================================ // ============================================================================================
// UI States // UI States
// ============================================================================================ // ============================================================================================
...@@ -1109,7 +1114,7 @@ abstract class OverlayPanelBase { ...@@ -1109,7 +1114,7 @@ abstract class OverlayPanelBase {
* portion of the Base Page visible when a Panel is in expanded state. To facilitate the * portion of the Base Page visible when a Panel is in expanded state. To facilitate the
* calculation, the first argument contains the height of the Panel in the expanded state. * calculation, the first argument contains the height of the Panel in the expanded state.
* *
* @return The desired offset for the Base Page * @return The desired offset for the Base Page in DPs
*/ */
protected float calculateBasePageDesiredOffset() { protected float calculateBasePageDesiredOffset() {
return 0.f; return 0.f;
...@@ -1131,7 +1136,7 @@ abstract class OverlayPanelBase { ...@@ -1131,7 +1136,7 @@ abstract class OverlayPanelBase {
* consideration the Toolbar height, and adjust the offset accordingly, in order to * consideration the Toolbar height, and adjust the offset accordingly, in order to
* move the Toolbar out of the view as the Panel expands. * move the Toolbar out of the view as the Panel expands.
* *
* @return The target offset Y. * @return The target offset Y in DPs.
*/ */
private float calculateBasePageTargetY() { private float calculateBasePageTargetY() {
// Only a fullscreen wide Panel should offset the base page. A small panel should // Only a fullscreen wide Panel should offset the base page. A small panel should
...@@ -1140,7 +1145,7 @@ abstract class OverlayPanelBase { ...@@ -1140,7 +1145,7 @@ abstract class OverlayPanelBase {
// Start with the desired offset taking viewport offset into consideration and make sure // Start with the desired offset taking viewport offset into consideration and make sure
// the result is <= 0 so the page moves up and not down. // the result is <= 0 so the page moves up and not down.
float offset = Math.min(calculateBasePageDesiredOffset() - mLayoutYOffset, 0.0f); float offset = Math.min(calculateBasePageDesiredOffset() - getLayoutOffsetYDps(), 0.0f);
// Make sure the offset is not greater than the expanded height, because // Make sure the offset is not greater than the expanded height, because
// there's nothing to render below the Page. // there's nothing to render below the Page.
......
...@@ -789,6 +789,7 @@ public class ContextualSearchPanel extends OverlayPanel { ...@@ -789,6 +789,7 @@ public class ContextualSearchPanel extends OverlayPanel {
// Calculate the offset to center the selection on the available area. // Calculate the offset to center the selection on the available area.
final float availableHeight = getTabHeight() - getExpandedHeight(); final float availableHeight = getTabHeight() - getExpandedHeight();
offset = -selectionY + availableHeight / 2; offset = -selectionY + availableHeight / 2;
offset += getLayoutOffsetYDps();
} }
return offset; return offset;
} }
......
...@@ -1246,6 +1246,7 @@ public class SelectionPopupControllerImpl extends ActionModeCallbackHelper ...@@ -1246,6 +1246,7 @@ public class SelectionPopupControllerImpl extends ActionModeCallbackHelper
switch (eventType) { switch (eventType) {
case SelectionEventType.SELECTION_HANDLES_SHOWN: case SelectionEventType.SELECTION_HANDLES_SHOWN:
mSelectionRect.set(left, top, right, bottom);
break; break;
case SelectionEventType.SELECTION_HANDLES_MOVED: case SelectionEventType.SELECTION_HANDLES_MOVED:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment