mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 1002426 - Check restore status before overriding zoom. r=kats
This commit is contained in:
parent
0476f35f2b
commit
160103aa7f
@ -576,6 +576,23 @@ nsDOMWindowUtils::GetResolution(float* aXResolution, float* aYResolution)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetIsHistoryRestored(bool* aIsHistoryRestored) {
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
||||
nsIPresShell* presShell = GetPresShell();
|
||||
if (!presShell) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
const nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
|
||||
*aIsHistoryRestored = sf && sf->DidHistoryRestore();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::SetIsFirstPaint(bool aIsFirstPaint)
|
||||
{
|
||||
|
@ -48,7 +48,7 @@ interface nsIRunnable;
|
||||
interface nsICompositionStringSynthesizer;
|
||||
interface nsITranslationNodeList;
|
||||
|
||||
[scriptable, uuid(d68ea9fa-b1ea-4744-a78e-bb0e6ef95f55)]
|
||||
[scriptable, uuid(8489681a-7407-457e-b889-53d1ae999b30)]
|
||||
interface nsIDOMWindowUtils : nsISupports {
|
||||
|
||||
/**
|
||||
@ -230,6 +230,15 @@ interface nsIDOMWindowUtils : nsISupports {
|
||||
|
||||
void getResolution(out float aXResolution, out float aYResolution);
|
||||
|
||||
/**
|
||||
* Whether the current window has been restored from session history.
|
||||
* This gives a way to check whether the provided resolution and scroll
|
||||
* position are default values or restored from a previous session.
|
||||
*
|
||||
* Can only be accessed with chrome privileges.
|
||||
*/
|
||||
readonly attribute boolean isHistoryRestored;
|
||||
|
||||
/**
|
||||
* Whether the next paint should be flagged as the first paint for a document.
|
||||
* This gives a way to track the next paint that occurs after the flag is
|
||||
|
@ -658,7 +658,7 @@ public:
|
||||
virtual void ResetScrollPositionForLayerPixelAlignment() MOZ_OVERRIDE {
|
||||
mHelper.ResetScrollPositionForLayerPixelAlignment();
|
||||
}
|
||||
virtual bool DidHistoryRestore() MOZ_OVERRIDE {
|
||||
virtual bool DidHistoryRestore() const MOZ_OVERRIDE {
|
||||
return mHelper.mDidHistoryRestore;
|
||||
}
|
||||
virtual void ClearDidHistoryRestore() MOZ_OVERRIDE {
|
||||
@ -972,7 +972,7 @@ public:
|
||||
virtual void ResetScrollPositionForLayerPixelAlignment() MOZ_OVERRIDE {
|
||||
mHelper.ResetScrollPositionForLayerPixelAlignment();
|
||||
}
|
||||
virtual bool DidHistoryRestore() MOZ_OVERRIDE {
|
||||
virtual bool DidHistoryRestore() const MOZ_OVERRIDE {
|
||||
return mHelper.mDidHistoryRestore;
|
||||
}
|
||||
virtual void ClearDidHistoryRestore() MOZ_OVERRIDE {
|
||||
|
@ -270,7 +270,7 @@ public:
|
||||
/**
|
||||
* Was the current presentation state for this frame restored from history?
|
||||
*/
|
||||
virtual bool DidHistoryRestore() = 0;
|
||||
virtual bool DidHistoryRestore() const = 0;
|
||||
/**
|
||||
* Clear the flag so that DidHistoryRestore() returns false until the next
|
||||
* RestoreState call.
|
||||
|
@ -4204,20 +4204,26 @@ Tab.prototype = {
|
||||
sendMessageToJava(message);
|
||||
},
|
||||
|
||||
_getGeckoZoom: function() {
|
||||
let res = {x: {}, y: {}};
|
||||
let cwu = this.browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
|
||||
cwu.getResolution(res.x, res.y);
|
||||
let zoom = res.x.value * window.devicePixelRatio;
|
||||
return zoom;
|
||||
},
|
||||
|
||||
saveSessionZoom: function(aZoom) {
|
||||
let cwu = this.browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
|
||||
cwu.setResolution(aZoom / window.devicePixelRatio, aZoom / window.devicePixelRatio);
|
||||
},
|
||||
|
||||
restoredSessionZoom: function() {
|
||||
if (!this._restoreZoom) {
|
||||
return null;
|
||||
}
|
||||
|
||||
let cwu = this.browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
|
||||
let res = {x: {}, y: {}};
|
||||
cwu.getResolution(res.x, res.y);
|
||||
return res.x.value * window.devicePixelRatio;
|
||||
|
||||
if (this._restoreZoom && cwu.isHistoryRestored) {
|
||||
return this._getGeckoZoom();
|
||||
}
|
||||
return null;
|
||||
},
|
||||
|
||||
OnHistoryNewEntry: function(aUri) {
|
||||
|
Loading…
Reference in New Issue
Block a user