Add OpenAction destination support, off by default, to the viewer

Given that it's really not clear to me if this is actually desired functionality in the default viewer, and considering that it doesn't fit in *great* with the way that `PDFHistory` is initialized, this feature is currently off by default[1].

---
[1] It's controlled with the `disableOpenActionDestination` Preference/AppOption.
This commit is contained in:
Jonas Jenwald 2018-12-06 18:32:41 +01:00
parent b05f053287
commit a7e70a50f5
6 changed files with 42 additions and 10 deletions

View file

@ -158,16 +158,27 @@ class PDFHistory {
* Push an internal destination to the browser history.
* @param {PushParameters}
*/
push({ namedDest, explicitDest, pageNumber, }) {
push({ namedDest = null, explicitDest, pageNumber, }) {
if (!this.initialized) {
return;
}
if ((namedDest && typeof namedDest !== 'string') ||
!Array.isArray(explicitDest) ||
!(Number.isInteger(pageNumber) &&
pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
console.error('PDFHistory.push: Invalid parameters.');
if (namedDest && typeof namedDest !== 'string') {
console.error('PDFHistory.push: ' +
`"${namedDest}" is not a valid namedDest parameter.`);
return;
} else if (!Array.isArray(explicitDest)) {
console.error('PDFHistory.push: ' +
`"${explicitDest}" is not a valid explicitDest parameter.`);
return;
} else if (!(Number.isInteger(pageNumber) &&
pageNumber > 0 && pageNumber <= this.linkService.pagesCount)) {
// Allow an unset `pageNumber` if and only if the history is still empty;
// please refer to the `this._destination.page = null;` comment above.
if (pageNumber !== null || this._destination) {
console.error('PDFHistory.push: ' +
`"${pageNumber}" is not a valid pageNumber parameter.`);
return;
}
}
let hash = namedDest || JSON.stringify(explicitDest);