forked from mozilla/gecko-dev
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
71 changed files
with
16,930 additions
and
358 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
#include "mozilla/dom/PendingGlobalHistoryEntry.h" | ||
|
||
namespace mozilla { | ||
|
||
namespace dom { | ||
|
||
void | ||
PendingGlobalHistoryEntry::VisitURI(nsIURI* aURI, | ||
nsIURI* aLastVisitedURI, | ||
nsIURI* aReferrerURI, | ||
uint32_t aFlags) | ||
{ | ||
URIVisit visit; | ||
visit.mURI = aURI; | ||
visit.mLastVisitedURI = aLastVisitedURI; | ||
visit.mReferrerURI = aReferrerURI; | ||
visit.mFlags = aFlags; | ||
mVisits.AppendElement(Move(visit)); | ||
} | ||
|
||
void | ||
PendingGlobalHistoryEntry::SetURITitle(nsIURI* aURI, | ||
const nsAString& aTitle) | ||
{ | ||
URITitle title; | ||
title.mURI = aURI; | ||
title.mTitle.Assign(aTitle); | ||
mTitles.AppendElement(title); | ||
} | ||
|
||
nsresult | ||
PendingGlobalHistoryEntry::ApplyChanges(IHistory* aHistory) | ||
{ | ||
nsresult rv; | ||
for (const URIVisit& visit : mVisits) { | ||
rv = aHistory->VisitURI(visit.mURI, visit.mLastVisitedURI, visit.mFlags); | ||
NS_ENSURE_SUCCESS(rv, rv); | ||
} | ||
mVisits.Clear(); | ||
|
||
for (const URITitle& title : mTitles) { | ||
aHistory->SetURITitle(title.mURI, title.mTitle); | ||
NS_ENSURE_SUCCESS(rv, rv); | ||
} | ||
mTitles.Clear(); | ||
|
||
return NS_OK; | ||
} | ||
|
||
nsresult | ||
PendingGlobalHistoryEntry::ApplyChanges(nsIGlobalHistory2* aHistory) | ||
{ | ||
nsresult rv; | ||
for (const URIVisit& visit : mVisits) { | ||
bool redirect = (visit.mFlags & IHistory::REDIRECT_TEMPORARY) || | ||
(visit.mFlags & IHistory::REDIRECT_PERMANENT); | ||
bool toplevel = (visit.mFlags & IHistory::TOP_LEVEL); | ||
|
||
rv = aHistory->AddURI(visit.mURI, redirect, toplevel, visit.mReferrerURI); | ||
NS_ENSURE_SUCCESS(rv, rv); | ||
} | ||
mVisits.Clear(); | ||
|
||
for (const URITitle& title : mTitles) { | ||
rv = aHistory->SetPageTitle(title.mURI, title.mTitle); | ||
NS_ENSURE_SUCCESS(rv, rv); | ||
} | ||
mTitles.Clear(); | ||
|
||
return NS_OK; | ||
} | ||
|
||
} // namespace dom | ||
|
||
} // namespace mozilla |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* -*- 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_PendingGlobalHistoryEntry_h_ | ||
#define mozilla_dom_PendingGlobalHistoryEntry_h_ | ||
|
||
#include "mozilla/IHistory.h" | ||
#include "nsIGlobalHistory2.h" | ||
#include "nsIURI.h" | ||
#include "nsCOMPtr.h" | ||
#include "nsString.h" | ||
#include "nsTArray.h" | ||
|
||
namespace mozilla { | ||
|
||
namespace dom { | ||
|
||
// This class acts as a wrapper around a IHistory, in that it can be used to | ||
// record a series of operations on the IHistory, and then play them back at a | ||
// later time. This is used in Prerendering in order to record the Global | ||
// History changes being made by the prerendering docshell and then play them | ||
// back when the docshell is finished rendering. | ||
// | ||
// This class also handles applying the changes to nsIGlobalHistory2. | ||
class PendingGlobalHistoryEntry | ||
{ | ||
public: | ||
void VisitURI(nsIURI* aURI, | ||
nsIURI* aLastVisitedURI, | ||
nsIURI* aReferrerURI, | ||
uint32_t aFlags); | ||
|
||
void SetURITitle(nsIURI* aURI, | ||
const nsAString& aTitle); | ||
|
||
nsresult ApplyChanges(IHistory* aHistory); | ||
|
||
nsresult ApplyChanges(nsIGlobalHistory2* aHistory); | ||
|
||
private: | ||
struct URIVisit | ||
{ | ||
nsCOMPtr<nsIURI> mURI; | ||
nsCOMPtr<nsIURI> mLastVisitedURI; | ||
nsCOMPtr<nsIURI> mReferrerURI; | ||
uint32_t mFlags = 0; | ||
}; | ||
struct URITitle | ||
{ | ||
nsCOMPtr<nsIURI> mURI; | ||
nsString mTitle; | ||
}; | ||
nsTArray<URIVisit> mVisits; | ||
nsTArray<URITitle> mTitles; | ||
}; | ||
|
||
} // namespace dom | ||
|
||
} // namespace mozilla | ||
|
||
#endif // mozilla_dom_PendingGlobalHistoryEntry_h_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.