Commit 71e7900a authored by Peter Van der Beken's avatar Peter Van der Beken
Browse files

Bug 1711544 - Move decision about name resetting to the parent process if...

Bug 1711544 - Move decision about name resetting to the parent process if we're replacing the BC for BFCache in the parent. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D116759
parent 7474b83b
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -258,8 +258,10 @@ void CanonicalBrowsingContext::ReplacedBy(
  if (aRemotenessOptions.mTryUseBFCache) {
    MOZ_ASSERT(!aNewContext->EverAttached());
    aNewContext->mFields.SetWithoutSyncing<IDX_Name>(GetName());
    aNewContext->mFields.SetWithoutSyncing<IDX_HasLoadedNonInitialDocument>(
        GetHasLoadedNonInitialDocument());
    // We don't copy over HasLoadedNonInitialDocument here, we'll actually end
    // up loading a new initial document at this point, before the real load.
    // The real load will then end up setting HasLoadedNonInitialDocument to
    // true.
  }

  if (mSessionHistory) {
+4 −0
Original line number Diff line number Diff line
@@ -494,6 +494,10 @@ class nsDocShell final : public nsDocLoader,

  void SetLoadingSessionHistoryInfo(
      const mozilla::dom::LoadingSessionHistoryInfo& aLoadingInfo);
  const mozilla::dom::LoadingSessionHistoryInfo*
  GetLoadingSessionHistoryInfo() {
    return mLoadingEntry.get();
  }

  already_AddRefed<nsIInputStream> GetPostDataFromCurrentEntry() const;
  mozilla::Maybe<uint32_t> GetCacheKeyFromCurrentEntry() const;
+6 −1
Original line number Diff line number Diff line
@@ -1583,6 +1583,8 @@ void IPDLParamTraits<dom::LoadingSessionHistoryInfo>::Write(
  WriteIPDLParam(aMsg, aActor, aParam.mLoadIsFromSessionHistory);
  WriteIPDLParam(aMsg, aActor, aParam.mRequestedIndex);
  WriteIPDLParam(aMsg, aActor, aParam.mSessionHistoryLength);
  WriteIPDLParam(aMsg, aActor, aParam.mLoadingCurrentActiveEntry);
  WriteIPDLParam(aMsg, aActor, aParam.mForceMaybeResetName);
}

bool IPDLParamTraits<dom::LoadingSessionHistoryInfo>::Read(
@@ -1593,7 +1595,10 @@ bool IPDLParamTraits<dom::LoadingSessionHistoryInfo>::Read(
      !ReadIPDLParam(aMsg, aIter, aActor,
                     &aResult->mLoadIsFromSessionHistory) ||
      !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mRequestedIndex) ||
      !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSessionHistoryLength)) {
      !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mSessionHistoryLength) ||
      !ReadIPDLParam(aMsg, aIter, aActor,
                     &aResult->mLoadingCurrentActiveEntry) ||
      !ReadIPDLParam(aMsg, aIter, aActor, &aResult->mForceMaybeResetName)) {
    aActor->FatalError("Error reading fields for LoadingSessionHistoryInfo");
    return false;
  }
+7 −0
Original line number Diff line number Diff line
@@ -236,6 +236,13 @@ struct LoadingSessionHistoryInfo {
  // If we're loading from the current active entry we want to treat it as not
  // a same-document navigation (see nsDocShell::IsSameDocumentNavigation).
  bool mLoadingCurrentActiveEntry = false;
  // If mForceMaybeResetName.isSome() is true then the parent process has
  // determined whether the BC's name should be cleared and stored in session
  // history (see https://html.spec.whatwg.org/#history-traversal step 4.2).
  // This is used when we're replacing the BC for BFCache in the parent. In
  // other cases mForceMaybeResetName.isSome() will be false and the child
  // process should be able to make that determination itself.
  Maybe<bool> mForceMaybeResetName;
};

// HistoryEntryCounterForBrowsingContext is used to count the number of entries
+5 −1
Original line number Diff line number Diff line
@@ -928,8 +928,9 @@ static void LogEntry(nsISHEntry* aEntry, int32_t aIndex, int32_t aTotal,
  }

  nsCOMPtr<nsIURI> uri = aEntry->GetURI();
  nsAutoString title;
  nsAutoString title, name;
  aEntry->GetTitle(title);
  aEntry->GetName(name);

  SHEntrySharedParentState* shared;
  if (mozilla::SessionHistoryInParent()) {
@@ -961,6 +962,9 @@ static void LogEntry(nsISHEntry* aEntry, int32_t aIndex, int32_t aTotal,
  MOZ_LOG(gSHLog, LogLevel::Debug,
          (" %s%s  Title = %s\n", prefix.get(), childCount > 0 ? "|" : " ",
           NS_LossyConvertUTF16toASCII(title).get()));
  MOZ_LOG(gSHLog, LogLevel::Debug,
          (" %s%s  Name = %s\n", prefix.get(), childCount > 0 ? "|" : " ",
           NS_LossyConvertUTF16toASCII(name).get()));

  nsCOMPtr<nsISHEntry> prevChild;
  for (int32_t i = 0; i < childCount; ++i) {
Loading