Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify a number of the viewer preferences, whose current default value is 0, such that they behave as expected with the view history #10502

Merged
merged 5 commits into from
Feb 4, 2019

Conversation

Snuffleupagus
Copy link
Collaborator

The intention with preferences such as sidebarViewOnLoad/scrollModeOnLoad/spreadModeOnLoad was 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.


[1] This is mostly my fault, since I wrote the initial implementation which has then been used as a template when additional preferences were added.
I've been aware of these problems for quite a while now, and seing issue #10335 provided the final impetus needed to actually try and fix this.

[2] Given that a ViewHistory value may easily override the relevant Preference value.

@Snuffleupagus Snuffleupagus force-pushed the adjust-onLoad-prefs branch 7 times, most recently from fbfb4da to 35f580f Compare January 28, 2019 07:22
@Snuffleupagus Snuffleupagus changed the title [WIP] Modify a number of the viewer preferences, whose currently default value is 0, such that they behave as expected with the view history Modify a number of the viewer preferences, whose current default value is 0, such that they behave as expected with the view history Jan 29, 2019
@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

@Snuffleupagus Snuffleupagus force-pushed the adjust-onLoad-prefs branch 2 times, most recently from 1b94a42 to 0ec4d53 Compare February 2, 2019 09:18
…DFSidebar._switchView` method

The new "private" method will return a boolean, indicating if the `sidebarviewchanged` event was dispatched, thus allowing some simplification of the `PDFSidebar.setInitialView` method.
…e 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.
… preferences to the new `viewOnLoad` preference

This patch ignores the recently added `disableOpenActionDestination` preference, since the latest PDF.js version found on the "Chrome Web Store" doesn't include it.
…erApplication`

This avoids having the initialization code "spread out", and will become even simpler once the `TODO` is addressed (which I'm planning on fixing as soon as possible).
The intention with this change is to, more clearly, highlight when the default values may possibly be overridden by "compatibility" values.
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Feb 2, 2019

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/fa2fbf7e8e5276a/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Feb 2, 2019

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/fa2fbf7e8e5276a/output.txt

Total script time: 1.70 mins

Published

@mozilla mozilla deleted a comment from pdfjsbot Feb 2, 2019
@mozilla mozilla deleted a comment from pdfjsbot Feb 2, 2019
@timvandermeij
Copy link
Contributor

I notice there is migration code for the Chrome extension, but how will the removal of the old preferences work for the version embedded in Firefox? Don't we need some migration code for that as well, i.e., temporarily handle both the old and the new preferences?

@Snuffleupagus
Copy link
Collaborator Author

Snuffleupagus commented Feb 3, 2019

I notice there is migration code for the Chrome extension, but how will the removal of the old preferences work for the version embedded in Firefox?

Honestly, I was kind of hoping not having to bother with general preference migration[1], since it's only in the Chrome extension that the preferences are easily accessible.
In Firefox, the only way that a user has changed any of the PDF.js preferences is manually through about:config, which I'm assuming/hoping is somewhat rare in practice. There's also "prior art" when it comes to not migrating general preferences, see e.g. the textLayerMode pref added in PR #9479.

Don't we need some migration code for that as well, i.e., temporarily handle both the old and the new preferences?

If you insist on migration being necessary here, I really cannot object too strongly though[2].
Given that none of these preferences will outright "break" anything, but rather only (potentially) change the initial view when loading a PDF document, I was simply trying to take the easy way out here :-)


[1] Which unfortunately the BasePreferences class itself, nor the code in PdfStreamConverter.jsm, isn't really well-equipped to handle.

[2] Most likely, with my review hat on, I would've asked the exact same questions.

@timvandermeij
Copy link
Contributor

I agree with this. Changing preferences through about:config is always at the user's own risk since no guarantees are generally made, as far as I know, that the preferences will keep on existing in newer versions. Since these preferences also don't break anything, I'm fine with this.

Copy link
Contributor

@timvandermeij timvandermeij left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good with the minor comment addressed.

web/pdf_sidebar.js Show resolved Hide resolved
@timvandermeij timvandermeij merged commit c0d6e46 into mozilla:master Feb 4, 2019
@timvandermeij
Copy link
Contributor

Thank you for improving this!

@Snuffleupagus Snuffleupagus deleted the adjust-onLoad-prefs branch February 4, 2019 23:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants