зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1597499 - Move nsIDocShell::ChildOffset to BrowsingContext, r=nika
Differential Revision: https://phabricator.services.mozilla.com/D89969
This commit is contained in:
Родитель
14f7b0bd69
Коммит
c91bbe8c6d
|
@ -489,6 +489,7 @@ void BrowsingContext::CreateFromIPC(BrowsingContext::IPCInitializer&& aInit,
|
|||
|
||||
context->mWindowless = aInit.mWindowless;
|
||||
context->mCreatedDynamically = aInit.mCreatedDynamically;
|
||||
context->mChildOffset = aInit.mChildOffset;
|
||||
if (context->GetHasSessionHistory()) {
|
||||
context->CreateChildSHistory();
|
||||
if (mozilla::SessionHistoryInParent()) {
|
||||
|
@ -528,7 +529,8 @@ BrowsingContext::BrowsingContext(WindowContext* aParentWindow,
|
|||
mEmbeddedByThisProcess(false),
|
||||
mUseRemoteTabs(false),
|
||||
mUseRemoteSubframes(false),
|
||||
mCreatedDynamically(false) {
|
||||
mCreatedDynamically(false),
|
||||
mChildOffset(0) {
|
||||
MOZ_RELEASE_ASSERT(!mParentWindow || mParentWindow->Group() == mGroup);
|
||||
MOZ_RELEASE_ASSERT(mBrowsingContextId != 0);
|
||||
MOZ_RELEASE_ASSERT(mGroup);
|
||||
|
@ -721,7 +723,8 @@ void BrowsingContext::Attach(bool aFromIPC, ContentParent* aOriginProcess) {
|
|||
MOZ_DIAGNOSTIC_ASSERT(mParentWindow->GetWindowGlobalChild()->CanSend(),
|
||||
"local attach call with dead parent window");
|
||||
}
|
||||
|
||||
mChildOffset =
|
||||
mCreatedDynamically ? -1 : mParentWindow->Children().Length();
|
||||
mParentWindow->AppendChildBrowsingContext(this);
|
||||
} else {
|
||||
mGroup->Toplevels().AppendElement(this);
|
||||
|
@ -2379,6 +2382,7 @@ BrowsingContext::IPCInitializer BrowsingContext::GetIPCInitializer() {
|
|||
init.mUseRemoteTabs = mUseRemoteTabs;
|
||||
init.mUseRemoteSubframes = mUseRemoteSubframes;
|
||||
init.mCreatedDynamically = mCreatedDynamically;
|
||||
init.mChildOffset = mChildOffset;
|
||||
init.mOriginAttributes = mOriginAttributes;
|
||||
if (mChildSessionHistory && mozilla::SessionHistoryInParent()) {
|
||||
init.mSessionHistoryIndex = mChildSessionHistory->Index();
|
||||
|
@ -3397,6 +3401,7 @@ void IPDLParamTraits<dom::BrowsingContext::IPCInitializer>::Write(
|
|||
WriteIPDLParam(aMessage, aActor, aInit.mUseRemoteTabs);
|
||||
WriteIPDLParam(aMessage, aActor, aInit.mUseRemoteSubframes);
|
||||
WriteIPDLParam(aMessage, aActor, aInit.mCreatedDynamically);
|
||||
WriteIPDLParam(aMessage, aActor, aInit.mChildOffset);
|
||||
WriteIPDLParam(aMessage, aActor, aInit.mOriginAttributes);
|
||||
WriteIPDLParam(aMessage, aActor, aInit.mRequestContextId);
|
||||
WriteIPDLParam(aMessage, aActor, aInit.mSessionHistoryIndex);
|
||||
|
@ -3416,6 +3421,7 @@ bool IPDLParamTraits<dom::BrowsingContext::IPCInitializer>::Read(
|
|||
&aInit->mUseRemoteSubframes) ||
|
||||
!ReadIPDLParam(aMessage, aIterator, aActor,
|
||||
&aInit->mCreatedDynamically) ||
|
||||
!ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mChildOffset) ||
|
||||
!ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mOriginAttributes) ||
|
||||
!ReadIPDLParam(aMessage, aIterator, aActor, &aInit->mRequestContextId) ||
|
||||
!ReadIPDLParam(aMessage, aIterator, aActor,
|
||||
|
|
|
@ -677,6 +677,7 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
|||
bool mUseRemoteTabs = false;
|
||||
bool mUseRemoteSubframes = false;
|
||||
bool mCreatedDynamically = false;
|
||||
int32_t mChildOffset = 0;
|
||||
int32_t mSessionHistoryIndex = -1;
|
||||
int32_t mSessionHistoryCount = 0;
|
||||
OriginAttributes mOriginAttributes;
|
||||
|
@ -715,6 +716,8 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
|||
|
||||
bool CreatedDynamically() const { return mCreatedDynamically; }
|
||||
|
||||
int32_t ChildOffset() const { return mChildOffset; }
|
||||
|
||||
const OriginAttributes& OriginAttributesRef() { return mOriginAttributes; }
|
||||
nsresult SetOriginAttributes(const OriginAttributes& aAttrs);
|
||||
|
||||
|
@ -1133,6 +1136,10 @@ class BrowsingContext : public nsILoadContext, public nsWrapperCache {
|
|||
// True if this BrowsingContext is for a frame that was added dynamically.
|
||||
bool mCreatedDynamically : 1;
|
||||
|
||||
// The original offset of this context in its container. This property is -1
|
||||
// if this BrowsingContext is for a frame that was added dynamically.
|
||||
int32_t mChildOffset;
|
||||
|
||||
// The start time of user gesture, this is only available if the browsing
|
||||
// context is in process.
|
||||
TimeStamp mUserGestureStart;
|
||||
|
|
|
@ -376,7 +376,6 @@ nsDocShell::nsDocShell(BrowsingContext* aBrowsingContext,
|
|||
mItemType(aBrowsingContext->IsContent() ? typeContent : typeChrome),
|
||||
mPreviousEntryIndex(-1),
|
||||
mLoadedEntryIndex(-1),
|
||||
mChildOffset(0),
|
||||
mBusyFlags(BUSY_FLAGS_NONE),
|
||||
mAppType(nsIDocShell::APP_TYPE_UNKNOWN),
|
||||
mLoadType(0),
|
||||
|
@ -1023,7 +1022,7 @@ bool nsDocShell::MaybeHandleSubframeHistory(
|
|||
// it wasn't originally for some other frame.
|
||||
nsCOMPtr<nsISHEntry> shEntry;
|
||||
currentSH->GetChildSHEntryIfHasNoDynamicallyAddedChild(
|
||||
mChildOffset, getter_AddRefs(shEntry));
|
||||
mBrowsingContext->ChildOffset(), getter_AddRefs(shEntry));
|
||||
if (shEntry) {
|
||||
aLoadState->SetSHEntry(shEntry);
|
||||
}
|
||||
|
@ -3011,12 +3010,6 @@ nsDocShell::SetTreeOwner(nsIDocShellTreeOwner* aTreeOwner) {
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
void nsDocShell::SetChildOffset(int32_t aChildOffset) {
|
||||
mChildOffset = aChildOffset;
|
||||
}
|
||||
|
||||
int32_t nsDocShell::GetChildOffset() { return mChildOffset; }
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetHistoryID(nsID& aID) {
|
||||
aID = mBrowsingContext->GetHistoryID();
|
||||
|
@ -3070,24 +3063,11 @@ nsDocShell::AddChild(nsIDocShellTreeItem* aChild) {
|
|||
NS_ASSERTION(!mChildList.IsEmpty(),
|
||||
"child list must not be empty after a successful add");
|
||||
|
||||
nsCOMPtr<nsIDocShell> childDocShell = do_QueryInterface(aChild);
|
||||
bool dynamic = nsDocShell::Cast(childDocShell)->GetCreatedDynamically();
|
||||
if (!dynamic) {
|
||||
nsCOMPtr<nsISHEntry> currentSH;
|
||||
bool oshe = false;
|
||||
GetCurrentSHEntry(getter_AddRefs(currentSH), &oshe);
|
||||
if (currentSH) {
|
||||
currentSH->HasDynamicallyAddedChild(&dynamic);
|
||||
}
|
||||
}
|
||||
childDocShell->SetChildOffset(dynamic ? -1 : mChildList.Length() - 1);
|
||||
|
||||
/* Set the child's global history if the parent has one */
|
||||
if (mBrowsingContext->GetUseGlobalHistory()) {
|
||||
// childDocShell->SetUseGlobalHistory(true);
|
||||
// this should be set through BC inherit
|
||||
MOZ_ASSERT(nsDocShell::Cast(childDocShell)
|
||||
->mBrowsingContext->GetUseGlobalHistory());
|
||||
MOZ_ASSERT(aChild->GetBrowsingContext()->GetUseGlobalHistory());
|
||||
}
|
||||
|
||||
if (aChild->ItemType() != mItemType) {
|
||||
|
@ -11865,7 +11845,8 @@ nsresult nsDocShell::AddToSessionHistory(
|
|||
MOZ_ALWAYS_SUCCEEDS(topWc->SetSHEntryHasUserInteraction(false));
|
||||
}
|
||||
if (!mOSHE || !LOAD_TYPE_HAS_FLAGS(mLoadType, LOAD_FLAGS_REPLACE_HISTORY)) {
|
||||
rv = AddChildSHEntryToParent(entry, mChildOffset, aCloneChildren);
|
||||
rv = AddChildSHEntryToParent(entry, mBrowsingContext->ChildOffset(),
|
||||
aCloneChildren);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1202,10 +1202,6 @@ class nsDocShell final : public nsDocLoader,
|
|||
int32_t mPreviousEntryIndex;
|
||||
int32_t mLoadedEntryIndex;
|
||||
|
||||
// Offset in the parent's child list.
|
||||
// -1 if the docshell is added dynamically to the parent shell.
|
||||
int32_t mChildOffset;
|
||||
|
||||
BusyFlags mBusyFlags;
|
||||
AppType mAppType;
|
||||
uint32_t mLoadType;
|
||||
|
|
|
@ -449,12 +449,6 @@ interface nsIDocShell : nsIDocShellTreeItem
|
|||
*/
|
||||
readonly attribute nsIChannel currentDocumentChannel;
|
||||
|
||||
/**
|
||||
* The original offset of this child in its container. This property is -1 for
|
||||
* dynamically added docShells.
|
||||
*/
|
||||
[notxpcom,nostdcall] attribute long childOffset;
|
||||
|
||||
/**
|
||||
* Find out whether the docshell is currently in the middle of a page
|
||||
* transition. This is set just before the pagehide/unload events fire.
|
||||
|
|
|
@ -201,6 +201,8 @@ interface BrowsingContext {
|
|||
|
||||
// Resets the location change rate limit. Used for testing.
|
||||
void resetLocationChangeRateLimit();
|
||||
|
||||
readonly attribute long childOffset;
|
||||
};
|
||||
|
||||
BrowsingContext includes LoadContextMixin;
|
||||
|
|
|
@ -121,18 +121,10 @@ void SessionStoreUtils::ForEachNonDynamicChildFrame(
|
|||
return;
|
||||
}
|
||||
|
||||
if (context->CreatedDynamically()) {
|
||||
continue;
|
||||
if (!context->CreatedDynamically()) {
|
||||
int32_t childOffset = context->ChildOffset();
|
||||
aCallback.Call(WindowProxyHolder(context.forget()), childOffset);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIDocShell> childDocShell(do_QueryInterface(item));
|
||||
if (!childDocShell) {
|
||||
aRv.Throw(NS_ERROR_FAILURE);
|
||||
return;
|
||||
}
|
||||
|
||||
int32_t childOffset = childDocShell->GetChildOffset();
|
||||
aCallback.Call(WindowProxyHolder(context.forget()), childOffset);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче