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 203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
214 }, 0); | 214 }, 0); |
215 event.preventDefault(); | 215 event.preventDefault(); |
216 } | 216 } |
217 }; | 217 }; |
218 | 218 |
219 ListPicker.prototype._fixWindowSize = function() { | 219 ListPicker.prototype._fixWindowSize = function() { |
220 this._selectElement.style.height = ""; | 220 this._selectElement.style.height = ""; |
221 var zoom = this._config.zoomFactor; | 221 var zoom = this._config.zoomFactor; |
222 var maxHeight = this._selectElement.offsetHeight * zoom; | 222 var maxHeight = this._selectElement.offsetHeight * zoom; |
223 var noScrollHeight = (this._calculateScrollHeight() + ListPicker.ListboxSele
ctBorder * 2) * zoom; | 223 var noScrollHeight = (this._calculateScrollHeight() + ListPicker.ListboxSele
ctBorder * 2) * zoom; |
224 var scrollbarWidth = getScrollbarWidth() * zoom; | |
225 var elementOffsetWidth = this._selectElement.offsetWidth * zoom; | 224 var elementOffsetWidth = this._selectElement.offsetWidth * zoom; |
226 var desiredWindowHeight = noScrollHeight; | 225 var desiredWindowHeight = noScrollHeight; |
227 var desiredWindowWidth = elementOffsetWidth; | 226 var desiredWindowWidth = elementOffsetWidth; |
228 var expectingScrollbar = false; | 227 var expectingScrollbar = false; |
229 if (desiredWindowHeight > maxHeight) { | 228 if (desiredWindowHeight > maxHeight) { |
230 desiredWindowHeight = maxHeight; | 229 desiredWindowHeight = maxHeight; |
231 // Setting overflow to auto does not increase width for the scrollbar | 230 // Setting overflow to auto does not increase width for the scrollbar |
232 // so we need to do it manually. | 231 // so we need to do it manually. |
233 desiredWindowWidth += scrollbarWidth; | |
234 expectingScrollbar = true; | 232 expectingScrollbar = true; |
235 } | 233 } |
236 desiredWindowWidth = Math.max(this._config.anchorRectInScreen.width, desired
WindowWidth); | 234 desiredWindowWidth = Math.max(this._config.anchorRectInScreen.width, desired
WindowWidth); |
237 var windowRect = adjustWindowRect(desiredWindowWidth, desiredWindowHeight, e
lementOffsetWidth, 0); | 235 var windowRect = adjustWindowRect(desiredWindowWidth, desiredWindowHeight, e
lementOffsetWidth, 0); |
238 // If the available screen space is smaller than maxHeight, we will get an u
nexpected scrollbar. | 236 // If the available screen space is smaller than maxHeight, we will get an u
nexpected scrollbar. |
239 if (!expectingScrollbar && windowRect.height < noScrollHeight) { | 237 if (!expectingScrollbar && windowRect.height < noScrollHeight) { |
240 desiredWindowWidth = windowRect.width + scrollbarWidth; | 238 desiredWindowWidth = windowRect.width; |
241 windowRect = adjustWindowRect(desiredWindowWidth, windowRect.height, win
dowRect.width, windowRect.height); | 239 windowRect = adjustWindowRect(desiredWindowWidth, windowRect.height, win
dowRect.width, windowRect.height); |
242 } | 240 } |
243 this._selectElement.style.width = (windowRect.width / zoom) + "px"; | 241 this._selectElement.style.width = (windowRect.width / zoom) + "px"; |
244 this._selectElement.style.height = (windowRect.height / zoom) + "px"; | 242 this._selectElement.style.height = (windowRect.height / zoom) + "px"; |
245 this._element.style.height = (windowRect.height / zoom) + "px"; | 243 this._element.style.height = (windowRect.height / zoom) + "px"; |
246 setWindowRect(windowRect); | 244 setWindowRect(windowRect); |
247 }; | 245 }; |
248 | 246 |
249 ListPicker.prototype._calculateScrollHeight = function() { | 247 ListPicker.prototype._calculateScrollHeight = function() { |
250 // Element.scrollHeight returns an integer value but this calculate the | 248 // Element.scrollHeight returns an integer value but this calculate the |
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
446 } | 444 } |
447 this._applyItemStyle(element, config.style); | 445 this._applyItemStyle(element, config.style); |
448 }; | 446 }; |
449 | 447 |
450 if (window.dialogArguments) { | 448 if (window.dialogArguments) { |
451 initialize(dialogArguments); | 449 initialize(dialogArguments); |
452 } else { | 450 } else { |
453 window.addEventListener("message", handleMessage, false); | 451 window.addEventListener("message", handleMessage, false); |
454 window.setTimeout(handleArgumentsTimeout, 1000); | 452 window.setTimeout(handleArgumentsTimeout, 1000); |
455 } | 453 } |
OLD | NEW |