-
Notifications
You must be signed in to change notification settings - Fork 10k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wraps mozL10n to async calls; splits firefox and generic l10n libs. #8394
Conversation
0406f58
to
cbab3b4
Compare
Needed for #8402 too |
/botio-windows preview |
From: Bot.io (Windows)ReceivedCommand cmd_preview from @yurydelendik received. Current queue size: 0 Live output at: http://54.215.176.217:8877/74930242f69674f/output.txt |
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/74930242f69674f/output.txt Total script time: 19.14 mins Published |
6c67e24
to
8f549ef
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally this looks really good, thank you!
However, given the size of the PR and that there's a couple of parameter/naming issues which cause UI glitches, I'd like to look at/test this again once the comments are addressed.
web/ui_utils.js
Outdated
@@ -30,8 +30,29 @@ var RendererType = { | |||
SVG: 'svg', | |||
}; | |||
|
|||
var mozL10n = typeof document !== 'undefined' ? | |||
(document.mozL10n || document.webL10n) : undefined; | |||
// replace {{arguments}} with their values |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Grammar nit: // Replace {{arguments}} with their values.
web/genericl10n.js
Outdated
} | ||
|
||
getDirection() { | ||
return this._ready.then((webL10n) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here, and below, can we avoid shadowing the webL10n
name, given the var webL10n = document.webL10n;
definition above?
Initially, this name confused me for a second, and naming this for example l10n
instead wouldn't hurt in my opinion.
web/annotation_layer_builder.js
Outdated
@@ -24,6 +24,7 @@ import { SimpleLinkService } from './pdf_link_service'; | |||
* @property {boolean} renderInteractiveForms | |||
* @property {IPDFLinkService} linkService | |||
* @property {DownloadManager} downloadManager | |||
* @property {IL10n} l10n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: For consistency, let's make this
* @property {IL10n} l10n - Localization service.
web/pdf_thumbnail_viewer.js
Outdated
@@ -26,6 +26,7 @@ var THUMBNAIL_SCROLL_MARGIN = -19; | |||
* elements. | |||
* @property {IPDFLinkService} linkService - The navigation/linking service. | |||
* @property {PDFRenderingQueue} renderingQueue - The rendering queue object. | |||
* @property {IL10n} l10n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: For consistency, let's make this
* @property {IL10n} l10n - Localization service.
web/interfaces.js
Outdated
@@ -118,9 +118,39 @@ class IPDFAnnotationLayerFactory { | |||
/** | |||
* @param {HTMLDivElement} pageDiv | |||
* @param {PDFPage} pdfPage | |||
* @param {IL10n} l10n, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Remove the comma.
web/app.js
Outdated
@@ -740,27 +772,27 @@ var PDFViewerApplication = { | |||
* and optionally a 'stack' property. | |||
*/ | |||
error: function pdfViewError(message, moreInfo) { | |||
var moreInfoText = mozL10n.get('error_version_info', | |||
var moreInfoText = [this.l10n.get('error_version_info', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Since you're already touching this line, let's change var
to let
.
web/app.js
Outdated
'PDF documents are not allowed to use their own colors: ' + | ||
'\'Allow pages to choose their own colors\' ' + | ||
'is deactivated in the browser.')); | ||
'is deactivated in the browser.').then((msg) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Let's indent the above three lines with two more spaces, to improve readability here.
web/app.js
Outdated
_initializeL10n() { | ||
if ((typeof PDFJSDev === 'undefined' || | ||
!PDFJSDev.test('FIREFOX || MOZCENTRAL')) && | ||
PDFViewerApplication.viewerPrefs['pdfBugEnabled']) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above condition isn't exactly equal to the current ones, since in master
it's possible to change the #locale
in dev-mode (i.e. when using gulp server
) without having the 'pdfBugEnabled' pref set.
I think it'd be nice if we could keep that behaviour, so this needs to look something like:
if (((typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION')) ||
this.viewerPrefs['pdfBugEnabled']) &&
(typeof PDFJSDev === 'undefined' ||
!PDFJSDev.test('FIREFOX || MOZCENTRAL'))) {
Obviously that isn't as readable as one would like, but it may be possible to simplify the condition somewhat.
web/app.js
Outdated
!PDFViewerApplication.supportsDocumentFonts) { | ||
PDFJS.disableFontFace = true; | ||
PDFViewerApplication.l10n.get('web_fonts_disabled', null, | ||
'Web fonts are disabled: unable to use embedded PDF fonts.'). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: Let's indent this line with two more spaces, to improve readability here.
web/password_prompt.js
Outdated
} | ||
|
||
this.label.textContent = promptString; | ||
promptString.then((msg) => { | ||
this.label.textContent = promptString; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs to be this.label.textContent = msg;
.
@Snuffleupagus thanks for the review /botio-windows preview |
From: Bot.io (Windows)ReceivedCommand cmd_preview from @yurydelendik received. Current queue size: 0 Live output at: http://54.215.176.217:8877/21dff0cbfb857ad/output.txt |
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/21dff0cbfb857ad/output.txt Total script time: 19.47 mins Published |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've left a couple of final comments; and please also add createL10n
to DefaultExternalServices
in https://github.com/mozilla/pdf.js/blob/master/web/app.js#L67.
Please note that when rebasing this, the changes to the hand_tool.js
and secondary_toolbar.js
files are no longer needed!
This looks really good, thanks for working on this!
web/pdf_viewer.js
Outdated
@@ -899,16 +902,19 @@ var PDFViewer = (function pdfViewer() { | |||
* @param {HTMLDivElement} pageDiv | |||
* @param {PDFPage} pdfPage | |||
* @param {boolean} renderInteractiveForms | |||
* @param {L10n} l10n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the type be {IL10n}
here, since that's used everywhere else?
web/annotation_layer_builder.js
Outdated
@@ -96,15 +96,18 @@ class DefaultAnnotationLayerFactory { | |||
* @param {HTMLDivElement} pageDiv | |||
* @param {PDFPage} pdfPage | |||
* @param {boolean} renderInteractiveForms | |||
* @param {L10n} l10n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the type be {IL10n}
here, since that's used everywhere else?
web/app.js
Outdated
// It is not possible to change locale for Firefox extension builds. | ||
if (typeof PDFJSDev === 'undefined' || !PDFJSDev.test('PRODUCTION') || | ||
(!PDFJSDev.test('FIREFOX || MOZCENTRAL') && | ||
PDFViewerApplication.viewerPrefs['pdfBugEnabled'])) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This can be this.viewerPrefs['pdfBugEnabled']
, given the current scope here (and you're already using this.externalServices
below).
web/pdf_thumbnail_view.js
Outdated
@@ -30,6 +30,7 @@ var THUMBNAIL_CANVAS_BORDER_WIDTH = 1; // px | |||
* @property {boolean} disableCanvasToImageConversion - (optional) Don't convert | |||
* the canvas thumbnails to images. This prevents `toDataURL` calls, | |||
* but increases the overall memory usage. The default value is false. | |||
* @property {L10n} l10n - Localization service. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't the type be {IL10n}
here, since that's used everywhere else?
web/pdf_thumbnail_view.js
Outdated
@@ -64,6 +65,7 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() { | |||
/** | |||
* @constructs PDFThumbnailView | |||
* @param {PDFThumbnailViewOptions} options | |||
* @param {IL10n} l10n |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this line, since it's passed in with the options now.
web/toolbar.js
Outdated
return; | ||
} | ||
|
||
let selectScaleOption = (value, scale, l10n) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove the l10n
parameter, since it's now unused.
@@ -998,7 +998,6 @@ document.webL10n = (function(window, document, undefined) { | |||
loadLocale(lang, function() { | |||
if (callback) | |||
callback(); | |||
translateFragment(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mention this change at https://github.com/yurydelendik/pdf.js/blob/6f76510a74f086de4fdb9a21a677649de9618c56/external/webL10n/l10n.js#L24 as well. If we update webL10n
in the future, this change may be accidentally reverted if it's not mentioned there.
/botio-windows preview |
From: Bot.io (Windows)ReceivedCommand cmd_preview from @yurydelendik received. Current queue size: 0 Live output at: http://54.215.176.217:8877/28e5a95d406952c/output.txt |
From: Bot.io (Windows)SuccessFull output at http://54.215.176.217:8877/28e5a95d406952c/output.txt Total script time: 21.89 mins Published |
Wraps mozL10n to async calls; splits firefox and generic l10n libs.
No description provided.