зеркало из https://github.com/mozilla/pjs.git
[mq]: review
This commit is contained in:
Родитель
2800bd62b5
Коммит
379f24607c
|
@ -37,8 +37,8 @@
|
|||
#filter substitution
|
||||
|
||||
// for browser.xml binding
|
||||
pref("toolkit.browser.cachePixelX", 400);
|
||||
pref("toolkit.browser.cachePixelY", 1000);
|
||||
pref("toolkit.browser.cachePixelX", 800);
|
||||
pref("toolkit.browser.cachePixelY", 2000);
|
||||
pref("toolkit.browser.recacheRatio", 60);
|
||||
|
||||
pref("toolkit.defaultChromeURI", "chrome://browser/content/browser.xul");
|
||||
|
@ -373,7 +373,7 @@ pref("browser.ui.kinetic.swipeLength", 160);
|
|||
|
||||
// zooming
|
||||
pref("browser.ui.zoom.pageFitGranularity", 9); // don't zoom to fit by less than 1/9
|
||||
pref("browser.ui.zoom.animationDuration", 350); // ms duration of double-tap zoom animation
|
||||
pref("browser.ui.zoom.animationDuration", 200); // ms duration of double-tap zoom animation
|
||||
|
||||
// pinch gesture
|
||||
pref("browser.ui.pinch.maxGrowth", 150); // max pinch distance growth
|
||||
|
|
|
@ -46,7 +46,7 @@ let Cu = Components.utils;
|
|||
/**
|
||||
* Responsible for zooming in to a given view rectangle
|
||||
*/
|
||||
const animatedZoom = {
|
||||
const AnimatedZoom = {
|
||||
/** Starts an animated zoom to zoomRect. */
|
||||
animateTo: function(aZoomRect) {
|
||||
if (!aZoomRect)
|
||||
|
@ -61,17 +61,15 @@ const animatedZoom = {
|
|||
Browser.hideTitlebar();
|
||||
Browser.forceChromeReflow();
|
||||
|
||||
this.beginTime = Date.now();
|
||||
this.beginTime = mozAnimationStartTime;
|
||||
|
||||
// Check if zooming animations were occuring before.
|
||||
if (this.zoomRect) {
|
||||
this.zoomFrom = this.zoomRect;
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
let browserRect = Rect.fromRect(getBrowser().getBoundingClientRect());
|
||||
let scrollX = {}, scrollY = {};
|
||||
getBrowser().getPosition(scrollX, scrollY);
|
||||
this.zoomFrom = browserRect.translate(scrollX.value, scrollY.value);
|
||||
let scroll = getBrowser().getPosition();
|
||||
this.zoomFrom = browserRect.translate(scroll.x, scroll.y);
|
||||
this.updateTo(this.zoomFrom);
|
||||
|
||||
window.addEventListener("MozBeforePaint", this, false);
|
||||
|
@ -109,16 +107,14 @@ const animatedZoom = {
|
|||
let counter = tdiff / this.animationDuration;
|
||||
if (counter < 1) {
|
||||
// update browser to interpolated rectangle
|
||||
let rect = this.zoomFrom.blend(this.zoomTo, Math.min(counter, 1));
|
||||
let rect = this.zoomFrom.blend(this.zoomTo, counter);
|
||||
this.updateTo(rect);
|
||||
mozRequestAnimationFrame();
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// last cycle already rendered final scaled image, now clean up
|
||||
this.finish();
|
||||
}
|
||||
}
|
||||
catch(e) {
|
||||
} catch(e) {
|
||||
this.finish();
|
||||
throw e;
|
||||
}
|
||||
|
|
|
@ -432,7 +432,6 @@ MouseModule.prototype = {
|
|||
= this.getScrollboxFromElement(aEvent.target);
|
||||
|
||||
// stop kinetic panning if targetScrollbox has changed
|
||||
let oldDragger = this._dragger;
|
||||
if (this._kinetic.isActive() && this._dragger != dragger)
|
||||
this._kinetic.end();
|
||||
|
||||
|
@ -445,7 +444,8 @@ MouseModule.prototype = {
|
|||
if (this._clicker)
|
||||
this._clicker.mouseDown(aEvent.clientX, aEvent.clientY);
|
||||
|
||||
if (this._dragger && this._dragger.isDraggable(targetScrollbox, targetScrollInterface))
|
||||
let draggable = this._dragger.isDraggable(targetScrollbox, targetScrollInterface);
|
||||
if (this._dragger && (draggable.x || draggable.y))
|
||||
this._doDragStart(aEvent);
|
||||
|
||||
if (this._targetIsContent(aEvent)) {
|
||||
|
@ -1305,7 +1305,7 @@ GestureModule.prototype = {
|
|||
document.getElementById("inputhandler-overlay").customClicker.panBegin();
|
||||
|
||||
// create the AnimatedZoom object for fast arbitrary zooming
|
||||
this._pinchZoom = animatedZoom;
|
||||
this._pinchZoom = AnimatedZoom;
|
||||
|
||||
// start from current zoom level
|
||||
this._pinchZoomLevel = getBrowser().scale;
|
||||
|
@ -1320,10 +1320,9 @@ GestureModule.prototype = {
|
|||
[this._pinchStartX, this._pinchStartY] =
|
||||
Browser.transformClientToBrowser(aEvent.clientX, aEvent.clientY);
|
||||
|
||||
let scrollX = {}, scrollY = {};
|
||||
getBrowser().getPosition(scrollX, scrollY);
|
||||
this._pinchScrollX = scrollX.value;
|
||||
this._pinchScrollY = scrollY.value;
|
||||
let scroll = getBrowser().getPosition();
|
||||
this._pinchScrollX = scroll.x;
|
||||
this._pinchScrollY = scroll.y
|
||||
|
||||
let [centerX, centerY] = Browser.transformClientToBrowser(window.innerWidth / 2,
|
||||
window.innerHeight / 2);
|
||||
|
@ -1345,10 +1344,9 @@ GestureModule.prototype = {
|
|||
Browser.transformClientToBrowser(aEvent.clientX, aEvent.clientY);
|
||||
|
||||
let scale = getBrowser().scale;
|
||||
let scrollX = {}, scrollY = {};
|
||||
getBrowser().getPosition(scrollX, scrollY);
|
||||
pX += (this._pinchScrollX - scrollX.value) / scale;
|
||||
pY += (this._pinchScrollY - scrollY.value) / scale;
|
||||
let scroll = getBrowser().getPosition();
|
||||
pX += (this._pinchScrollX - scroll.x) / scale;
|
||||
pY += (this._pinchScrollY - scroll.y) / scale;
|
||||
|
||||
// redraw zoom canvas according to new zoom rect
|
||||
let rect = Browser._getZoomRectForPoint(this._centerX + this._pinchStartX - pX,
|
||||
|
|
|
@ -367,7 +367,7 @@ let ContentScroll = {
|
|||
break;
|
||||
|
||||
let cwu = Util.getWindowUtils(content);
|
||||
cwu.setResolution(json.zoomLevel, json.zoomLevel);
|
||||
cwu.setResolution(json.scale, json.scale);
|
||||
cwu.setDisplayPort(displayport.x, displayport.y, displayport.width, displayport.height);
|
||||
break;
|
||||
}
|
||||
|
@ -388,12 +388,12 @@ let ContentScroll = {
|
|||
|
||||
case "MozScrolledAreaChanged": {
|
||||
let doc = aEvent.originalTarget;
|
||||
let win = doc.defaultView;
|
||||
// XXX need to make some things in Util as its own module!
|
||||
let scrollOffset = Util.getScrollOffset(win);
|
||||
if (win.parent != win) // We are only interested in root scroll pane changes
|
||||
if (content != doc.defaultView) // We are only interested in root scroll pane changes
|
||||
return;
|
||||
|
||||
// XXX need to make some things in Util as its own module!
|
||||
let scrollOffset = Util.getScrollOffset(content);
|
||||
|
||||
// Adjust width and height from the incoming event properties so that we
|
||||
// ignore changes to width and height contributed by growth in page
|
||||
// quadrants other than x > 0 && y > 0.
|
||||
|
|
|
@ -147,8 +147,8 @@
|
|||
break;
|
||||
|
||||
case "MozScrolledAreaChanged":
|
||||
this._widthInCSSPx = aMessage.json.width;
|
||||
this._heightInCSSPx = aMessage.json.height;
|
||||
this._contentDocumentWidth = aMessage.json.width;
|
||||
this._contentDocumentHeight = aMessage.json.height;
|
||||
this._updateCacheViewport();
|
||||
break;
|
||||
}
|
||||
|
@ -263,7 +263,7 @@
|
|||
this._browser._searchEngines = [];
|
||||
}
|
||||
|
||||
this._browser._zoomLevel = 1;
|
||||
this._browser.scale = 1;
|
||||
this._browser._updateCacheViewport();
|
||||
|
||||
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_LOCATION,
|
||||
|
@ -385,28 +385,28 @@
|
|||
<field name="_frameLoader">null</field>
|
||||
|
||||
<!-- Dimensions of content window -->
|
||||
<property name="viewportWidthInCSSPx"
|
||||
onget="return this._viewportWidthInCSSPx;"
|
||||
<property name="contentWindowWidth"
|
||||
onget="return this._contentWindowWidth;"
|
||||
readonly="true"/>
|
||||
<property name="viewportHeightInCSSPx"
|
||||
onget="return this._viewportHeightInCSSPx;"
|
||||
<property name="contentWindowHeight"
|
||||
onget="return this._contentWindowHeight;"
|
||||
readonly="true"/>
|
||||
|
||||
<!-- Dimensions of content document -->
|
||||
<field name="_widthInCSSPx">0</field>
|
||||
<field name="_heightInCSSPx">0</field>
|
||||
<property name="_widthInDevicePx"
|
||||
onget="return this._widthInCSSPx * this._zoomLevel;"
|
||||
<field name="_contentDocumentWidth">0</field>
|
||||
<field name="_contentDocumentHeight">0</field>
|
||||
<property name="contentDocumentWidth"
|
||||
onget="return this._contentDocumentWidth;"
|
||||
readonly="true"/>
|
||||
<property name="_heightInDevicePx"
|
||||
onget="return this._heightInCSSPx * this._zoomLevel;"
|
||||
<property name="contentDocumentHeight"
|
||||
onget="return this._contentDocumentHeight;"
|
||||
readonly="true"/>
|
||||
|
||||
<!-- Zoom level is the ratio of device pixels to CSS pixels -->
|
||||
<field name="_zoomLevel">1</field>
|
||||
<field name="_scale">1</field>
|
||||
<property name="scale"
|
||||
onget="return this._zoomLevel;"
|
||||
readonly="true"/>
|
||||
onget="return this._scale;"
|
||||
onset="return this._setScale(val);"/>
|
||||
|
||||
<!-- These counters are used to update the cached viewport after they reach a certain
|
||||
threshold when scrolling -->
|
||||
|
@ -415,10 +415,10 @@
|
|||
<field name="_pendingThresholdX">0</field>
|
||||
<field name="_pendingThresholdY">0</field>
|
||||
<!-- This determines what percentage of cached pixels are not yet visible before the cache
|
||||
is refreshed. For instance, if we recached at 50% and there are originally a total of
|
||||
400px offscreen, we'd refresh once 200 of those pixels have been scrolled into
|
||||
is refreshed. For instance, if we recached at 25% and there are originally a total of
|
||||
400px offscreen, we'd refresh once 100 of those pixels have been scrolled into
|
||||
view. -->
|
||||
<field name="_recacheRatio">0</field>
|
||||
<field name="_recacheRatio">1</field>
|
||||
|
||||
<!-- The cache viewport is what parts of content is cached in the parent process for
|
||||
fast scrolling. This syncs that up with the current projection viewport. -->
|
||||
|
@ -431,11 +431,11 @@
|
|||
|
||||
let frameLoader = this._frameLoader;
|
||||
this.messageManager.sendAsyncMessage("Content:SetCacheViewport", {
|
||||
x: (frameLoader.viewportScrollX + bcr.width / 2 - cacheX) / this._zoomLevel,
|
||||
y: (frameLoader.viewportScrollY + bcr.height / 2 - cacheY) / this._zoomLevel,
|
||||
w: (cacheX * 2) / this._zoomLevel,
|
||||
h: (cacheY * 2) / this._zoomLevel,
|
||||
zoomLevel: this._zoomLevel
|
||||
x: (frameLoader.viewportScrollX + bcr.width / 2 - cacheX) / this._scale,
|
||||
y: (frameLoader.viewportScrollY + bcr.height / 2 - cacheY) / this._scale,
|
||||
w: (cacheX * 2) / this._scale,
|
||||
h: (cacheY * 2) / this._scale,
|
||||
scale: this._scale
|
||||
});
|
||||
|
||||
this._pendingPixelsX = 0;
|
||||
|
@ -450,22 +450,22 @@
|
|||
<![CDATA[
|
||||
let frameLoader = this._frameLoader;
|
||||
this.messageManager.sendAsyncMessage("Content:ScrollTo", {
|
||||
x: frameLoader.viewportScrollX / this._zoomLevel,
|
||||
y: frameLoader.viewportScrollY / this._zoomLevel
|
||||
x: frameLoader.viewportScrollX / this._scale,
|
||||
y: frameLoader.viewportScrollY / this._scale
|
||||
});
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
||||
<!-- Sets the scale of CSS pixels to device pixels. Does not affect page layout. -->
|
||||
<method name="setScale">
|
||||
<parameter name="zl"/>
|
||||
<method name="_setScale">
|
||||
<parameter name="scale"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
if (zl <= 0) throw "Bad zoom level given.";
|
||||
if (scale <= 0) throw "Bad scale given.";
|
||||
|
||||
this._zoomLevel = zl;
|
||||
this._frameLoader.setViewportScale(zl, zl);
|
||||
this._scale = scale;
|
||||
this._frameLoader.setViewportScale(scale, scale);
|
||||
this._updateCacheViewport();
|
||||
|
||||
let event = document.createEvent("Events");
|
||||
|
@ -476,14 +476,14 @@
|
|||
</method>
|
||||
|
||||
<!-- Sets size of CSS viewport, which affects how page is layout. -->
|
||||
<method name="setCssViewportSize">
|
||||
<method name="setWindowSize">
|
||||
<parameter name="width"/>
|
||||
<parameter name="height"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
this._viewportWidthInCSSPx = width;
|
||||
this._viewportHeightInCSSPx = height;
|
||||
this.messageManager.sendAsyncMessage("Content:SetCssViewportSize", {
|
||||
this._contentWindowWidth = width;
|
||||
this._contentWindowHeight = height;
|
||||
this.messageManager.sendAsyncMessage("Content:SetWindowSize", {
|
||||
width: width,
|
||||
height: height
|
||||
});
|
||||
|
@ -519,9 +519,11 @@
|
|||
<parameter name="scrollY"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
let scrollX = {}, scrollY = {};
|
||||
let cwu = this.contentWindow.QueryInterface(Components.interfaces.nsIInterfaceRequestor).
|
||||
getInterface(Components.interfaces.nsIDOMWindowUtils);
|
||||
cwu.getScrollXY(false, scrollX, scrollY);
|
||||
return { x: scrollX.value, y: scrollY.value };
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
@ -741,7 +743,7 @@
|
|||
this._browser._searchEngines = [];
|
||||
}
|
||||
|
||||
this._browser._zoomLevel = 1;
|
||||
this._browser._scale = 1;
|
||||
this._browser._updateCacheViewport();
|
||||
|
||||
this._notify(Components.interfaces.nsIWebProgress.NOTIFY_LOCATION,
|
||||
|
@ -814,6 +816,7 @@
|
|||
onget="throw 'documentCharsetInfo: Not Remoteable'"
|
||||
readonly="true"/>
|
||||
|
||||
<!-- Scroll by (x, y) device pixels -->
|
||||
<method name="scrollBy">
|
||||
<parameter name="x"/>
|
||||
<parameter name="y"/>
|
||||
|
@ -821,12 +824,16 @@
|
|||
<![CDATA[
|
||||
let frameLoader = this._frameLoader;
|
||||
|
||||
// Bounding content rectangle is in device pixels
|
||||
let bcr = this.getBoundingClientRect();
|
||||
let viewportWidth = bcr.width;
|
||||
let viewportHeight = bcr.height;
|
||||
// Calculate document dimensions in device pixels
|
||||
let docWidth = this.contentDocumentWidth * this.scale;
|
||||
let docHeight = this.contentDocumentHeight * this.scale;
|
||||
|
||||
x = Math.floor(Math.max(0, Math.min(this._widthInDevicePx - viewportWidth, frameLoader.viewportScrollX + x)) - frameLoader.viewportScrollX);
|
||||
y = Math.floor(Math.max(0, Math.min(this._heightInDevicePx - viewportHeight, frameLoader.viewportScrollY + y)) - frameLoader.viewportScrollY);
|
||||
x = Math.floor(Math.max(0, Math.min(docWidth - viewportWidth, frameLoader.viewportScrollX + x)) - frameLoader.viewportScrollX);
|
||||
y = Math.floor(Math.max(0, Math.min(docHeight - viewportHeight, frameLoader.viewportScrollY + y)) - frameLoader.viewportScrollY);
|
||||
|
||||
if (x == 0 && y == 0)
|
||||
return;
|
||||
|
@ -845,6 +852,7 @@
|
|||
</body>
|
||||
</method>
|
||||
|
||||
<!-- Scroll to position (x, y) in device pixels -->
|
||||
<method name="scrollTo">
|
||||
<parameter name="x"/>
|
||||
<parameter name="y"/>
|
||||
|
@ -856,14 +864,12 @@
|
|||
</body>
|
||||
</method>
|
||||
|
||||
<!-- Get position of window in device pixels -->
|
||||
<method name="getPosition">
|
||||
<parameter name="scrollX"/>
|
||||
<parameter name="scrollY"/>
|
||||
<body>
|
||||
<![CDATA[
|
||||
let frameLoader = this._frameLoader;
|
||||
scrollX.value = frameLoader.viewportScrollX;
|
||||
scrollY.value = frameLoader.viewportScrollY;
|
||||
return { x: frameLoader.viewportScrollX, y: frameLoader.viewportScrollY };
|
||||
]]>
|
||||
</body>
|
||||
</method>
|
||||
|
|
|
@ -1057,15 +1057,15 @@ var TapHighlightHelper = {
|
|||
},
|
||||
|
||||
show: function show(aRects) {
|
||||
let scrollX = {}, scrollY = {};
|
||||
getBrowser().getPosition(scrollX, scrollY);
|
||||
let browser = getBrowser();
|
||||
let scroll = browser.getPosition();
|
||||
|
||||
let union = aRects.reduce(function(a, b) {
|
||||
return a.expandToContain(b);
|
||||
}, new Rect(0, 0, 0, 0)).map(function(val) { return val * getBrowser().scale; })
|
||||
.translate(-scrollX.value, -scrollY.value);
|
||||
}, new Rect(0, 0, 0, 0)).map(function(val) val * browser.scale)
|
||||
.translate(-scroll.x, -scroll.y);
|
||||
|
||||
let vis = Rect.fromRect(getBrowser().getBoundingClientRect());
|
||||
let vis = Rect.fromRect(browser.getBoundingClientRect());
|
||||
let canvasArea = vis.intersect(union);
|
||||
|
||||
let overlay = this._overlay;
|
||||
|
@ -1077,14 +1077,14 @@ var TapHighlightHelper = {
|
|||
let ctx = overlay.getContext("2d");
|
||||
ctx.save();
|
||||
ctx.translate(-canvasArea.left, -canvasArea.top);
|
||||
ctx.scale(getBrowser().scale, getBrowser().scale);
|
||||
ctx.scale(browser.scale, browser.scale);
|
||||
|
||||
overlay.style.left = canvasArea.left + "px";
|
||||
overlay.style.top = canvasArea.top + "px";
|
||||
ctx.fillStyle = "rgba(0, 145, 255, .5)";
|
||||
for (let i = aRects.length - 1; i >= 0; i--) {
|
||||
let rect = aRects[i];
|
||||
ctx.fillRect(rect.left - scrollX.value / getBrowser().scale, rect.top - scrollY.value / getBrowser().scale, rect.width, rect.height);
|
||||
ctx.fillRect(rect.left - scroll.x / browser.scale, rect.top - scroll.y / browser.scale, rect.width, rect.height);
|
||||
}
|
||||
ctx.restore();
|
||||
overlay.style.display = "block";
|
||||
|
@ -1877,6 +1877,7 @@ var FormHelperUI = {
|
|||
|
||||
/** Zoom and move viewport so that element is legible and touchable. */
|
||||
_zoom: function _formHelperZoom(aElementRect, aCaretRect) {
|
||||
let browser = getBrowser();
|
||||
if (aElementRect && aCaretRect && this._open) {
|
||||
this._currentCaretRect = aCaretRect;
|
||||
|
||||
|
@ -1929,7 +1930,7 @@ var FormHelperUI = {
|
|||
aCaretRect.x = aElementRect.x;
|
||||
}
|
||||
|
||||
let zoomLevel = getBrowser().scale;
|
||||
let zoomLevel = browser.scale;
|
||||
let enableZoom = Browser.selectedTab.allowZoom && Services.prefs.getBoolPref("formhelper.autozoom");
|
||||
if (enableZoom) {
|
||||
zoomLevel = (viewAreaHeight / caretLines) / harmonizedCaretHeight;
|
||||
|
@ -1947,25 +1948,24 @@ var FormHelperUI = {
|
|||
: aCaretRect.x - viewAreaWidth + margin + marginRight;
|
||||
// use the adjustet Caret Y minus a margin four our visible rect
|
||||
let y = harmonizedCaretY - margin;
|
||||
x *= browser.scale;
|
||||
y *= browser.scale;
|
||||
|
||||
let scrollX = {}, scrollY = {};
|
||||
getBrowser().getPosition(scrollX, scrollY);
|
||||
let vis = new Rect(scrollX.value, scrollY.value, window.innerWidth, window.innerHeight);
|
||||
x *= getBrowser().scale;
|
||||
y *= getBrowser().scale;
|
||||
let scroll = browser.getPosition(scrollX, scrollY);
|
||||
let vis = new Rect(scroll.x, scroll.y, window.innerWidth, window.innerHeight);
|
||||
|
||||
// from here on play with zoomed values
|
||||
// if we want to have it animated, build up zoom rect and animate.
|
||||
if (enableZoom && getBrowser().scale != zoomLevel) {
|
||||
if (enableZoom && browser.scale != zoomLevel) {
|
||||
// don't use browser functions they are bogus for this case
|
||||
let zoomRatio = zoomLevel / getBrowser().scale;
|
||||
let zoomRatio = zoomLevel / browser.scale;
|
||||
let newVisW = vis.width / zoomRatio, newVisH = vis.height / zoomRatio;
|
||||
let zoomRect = new Rect(x, y, newVisW, newVisH);
|
||||
|
||||
Browser.animatedZoomTo(zoomRect);
|
||||
}
|
||||
else { // no zooming at all
|
||||
getBrowser().scrollBy(x - vis.x, y - vis.y);
|
||||
browser.scrollBy(x - vis.x, y - vis.y);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
|
|
@ -191,7 +191,9 @@ var Browser = {
|
|||
},
|
||||
|
||||
getPosition: function(scrollX, scrollY) {
|
||||
getBrowser().getPosition(scrollX, scrollY);
|
||||
let { x: x, y: y } = getBrowser().getPosition();
|
||||
scrollX.value = x;
|
||||
scrollY.value = y;
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -841,9 +843,6 @@ var Browser = {
|
|||
|
||||
zoomLevel = tab.clampZoomLevel(zoomLevel);
|
||||
|
||||
let scrollX = {}, scrollY = {};
|
||||
tab.browser.getPosition(scrollX, scrollY);
|
||||
|
||||
let [centerX, centerY] = this.transformClientToBrowser(window.innerWidth / 2,
|
||||
window.innerHeight / 2);
|
||||
|
||||
|
@ -890,24 +889,25 @@ var Browser = {
|
|||
let result = new Rect(x - newVisW / 2, y - newVisH / 2, newVisW, newVisH);
|
||||
|
||||
// Make sure rectangle doesn't poke out of viewport
|
||||
return result.translateInside(new Rect(0, 0, getBrowser()._widthInDevicePx, getBrowser()._heightInDevicePx));
|
||||
return result.translateInside(new Rect(0, 0, getBrowser().contentDocumentWidth, getBrowser().contentDocumentHeight));
|
||||
},
|
||||
|
||||
animatedZoomTo: function animatedZoomTo(rect) {
|
||||
animatedZoom.animateTo(rect);
|
||||
AnimatedZoom.animateTo(rect);
|
||||
},
|
||||
|
||||
setVisibleRect: function setVisibleRect(rect) {
|
||||
let browser = getBrowser();
|
||||
let zoomRatio = window.innerWidth / rect.width;
|
||||
let zoomLevel = getBrowser().scale * zoomRatio;
|
||||
let zoomLevel = browser.scale * zoomRatio;
|
||||
let scrollX = rect.left * zoomRatio;
|
||||
let scrollY = rect.top * zoomRatio;
|
||||
|
||||
this.hideSidebars();
|
||||
this.hideTitlebar();
|
||||
|
||||
getBrowser().setScale(this.selectedTab.clampZoomLevel(zoomLevel));
|
||||
getBrowser().scrollTo(scrollX, scrollY);
|
||||
browser.scale = this.selectedTab.clampZoomLevel(zoomLevel);
|
||||
browser.scrollTo(scrollX, scrollY);
|
||||
},
|
||||
|
||||
zoomToPoint: function zoomToPoint(cX, cY, aRect) {
|
||||
|
@ -949,9 +949,8 @@ var Browser = {
|
|||
if (arguments.length > 1)
|
||||
y0 = Math.round(containerBCR.top);
|
||||
|
||||
let scrollX = {}, scrollY = {};
|
||||
getBrowser().getPosition(scrollX, scrollY);
|
||||
return (arguments.length > 1) ? [x - x0 + scrollX.value, y - y0 + scrollY.value] : (x - x0 + scrollX.value);
|
||||
let scroll = getBrowser().getPosition();
|
||||
return (arguments.length > 1) ? [x - x0 + scroll.x, y - y0 + scroll.y] : (x - x0 + scroll.x);
|
||||
},
|
||||
|
||||
browserViewToClient: function browserViewToClient(x, y) {
|
||||
|
@ -1079,7 +1078,6 @@ Browser.MainDragger.prototype = {
|
|||
x = Math.min(doffset.x, rect.left);
|
||||
|
||||
let height = document.getElementById("tile-stack").getBoundingClientRect().height;
|
||||
// XXX change
|
||||
rect = Rect.fromRect(Browser.contentScrollbox.getBoundingClientRect()).map(Math.round);
|
||||
if (doffset.y < 0 && rect.bottom < height)
|
||||
y = Math.max(doffset.y, rect.bottom - height);
|
||||
|
@ -2242,7 +2240,7 @@ Tab.prototype = {
|
|||
viewportH = kDefaultBrowserWidth * (screenH / screenW);
|
||||
}
|
||||
|
||||
browser.setCssViewportSize(viewportW, viewportH);
|
||||
browser.setWindowSize(viewportW, viewportH);
|
||||
}
|
||||
else {
|
||||
let browserBCR = browser.getBoundingClientRect();
|
||||
|
@ -2254,16 +2252,8 @@ Tab.prototype = {
|
|||
h /= dpiScale;
|
||||
}
|
||||
|
||||
browser.setCssViewportSize(w, h);
|
||||
browser.setWindowSize(w, h);
|
||||
}
|
||||
|
||||
// Local XUL documents are not firing MozScrolledAreaChanged
|
||||
/*let contentDocument = browser.contentDocument;
|
||||
if (contentDocument && contentDocument instanceof XULDocument) {
|
||||
let width = contentDocument.documentElement.scrollWidth;
|
||||
let height = contentDocument.documentElement.scrollHeight;
|
||||
BrowserView.Util.ensureMozScrolledAreaEvent(browser, width, height);
|
||||
} */
|
||||
},
|
||||
|
||||
startLoading: function startLoading() {
|
||||
|
@ -2364,27 +2354,25 @@ Tab.prototype = {
|
|||
return rounded || 1.0;
|
||||
},
|
||||
|
||||
/**
|
||||
* XXX document me
|
||||
*/
|
||||
/** Record the initial zoom level when a page first loads. */
|
||||
resetZoomLevel: function resetZoomLevel() {
|
||||
let browser = this._browser;
|
||||
this._defaultZoomLevel = browser.scale;
|
||||
this._defaultZoomLevel = this._browser.scale;
|
||||
},
|
||||
|
||||
/**
|
||||
* XXX document me
|
||||
* Recalculate default zoom level when page size changes, and update zoom
|
||||
* level if we are at default.
|
||||
*/
|
||||
updateDefaultZoomLevel: function updateDefaultZoomLevel() {
|
||||
let browser = this._browser;
|
||||
let isDefault = (browser.scale == this._defaultZoomLevel);
|
||||
this._defaultZoomLevel = this.getDefaultZoomLevel();
|
||||
if (isDefault)
|
||||
browser.setScale(this._defaultZoomLevel);
|
||||
browser.scale = this._defaultZoomLevel;
|
||||
},
|
||||
|
||||
isDefaultZoomLevel: function isDefaultZoomLevel() {
|
||||
return getBrowser().scale == this._defaultZoomLevel;
|
||||
return this._browser.scale == this._defaultZoomLevel;
|
||||
},
|
||||
|
||||
getDefaultZoomLevel: function getDefaultZoomLevel() {
|
||||
|
@ -2404,7 +2392,7 @@ Tab.prototype = {
|
|||
},
|
||||
|
||||
getPageZoomLevel: function getPageZoomLevel() {
|
||||
let browserW = this._browser._widthInCSSPx;
|
||||
let browserW = this._browser.contentDocumentWidth;
|
||||
return this._browser.getBoundingClientRect().width / browserW;
|
||||
},
|
||||
|
||||
|
|
|
@ -349,13 +349,11 @@ Content.prototype = {
|
|||
|
||||
switch (aMessage.name) {
|
||||
case "Browser:Blur":
|
||||
docShell.isOffScreenBrowser = false;
|
||||
docShell.isActive = false;
|
||||
this._selected = false;
|
||||
break;
|
||||
|
||||
case "Browser:Focus":
|
||||
docShell.isOffScreenBrowser = true;
|
||||
docShell.isActive = true;
|
||||
this._selected = true;
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче