From cbfc94010034cd82b63d3909b6a77ee1b7188f46 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Wed, 7 Nov 2012 11:47:08 -0500 Subject: [PATCH] Bug 809199 - Update the getDisplayPort JNI-called function to take an ImmutableViewportMetrics. r=Cwiiis --- mobile/android/base/gfx/GeckoLayerClient.java | 11 +++++------ widget/android/AndroidJavaWrappers.cpp | 4 ++-- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/mobile/android/base/gfx/GeckoLayerClient.java b/mobile/android/base/gfx/GeckoLayerClient.java index fa14d1b52d2..200bf6d1b36 100644 --- a/mobile/android/base/gfx/GeckoLayerClient.java +++ b/mobile/android/base/gfx/GeckoLayerClient.java @@ -306,7 +306,7 @@ public class GeckoLayerClient } /** Viewport message handler. */ - private DisplayPortMetrics handleViewportMessage(ViewportMetrics messageMetrics, ViewportMessageType type) { + private DisplayPortMetrics handleViewportMessage(ImmutableViewportMetrics messageMetrics, ViewportMessageType type) { synchronized (this) { ViewportMetrics metrics; ImmutableViewportMetrics oldMetrics = getViewportMetrics(); @@ -314,7 +314,7 @@ public class GeckoLayerClient switch (type) { default: case UPDATE: - metrics = messageMetrics; + metrics = new ViewportMetrics(messageMetrics); // Keep the old viewport size metrics.setSize(oldMetrics.getSize()); abortPanZoomAnimation(); @@ -323,7 +323,7 @@ public class GeckoLayerClient // adjust the page dimensions to account for differences in zoom // between the rendered content (which is what Gecko tells us) // and our zoom level (which may have diverged). - float scaleFactor = oldMetrics.zoomFactor / messageMetrics.getZoomFactor(); + float scaleFactor = oldMetrics.zoomFactor / messageMetrics.zoomFactor; metrics = new ViewportMetrics(oldMetrics); metrics.setPageRect(RectUtils.scale(messageMetrics.getPageRect(), scaleFactor), messageMetrics.getCssPageRect()); break; @@ -341,7 +341,7 @@ public class GeckoLayerClient return mDisplayPort; } - public DisplayPortMetrics getDisplayPort(boolean pageSizeUpdate, boolean isBrowserContentDisplayed, int tabId, ViewportMetrics metrics) { + public DisplayPortMetrics getDisplayPort(boolean pageSizeUpdate, boolean isBrowserContentDisplayed, int tabId, ImmutableViewportMetrics metrics) { Tabs tabs = Tabs.getInstance(); if (tabs.isSelectedTab(tabs.getTab(tabId)) && isBrowserContentDisplayed) { // for foreground tabs, send the viewport update unless the document @@ -353,8 +353,7 @@ public class GeckoLayerClient // when we do switch to that tab, we have the correct display port and // don't need to draw twice (once to allow the first-paint viewport to // get to java, and again once java figures out the display port). - ImmutableViewportMetrics newMetrics = new ImmutableViewportMetrics(metrics); - return DisplayPortCalculator.calculate(newMetrics, null); + return DisplayPortCalculator.calculate(metrics, null); } } diff --git a/widget/android/AndroidJavaWrappers.cpp b/widget/android/AndroidJavaWrappers.cpp index e5924deb718..7b9ac058abd 100644 --- a/widget/android/AndroidJavaWrappers.cpp +++ b/widget/android/AndroidJavaWrappers.cpp @@ -355,9 +355,9 @@ AndroidGeckoLayerClient::InitGeckoLayerClientClass(JNIEnv *jEnv) jCreateFrameMethod = getMethod("createFrame", "()Lorg/mozilla/gecko/gfx/LayerRenderer$Frame;"); jActivateProgramMethod = getMethod("activateProgram", "()V"); jDeactivateProgramMethod = getMethod("deactivateProgram", "()V"); - jGetDisplayPort = getMethod("getDisplayPort", "(ZZILorg/mozilla/gecko/gfx/ViewportMetrics;)Lorg/mozilla/gecko/gfx/DisplayPortMetrics;"); + jGetDisplayPort = getMethod("getDisplayPort", "(ZZILorg/mozilla/gecko/gfx/ImmutableViewportMetrics;)Lorg/mozilla/gecko/gfx/DisplayPortMetrics;"); - jViewportClass = GetClassGlobalRef(jEnv, "org/mozilla/gecko/gfx/ViewportMetrics"); + jViewportClass = GetClassGlobalRef(jEnv, "org/mozilla/gecko/gfx/ImmutableViewportMetrics"); jViewportCtor = GetMethodID(jEnv, jViewportClass, "", "(FFFFFFFFFFFFF)V"); jDisplayportClass = GetClassGlobalRef(jEnv, "org/mozilla/gecko/gfx/DisplayPortMetrics");