Chromium Code Reviews| 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 * Crop mode. | 6 * Crop mode. |
| 7 * | 7 * |
| 8 * @extends {ImageEditor.Mode} | 8 * @extends {ImageEditor.Mode} |
| 9 * @constructor | 9 * @constructor |
| 10 * @struct | 10 * @struct |
| 11 */ | 11 */ |
| 12 ImageEditor.Mode.Crop = function() { | 12 ImageEditor.Mode.Crop = function() { |
| 13 ImageEditor.Mode.call(this, 'crop', 'GALLERY_CROP'); | 13 ImageEditor.Mode.call(this, 'crop', 'GALLERY_CROP'); |
| 14 | 14 |
| 15 this.paddingTop = ImageEditor.Mode.Crop.MOUSE_GRAB_RADIUS; | 15 this.paddingTop = ImageEditor.Mode.Crop.MOUSE_GRAB_RADIUS; |
| 16 this.paddingBottom = ImageEditor.Mode.Crop.MOUSE_GRAB_RADIUS; | 16 this.paddingBottom = ImageEditor.Mode.Crop.MOUSE_GRAB_RADIUS; |
| 17 | 17 |
| 18 /** | 18 /** |
| 19 * @type {HTMLDivElement} | 19 * @type {HTMLElement} |
| 20 * @private | 20 * @private |
| 21 */ | 21 */ |
| 22 this.domOverlay_ = null; | 22 this.domOverlay_ = null; |
| 23 | 23 |
| 24 /** | 24 /** |
| 25 * @type {HTMLDivElement} | 25 * @type {HTMLElement} |
| 26 * @private | 26 * @private |
| 27 */ | 27 */ |
| 28 this.shadowTop_ = null; | 28 this.shadowTop_ = null; |
| 29 | 29 |
| 30 /** | 30 /** |
| 31 * @type {HTMLDivElement} | 31 * @type {HTMLElement} |
| 32 * @private | 32 * @private |
| 33 */ | 33 */ |
| 34 this.middleBox_ = null; | 34 this.middleBox_ = null; |
| 35 | 35 |
| 36 /** | 36 /** |
| 37 * @type {HTMLDivElement} | 37 * @type {HTMLElement} |
| 38 * @private | 38 * @private |
| 39 */ | 39 */ |
| 40 this.shadowLeft_ = null; | 40 this.shadowLeft_ = null; |
| 41 | 41 |
| 42 /** | 42 /** |
| 43 * @type {HTMLDivElement} | 43 * @type {HTMLElement} |
| 44 * @private | 44 * @private |
| 45 */ | 45 */ |
| 46 this.cropFrame_ = null; | 46 this.cropFrame_ = null; |
| 47 | 47 |
| 48 /** | 48 /** |
| 49 * @type {HTMLDivElement} | 49 * @type {HTMLElement} |
| 50 * @private | 50 * @private |
| 51 */ | 51 */ |
| 52 this.shadowRight_ = null; | 52 this.shadowRight_ = null; |
| 53 | 53 |
| 54 /** | 54 /** |
| 55 * @type {HTMLDivElement} | 55 * @type {HTMLElement} |
| 56 * @private | 56 * @private |
| 57 */ | 57 */ |
| 58 this.shadowBottom_ = null; | 58 this.shadowBottom_ = null; |
| 59 | 59 |
| 60 /** | 60 /** |
| 61 * @type {?function()} | 61 * @type {?function()} |
| 62 * @private | 62 * @private |
| 63 */ | 63 */ |
| 64 this.onViewportResizedBound_ = null; | 64 this.onViewportResizedBound_ = null; |
| 65 | 65 |
| 66 /** | 66 /** |
| 67 * @type {DraggableRect} | 67 * @type {DraggableRect} |
| 68 * @private | 68 * @private |
| 69 */ | 69 */ |
| 70 this.cropRect_ = null; | 70 this.cropRect_ = null; |
| 71 }; | 71 }; |
| 72 | 72 |
| 73 ImageEditor.Mode.Crop.prototype = {__proto__: ImageEditor.Mode.prototype}; | 73 ImageEditor.Mode.Crop.prototype = {__proto__: ImageEditor.Mode.prototype}; |
| 74 | 74 |
| 75 /** | 75 /** |
| 76 * Sets the mode up. | 76 * Sets the mode up. |
| 77 * @override | 77 * @override |
| 78 */ | 78 */ |
| 79 ImageEditor.Mode.Crop.prototype.setUp = function() { | 79 ImageEditor.Mode.Crop.prototype.setUp = function() { |
| 80 ImageEditor.Mode.prototype.setUp.apply(this, arguments); | 80 ImageEditor.Mode.prototype.setUp.apply(this, arguments); |
| 81 | 81 |
| 82 var container = this.getImageView().container_; | 82 var container = this.getImageView().container_; |
| 83 var doc = container.ownerDocument; | 83 var doc = container.ownerDocument; |
| 84 | 84 |
| 85 this.domOverlay_ = doc.createElement('div'); | 85 this.domOverlay_ = assertInstanceof(doc.createElement('div'), HTMLElement); |
|
Dan Beam
2015/10/21 01:35:26
assertInstanceof is not required, createElement on
fukino
2015/10/21 04:00:28
Do you suggest to use /** @type {!HTMLElement} */
| |
| 86 this.domOverlay_.className = 'crop-overlay'; | 86 this.domOverlay_.className = 'crop-overlay'; |
| 87 container.appendChild(this.domOverlay_); | 87 container.appendChild(this.domOverlay_); |
| 88 | 88 |
| 89 this.shadowTop_ = doc.createElement('div'); | 89 this.shadowTop_ = assertInstanceof(doc.createElement('div'), HTMLElement); |
| 90 this.shadowTop_.className = 'shadow'; | 90 this.shadowTop_.className = 'shadow'; |
| 91 this.domOverlay_.appendChild(this.shadowTop_); | 91 this.domOverlay_.appendChild(this.shadowTop_); |
| 92 | 92 |
| 93 this.middleBox_ = doc.createElement('div'); | 93 this.middleBox_ = assertInstanceof(doc.createElement('div'), HTMLElement); |
| 94 this.middleBox_.className = 'middle-box'; | 94 this.middleBox_.className = 'middle-box'; |
| 95 this.domOverlay_.appendChild(this.middleBox_); | 95 this.domOverlay_.appendChild(this.middleBox_); |
| 96 | 96 |
| 97 this.shadowLeft_ = doc.createElement('div'); | 97 this.shadowLeft_ = assertInstanceof(doc.createElement('div'), HTMLElement); |
| 98 this.shadowLeft_.className = 'shadow'; | 98 this.shadowLeft_.className = 'shadow'; |
| 99 this.middleBox_.appendChild(this.shadowLeft_); | 99 this.middleBox_.appendChild(this.shadowLeft_); |
| 100 | 100 |
| 101 this.cropFrame_ = doc.createElement('div'); | 101 this.cropFrame_ = assertInstanceof(doc.createElement('div'), HTMLElement); |
| 102 this.cropFrame_.className = 'crop-frame'; | 102 this.cropFrame_.className = 'crop-frame'; |
| 103 this.middleBox_.appendChild(this.cropFrame_); | 103 this.middleBox_.appendChild(this.cropFrame_); |
| 104 | 104 |
| 105 this.shadowRight_ = doc.createElement('div'); | 105 this.shadowRight_ = assertInstanceof(doc.createElement('div'), HTMLElement); |
| 106 this.shadowRight_.className = 'shadow'; | 106 this.shadowRight_.className = 'shadow'; |
| 107 this.middleBox_.appendChild(this.shadowRight_); | 107 this.middleBox_.appendChild(this.shadowRight_); |
| 108 | 108 |
| 109 this.shadowBottom_ = doc.createElement('div'); | 109 this.shadowBottom_ = assertInstanceof(doc.createElement('div'), HTMLElement); |
| 110 this.shadowBottom_.className = 'shadow'; | 110 this.shadowBottom_.className = 'shadow'; |
| 111 this.domOverlay_.appendChild(this.shadowBottom_); | 111 this.domOverlay_.appendChild(this.shadowBottom_); |
| 112 | 112 |
| 113 var cropFrame = this.cropFrame_; | 113 var cropFrame = this.cropFrame_; |
| 114 function addCropFrame(className) { | 114 function addCropFrame(className) { |
| 115 var div = doc.createElement('div'); | 115 var div = doc.createElement('div'); |
| 116 div.className = className; | 116 div.className = className; |
| 117 cropFrame.appendChild(div); | 117 cropFrame.appendChild(div); |
| 118 } | 118 } |
| 119 | 119 |
| (...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 737 break; | 737 break; |
| 738 case 'bottom': | 738 case 'bottom': |
| 739 this.bounds_.bottom = this.bounds_.top + newHeight; | 739 this.bounds_.bottom = this.bounds_.top + newHeight; |
| 740 break; | 740 break; |
| 741 case 'none': | 741 case 'none': |
| 742 this.bounds_.top = middle - newHeight / 2; | 742 this.bounds_.top = middle - newHeight / 2; |
| 743 this.bounds_.bottom = middle + newHeight / 2; | 743 this.bounds_.bottom = middle + newHeight / 2; |
| 744 break; | 744 break; |
| 745 } | 745 } |
| 746 }; | 746 }; |
| OLD | NEW |