Bug 781220 - Expose a getLayerView function from GeckoApp and use it instead of going through the layer client in a few places. r=sriram

This commit is contained in:
Kartikaya Gupta 2012-08-20 15:43:53 -04:00
parent f370fb6d42
commit f82d267807
5 changed files with 21 additions and 23 deletions

View File

@ -2541,6 +2541,10 @@ abstract public class GeckoApp
/* This method is referenced by Robocop via reflection. */
public GeckoLayerClient getLayerClient() { return mLayerClient; }
public LayerView getLayerView() {
return mLayerView;
}
public AbsoluteLayout getPluginContainer() { return mPluginContainer; }
// accelerometer

View File

@ -535,11 +535,9 @@ public class GeckoAppShell
// Called on the UI thread after Gecko loads.
private static void geckoLoaded() {
final GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
LayerView v = layerClient.getView();
LayerView v = GeckoApp.mAppContext.getLayerView();
mInputConnection = GeckoInputConnection.create(v);
v.setInputConnectionHandler(mInputConnection);
layerClient.setForceRedraw();
}
static void sendPendingEventsToGecko() {
@ -1421,8 +1419,7 @@ public class GeckoAppShell
// Don't perform haptic feedback if a vibration is currently playing,
// because the haptic feedback will nuke the vibration.
if (!sVibrationMaybePlaying || System.nanoTime() >= sVibrationEndTime) {
GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
LayerView layerView = layerClient.getView();
LayerView layerView = GeckoApp.mAppContext.getLayerView();
layerView.performHapticFeedback(aIsLongPress ?
HapticFeedbackConstants.LONG_PRESS :
HapticFeedbackConstants.VIRTUAL_KEY);
@ -1430,9 +1427,7 @@ public class GeckoAppShell
}
private static Vibrator vibrator() {
GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
LayerView layerView = layerClient.getView();
LayerView layerView = GeckoApp.mAppContext.getLayerView();
return (Vibrator) layerView.getContext().getSystemService(Context.VIBRATOR_SERVICE);
}
@ -1479,7 +1474,7 @@ public class GeckoAppShell
public static void notifyDefaultPrevented(final boolean defaultPrevented) {
getMainHandler().post(new Runnable() {
public void run() {
LayerView view = GeckoApp.mAppContext.getLayerClient().getView();
LayerView view = GeckoApp.mAppContext.getLayerView();
view.getTouchEventHandler().handleEventListenerAction(!defaultPrevented);
}
});
@ -2535,9 +2530,9 @@ class ScreenshotHandler implements Runnable {
// this screenshot has all its slices done, so push it out
// to the layer renderer and remove it from the list
}
GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
if (layerClient != null) {
layerClient.getView().getRenderer().setCheckerboardBitmap(
LayerView layerView = GeckoApp.mAppContext.getLayerView();
if (layerView != null) {
layerView.getRenderer().setCheckerboardBitmap(
data, bufferWidth, bufferHeight, handler.mPageRect,
current.getPaintedRegion());
}

View File

@ -5,7 +5,6 @@
package org.mozilla.gecko;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.InputConnectionHandler;
import android.R;
@ -276,8 +275,7 @@ class GeckoInputConnection
}
private static View getView() {
GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
return (layerClient == null ? null : layerClient.getView());
return GeckoApp.mAppContext.getLayerView();
}
private Span getSelection() {

View File

@ -4,9 +4,9 @@
package org.mozilla.gecko;
import org.mozilla.gecko.gfx.GeckoLayerClient;
import org.mozilla.gecko.gfx.Layer;
import org.mozilla.gecko.gfx.Layer.RenderContext;
import org.mozilla.gecko.gfx.LayerView;
import org.mozilla.gecko.util.EventDispatcher;
import org.mozilla.gecko.util.FloatUtils;
import org.mozilla.gecko.util.GeckoEventListener;
@ -60,18 +60,18 @@ class TextSelection extends Layer implements GeckoEventListener {
mViewLeft = 0.0f;
mViewTop = 0.0f;
mViewZoom = 0.0f;
GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
if (layerClient != null) {
layerClient.getView().addLayer(TextSelection.this);
LayerView layerView = GeckoApp.mAppContext.getLayerView();
if (layerView != null) {
layerView.addLayer(TextSelection.this);
}
}
});
} else if (event.equals("TextSelection:HideHandles")) {
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {
GeckoLayerClient layerClient = GeckoApp.mAppContext.getLayerClient();
if (layerClient != null) {
layerClient.getView().removeLayer(TextSelection.this);
LayerView layerView = GeckoApp.mAppContext.getLayerView();
if (layerView != null) {
layerView.removeLayer(TextSelection.this);
}
mStartHandle.setVisibility(View.GONE);

View File

@ -136,6 +136,7 @@ public class LayerView extends FrameLayout {
public void setInputConnectionHandler(InputConnectionHandler inputConnectionHandler) {
mInputConnectionHandler = inputConnectionHandler;
mLayerClient.setForceRedraw();
}
@Override
@ -281,7 +282,7 @@ public class LayerView extends FrameLayout {
/** This function is invoked by Gecko (compositor thread) via JNI; be careful when modifying signature. */
public static GLController registerCxxCompositor() {
try {
LayerView layerView = GeckoApp.mAppContext.getLayerClient().getView();
LayerView layerView = GeckoApp.mAppContext.getLayerView();
layerView.mListener.compositorCreated();
return layerView.getGLController();
} catch (Exception e) {