Bug 882120 - Apply rounding to the layer-pixel rect in Java to fix robopan regression. r=kentuckyfriedtakahe

This commit is contained in:
Kartikaya Gupta 2013-06-18 09:27:45 -04:00
parent 00adf5a054
commit 79ecb8de2c
2 changed files with 12 additions and 1 deletions

View File

@ -560,10 +560,12 @@ public class GeckoLayerClient implements LayerView.Listener, PanZoomTarget
Tab tab = Tabs.getInstance().getSelectedTab();
RectF cssPageRect = new RectF(cssPageLeft, cssPageTop, cssPageRight, cssPageBottom);
RectF pageRect = RectUtils.scaleAndRound(cssPageRect, zoom);
final ImmutableViewportMetrics newMetrics = currentMetrics
.setViewportOrigin(offsetX, offsetY)
.setZoomFactor(zoom)
.setPageRect(RectUtils.scale(cssPageRect, zoom), cssPageRect)
.setPageRect(pageRect, cssPageRect)
.setIsRTL(tab.getIsRTL());
// Since we have switched to displaying a different document, we need to update any
// viewport-related state we have lying around. This includes mGeckoViewport and

View File

@ -74,6 +74,15 @@ public final class RectUtils {
y + (rect.height() * scale));
}
public static RectF scaleAndRound(RectF rect, float scale) {
float left = rect.left * scale;
float top = rect.top * scale;
return new RectF(Math.round(left),
Math.round(top),
Math.round(left + (rect.width() * scale)),
Math.round(top + (rect.height() * scale)));
}
/** Returns the nearest integer rect of the given rect. */
public static Rect round(RectF rect) {
Rect r = new Rect();