Commit Graph

464 Commits

Author SHA1 Message Date
Jonas Jenwald
553c2e05cd Introduce inset usage in the CSS files
The `inset` property is a nice shorthand that can be used to avoid having to specify the positions individually; please see
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline
2023-03-19 14:32:37 +01:00
Tim van der Meij
bdb6d978a9
Merge pull request #15968 from Snuffleupagus/rm-postCSS-logical
[api-minor] Update the minimum supported browsers, and remove the PostCSS `logical` plugin
2023-02-04 15:04:29 +01:00
Jonas Jenwald
849b492b33 Move the --scale-select-width CSS variable to the relevant DOM element
The default value of the `--scale-select-width` CSS variable has been choosen such that it should be large enough for most locales. This means that in many locales we don't even update the CSS variable at all, and for those locales where we do the update happens *one time* early during the viewer initialization (i.e. before the PDF document has loaded).

*Please note:* Compared to other recent PRs, the effect of these changes ought to be really tiny and are mostly done to promote better coding patterns.
2023-02-04 14:18:48 +01:00
Calixte Denizet
f14413989c Remove the transition when displaying the sidebar when the user prefers reduced motion (bug 1813138)
In Firefox, it can be easily testesd in setting the pref `ui.prefersReducedMotion` to 1.
2023-01-30 10:56:37 +01:00
Jonas Jenwald
ca996d2546 [api-minor] Update the minimum supported browsers, and remove the PostCSS logical plugin
The patch updates the minimum supported browsers/environments as follows:
 - Chrome 87, which was released on 2020-11-17; see https://en.wikipedia.org/wiki/Google_Chrome_version_history
 - Firefox ESR (no change); see https://wiki.mozilla.org/Release_Management/Calendar
 - Safari 14.1, which was released on 2021-04-26; see https://en.wikipedia.org/wiki/Safari_version_history#Safari_14
 - Node.js 14 (no change); see https://en.wikipedia.org/wiki/Node.js#Releases

The recent *major* release of the PostCSS `logical` plugin effectively removed support for all of the things that we used it for, which includes (but may not be limited to): preserving the original CSS code (for up-to-date browsers), re-writing the `:dir` pseudo-class, and support for re-writing `float: inline-start;`/`float: inline-end;` properties.
Please find additional details at https://github.com/csstools/postcss-plugins/blob/main/plugins/postcss-logical/CHANGELOG.md#600-january-24-2023
Hence the primary reason for these changes are related to native support for *logical* CSS properties/values. Currently, in the default viewer, we're using the following ones:
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline-start#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/inset-inline-end#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline-start#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/margin-inline-end#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/padding-inline-start#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/padding-inline-end#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/text-align#browser_compatibility
 - https://developer.mozilla.org/en-US/docs/Web/CSS/float#browser_compatibility

By updating the minimum supported browsers, we thus only have to worry about the *last* case here. Thankfully there's not that many `float: inline-start;`/`float: inline-end;` occurrences, and we can utilize CSS variables together with the pre-processor to support those in a way that won't affect the Firefox PDF Viewer.
2023-01-29 20:25:05 +01:00
Jonas Jenwald
9d5085347a Move ProgressBar-related CSS variables into the loadingBar DOM-element (issue 15958)
This way we avoid reflowing the entire viewer when e.g. updating the loading progress.
2023-01-25 11:09:28 +01:00
Jonas Jenwald
8ab5476cb8 Remove the background-color of the sidebarContent (PR 15850 follow-up)
After the changes in PR 15850, the `background-color` of the sidebar is now unnecessarily dark in the light-theme. Hence, we can simply remove this CSS rule to improve things overall (and these changes don't affect the dark-theme much at all).
This is even an overall consistency improvement, given the existing `--sidebar-narrow-bg-color` values.
2023-01-08 14:06:02 +01:00
Jonas Jenwald
bd84bf4ebd Tweak the --toolbar-border-color CSS variable (PR 15850 follow-up)
After the changes in PR 15850, the toolbar-border is now quite difficult to spot in the light-theme. Hence, let's tweak it slightly to improve things.
2023-01-07 13:44:21 +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
Jonas Jenwald
49c09eda9b Decouple the loadingBar background-color from the rest of the viewer
With upcoming background changes elsewhere in the viewer, this should be helpful in separating the styling of the loadingBar. These changes also means that both the "regular" and the "indeterminate" loadingBar now uses the same `background-color` value.

Also, shortens the related CSS variables a little bit since that can't hurt.
2022-12-28 12:07:39 +01:00
Jonas Jenwald
f0811a4a3c Prevent mouse interaction with form elements in PresentationMode (issue 12232) 2022-10-30 21:55:44 +01:00
Calixte Denizet
0996398372 Fix font for the 'current view' entry in the secondary toolbar (bug 1797310) 2022-10-26 10:49:23 +02:00
Jonas Jenwald
0983ebb257 Tweak the vertical position of the sidebar notification icon
Given that the new sidebar icon is slightly shorter than the old one, it cannot hurt to ever so slightly tweak the vertical position of the notification icon.

(While the patch also changes the CSS rule used for the horizontal position, this is a no-op and was done to improve consistency between the two values.)
2022-10-15 22:19:24 +02:00
Jonas Jenwald
450be1ad3e Simplify the dropdownToolbarButton-select width computation
The way that we set the width of the `dropdownToolbarButton`-select is very old, and despite some improvements over the years this is still somewhat hacky.
In particular, note how we're assigning the select-element a larger width than its containing `dropdownToolbarButton`-element. This was done to prevent displaying *two* separate icons, i.e. the native and the PDF.js one, since it's the only way to handle this in older browsers (particularly Internet Explorer).

Given the currently supported browsers, there's however a better solution available: use `appearance: none;` to disable native styling of the select-element. [According to MDN](https://developer.mozilla.org/en-US/docs/Web/CSS/appearance#browser_compatibility), this is supported in all reasonably modern browsers.
This way we're able to simplify both the CSS rules and the JS-code that's used to adjust the `dropdownToolbarButton` width in a localization aware way.
2022-10-07 18:19:10 +02:00
Jonas Jenwald
75e06fddf1 [GENERIC viewer] Remove the errorWrapper UI
In the Firefox PDF Viewer this has never been used, with the error message simply printed in the web-console, and (somewhat) recently we've also updated the viewer code to avoid bundling the relevant code there. Furthermore, in the Firefox PDF Viewer we're not even display the *browser* fallback bar any more; see https://bugzilla.mozilla.org/show_bug.cgi?id=1705327.

Hence it seems slightly strange to keep this UI around in the GENERIC viewer, and this patch proposes that we simply remove it to simplify/unify the relevant code in the viewer. In particular this also allows us to remove a couple of l10n-strings, which have always been unused in the Firefox PDF Viewer.
2022-10-01 17:35:35 +02:00
Tim van der Meij
907ef467ea
Merge pull request #15503 from Snuffleupagus/consistent-outline
Use a consistent `outline` for all UI buttons (PR 15438 follow-up)
2022-09-24 14:48:21 +02:00
Jonas Jenwald
5296fc991c Restore the old fonts in the errorWrapper (PR 15438 follow-up)
This only applies to the GENERIC viewer, hence we use the pre-processor to exclude it from the Firefox PDF Viewer.
2022-09-24 13:54:34 +02:00
Jonas Jenwald
616535b7a7 Use a consistent outline for all UI buttons (PR 15438 follow-up)
Currently the `viewBookmark`-button, which is actually a `href`-element, gets an inconsistent `outline`.
Similarly, the `dialog`-buttons also have an inconsistent `outline` after the changes in PR 15438.

Finally, simplifies a couple of `border` rules since setting a border-width when "none" is being used doesn't seem meaningful.
2022-09-24 13:42:27 +02:00
Calixte Denizet
3b536f2701 [Editor] Make sure to have the annotation editor layer on top of the annotation one (bug 1791515)
Some z-index have been added in the annotation layer because the elements inside are re-ordered
in order to improve accessibility.
Hence we must add a "high" z-index on the annotation editor layer in order to avoid any bad
interaction between the different layers.
2022-09-20 10:58:35 +02:00
Calixte Denizet
68977ebc26 Use AccentColor as background for selected text in the text layer (bug 1790309)
and use the default color for the viewer in general.
2022-09-19 21:25:56 +02:00
Calixte Denizet
07cd7cb3dc Improve CSS for HCM (bug 1726183)
The default outline for a focused text input is not that bad but for any reason when changing
the background color, all the good default border/outline properties are lost (it's the same
behaviour in Edge).
So in order have something consistent in HCM/non-HCM, a 2px-border+1px-outline (on @MReschenberg
advices) is added when an input is focused with different colors depending on HCM.
While working on the above issue, I noticed few bugs I fixed when in HCM:
 - input, button and select have some default properties which have been created at a time where
   annotation layer didn't exist, hence this patch remove them and set those properties where
   they should live;
 - some elements (like the main toolbar) is using a box-shadow which is invisible in HCM, hence
   it's replaced by a border-bottom in HCM;
 - some separators are invisible in HCM, hence use GrayText color to render them correctly;
 - the options for the zoom selection were invisible in HCM with Desert (one of the Windows 11
   themes).
2022-09-18 16:03:24 +02:00
Calixte Denizet
f8ae49d20b Set a display value for the secondary toolbar buttons
and remove a useless property: visibleSmallView.
2022-09-08 12:19:21 +02:00
Calixte Denizet
e56c30eb59 Move 'presentation mode' and 'bookmarks' buttons in the secondary toolbar (bug 1789082) 2022-09-08 12:18:08 +02:00
Jonas Jenwald
19182d5f25 [editor] Remove the editorNone toolbar button (bug 1787295) 2022-08-26 09:25:05 +02:00
Jonas Jenwald
7543a91086 [Firefox] Remove a couple of webkit CSS rules related to editing
Thanks to the CSS preprocessor, we can get rid of a couple of unnecessary CSS rules in the Firefox PDF Viewer.
2022-07-30 20:07:44 +02:00
Jonas Jenwald
4a38949886 Remove unnecessary color CSS property
This property is first of all unused, and secondly it contained a static value which means that it'd not have worked correctly in light/dark themes.
2022-07-30 19:53:34 +02:00
Jonas Jenwald
03c6febc44
Merge pull request #15121 from Snuffleupagus/loadingBar-cleanup
[api-minor] Further modernize the `ProgressBar` class (PR 14918 follow-up)
2022-07-02 16:46:40 +02:00
Jonas Jenwald
84ae9f9c58 [editor] Tweak @media CSS rules to account for the new toolbar buttons 2022-07-01 13:27:13 +02:00
Jonas Jenwald
d9ce17642f [api-minor] Further modernize the ProgressBar class (PR 14918 follow-up)
- Simplify how we look-up the DOM-element, which should also be a tiny bit more efficent.

 - Use private class-fields, rather than property-names prefixed with underscores.

 - Inline the `#updateBar` helper-method directly in the `percent`-setter, since having a separate method doesn't seem necessary in this case.

 - Set the `indeterminate`-class on the ProgressBar DOM-element, to simplify the code.

Finally, also (slightly) re-factors the `PDFViewerApplication.progress`-method to make it a bit smaller.
2022-07-01 10:31:25 +02:00
Calixte Denizet
1a3ef2a0aa [editor] Add some UI elements in order to set font size & color, and ink thickness & color 2022-06-28 12:05:04 +02:00
Jonas Jenwald
9748d3eb85 Remove element ids from the layersView in the sidebar
Similar to other recent patches, see e.g. PR 15057, we don't want to add these kind of `id`s to DOM-elements since they shouldn't become "linkable" through the URL hash.

*Please note:* This patch can be tested, in the viewer, with e.g. `bug1737260.pdf` from the test-suite.
2022-06-24 20:15:46 +02:00
Calixte Denizet
c161a86ba1 [editor] Add an Ink editor
- Approximate the drawn curve by a set of Bezier curves in using
  js code from https://github.com/soswow/fit-curves.
  The code has been slightly modified in order to make the linter
  happy.
2022-06-09 19:35:59 +02:00
Jonas Jenwald
d34e7fff01 [editor] Disable the editor-buttons in XFA documents
Given the differences between XFA documents and "normal" PDF documents, we don't support editing of the former ones. Hence, when a XFA-document is opened, we temporarily disable the editor-buttons.
2022-06-05 10:00:08 +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
Calixte Denizet
e94b9d1d7f Use a CSS transform to update the progress bar instead of changing the width (bug 1768481)
- it isn't a fix for bug 1768481 but just a tiny improvement to refresh the progress bar on the compositor thread.
2022-05-15 17:30:37 +02:00
Jonas Jenwald
1f3da032b4 [api-minor] Modernize and simplify the ProgressBar class
The original `ProgressBar`-functionality is very old, and could thus do with some general clean-up.
In particular, while it currently accepts various options those have never really been used in either the default viewer or in any examples. The sort of "styling" that these options provided are *much better*, not to mention simpler, done directly with CSS rules.

As part of these changes, the "progress" is now updated using CSS variables rather than by directly modifying the `style` of DOM elements. This should hopefully simplify future changes to this code, see e.g. PR 14898.

Finally, this also fixes a couple of other small things in the "mobile viewer" example.
2022-05-14 13:49:10 +02:00
Jonas Jenwald
d1f13a6af3 Use the regular preprocess-function for the CSS files as well
An old shortcoming of the `preprocessCSS`-function is its complete lack of support for our "normal" defines, which makes it very difficult to have build-specific CSS rules. Recently we've started using specially crafted comments to remove CSS rules from the MOZCENTRAL build, but (ab)using the `preprocessCSS`-function in this way really doesn't feel great.
However, it turns out to be surprisingly simple to instead use the "regular" `preprocess`-function for the CSS files as well. The only special-handling that's still necessary is the helper-function for dealing with CSS-imports, but apart from that everything seems to just work.

One reason, as far as I can tell, for having a separate `preprocessCSS`-function was likely that we originally used *lots* of vendor-prefixed CSS rules in our CSS files. With improvements over the years, especially thanks to Autoprefixer and PostCSS, we've been able to remove *almost* all non-standard CSS rules and the need for special-casing the CSS parsing has mostly vanished.

*Please note:* As part of testing this patch I've diffed the output of `gulp generic`, `gulp mozcentral`, and `gulp chromium` against the `master`-branch to check that there was no obvious breakage.
2022-05-07 22:45:52 +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
1e24fe97f2 Remove unnecessary CSS classes when specifying button icons
Currently we're using *both* ids and classes when specifying the button icons, which seems completely unnecessary and only serves to bloat the CSS code.
In general you always need to be careful about CSS specificity, but in these cases that should not actually be a problem.

Also, while not a button, this patch makes a similar simplification for the `pageNumber`-input.
2022-04-29 09:40:03 +02:00
Jonas Jenwald
4f69d66ab2 Remove redundant class names from the button DOM-elements
Note how in the `viewer.html` file we're specifying class names for most buttons, despite that not really being necessary. First of all, in many cases those class names are *identical* to the element-ids. Secondly, looking through the CSS rules they are only ever used when specifying button icons.
All-in-all, we should be able to simplify the HTML-code and use the element-ids in the CSS rules instead. Obviously ids have a higher CSS specificity than classes, but given how the old classes were being used that shouldn't be a problem here.

Also, the patch generalizes the styling for buttons (e.g. `viewBookmark`) that are *actually* link-elements.

Finally, while slightly unrelated, this patch also removes a little bit of duplication when specifying the border for `toolbarField`s.
2022-04-29 09:36:35 +02:00
Tim van der Meij
b72a448327
Merge pull request #14835 from Snuffleupagus/CSS-cleanup-separators
Clean-up some CSS rules for the various toolbar separators
2022-04-27 14:32:23 +02:00
Jonas Jenwald
3c10c66cd3 Remove unused CSS rules for toolbar buttons with textButton-classes
Searching through all of the files in the `web/`-folder has no *other* hits for the "textButton" string. Hence it's clear that there are no DOM elements actually using this class, and it's thus dead code.
2022-04-25 14:55:32 +02:00
Jonas Jenwald
f9262d29fc Clean-up some CSS rules for the various toolbar separators
This re-factors the various toolbar separators to *explicitly* specify both their dimensions and margins. Also, for the `horizontalToolbarSeparator`-class we can just set the `background-color` rather than using `border-top`.

Note that the `splitToolbarButtonSeparator`-class currently sets a number of unnecessary CSS rules, since as mentioned by the Firefox Devtools both the `display`- and `z-index`-properties are being ignored because `float` is used.

Finally, there's also no need to set a `z-index` for some of the `:hover`-rules. It's possible that this *was* necessary before the re-design, since the buttons had borders then.
2022-04-25 14:53:12 +02:00
Jonas Jenwald
b04c373362 Stop bundling the openFile-buttons in the MOZCENTRAL build
Note how both of the openFile-buttons are always hidden during viewer initialization in the MOZCENTRAL build, i.e. the *built-in* Firefox PDF Viewer. Despite that we still include HTML, CSS, and JavaScript code for these buttons in the build.

This patch *reduces* the size of the `gulp mozcentral` output by `1679` bytes, which isn't a lot but still cannot hurt.
2022-04-25 11:35:17 +02:00
Jonas Jenwald
925a7bc58a Remove unnecessary print CSS rules
These rules became unnecessary with PR 7697, over five years ago, since printing is now done from a `printContainer`-element rather than "directly" using the viewer.

Note how the *entire* `outerContainer`, which contains all of the DOM elements that were being manually hidden, is now being hidden during printing. Furthermore, note also how the print-canvases/images and their containers are using custom CSS-classes[1] rather than re-using the ones from the viewer.

---
[1] See the `printedPage` respectively `xfaPrintedPage` classes.
2022-04-23 14:32:00 +02:00
Jonas Jenwald
33ed743c48 Simplify setting of spacing at the left/right edges of the toolbar(s)
Rather than modifying the leading/trailing `margin` on the actual toolbar buttons, to achieve appropriate spacing at the left/right edges of the toolbar(s), it seems much more appropriate (and simpler) to just specify an explicit `padding` for the relevant toolbar containers.

Also, for toolbar buttons placed in `splitToolbarButton`-classes we can reduce some complexity around setting the `margin` (since it should always be zero now).

With these changes, we're thus able to get rid of a couple more `!important`-rules.
2022-04-22 18:15:28 +02:00
Jonas Jenwald
0f7e3213a1 Some more, small, CSS clean-up
- Remove a redundant `margin-top` rule for the `.dropdownToolbarButton`. After the (somewhat) recent UI-refresh all buttons now use `margin: 2px 1px;`, which renders the override unnecessary (and getting rid of an `!important`-rule can't hurt).

 - Combine two `.toggled::before` rules, since they're identical.
2022-04-21 15:41:30 +02:00
Jonas Jenwald
1d803451c3 Stop bundling errorWrapper CSS rules in the MOZCENTRAL build
Note that both the `errorWrapper` HTML and JavaScript code is being ignored in the MOZCENTRAL build, i.e. the *built-in* Firefox PDF Viewer, however the CSS rules are still being included.
That seems totally unnecessary, and while we currently don't have full build-target support in the CSS pre-processor we can actually improve things quite easily anyway. By (ab)using the existing CSS pre-processor, which will remove any non-Firefox CSS rules for the MOZCENTRAL build, it's possible to easily stop bundling any CSS rules by using comments that include a `-webkit`-string.

*Please note:* To easily test that this doesn't break the `errorWrapper` in GENERIC builds, try running e.g. `PDFViewerApplication._otherError("test");` in the web-console.
2022-04-20 14:35:09 +02:00