1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-20 07:08:08 +02:00
pdf.js/web
Rob Wu cdea75dc39 Refactor the previous history rewriting logic
When the user edits the URL and changes the reference fragment (hash),
PDF.js intercepts this action, and saves the then-current history state
in the previous history entry. This is implemented by navigating back,
editing the history and navigating forward again.

The current logic has a flaw: It assumes that calling history.back() and
history.forward() immediately updates the history state. This is however
not guaranteed by the web standards, which states that calling e.g.
history.back "must traverse the history by a delta -1", which means that
the browser must QUEUE a task to traverse the session history, per spec:
http://w3.org/TR/2011/WD-html5-20110113/history.html#dom-history-back
https://html.spec.whatwg.org/multipage/browsers.html#dom-history-back

Firefox and Internet Explorer deviate from the standards by immediately
changing the history state instead of queuing the navigation.
WebKit derived browsers (Chrome, Opera, Safari) and Opera presto do not.

The user-visible consequence of strictly adhering to the standards in
PDF.js can be shown as follows:

1. Edit the URL.
2. Append #page=2 for example.
3. Press Enter.
   -> Presto and WebKit: PDF.js reverts to the previous URL.
   -> Gecko and Trident: PDF.js keeps the new URL, as expected.

To fix the issue, modification of the previous history item happens in
a few asynchronous steps, guided by the popstate event to detect when
the history navigation request has been committed.

--
Some more implementation notes:

I have removed the preventDefault and stopPropagation calls, because
popstate is not cancelable, and window is already the last target of the
event propagation.

The previous allowHashChange logic was hard to follow, because it did
not explain that hashchange will be called twice; once during the
popstate handler for history.back() (which will reset allowHashChange),
and again for history.forward() (where allowHashChange will be false).
The purpose of allowHashChange is now more explicit, by incorporating
the logic in the replacePreviousHistoryState helper function.
2015-09-26 23:15:29 +02:00
..
images Add updated loading-small.png (and corresponding Retina) asset 2014-10-01 00:13:45 +02:00
.gitignore Remove obselete file from .gitignore 2015-01-26 16:44:45 +01:00
annotations_layer_builder.js Replaces text selection example 2014-12-20 23:41:34 -06:00
chromecom.js [CRX] Add Referer request header if needed 2015-06-05 23:24:40 +02:00
compatibility.js Merge pull request #5598 from CodingFabian/chrome39-range-disable 2015-04-30 22:31:50 +02: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 Fix regression that prevents downloading of font files in the debugger 2014-10-28 19:56:55 +01:00
default_preferences.js Removes B2G preprocessing directives. 2015-06-30 16:53:32 -05:00
download_manager.js Fixes DownloadManager for IE10 and above 2014-04-28 22:43:05 +02:00
firefoxcom.js cleaned whitespace 2015-02-17 11:07:37 -05:00
grab_to_pan.js Handtool: Remove focus from previous node on click 2014-09-03 16:31:47 +02:00
hand_tool.js Break dependencies between PresentationMode and other code, and add PresentationMode related utility methods to PDFViewer 2015-04-21 16:02:32 +02:00
interfaces.js Refactors PDFHistory. 2015-05-16 11:20:36 -05:00
mozPrintCallback_polyfill.js Check availability of canvas & PDF before printing 2015-06-05 23:55:08 +02:00
overlay_manager.js [OverlayManager] Add preventDefault to the keydown event handler 2014-05-27 23:48:02 +02:00
password_prompt.js Convert the existing overlays to use the OverlayManager 2014-05-25 21:33:15 +02:00
pdf_attachment_view.js Add custom |outlineloaded| and |attachmentsloaded| events to the viewer (bug 1112947) 2015-03-21 17:49:34 +01:00
pdf_document_properties.js Simplify document properties field logic 2015-04-27 15:25:40 +02:00
pdf_find_bar.js cleaned whitespace 2015-02-17 11:07:37 -05:00
pdf_find_controller.js Merge pull request #5769 from dumyan/findcontroller-nbsp 2015-02-28 14:50:25 +01:00
pdf_history.js Refactor the previous history rewriting logic 2015-09-26 23:15:29 +02:00
pdf_link_service.js Fix a couple of function names in error messages in PDFLinkService 2015-05-29 13:47:28 +02:00
pdf_outline_view.js Add custom |outlineloaded| and |attachmentsloaded| events to the viewer (bug 1112947) 2015-03-21 17:49:34 +01:00
pdf_page_view.js Merge pull request #5857 from Rob--W/print-page-size 2015-05-14 16:52:40 +02:00
pdf_presentation_mode.js Pass in a PDFViewer instance to PDFPresentationMode and use it to eliminate all references to PDFViewerApplication 2015-07-06 09:49:51 +02:00
pdf_rendering_queue.js Refactors draw method in PDFPageView; makes optional some PDFPageViewOptions options 2014-12-20 23:41:34 -06:00
pdf_thumbnail_view.js viewer: Support Retina/HiDPI thumbnails 2015-05-18 15:13:46 +01:00
pdf_thumbnail_viewer.js Update thumbnail style only when sidebar is visible 2015-01-27 21:08:36 +01:00
pdf_viewer.component.js Using pdfjs-dist as a library for b2g viewer. 2015-06-30 16:53:32 -05:00
pdf_viewer.css Preface all "fullscreen" CSS rules with a |pdfPresentationMode| class, and add it to the |viewerContainer| while Presentation Mode is active 2015-04-21 16:28:50 +02:00
pdf_viewer.js Prevent re-rendering of pages because of rounding errors when computing the scale value 2015-07-06 17:22:03 +02:00
preferences.js Removes B2G preprocessing directives. 2015-06-30 16:53:32 -05:00
secondary_toolbar.js Simplify document properties field logic 2015-04-27 15:25:40 +02:00
text_layer_builder.css Replaces text selection example 2014-12-20 23:41:34 -06:00
text_layer_builder.js Add a |textlayerrendered| event 2015-01-06 17:57:32 +01:00
ui_utils.js Using pdfjs-dist as a library for b2g viewer. 2015-06-30 16:53:32 -05:00
view_history.js Removes B2G preprocessing directives. 2015-06-30 16:53:32 -05:00
viewer-snippet-chrome-extension.html Remove type="text/javascript" from script tags. 2014-05-13 02:41:01 +02:00
viewer-snippet-firefox-extension.html Remove type="text/javascript" from script tags. 2014-05-13 02:41:01 +02:00
viewer-snippet-minified.html Remove type="text/javascript" from script tags. 2014-05-13 02:41:01 +02:00
viewer-snippet-mozPrintCallback-polyfill.html Revert PR 5510, except in WebKit browsers, for breaking print preview in Firefox 2015-03-07 00:16:55 +01:00
viewer-snippet.html Remove type="text/javascript" from script tags. 2014-05-13 02:41:01 +02:00
viewer.css Apply padding on <select> and not the button 2015-06-03 12:16:12 -07:00
viewer.html Update Adobe CMaps URL and license 2015-06-30 00:42:21 -07:00
viewer.js Remove PDFViewerApplication.updateScaleControls (issue 6158) 2015-07-11 11:25:32 +02:00