[pdf] Defer page unloading in JS callback.
One of the callbacks from PDFium JavaScript into the embedder is to get the current page number. In Chromium, this will trigger a call to CalculateMostVisiblePage that method will determine the visible pages and unload any non-visible pages. But, if the originating JS is on a non-visible page we'll delete the page and annotations associated with that page. This will cause issues as we are currently working with those objects when the JavaScript returns. This Cl defers the page unloading triggered by getting the most visible page until the next event is handled by the Chromium embedder. BUG=chromium:653090 Review-Url: https://codereview.chromium.org/2418533002 Cr-Commit-Position: refs/heads/master@{#424781}
This commit is contained in:
@ -2287,7 +2287,13 @@ int PDFiumEngine::GetMostVisiblePage() {
|
||||
if (in_flight_visible_page_)
|
||||
return *in_flight_visible_page_;
|
||||
|
||||
// We can call GetMostVisiblePage through a callback from PDFium. We have
|
||||
// to defer the page deletion otherwise we could potentially delete the page
|
||||
// that originated the calling JS request and destroy the objects that are
|
||||
// currently being used.
|
||||
defer_page_unload_ = true;
|
||||
CalculateVisiblePages();
|
||||
defer_page_unload_ = false;
|
||||
return most_visible_page_;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user