Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Re-factor Toolbar._adjustScaleWidth to improve/simplify how the zoom dropdown width is calculated #11570

Merged
merged 1 commit into from
Feb 8, 2020

Conversation

Snuffleupagus
Copy link
Collaborator

@Snuffleupagus Snuffleupagus commented Feb 6, 2020

This patch contains some much needed clean-up of, and improvements to, this old code thus addressing a number of issues:

  • Set more reasonable default values for the widths, in web/viewer.css, since the current ones are actually too small even for the (default) en-US locale.
    This obviously result in a slightly larger zoom dropdown width for many locales, but the more consistent UI does look good to me.

  • Stop setting the min-width/max-width and just use width instead.

  • Set an explicit height of the zoom dropdown, in an attempt to get Google Chrome to display it with the same height as the toolbar buttons.

  • Remove additional Element.setAttribute("style", ...) usage.

  • Actually check all of the predefined l10n strings, since the old implementation (implicitly) assumed that the currently selected one was the longest (note e.g. the ja-JP locale where one string is considerably longer than the rest).

  • Stop invalidating the DOM multiple times when doing the measurements. This was achieved by using a temporary in-memory canvas, and we now only need to query the DOM once in order to get the current font properties of the zoom dropdown.

Fixes #11576

@Snuffleupagus
Copy link
Collaborator Author

/botio-linux preview

…m dropdown width is calculated

This patch contains some *much* needed clean-up of, and improvements to, this old code thus addressing a number of issues:

 - Set more reasonable *default* values for the widths, in `web/viewer.css`, since the current ones are actually too small even for the (default) `en-US` locale.
   This obviously result in a slightly larger zoom dropdown width for many locales, but the more consistent UI does look good to me.

 - Stop setting the `min-width`/`max-width` and just use `width` instead.

 - Set an explicit `height` of the zoom dropdown, in an attempt to get Google Chrome to display it with the same height as the toolbar buttons.

 - Remove additional `Element.setAttribute("style", ...)` usage.

 - Actually check *all* of the predefined l10n strings, since the old implementation (implicitly) assumed that the currently selected one was the longest (note e.g. the `ja-JP` locale where one string is considerably longer than the rest).

 - Stop invalidating the DOM multiple times when doing the measurements. This was achieved by using a temporary in-memory `canvas`, and we now only need to query the DOM once in order to get the current font properties of the zoom dropdown.
@mozilla mozilla deleted a comment from pdfjsbot Feb 8, 2020
@mozilla mozilla deleted a comment from pdfjsbot Feb 8, 2020
@timvandermeij
Copy link
Contributor

/botio-linux preview

@pdfjsbot
Copy link

pdfjsbot commented Feb 8, 2020

From: Bot.io (Linux m4)


Received

Command cmd_preview from @timvandermeij received. Current queue size: 0

Live output at: http://54.67.70.0:8877/7273e0d3318f0e8/output.txt

@pdfjsbot
Copy link

pdfjsbot commented Feb 8, 2020

From: Bot.io (Linux m4)


Success

Full output at http://54.67.70.0:8877/7273e0d3318f0e8/output.txt

Total script time: 1.75 mins

Published

@timvandermeij timvandermeij merged commit 45e2ab8 into mozilla:master Feb 8, 2020
@timvandermeij
Copy link
Contributor

Looks good!

@Snuffleupagus Snuffleupagus deleted the zoom_adjustScaleWidth branch February 9, 2020 08:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CSP unsafe-inline CSS violations
3 participants