mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-20 08:45:46 +00:00
d00cd16240
Differential Revision: https://phabricator.services.mozilla.com/D85124
149 lines
4.7 KiB
C++
149 lines
4.7 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* 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/. */
|
|
|
|
#ifndef mozilla_dom_SessionHistoryEntry_h
|
|
#define mozilla_dom_SessionHistoryEntry_h
|
|
|
|
#include "mozilla/UniquePtr.h"
|
|
#include "nsILayoutHistoryState.h"
|
|
#include "nsISHEntry.h"
|
|
#include "nsStructuredCloneContainer.h"
|
|
#include "nsDataHashtable.h"
|
|
|
|
class nsDocShellLoadState;
|
|
class nsIChannel;
|
|
class nsIInputStream;
|
|
class nsIReferrerInfo;
|
|
class nsISHistory;
|
|
class nsIURI;
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
class SHEntrySharedParentState;
|
|
|
|
// SessionHistoryInfo stores session history data for a load. It can be sent
|
|
// over IPC and is used in both the parent and the child processes.
|
|
class SessionHistoryInfo {
|
|
public:
|
|
SessionHistoryInfo() = default;
|
|
SessionHistoryInfo(nsDocShellLoadState* aLoadState, nsIChannel* aChannel);
|
|
|
|
bool operator==(const SessionHistoryInfo& aInfo) const {
|
|
return false; // FIXME
|
|
}
|
|
|
|
nsIInputStream* GetPostData() const { return mPostData; }
|
|
void GetScrollPosition(int32_t* aScrollPositionX, int32_t* aScrollPositionY) {
|
|
*aScrollPositionX = mScrollPositionX;
|
|
*aScrollPositionY = mScrollPositionY;
|
|
}
|
|
bool GetScrollRestorationIsManual() const {
|
|
return mScrollRestorationIsManual;
|
|
}
|
|
const nsAString& GetTitle() { return mTitle; }
|
|
nsIURI* GetURI() const { return mURI; }
|
|
|
|
bool GetURIWasModified() const { return mURIWasModified; }
|
|
|
|
uint64_t Id() const { return mId; }
|
|
|
|
nsILayoutHistoryState* GetLayoutHistoryState() { return mLayoutHistoryState; }
|
|
|
|
void SetLayoutHistoryState(nsILayoutHistoryState* aState) {
|
|
mLayoutHistoryState = aState;
|
|
}
|
|
|
|
private:
|
|
friend class SessionHistoryEntry;
|
|
friend struct mozilla::ipc::IPDLParamTraits<SessionHistoryInfo>;
|
|
|
|
void MaybeUpdateTitleFromURI();
|
|
|
|
nsCOMPtr<nsIURI> mURI;
|
|
nsCOMPtr<nsIURI> mOriginalURI;
|
|
nsCOMPtr<nsIURI> mResultPrincipalURI;
|
|
nsCOMPtr<nsIReferrerInfo> mReferrerInfo;
|
|
nsString mTitle;
|
|
nsCOMPtr<nsIInputStream> mPostData;
|
|
uint32_t mLoadType = 0;
|
|
int32_t mScrollPositionX = 0;
|
|
int32_t mScrollPositionY = 0;
|
|
RefPtr<nsStructuredCloneContainer> mStateData;
|
|
nsString mSrcdocData;
|
|
nsCOMPtr<nsIURI> mBaseURI;
|
|
// mLayoutHistoryState is used to serialize layout history state across
|
|
// IPC. In the parent process this is then synchronized to
|
|
// SHEntrySharedParentState::mLayoutHistoryState
|
|
nsCOMPtr<nsILayoutHistoryState> mLayoutHistoryState;
|
|
|
|
uint64_t mId = 0;
|
|
bool mLoadReplace = false;
|
|
bool mURIWasModified = false;
|
|
bool mIsSrcdocEntry = false;
|
|
bool mScrollRestorationIsManual = false;
|
|
bool mPersist = false;
|
|
};
|
|
|
|
// SessionHistoryEntry is used to store session history data in the parent
|
|
// process. It holds a SessionHistoryInfo, some state shared amongst multiple
|
|
// SessionHistoryEntries, a parent and children.
|
|
class SessionHistoryEntry : public nsISHEntry {
|
|
public:
|
|
SessionHistoryEntry(nsDocShellLoadState* aLoadState, nsIChannel* aChannel);
|
|
explicit SessionHistoryEntry(SessionHistoryInfo* aInfo);
|
|
|
|
NS_DECL_ISUPPORTS
|
|
NS_DECL_NSISHENTRY
|
|
|
|
const SessionHistoryInfo& Info() const { return *mInfo; }
|
|
|
|
// Get an entry based on SessionHistoryInfo's Id. Parent process only.
|
|
static SessionHistoryEntry* GetByInfoId(uint64_t aId);
|
|
|
|
static void UpdateLayoutHistoryState(uint64_t aSessionHistoryEntryID,
|
|
nsILayoutHistoryState* aState);
|
|
|
|
private:
|
|
virtual ~SessionHistoryEntry();
|
|
|
|
UniquePtr<SessionHistoryInfo> mInfo;
|
|
RefPtr<SHEntrySharedParentState> mSharedInfo;
|
|
nsISHEntry* mParent = nullptr;
|
|
uint32_t mID;
|
|
nsTArray<RefPtr<SessionHistoryEntry>> mChildren;
|
|
|
|
static nsDataHashtable<nsUint64HashKey, SessionHistoryEntry*>* sInfoIdToEntry;
|
|
};
|
|
|
|
} // namespace dom
|
|
|
|
namespace ipc {
|
|
|
|
// Allow sending SessionHistoryInfo objects over IPC.
|
|
template <>
|
|
struct IPDLParamTraits<dom::SessionHistoryInfo> {
|
|
static void Write(IPC::Message* aMsg, IProtocol* aActor,
|
|
const dom::SessionHistoryInfo& aParam);
|
|
static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
|
|
IProtocol* aActor, dom::SessionHistoryInfo* aResult);
|
|
};
|
|
|
|
// Allow sending nsILayoutHistoryState objects over IPC.
|
|
template <>
|
|
struct IPDLParamTraits<nsILayoutHistoryState*> {
|
|
static void Write(IPC::Message* aMsg, IProtocol* aActor,
|
|
nsILayoutHistoryState* aParam);
|
|
static bool Read(const IPC::Message* aMsg, PickleIterator* aIter,
|
|
IProtocol* aActor, RefPtr<nsILayoutHistoryState>* aResult);
|
|
};
|
|
|
|
} // namespace ipc
|
|
|
|
} // namespace mozilla
|
|
|
|
#endif /* mozilla_dom_SessionHistoryEntry_h */
|