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

Side by Side Diff: chrome/test/data/pdf/test_util.js

Issue 931013002: OOP PDF: Fix incorrect scrolling during fit-to-page (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 10 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
« no previous file with comments | « chrome/browser/resources/pdf/viewport.js ('k') | chrome/test/data/pdf/viewport_test.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 // Utilities that are used in multiple tests. 5 // Utilities that are used in multiple tests.
6 function MockWindow(width, height, sizer) { 6 function MockWindow(width, height, sizer) {
7 this.innerWidth = width; 7 this.innerWidth = width;
8 this.innerHeight = height; 8 this.innerHeight = height;
9 this.addEventListener = function(e, f) { 9 this.addEventListener = function(e, f) {
10 if (e == 'scroll') 10 if (e == 'scroll')
11 this.scrollCallback = f; 11 this.scrollCallback = f;
12 if (e == 'resize') 12 if (e == 'resize')
13 this.resizeCallback = f; 13 this.resizeCallback = f;
14 }; 14 };
15 this.setSize = function(width, height) {
16 this.innerWidth = width;
17 this.innerHeight = height;
18 this.resizeCallback();
19 }
15 this.scrollTo = function(x, y) { 20 this.scrollTo = function(x, y) {
16 if (sizer) { 21 if (sizer) {
17 x = Math.min(x, parseInt(sizer.style.width) - width); 22 x = Math.min(x, parseInt(sizer.style.width) - width);
18 y = Math.min(y, parseInt(sizer.style.height) - height); 23 y = Math.min(y, parseInt(sizer.style.height) - height);
19 } 24 }
20 this.pageXOffset = Math.max(0, x); 25 this.pageXOffset = Math.max(0, x);
21 this.pageYOffset = Math.max(0, y); 26 this.pageYOffset = Math.max(0, y);
22 this.scrollCallback(); 27 this.scrollCallback();
23 }; 28 };
24 if (sizer) { 29 if (sizer) {
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 width: w, 85 width: w,
81 height: h 86 height: h
82 }); 87 });
83 }; 88 };
84 this.reset = function() { 89 this.reset = function() {
85 this.width = 0; 90 this.width = 0;
86 this.height = 0; 91 this.height = 0;
87 this.pageDimensions = []; 92 this.pageDimensions = [];
88 }; 93 };
89 } 94 }
OLDNEW
« no previous file with comments | « chrome/browser/resources/pdf/viewport.js ('k') | chrome/test/data/pdf/viewport_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698