| OLD | NEW |
| 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 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 page = this.pageDimensions_.length - 1; | 414 page = this.pageDimensions_.length - 1; |
| 415 var dimensions = this.pageDimensions_[page]; | 415 var dimensions = this.pageDimensions_[page]; |
| 416 this.window_.scrollTo(dimensions.x * this.zoom_, dimensions.y * this.zoom_); | 416 this.window_.scrollTo(dimensions.x * this.zoom_, dimensions.y * this.zoom_); |
| 417 }, | 417 }, |
| 418 | 418 |
| 419 /** | 419 /** |
| 420 * Set the dimensions of the document. | 420 * Set the dimensions of the document. |
| 421 * @param {Object} documentDimensions the dimensions of the document | 421 * @param {Object} documentDimensions the dimensions of the document |
| 422 */ | 422 */ |
| 423 setDocumentDimensions: function(documentDimensions) { | 423 setDocumentDimensions: function(documentDimensions) { |
| 424 var initialDimensions = !this.documentDimensions_; |
| 424 this.documentDimensions_ = documentDimensions; | 425 this.documentDimensions_ = documentDimensions; |
| 425 this.pageDimensions_ = this.documentDimensions_.pageDimensions; | 426 this.pageDimensions_ = this.documentDimensions_.pageDimensions; |
| 427 if (initialDimensions) { |
| 428 this.setZoom_(this.computeFittingZoom_(this.documentDimensions_, true)); |
| 429 if (this.zoom_ > 1) |
| 430 this.setZoom_(1); |
| 431 this.window_.scrollTo(0, 0); |
| 432 } |
| 426 this.contentSizeChanged_(); | 433 this.contentSizeChanged_(); |
| 427 this.resize_(); | 434 this.resize_(); |
| 428 }, | 435 }, |
| 429 | 436 |
| 430 /** | 437 /** |
| 431 * Get the coordinates of the page contents (excluding the page shadow) | 438 * Get the coordinates of the page contents (excluding the page shadow) |
| 432 * relative to the screen. | 439 * relative to the screen. |
| 433 * @param {number} page the index of the page to get the rect for. | 440 * @param {number} page the index of the page to get the rect for. |
| 434 * @return {Object} a rect representing the page in screen coordinates. | 441 * @return {Object} a rect representing the page in screen coordinates. |
| 435 */ | 442 */ |
| (...skipping 18 matching lines...) Expand all Loading... |
| 454 (this.size.width - pageDimensions.width * this.zoom_) / 2.0, 0); | 461 (this.size.width - pageDimensions.width * this.zoom_) / 2.0, 0); |
| 455 | 462 |
| 456 return { | 463 return { |
| 457 x: Viewport.PAGE_SHADOW.left + spaceOnLeft - this.window_.pageXOffset, | 464 x: Viewport.PAGE_SHADOW.left + spaceOnLeft - this.window_.pageXOffset, |
| 458 y: (insetDimensions.y * this.zoom_) - this.window_.pageYOffset, | 465 y: (insetDimensions.y * this.zoom_) - this.window_.pageYOffset, |
| 459 width: insetDimensions.width * this.zoom_, | 466 width: insetDimensions.width * this.zoom_, |
| 460 height: insetDimensions.height * this.zoom_ | 467 height: insetDimensions.height * this.zoom_ |
| 461 }; | 468 }; |
| 462 } | 469 } |
| 463 }; | 470 }; |
| OLD | NEW |