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

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

Issue 477933003: OOP PDF - Add OpenPDFParamsParser class (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove invalid comment and change method name Created 6 years, 3 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 area of the intersection of two rectangles. 6 * Returns the area 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 area of the intersection of the rects 9 * @return {number} the area of the intersection of the rects
10 */ 10 */
(...skipping 27 matching lines...) Expand all
38 this.sizer_ = sizer; 38 this.sizer_ = sizer;
39 this.viewportChangedCallback_ = viewportChangedCallback; 39 this.viewportChangedCallback_ = viewportChangedCallback;
40 this.beforeZoomCallback_ = beforeZoomCallback; 40 this.beforeZoomCallback_ = beforeZoomCallback;
41 this.afterZoomCallback_ = afterZoomCallback; 41 this.afterZoomCallback_ = afterZoomCallback;
42 this.allowedToChangeZoom_ = false; 42 this.allowedToChangeZoom_ = false;
43 this.zoom_ = 1; 43 this.zoom_ = 1;
44 this.documentDimensions_ = null; 44 this.documentDimensions_ = null;
45 this.pageDimensions_ = []; 45 this.pageDimensions_ = [];
46 this.scrollbarWidth_ = scrollbarWidth; 46 this.scrollbarWidth_ = scrollbarWidth;
47 this.fittingType_ = Viewport.FittingType.NONE; 47 this.fittingType_ = Viewport.FittingType.NONE;
48 this.initialViewport_ = {};
48 49
49 window.addEventListener('scroll', this.updateViewport_.bind(this)); 50 window.addEventListener('scroll', this.updateViewport_.bind(this));
50 window.addEventListener('resize', this.resize_.bind(this)); 51 window.addEventListener('resize', this.resize_.bind(this));
51 } 52 }
52 53
53 /** 54 /**
54 * Enumeration of page fitting types. 55 * Enumeration of page fitting types.
55 * @enum {string} 56 * @enum {string}
56 */ 57 */
57 Viewport.FittingType = { 58 Viewport.FittingType = {
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
169 170
170 /** 171 /**
171 * Scroll the viewport to the specified position. 172 * Scroll the viewport to the specified position.
172 * @type {Object} position the position to scroll to. 173 * @type {Object} position the position to scroll to.
173 */ 174 */
174 set position(position) { 175 set position(position) {
175 this.window_.scrollTo(position.x, position.y); 176 this.window_.scrollTo(position.x, position.y);
176 }, 177 },
177 178
178 /** 179 /**
180 * Initial viewport settings to be used to open pdf. These are
181 * set by parsing open pdf parameters.
182 */
183 set initialViewportSettings(viewportSettings) {
184 this.initialViewport_ = viewportSettings;
185 },
raymes 2014/08/27 01:02:24 I think we don't need this setter, we can just cal
Nikhil 2014/08/27 10:16:09 Done.
186
187 /**
179 * @type {Object} the size of the viewport excluding scrollbars. 188 * @type {Object} the size of the viewport excluding scrollbars.
180 */ 189 */
181 get size() { 190 get size() {
182 var needsScrollbars = this.documentNeedsScrollbars_(this.zoom_); 191 var needsScrollbars = this.documentNeedsScrollbars_(this.zoom_);
183 var scrollbarWidth = needsScrollbars.vertical ? this.scrollbarWidth_ : 0; 192 var scrollbarWidth = needsScrollbars.vertical ? this.scrollbarWidth_ : 0;
184 var scrollbarHeight = needsScrollbars.horizontal ? this.scrollbarWidth_ : 0; 193 var scrollbarHeight = needsScrollbars.horizontal ? this.scrollbarWidth_ : 0;
185 return { 194 return {
186 width: this.window_.innerWidth - scrollbarWidth, 195 width: this.window_.innerWidth - scrollbarWidth,
187 height: this.window_.innerHeight - scrollbarHeight 196 height: this.window_.innerHeight - scrollbarHeight
188 }; 197 };
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
540 spaceOnLeft = Math.max(spaceOnLeft, 0); 549 spaceOnLeft = Math.max(spaceOnLeft, 0);
541 550
542 return { 551 return {
543 x: x * this.zoom_ + spaceOnLeft - this.window_.pageXOffset, 552 x: x * this.zoom_ + spaceOnLeft - this.window_.pageXOffset,
544 y: insetDimensions.y * this.zoom_ - this.window_.pageYOffset, 553 y: insetDimensions.y * this.zoom_ - this.window_.pageYOffset,
545 width: insetDimensions.width * this.zoom_, 554 width: insetDimensions.width * this.zoom_,
546 height: insetDimensions.height * this.zoom_ 555 height: insetDimensions.height * this.zoom_
547 }; 556 };
548 } 557 }
549 }; 558 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698