From 39ac3ef1a6c5123b1ded1482d7517dba4de1f659 Mon Sep 17 00:00:00 2001 From: Jonas Jenwald Date: Thu, 29 Aug 2024 12:57:57 +0200 Subject: [PATCH] Move the metric-locale check into `PDFDocumentProperties.#parsePageSize` With the introduction of Fluent the `getLanguage`-method became synchronous, hence it no longer seems necessary to do the metric-locale check eagerly in the constructor and it can instead be "delayed" until actually needed. --- web/pdf_document_properties.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/web/pdf_document_properties.js b/web/pdf_document_properties.js index ad4a4da4b3f53..dd386ffec7517 100644 --- a/web/pdf_document_properties.js +++ b/web/pdf_document_properties.js @@ -87,8 +87,6 @@ class PDFDocumentProperties { eventBus._on("rotationchanging", evt => { this._pagesRotation = evt.pagesRotation; }); - - this._isNonMetricLocale = NON_METRIC_LOCALES.includes(l10n.getLanguage()); } /** @@ -251,7 +249,8 @@ class PDFDocumentProperties { height: pageSizeInches.width, }; } - const isPortrait = isPortraitOrientation(pageSizeInches); + const isPortrait = isPortraitOrientation(pageSizeInches), + nonMetric = NON_METRIC_LOCALES.includes(this.l10n.getLanguage()); let sizeInches = { width: Math.round(pageSizeInches.width * 100) / 100, @@ -305,9 +304,9 @@ class PDFDocumentProperties { } const [{ width, height }, unit, name, orientation] = await Promise.all([ - this._isNonMetricLocale ? sizeInches : sizeMillimeters, + nonMetric ? sizeInches : sizeMillimeters, this.l10n.get( - this._isNonMetricLocale + nonMetric ? "pdfjs-document-properties-page-size-unit-inches" : "pdfjs-document-properties-page-size-unit-millimeters" ),