Commit Graph

53 Commits

Author SHA1 Message Date
Jonas Jenwald
4ebddcb092 Remove unnecessary alpha-value from CSS rgb colors
Setting the alpha-value explicitly to `1` in `rgb` colors is unnecessary, since that's the default value, and this way we ever so slightly reduce the size of our CSS files.
Unfortunately I've not found a Stylelint rule to enforce this automatically, and the patch was generated using search and replace.
2023-10-06 09:50:03 +02:00
Jonas Jenwald
4277205d78 Enable some Stylelint color-related rules to slightly reduce file sizes
- Use a consistent format for all alpha-values (this rule didn't require any code changes); see https://stylelint.io/user-guide/rules/alpha-value-notation
 - Use modern and slightly shorter color notation, since [according to MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/color_value/rgb#browser_compatibility) that should be supported "everywhere" nowadays; see https://stylelint.io/user-guide/rules/color-function-notation/
 - Use "short" hexadecimal colors whenever possible; see https://stylelint.io/user-guide/rules/color-hex-length/
 - Help avoid adding broken hexadecimal colors (this rule didn't require any code changes); see https://stylelint.io/user-guide/rules/color-no-invalid-hex/
2023-10-05 17:51:21 +02:00
Jonas Jenwald
5711d0f95d [GeckoView] Exclude annotation_editor_layer_builder.css in the build (issue 16994)
Given the limitations of the old pre-processor that's used for CSS/HTML files, this unfortunately isn't as "easy" to implement as it is for JavaScript code.
Since this is the first case where we've wanted to do conditional CSS imports, rather than trying to completely re-write the pre-processor, this patch settles for handling it explicitly in the `expandCssImports` function.
2023-09-21 15:51:33 +02:00
Calixte Denizet
b59b1a81a9 [Editor] Refactor dragging and dropping an editor (bugs 1802895, 1844618)
It'll help to have a full control on what's happening when moving an editor.
2023-08-03 14:47:16 +02:00
Jonas Jenwald
8a9d7a18cc Allow text-selection, but not copying, when enablePermissions is set (PR 16320 follow-up) 2023-04-25 11:07:05 +02:00
Jonas Jenwald
36ff19c53b
Merge pull request #16314 from Snuffleupagus/pdfViewer-CSS-is
Introduce some `:is` usage in the PDFViewer CSS
2023-04-19 15:28:53 +02:00
Jonas Jenwald
529dbf9b65 Enforce double-colon notation for CSS pseudo-elements
These changes are part of https://phabricator.services.mozilla.com/D170496, and thanks to a Stylelint rule we can both enforce and fix this automatically; see also https://stylelint.io/user-guide/rules/selector-pseudo-element-colon-notation/
2023-04-18 15:50:22 +02:00
Jonas Jenwald
04ed5ddeba Introduce some :is usage in the PDFViewer CSS 2023-04-18 12:01:08 +02:00
Calixte Denizet
ca54ea12b3 Add the possibility to copy all the pdf text whatever the rendered pages are (bug 1788035) 2023-04-15 18:59:40 +02:00
Jonas Jenwald
1efe41c248 Use margin-inline in the web/pdf_viewer.css file (PR 14670 follow-up)
Given that the viewer always set the `dir`-attribute, we should be able to use logical margins in this CSS file as well; please also see https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline
2023-03-19 12:31:34 +01:00
calixteman
ff3b9ccf6e
Merge pull request #16017 from calixteman/hide_struct_tree
Hide the struct tree layer during zooming
2023-02-09 11:32:28 +01:00
Calixte Denizet
bb89daa2a8 Avoid a useless animation when the spinner is invisible
In looking at a profile, I noticed in Marker chart that there's an animation
for loading-icon.gif even if this icon isn't visible.
This patch doesn't completely remove it but just slightly postpones it.
2023-02-08 11:57:53 +01:00
Calixte Denizet
5bd352f69b Hide the struct tree layer during zooming 2023-02-07 15:33:01 +01:00
Jonas Jenwald
ddf5563174 Limit the removePageBorders option, in PDFViewer, to only GENERIC builds
This option was added specifically for third-party users, but has never been used in the PDF.js project itself. Furthermore there's no preference that can be used to enable it, and you need to provide the `removePageBorders` option when initializing a `PDFViewer`-instance.

This patch thus get rid of a little bit more unused code in the Firefox PDF Viewer.
2023-02-03 10:15:26 +01:00
Jonas Jenwald
fc8494b2c2 Limit the singlePageView CSS rules to only the COMPONENTS build
These CSS rules exist solely for the `pageviewer` viewer-component example, see https://github.com/mozilla/pdf.js/tree/master/examples/components, and consequently it doesn't make sense in other builds.
2023-02-02 18:00:12 +01:00
Calixte Denizet
aac073feeb Remove the loading icon div and replace it by a pure css solution using :after.
This way we don't have a lot of useless divs and we let the css engine handle the
creation/destruction of the :after pseudo-element.
It'll help to slightly improve performance when zooming.
2023-02-02 15:33:53 +01:00
Calixte Denizet
089ed6fb65 Move --scale-factor variable in the viewer container (fix #15929)
When a css variable is update in a node then all the children under this
node are updated.
In order to avoid to update all the UI when a page is rescaling, this
patch moves the --scale-factor from the :root to the viewer container.
2023-01-17 10:50:53 +01:00
Tim van der Meij
38e46e7614
Merge pull request #15850 from calixteman/15836
Remove shadow around each pages (fix issue #15836)
2023-01-07 13:29:41 +01:00
Calixte Denizet
dd29f8705c Delay the loading icon display
In most of the cases, showing the loading icon is useless because
it's for a very short time, consequently it doesn't bring any useful
information for the user.
After a delay (400ms), the icon is shown in order to inform the user
that the viewer isn't stuck but it's doing something.
2023-01-06 12:28:32 +01:00
Calixte Denizet
685b5866e4 Remove shadow around each pages (fix issue #15836) 2023-01-02 14:58:53 +01:00
Calixte Denizet
c677b167b6 Set a z-index for the different layers within a page (fixes #15861)
Each layer has an absolute position, hence it induces the creation of
some stacking contexts (see https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Positioning/Understanding_z_index/The_stacking_context).
Thanks to this feature, we don't have to worry about the z-index used in
the annotation layer and how form elements interact with the other layers.
2022-12-26 22:55:08 +01:00
Calixte Denizet
663007a5c7 Only redraw after zooming is finished (bug 1661253)
Right now, the visible pages are redrawn for each scale change.
Consequently, zooming with mouse wheel or in pinching can be pretty janky
(even on a desktop machine but with a hdpi screen).
So the main idea in this patch is to draw the visible pages only once zooming
is finished.
2022-12-26 18:13:17 +01:00
Calixte Denizet
a989b5a879 Set the dimensions of the various layers at their creation
- Use a unique helper function in display/display_utils.js;
- Move those dimensions in css' side.
2022-12-10 14:35:06 +01:00
Calixte Denizet
3e751679ba Add a visible page border in HCM (bug 1776914) 2022-06-29 11:52:19 +02:00
Calixte Denizet
0c420f5135 Support rotating editor layer
- As in the annotation layer, use percent instead of pixels as unit;
- handle the rotation of the editor layer in allowing editing when rotation
  angle is not zero;
- the different editors are rotated counterclockwise in order to be usable
  when the main page is itself rotated;
- add support for saving/printing rotated editors.
2022-06-24 20:02:32 +02:00
Calixte Denizet
e2db9bacef Get rid of CSS transform on each annotation in the annotation layer
- each annotation has its coordinates/dimensions expressed in percentage,
  hence it's correctly positioned whatever the scale factor is;
- the font sizes are expressed in percentage too and the main font size
  is scaled thanks a css var (--scale-factor);
- the rotation is now applied on the div annotationLayer;
- this patch improve the rendering of some strings where the glyph spacing
  was not correct (it's a Firefox bug);
- it helps to simplify the code and it should slightly improve the update of
  page (on zoom or rotation).
2022-06-18 17:54:59 +02:00
Calixte Denizet
be1aa11986 [edition] Add a FreeText editor (#14970)
- add a basic UI to edit some text in a pdf;
- an editor can be moved, suppressed, cut, copied, pasted, selected;
- add an undo/redo manager.
2022-06-04 18:20:11 +02:00
Jonas Jenwald
9817230ef8 Introduce a --viewer-container-height CSS variable to simplify the code
This new CSS variable will allow us to simplify a couple of different viewer components, since we no longer need to use JavaScript-based hacks and can directly set the CSS rules instead. In particular:

 - The `BaseViewer`-handling, used as part of the code that will center pages *vertically* in PresentationMode, can be simplified.
   By using CSS to control the height of the "dummy"-page we avoid unnecessarily invalidating the scale-value, which can reduce *some* unneeded re-rendering while PresentationMode is active.

 - The `SecondaryToolbar.#setMaxHeight`-method, and its associated parameters, are no longer necessary and can be completely removed.

Note that in order for things to work correctly in general, the new `--viewer-container-height` CSS variable must potentially be updated on any window-based "resize"-event (even when there's no zooming). While this is currently only done in the default viewer, that shouldn't be an issue since neither PresentationMode nor Toolbar-functionality is included in the "viewer components".
2022-05-06 13:45:39 +02:00
Jonas Jenwald
e67cd7fae0 Replace the --viewport-scale-factor CSS variable
This CSS variable is only used together with the `annotationCanvasMap`-functionality in the canvas-code, however its value can be *trivially* computed by using the older `--zoom-factor` CSS variable together with the `PixelsPerInch`-structure.
Rather than having *two different* CSS variables that are this closely linked, it seems better to simplify things by using just one CSS variable instead.
2022-04-14 12:43:57 +02:00
Jonas Jenwald
b03281de18 Move the permissions handling into the BaseViewer (PR 11789 follow-up)
Besides making the permissions-functionality directly available in the viewer-components, these changes are also necessary for the next patch.
2021-12-11 17:13:41 +01:00
Jonas Jenwald
f7b1da418f Center pages vertically in PresentationMode (issue 10906)
*This patch can be tested e.g. with the `sizes.pdf` document in the test-suite.*

While this patch isn't necessarily the best solution, e.g. it might be possible to solve this with *only* CSS, it's what I was able to come up with to address an old issue.
The solution here re-uses the `spread`-class in PresentationMode, since that one already takes care of centering pages *vertically*, together with a dummy-page that takes up the entire height of the window.

Finally, some PresentationMode-related CSS-rules are also simplified slightly, since the changes in PR 14112 (using Page-scrolling) allows some clean-up here.
2021-11-24 14:09:34 +01:00
Brendan Dahl
9f4a2cf5ce
Merge pull request #14276 from Snuffleupagus/issue-14242-2
Only show the `loadingIcon`-spinner on visible pages (issue 14242)
2021-11-18 13:43:58 -08:00
Jonas Jenwald
e909fcdba8 Only show the loadingIcon-spinner on visible pages (issue 14242)
This patch preserves the old behaviour of appending a `loadingIcon`-div to all pages that are not yet loaded/rendered. However, the actual `loadingIcon`-spinner (i.e. the `loading-icon.gif` image) will only be displayed on *visible* pages to improve performance.

To avoid having to iterate through all pages in the document, which doesn't seem like a good idea for a PDF document with thousands of pages, we use a combination of the currently visible *and* cached pages to toggle the `loadingIcon`-spinner.
2021-11-15 14:06:14 +01:00
Calixte Denizet
33ea817b20 [api-minor] Render pushbuttons on their own canvas (bug 1737260)
- First step to fix https://bugzilla.mozilla.org/show_bug.cgi?id=1737260;
 - several interactive pdfs use the possibility to hide/show buttons to show different icons;
 - render pushbuttons on their own canvas and then insert it the annotation_layer;
 - update test/driver.js in order to convert canvases for pushbuttons into images.
2021-11-12 15:37:33 +01:00
Calixte Denizet
71a100a4d0 Annotation & XFA: Scale the font size in choicelist using zoom factor (bug 1715996)
- this is an accessibility issue which could be painful for some people with visual disabilities.
2021-08-04 20:36:04 +02:00
utopianknight
be3debeeb8 Implement high contrast mode 2021-04-11 17:07:33 +04:00
calixteman
24e598a895
XFA - Add a layer to display XFA forms (#13069)
- add an option to enable XFA rendering if any;
  - for now, let the canvas layer: it could be useful to implement XFAF forms (embedded pdf in xml stream for the background and xfa form for the foreground);
  - ui elements in template DOM are pretty close to their html counterpart so we generate a fake html DOM from template one:
    - it makes easier to translate template properties to html ones;
    - it makes faster the creation of the html element in the main thread.
2021-03-19 10:11:40 +01:00
Jonas Jenwald
38c9f1a37a Enable the Stylelint shorthand-property-no-redundant-values rule
Note that these changes were done automatically, using `gulp lint --fix`; this rule will help avoid unnecessary repetition in the CSS.

Please find additional details about the Stylelint rule at https://stylelint.io/user-guide/rules/shorthand-property-no-redundant-values
2021-01-22 14:36:02 +01:00
Jonas Jenwald
246a6f9d13 Enable the Stylelint length-zero-no-unit rule
Note that these changes were done automatically, using `gulp lint --fix`.
With this rule, we'll thus enforce a *consistent* formatting of zero-lengths in our CSS files.

Please find additional details about the Stylelint rule at https://stylelint.io/user-guide/rules/length-zero-no-unit
2021-01-10 14:09:36 +01:00
Jonas Jenwald
87b002c52f Remove code-paths only relevant for IE 11/Edge (non-Chromium based) from the web/ folder
This patch purposely starts small, by removing IE-specific code from various JS/CSS files in the `web/` folder.

There's obviously lots of potential for additional clean-up, especially the removal of no longer necessary polyfills in `src/shared/compatibility.js`, however that will require some care considering that certain polyfills may also be necessary for e.g. Node.js or the Chromium-extension as well.
Generally speaking, once we start removing polyfills it's probably a good idea to consult the compatibility information on https://developer.mozilla.org/ and also https://caniuse.com/ first. (Deciding on the lowest supported Chromium version, for the extension, would also seem like a good idea.)
2020-09-05 17:18:15 +02:00
Jonas Jenwald
8aa2718d22 Re-format all web/*.css files using Stylelint/Prettier
This was done automatically, using `gulp lint --fix`.
2020-08-30 21:49:08 +02:00
Tim van der Meij
d002637405
Convert all named colors to RGBA colors 2020-01-01 14:48:56 +01:00
Ryan Hendrickson
3d83c646c6 Add spread modes to web viewer
This builds on the scrolling mode work to add three buttons for joining
page spreads together: one for the default view, with no page spreads,
and two for spreads starting on odd-numbered or even-numbered pages.
2018-05-14 23:10:32 -04:00
Ryan Hendrickson
91cbc185da Add scrolling modes to web viewer
In addition to the default scrolling mode (vertical), this commit adds
horizontal and wrapped scrolling, implemented primarily with CSS.
2018-05-14 23:10:32 -04:00
Wojciech Maj
dbb0e88bc1 Clean up browser-specific CSS 2018-04-04 00:25:12 +02:00
Yury Delendik
18e1f3d29b Ensure canvas is really hidden when used with pdfjs-dist.
Avoids black background flickering in such examples as components/simpleviewer.html
2017-06-20 14:45:07 -05:00
Yury Delendik
5f883d763f Better components examples. 2016-04-28 13:30:03 -05:00
Jonas Jenwald
3079dd937f Remove a superfluous "s" in AnnotationsLayerBuilder from files in web/
This patch makes the naming consistent with the `TextLayerBuilder`, and also the new `AnnotationLayer`, and should thus help reduce possible confusion when working with the code.
Please note that the files were renamed using `git mv`, in order to preserve blame.
2015-12-18 19:55:54 +01:00
Jonas Jenwald
d9975ea778 Move annotation related CSS rules from pdf_viewer.css to its own file
This is similar to the already existing, separate, CSS file used for the `textLayer`, and it's necessary in order for the `pageviewer` components example to actually show annotations correctly.
2015-07-06 16:37:33 +02:00
Jonas Jenwald
601bd4a930 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