Re-factor Toolbar._adjustScaleWidth
to improve/simplify how the zoom dropdown width is calculated
#11570
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 usewidth
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