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 |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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'), HTMLDivElement); |
Dan Beam
2015/10/16 07:20:47
why do these need to be HTMLDivElement rather than
fukino
2015/10/19 09:55:14
As we call createElement('div'), we expect the ret
Dan Beam
2015/10/20 00:33:37
yes, i understand. HTMLDivElement#align is the /o
| |
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'), HTMLDivElement); |
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'), HTMLDivElement); |
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'), HTMLDivElement); |
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'), HTMLDivElement); |
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'), |
106 HTMLDivElement); | |
106 this.shadowRight_.className = 'shadow'; | 107 this.shadowRight_.className = 'shadow'; |
107 this.middleBox_.appendChild(this.shadowRight_); | 108 this.middleBox_.appendChild(this.shadowRight_); |
108 | 109 |
109 this.shadowBottom_ = doc.createElement('div'); | 110 this.shadowBottom_ = assertInstanceof(doc.createElement('div'), |
111 HTMLDivElement); | |
110 this.shadowBottom_.className = 'shadow'; | 112 this.shadowBottom_.className = 'shadow'; |
111 this.domOverlay_.appendChild(this.shadowBottom_); | 113 this.domOverlay_.appendChild(this.shadowBottom_); |
112 | 114 |
113 var cropFrame = this.cropFrame_; | 115 var cropFrame = this.cropFrame_; |
114 function addCropFrame(className) { | 116 function addCropFrame(className) { |
115 var div = doc.createElement('div'); | 117 var div = doc.createElement('div'); |
116 div.className = className; | 118 div.className = className; |
117 cropFrame.appendChild(div); | 119 cropFrame.appendChild(div); |
118 } | 120 } |
119 | 121 |
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
737 break; | 739 break; |
738 case 'bottom': | 740 case 'bottom': |
739 this.bounds_.bottom = this.bounds_.top + newHeight; | 741 this.bounds_.bottom = this.bounds_.top + newHeight; |
740 break; | 742 break; |
741 case 'none': | 743 case 'none': |
742 this.bounds_.top = middle - newHeight / 2; | 744 this.bounds_.top = middle - newHeight / 2; |
743 this.bounds_.bottom = middle + newHeight / 2; | 745 this.bounds_.bottom = middle + newHeight / 2; |
744 break; | 746 break; |
745 } | 747 } |
746 }; | 748 }; |
OLD | NEW |