Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(502)

Unified Diff: chrome/browser/resources/pdf/pdf.js

Issue 1255403002: Add a scroll offset to PDF documents to account for the top material design toolbar. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/viewport.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/resources/pdf/pdf.js
diff --git a/chrome/browser/resources/pdf/pdf.js b/chrome/browser/resources/pdf/pdf.js
index dfa2d31dde07bfb508bd55551cb4e8d61b3acc0e..3fb61482a5e994149ec83f6ad9d9a90705b18a9a 100644
--- a/chrome/browser/resources/pdf/pdf.js
+++ b/chrome/browser/resources/pdf/pdf.js
@@ -75,6 +75,12 @@ function shouldIgnoreKeyEvents(activeElement) {
PDFViewer.MIN_TOOLBAR_OFFSET = 15;
/**
+ * The height of the toolbar along the top of the page. The document will be
+ * shifted down by this much in the viewport.
+ */
+PDFViewer.MATERIAL_TOOLBAR_HEIGHT = 64;
+
+/**
* Creates a new PDFViewer. There should only be one of these objects per
* document.
* @constructor
@@ -104,13 +110,16 @@ function PDFViewer(browserApi) {
this.errorScreen_ = $('error-screen');
// Create the viewport.
+ var topToolbarHeight =
+ this.isMaterial_ ? PDFViewer.MATERIAL_TOOLBAR_HEIGHT : 0;
this.viewport_ = new Viewport(window,
this.sizer_,
this.viewportChanged_.bind(this),
this.beforeZoom_.bind(this),
this.afterZoom_.bind(this),
getScrollbarWidth(),
- this.browserApi_.getDefaultZoom());
+ this.browserApi_.getDefaultZoom(),
+ topToolbarHeight);
// Create the plugin object dynamically so we can set its src. The plugin
// element is sized to fill the entire window and is set to be fixed
@@ -143,8 +152,11 @@ function PDFViewer(browserApi) {
}
this.plugin_.setAttribute('headers', headers);
- if (this.isMaterial_)
+ if (this.isMaterial_) {
this.plugin_.setAttribute('is-material', '');
+ this.plugin_.setAttribute('top-toolbar-height',
+ PDFViewer.MATERIAL_TOOLBAR_HEIGHT);
+ }
if (!this.browserApi_.getStreamInfo().embedded)
this.plugin_.setAttribute('full-frame', '');
« no previous file with comments | « no previous file | chrome/browser/resources/pdf/viewport.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698