Bug 769269 - Update a bunch of fields in GeckoApp to not be static any more. r=mfinkle

This commit is contained in:
Kartikaya Gupta 2012-07-13 10:17:03 -04:00
Родитель 54fa406bbb
Коммит 6084aabef4
11 изменённых файлов: 64 добавлений и 17 удалений

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

@ -168,7 +168,7 @@ public class DoorHanger extends LinearLayout implements Button.OnClickListener {
// This method checks with persistence and timeout options to see if
// it's okay to remove a doorhanger.
public boolean shouldRemove() {
if (mPersistWhileVisible && GeckoApp.mDoorHangerPopup.isShowing()) {
if (mPersistWhileVisible && GeckoApp.mAppContext.mDoorHangerPopup.isShowing()) {
// We still want to decrement mPersistence, even if the popup is showing
if (mPersistence != 0)
mPersistence--;

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

@ -75,6 +75,12 @@ public class FormAssistPopup extends RelativeLayout implements GeckoEventListene
GeckoAppShell.registerGeckoEventListener("FormAssist:Hide", this);
}
void destroy() {
GeckoAppShell.unregisterGeckoEventListener("FormAssist:AutoComplete", this);
GeckoAppShell.unregisterGeckoEventListener("FormAssist:ValidationMessage", this);
GeckoAppShell.unregisterGeckoEventListener("FormAssist:Hide", this);
}
public void handleMessage(String event, JSONObject message) {
try {
if (event.equals("FormAssist:AutoComplete")) {

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

@ -82,9 +82,9 @@ abstract public class GeckoApp
protected LinearLayout mMainLayout;
protected RelativeLayout mGeckoLayout;
public View getView() { return mGeckoLayout; }
public static SurfaceView cameraView;
public SurfaceView cameraView;
public static GeckoApp mAppContext;
public static boolean mDOMFullScreen = false;
public boolean mDOMFullScreen = false;
protected MenuPanel mMenuPanel;
protected Menu mMenu;
private static GeckoThread sGeckoThread;
@ -97,15 +97,15 @@ abstract public class GeckoApp
private GeckoBatteryManager mBatteryReceiver;
private PromptService mPromptService;
public static DoorHangerPopup mDoorHangerPopup;
public static FormAssistPopup mFormAssistPopup;
public DoorHangerPopup mDoorHangerPopup;
public FormAssistPopup mFormAssistPopup;
public TabsPanel mTabsPanel;
public Favicons mFavicons;
private static LayerController mLayerController;
private static GeckoLayerClient mLayerClient;
private static AbsoluteLayout mPluginContainer;
private static FindInPageBar mFindInPageBar;
private LayerController mLayerController;
private GeckoLayerClient mLayerClient;
private AbsoluteLayout mPluginContainer;
private FindInPageBar mFindInPageBar;
private FullScreenHolder mFullScreenPluginContainer;
private View mFullScreenPluginView;
@ -2325,6 +2325,15 @@ abstract public class GeckoApp
deleteTempFiles();
if (mLayerController != null)
mLayerController.destroy();
if (mLayerClient != null)
mLayerClient.destroy();
if (mFormAssistPopup != null)
mFormAssistPopup.destroy();
if (mPromptService != null)
mPromptService.destroy();
if (mFavicons != null)
mFavicons.close();
@ -2886,8 +2895,6 @@ abstract public class GeckoApp
moveTaskToBack(true);
}
static int kCaptureIndex = 0;
public interface ActivityResultHandler {
public void onActivityResult(int resultCode, Intent data);
}

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

@ -1845,7 +1845,7 @@ public class GeckoAppShell
}
try {
sCamera.setPreviewDisplay(GeckoApp.cameraView.getHolder());
sCamera.setPreviewDisplay(GeckoApp.mAppContext.cameraView.getHolder());
} catch(IOException e) {
Log.e(LOGTAG, "Error setPreviewDisplay:", e);
} catch(RuntimeException e) {
@ -2346,7 +2346,12 @@ class ScreenshotHandler {
Tab tab = Tabs.getInstance().getSelectedTab();
ImmutableViewportMetrics viewport = GeckoApp.mAppContext.getLayerController().getViewportMetrics();
if (tab == null)
return;
LayerController layerController = GeckoApp.mAppContext.getLayerController();
if (layerController == null)
return;
ImmutableViewportMetrics viewport = layerController.getViewportMetrics();
if (RectUtils.fuzzyEquals(sCheckerboardPageRect, viewport.getCssPageRect())) {
float width = right - left;

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

@ -85,6 +85,10 @@ public class PromptService implements OnClickListener, OnCancelListener, OnItemC
GeckoAppShell.registerGeckoEventListener("Prompt:Show", this);
}
void destroy() {
GeckoAppShell.unregisterGeckoEventListener("Prompt:Show", this);
}
private class PromptButton {
public String label = "";
PromptButton(JSONObject aJSONButton) {

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

@ -101,7 +101,7 @@ public class Tabs implements GeckoEventListener {
selectedTab = tab;
GeckoApp.mAppContext.mMainHandler.post(new Runnable() {
public void run() {
GeckoApp.mFormAssistPopup.hide();
GeckoApp.mAppContext.mFormAssistPopup.hide();
if (isSelectedTab(tab)) {
String url = tab.getURL();
notifyListeners(tab, TabEvents.SELECTED);

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

@ -106,6 +106,14 @@ public class GeckoLayerClient implements GeckoEventResponder,
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent("Preferences:Get", prefs.toString()));
}
public void destroy() {
GeckoAppShell.unregisterGeckoEventListener("Viewport:Update", this);
GeckoAppShell.unregisterGeckoEventListener("Viewport:PageSize", this);
GeckoAppShell.unregisterGeckoEventListener("Viewport:CalculateDisplayPort", this);
GeckoAppShell.unregisterGeckoEventListener("Checkerboard:Toggle", this);
GeckoAppShell.unregisterGeckoEventListener("Preferences:Data", this);
}
DisplayPortMetrics getDisplayPort() {
return mDisplayPort;
}

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

@ -82,6 +82,10 @@ public class LayerController {
layerClient.setLayerController(this);
}
public void destroy() {
mPanZoomController.destroy();
}
public void setForceRedraw() {
mForceRedraw = true;
}

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

@ -84,8 +84,8 @@ public class LayerView extends SurfaceView implements SurfaceHolder.Callback {
requestFocus();
/** We need to manually hide FormAssistPopup because it is not a regular PopupWindow. */
if (GeckoApp.mFormAssistPopup != null)
GeckoApp.mFormAssistPopup.hide();
if (GeckoApp.mAppContext != null && GeckoApp.mAppContext.mFormAssistPopup != null)
GeckoApp.mAppContext.mFormAssistPopup.hide();
return mTouchEventHandler.handleEvent(event);
}

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

@ -142,6 +142,13 @@ public class PanZoomController
GeckoAppShell.sendEventToGecko(GeckoEvent.createBroadcastEvent(MESSAGE_PREFS_GET, prefs.toString()));
}
public void destroy() {
GeckoAppShell.unregisterGeckoEventListener(MESSAGE_ZOOM_RECT, this);
GeckoAppShell.unregisterGeckoEventListener(MESSAGE_ZOOM_PAGE, this);
GeckoAppShell.unregisterGeckoEventListener(MESSAGE_PREFS_DATA, this);
mSubscroller.destroy();
}
// for debugging bug 713011; it can be taken out once that is resolved.
private void checkMainThread() {
if (mMainThread != Thread.currentThread()) {
@ -868,7 +875,7 @@ public class PanZoomController
@Override
public boolean onScale(SimpleScaleGestureDetector detector) {
if (GeckoApp.mDOMFullScreen)
if (GeckoApp.mAppContext == null || GeckoApp.mAppContext.mDOMFullScreen)
return false;
if (mState != PanZoomState.PINCHING)

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

@ -56,6 +56,12 @@ class SubdocumentScrollHelper implements GeckoEventListener {
GeckoAppShell.registerGeckoEventListener(MESSAGE_SCROLL_ACK, this);
}
void destroy() {
GeckoAppShell.unregisterGeckoEventListener(MESSAGE_PANNING_OVERRIDE, this);
GeckoAppShell.unregisterGeckoEventListener(MESSAGE_CANCEL_OVERRIDE, this);
GeckoAppShell.unregisterGeckoEventListener(MESSAGE_SCROLL_ACK, this);
}
boolean scrollBy(PointF displacement) {
if (! mOverridePanning) {
return false;