pdf.js/web
Jonas Jenwald a2b592f4a2 Add previous/next-page functionality that takes scroll/spread-modes into account (issue 11946)
- For wrapped scrolling, we unfortunately need to do a fair bit of parsing of the *current* page layout. Compared to e.g. the spread-modes, where we can easily tell how the pages are laid out, with wrapped scrolling we cannot tell without actually checking. In particular documents with varying page sizes require some care, since we need to check all pages on the "row" of the current page are visible and that there aren't any "holes" present. Otherwise, in the general case, there's a risk that we'd skip over pages if we'd simply always advance to the previous/next "row" in wrapped scrolling.

 - For horizontal scrolling, this patch simply maintains the current behaviour of advancing *one* page at a time. The reason for this is to prevent inconsistent behaviour for the next and previous cases, since those cannot be handled identically. For the next-case, it'd obviously be simple to advance to the first not completely visible page. However for the previous-case, we'd only be able to go back *one* page since it's not possible to (easily) determine the page layout of non-visible pages (documents with varying page sizes being a particular issue).

 - For vertical scrolling, this patch maintains the current behaviour by default. When spread-modes are being used, we'll now attempt to advance to the next *spread*, rather than just the next page, whenever possible. To prevent skipping over a page, this two-page advance will only apply when both pages of the current spread are visible (to avoid breaking documents with varying page sizes) and when the second page in the current spread is fully visible *horizontally* (to handle larger zoom values).

In order to reduce the performance impact of these changes, note that the previous/next-functionality will only call `getVisibleElements` for the scroll/spread-modes where that's necessary and that "normal" vertical scrolling is thus unaffected by these changes.

To support these changes, the `getVisibleElements` helper function will now also include the `widthPercent` in addition to the existing `percent` property.
The `PDFViewer._updateHelper` method is changed slightly w.r.t. updating the `currentPageNumber` for the non-vertical/spread modes, i.e. won't affect "normal" vertical scrolling, since that helped simplify the overall calculation of the page advance.

Finally, these new `BaseViewer` methods also allow (some) simplification of previous/next-page functionality in various viewer components.

*Please note:* There's one thing that this patch does not attempt to change, namely disabling of the previous/next toolbarButtons respectively the firstPage/lastPage secondaryToolbarButtons. The reason for this is that doing so would add quite a bit of complexity in general, and if for some reason `BaseViewer._getPageAdvance` would get things wrong we could end up incorrectly disabling the buttons. Hence it seemed overall safer to *not* touch this, and accept that the buttons won't be `disabled` despite in some edge-cases no further scrolling being possible.
2021-01-22 21:38:15 +01:00
..
images Add an icon for the "find/highlight the current outlineItem" functionality 2021-01-09 16:09:46 +01:00
.eslintrc Enable the ESLint prefer-const rule globally (PR 11450 follow-up) 2020-01-25 00:20:22 +01:00
.gitignore Remove obselete file from .gitignore 2015-01-26 16:44:45 +01:00
annotation_layer_builder.css Correctly align annotation content in horizontal/spread scrolling modes 2021-01-10 18:58:13 +01:00
annotation_layer_builder.js Tweak the new mouseState parameter, and its usage, in the viewer components and the AnnotationLayer 2020-12-18 22:03:41 +01:00
app_options.js Remove the ENABLE_SCRIPTING build-target, since it's not necessary 2020-12-18 22:10:36 +01:00
app.js Add previous/next-page functionality that takes scroll/spread-modes into account (issue 11946) 2021-01-22 21:38:15 +01:00
base_tree_viewer.js Add support for finding/highlighting the outlineItem, corresponding to the currently visible page, in the sidebar (issue 7557, bug 1253820, bug 1499050) 2021-01-09 16:09:44 +01:00
base_viewer.js Add previous/next-page functionality that takes scroll/spread-modes into account (issue 11946) 2021-01-22 21:38:15 +01:00
chrome-i18n-allow-access-to-file-urls.json Add translations of "Allow access to file URLs" 2015-08-14 18:59:55 +02:00
chromecom.js Pass in the "sandboxBundleSrc" option when calling DefaultExternalServices.createScripting 2020-12-23 14:05:49 +01:00
compressed.tracemonkey-pldi-09.pdf Add Makefile. Move some files around to make building the website easier. 2011-07-05 10:53:57 -07:00
debugger.js Enable the ESLint no-useless-escape rule (PR 12551 follow-up) 2020-11-07 13:06:24 +01:00
download_manager.js Remove the DownloadManager.onerror functionality, since its only usage is unlikely to be helpful 2021-01-02 13:25:42 +01:00
firefox_print_service.js [Firefox] Stop logging RenderingCancelledExceptions as errors when printing 2020-10-04 20:25:31 +02:00
firefoxcom.js Remove the DownloadManager.onerror functionality, since its only usage is unlikely to be helpful 2021-01-02 13:25:42 +01:00
generic_scripting.js Pass in the "sandboxBundleSrc" option when calling DefaultExternalServices.createScripting 2020-12-23 14:05:49 +01:00
genericcom.js Pass in the "sandboxBundleSrc" option when calling DefaultExternalServices.createScripting 2020-12-23 14:05:49 +01:00
genericl10n.js Enable import/extensions of ESlint plugin to enforce all import have a .js file extension. 2020-01-18 10:53:01 +09:00
grab_to_pan.js Remove some code/comments relevant for old (pre-Chromium) versions of Opera 2020-09-08 12:54:51 +02:00
interfaces.js Use ESLint to ensure that exports are sorted alphabetically 2021-01-09 20:37:51 +01:00
overlay_manager.js Fix the linting errors, from the Prettier auto-formatting, that ESLint --fix couldn't handle 2019-12-26 12:35:12 +01:00
password_prompt.js Ensure that all import and require statements, in the entire code-base, have a .js file extension 2020-01-04 13:01:43 +01:00
pdf_attachment_viewer.js Extract common functionality into a new BaseTreeViewer._finishRendering method 2020-12-30 13:48:58 +01:00
pdf_cursor_tools.js Include the state in the "presentationmodechanged" event, and remove the separate active/switchInProgress properties 2020-12-28 20:31:17 +01:00
pdf_document_properties.js Convert the PDFDocumentProperties.open method to be async 2020-11-21 13:54:36 +01:00
pdf_find_bar.js [Generic viewer] Re-factor how the notFound appearance is set on the "findInput" in the PDFFindBar 2020-12-02 15:23:20 +01:00
pdf_find_controller.js [api-minor] Highlight search results correctly for normalized text (PR 9448) 2021-01-12 18:08:08 +01:00
pdf_find_utils.js Enable auto-formatting of the entire code-base using Prettier (issue 11444) 2019-12-26 12:34:24 +01:00
pdf_history.js Use ESLint to ensure that exports are sorted alphabetically 2021-01-09 20:37:51 +01:00
pdf_layer_viewer.js Add support for finding/highlighting the outlineItem, corresponding to the currently visible page, in the sidebar (issue 7557, bug 1253820, bug 1499050) 2021-01-09 16:09:44 +01:00
pdf_link_service.js Add previous/next-page functionality that takes scroll/spread-modes into account (issue 11946) 2021-01-22 21:38:15 +01:00
pdf_outline_viewer.js Add support for finding/highlighting the outlineItem, corresponding to the currently visible page, in the sidebar (issue 7557, bug 1253820, bug 1499050) 2021-01-09 16:09:44 +01:00
pdf_page_view.js Tweak the new mouseState parameter, and its usage, in the viewer components and the AnnotationLayer 2020-12-18 22:03:41 +01:00
pdf_presentation_mode.js Add previous/next-page functionality that takes scroll/spread-modes into account (issue 11946) 2021-01-22 21:38:15 +01:00
pdf_print_service.js Remove code-paths only relevant for IE 11/Edge (non-Chromium based) from the web/ folder 2020-09-05 17:18:15 +02:00
pdf_rendering_queue.js Use ESLint to ensure that exports are sorted alphabetically 2021-01-09 20:37:51 +01:00
pdf_sidebar_resizer.js Remove CSS variables feature-testing from PDFSidebarResizer 2020-09-09 22:26:08 +02:00
pdf_sidebar.js Only display a notification on the sidebarToggle-button, and not the individual view-buttons (PR 7959 follow-up) 2021-01-18 11:36:42 +01:00
pdf_single_page_viewer.js Add previous/next-page functionality that takes scroll/spread-modes into account (issue 11946) 2021-01-22 21:38:15 +01:00
pdf_thumbnail_view.js Merge pull request #12618 from Snuffleupagus/thumbnails-render-transform 2020-11-14 16:32:09 +01:00
pdf_thumbnail_viewer.js Improve the cleanup functionality for thumbnails 2020-11-13 13:31:01 +01:00
pdf_viewer.component.js Use ESLint to ensure that exports are sorted alphabetically 2021-01-09 20:37:51 +01:00
pdf_viewer.css Enable the Stylelint shorthand-property-no-redundant-values rule 2021-01-22 14:36:02 +01:00
pdf_viewer.js Add previous/next-page functionality that takes scroll/spread-modes into account (issue 11946) 2021-01-22 21:38:15 +01:00
pdfjs.js Enable auto-formatting of the entire code-base using Prettier (issue 11444) 2019-12-26 12:34:24 +01:00
preferences.js Reduce, now unnecessary, asynchronicity in the BasePreferences constructor 2020-11-16 14:19:54 +01:00
secondary_toolbar.js Update Prettier to version 2.0 2020-04-14 12:28:14 +02:00
text_layer_builder.css Enable the Stylelint length-zero-no-unit rule 2021-01-10 14:09:36 +01:00
text_layer_builder.js [api-minor] Highlight search results correctly for normalized text (PR 9448) 2021-01-12 18:08:08 +01:00
toolbar.js Update the zoom dropdown width calculation to work better in locales with long zoom-strings (PR 11077 follow-up) 2020-08-20 09:57:42 +02:00
ui_utils.js Add previous/next-page functionality that takes scroll/spread-modes into account (issue 11946) 2021-01-22 21:38:15 +01:00
view_history.js Add a bit more validation in the ViewHistory constructor 2020-03-21 13:55:06 +01:00
viewer_compatibility.js Remove code-paths only relevant for IE 11/Edge (non-Chromium based) from the web/ folder 2020-09-05 17:18:15 +02:00
viewer-snippet-chrome-extension.html Wraps mozL10n to async calls; splits firefox and generic l10n libs. 2017-05-31 09:22:25 -05:00
viewer-snippet-chrome-overlays.html [CRX] Add file chooser as fallback (fixes #9411) 2018-03-21 18:21:46 +01:00
viewer-snippet-firefox-extension.html Stop bundling the ReadableStream polyfill in MOZCENTRAL builds (PR 10470 follow-up) 2019-01-23 20:33:20 +01:00
viewer-snippet-minified.html Remove XHTML leftovers from the viewer HTML files 2016-02-14 13:23:34 +01:00
viewer-snippet.html Wraps mozL10n to async calls; splits firefox and generic l10n libs. 2017-05-31 09:22:25 -05:00
viewer.css Enable the Stylelint shorthand-property-no-redundant-values rule 2021-01-22 14:36:02 +01:00
viewer.html Add support for finding/highlighting the outlineItem, corresponding to the currently visible page, in the sidebar (issue 7557, bug 1253820, bug 1499050) 2021-01-09 16:09:44 +01:00
viewer.js Add support for finding/highlighting the outlineItem, corresponding to the currently visible page, in the sidebar (issue 7557, bug 1253820, bug 1499050) 2021-01-09 16:09:44 +01:00