Commit 89ebbb68 authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Chromium LUCI CQ

PDF Viewer: Delegate two-up-view tracking to the plugin

Currently, both the plugin and the UI track the state of two-up-view.
Additionally, the state tracked by the plugin is consistently sent to
the UI.

While two-up-view can only be invoked on through the UI, the feature
actually occurs asynchronously. It would be better to update the UI
state with that of the plugin.

Change-Id: Id0b40c2fa0d7d4eb029bbb06d8eb162871938385
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2631360
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Cr-Commit-Position: refs/heads/master@{#844870}
parent 6b08bfc7
......@@ -544,7 +544,6 @@ export class PDFViewerElement extends PDFViewerBaseElement {
onResetView_() {
if (this.twoUpViewEnabled_) {
this.currentController.setTwoUpView(false);
this.twoUpViewEnabled_ = false;
}
const rotations = this.viewport.getClockwiseRotations();
......@@ -777,12 +776,12 @@ export class PDFViewerElement extends PDFViewerBaseElement {
* @private
*/
onTwoUpViewChanged_(e) {
this.twoUpViewEnabled_ = e.detail;
this.currentController.setTwoUpView(this.twoUpViewEnabled_);
const twoUpViewEnabled = e.detail;
this.currentController.setTwoUpView(twoUpViewEnabled);
if (!this.pdfViewerUpdateEnabled_) {
this.toolbarManager_.forceHideTopToolbar();
}
recordTwoUpViewEnabled(this.twoUpViewEnabled_);
recordTwoUpViewEnabled(twoUpViewEnabled);
}
/**
......@@ -848,12 +847,9 @@ export class PDFViewerElement extends PDFViewerBaseElement {
}
// Update toolbar elements.
if (this.toolbarEnabled_) {
const visiblePage = this.viewport.getMostVisiblePage();
this.pageNo_ = visiblePage + 1;
this.clockwiseRotations_ = this.viewport.getClockwiseRotations();
}
this.pageNo_ = this.viewport.getMostVisiblePage() + 1;
this.twoUpViewEnabled_ = this.viewport.twoUpViewEnabled();
this.currentController.viewportChanged();
}
......
......@@ -237,10 +237,7 @@ export class Viewport {
/** @return {boolean} Whether viewport is in two-up view mode. */
twoUpViewEnabled() {
const options = this.getLayoutOptions();
if (options === undefined) {
return false;
}
return options.twoUpViewEnabled;
return !!options && options.twoUpViewEnabled;
}
/**
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment