mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
0e575681dc
This will allow the session store to store and restore scroll positions (and pinch zoom on Android) for past session history entries as well, whereas today only the scroll position of the current page is saved. As a LayoutHistoryState saves its PresStates in a hash table that doesn't allow direct access to its contents if you don't already know the entry's key, we provide a function to iterate over all stored PresStates and retrieve their keys, which can then be used to get access to each individual PresState in turn. Since nsPresState is little more than a fancy struct and we don't want to have to turn it into a full-blown XPCOM-compatible interface, we just pass the scroll/zoom-related values we're interested in as in/out parameters from/to JS via the LayoutHistoryState. We also require a helper method for initialising an SHEntry's LayoutHistoryState, since normally this doesn't happen until the PresShell wants to capture the history state in it. We on the other hand require a LayoutHistoryState to be present immediately after creation of a fresh SHEntry object, so we can feed it the session store data during history restoration. MozReview-Commit-ID: FfZf8KDsVWl *** --HG-- extra : rebase_source : 0b3f729bff3ac24680d6fe8a0fb796979886170b
101 lines
2.9 KiB
Plaintext
101 lines
2.9 KiB
Plaintext
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
/*
|
|
* interface for container for information saved in session history when
|
|
* the document is not
|
|
*/
|
|
|
|
#include "nsISupports.idl"
|
|
|
|
interface nsPresState;
|
|
|
|
[ptr] native nsPresStatePtr(nsPresState);
|
|
[ref] native nsCString(const nsCString);
|
|
native constBool(const bool);
|
|
|
|
%{C++
|
|
#include "nsStringFwd.h"
|
|
|
|
template<typename> struct already_AddRefed;
|
|
%}
|
|
|
|
[scriptable, uuid(aef27cb3-4df9-4eeb-b0b0-ac56cf861d04)]
|
|
interface nsILayoutHistoryState : nsISupports
|
|
{
|
|
/**
|
|
* Whether this LayoutHistoryState contains any PresStates.
|
|
*/
|
|
readonly attribute boolean hasStates;
|
|
|
|
/**
|
|
* Get the keys of all PresStates held by this LayoutHistoryState.
|
|
* Note: Check hasStates first.
|
|
*/
|
|
void getKeys([optional] out uint32_t aCount,
|
|
[array, size_is(aCount), retval] out string aKeys);
|
|
|
|
/*
|
|
* Attempts to get the data of the PresState corresponding to
|
|
* the passed key. Throws if no data could be found.
|
|
*/
|
|
void getPresState(in ACString aKey,
|
|
out float aScrollX, out float aScrollY,
|
|
out boolean aAllowScrollOriginDowngrade,
|
|
out float aRes, out boolean aScaleToRes);
|
|
|
|
/**
|
|
* Constructs a new nsPresState object based on the supplied data
|
|
* and adds it to the LayoutHistoryState.
|
|
*/
|
|
void addNewPresState(in ACString aKey,
|
|
in float aScrollX, in float aScrollY,
|
|
in boolean aAllowScrollOriginDowngrade,
|
|
in float aRes, in boolean aScaleToRes);
|
|
|
|
// Native only interface, converted from the original nsILayoutHistoryState.h
|
|
|
|
/**
|
|
* Set |aState| as the state object for |aKey|.
|
|
* This _transfers_ownership_ of |aState| to the LayoutHistoryState.
|
|
* It will be freed when RemoveState() is called or when the
|
|
* LayoutHistoryState is destroyed.
|
|
*/
|
|
[noscript, notxpcom, nostdcall] void AddState(in nsCString aKey, in nsPresStatePtr aState);
|
|
|
|
/**
|
|
* Look up the state object for |aKey|.
|
|
*/
|
|
[noscript, notxpcom, nostdcall] nsPresStatePtr GetState(in nsCString aKey);
|
|
|
|
/**
|
|
* Remove the state object for |aKey|.
|
|
*/
|
|
[noscript, notxpcom, nostdcall] void RemoveState(in nsCString aKey);
|
|
|
|
/**
|
|
* Check whether this history has any states in it
|
|
*/
|
|
[noscript, notxpcom, nostdcall] boolean HasStates();
|
|
|
|
/**
|
|
* Sets whether this history can contain only scroll position history
|
|
* or all possible history
|
|
*/
|
|
[noscript, notxpcom, nostdcall] void SetScrollPositionOnly(in constBool aFlag);
|
|
|
|
/**
|
|
* Resets nsPresState::GetScrollState of all nsPresState objects to 0,0.
|
|
*/
|
|
[noscript, notxpcom, nostdcall] void ResetScrollState();
|
|
};
|
|
|
|
%{C++
|
|
already_AddRefed<nsILayoutHistoryState>
|
|
NS_NewLayoutHistoryState();
|
|
%}
|
|
|
|
|