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

Ensure that Toolbar.setPageScale always sets the pageScaleValue property to a valid value #10138

Merged
merged 1 commit into from
Oct 5, 2018
Merged
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
14 changes: 6 additions & 8 deletions web/toolbar.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ class Toolbar {
}

setPageScale(pageScaleValue, pageScale) {
this.pageScaleValue = pageScaleValue;
this.pageScaleValue = (pageScaleValue || pageScale).toString();
this.pageScale = pageScale;
this._updateUIState(false);
}
Expand Down Expand Up @@ -171,9 +171,7 @@ class Toolbar {
// Don't update the UI state until we localize the toolbar.
return;
}
let { pageNumber, pagesCount, items, } = this;
let scaleValue = (this.pageScaleValue || this.pageScale).toString();
let scale = this.pageScale;
const { pageNumber, pagesCount, pageScaleValue, pageScale, items, } = this;

if (resetNumPages) {
if (this.hasPageLabels) {
Expand Down Expand Up @@ -201,17 +199,17 @@ class Toolbar {
items.previous.disabled = (pageNumber <= 1);
items.next.disabled = (pageNumber >= pagesCount);

items.zoomOut.disabled = (scale <= MIN_SCALE);
items.zoomIn.disabled = (scale >= MAX_SCALE);
items.zoomOut.disabled = (pageScale <= MIN_SCALE);
items.zoomIn.disabled = (pageScale >= MAX_SCALE);

let customScale = Math.round(scale * 10000) / 100;
let customScale = Math.round(pageScale * 10000) / 100;
this.l10n.get('page_scale_percent', { scale: customScale, },
'{{scale}}%').then((msg) => {
let options = items.scaleSelect.options;
let predefinedValueFound = false;
for (let i = 0, ii = options.length; i < ii; i++) {
let option = options[i];
if (option.value !== scaleValue) {
if (option.value !== pageScaleValue) {
option.selected = false;
continue;
}
Expand Down