| OLD | NEW |
| 1 "use strict"; | 1 "use strict"; |
| 2 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 2 // Copyright (c) 2014 The Chromium Authors. All rights reserved. |
| 3 // Use of this source code is governed by a BSD-style license that can be | 3 // Use of this source code is governed by a BSD-style license that can be |
| 4 // found in the LICENSE file. | 4 // found in the LICENSE file. |
| 5 | 5 |
| 6 var global = { | 6 var global = { |
| 7 argumentsReceived: false, | 7 argumentsReceived: false, |
| 8 params: null, | 8 params: null, |
| 9 picker: null | 9 picker: null |
| 10 }; | 10 }; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 window.pagePopupController.setValue(this._selectElement.value); | 171 window.pagePopupController.setValue(this._selectElement.value); |
| 172 } | 172 } |
| 173 }; | 173 }; |
| 174 | 174 |
| 175 ListPicker.prototype._fixWindowSize = function() { | 175 ListPicker.prototype._fixWindowSize = function() { |
| 176 this._selectElement.style.height = ""; | 176 this._selectElement.style.height = ""; |
| 177 this._selectElement.size = 20; | 177 this._selectElement.size = 20; |
| 178 var maxHeight = this._selectElement.offsetHeight; | 178 var maxHeight = this._selectElement.offsetHeight; |
| 179 this._selectElement.style.height = "0"; | 179 this._selectElement.style.height = "0"; |
| 180 var heightOutsideOfContent = this._selectElement.offsetHeight - this._select
Element.clientHeight; | 180 var heightOutsideOfContent = this._selectElement.offsetHeight - this._select
Element.clientHeight; |
| 181 var desiredWindowHeight = Math.round(this._calculateScrollHeight() + heightO
utsideOfContent); | 181 var noScrollHeight = Math.round(this._calculateScrollHeight() + heightOutsid
eOfContent); |
| 182 if (desiredWindowHeight > maxHeight) | 182 var desiredWindowHeight = noScrollHeight; |
| 183 var desiredWindowWidth = this._selectElement.offsetWidth; |
| 184 var expectingScrollbar = false; |
| 185 if (desiredWindowHeight > maxHeight) { |
| 183 desiredWindowHeight = maxHeight; | 186 desiredWindowHeight = maxHeight; |
| 184 var desiredWindowWidth = Math.max(this._config.anchorRectInScreen.width, thi
s._selectElement.offsetWidth); | 187 // Setting overflow to auto does not increase width for the scrollbar |
| 188 // so we need to do it manually. |
| 189 desiredWindowWidth += getScrollbarWidth(); |
| 190 expectingScrollbar = true; |
| 191 } |
| 192 desiredWindowWidth = Math.max(this._config.anchorRectInScreen.width, desired
WindowWidth); |
| 185 var windowRect = adjustWindowRect(desiredWindowWidth, desiredWindowHeight, t
his._selectElement.offsetWidth, 0); | 193 var windowRect = adjustWindowRect(desiredWindowWidth, desiredWindowHeight, t
his._selectElement.offsetWidth, 0); |
| 194 // If the available screen space is smaller than maxHeight, we will get an u
nexpected scrollbar. |
| 195 if (!expectingScrollbar && windowRect.height < noScrollHeight) { |
| 196 desiredWindowWidth = windowRect.width + getScrollbarWidth(); |
| 197 windowRect = adjustWindowRect(desiredWindowWidth, windowRect.height, win
dowRect.width, windowRect.height); |
| 198 } |
| 186 this._selectElement.style.width = windowRect.width + "px"; | 199 this._selectElement.style.width = windowRect.width + "px"; |
| 187 this._selectElement.style.height = windowRect.height + "px"; | 200 this._selectElement.style.height = windowRect.height + "px"; |
| 188 this._element.style.height = windowRect.height + "px"; | 201 this._element.style.height = windowRect.height + "px"; |
| 189 setWindowRect(windowRect); | 202 setWindowRect(windowRect); |
| 190 }; | 203 }; |
| 191 | 204 |
| 192 ListPicker.prototype._calculateScrollHeight = function() { | 205 ListPicker.prototype._calculateScrollHeight = function() { |
| 193 // Element.scrollHeight returns an integer value but this calculate the | 206 // Element.scrollHeight returns an integer value but this calculate the |
| 194 // actual fractional value. | 207 // actual fractional value. |
| 195 var top = Infinity; | 208 var top = Infinity; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 } | 342 } |
| 330 this._applyItemStyle(element, config.style); | 343 this._applyItemStyle(element, config.style); |
| 331 }; | 344 }; |
| 332 | 345 |
| 333 if (window.dialogArguments) { | 346 if (window.dialogArguments) { |
| 334 initialize(dialogArguments); | 347 initialize(dialogArguments); |
| 335 } else { | 348 } else { |
| 336 window.addEventListener("message", handleMessage, false); | 349 window.addEventListener("message", handleMessage, false); |
| 337 window.setTimeout(handleArgumentsTimeout, 1000); | 350 window.setTimeout(handleArgumentsTimeout, 1000); |
| 338 } | 351 } |
| OLD | NEW |