mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-28 03:18:41 +00:00
Bug 781220 - Hide other GeckoLayerClient methods and expose them via the LayerView API. r=sriram
This commit is contained in:
parent
d643365be3
commit
192f94dbc6
@ -223,7 +223,7 @@ public class FormAssistPopup extends RelativeLayout implements GeckoEventListene
|
|||||||
int popupWidth = RelativeLayout.LayoutParams.FILL_PARENT;
|
int popupWidth = RelativeLayout.LayoutParams.FILL_PARENT;
|
||||||
int popupLeft = left < 0 ? 0 : left;
|
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,
|
// For autocomplete suggestions, if the input is smaller than the screen-width,
|
||||||
// shrink the popup's width. Otherwise, keep it as FILL_PARENT.
|
// shrink the popup's width. Otherwise, keep it as FILL_PARENT.
|
||||||
|
@ -2339,11 +2339,11 @@ class ScreenshotHandler implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void screenshotWholePage(int tabId) {
|
private void screenshotWholePage(int tabId) {
|
||||||
GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
|
LayerView layerView = GeckoApp.mAppContext.getLayerView();
|
||||||
if (layerClient == null) {
|
if (layerView == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ImmutableViewportMetrics viewport = layerClient.getViewportMetrics();
|
ImmutableViewportMetrics viewport = layerView.getViewportMetrics();
|
||||||
RectF pageRect = viewport.getCssPageRect();
|
RectF pageRect = viewport.getCssPageRect();
|
||||||
|
|
||||||
if (FloatUtils.fuzzyEquals(pageRect.width(), 0) || FloatUtils.fuzzyEquals(pageRect.height(), 0)) {
|
if (FloatUtils.fuzzyEquals(pageRect.width(), 0) || FloatUtils.fuzzyEquals(pageRect.height(), 0)) {
|
||||||
@ -2443,14 +2443,14 @@ class ScreenshotHandler implements Runnable {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
|
LayerView layerView = GeckoApp.mAppContext.getLayerView();
|
||||||
if (layerClient == null) {
|
if (layerView == null) {
|
||||||
// we could be in the midst of an activity tear-down and re-start, so guard
|
// 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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ImmutableViewportMetrics viewport = layerClient.getViewportMetrics();
|
ImmutableViewportMetrics viewport = layerView.getViewportMetrics();
|
||||||
if (RectUtils.fuzzyEquals(mPageRect, viewport.getCssPageRect())) {
|
if (RectUtils.fuzzyEquals(mPageRect, viewport.getCssPageRect())) {
|
||||||
// the page size hasn't changed, so our dirty rect is still valid and we can just
|
// the page size hasn't changed, so our dirty rect is still valid and we can just
|
||||||
// repaint that area
|
// repaint that area
|
||||||
|
@ -227,7 +227,7 @@ public class GeckoEvent {
|
|||||||
public void addMotionPoint(int index, int eventIndex, MotionEvent event) {
|
public void addMotionPoint(int index, int eventIndex, MotionEvent event) {
|
||||||
try {
|
try {
|
||||||
PointF geckoPoint = new PointF(event.getX(eventIndex), event.getY(eventIndex));
|
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));
|
mPoints[index] = new Point(Math.round(geckoPoint.x), Math.round(geckoPoint.y));
|
||||||
mPointIndicies[index] = event.getPointerId(eventIndex);
|
mPointIndicies[index] = event.getPointerId(eventIndex);
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
package org.mozilla.gecko;
|
package org.mozilla.gecko;
|
||||||
|
|
||||||
import org.mozilla.gecko.gfx.GeckoLayerClient;
|
import org.mozilla.gecko.gfx.LayerView;
|
||||||
import org.mozilla.gecko.util.GeckoEventResponder;
|
import org.mozilla.gecko.util.GeckoEventResponder;
|
||||||
|
|
||||||
import org.json.JSONArray;
|
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) {
|
public void show(String aTitle, String aText, PromptButton[] aButtons, PromptListItem[] aMenuList, boolean aMultipleSelection) {
|
||||||
final GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
|
final LayerView layerView = GeckoApp.mAppContext.getLayerView();
|
||||||
layerClient.post(new Runnable() {
|
layerView.post(new Runnable() {
|
||||||
public void run() {
|
public void run() {
|
||||||
// treat actions that show a dialog as if preventDefault by content to prevent panning
|
// treat actions that show a dialog as if preventDefault by content to prevent panning
|
||||||
layerClient.getPanZoomController().abortPanning();
|
layerView.abortPanning();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -4,8 +4,8 @@
|
|||||||
|
|
||||||
package org.mozilla.gecko;
|
package org.mozilla.gecko;
|
||||||
|
|
||||||
import org.mozilla.gecko.gfx.GeckoLayerClient;
|
|
||||||
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
|
import org.mozilla.gecko.gfx.ImmutableViewportMetrics;
|
||||||
|
import org.mozilla.gecko.gfx.LayerView;
|
||||||
|
|
||||||
import org.json.JSONObject;
|
import org.json.JSONObject;
|
||||||
|
|
||||||
@ -83,15 +83,15 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
|
|||||||
mLeft = mLeft + newX - mTouchStartX;
|
mLeft = mLeft + newX - mTouchStartX;
|
||||||
mTop = mTop + newY - mTouchStartY;
|
mTop = mTop + newY - mTouchStartY;
|
||||||
|
|
||||||
GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
|
LayerView layerView = GeckoApp.mAppContext.getLayerView();
|
||||||
if (layerClient == null) {
|
if (layerView == null) {
|
||||||
Log.e(LOGTAG, "Can't move selection because layerClient is null");
|
Log.e(LOGTAG, "Can't move selection because layerView is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Send x coordinate on the right side of the start handle, left side of the end handle.
|
// 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);
|
float left = (float) mLeft + (mHandleType.equals(HandleType.START) ? mWidth - mShadow : mShadow);
|
||||||
PointF geckoPoint = new PointF(left, (float) mTop);
|
PointF geckoPoint = new PointF(left, (float) mTop);
|
||||||
geckoPoint = layerClient.convertViewPointToLayerPoint(geckoPoint);
|
geckoPoint = layerView.convertViewPointToLayerPoint(geckoPoint);
|
||||||
|
|
||||||
JSONObject args = new JSONObject();
|
JSONObject args = new JSONObject();
|
||||||
try {
|
try {
|
||||||
@ -107,14 +107,14 @@ class TextSelectionHandle extends ImageView implements View.OnTouchListener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void positionFromGecko(int left, int top) {
|
void positionFromGecko(int left, int top) {
|
||||||
GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
|
LayerView layerView = GeckoApp.mAppContext.getLayerView();
|
||||||
if (layerClient == null) {
|
if (layerView == null) {
|
||||||
Log.e(LOGTAG, "Can't position handle because layerClient is null");
|
Log.e(LOGTAG, "Can't position handle because layerView is null");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
mGeckoPoint = new PointF((float) left, (float) top);
|
mGeckoPoint = new PointF((float) left, (float) top);
|
||||||
ImmutableViewportMetrics metrics = layerClient.getViewportMetrics();
|
ImmutableViewportMetrics metrics = layerView.getViewportMetrics();
|
||||||
repositionWithViewport(metrics.viewportRectLeft, metrics.viewportRectTop, metrics.zoomFactor);
|
repositionWithViewport(metrics.viewportRectLeft, metrics.viewportRectTop, metrics.zoomFactor);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -222,7 +222,7 @@ public class GeckoLayerClient
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public PanZoomController getPanZoomController() {
|
PanZoomController getPanZoomController() {
|
||||||
return mPanZoomController;
|
return mPanZoomController;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,6 +13,7 @@ import android.content.Context;
|
|||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.PixelFormat;
|
import android.graphics.PixelFormat;
|
||||||
|
import android.graphics.PointF;
|
||||||
import android.graphics.SurfaceTexture;
|
import android.graphics.SurfaceTexture;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
import android.util.AttributeSet;
|
import android.util.AttributeSet;
|
||||||
@ -129,6 +130,18 @@ public class LayerView extends FrameLayout {
|
|||||||
public GeckoLayerClient getLayerClient() { return mLayerClient; }
|
public GeckoLayerClient getLayerClient() { return mLayerClient; }
|
||||||
public TouchEventHandler getTouchEventHandler() { return mTouchEventHandler; }
|
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. */
|
/** The LayerRenderer calls this to indicate that the window has changed size. */
|
||||||
public void setViewportSize(IntSize size) {
|
public void setViewportSize(IntSize size) {
|
||||||
mLayerClient.setViewportSize(new FloatSize(size));
|
mLayerClient.setViewportSize(new FloatSize(size));
|
||||||
|
Loading…
Reference in New Issue
Block a user