Bug 1197811 - Extract a wrapper for getting/setting the translation on the LayerView. r=rbarker

--HG--
extra : commitid : 4TUIGjEccG0
This commit is contained in:
Kartikaya Gupta 2015-08-28 17:22:17 -04:00
Родитель 26b988279e
Коммит 89a588ea02
5 изменённых файлов: 18 добавлений и 10 удалений

Просмотреть файл

@ -1247,7 +1247,7 @@ public class BrowserApp extends GeckoApp
ViewHelper.setTranslationY(mBrowserChrome, 0);
}
if (mLayerView != null) {
ViewHelper.setTranslationY(mLayerView, 0);
mLayerView.setSurfaceTranslation(0);
}
}
@ -1559,11 +1559,10 @@ public class BrowserApp extends GeckoApp
}
final View browserChrome = mBrowserChrome;
final View layerView = mLayerView;
final ToolbarProgressView progressView = mProgressView;
ViewHelper.setTranslationY(browserChrome, -aToolbarTranslation);
ViewHelper.setTranslationY(layerView, mToolbarHeight - aLayerViewTranslation);
mLayerView.setSurfaceTranslation(mToolbarHeight - aLayerViewTranslation);
// Stop the progressView from moving all the way up so that we can still see a good chunk of it
// when the chrome is offscreen.

Просмотреть файл

@ -289,7 +289,7 @@ public class FormAssistPopup extends RelativeLayout implements GeckoEventListene
// These values correspond to the input box for which we want to
// display the FormAssistPopup.
int left = (int) (mX * zoom - aMetrics.viewportRectLeft);
int top = (int) (mY * zoom - aMetrics.viewportRectTop + ViewHelper.getTranslationY(GeckoAppShell.getLayerView()));
int top = (int) (mY * zoom - aMetrics.viewportRectTop + GeckoAppShell.getLayerView().getSurfaceTranslation());
int width = (int) (mW * zoom);
int height = (int) (mH * zoom);

Просмотреть файл

@ -132,7 +132,7 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
// so subtracting that from newY puts newY into the desired coordinate
// space. We also need to include the offset amount of the touch location
// relative to the top left of the handle (mTouchStart).
float layerViewTranslation = ViewHelper.getTranslationY(GeckoAppShell.getLayerView());
float layerViewTranslation = GeckoAppShell.getLayerView().getSurfaceTranslation();
int[] layerViewPosition = new int[2];
GeckoAppShell.getLayerView().getLocationOnScreen(layerViewPosition);
float ancestorOrigin = layerViewPosition[1] - layerViewTranslation;
@ -191,7 +191,7 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
PointF viewPoint = new PointF((mGeckoPoint.x * zoom) - x,
(mGeckoPoint.y * zoom) - y);
mLeft = viewPoint.x - adjustLeftForHandle();
mTop = viewPoint.y + ViewHelper.getTranslationY(GeckoAppShell.getLayerView());
mTop = viewPoint.y + GeckoAppShell.getLayerView().getSurfaceTranslation();
setLayoutPosition();
}

Просмотреть файл

@ -334,7 +334,7 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
visibleContentPixels = viewHeight / zoomFactor;
maxContentOffset = parentHeight - visibleContentPixels;
maxZoomedViewOffset = parentHeight - (viewContainerHeight - toolbarHeight);
float zoomedAreaOffset = (float)params.topMargin + offsetDueToToolBarPosition - ViewHelper.getTranslationY(layerView);
float zoomedAreaOffset = (float)params.topMargin + offsetDueToToolBarPosition - layerView.getSurfaceTranslation();
zoomedContentOffset = zoomedAreaOffset * maxContentOffset / maxZoomedViewOffset;
returnValue.y = (int)(zoomedContentOffset + ((y - offsetDueToToolBarPosition) / zoomFactor));
@ -364,7 +364,7 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
maxContentOffset = parentHeight - visibleContentPixels;
maxZoomedViewOffset = parentHeight - (viewContainerHeight - toolbarHeight);
contentPixelOffset = y - (visibleContentPixels / 2.0f);
float unscaledViewOffset = ViewHelper.getTranslationY(layerView) - offsetDueToToolBarPosition;
float unscaledViewOffset = layerView.getSurfaceTranslation() - offsetDueToToolBarPosition;
returnValue.y = (int)((contentPixelOffset * (maxZoomedViewOffset / maxContentOffset)) + unscaledViewOffset);
return returnValue;
@ -375,7 +375,7 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
RelativeLayout.LayoutParams newLayoutParams = (RelativeLayout.LayoutParams) getLayoutParams();
newLayoutParams.leftMargin = (int) newLeftMargin;
newLayoutParams.topMargin = (int) newTopMargin;
int topMarginMin = (int)(ViewHelper.getTranslationY(layerView) + dynamicToolbarOverlap);
int topMarginMin = (int)(layerView.getSurfaceTranslation() + dynamicToolbarOverlap);
int topMarginMax = layerView.getHeight() - viewContainerHeight;
int leftMarginMin = 0;
int leftMarginMax = layerView.getWidth() - viewContainerWidth;
@ -550,7 +550,7 @@ public class ZoomedView extends FrameLayout implements LayerView.DynamicToolbarL
// Later, it will be converted relative to the zoomed view as soon as
// the position of the zoomed view will be calculated.
animationStart.x = (float) leftFromGecko * metrics.zoomFactor;
animationStart.y = (float) topFromGecko * metrics.zoomFactor + ViewHelper.getTranslationY(layerView);
animationStart.y = (float) topFromGecko * metrics.zoomFactor + layerView.getSurfaceTranslation();
moveUsingGeckoPosition(leftFromGecko, topFromGecko);
}

Просмотреть файл

@ -10,6 +10,7 @@ import java.nio.IntBuffer;
import java.util.ArrayList;
import org.mozilla.gecko.AndroidGamepadManager;
import org.mozilla.gecko.animation.ViewHelper;
import org.mozilla.gecko.annotation.RobocopTarget;
import org.mozilla.gecko.annotation.WrapForJNI;
import org.mozilla.gecko.AppConstants.Versions;
@ -657,6 +658,14 @@ public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener
return mFullScreenState;
}
public void setSurfaceTranslation(float translation) {
ViewHelper.setTranslationY(this, translation);
}
public float getSurfaceTranslation() {
return ViewHelper.getTranslationY(this);
}
@Override
public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
if (msg == Tabs.TabEvents.VIEWPORT_CHANGE && Tabs.getInstance().isSelectedTab(tab) && mLayerClient != null) {