mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-07 17:05:38 +02:00
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.
This commit is contained in:
parent
a6e54160cc
commit
39ac3ef1a6
1 changed files with 4 additions and 5 deletions
|
@ -87,8 +87,6 @@ class PDFDocumentProperties {
|
||||||
eventBus._on("rotationchanging", evt => {
|
eventBus._on("rotationchanging", evt => {
|
||||||
this._pagesRotation = evt.pagesRotation;
|
this._pagesRotation = evt.pagesRotation;
|
||||||
});
|
});
|
||||||
|
|
||||||
this._isNonMetricLocale = NON_METRIC_LOCALES.includes(l10n.getLanguage());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -251,7 +249,8 @@ class PDFDocumentProperties {
|
||||||
height: pageSizeInches.width,
|
height: pageSizeInches.width,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
const isPortrait = isPortraitOrientation(pageSizeInches);
|
const isPortrait = isPortraitOrientation(pageSizeInches),
|
||||||
|
nonMetric = NON_METRIC_LOCALES.includes(this.l10n.getLanguage());
|
||||||
|
|
||||||
let sizeInches = {
|
let sizeInches = {
|
||||||
width: Math.round(pageSizeInches.width * 100) / 100,
|
width: Math.round(pageSizeInches.width * 100) / 100,
|
||||||
|
@ -305,9 +304,9 @@ class PDFDocumentProperties {
|
||||||
}
|
}
|
||||||
|
|
||||||
const [{ width, height }, unit, name, orientation] = await Promise.all([
|
const [{ width, height }, unit, name, orientation] = await Promise.all([
|
||||||
this._isNonMetricLocale ? sizeInches : sizeMillimeters,
|
nonMetric ? sizeInches : sizeMillimeters,
|
||||||
this.l10n.get(
|
this.l10n.get(
|
||||||
this._isNonMetricLocale
|
nonMetric
|
||||||
? "pdfjs-document-properties-page-size-unit-inches"
|
? "pdfjs-document-properties-page-size-unit-inches"
|
||||||
: "pdfjs-document-properties-page-size-unit-millimeters"
|
: "pdfjs-document-properties-page-size-unit-millimeters"
|
||||||
),
|
),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue