Bug 707285 - Disallow browser.js from overriding viewport size [r=pcwalton]

Don't allow Gecko to set the viewport size because Java knows
this better. Allowing this behaviour could result in Bad Things(TM)
under certain race conditions such as described in bug 707285.
This commit is contained in:
Kartikaya Gupta 2011-12-03 10:56:39 -05:00
parent b6bb536da1
commit e569e9ae37

View File

@ -130,7 +130,14 @@ public class GeckoSoftwareLayerClient extends LayerClient implements GeckoEventL
private void updateViewport(String viewportDescription, final boolean onlyUpdatePageSize) {
try {
JSONObject viewportObject = new JSONObject(viewportDescription);
// save and restore the viewport size stored in java; never let the
// JS-side viewport dimensions override the java-side ones because
// java is the One True Source of this information, and allowing JS
// to override can lead to race conditions where this data gets clobbered.
FloatSize viewportSize = getLayerController().getViewportSize();
mGeckoViewport = new ViewportMetrics(viewportObject);
mGeckoViewport.setSize(viewportSize);
mTileLayer.setOrigin(PointUtils.round(mGeckoViewport.getDisplayportOrigin()));
mTileLayer.setResolution(mGeckoViewport.getZoomFactor());