зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1002426 - Check resolution restore status via specialized flag. r=kats, r=tn
This commit is contained in:
Родитель
713a334dc5
Коммит
219e6bff01
|
@ -577,7 +577,7 @@ nsDOMWindowUtils::GetResolution(float* aXResolution, float* aYResolution)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMWindowUtils::GetIsHistoryRestored(bool* aIsHistoryRestored) {
|
||||
nsDOMWindowUtils::GetIsResolutionSet(bool* aIsResolutionSet) {
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
return NS_ERROR_DOM_SECURITY_ERR;
|
||||
}
|
||||
|
@ -588,7 +588,7 @@ nsDOMWindowUtils::GetIsHistoryRestored(bool* aIsHistoryRestored) {
|
|||
}
|
||||
|
||||
const nsIScrollableFrame* sf = presShell->GetRootScrollFrameAsScrollable();
|
||||
*aIsHistoryRestored = sf && sf->DidHistoryRestore();
|
||||
*aIsResolutionSet = sf && sf->IsResolutionSet();
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ interface nsIRunnable;
|
|||
interface nsICompositionStringSynthesizer;
|
||||
interface nsITranslationNodeList;
|
||||
|
||||
[scriptable, uuid(8489681a-7407-457e-b889-53d1ae999b30)]
|
||||
[scriptable, uuid(aae2d993-366f-43e6-aa51-f2eb83935e7d)]
|
||||
interface nsIDOMWindowUtils : nsISupports {
|
||||
|
||||
/**
|
||||
|
@ -231,13 +231,13 @@ 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.
|
||||
* Whether the resolution has been set by the user.
|
||||
* This gives a way to check whether the provided resolution is the default
|
||||
* value or restored from a previous session.
|
||||
*
|
||||
* Can only be accessed with chrome privileges.
|
||||
*/
|
||||
readonly attribute boolean isHistoryRestored;
|
||||
readonly attribute boolean isResolutionSet;
|
||||
|
||||
/**
|
||||
* Whether the next paint should be flagged as the first paint for a document.
|
||||
|
|
|
@ -1607,6 +1607,7 @@ ScrollFrameHelper::ScrollFrameHelper(nsContainerFrame* aOuter,
|
|||
, mCollapsedResizer(false)
|
||||
, mShouldBuildScrollableLayer(false)
|
||||
, mHasBeenScrolled(false)
|
||||
, mIsResolutionSet(false)
|
||||
{
|
||||
mScrollingActive = IsAlwaysActive();
|
||||
|
||||
|
@ -2795,6 +2796,7 @@ void
|
|||
ScrollFrameHelper::SetResolution(const gfxSize& aResolution)
|
||||
{
|
||||
mResolution = aResolution;
|
||||
mIsResolutionSet = true;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -4538,6 +4540,7 @@ ScrollFrameHelper::RestoreState(nsPresState* aState)
|
|||
mDidHistoryRestore = true;
|
||||
mLastPos = mScrolledFrame ? GetLogicalScrollPosition() : nsPoint(0,0);
|
||||
mResolution = aState->GetResolution();
|
||||
mIsResolutionSet = true;
|
||||
|
||||
if (mIsRoot) {
|
||||
mOuter->PresContext()->PresShell()->SetResolution(mResolution.width, mResolution.height);
|
||||
|
|
|
@ -407,6 +407,10 @@ public:
|
|||
// True if this frame has been scrolled at least once
|
||||
bool mHasBeenScrolled:1;
|
||||
|
||||
// True if the frame's resolution has been set via SetResolution or restored
|
||||
// via RestoreState.
|
||||
bool mIsResolutionSet:1;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* @note This method might destroy the frame, pres shell and other objects.
|
||||
|
@ -658,6 +662,9 @@ public:
|
|||
virtual void ResetScrollPositionForLayerPixelAlignment() MOZ_OVERRIDE {
|
||||
mHelper.ResetScrollPositionForLayerPixelAlignment();
|
||||
}
|
||||
virtual bool IsResolutionSet() const MOZ_OVERRIDE {
|
||||
return mHelper.mIsResolutionSet;
|
||||
}
|
||||
virtual bool DidHistoryRestore() const MOZ_OVERRIDE {
|
||||
return mHelper.mDidHistoryRestore;
|
||||
}
|
||||
|
@ -972,6 +979,9 @@ public:
|
|||
virtual void ResetScrollPositionForLayerPixelAlignment() MOZ_OVERRIDE {
|
||||
mHelper.ResetScrollPositionForLayerPixelAlignment();
|
||||
}
|
||||
virtual bool IsResolutionSet() const MOZ_OVERRIDE {
|
||||
return mHelper.mIsResolutionSet;
|
||||
}
|
||||
virtual bool DidHistoryRestore() const MOZ_OVERRIDE {
|
||||
return mHelper.mDidHistoryRestore;
|
||||
}
|
||||
|
|
|
@ -271,6 +271,10 @@ public:
|
|||
* Was the current presentation state for this frame restored from history?
|
||||
*/
|
||||
virtual bool DidHistoryRestore() const = 0;
|
||||
/**
|
||||
* Was the current resolution set by the user or just default initialized?
|
||||
*/
|
||||
virtual bool IsResolutionSet() const = 0;
|
||||
/**
|
||||
* Clear the flag so that DidHistoryRestore() returns false until the next
|
||||
* RestoreState call.
|
||||
|
|
|
@ -4233,7 +4233,7 @@ Tab.prototype = {
|
|||
restoredSessionZoom: function() {
|
||||
let cwu = this.browser.contentWindow.QueryInterface(Ci.nsIInterfaceRequestor).getInterface(Ci.nsIDOMWindowUtils);
|
||||
|
||||
if (this._restoreZoom && cwu.isHistoryRestored) {
|
||||
if (this._restoreZoom && cwu.isResolutionSet) {
|
||||
return this._getGeckoZoom();
|
||||
}
|
||||
return null;
|
||||
|
|
Загрузка…
Ссылка в новой задаче