Skip to content
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

Merged
merged 1 commit into from
May 31, 2017

Conversation

yurydelendik
Copy link
Contributor

No description provided.

@yurydelendik
Copy link
Contributor Author

Needed for #8402 too

@yurydelendik
Copy link
Contributor Author

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_preview from @yurydelendik received. Current queue size: 0

Live output at: http://54.215.176.217:8877/74930242f69674f/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/74930242f69674f/output.txt

Total script time: 19.14 mins

Published

@Snuffleupagus Snuffleupagus self-requested a review May 12, 2017 21:47
Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a 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
Copy link
Collaborator

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.

}

getDirection() {
return this._ready.then((webL10n) => {
Copy link
Collaborator

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.

@@ -24,6 +24,7 @@ import { SimpleLinkService } from './pdf_link_service';
* @property {boolean} renderInteractiveForms
* @property {IPDFLinkService} linkService
* @property {DownloadManager} downloadManager
* @property {IL10n} l10n
Copy link
Collaborator

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.

@@ -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
Copy link
Collaborator

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.

@@ -118,9 +118,39 @@ class IPDFAnnotationLayerFactory {
/**
* @param {HTMLDivElement} pageDiv
* @param {PDFPage} pdfPage
* @param {IL10n} l10n,
Copy link
Collaborator

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',
Copy link
Collaborator

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) => {
Copy link
Collaborator

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']) {
Copy link
Collaborator

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.').
Copy link
Collaborator

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.

}

this.label.textContent = promptString;
promptString.then((msg) => {
this.label.textContent = promptString;
Copy link
Collaborator

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;.

@yurydelendik
Copy link
Contributor Author

@Snuffleupagus thanks for the review

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_preview from @yurydelendik received. Current queue size: 0

Live output at: http://54.215.176.217:8877/21dff0cbfb857ad/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/21dff0cbfb857ad/output.txt

Total script time: 19.47 mins

Published

Copy link
Collaborator

@Snuffleupagus Snuffleupagus left a 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!

@@ -899,16 +902,19 @@ var PDFViewer = (function pdfViewer() {
* @param {HTMLDivElement} pageDiv
* @param {PDFPage} pdfPage
* @param {boolean} renderInteractiveForms
* @param {L10n} l10n
Copy link
Collaborator

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?

@@ -96,15 +96,18 @@ class DefaultAnnotationLayerFactory {
* @param {HTMLDivElement} pageDiv
* @param {PDFPage} pdfPage
* @param {boolean} renderInteractiveForms
* @param {L10n} l10n
Copy link
Collaborator

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'])) {
Copy link
Collaborator

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).

@@ -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.
Copy link
Collaborator

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?

@@ -64,6 +65,7 @@ var PDFThumbnailView = (function PDFThumbnailViewClosure() {
/**
* @constructs PDFThumbnailView
* @param {PDFThumbnailViewOptions} options
* @param {IL10n} l10n
Copy link
Collaborator

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) => {
Copy link
Collaborator

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();
Copy link
Contributor

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.

@yurydelendik
Copy link
Contributor Author

/botio-windows preview

@pdfjsbot
Copy link

From: Bot.io (Windows)


Received

Command cmd_preview from @yurydelendik received. Current queue size: 0

Live output at: http://54.215.176.217:8877/28e5a95d406952c/output.txt

@pdfjsbot
Copy link

From: Bot.io (Windows)


Success

Full output at http://54.215.176.217:8877/28e5a95d406952c/output.txt

Total script time: 21.89 mins

Published

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants