Bug 932690 - Move viewport message management into tabs. r=kats

This commit is contained in:
Wes Johnston 2013-11-04 08:56:29 -08:00
Родитель a24d5e7884
Коммит 0568c0b878
3 изменённых файлов: 19 добавлений и 16 удалений

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

@ -583,19 +583,6 @@ abstract public class GeckoApp
String host = message.getString("host");
JSONArray permissions = message.getJSONArray("permissions");
showSiteSettingsDialog(host, permissions);
} else if (event.equals("Tab:ViewportMetadata")) {
int tabId = message.getInt("tabID");
Tab tab = Tabs.getInstance().getTab(tabId);
if (tab == null)
return;
tab.setZoomConstraints(new ZoomConstraints(message));
tab.setIsRTL(message.getBoolean("isRTL"));
// Sync up the layer view and the tab if the tab is currently displayed.
LayerView layerView = mLayerView;
if (layerView != null && Tabs.getInstance().isSelectedTab(tab)) {
layerView.setZoomConstraints(tab.getZoomConstraints());
layerView.setIsRTL(tab.getIsRTL());
}
} else if (event.equals("Session:StatePurged")) {
onStatePurged();
} else if (event.equals("Bookmark:Insert")) {
@ -1487,7 +1474,6 @@ abstract public class GeckoApp
registerEventListener("ToggleChrome:Show");
registerEventListener("ToggleChrome:Focus");
registerEventListener("Permissions:Data");
registerEventListener("Tab:ViewportMetadata");
registerEventListener("Session:StatePurged");
registerEventListener("Bookmark:Insert");
registerEventListener("Accessibility:Event");

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

@ -101,6 +101,7 @@ public class Tabs implements GeckoEventListener {
registerEventListener("Link:Favicon");
registerEventListener("Link:Feed");
registerEventListener("DesktopMode:Changed");
registerEventListener("Tab:ViewportMetadata");
}
public synchronized void attachToContext(Context context) {
@ -466,6 +467,10 @@ public class Tabs implements GeckoEventListener {
} else if (event.equals("DesktopMode:Changed")) {
tab.setDesktopMode(message.getBoolean("desktopMode"));
notifyListeners(tab, TabEvents.DESKTOP_MODE_CHANGE);
} else if (event.equals("Tab:ViewportMetadata")) {
tab.setZoomConstraints(new ZoomConstraints(message));
tab.setIsRTL(message.getBoolean("isRTL"));
notifyListeners(tab, TabEvents.VIEWPORT_CHANGE);
}
} catch (Exception e) {
Log.w(LOGTAG, "handleMessage threw for " + event, e);
@ -519,7 +524,8 @@ public class Tabs implements GeckoEventListener {
LINK_FEED,
SECURITY_CHANGE,
READER_ENABLED,
DESKTOP_MODE_CHANGE
DESKTOP_MODE_CHANGE,
VIEWPORT_CHANGE
}
public void notifyListeners(Tab tab, TabEvents msg) {

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

@ -10,6 +10,8 @@ import org.mozilla.gecko.GeckoAppShell;
import org.mozilla.gecko.GeckoEvent;
import org.mozilla.gecko.PrefsHelper;
import org.mozilla.gecko.R;
import org.mozilla.gecko.Tab;
import org.mozilla.gecko.Tabs;
import org.mozilla.gecko.TouchEventInterceptor;
import org.mozilla.gecko.ZoomConstraints;
import org.mozilla.gecko.mozglue.GeneratableAndroidBridgeTarget;
@ -49,7 +51,7 @@ import java.util.ArrayList;
*
* Note that LayerView is accessed by Robocop via reflection.
*/
public class LayerView extends FrameLayout {
public class LayerView extends FrameLayout implements Tabs.OnTabsChangedListener {
private static String LOGTAG = "GeckoLayerView";
private GeckoLayerClient mLayerClient;
@ -109,6 +111,7 @@ public class LayerView extends FrameLayout {
mTouchInterceptors = new ArrayList<TouchEventInterceptor>();
mOverscroll = new Overscroll(this);
Tabs.registerOnTabsChangedListener(this);
}
public void initializeView(EventDispatcher eventDispatcher) {
@ -658,4 +661,12 @@ public class LayerView extends FrameLayout {
public boolean isFullScreen() {
return mFullScreen;
}
@Override
public void onTabChanged(Tab tab, Tabs.TabEvents msg, Object data) {
if (msg == Tabs.TabEvents.VIEWPORT_CHANGE && Tabs.getInstance().isSelectedTab(tab)) {
setZoomConstraints(tab.getZoomConstraints());
setIsRTL(tab.getIsRTL());
}
}
}