@@ -170,7 +170,7 @@ class Toolbar {
170
170
171
171
this . eventBus . _on ( "localized" , ( ) => {
172
172
this . _wasLocalized = true ;
173
- this . _adjustScaleWidth ( ) ;
173
+ this . #adjustScaleWidth ( ) ;
174
174
this . _updateUIState ( true ) ;
175
175
} ) ;
176
176
}
@@ -237,9 +237,8 @@ class Toolbar {
237
237
/**
238
238
* Increase the width of the zoom dropdown DOM element if, and only if, it's
239
239
* too narrow to fit the *longest* of the localized strings.
240
- * @private
241
240
*/
242
- async _adjustScaleWidth ( ) {
241
+ async #adjustScaleWidth ( ) {
243
242
const { items, l10n } = this ;
244
243
245
244
const predefinedValuesPromise = Promise . all ( [
@@ -248,6 +247,7 @@ class Toolbar {
248
247
l10n . get ( "page_scale_fit" ) ,
249
248
l10n . get ( "page_scale_width" ) ,
250
249
] ) ;
250
+ await animationStarted ;
251
251
252
252
const style = getComputedStyle ( items . scaleSelect ) ,
253
253
scaleSelectContainerWidth = parseInt (
@@ -260,10 +260,8 @@ class Toolbar {
260
260
) ;
261
261
262
262
// The temporary canvas is used to measure text length in the DOM.
263
- let canvas = document . createElement ( "canvas" ) ;
264
- let ctx = canvas . getContext ( "2d" , { alpha : false } ) ;
265
-
266
- await animationStarted ;
263
+ const canvas = document . createElement ( "canvas" ) ;
264
+ const ctx = canvas . getContext ( "2d" , { alpha : false } ) ;
267
265
ctx . font = `${ style . fontSize } ${ style . fontFamily } ` ;
268
266
269
267
let maxWidth = 0 ;
@@ -283,7 +281,6 @@ class Toolbar {
283
281
// immediately, which can greatly reduce memory consumption.
284
282
canvas . width = 0 ;
285
283
canvas . height = 0 ;
286
- canvas = ctx = null ;
287
284
}
288
285
}
289
286
0 commit comments