From 192f94dbc666e6898e0c779a6d40f28f0d7bb3e7 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Mon, 20 Aug 2012 15:43:53 -0400 Subject: [PATCH] Bug 781220 - Hide other GeckoLayerClient methods and expose them via the LayerView API. r=sriram --- mobile/android/base/FormAssistPopup.java | 2 +- mobile/android/base/GeckoAppShell.java | 14 +++++++------- mobile/android/base/GeckoEvent.java | 2 +- mobile/android/base/PromptService.java | 8 ++++---- mobile/android/base/TextSelectionHandle.java | 18 +++++++++--------- mobile/android/base/gfx/GeckoLayerClient.java | 2 +- mobile/android/base/gfx/LayerView.java | 13 +++++++++++++ 7 files changed, 36 insertions(+), 23 deletions(-) diff --git a/mobile/android/base/FormAssistPopup.java b/mobile/android/base/FormAssistPopup.java index 9bd878403063..adb5b9cf28d5 100644 --- a/mobile/android/base/FormAssistPopup.java +++ b/mobile/android/base/FormAssistPopup.java @@ -223,7 +223,7 @@ public class FormAssistPopup extends RelativeLayout implements GeckoEventListene int popupWidth = RelativeLayout.LayoutParams.FILL_PARENT; int popupLeft = left < 0 ? 0 : left; - FloatSize viewport = GeckoApp.mAppContext.getLayerClient().getViewportSize(); + FloatSize viewport = GeckoApp.mAppContext.getLayerView().getViewportMetrics().getSize(); // For autocomplete suggestions, if the input is smaller than the screen-width, // shrink the popup's width. Otherwise, keep it as FILL_PARENT. diff --git a/mobile/android/base/GeckoAppShell.java b/mobile/android/base/GeckoAppShell.java index f351b815ac89..4ef8c2764f5f 100644 --- a/mobile/android/base/GeckoAppShell.java +++ b/mobile/android/base/GeckoAppShell.java @@ -2339,11 +2339,11 @@ class ScreenshotHandler implements Runnable { } private void screenshotWholePage(int tabId) { - GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient(); - if (layerClient == null) { + LayerView layerView = GeckoApp.mAppContext.getLayerView(); + if (layerView == null) { return; } - ImmutableViewportMetrics viewport = layerClient.getViewportMetrics(); + ImmutableViewportMetrics viewport = layerView.getViewportMetrics(); RectF pageRect = viewport.getCssPageRect(); if (FloatUtils.fuzzyEquals(pageRect.width(), 0) || FloatUtils.fuzzyEquals(pageRect.height(), 0)) { @@ -2443,14 +2443,14 @@ class ScreenshotHandler implements Runnable { return; } - GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient(); - if (layerClient == null) { + LayerView layerView = GeckoApp.mAppContext.getLayerView(); + if (layerView == null) { // we could be in the midst of an activity tear-down and re-start, so guard - // against a null layer controller. + // against a null layer view return; } - ImmutableViewportMetrics viewport = layerClient.getViewportMetrics(); + ImmutableViewportMetrics viewport = layerView.getViewportMetrics(); if (RectUtils.fuzzyEquals(mPageRect, viewport.getCssPageRect())) { // the page size hasn't changed, so our dirty rect is still valid and we can just // repaint that area diff --git a/mobile/android/base/GeckoEvent.java b/mobile/android/base/GeckoEvent.java index 4e5f2ae6e659..07a5cbd58da5 100644 --- a/mobile/android/base/GeckoEvent.java +++ b/mobile/android/base/GeckoEvent.java @@ -227,7 +227,7 @@ public class GeckoEvent { public void addMotionPoint(int index, int eventIndex, MotionEvent event) { try { PointF geckoPoint = new PointF(event.getX(eventIndex), event.getY(eventIndex)); - geckoPoint = GeckoApp.mAppContext.getLayerClient().convertViewPointToLayerPoint(geckoPoint); + geckoPoint = GeckoApp.mAppContext.getLayerView().convertViewPointToLayerPoint(geckoPoint); mPoints[index] = new Point(Math.round(geckoPoint.x), Math.round(geckoPoint.y)); mPointIndicies[index] = event.getPointerId(eventIndex); diff --git a/mobile/android/base/PromptService.java b/mobile/android/base/PromptService.java index 9aeb8d501ba0..886193ab5222 100644 --- a/mobile/android/base/PromptService.java +++ b/mobile/android/base/PromptService.java @@ -5,7 +5,7 @@ package org.mozilla.gecko; -import org.mozilla.gecko.gfx.GeckoLayerClient; +import org.mozilla.gecko.gfx.LayerView; import org.mozilla.gecko.util.GeckoEventResponder; import org.json.JSONArray; @@ -182,11 +182,11 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC } public void show(String aTitle, String aText, PromptButton[] aButtons, PromptListItem[] aMenuList, boolean aMultipleSelection) { - final GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient(); - layerClient.post(new Runnable() { + final LayerView layerView = GeckoApp.mAppContext.getLayerView(); + layerView.post(new Runnable() { public void run() { // treat actions that show a dialog as if preventDefault by content to prevent panning - layerClient.getPanZoomController().abortPanning(); + layerView.abortPanning(); } }); diff --git a/mobile/android/base/TextSelectionHandle.java b/mobile/android/base/TextSelectionHandle.java index f66435caa085..ba5fbfe7fe88 100644 --- a/mobile/android/base/TextSelectionHandle.java +++ b/mobile/android/base/TextSelectionHandle.java @@ -4,8 +4,8 @@ package org.mozilla.gecko; -import org.mozilla.gecko.gfx.GeckoLayerClient; import org.mozilla.gecko.gfx.ImmutableViewportMetrics; +import org.mozilla.gecko.gfx.LayerView; import org.json.JSONObject; @@ -83,15 +83,15 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener { mLeft = mLeft + newX - mTouchStartX; mTop = mTop + newY - mTouchStartY; - GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient(); - if (layerClient == null) { - Log.e(LOGTAG, "Can't move selection because layerClient is null"); + LayerView layerView = GeckoApp.mAppContext.getLayerView(); + if (layerView == null) { + Log.e(LOGTAG, "Can't move selection because layerView is null"); return; } // Send x coordinate on the right side of the start handle, left side of the end handle. float left = (float) mLeft + (mHandleType.equals(HandleType.START) ? mWidth - mShadow : mShadow); PointF geckoPoint = new PointF(left, (float) mTop); - geckoPoint = layerClient.convertViewPointToLayerPoint(geckoPoint); + geckoPoint = layerView.convertViewPointToLayerPoint(geckoPoint); JSONObject args = new JSONObject(); try { @@ -107,14 +107,14 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener { } void positionFromGecko(int left, int top) { - GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient(); - if (layerClient == null) { - Log.e(LOGTAG, "Can't position handle because layerClient is null"); + LayerView layerView = GeckoApp.mAppContext.getLayerView(); + if (layerView == null) { + Log.e(LOGTAG, "Can't position handle because layerView is null"); return; } mGeckoPoint = new PointF((float) left, (float) top); - ImmutableViewportMetrics metrics = layerClient.getViewportMetrics(); + ImmutableViewportMetrics metrics = layerView.getViewportMetrics(); repositionWithViewport(metrics.viewportRectLeft, metrics.viewportRectTop, metrics.zoomFactor); } diff --git a/mobile/android/base/gfx/GeckoLayerClient.java b/mobile/android/base/gfx/GeckoLayerClient.java index b2a9be461c64..663442db2b04 100644 --- a/mobile/android/base/gfx/GeckoLayerClient.java +++ b/mobile/android/base/gfx/GeckoLayerClient.java @@ -222,7 +222,7 @@ public class GeckoLayerClient } } - public PanZoomController getPanZoomController() { + PanZoomController getPanZoomController() { return mPanZoomController; } diff --git a/mobile/android/base/gfx/LayerView.java b/mobile/android/base/gfx/LayerView.java index b4eee13d235b..1518433b4ae8 100644 --- a/mobile/android/base/gfx/LayerView.java +++ b/mobile/android/base/gfx/LayerView.java @@ -13,6 +13,7 @@ import android.content.Context; import android.graphics.Bitmap; import android.graphics.BitmapFactory; import android.graphics.PixelFormat; +import android.graphics.PointF; import android.graphics.SurfaceTexture; import android.os.Build; import android.util.AttributeSet; @@ -129,6 +130,18 @@ public class LayerView extends FrameLayout { public GeckoLayerClient getLayerClient() { return mLayerClient; } public TouchEventHandler getTouchEventHandler() { return mTouchEventHandler; } + public ImmutableViewportMetrics getViewportMetrics() { + return mLayerClient.getViewportMetrics(); + } + + public void abortPanning() { + mLayerClient.getPanZoomController().abortPanning(); + } + + public PointF convertViewPointToLayerPoint(PointF viewPoint) { + return mLayerClient.convertViewPointToLayerPoint(viewPoint); + } + /** The LayerRenderer calls this to indicate that the window has changed size. */ public void setViewportSize(IntSize size) { mLayerClient.setViewportSize(new FloatSize(size));