0

Speculatively defer page unloading in a PDFiumFormFiller callback.

In PDFiumFormFiller::Form_OnFocusChange(), defer unloading to avoid
triggering code that would unload the page that PDFium still has a
pointer to.

Bug: 1279147
Change-Id: I294b75e6fc9484056c7aba4dbea2457a978041b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3340453
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Commit-Queue: Lei Zhang <thestig@chromium.org>
Cr-Commit-Position: refs/heads/main@{#952001}
This commit is contained in:
Lei Zhang
2021-12-15 17:57:40 +00:00
committed by Chromium LUCI CQ
parent fd6fb40b16
commit 997b23f277

@ -9,6 +9,7 @@
#include <string>
#include <utility>
#include "base/auto_reset.h"
#include "base/bind.h"
#include "base/check_op.h"
#include "base/containers/contains.h"
@ -309,6 +310,9 @@ void PDFiumFormFiller::Form_OnFocusChange(FPDF_FORMFILLINFO* param,
if (!engine->PageIndexInBounds(page_index))
return;
base::AutoReset<bool> defer_page_unload_guard(&engine->defer_page_unload_,
true);
// Maintain viewport if we are updating focus. This is to ensure that we don't
// scroll the focused annotation into view when focus is regained.
if (!engine->updating_focus_)