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

Side by Side Diff: chrome/browser/resources/pdf/viewport.js

Issue 806633003: Implement basic toolbar with Material Design and loading progress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Strip out unnecessary components Created 5 years, 11 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 unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 /** 5 /**
6 * Returns the height of the intersection of two rectangles. 6 * Returns the height of the intersection of two rectangles.
7 * @param {Object} rect1 the first rect 7 * @param {Object} rect1 the first rect
8 * @param {Object} rect2 the second rect 8 * @param {Object} rect2 the second rect
9 * @return {number} the height of the intersection of the rects 9 * @return {number} the height of the intersection of the rects
10 */ 10 */
(...skipping 23 matching lines...) Expand all
34 this.sizer_ = sizer; 34 this.sizer_ = sizer;
35 this.viewportChangedCallback_ = viewportChangedCallback; 35 this.viewportChangedCallback_ = viewportChangedCallback;
36 this.beforeZoomCallback_ = beforeZoomCallback; 36 this.beforeZoomCallback_ = beforeZoomCallback;
37 this.afterZoomCallback_ = afterZoomCallback; 37 this.afterZoomCallback_ = afterZoomCallback;
38 this.allowedToChangeZoom_ = false; 38 this.allowedToChangeZoom_ = false;
39 this.zoom_ = 1; 39 this.zoom_ = 1;
40 this.documentDimensions_ = null; 40 this.documentDimensions_ = null;
41 this.pageDimensions_ = []; 41 this.pageDimensions_ = [];
42 this.scrollbarWidth_ = scrollbarWidth; 42 this.scrollbarWidth_ = scrollbarWidth;
43 this.fittingType_ = Viewport.FittingType.NONE; 43 this.fittingType_ = Viewport.FittingType.NONE;
44 var toolbar = $('pdf-toolbar');
45 this.toolbarHeight_ = (toolbar) ? toolbar.clientHeight : 0;
raymes 2015/01/09 04:15:10 Can we pass the toolbar height into the viewport.
Alexandre Carlton 2015/01/12 06:33:57 Done.
44 46
45 window.addEventListener('scroll', this.updateViewport_.bind(this)); 47 window.addEventListener('scroll', this.updateViewport_.bind(this));
46 window.addEventListener('resize', this.resize_.bind(this)); 48 window.addEventListener('resize', this.resize_.bind(this));
47 } 49 }
48 50
49 /** 51 /**
50 * Enumeration of page fitting types. 52 * Enumeration of page fitting types.
51 * @enum {string} 53 * @enum {string}
52 */ 54 */
53 Viewport.FittingType = { 55 Viewport.FittingType = {
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 return this.documentNeedsScrollbars_(this.zoom_); 129 return this.documentNeedsScrollbars_(this.zoom_);
128 }, 130 },
129 131
130 /** 132 /**
131 * @private 133 * @private
132 * Helper function called when the zoomed document size changes. 134 * Helper function called when the zoomed document size changes.
133 */ 135 */
134 contentSizeChanged_: function() { 136 contentSizeChanged_: function() {
135 if (this.documentDimensions_) { 137 if (this.documentDimensions_) {
136 this.sizer_.style.width = 138 this.sizer_.style.width =
137 this.documentDimensions_.width * this.zoom_ + 'px'; 139 this.documentDimensions_.width * this.zoom_ +
140 this.toolbarHeight_ + 'px';
raymes 2015/01/09 04:15:10 We shouldn't need to adjust the width
Alexandre Carlton 2015/01/12 06:33:57 Done.
138 this.sizer_.style.height = 141 this.sizer_.style.height =
139 this.documentDimensions_.height * this.zoom_ + 'px'; 142 this.documentDimensions_.height * this.zoom_ +
143 this.toolbarHeight_ + 'px';
140 } 144 }
141 }, 145 },
142 146
143 /** 147 /**
144 * @private 148 * @private
145 * Called when the viewport should be updated. 149 * Called when the viewport should be updated.
146 */ 150 */
147 updateViewport_: function() { 151 updateViewport_: function() {
148 this.viewportChangedCallback_(); 152 this.viewportChangedCallback_();
149 }, 153 },
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 spaceOnLeft = Math.max(spaceOnLeft, 0); 543 spaceOnLeft = Math.max(spaceOnLeft, 0);
540 544
541 return { 545 return {
542 x: x * this.zoom_ + spaceOnLeft - this.window_.pageXOffset, 546 x: x * this.zoom_ + spaceOnLeft - this.window_.pageXOffset,
543 y: insetDimensions.y * this.zoom_ - this.window_.pageYOffset, 547 y: insetDimensions.y * this.zoom_ - this.window_.pageYOffset,
544 width: insetDimensions.width * this.zoom_, 548 width: insetDimensions.width * this.zoom_,
545 height: insetDimensions.height * this.zoom_ 549 height: insetDimensions.height * this.zoom_
546 }; 550 };
547 } 551 }
548 }; 552 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698