Commit 2bc72543 authored by Edgar Chen's avatar Edgar Chen
Browse files

Bug 1718796 - Use DocShell to get last transaction id of root PresContext; r=smaug

parent b8cfdf05
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -2748,12 +2748,24 @@ nsDOMWindowUtils::AdvanceTimeAndRefresh(int64_t aMilliseconds) {

NS_IMETHODIMP
nsDOMWindowUtils::GetLastTransactionId(uint64_t* aLastTransactionId) {
  nsPresContext* presContext = GetPresContext();
  nsCOMPtr<nsIDocShell> docShell = GetDocShell();
  if (!docShell) {
    return NS_ERROR_UNEXPECTED;
  }

  nsCOMPtr<nsIDocShellTreeItem> rootTreeItem;
  docShell->GetInProcessRootTreeItem(getter_AddRefs(rootTreeItem));
  docShell = do_QueryInterface(rootTreeItem);
  if (!docShell) {
    return NS_ERROR_UNEXPECTED;
  }

  nsPresContext* presContext = docShell->GetPresContext();
  if (!presContext) {
    return NS_ERROR_UNEXPECTED;
  }

  nsRefreshDriver* driver = presContext->GetRootPresContext()->RefreshDriver();
  nsRefreshDriver* driver = presContext->RefreshDriver();
  *aLastTransactionId = uint64_t(driver->LastTransactionId());
  return NS_OK;
}