Accept non-matching document fingerprints, in PDFHistory
, when the viewer is reloaded (issue 6847)
This should hopefully be sufficient to address issue 6847, and given the limited impact of the code changes I'm not completely sure if this would need to be controlled by a preference!? Initially my intention was to try and provide some (slightly more detailed) implementation suggestions in the issue, but having looked briefly at doing that it would essentially have amounted to actually writing the code anyway. (Especially considering that the recent questions seemed to more-or-less ignore the information already provided in the first post.) Finally, note that since `performance.navigation.type` is marked as deprecated, a slightly different approach was choosen instead.
This commit is contained in:
parent
968a153180
commit
d46715210a
@ -112,7 +112,7 @@ class PDFHistory {
|
||||
this._destination = null;
|
||||
this._position = null;
|
||||
|
||||
if (!this._isValidState(state) || resetHistory) {
|
||||
if (!this._isValidState(state, /* checkReload = */ true) || resetHistory) {
|
||||
let { hash, page, rotation, } = parseCurrentHash(this.linkService);
|
||||
|
||||
if (!hash || reInitialized || resetHistory) {
|
||||
@ -359,14 +359,27 @@ class PDFHistory {
|
||||
/**
|
||||
* @private
|
||||
*/
|
||||
_isValidState(state) {
|
||||
_isValidState(state, checkReload = false) {
|
||||
if (!state) {
|
||||
return false;
|
||||
}
|
||||
if (state.fingerprint !== this.fingerprint) {
|
||||
// This should only occur in viewers with support for opening more than
|
||||
// one PDF document, e.g. the GENERIC viewer.
|
||||
return false;
|
||||
if (checkReload) {
|
||||
// Potentially accept the history entry, even if the fingerprints don't
|
||||
// match, when the viewer was reloaded (see issue 6847).
|
||||
if (typeof state.fingerprint !== 'string' ||
|
||||
state.fingerprint.length !== this.fingerprint.length) {
|
||||
return false;
|
||||
}
|
||||
const [perfEntry] = performance.getEntriesByType('navigation');
|
||||
if (!perfEntry || perfEntry.type !== 'reload') {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
// This should only occur in viewers with support for opening more than
|
||||
// one PDF document, e.g. the GENERIC viewer.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (!Number.isInteger(state.uid) || state.uid < 0) {
|
||||
return false;
|
||||
|
Loading…
x
Reference in New Issue
Block a user