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 cr.define('extensions', function() { | 5 cr.define('extensions', function() { |
6 'use strict'; | 6 'use strict'; |
7 | 7 |
8 /** | 8 /** |
9 * The ExtensionOptionsOverlay will show an extension's options page using | 9 * The ExtensionOptionsOverlay will show an extension's options page using |
10 * an <extensionoptions> element. | 10 * an <extensionoptions> element. |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
120 // undesirable effects. | 120 // undesirable effects. |
121 var animation = null; | 121 var animation = null; |
122 | 122 |
123 /** | 123 /** |
124 * Resize the overlay if the <extensionoptions> changes preferred size. | 124 * Resize the overlay if the <extensionoptions> changes preferred size. |
125 * @param {{width: number, height: number}} evt | 125 * @param {{width: number, height: number}} evt |
126 */ | 126 */ |
127 extensionoptions.onpreferredsizechanged = function(evt) { | 127 extensionoptions.onpreferredsizechanged = function(evt) { |
128 var oldWidth = parseInt(overlayStyle.width, 10); | 128 var oldWidth = parseInt(overlayStyle.width, 10); |
129 var oldHeight = parseInt(overlayStyle.height, 10); | 129 var oldHeight = parseInt(overlayStyle.height, 10); |
130 var newWidth = Math.max(evt.width, minWidth); | 130 // The overlay must be slightly larger than the extension options to |
131 var newHeight = Math.min(evt.height, maxHeight); | 131 // avoid creating scrollbars. |
| 132 // TODO(paulmeyer): This shouldn't be necessary, but the preferred size |
| 133 // (coming from Blink) seems to be too small for some zoom levels. The |
| 134 // 2-pixel addition should be removed once this problem is investigated |
| 135 // and corrected. |
| 136 var newWidth = Math.max(evt.width + 2, minWidth); |
| 137 var newHeight = Math.min(evt.height + 2, maxHeight); |
132 | 138 |
133 // animationTime is the amount of time in ms that will be used to resize | 139 // animationTime is the amount of time in ms that will be used to resize |
134 // the overlay. It is calculated by multiplying the pythagorean distance | 140 // the overlay. It is calculated by multiplying the pythagorean distance |
135 // between old and the new size (in px) with a constant speed of | 141 // between old and the new size (in px) with a constant speed of |
136 // 0.25 ms/px. | 142 // 0.25 ms/px. |
137 var loading = document.documentElement.classList.contains('loading'); | 143 var loading = document.documentElement.classList.contains('loading'); |
138 var animationTime = loading ? 0 : | 144 var animationTime = loading ? 0 : |
139 0.25 * Math.sqrt(Math.pow(newWidth - oldWidth, 2) + | 145 0.25 * Math.sqrt(Math.pow(newWidth - oldWidth, 2) + |
140 Math.pow(newHeight - oldHeight, 2)); | 146 Math.pow(newHeight - oldHeight, 2)); |
141 | 147 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 /** @type {HTMLDivElement} */($('extension-options-overlay')) : | 199 /** @type {HTMLDivElement} */($('extension-options-overlay')) : |
194 null); | 200 null); |
195 } | 201 } |
196 }; | 202 }; |
197 | 203 |
198 // Export | 204 // Export |
199 return { | 205 return { |
200 ExtensionOptionsOverlay: ExtensionOptionsOverlay | 206 ExtensionOptionsOverlay: ExtensionOptionsOverlay |
201 }; | 207 }; |
202 }); | 208 }); |
OLD | NEW |