Skip to content

Commit

Permalink
Move the metric-locale check into PDFDocumentProperties.#parsePageSize
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Snuffleupagus committed Aug 29, 2024
1 parent a6e5416 commit 39ac3ef
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions web/pdf_document_properties.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,8 +87,6 @@ class PDFDocumentProperties {
eventBus._on("rotationchanging", evt => {
this._pagesRotation = evt.pagesRotation;
});

this._isNonMetricLocale = NON_METRIC_LOCALES.includes(l10n.getLanguage());
}

/**
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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"
),
Expand Down

0 comments on commit 39ac3ef

Please sign in to comment.