mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-07 21:43:24 +00:00
Bug 708683 - Guard more rigorously against bad viewport updates. r=kats a=android-only
Check more values in browser.js when updating the viewport, and restructure the JSON conversion in Java so that it's easier to tell what value caused a bad viewport if it comes from Java.
This commit is contained in:
parent
b01492badc
commit
e7483beacf
@ -236,17 +236,17 @@ public class ViewportMetrics {
|
||||
|
||||
public String toJSON() {
|
||||
try {
|
||||
return new JSONStringer().object()
|
||||
.key("x").value(mViewportRect.left)
|
||||
.key("y").value(mViewportRect.top)
|
||||
.key("width").value(mViewportRect.width())
|
||||
.key("height").value(mViewportRect.height())
|
||||
.key("pageWidth").value(mPageSize.width)
|
||||
.key("pageHeight").value(mPageSize.height)
|
||||
.key("offsetX").value(mViewportOffset.x)
|
||||
.key("offsetY").value(mViewportOffset.y)
|
||||
.key("zoom").value(mZoomFactor)
|
||||
.endObject().toString();
|
||||
JSONStringer object = new JSONStringer().object();
|
||||
object.key("zoom").value(mZoomFactor);
|
||||
object.key("offsetY").value(mViewportOffset.y);
|
||||
object.key("offsetX").value(mViewportOffset.x);
|
||||
object.key("pageHeight").value(mPageSize.height);
|
||||
object.key("pageWidth").value(mPageSize.width);
|
||||
object.key("height").value(mViewportRect.height());
|
||||
object.key("width").value(mViewportRect.width());
|
||||
object.key("y").value(mViewportRect.top);
|
||||
object.key("x").value(mViewportRect.left);
|
||||
return object.endObject().toString();
|
||||
} catch (JSONException je) {
|
||||
Log.e(LOGTAG, "Error serializing viewportmetrics", je);
|
||||
return "";
|
||||
|
@ -1160,10 +1160,10 @@ Tab.prototype = {
|
||||
|
||||
get viewport() {
|
||||
// Update the viewport to current dimensions
|
||||
this._viewport.x = this.browser.contentWindow.scrollX +
|
||||
this.viewportExcess.x;
|
||||
this._viewport.y = this.browser.contentWindow.scrollY +
|
||||
this.viewportExcess.y;
|
||||
this._viewport.x = (this.browser.contentWindow.scrollX +
|
||||
this.viewportExcess.x) || 0;
|
||||
this._viewport.y = (this.browser.contentWindow.scrollY +
|
||||
this.viewportExcess.y) || 0;
|
||||
|
||||
// Transform coordinates based on zoom
|
||||
this._viewport.x = Math.round(this._viewport.x * this._viewport.zoom);
|
||||
@ -1192,8 +1192,8 @@ Tab.prototype = {
|
||||
updateViewport: function(aReset) {
|
||||
let win = this.browser.contentWindow;
|
||||
let zoom = (aReset ? this.getDefaultZoomLevel() : this._viewport.zoom);
|
||||
let xpos = (aReset ? win.scrollX * zoom : this._viewport.x);
|
||||
let ypos = (aReset ? win.scrollY * zoom : this._viewport.y);
|
||||
let xpos = ((aReset && win) ? win.scrollX * zoom : this._viewport.x);
|
||||
let ypos = ((aReset && win) ? win.scrollY * zoom : this._viewport.y);
|
||||
|
||||
this.viewportExcess = { x: 0, y: 0 };
|
||||
this.viewport = { x: xpos, y: ypos,
|
||||
|
Loading…
Reference in New Issue
Block a user