зеркало из https://github.com/mozilla/gecko-dev.git
Bug 624451 Followup: stop relying on contentWidth/contentHeight r=mbrubeck
This commit is contained in:
Родитель
ab946e018f
Коммит
d998a8a40d
|
@ -89,14 +89,8 @@ const AnimatedZoom = {
|
||||||
let zoomRatio = window.innerWidth / nextRect.width;
|
let zoomRatio = window.innerWidth / nextRect.width;
|
||||||
let zoomLevel = browser.scale * zoomRatio;
|
let zoomLevel = browser.scale * zoomRatio;
|
||||||
|
|
||||||
// XXX using the underlying frameLoader APIs is undesirable and is not a
|
|
||||||
// pattern to propagate. The browser binding should be taking care of this!
|
|
||||||
// There is some bug that I have not yet discovered that make browser.scrollTo
|
|
||||||
// not behave correctly and there is no intelligence in browser.scale to keep
|
|
||||||
// the actual resolution changes small.
|
|
||||||
// * One bug is related to setting scale. See bug 626792.
|
|
||||||
let contentView = browser.getRootView();
|
let contentView = browser.getRootView();
|
||||||
contentView.setScale(zoomLevel, zoomLevel);
|
contentView.setScale(zoomLevel);
|
||||||
contentView.scrollTo(nextRect.left * zoomRatio, nextRect.top * zoomRatio);
|
contentView.scrollTo(nextRect.left * zoomRatio, nextRect.top * zoomRatio);
|
||||||
|
|
||||||
this.zoomRect = nextRect;
|
this.zoomRect = nextRect;
|
||||||
|
|
|
@ -818,8 +818,9 @@
|
||||||
|
|
||||||
let cacheWidth = self._cacheRatioWidth * viewportSize.width;
|
let cacheWidth = self._cacheRatioWidth * viewportSize.width;
|
||||||
let cacheHeight = self._cacheRatioHeight * viewportSize.height;
|
let cacheHeight = self._cacheRatioHeight * viewportSize.height;
|
||||||
let contentWidth = contentView.contentWidth;
|
let contentSize = this._getContentSize();
|
||||||
let contentHeight = contentView.contentHeight;
|
let contentWidth = contentSize.width;
|
||||||
|
let contentHeight = contentSize.height;
|
||||||
|
|
||||||
// There are common cases, such as long skinny pages, where our cache size is
|
// There are common cases, such as long skinny pages, where our cache size is
|
||||||
// bigger than our content size. In those cases, we take that sliver of leftover
|
// bigger than our content size. In those cases, we take that sliver of leftover
|
||||||
|
@ -849,10 +850,11 @@
|
||||||
let cacheSize = this._getCacheSize(viewportSize);
|
let cacheSize = this._getCacheSize(viewportSize);
|
||||||
let cacheX = this._getRelativeCacheStart(this._pixelsPannedSinceRefresh.x, viewportSize.width, cacheSize.width) + contentView.scrollX;
|
let cacheX = this._getRelativeCacheStart(this._pixelsPannedSinceRefresh.x, viewportSize.width, cacheSize.width) + contentView.scrollX;
|
||||||
let cacheY = this._getRelativeCacheStart(this._pixelsPannedSinceRefresh.y, viewportSize.height, cacheSize.height) + contentView.scrollY;
|
let cacheY = this._getRelativeCacheStart(this._pixelsPannedSinceRefresh.y, viewportSize.height, cacheSize.height) + contentView.scrollY;
|
||||||
|
let contentSize = this._getContentSize();
|
||||||
|
|
||||||
// Use our pixels efficiently and don't try to cache things outside of content
|
// Use our pixels efficiently and don't try to cache things outside of content
|
||||||
// boundaries.
|
// boundaries.
|
||||||
let bounds = new Rect(0, 0, contentView.contentWidth, contentView.contentHeight);
|
let bounds = new Rect(0, 0, contentSize.width, contentSize.height);
|
||||||
let displayport = new Rect(cacheX, cacheY, cacheSize.width, cacheSize.height);
|
let displayport = new Rect(cacheX, cacheY, cacheSize.width, cacheSize.height);
|
||||||
displayport.translateInside(bounds);
|
displayport.translateInside(bounds);
|
||||||
|
|
||||||
|
@ -871,6 +873,20 @@
|
||||||
this._pixelsPannedSinceRefresh.y = 0;
|
this._pixelsPannedSinceRefresh.y = 0;
|
||||||
},
|
},
|
||||||
|
|
||||||
|
_getContentSize: function() {
|
||||||
|
let self = this.self;
|
||||||
|
if (this.isRoot()) {
|
||||||
|
// XXX Bug 626792 means contentWidth and contentHeight aren't always
|
||||||
|
// updated immediately. This makes the displayport go haywire so
|
||||||
|
// use contentDocument properties.
|
||||||
|
return { width: self._contentDocumentWidth * this._scale,
|
||||||
|
height: self._contentDocumentHeight * this._scale };
|
||||||
|
} else {
|
||||||
|
return { width: this._contentView.contentWidth,
|
||||||
|
height: this._contentView.contentHeight };
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
_getViewportSize: function() {
|
_getViewportSize: function() {
|
||||||
let self = this.self;
|
let self = this.self;
|
||||||
if (this.isRoot()) {
|
if (this.isRoot()) {
|
||||||
|
@ -886,6 +902,7 @@
|
||||||
|
|
||||||
this._contentView = contentView;
|
this._contentView = contentView;
|
||||||
this._id = contentView.id;
|
this._id = contentView.id;
|
||||||
|
this._scale = 1;
|
||||||
self._contentViews[this._id] = this;
|
self._contentViews[this._id] = this;
|
||||||
|
|
||||||
if (!this.isRoot()) {
|
if (!this.isRoot()) {
|
||||||
|
@ -905,9 +922,10 @@
|
||||||
// Bounding content rectangle is in device pixels
|
// Bounding content rectangle is in device pixels
|
||||||
let contentView = this._contentView;
|
let contentView = this._contentView;
|
||||||
let viewportSize = this._getViewportSize();
|
let viewportSize = this._getViewportSize();
|
||||||
|
let contentSize = this._getContentSize();
|
||||||
// Calculate document dimensions in device pixels
|
// Calculate document dimensions in device pixels
|
||||||
let scrollRangeX = contentView.contentWidth - viewportSize.width;
|
let scrollRangeX = contentSize.width - viewportSize.width;
|
||||||
let scrollRangeY = contentView.contentHeight - viewportSize.height;
|
let scrollRangeY = contentSize.height - viewportSize.height;
|
||||||
|
|
||||||
x = Math.floor(Math.max(0, Math.min(scrollRangeX, contentView.scrollX + x)) - contentView.scrollX);
|
x = Math.floor(Math.max(0, Math.min(scrollRangeX, contentView.scrollX + x)) - contentView.scrollX);
|
||||||
y = Math.floor(Math.max(0, Math.min(scrollRangeY, contentView.scrollY + y)) - contentView.scrollY);
|
y = Math.floor(Math.max(0, Math.min(scrollRangeY, contentView.scrollY + y)) - contentView.scrollY);
|
||||||
|
@ -931,9 +949,10 @@
|
||||||
this.scrollBy(x - contentView.scrollX, y - contentView.scrollY);
|
this.scrollBy(x - contentView.scrollX, y - contentView.scrollY);
|
||||||
},
|
},
|
||||||
|
|
||||||
setScale: function(aXScale, aYScale) {
|
setScale: function(scale) {
|
||||||
let contentView = this._contentView;
|
let contentView = this._contentView;
|
||||||
contentView.setScale(aXScale, aYScale);
|
this._scale = scale;
|
||||||
|
contentView.setScale(scale, scale);
|
||||||
},
|
},
|
||||||
|
|
||||||
getPosition: function() {
|
getPosition: function() {
|
||||||
|
@ -954,7 +973,7 @@
|
||||||
|
|
||||||
this._scale = scale;
|
this._scale = scale;
|
||||||
let rootView = this.getRootView();
|
let rootView = this.getRootView();
|
||||||
rootView.setScale(scale, scale);
|
rootView.setScale(scale);
|
||||||
rootView._updateCacheViewport();
|
rootView._updateCacheViewport();
|
||||||
|
|
||||||
let event = document.createEvent("Events");
|
let event = document.createEvent("Events");
|
||||||
|
|
|
@ -1033,13 +1033,9 @@ var Browser = {
|
||||||
this.hideSidebars();
|
this.hideSidebars();
|
||||||
this.hideTitlebar();
|
this.hideTitlebar();
|
||||||
|
|
||||||
// XXX see AnimatedZoom.updateTo for why we use _contentView.
|
|
||||||
browser.scale = this.selectedTab.clampZoomLevel(zoomLevel);
|
browser.scale = this.selectedTab.clampZoomLevel(zoomLevel);
|
||||||
let view = browser.getRootView();
|
let view = browser.getRootView();
|
||||||
if (view._contentView) {
|
view.scrollTo(scrollX, scrollY);
|
||||||
view._contentView.scrollTo(scrollX, scrollY);
|
|
||||||
view._updateCacheViewport();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
|
|
||||||
zoomToPoint: function zoomToPoint(cX, cY, aRect) {
|
zoomToPoint: function zoomToPoint(cX, cY, aRect) {
|
||||||
|
|
Загрузка…
Ссылка в новой задаче