2015-05-08 14:37:00 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
2012-05-21 15:12:37 +04:00
|
|
|
/* 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/. */
|
1999-12-23 01:35:31 +03:00
|
|
|
|
2005-08-18 15:15:33 +04:00
|
|
|
#include "nsSHEntry.h"
|
2017-04-27 13:16:46 +03:00
|
|
|
|
|
|
|
#include <algorithm>
|
|
|
|
|
2019-02-21 18:00:32 +03:00
|
|
|
#include "nsIContentSecurityPolicy.h"
|
2017-04-27 13:16:46 +03:00
|
|
|
#include "nsDocShellEditorData.h"
|
2018-10-30 03:13:29 +03:00
|
|
|
#include "nsDocShellLoadTypes.h"
|
2017-04-27 13:16:46 +03:00
|
|
|
#include "nsIContentViewer.h"
|
2005-08-18 15:17:00 +04:00
|
|
|
#include "nsIDocShellTreeItem.h"
|
2017-04-27 13:16:46 +03:00
|
|
|
#include "nsIInputStream.h"
|
2011-10-21 19:26:34 +04:00
|
|
|
#include "nsILayoutHistoryState.h"
|
2012-07-02 03:45:59 +04:00
|
|
|
#include "nsIStructuredCloneContainer.h"
|
2013-09-04 19:26:20 +04:00
|
|
|
#include "nsIURI.h"
|
2017-04-27 13:16:46 +03:00
|
|
|
#include "nsSHEntryShared.h"
|
|
|
|
#include "nsSHistory.h"
|
|
|
|
|
2014-11-18 16:46:29 +03:00
|
|
|
#include "mozilla/net/ReferrerPolicy.h"
|
2019-02-12 22:35:32 +03:00
|
|
|
#include "nsIReferrerInfo.h"
|
2007-09-21 13:19:59 +04:00
|
|
|
|
2010-08-24 11:05:56 +04:00
|
|
|
namespace dom = mozilla::dom;
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
static uint32_t gEntryID = 0;
|
2007-09-21 13:19:59 +04:00
|
|
|
|
2011-10-21 19:26:34 +04:00
|
|
|
nsSHEntry::nsSHEntry()
|
2015-05-06 20:57:23 +03:00
|
|
|
: mShared(new nsSHEntryShared()),
|
2014-11-18 16:46:29 +03:00
|
|
|
mLoadType(0),
|
2005-08-18 15:16:54 +04:00
|
|
|
mID(gEntryID++),
|
|
|
|
mScrollPositionX(0),
|
|
|
|
mScrollPositionY(0),
|
2012-07-30 18:20:58 +04:00
|
|
|
mParent(nullptr),
|
2017-04-27 13:16:46 +03:00
|
|
|
mLoadReplace(false),
|
2011-10-17 18:59:28 +04:00
|
|
|
mURIWasModified(false),
|
2013-06-29 07:13:22 +04:00
|
|
|
mIsSrcdocEntry(false),
|
2015-12-26 13:59:09 +03:00
|
|
|
mScrollRestorationIsManual(false),
|
2017-05-18 14:08:56 +03:00
|
|
|
mLoadedInThisProcess(false),
|
2018-09-05 02:02:37 +03:00
|
|
|
mPersist(true) {}
|
2005-08-18 15:16:54 +04:00
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::nsSHEntry(const nsSHEntry& aOther)
|
|
|
|
: mShared(aOther.mShared),
|
|
|
|
mURI(aOther.mURI),
|
2015-09-30 09:54:39 +03:00
|
|
|
mOriginalURI(aOther.mOriginalURI),
|
2017-07-29 20:04:39 +03:00
|
|
|
mResultPrincipalURI(aOther.mResultPrincipalURI),
|
2019-02-12 22:35:32 +03:00
|
|
|
mReferrerInfo(aOther.mReferrerInfo),
|
2015-05-06 20:57:23 +03:00
|
|
|
mTitle(aOther.mTitle),
|
|
|
|
mPostData(aOther.mPostData),
|
2005-08-18 15:16:54 +04:00
|
|
|
mLoadType(0) // XXX why not copy?
|
|
|
|
,
|
2015-05-06 20:57:23 +03:00
|
|
|
mID(aOther.mID),
|
2005-08-18 15:16:54 +04:00
|
|
|
mScrollPositionX(0) // XXX why not copy?
|
|
|
|
,
|
|
|
|
mScrollPositionY(0) // XXX why not copy?
|
2015-05-06 20:57:23 +03:00
|
|
|
,
|
|
|
|
mParent(aOther.mParent),
|
|
|
|
mStateData(aOther.mStateData),
|
|
|
|
mSrcdocData(aOther.mSrcdocData),
|
|
|
|
mBaseURI(aOther.mBaseURI),
|
2017-04-27 13:16:46 +03:00
|
|
|
mLoadReplace(aOther.mLoadReplace),
|
|
|
|
mURIWasModified(aOther.mURIWasModified),
|
|
|
|
mIsSrcdocEntry(aOther.mIsSrcdocEntry),
|
|
|
|
mScrollRestorationIsManual(false),
|
2017-05-18 14:08:56 +03:00
|
|
|
mLoadedInThisProcess(aOther.mLoadedInThisProcess),
|
2018-09-14 04:09:19 +03:00
|
|
|
mPersist(aOther.mPersist) {}
|
2018-11-30 13:46:48 +03:00
|
|
|
|
2005-08-18 15:17:00 +04:00
|
|
|
nsSHEntry::~nsSHEntry() {
|
2011-10-21 19:26:34 +04:00
|
|
|
// Null out the mParent pointers on all our kids.
|
2017-02-24 13:32:20 +03:00
|
|
|
for (nsISHEntry* entry : mChildren) {
|
|
|
|
if (entry) {
|
|
|
|
entry->SetParent(nullptr);
|
|
|
|
}
|
|
|
|
}
|
2005-08-18 15:17:00 +04:00
|
|
|
}
|
|
|
|
|
2018-08-22 12:20:56 +03:00
|
|
|
NS_IMPL_ISUPPORTS(nsSHEntry, nsISHEntry)
|
1999-12-23 01:35:31 +03:00
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetScrollPosition(int32_t aX, int32_t aY) {
|
|
|
|
mScrollPositionX = aX;
|
|
|
|
mScrollPositionY = aY;
|
2005-08-18 15:16:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetScrollPosition(int32_t* aX, int32_t* aY) {
|
|
|
|
*aX = mScrollPositionX;
|
|
|
|
*aY = mScrollPositionY;
|
2005-08-18 15:16:37 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
1999-12-23 01:35:31 +03:00
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetURIWasModified(bool* aOut) {
|
2011-07-07 17:12:14 +04:00
|
|
|
*aOut = mURIWasModified;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetURIWasModified(bool aIn) {
|
2011-07-07 17:12:14 +04:00
|
|
|
mURIWasModified = aIn;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetURI(nsIURI** aURI) {
|
2005-08-18 15:16:54 +04:00
|
|
|
*aURI = mURI;
|
|
|
|
NS_IF_ADDREF(*aURI);
|
|
|
|
return NS_OK;
|
2005-08-18 15:15:31 +04:00
|
|
|
}
|
1999-12-23 01:35:31 +03:00
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetURI(nsIURI* aURI) {
|
2005-08-18 15:16:54 +04:00
|
|
|
mURI = aURI;
|
|
|
|
return NS_OK;
|
1999-12-23 01:35:31 +03:00
|
|
|
}
|
|
|
|
|
2015-09-30 09:54:39 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetOriginalURI(nsIURI** aOriginalURI) {
|
|
|
|
*aOriginalURI = mOriginalURI;
|
|
|
|
NS_IF_ADDREF(*aOriginalURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetOriginalURI(nsIURI* aOriginalURI) {
|
|
|
|
mOriginalURI = aOriginalURI;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-30 19:07:59 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetResultPrincipalURI(nsIURI** aResultPrincipalURI) {
|
|
|
|
*aResultPrincipalURI = mResultPrincipalURI;
|
|
|
|
NS_IF_ADDREF(*aResultPrincipalURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetResultPrincipalURI(nsIURI* aResultPrincipalURI) {
|
|
|
|
mResultPrincipalURI = aResultPrincipalURI;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-06-28 11:03:25 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetLoadReplace(bool* aLoadReplace) {
|
|
|
|
*aLoadReplace = mLoadReplace;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetLoadReplace(bool aLoadReplace) {
|
|
|
|
mLoadReplace = aLoadReplace;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
2019-02-12 22:35:32 +03:00
|
|
|
nsSHEntry::GetReferrerInfo(nsIReferrerInfo** aReferrerInfo) {
|
|
|
|
*aReferrerInfo = mReferrerInfo;
|
|
|
|
NS_IF_ADDREF(*aReferrerInfo);
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
2005-08-18 15:16:10 +04:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
2019-02-12 22:35:32 +03:00
|
|
|
nsSHEntry::SetReferrerInfo(nsIReferrerInfo* aReferrerInfo) {
|
|
|
|
mReferrerInfo = aReferrerInfo;
|
2014-11-18 16:46:29 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-18 15:17:00 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::SetContentViewer(nsIContentViewer* aViewer) {
|
2011-10-21 19:26:34 +04:00
|
|
|
return mShared->SetContentViewer(aViewer);
|
1999-12-23 01:35:31 +03:00
|
|
|
}
|
|
|
|
|
2005-08-18 15:17:00 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetContentViewer(nsIContentViewer** aResult) {
|
2011-10-21 19:26:34 +04:00
|
|
|
*aResult = mShared->mContentViewer;
|
2005-08-18 15:16:54 +04:00
|
|
|
NS_IF_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
1999-12-23 01:35:31 +03:00
|
|
|
}
|
|
|
|
|
2005-09-23 22:16:40 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetAnyContentViewer(nsISHEntry** aOwnerEntry,
|
|
|
|
nsIContentViewer** aResult) {
|
2005-09-23 22:16:40 +04:00
|
|
|
// Find a content viewer in the root node or any of its children,
|
|
|
|
// assuming that there is only one content viewer total in any one
|
|
|
|
// nsSHEntry tree
|
2018-09-07 04:56:23 +03:00
|
|
|
nsCOMPtr<nsIContentViewer> viewer = GetContentViewer();
|
|
|
|
viewer.forget(aResult);
|
2005-09-23 22:16:40 +04:00
|
|
|
if (*aResult) {
|
2015-05-06 20:57:23 +03:00
|
|
|
#ifdef DEBUG_PAGE_CACHE
|
2005-09-23 22:16:40 +04:00
|
|
|
printf("Found content viewer\n");
|
|
|
|
#endif
|
|
|
|
*aOwnerEntry = this;
|
|
|
|
NS_ADDREF(*aOwnerEntry);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
// The root SHEntry doesn't have a ContentViewer, so check child nodes
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = 0; i < mChildren.Count(); i++) {
|
2005-09-23 22:16:40 +04:00
|
|
|
nsISHEntry* child = mChildren[i];
|
|
|
|
if (child) {
|
|
|
|
#ifdef DEBUG_PAGE_CACHE
|
|
|
|
printf("Evaluating SHEntry child %d\n", i);
|
|
|
|
#endif
|
|
|
|
child->GetAnyContentViewer(aOwnerEntry, aResult);
|
|
|
|
if (*aResult) {
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-18 15:17:00 +04:00
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsSHEntry::SetSticky(bool aSticky) {
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mSticky = aSticky;
|
2005-08-18 15:17:00 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetSticky(bool* aSticky) {
|
2011-10-21 19:26:34 +04:00
|
|
|
*aSticky = mShared->mSticky;
|
2005-08-18 15:17:00 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
2018-09-05 04:29:36 +03:00
|
|
|
nsSHEntry::GetTitle(nsAString& aTitle) {
|
2005-08-18 15:16:54 +04:00
|
|
|
// Check for empty title...
|
|
|
|
if (mTitle.IsEmpty() && mURI) {
|
|
|
|
// Default title is the URL.
|
2012-09-02 06:35:17 +04:00
|
|
|
nsAutoCString spec;
|
2015-05-06 20:57:23 +03:00
|
|
|
if (NS_SUCCEEDED(mURI->GetSpec(spec))) {
|
2005-08-18 15:16:54 +04:00
|
|
|
AppendUTF8toUTF16(spec, mTitle);
|
2015-05-06 20:57:23 +03:00
|
|
|
}
|
2005-08-18 15:16:54 +04:00
|
|
|
}
|
2005-08-18 15:15:49 +04:00
|
|
|
|
2018-09-05 04:29:36 +03:00
|
|
|
aTitle = mTitle;
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
1999-12-23 01:35:31 +03:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetTitle(const nsAString& aTitle) {
|
2005-08-18 15:16:54 +04:00
|
|
|
mTitle = aTitle;
|
|
|
|
return NS_OK;
|
1999-12-23 01:35:31 +03:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetPostData(nsIInputStream** aResult) {
|
2005-08-18 15:16:54 +04:00
|
|
|
*aResult = mPostData;
|
|
|
|
NS_IF_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
1999-12-23 01:35:31 +03:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetPostData(nsIInputStream* aPostData) {
|
2005-08-18 15:16:54 +04:00
|
|
|
mPostData = aPostData;
|
|
|
|
return NS_OK;
|
1999-12-23 01:35:31 +03:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetLayoutHistoryState(nsILayoutHistoryState** aResult) {
|
2011-10-21 19:26:34 +04:00
|
|
|
*aResult = mShared->mLayoutHistoryState;
|
2005-08-18 15:16:54 +04:00
|
|
|
NS_IF_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
1999-12-23 01:35:31 +03:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetLayoutHistoryState(nsILayoutHistoryState* aState) {
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mLayoutHistoryState = aState;
|
|
|
|
if (mShared->mLayoutHistoryState) {
|
2015-05-06 20:57:23 +03:00
|
|
|
mShared->mLayoutHistoryState->SetScrollPositionOnly(
|
|
|
|
!mShared->mSaveLayoutState);
|
2011-10-21 19:26:34 +04:00
|
|
|
}
|
2008-12-03 20:55:14 +03:00
|
|
|
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
1999-12-23 01:35:31 +03:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
2017-03-25 16:01:29 +03:00
|
|
|
nsSHEntry::InitLayoutHistoryState(nsILayoutHistoryState** aState) {
|
|
|
|
if (!mShared->mLayoutHistoryState) {
|
|
|
|
nsCOMPtr<nsILayoutHistoryState> historyState;
|
|
|
|
historyState = NS_NewLayoutHistoryState();
|
2018-09-07 04:56:23 +03:00
|
|
|
SetLayoutHistoryState(historyState);
|
2017-03-25 16:01:29 +03:00
|
|
|
}
|
|
|
|
|
2018-09-07 04:56:23 +03:00
|
|
|
nsCOMPtr<nsILayoutHistoryState> state = GetLayoutHistoryState();
|
|
|
|
state.forget(aState);
|
|
|
|
return NS_OK;
|
2017-03-25 16:01:29 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetLoadType(uint32_t* aResult) {
|
2005-08-18 15:16:54 +04:00
|
|
|
*aResult = mLoadType;
|
|
|
|
return NS_OK;
|
2005-08-18 15:15:52 +04:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetLoadType(uint32_t aLoadType) {
|
2005-08-18 15:16:54 +04:00
|
|
|
mLoadType = aLoadType;
|
|
|
|
return NS_OK;
|
2005-08-18 15:15:52 +04:00
|
|
|
}
|
2005-08-18 15:15:34 +04:00
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetID(uint32_t* aResult) {
|
2005-08-18 15:16:54 +04:00
|
|
|
*aResult = mID;
|
|
|
|
return NS_OK;
|
2005-08-18 15:15:58 +04:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetID(uint32_t aID) {
|
2005-08-18 15:16:54 +04:00
|
|
|
mID = aID;
|
|
|
|
return NS_OK;
|
2005-08-18 15:15:58 +04:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntryShared* nsSHEntry::GetSharedState() { return mShared; }
|
2009-09-01 20:45:05 +04:00
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetIsSubFrame(bool* aFlag) {
|
2011-10-21 19:26:34 +04:00
|
|
|
*aFlag = mShared->mIsFrameNavigation;
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
2005-08-18 15:16:01 +04:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetIsSubFrame(bool aFlag) {
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mIsFrameNavigation = aFlag;
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
2005-08-18 15:16:01 +04:00
|
|
|
}
|
2005-08-18 15:16:09 +04:00
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
2018-03-06 06:19:42 +03:00
|
|
|
nsSHEntry::GetCacheKey(uint32_t* aResult) {
|
2011-10-21 19:26:34 +04:00
|
|
|
*aResult = mShared->mCacheKey;
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
2005-08-18 15:16:09 +04:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
2018-03-06 06:19:42 +03:00
|
|
|
nsSHEntry::SetCacheKey(uint32_t aCacheKey) {
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mCacheKey = aCacheKey;
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
2005-08-18 15:16:09 +04:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetSaveLayoutStateFlag(bool* aFlag) {
|
2011-10-21 19:26:34 +04:00
|
|
|
*aFlag = mShared->mSaveLayoutState;
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
2005-08-18 15:16:12 +04:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetSaveLayoutStateFlag(bool aFlag) {
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mSaveLayoutState = aFlag;
|
|
|
|
if (mShared->mLayoutHistoryState) {
|
|
|
|
mShared->mLayoutHistoryState->SetScrollPositionOnly(!aFlag);
|
|
|
|
}
|
2005-08-18 15:16:48 +04:00
|
|
|
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
2005-08-18 15:16:12 +04:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetExpirationStatus(bool* aFlag) {
|
2011-10-21 19:26:34 +04:00
|
|
|
*aFlag = mShared->mExpired;
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
2005-08-18 15:16:14 +04:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetExpirationStatus(bool aFlag) {
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mExpired = aFlag;
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
2005-08-18 15:16:14 +04:00
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetContentType(nsACString& aContentType) {
|
2011-10-21 19:26:34 +04:00
|
|
|
aContentType = mShared->mContentType;
|
2005-08-18 15:16:43 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetContentType(const nsACString& aContentType) {
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mContentType = aContentType;
|
2005-08-18 15:16:43 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-18 15:16:36 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::Create(nsIURI* aURI, const nsAString& aTitle,
|
|
|
|
nsIInputStream* aInputStream,
|
|
|
|
nsILayoutHistoryState* aLayoutHistoryState,
|
2018-03-06 06:19:42 +03:00
|
|
|
uint32_t aCacheKey, const nsACString& aContentType,
|
2016-09-20 09:36:25 +03:00
|
|
|
nsIPrincipal* aTriggeringPrincipal,
|
2019-02-21 18:00:32 +03:00
|
|
|
nsIPrincipal* aPrincipalToInherit,
|
|
|
|
nsIContentSecurityPolicy* aCsp, const nsID& aDocShellID,
|
2015-05-06 20:57:23 +03:00
|
|
|
bool aDynamicCreation) {
|
2017-01-27 13:19:13 +03:00
|
|
|
MOZ_ASSERT(
|
|
|
|
aTriggeringPrincipal,
|
|
|
|
"need a valid triggeringPrincipal to create a session history entry");
|
|
|
|
|
2005-08-18 15:16:54 +04:00
|
|
|
mURI = aURI;
|
|
|
|
mTitle = aTitle;
|
|
|
|
mPostData = aInputStream;
|
2009-09-01 20:45:05 +04:00
|
|
|
|
2005-08-18 15:16:09 +04:00
|
|
|
// Set the LoadType by default to loadHistory during creation
|
2018-07-03 02:32:47 +03:00
|
|
|
mLoadType = LOAD_HISTORY;
|
2005-08-18 15:16:01 +04:00
|
|
|
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mCacheKey = aCacheKey;
|
|
|
|
mShared->mContentType = aContentType;
|
2016-07-28 10:20:41 +03:00
|
|
|
mShared->mTriggeringPrincipal = aTriggeringPrincipal;
|
2016-09-20 09:36:25 +03:00
|
|
|
mShared->mPrincipalToInherit = aPrincipalToInherit;
|
2019-02-21 18:00:32 +03:00
|
|
|
mShared->mCsp = aCsp;
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mDocShellID = aDocShellID;
|
|
|
|
mShared->mDynamicallyCreated = aDynamicCreation;
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
// By default all entries are set false for subframe flag.
|
2005-08-18 15:16:09 +04:00
|
|
|
// nsDocShell::CloneAndReplace() which creates entries for
|
|
|
|
// all subframe navigations, sets the flag to true.
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mIsFrameNavigation = false;
|
2005-08-18 15:16:01 +04:00
|
|
|
|
2005-08-18 15:17:00 +04:00
|
|
|
// By default we save LayoutHistoryState
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mSaveLayoutState = true;
|
|
|
|
mShared->mLayoutHistoryState = aLayoutHistoryState;
|
2005-08-18 15:16:12 +04:00
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
// By default the page is not expired
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mExpired = false;
|
2005-08-18 15:16:14 +04:00
|
|
|
|
2013-07-16 18:32:39 +04:00
|
|
|
mIsSrcdocEntry = false;
|
2017-09-22 07:35:46 +03:00
|
|
|
mSrcdocData = VoidString();
|
2013-07-16 18:32:39 +04:00
|
|
|
|
2017-05-18 14:08:56 +03:00
|
|
|
mLoadedInThisProcess = true;
|
|
|
|
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
1999-12-23 01:35:31 +03:00
|
|
|
}
|
2005-08-18 15:15:34 +04:00
|
|
|
|
2005-08-18 15:16:36 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::Clone(nsISHEntry** aResult) {
|
2005-08-18 15:16:54 +04:00
|
|
|
*aResult = new nsSHEntry(*this);
|
|
|
|
NS_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
2005-08-18 15:16:36 +04:00
|
|
|
}
|
|
|
|
|
2005-08-18 15:15:34 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetParent(nsISHEntry** aResult) {
|
2011-11-01 06:33:24 +04:00
|
|
|
*aResult = mParent;
|
2005-08-18 15:15:34 +04:00
|
|
|
NS_IF_ADDREF(*aResult);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::SetParent(nsISHEntry* aParent) {
|
2005-08-18 15:16:54 +04:00
|
|
|
/* parent not Addrefed on purpose to avoid cyclic reference
|
|
|
|
* Null parent is OK
|
|
|
|
*
|
|
|
|
* XXX this method should not be scriptable if this is the case!!
|
|
|
|
*/
|
2011-11-01 06:33:24 +04:00
|
|
|
mParent = aParent;
|
2005-08-18 15:15:34 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2005-08-18 15:17:00 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::SetWindowState(nsISupports* aState) {
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mWindowState = aState;
|
2005-08-18 15:17:00 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetWindowState(nsISupports** aState) {
|
2011-10-21 19:26:34 +04:00
|
|
|
NS_IF_ADDREF(*aState = mShared->mWindowState);
|
2005-08-18 15:17:00 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-09-07 04:56:23 +03:00
|
|
|
NS_IMETHODIMP_(void)
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::SetViewerBounds(const nsIntRect& aBounds) {
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mViewerBounds = aBounds;
|
2005-08-18 15:17:00 +04:00
|
|
|
}
|
|
|
|
|
2018-09-07 04:56:23 +03:00
|
|
|
NS_IMETHODIMP_(void)
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetViewerBounds(nsIntRect& aBounds) {
|
2011-10-21 19:26:34 +04:00
|
|
|
aBounds = mShared->mViewerBounds;
|
2006-06-20 01:08:45 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2016-07-28 10:20:41 +03:00
|
|
|
nsSHEntry::GetTriggeringPrincipal(nsIPrincipal** aTriggeringPrincipal) {
|
|
|
|
NS_IF_ADDREF(*aTriggeringPrincipal = mShared->mTriggeringPrincipal);
|
2005-08-18 15:17:00 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2007-09-18 02:27:17 +04:00
|
|
|
NS_IMETHODIMP
|
2016-07-28 10:20:41 +03:00
|
|
|
nsSHEntry::SetTriggeringPrincipal(nsIPrincipal* aTriggeringPrincipal) {
|
|
|
|
mShared->mTriggeringPrincipal = aTriggeringPrincipal;
|
2011-10-21 19:26:34 +04:00
|
|
|
return NS_OK;
|
2016-09-20 09:36:25 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetPrincipalToInherit(nsIPrincipal** aPrincipalToInherit) {
|
|
|
|
NS_IF_ADDREF(*aPrincipalToInherit = mShared->mPrincipalToInherit);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetPrincipalToInherit(nsIPrincipal* aPrincipalToInherit) {
|
|
|
|
mShared->mPrincipalToInherit = aPrincipalToInherit;
|
|
|
|
return NS_OK;
|
2011-10-21 19:26:34 +04:00
|
|
|
}
|
|
|
|
|
2019-02-21 18:00:32 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetCsp(nsIContentSecurityPolicy** aCsp) {
|
|
|
|
NS_IF_ADDREF(*aCsp = mShared->mCsp);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetCsp(nsIContentSecurityPolicy* aCsp) {
|
|
|
|
mShared->mCsp = aCsp;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-10-21 19:26:34 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetBFCacheEntry(nsIBFCacheEntry** aEntry) {
|
2011-10-21 19:26:34 +04:00
|
|
|
NS_IF_ADDREF(*aEntry = mShared);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
bool nsSHEntry::HasBFCacheEntry(nsIBFCacheEntry* aEntry) {
|
2011-10-21 19:26:34 +04:00
|
|
|
return static_cast<nsIBFCacheEntry*>(mShared) == aEntry;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::AdoptBFCacheEntry(nsISHEntry* aEntry) {
|
2018-08-22 12:13:57 +03:00
|
|
|
nsSHEntryShared* shared = aEntry->GetSharedState();
|
2011-10-21 19:26:34 +04:00
|
|
|
NS_ENSURE_STATE(shared);
|
|
|
|
|
|
|
|
mShared = shared;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::SharesDocumentWith(nsISHEntry* aEntry, bool* aOut) {
|
2011-10-21 19:26:34 +04:00
|
|
|
NS_ENSURE_ARG_POINTER(aOut);
|
|
|
|
|
2018-08-22 12:13:57 +03:00
|
|
|
*aOut = mShared == aEntry->GetSharedState();
|
2011-10-21 19:26:34 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::AbandonBFCacheEntry() {
|
|
|
|
mShared = nsSHEntryShared::Duplicate(mShared);
|
2007-09-18 02:27:17 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2013-06-29 07:13:22 +04:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetIsSrcdocEntry(bool* aIsSrcdocEntry) {
|
|
|
|
*aIsSrcdocEntry = mIsSrcdocEntry;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetSrcdocData(nsAString& aSrcdocData) {
|
2013-06-29 07:13:22 +04:00
|
|
|
aSrcdocData = mSrcdocData;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::SetSrcdocData(const nsAString& aSrcdocData) {
|
2013-06-29 07:13:22 +04:00
|
|
|
mSrcdocData = aSrcdocData;
|
|
|
|
mIsSrcdocEntry = true;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2014-02-06 18:46:29 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetBaseURI(nsIURI** aBaseURI) {
|
2014-02-06 18:46:29 +04:00
|
|
|
*aBaseURI = mBaseURI;
|
|
|
|
NS_IF_ADDREF(*aBaseURI);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-06-29 07:13:22 +04:00
|
|
|
|
2014-02-06 18:46:29 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::SetBaseURI(nsIURI* aBaseURI) {
|
2014-02-06 18:46:29 +04:00
|
|
|
mBaseURI = aBaseURI;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2013-06-29 07:13:22 +04:00
|
|
|
|
2015-12-26 13:59:09 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetScrollRestorationIsManual(bool* aIsManual) {
|
|
|
|
*aIsManual = mScrollRestorationIsManual;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetScrollRestorationIsManual(bool aIsManual) {
|
|
|
|
mScrollRestorationIsManual = aIsManual;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-05-18 14:08:56 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetLoadedInThisProcess(bool* aLoadedInThisProcess) {
|
|
|
|
*aLoadedInThisProcess = mLoadedInThisProcess;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetChildCount(int32_t* aCount) {
|
2005-08-18 15:16:54 +04:00
|
|
|
*aCount = mChildren.Count();
|
|
|
|
return NS_OK;
|
2005-08-18 15:15:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::AddChild(nsISHEntry* aChild, int32_t aOffset) {
|
2010-08-17 18:13:55 +04:00
|
|
|
if (aChild) {
|
|
|
|
NS_ENSURE_SUCCESS(aChild->SetParent(this), NS_ERROR_FAILURE);
|
|
|
|
}
|
2005-08-18 15:15:34 +04:00
|
|
|
|
2010-08-17 18:13:55 +04:00
|
|
|
if (aOffset < 0) {
|
|
|
|
mChildren.AppendObject(aChild);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2005-08-18 15:16:42 +04:00
|
|
|
|
2005-08-18 15:16:54 +04:00
|
|
|
//
|
|
|
|
// Bug 52670: Ensure children are added in order.
|
|
|
|
//
|
|
|
|
// Later frames in the child list may load faster and get appended
|
|
|
|
// before earlier frames, causing session history to be scrambled.
|
|
|
|
// By growing the list here, they are added to the right position.
|
|
|
|
//
|
|
|
|
// Assert that aOffset will not be so high as to grow us a lot.
|
|
|
|
//
|
2015-05-06 20:57:23 +03:00
|
|
|
NS_ASSERTION(aOffset < (mChildren.Count() + 1023), "Large frames array!\n");
|
2005-08-18 15:16:13 +04:00
|
|
|
|
2018-09-12 04:59:06 +03:00
|
|
|
bool newChildIsDyn = aChild ? aChild->IsDynamicallyAdded() : false;
|
2010-08-17 18:13:55 +04:00
|
|
|
|
2011-03-24 15:23:36 +03:00
|
|
|
// If the new child is dynamically added, try to add it to aOffset, but if
|
|
|
|
// there are non-dynamically added children, the child must be after those.
|
|
|
|
if (newChildIsDyn) {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t lastNonDyn = aOffset - 1;
|
|
|
|
for (int32_t i = aOffset; i < mChildren.Count(); ++i) {
|
2011-03-24 15:23:36 +03:00
|
|
|
nsISHEntry* entry = mChildren[i];
|
|
|
|
if (entry) {
|
2018-09-12 04:59:06 +03:00
|
|
|
if (entry->IsDynamicallyAdded()) {
|
2011-03-24 15:23:36 +03:00
|
|
|
break;
|
|
|
|
} else {
|
|
|
|
lastNonDyn = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// InsertObjectAt allows only appending one object.
|
|
|
|
// If aOffset is larger than Count(), we must first manually
|
|
|
|
// set the capacity.
|
|
|
|
if (aOffset > mChildren.Count()) {
|
|
|
|
mChildren.SetCount(aOffset);
|
|
|
|
}
|
|
|
|
if (!mChildren.InsertObjectAt(aChild, lastNonDyn + 1)) {
|
|
|
|
NS_WARNING("Adding a child failed!");
|
2012-07-30 18:20:58 +04:00
|
|
|
aChild->SetParent(nullptr);
|
2011-03-24 15:23:36 +03:00
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// If the new child isn't dynamically added, it should be set to aOffset.
|
|
|
|
// If there are dynamically added children before that, those must be
|
|
|
|
// moved to be after aOffset.
|
|
|
|
if (mChildren.Count() > 0) {
|
2013-01-15 16:22:03 +04:00
|
|
|
int32_t start = std::min(mChildren.Count() - 1, aOffset);
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t dynEntryIndex = -1;
|
2012-07-30 18:20:58 +04:00
|
|
|
nsISHEntry* dynEntry = nullptr;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = start; i >= 0; --i) {
|
2011-03-24 15:23:36 +03:00
|
|
|
nsISHEntry* entry = mChildren[i];
|
|
|
|
if (entry) {
|
2018-09-12 04:59:06 +03:00
|
|
|
if (entry->IsDynamicallyAdded()) {
|
2011-03-24 15:23:36 +03:00
|
|
|
dynEntryIndex = i;
|
|
|
|
dynEntry = entry;
|
|
|
|
} else {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2015-05-06 20:57:23 +03:00
|
|
|
|
2011-03-24 15:23:36 +03:00
|
|
|
if (dynEntry) {
|
|
|
|
nsCOMArray<nsISHEntry> tmp;
|
|
|
|
tmp.SetCount(aOffset - dynEntryIndex + 1);
|
|
|
|
mChildren.InsertObjectsAt(tmp, dynEntryIndex);
|
|
|
|
NS_ASSERTION(mChildren[aOffset + 1] == dynEntry, "Whaat?");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Make sure there isn't anything at aOffset.
|
|
|
|
if (aOffset < mChildren.Count()) {
|
|
|
|
nsISHEntry* oldChild = mChildren[aOffset];
|
|
|
|
if (oldChild && oldChild != aChild) {
|
|
|
|
NS_ERROR(
|
|
|
|
"Adding a child where we already have a child? This may misbehave");
|
2012-07-30 18:20:58 +04:00
|
|
|
oldChild->SetParent(nullptr);
|
2011-03-24 15:23:36 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 17:20:00 +03:00
|
|
|
mChildren.ReplaceObjectAt(aChild, aOffset);
|
2010-08-21 01:26:52 +04:00
|
|
|
}
|
2005-08-18 15:15:34 +04:00
|
|
|
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
2005-08-18 15:15:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::RemoveChild(nsISHEntry* aChild) {
|
2005-08-18 15:16:54 +04:00
|
|
|
NS_ENSURE_TRUE(aChild, NS_ERROR_FAILURE);
|
2011-09-29 10:19:26 +04:00
|
|
|
bool childRemoved = false;
|
2018-09-12 04:59:06 +03:00
|
|
|
if (aChild->IsDynamicallyAdded()) {
|
2010-08-17 18:13:55 +04:00
|
|
|
childRemoved = mChildren.RemoveObject(aChild);
|
|
|
|
} else {
|
2012-08-22 19:56:38 +04:00
|
|
|
int32_t index = mChildren.IndexOfObject(aChild);
|
2010-08-17 18:13:55 +04:00
|
|
|
if (index >= 0) {
|
2017-01-24 09:56:37 +03:00
|
|
|
// Other alive non-dynamic child docshells still keep mChildOffset,
|
|
|
|
// so we don't want to change the indices here.
|
2016-08-02 17:20:00 +03:00
|
|
|
mChildren.ReplaceObjectAt(nullptr, index);
|
|
|
|
childRemoved = true;
|
2010-08-17 18:13:55 +04:00
|
|
|
}
|
|
|
|
}
|
2012-02-01 14:45:53 +04:00
|
|
|
if (childRemoved) {
|
2012-07-30 18:20:58 +04:00
|
|
|
aChild->SetParent(nullptr);
|
2012-02-01 14:45:53 +04:00
|
|
|
|
|
|
|
// reduce the child count, i.e. remove empty children at the end
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = mChildren.Count() - 1; i >= 0 && !mChildren[i]; --i) {
|
2012-02-01 14:45:53 +04:00
|
|
|
if (!mChildren.RemoveObjectAt(i)) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-08-18 15:16:54 +04:00
|
|
|
return NS_OK;
|
2005-08-18 15:15:34 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetChildAt(int32_t aIndex, nsISHEntry** aResult) {
|
2005-08-18 15:16:54 +04:00
|
|
|
if (aIndex >= 0 && aIndex < mChildren.Count()) {
|
|
|
|
*aResult = mChildren[aIndex];
|
2005-08-18 15:16:55 +04:00
|
|
|
// yes, mChildren can have holes in it. AddChild's offset parameter makes
|
|
|
|
// that possible.
|
|
|
|
NS_IF_ADDREF(*aResult);
|
2005-08-18 15:16:54 +04:00
|
|
|
} else {
|
2012-07-30 18:20:58 +04:00
|
|
|
*aResult = nullptr;
|
2005-08-18 15:16:54 +04:00
|
|
|
}
|
|
|
|
return NS_OK;
|
2005-08-18 15:15:34 +04:00
|
|
|
}
|
2005-08-18 15:17:00 +04:00
|
|
|
|
2014-11-13 21:19:20 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::ReplaceChild(nsISHEntry* aNewEntry) {
|
|
|
|
NS_ENSURE_STATE(aNewEntry);
|
|
|
|
|
2016-11-17 00:42:35 +03:00
|
|
|
nsID docshellID = aNewEntry->DocshellID();
|
2014-11-13 21:19:20 +03:00
|
|
|
|
|
|
|
for (int32_t i = 0; i < mChildren.Count(); ++i) {
|
2016-11-17 00:42:35 +03:00
|
|
|
if (mChildren[i] && docshellID == mChildren[i]->DocshellID()) {
|
2014-11-13 21:19:20 +03:00
|
|
|
mChildren[i]->SetParent(nullptr);
|
2016-08-02 17:20:00 +03:00
|
|
|
mChildren.ReplaceObjectAt(aNewEntry, i);
|
|
|
|
return aNewEntry->SetParent(this);
|
2014-11-13 21:19:20 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_ERROR_FAILURE;
|
|
|
|
}
|
|
|
|
|
2018-09-12 04:59:06 +03:00
|
|
|
NS_IMETHODIMP_(void)
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::AddChildShell(nsIDocShellTreeItem* aShell) {
|
2018-09-12 04:59:06 +03:00
|
|
|
MOZ_ASSERT(aShell, "Null child shell added to history entry");
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mChildShells.AppendObject(aShell);
|
2005-08-18 15:17:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::ChildShellAt(int32_t aIndex, nsIDocShellTreeItem** aShell) {
|
2011-10-21 19:26:34 +04:00
|
|
|
NS_IF_ADDREF(*aShell = mShared->mChildShells.SafeObjectAt(aIndex));
|
2005-08-18 15:17:00 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-09-12 04:59:06 +03:00
|
|
|
NS_IMETHODIMP_(void)
|
2011-10-21 19:26:34 +04:00
|
|
|
nsSHEntry::ClearChildShells() { mShared->mChildShells.Clear(); }
|
2005-08-18 15:17:00 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2016-10-10 21:36:41 +03:00
|
|
|
nsSHEntry::GetRefreshURIList(nsIMutableArray** aList) {
|
2011-10-21 19:26:34 +04:00
|
|
|
NS_IF_ADDREF(*aList = mShared->mRefreshURIList);
|
2005-08-18 15:17:00 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2016-10-10 21:36:41 +03:00
|
|
|
nsSHEntry::SetRefreshURIList(nsIMutableArray* aList) {
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mRefreshURIList = aList;
|
2005-08-18 15:17:00 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-09-12 04:59:06 +03:00
|
|
|
NS_IMETHODIMP_(void)
|
2005-08-18 15:17:00 +04:00
|
|
|
nsSHEntry::SyncPresentationState() { mShared->SyncPresentationState(); }
|
2007-09-05 12:22:17 +04:00
|
|
|
|
2008-04-24 01:36:17 +04:00
|
|
|
nsDocShellEditorData* nsSHEntry::ForgetEditorData() {
|
2011-10-21 19:26:34 +04:00
|
|
|
// XXX jlebar Check how this is used.
|
|
|
|
return mShared->mEditorData.forget();
|
2008-04-24 01:36:17 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void nsSHEntry::SetEditorData(nsDocShellEditorData* aData) {
|
2011-10-21 19:26:34 +04:00
|
|
|
NS_ASSERTION(!(aData && mShared->mEditorData),
|
2008-04-24 01:36:17 +04:00
|
|
|
"We're going to overwrite an owning ref!");
|
2011-10-21 19:26:34 +04:00
|
|
|
if (mShared->mEditorData != aData) {
|
|
|
|
mShared->mEditorData = aData;
|
|
|
|
}
|
2008-04-24 01:36:17 +04:00
|
|
|
}
|
|
|
|
|
2012-07-30 18:20:58 +04:00
|
|
|
bool nsSHEntry::HasDetachedEditor() { return mShared->mEditorData != nullptr; }
|
2008-04-24 01:36:17 +04:00
|
|
|
|
2009-09-01 20:45:05 +04:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetStateData(nsIStructuredCloneContainer** aContainer) {
|
2011-04-25 06:30:54 +04:00
|
|
|
NS_IF_ADDREF(*aContainer = mStateData);
|
2009-09-01 20:45:05 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::SetStateData(nsIStructuredCloneContainer* aContainer) {
|
2011-04-25 06:30:54 +04:00
|
|
|
mStateData = aContainer;
|
2009-09-01 20:45:05 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2018-09-12 04:59:06 +03:00
|
|
|
NS_IMETHODIMP_(bool)
|
|
|
|
nsSHEntry::IsDynamicallyAdded() { return mShared->mDynamicallyCreated; }
|
2010-08-17 18:13:55 +04:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2011-09-29 10:19:26 +04:00
|
|
|
nsSHEntry::HasDynamicallyAddedChild(bool* aAdded) {
|
2011-10-17 18:59:28 +04:00
|
|
|
*aAdded = false;
|
2012-08-22 19:56:38 +04:00
|
|
|
for (int32_t i = 0; i < mChildren.Count(); ++i) {
|
2010-08-17 18:13:55 +04:00
|
|
|
nsISHEntry* entry = mChildren[i];
|
|
|
|
if (entry) {
|
2018-09-12 04:59:06 +03:00
|
|
|
*aAdded = entry->IsDynamicallyAdded();
|
2010-08-17 18:13:55 +04:00
|
|
|
if (*aAdded) {
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2016-11-17 00:42:35 +03:00
|
|
|
nsSHEntry::GetDocshellID(nsID** aID) {
|
2017-10-18 02:39:20 +03:00
|
|
|
*aID = mShared->mDocShellID.Clone();
|
2010-08-17 18:13:55 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2016-11-17 00:42:35 +03:00
|
|
|
const nsID nsSHEntry::DocshellID() { return mShared->mDocShellID; }
|
|
|
|
|
2010-08-17 18:13:55 +04:00
|
|
|
NS_IMETHODIMP
|
2016-11-17 00:42:35 +03:00
|
|
|
nsSHEntry::SetDocshellID(const nsID* aID) {
|
|
|
|
mShared->mDocShellID = *aID;
|
2010-08-17 18:13:55 +04:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2011-01-19 22:57:36 +03:00
|
|
|
NS_IMETHODIMP
|
2015-05-06 20:57:23 +03:00
|
|
|
nsSHEntry::GetLastTouched(uint32_t* aLastTouched) {
|
2011-10-21 19:26:34 +04:00
|
|
|
*aLastTouched = mShared->mLastTouched;
|
2011-01-19 22:57:36 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2012-08-22 19:56:38 +04:00
|
|
|
nsSHEntry::SetLastTouched(uint32_t aLastTouched) {
|
2011-10-21 19:26:34 +04:00
|
|
|
mShared->mLastTouched = aLastTouched;
|
2011-01-19 22:57:36 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2017-04-27 13:59:11 +03:00
|
|
|
|
2017-05-22 10:36:06 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetSHistory(nsISHistory** aSHistory) {
|
|
|
|
nsCOMPtr<nsISHistory> shistory(do_QueryReferent(mShared->mSHistory));
|
|
|
|
shistory.forget(aSHistory);
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
2017-04-27 13:59:11 +03:00
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetSHistory(nsISHistory* aSHistory) {
|
2017-05-16 05:54:01 +03:00
|
|
|
nsWeakPtr shistory = do_GetWeakReference(aSHistory);
|
|
|
|
// mSHistory can not be changed once it's set
|
2017-05-22 06:25:54 +03:00
|
|
|
MOZ_ASSERT(!mShared->mSHistory || (mShared->mSHistory == shistory));
|
2017-05-16 05:54:01 +03:00
|
|
|
mShared->mSHistory = shistory;
|
2017-04-27 13:59:11 +03:00
|
|
|
return NS_OK;
|
|
|
|
}
|
2018-07-03 02:32:47 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
2018-09-12 05:54:11 +03:00
|
|
|
nsSHEntry::SetLoadTypeAsHistory() {
|
2018-07-03 02:32:47 +03:00
|
|
|
// Set the LoadType by default to loadHistory during creation
|
|
|
|
mLoadType = LOAD_HISTORY;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
2018-09-05 02:02:37 +03:00
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::GetPersist(bool* aPersist) {
|
|
|
|
*aPersist = mPersist;
|
|
|
|
return NS_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
NS_IMETHODIMP
|
|
|
|
nsSHEntry::SetPersist(bool aPersist) {
|
|
|
|
mPersist = aPersist;
|
|
|
|
return NS_OK;
|
|
|
|
}
|