mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 01:10:08 +02:00
Modify a number of the viewer preferences, whose current default value is 0
, such that they behave as expected with the view history
The intention with preferences such as `sidebarViewOnLoad`/`scrollModeOnLoad`/`spreadModeOnLoad` were always that they should be able to *unconditionally* override their view history counterparts. Due to the way that these preferences were initially implemented[1], trying to e.g. force the sidebar to remain hidden on load cannot be guaranteed[2]. The reason for this is the use of "enumeration values" containing zero, which in hindsight was an unfortunate choice on my part. At this point it's also not as simple as just re-numbering the affected structures, since that would wreak havoc on existing (modified) preferences. The only reasonable solution that I was able to come up with was to change the *default* values of the preferences themselves, but not their actual values or the meaning thereof. As part of the refactoring, the `disablePageMode` preference was combined with the *adjusted* `sidebarViewOnLoad` one, to hopefully reduce confusion by not tracking related state separately. Additionally, the `showPreviousViewOnLoad` and `disableOpenActionDestination` preferences were combined into a *new* `viewOnLoad` enumeration preference, to further avoid tracking related state separately.
This commit is contained in:
parent
dd4620530d
commit
6806248030
9 changed files with 132 additions and 90 deletions
|
@ -41,6 +41,20 @@ const TextLayerMode = {
|
|||
ENABLE_ENHANCE: 2,
|
||||
};
|
||||
|
||||
const ScrollMode = {
|
||||
UNKNOWN: -1,
|
||||
VERTICAL: 0, // Default value.
|
||||
HORIZONTAL: 1,
|
||||
WRAPPED: 2,
|
||||
};
|
||||
|
||||
const SpreadMode = {
|
||||
UNKNOWN: -1,
|
||||
NONE: 0, // Default value.
|
||||
ODD: 1,
|
||||
EVEN: 2,
|
||||
};
|
||||
|
||||
// Replaces {{arguments}} with their values.
|
||||
function formatL10nValue(text, args) {
|
||||
if (!args) {
|
||||
|
@ -602,6 +616,16 @@ function isValidRotation(angle) {
|
|||
return Number.isInteger(angle) && angle % 90 === 0;
|
||||
}
|
||||
|
||||
function isValidScrollMode(mode) {
|
||||
return (Number.isInteger(mode) && Object.values(ScrollMode).includes(mode) &&
|
||||
mode !== ScrollMode.UNKNOWN);
|
||||
}
|
||||
|
||||
function isValidSpreadMode(mode) {
|
||||
return (Number.isInteger(mode) && Object.values(SpreadMode).includes(mode) &&
|
||||
mode !== SpreadMode.UNKNOWN);
|
||||
}
|
||||
|
||||
function isPortraitOrientation(size) {
|
||||
return size.width <= size.height;
|
||||
}
|
||||
|
@ -863,10 +887,14 @@ export {
|
|||
SCROLLBAR_PADDING,
|
||||
VERTICAL_PADDING,
|
||||
isValidRotation,
|
||||
isValidScrollMode,
|
||||
isValidSpreadMode,
|
||||
isPortraitOrientation,
|
||||
PresentationModeState,
|
||||
RendererType,
|
||||
TextLayerMode,
|
||||
ScrollMode,
|
||||
SpreadMode,
|
||||
NullL10n,
|
||||
EventBus,
|
||||
getGlobalEventBus,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue