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

Enable forwarding, in FirefoxCom, of the matchesCount to the browser findbar (bug 1062025) #10071

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion web/firefoxcom.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ PDFViewerApplication.externalServices = {
},

updateFindMatchesCount(data) {
// FirefoxCom.request('updateFindMatchesCount', data);
FirefoxCom.request('updateFindMatchesCount', data);
},

initPassiveLoading(callbacks) {
Expand Down
35 changes: 26 additions & 9 deletions web/pdf_find_bar.js
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,33 @@ class PDFFindBar {

if (total) {
if (total > limit) {
matchesCountMsg = this.l10n.get('find_matches_count_limit', {
n: limit,
limit: limit.toLocaleString(),
}, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) {
// TODO: Remove this hard-coded `[other]` form once plural support has
// been implemented in the mozilla-central specific `l10n.js` file.
matchesCountMsg = this.l10n.get('find_matches_count_limit[other]', {
limit: limit.toLocaleString(),
}, 'More than {{limit}} matches');
} else {
matchesCountMsg = this.l10n.get('find_matches_count_limit', {
n: limit,
limit: limit.toLocaleString(),
}, 'More than {{limit}} match' + (limit !== 1 ? 'es' : ''));
}
} else {
matchesCountMsg = this.l10n.get('find_matches_count', {
n: total,
current: current.toLocaleString(),
total: total.toLocaleString(),
}, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
if (typeof PDFJSDev !== 'undefined' && PDFJSDev.test('MOZCENTRAL')) {
// TODO: Remove this hard-coded `[other]` form once plural support has
// been implemented in the mozilla-central specific `l10n.js` file.
matchesCountMsg = this.l10n.get('find_matches_count[other]', {
current: current.toLocaleString(),
total: total.toLocaleString(),
}, '{{current}} of {{total}} matches');
} else {
matchesCountMsg = this.l10n.get('find_matches_count', {
n: total,
current: current.toLocaleString(),
total: total.toLocaleString(),
}, '{{current}} of {{total}} match' + (total !== 1 ? 'es' : ''));
}
}
}
Promise.resolve(matchesCountMsg).then((msg) => {
Expand Down
2 changes: 1 addition & 1 deletion web/pdf_find_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -510,7 +510,7 @@ class PDFFindController {
// When searching starts, this method may be called before the `pageMatches`
// have been counted (in `_calculateMatch`). Ensure that the UI won't show
// temporarily broken state when the active find result doesn't make sense.
if (current > total) {
if (current < 1 || current > total) {
current = total = 0;
}
return { current, total, };
Expand Down