1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-19 22:58:07 +02:00
pdf.js/web
Nicolò Ribaudo 6f2e4d0d94
Fix flickering on text selection
When seleciting on a touch screen device, whenever the finger moves to a
blank area (so over `div.textLayer` directly rather than on a `<span>`),
the selection jumps to include all the text between the beginning of the
.textLayer and the selection side that is not being moved.

The existing selection flickering fix when using the mouse cannot be
trivially re-used on mobile, because when modifying a selection on
a touchscreen device Firefox will not emit any pointer event (and
Chrome will emit them inconsistently). Instead, we have to listen to the
'selectionchange' event.

The fix is different in Firefox and Chrome:
- on Firefox, we have to make sure that, when modifying the selection,
  hovering on blank areas will hover on the .endOfContent element
  rather than on the .textLayer element. This is done by adjusting the
  z-indexes so that .endOfContent is above .textLayer.
- on Chrome, hovering on blank areas needs to trigger hovering on an
  element that is either immediately after (or immediately before,
  depending on which side of the selection the user is moving) the
  currently selected text. This is done by moving the .endOfContent
  element around between the correct `<span>`s in the text layer.

The new anti-flickering code is also used when selecting using a mouse:
the improvement in Firefox is only observable on multi-page selection,
while in Chrome it also affects selection within a single page.

After this commit, the `z-index`es inside .textLayer are as follows:
- .endOfContent has `z-index: 0`
- everything else has `z-index: 1`
  - except for .markedContent, which have `z-index: 0`
    and their contents have `z-index: 1`.

`.textLayer` has an explicit `z-index: 0` to introduce a new stacking context,
so that its contents are not drawn on top of `.annotationLayer`.
2024-05-14 14:31:12 +02:00
..
images Tweak the fill-value of the Stamp-icon to work better in non-Firefox browsers 2024-04-10 11:14:41 +02:00
.gitignore Remove obselete file from .gitignore 2015-01-26 16:44:45 +01:00
alt_text_manager.js [Editor] Add some telemetry for the highlight feature (bug 1866437) 2024-02-28 10:17:11 +01:00
annotation_editor_layer_builder.css [Editor] Add a divider before the show all button 2024-03-25 14:59:34 +01:00
annotation_editor_layer_builder.js Avoid wrong scrolling when calling zoomReset 2024-03-21 16:04:36 +01:00
annotation_editor_params.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
annotation_layer_builder.css [Editor] Make the text layer focusable before the editors (bug 1881746) 2024-03-19 16:14:55 +01:00
annotation_layer_builder.js [Editor] Make the text layer focusable before the editors (bug 1881746) 2024-03-19 16:14:55 +01:00
app.js [api-minor] Update the minimum supported Safari version to 16.4 2024-04-15 12:44:37 +02:00
app_options.js Limit all compatibilityParams handling to the GENERIC viewer 2024-03-30 12:16:53 +01:00
base_tree_viewer.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
caret_browsing.js [Editor] In caret browsing mode, get the caret position in the text layer (bug 1881692) 2024-02-23 16:50:19 +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 Remove PDFViewerApplication.initPassiveLoading and directly invoke the open-method from the extension-specific code 2024-03-20 14:52:23 +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.css Fix the textLayer-opacity when using the FontInspector (PR 17533 follow-up) 2024-01-26 18:31:38 +01:00
debugger.mjs [Debugger] Add some info about substitution font 2023-10-09 12:06:33 +02:00
download_manager.js Re-factor the blob-URL caching in DownloadManager.openOrDownloadData 2023-10-17 10:18:34 +02:00
draw_layer_builder.css [Editor] Correctly rotate the mask when rotation a free highlight (bug 1879102) 2024-02-08 15:29:29 +01:00
draw_layer_builder.js [Editor] Add a new editor to highlight some text in a pdf (bug 1866119) 2023-11-28 14:21:53 +01:00
event_utils.js [api-minor] Replace the PromiseCapability with Promise.withResolvers() 2024-04-01 11:42:37 +02:00
external_services.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
firefox_print_service.js [api-minor] Implement basic support for OptionalContent Usage dicts (issue 5764, bug 1826783) 2024-03-12 13:18:15 +01:00
firefoxcom.js Remove PDFViewerApplication.initPassiveLoading and directly invoke the open-method from the extension-specific code 2024-03-20 14:52:23 +01:00
generic_scripting.js Use a limit, in more places, when splitting strings 2024-02-02 13:10:52 +01:00
genericcom.js [Editor] Add the possibility to query some ML stuff to guess an alt text for an image 2024-02-20 21:29:33 +01:00
genericl10n.js Point the *development mode* fallback locale-path to the l10n-folder (issue 17609, PR 17603 follow-up) 2024-02-01 13:03:36 +01:00
grab_to_pan.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
interfaces.js Break import cycles, in the viewer, for PDFViewerApplication 2024-02-10 23:15:57 +01:00
l10n.js Ensure that GenericL10n works if the locale files cannot be loaded 2024-01-31 14:07:11 +01:00
overlay_manager.js Remove the OverlayManager.unregister method since it's completely unused 2023-06-21 13:13:53 +02:00
password_prompt.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
pdf_attachment_viewer.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
pdf_cursor_tools.js Merge pull request #17879 from ex37/master 2024-04-14 16:35:02 +02:00
pdf_document_properties.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
pdf_find_bar.js Tweak the matchCount l10n-args handling slightly (PR 17146 follow-up) 2023-10-24 13:17:02 +02:00
pdf_find_controller.js [api-minor] Replace the PromiseCapability with Promise.withResolvers() 2024-04-01 11:42:37 +02:00
pdf_find_utils.js [api-minor] Don't normalize the text used in the text layer. 2023-04-17 14:31:23 +02:00
pdf_history.js Convert the history code to use proper private methods 2024-04-11 15:17:30 +02:00
pdf_layer_viewer.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
pdf_link_service.js Move the /SetOCGState handling into the OptionalContentConfig class (PR 15377 follow-up) 2024-03-12 13:18:15 +01:00
pdf_outline_viewer.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
pdf_page_view.js Limit all compatibilityParams handling to the GENERIC viewer 2024-03-30 12:16:53 +01:00
pdf_presentation_mode.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
pdf_print_service.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
pdf_rendering_queue.js Limit some PDFRenderingQueue-related code to the GENERIC viewer 2023-05-30 21:24:19 +02:00
pdf_scripting_manager.component.js Use shorter arrow functions where possible 2024-01-21 10:13:12 +01:00
pdf_scripting_manager.js Use the string value of the field when calling the Format callback (bug 1889122) 2024-04-09 22:52:11 +02:00
pdf_sidebar.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
pdf_single_page_viewer.js Remove the abstract BaseViewer-class 2022-09-08 12:38:17 +02:00
pdf_thumbnail_view.js Convert the thumbnail view(er) code to use proper private methods 2024-04-05 14:44:48 +02:00
pdf_thumbnail_viewer.js Convert the thumbnail view(er) code to use proper private methods 2024-04-05 14:44:48 +02:00
pdf_viewer.component.js Ensure that GenericL10n works if the locale files cannot be loaded 2024-01-31 14:07:11 +01:00
pdf_viewer.css [Editor] Make the text layer focusable before the editors (bug 1881746) 2024-03-19 16:14:55 +01:00
pdf_viewer.js [api-minor] Replace the PromiseCapability with Promise.withResolvers() 2024-04-01 11:42:37 +02:00
pdfjs.js [api-minor] Replace the PromiseCapability with Promise.withResolvers() 2024-04-01 11:42:37 +02:00
preferences.js A couple of small tweaks of the BasePreferences class 2024-03-26 13:38:40 +01:00
print_utils.js Handle appending consistently in the xfaLayer regardless of rendering intent (PR 17177 follow-up) 2023-10-26 12:05:33 +02:00
secondary_toolbar.js Merge pull request #17879 from ex37/master 2024-04-14 16:35:02 +02:00
struct_tree_layer_builder.js Ignore null-chars when using structTree-data in the viewer 2023-08-31 16:29:10 +02:00
stubs-geckoview.js [GeckoView] Avoid bundling the AltTextManager class, since it's unused 2023-09-21 12:51:34 +02:00
text_accessibility.js [Editor] Add the parent tag id (if any) to the serialized editors (bug 1845087) 2023-09-07 18:22:33 +02:00
text_highlighter.js [api-minor] Don't normalize the text used in the text layer. 2023-04-17 14:31:23 +02:00
text_layer_builder.css Fix flickering on text selection 2024-05-14 14:31:12 +02:00
text_layer_builder.js Fix flickering on text selection 2024-05-14 14:31:12 +02:00
toggle_button.css Fix the RTL-rule for the editorHighlightShowAll button, such that it works outside of the Firefox PDF Viewer 2024-04-10 11:35:04 +02:00
toolbar-geckoview.js [GeckoView] Remove the open-in-app button (bug 1832519) 2024-03-04 19:32:12 +01:00
toolbar.js Improve type definitions for the viewer 2024-04-12 17:12:04 +04:00
ui_utils.js Use shorter arrow functions where possible 2024-01-21 10:13:12 +01:00
view_history.js Add a bit more validation in the ViewHistory constructor 2020-03-21 13:55:06 +01:00
viewer-geckoview.css [GeckoView] Remove the open-in-app button (bug 1832519) 2024-03-04 19:32:12 +01:00
viewer-geckoview.html [GeckoView] Remove the open-in-app button (bug 1832519) 2024-03-04 19:32:12 +01:00
viewer-geckoview.js [GeckoView] Remove the open-in-app button (bug 1832519) 2024-03-04 19:32:12 +01:00
viewer-snippet-chrome-extension.html [api-minor] Move to Fluent for the localization (bug 1858715) 2023-10-19 11:20:41 +02:00
viewer-snippet-chrome-overlays.html Convert the existing overlays to use <dialog> elements (issue 14698) 2022-03-28 11:36:29 +02:00
viewer-snippet-firefox-extension.html [api-major] Output JavaScript modules in the builds (issue 10317) 2023-10-07 09:31:08 +02:00
viewer-snippet.html [api-minor] Move to Fluent for the localization (bug 1858715) 2023-10-19 11:20:41 +02:00
viewer.css Avoid useless CSS animation when nothing is done (bug 1888657) 2024-04-01 17:32:38 +02:00
viewer.html [Editor] Add a divider before the show all button 2024-03-25 14:59:34 +01:00
viewer.js [Editor] Add a toggle button to show/hide all the highlights (bug 1867740) 2024-03-07 13:16:59 +01:00
xfa_layer_builder.css Remove unnecessary alpha-value from CSS rgb colors 2023-10-06 09:50:03 +02:00
xfa_layer_builder.js Handle appending consistently in the xfaLayer regardless of rendering intent (PR 17177 follow-up) 2023-10-26 12:05:33 +02:00