Bug 1689601, make it possible to call Document::CanSavePresentation non-recursively, r=peterv

Differential Revision: https://phabricator.services.mozilla.com/D105236
This commit is contained in:
Olli Pettay 2021-03-02 12:13:19 +00:00
Родитель aa8606dfbc
Коммит 2835639129
4 изменённых файлов: 15 добавлений и 12 удалений

Просмотреть файл

@ -6938,7 +6938,7 @@ bool nsDocShell::CanSavePresentation(uint32_t aLoadType,
uint16_t bfCacheCombo = 0;
bool canSavePresentation =
doc->CanSavePresentation(aNewRequest, bfCacheCombo);
doc->CanSavePresentation(aNewRequest, bfCacheCombo, true);
MOZ_ASSERT_IF(canSavePresentation, bfCacheCombo == 0);
if (canSavePresentation && doc->IsTopLevelContentDocument()) {
auto* browsingContextGroup = mBrowsingContext->Group();

Просмотреть файл

@ -10634,7 +10634,8 @@ void Document::CollectDescendantDocuments(
}
bool Document::CanSavePresentation(nsIRequest* aNewRequest,
uint16_t& aBFCacheCombo) {
uint16_t& aBFCacheCombo,
bool aIncludeSubdocuments) {
bool ret = true;
if (!IsBFCachingAllowed()) {
@ -10763,16 +10764,16 @@ bool Document::CanSavePresentation(nsIRequest* aNewRequest,
ret = false;
}
if (mSubDocuments) {
if (aIncludeSubdocuments && mSubDocuments) {
for (auto iter = mSubDocuments->Iter(); !iter.Done(); iter.Next()) {
auto entry = static_cast<SubDocMapEntry*>(iter.Get());
Document* subdoc = entry->mSubDocument;
uint16_t subDocBFCacheCombo = 0;
// The aIgnoreRequest we were passed is only for us, so don't pass it on.
bool canCache =
subdoc ? subdoc->CanSavePresentation(nullptr, subDocBFCacheCombo)
: false;
bool canCache = subdoc ? subdoc->CanSavePresentation(
nullptr, subDocBFCacheCombo, true)
: false;
if (!canCache) {
MOZ_LOG(gPageCacheLog, mozilla::LogLevel::Verbose,
("Save of %s blocked due to subdocument blocked", uri.get()));

Просмотреть файл

@ -2319,8 +2319,8 @@ class Document : public nsINode,
/**
* Check whether it is safe to cache the presentation of this document
* and all of its subdocuments. This method checks the following conditions
* recursively:
* and all of its subdocuments (depending on the 3rd param). This method
* checks the following conditions recursively:
* - Some document types, such as plugin documents, cannot be safely cached.
* - If there are any pending requests, we don't allow the presentation
* to be cached. Ideally these requests would be suspended and resumed,
@ -2338,7 +2338,8 @@ class Document : public nsINode,
* combination is when we try to BFCache aNewRequest
*/
virtual bool CanSavePresentation(nsIRequest* aNewRequest,
uint16_t& aBFCacheCombo);
uint16_t& aBFCacheCombo,
bool aIncludeSubdocuments);
virtual nsresult Init();

Просмотреть файл

@ -39,8 +39,8 @@ class PluginDocument final : public MediaDocument, public nsIPluginDocument {
void SetScriptGlobalObject(
nsIScriptGlobalObject* aScriptGlobalObject) override;
bool CanSavePresentation(nsIRequest* aNewRequest,
uint16_t& aBFCacheStatus) override;
bool CanSavePresentation(nsIRequest* aNewRequest, uint16_t& aBFCacheStatus,
bool aIncludeSubdocuments = true) override;
const nsCString& GetType() const { return mMimeType; }
Element* GetPluginContent() { return mPluginContent; }
@ -135,7 +135,8 @@ void PluginDocument::SetScriptGlobalObject(
}
bool PluginDocument::CanSavePresentation(nsIRequest* aNewRequest,
uint16_t& aBFCacheStatus) {
uint16_t& aBFCacheStatus,
bool aIncludeSubdocuments) {
// Full-page plugins cannot be cached, currently, because we don't have
// the stream listener data to feed to the plugin instance.
return false;