diff options
author | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-20 10:33:36 +0100 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2017-11-22 11:45:12 +0000 |
commit | be59a35641616a4cf23c4a13fa0632624b021c1b (patch) | |
tree | 9da183258bdf9cc413f7562079d25ace6955467f /chromium/chrome/browser/resources/pdf | |
parent | d702e4b6a64574e97fc7df8fe3238cde70242080 (diff) |
BASELINE: Update Chromium to 62.0.3202.101
Change-Id: I2d5eca8117600df6d331f6166ab24d943d9814ac
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Diffstat (limited to 'chromium/chrome/browser/resources/pdf')
14 files changed, 78 insertions, 69 deletions
diff --git a/chromium/chrome/browser/resources/pdf/browser_api.js b/chromium/chrome/browser/resources/pdf/browser_api.js index 85822de29c1..34da975c46c 100644 --- a/chromium/chrome/browser/resources/pdf/browser_api.js +++ b/chromium/chrome/browser/resources/pdf/browser_api.js @@ -49,7 +49,6 @@ function lookupInitialZoom(streamInfo) { */ class BrowserApi { /** - * @constructor * @param {!Object} streamInfo The stream object which points to the data * contained in the PDF. * @param {number} defaultZoom The default browser zoom. @@ -104,9 +103,9 @@ class BrowserApi { setZoom(zoom) { if (this.zoomBehavior_ != BrowserApi.ZoomBehavior.MANAGE) return Promise.reject(new Error('Viewer does not manage browser zoom.')); - return new Promise(function(resolve, reject) { + return new Promise((resolve, reject) => { chrome.tabs.setZoom(this.streamInfo_.tabId, zoom, resolve); - }.bind(this)); + }); } /** @@ -143,13 +142,13 @@ class BrowserApi { this.zoomBehavior_ == BrowserApi.ZoomBehavior.PROPAGATE_PARENT)) return; - chrome.tabs.onZoomChange.addListener(function(info) { + chrome.tabs.onZoomChange.addListener(info => { var zoomChangeInfo = /** @type {{tabId: number, newZoomFactor: number}} */ (info); if (zoomChangeInfo.tabId != this.streamInfo_.tabId) return; listener(zoomChangeInfo.newZoomFactor); - }.bind(this)); + }); } } diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/viewer-error-screen.html b/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/viewer-error-screen.html index 10a850ee4d3..6844a004b41 100644 --- a/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/viewer-error-screen.html +++ b/chromium/chrome/browser/resources/pdf/elements/viewer-error-screen/viewer-error-screen.html @@ -7,14 +7,13 @@ <template> <style include="cr-shared-style"></style> <dialog is="cr-dialog" id="dialog" no-cancel> - <div class="title" slot="title"> + <div slot="title"> [[strings.errorDialogTitle]] </div> - <div class="body" slot="body"> + <div slot="body"> [[strings.pageLoadFailed]] </div> - <div class="button-container" slot="button-container" - hidden$="[[!reloadFn]]"> + <div slot="button-container" hidden$="[[!reloadFn]]"> <paper-button class="action-button" on-click="reload"> [[strings.pageReload]] </paper-button> diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/viewer-page-indicator.js b/chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/viewer-page-indicator.js index 96f7f3d07f4..48631d854d1 100644 --- a/chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/viewer-page-indicator.js +++ b/chromium/chrome/browser/resources/pdf/elements/viewer-page-indicator/viewer-page-indicator.js @@ -47,10 +47,10 @@ Polymer({ this.style.opacity = 1; clearTimeout(this.timerId); - this.timerId = setTimeout(function() { + this.timerId = setTimeout(() => { this.style.opacity = 0; this.timerId = undefined; - }.bind(this), displayTime); + }, displayTime); }, pageLabelsChanged: function() { diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/viewer-password-screen.html b/chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/viewer-password-screen.html index 76351c2eda9..485a061243c 100644 --- a/chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/viewer-password-screen.html +++ b/chromium/chrome/browser/resources/pdf/elements/viewer-password-screen/viewer-password-screen.html @@ -16,8 +16,8 @@ } </style> <dialog is="cr-dialog" id="dialog" no-cancel> - <div class="title" slot="title">[[strings.passwordDialogTitle]]</div> - <div class="body" slot="body"> + <div slot="title">[[strings.passwordDialogTitle]]</div> + <div slot="body"> <div id="message">[[strings.passwordPrompt]]</div> <paper-input id="password" type="password" @@ -27,7 +27,7 @@ autofocus> </paper-input> </div> - <div class="button-container" slot="button-container"> + <div slot="button-container"> <paper-button id="submit" class="action-button" on-click="submit"> [[strings.passwordSubmit]] </paper-button> diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html b/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html index 3935b7625f3..bc6553aab56 100644 --- a/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html +++ b/chromium/chrome/browser/resources/pdf/elements/viewer-pdf-toolbar/viewer-pdf-toolbar.html @@ -48,8 +48,8 @@ #buttons { @apply(--layout-flex-5); - -webkit-user-select: none; text-align: end; + user-select: none; } paper-icon-button { diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.html b/chromium/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.html index f36fcc9a3bd..83947a3e12f 100644 --- a/chromium/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.html +++ b/chromium/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.html @@ -75,7 +75,7 @@ <div id="dropdown" style="display: none"> <h1>{{header}}</h1> <div id="scroll-container"> - <content></content> + <slot></slot> </div> </div> </div> diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.js b/chromium/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.js index 53e9acc5318..f1751dd3306 100644 --- a/chromium/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.js +++ b/chromium/chrome/browser/resources/pdf/elements/viewer-toolbar-dropdown/viewer-toolbar-dropdown.js @@ -93,11 +93,11 @@ Polymer({ */ playAnimation_: function(isEntry) { this.animation_ = isEntry ? this.animateEntry_() : this.animateExit_(); - this.animation_.onfinish = function() { + this.animation_.onfinish = () => { this.animation_ = null; if (!this.dropdownOpen) this.$.dropdown.style.display = 'none'; - }.bind(this); + }; }, animateEntry_: function() { diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html b/chromium/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html index 757c24ef859..aba9da429c1 100644 --- a/chromium/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html +++ b/chromium/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.html @@ -7,11 +7,11 @@ <template> <style> :host { - -webkit-user-select: none; bottom: 0; padding: 48px 0; position: fixed; right: 0; + user-select: none; z-index: 3; } diff --git a/chromium/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.js b/chromium/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.js index 6a4af8f4aa3..f76c8cb596b 100644 --- a/chromium/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.js +++ b/chromium/chrome/browser/resources/pdf/elements/viewer-zoom-toolbar/viewer-zoom-toolbar.js @@ -56,6 +56,17 @@ Polymer({ }, /** + * Handle forcing zoom to fit-to-page via scripting. + */ + forceFitToPage: function() { + this.fire('fit-to-page'); + + // Set the button state since there was no mouse click. Since the zoom is + // set to fit-to-page, the button should do fit-to-width on the next click. + this.$['fit-button'].activeIndex = FIT_TO_WIDTH; + }, + + /** * Handle clicks of the zoom-in-button. */ zoomIn: function() { diff --git a/chromium/chrome/browser/resources/pdf/pdf.js b/chromium/chrome/browser/resources/pdf/pdf.js index 46c54bea404..ffc2a4907c9 100644 --- a/chromium/chrome/browser/resources/pdf/pdf.js +++ b/chromium/chrome/browser/resources/pdf/pdf.js @@ -123,9 +123,9 @@ function PDFViewer(browserApi) { this.errorScreen_ = $('error-screen'); // Can only reload if we are in a normal tab. if (chrome.tabs && this.browserApi_.getStreamInfo().tabId != -1) { - this.errorScreen_.reloadFn = function() { + this.errorScreen_.reloadFn = () => { chrome.tabs.reload(this.browserApi_.getStreamInfo().tabId); - }.bind(this); + }; } // Create the viewport. @@ -147,7 +147,8 @@ function PDFViewer(browserApi) { // according to the scroll position of the window. this.plugin_ = document.createElement('embed'); // NOTE: The plugin's 'id' field must be set to 'plugin' since - // chrome/renderer/printing/print_web_view_helper.cc actually references it. + // chrome/renderer/printing/print_render_frame_helper.cc actually + // references it. this.plugin_.id = 'plugin'; this.plugin_.type = 'application/x-google-chrome-pdf'; this.plugin_.addEventListener( @@ -215,16 +216,16 @@ function PDFViewer(browserApi) { this.toolbar_.docTitle = getFilenameFromURL(this.originalUrl_); } - document.body.addEventListener('change-page', function(e) { + document.body.addEventListener('change-page', e => { this.viewport_.goToPage(e.detail.page); - }.bind(this)); + }); - document.body.addEventListener('navigate', function(e) { + document.body.addEventListener('navigate', e => { var disposition = e.detail.newtab ? Navigator.WindowOpenDisposition.NEW_BACKGROUND_TAB : Navigator.WindowOpenDisposition.CURRENT_TAB; this.navigator_.navigate(e.detail.uri, disposition); - }.bind(this)); + }); this.toolbarManager_ = new ToolbarManager(window, this.toolbar_, this.zoomToolbar_); @@ -273,7 +274,7 @@ PDFViewer.prototype = { this.toolbarManager_.hideToolbarsAfterTimeout(e); - var pageUpHandler = function() { + var pageUpHandler = () => { // Go to the previous page if we are fit-to-page. if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { this.viewport_.goToPage(this.viewport_.getMostVisiblePage() - 1); @@ -283,8 +284,8 @@ PDFViewer.prototype = { position.y -= this.viewport.size.height; this.viewport.position = position; } - }.bind(this); - var pageDownHandler = function() { + }; + var pageDownHandler = () => { // Go to the next page if we are fit-to-page. if (this.viewport_.fittingType == Viewport.FittingType.FIT_TO_PAGE) { this.viewport_.goToPage(this.viewport_.getMostVisiblePage() + 1); @@ -294,7 +295,7 @@ PDFViewer.prototype = { position.y += this.viewport.size.height; this.viewport.position = position; } - }.bind(this); + }; switch (e.keyCode) { case 9: // Tab key. @@ -717,10 +718,10 @@ PDFViewer.prototype = { // Throttle number of pinch events to one per frame. if (!this.sentPinchEvent_) { this.sentPinchEvent_ = true; - window.requestAnimationFrame(function() { + window.requestAnimationFrame(() => { this.sentPinchEvent_ = false; this.viewport_.pinchZoom(e); - }.bind(this)); + }); } }, @@ -732,9 +733,9 @@ PDFViewer.prototype = { onPinchEnd_: function(e) { // Using rAF for pinch end prevents pinch updates scheduled by rAF getting // sent after the pinch end. - window.requestAnimationFrame(function() { + window.requestAnimationFrame(() => { this.viewport_.pinchZoomEnd(e); - }.bind(this)); + }); }, /** @@ -849,7 +850,7 @@ PDFViewer.prototype = { this.loadState_ = LoadState.LOADING; if (!this.inPrintPreviewMode_) { this.inPrintPreviewMode_ = true; - this.viewport_.fitToPage(); + this.zoomToolbar_.forceFitToPage(); } // Stash the scroll location so that it can be restored when the new diff --git a/chromium/chrome/browser/resources/pdf/pdf_scripting_api.js b/chromium/chrome/browser/resources/pdf/pdf_scripting_api.js index fd5e2e1559c..a133b5268f5 100644 --- a/chromium/chrome/browser/resources/pdf/pdf_scripting_api.js +++ b/chromium/chrome/browser/resources/pdf/pdf_scripting_api.js @@ -53,7 +53,7 @@ function PDFScriptingAPI(window, plugin) { this.pendingScriptingMessages_ = []; this.setPlugin(plugin); - window.addEventListener('message', function(event) { + window.addEventListener('message', event => { if (event.origin != 'chrome-extension://mhjfbmdgcfjbbpaeojofohoefgiehjai' && event.origin != 'chrome://print') { console.error( @@ -95,7 +95,7 @@ function PDFScriptingAPI(window, plugin) { this.keyEventCallback_(DeserializeKeyEvent(event.data.keyEvent)); break; } - }.bind(this), false); + }, false); } PDFScriptingAPI.prototype = { diff --git a/chromium/chrome/browser/resources/pdf/toolbar_manager.js b/chromium/chrome/browser/resources/pdf/toolbar_manager.js index 958b9ee3946..6fa82bf92d9 100644 --- a/chromium/chrome/browser/resources/pdf/toolbar_manager.js +++ b/chromium/chrome/browser/resources/pdf/toolbar_manager.js @@ -233,9 +233,9 @@ ToolbarManager.prototype = { return; this.toolbar_.hide(); this.sideToolbarAllowedOnly_ = true; - this.sideToolbarAllowedOnlyTimer_ = this.window_.setTimeout(function() { + this.sideToolbarAllowedOnlyTimer_ = this.window_.setTimeout(() => { this.sideToolbarAllowedOnlyTimer_ = null; - }.bind(this), FORCE_HIDE_TIMEOUT); + }, FORCE_HIDE_TIMEOUT); }, /** diff --git a/chromium/chrome/browser/resources/pdf/viewport.js b/chromium/chrome/browser/resources/pdf/viewport.js index 54f166bc6d4..358922c606b 100644 --- a/chromium/chrome/browser/resources/pdf/viewport.js +++ b/chromium/chrome/browser/resources/pdf/viewport.js @@ -397,10 +397,10 @@ Viewport.prototype = { newZoom = Math.max( Viewport.ZOOM_FACTOR_RANGE.min, Math.min(newZoom, Viewport.ZOOM_FACTOR_RANGE.max)); - this.mightZoom_(function() { + this.mightZoom_(() => { this.setZoomInternal_(newZoom); this.updateViewport_(); - }.bind(this)); + }); }, /** @@ -409,7 +409,7 @@ Viewport.prototype = { * @param {number} oldBrowserZoom the previous value of the browser zoom. */ updateZoomFromBrowserChange: function(oldBrowserZoom) { - this.mightZoom_(function() { + this.mightZoom_(() => { // Record the scroll position (relative to the top-left of the window). var oldZoom = oldBrowserZoom * this.internalZoom_; var currentScrollPos = { @@ -423,7 +423,7 @@ Viewport.prototype = { y: currentScrollPos.y * this.zoom }; this.updateViewport_(); - }.bind(this)); + }); }, /** @@ -565,7 +565,7 @@ Viewport.prototype = { * Zoom the viewport so that the page-width consumes the entire viewport. */ fitToWidth: function() { - this.mightZoom_(function() { + this.mightZoom_(() => { this.fittingType_ = Viewport.FittingType.FIT_TO_WIDTH; if (!this.documentDimensions_) return; @@ -575,7 +575,7 @@ Viewport.prototype = { this.computeFittingZoom_(this.documentDimensions_, true)); var page = this.getMostVisiblePage(); this.updateViewport_(); - }.bind(this)); + }); }, /** @@ -586,7 +586,7 @@ Viewport.prototype = { * should remain at the current scroll position. */ fitToPageInternal_: function(scrollToTopOfPage) { - this.mightZoom_(function() { + this.mightZoom_(() => { this.fittingType_ = Viewport.FittingType.FIT_TO_PAGE; if (!this.documentDimensions_) return; @@ -601,7 +601,7 @@ Viewport.prototype = { this.position = {x: 0, y: this.pageDimensions_[page].y * this.zoom}; } this.updateViewport_(); - }.bind(this)); + }); }, /** @@ -616,7 +616,7 @@ Viewport.prototype = { * Zoom out to the next predefined zoom level. */ zoomOut: function() { - this.mightZoom_(function() { + this.mightZoom_(() => { this.fittingType_ = Viewport.FittingType.NONE; var nextZoom = Viewport.ZOOM_FACTORS[0]; for (var i = 0; i < Viewport.ZOOM_FACTORS.length; i++) { @@ -625,14 +625,14 @@ Viewport.prototype = { } this.setZoomInternal_(nextZoom); this.updateViewport_(); - }.bind(this)); + }); }, /** * Zoom in to the next predefined zoom level. */ zoomIn: function() { - this.mightZoom_(function() { + this.mightZoom_(() => { this.fittingType_ = Viewport.FittingType.NONE; var nextZoom = Viewport.ZOOM_FACTORS[Viewport.ZOOM_FACTORS.length - 1]; for (var i = Viewport.ZOOM_FACTORS.length - 1; i >= 0; i--) { @@ -641,7 +641,7 @@ Viewport.prototype = { } this.setZoomInternal_(nextZoom); this.updateViewport_(); - }.bind(this)); + }); }, /** @@ -649,7 +649,7 @@ Viewport.prototype = { * @param {!Object} e The pinch event. */ pinchZoom: function(e) { - this.mightZoom_(function() { + this.mightZoom_(() => { this.pinchPhase_ = e.direction == 'out' ? Viewport.PinchPhase.PINCH_UPDATE_ZOOM_OUT : Viewport.PinchPhase.PINCH_UPDATE_ZOOM_IN; @@ -684,7 +684,7 @@ Viewport.prototype = { this.setPinchZoomInternal_(scaleDelta, frameToPluginCoordinate(e.center)); this.updateViewport_(); this.prevScale_ = e.startScaleRatio; - }.bind(this)); + }); }, pinchZoomStart: function(e) { @@ -701,14 +701,14 @@ Viewport.prototype = { }, pinchZoomEnd: function(e) { - this.mightZoom_(function() { + this.mightZoom_(() => { this.pinchPhase_ = Viewport.PinchPhase.PINCH_END; var scaleDelta = e.startScaleRatio / this.prevScale_; this.pinchCenter_ = e.center; this.setPinchZoomInternal_(scaleDelta, frameToPluginCoordinate(e.center)); this.updateViewport_(); - }.bind(this)); + }); this.pinchPhase_ = Viewport.PinchPhase.PINCH_NONE; this.pinchPanVector_ = null; @@ -721,7 +721,7 @@ Viewport.prototype = { * @param {number} page the index of the page to go to. zero-based. */ goToPage: function(page) { - this.mightZoom_(function() { + this.mightZoom_(() => { if (this.pageDimensions_.length === 0) return; if (page < 0) @@ -740,7 +740,7 @@ Viewport.prototype = { y: dimensions.y * this.zoom - toolbarOffset }; this.updateViewport_(); - }.bind(this)); + }); }, /** @@ -748,7 +748,7 @@ Viewport.prototype = { * @param {Object} documentDimensions the dimensions of the document */ setDocumentDimensions: function(documentDimensions) { - this.mightZoom_(function() { + this.mightZoom_(() => { var initialDimensions = !this.documentDimensions_; this.documentDimensions_ = documentDimensions; this.pageDimensions_ = this.documentDimensions_.pageDimensions; @@ -760,7 +760,7 @@ Viewport.prototype = { } this.contentSizeChanged_(); this.resize_(); - }.bind(this)); + }); }, /** diff --git a/chromium/chrome/browser/resources/pdf/zoom_manager.js b/chromium/chrome/browser/resources/pdf/zoom_manager.js index eec9115cd84..3ca81814d94 100644 --- a/chromium/chrome/browser/resources/pdf/zoom_manager.js +++ b/chromium/chrome/browser/resources/pdf/zoom_manager.js @@ -145,16 +145,15 @@ class ActiveZoomManager extends ZoomManager { if (this.floatingPointEquals(this.browserZoom_, zoom)) return; - this.changingBrowserZoom_ = - this.setBrowserZoomFunction_(zoom).then(function() { - this.browserZoom_ = zoom; - this.changingBrowserZoom_ = null; - - // The extension's zoom level may have changed while the browser zoom - // change was in progress. We call back into onPdfZoomChange to ensure - // the browser zoom is up to date. - this.onPdfZoomChange(); - }.bind(this)); + this.changingBrowserZoom_ = this.setBrowserZoomFunction_(zoom).then(() => { + this.browserZoom_ = zoom; + this.changingBrowserZoom_ = null; + + // The extension's zoom level may have changed while the browser zoom + // change was in progress. We call back into onPdfZoomChange to ensure + // the browser zoom is up to date. + this.onPdfZoomChange(); + }); } /** |