| 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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 // be reopened. | 186 // be reopened. |
| 187 setTimeout(function () { | 187 setTimeout(function () { |
| 188 window.pagePopupController.closePopup(); | 188 window.pagePopupController.closePopup(); |
| 189 }, 0); | 189 }, 0); |
| 190 event.preventDefault(); | 190 event.preventDefault(); |
| 191 } | 191 } |
| 192 }; | 192 }; |
| 193 | 193 |
| 194 ListPicker.prototype._fixWindowSize = function() { | 194 ListPicker.prototype._fixWindowSize = function() { |
| 195 this._selectElement.style.height = ""; | 195 this._selectElement.style.height = ""; |
| 196 var maxHeight = this._selectElement.offsetHeight; | 196 var scale = global.params.scaleFactor; |
| 197 var maxHeight = this._selectElement.offsetHeight / scale; |
| 198 |
| 197 // heightOutsideOfContent should be matched to border widths of the listbox | 199 // heightOutsideOfContent should be matched to border widths of the listbox |
| 198 // SELECT. See listPicker.css and html.css. | 200 // SELECT. See listPicker.css and html.css. |
| 199 var heightOutsideOfContent = 2; | 201 var heightOutsideOfContent = 2; |
| 200 var noScrollHeight = Math.round(this._calculateScrollHeight() + heightOutsid
eOfContent); | 202 var noScrollHeight = Math.round(this._calculateScrollHeight() + heightOutsid
eOfContent) / scale; |
| 201 var desiredWindowHeight = noScrollHeight; | 203 var desiredWindowHeight = noScrollHeight; |
| 202 var desiredWindowWidth = this._selectElement.offsetWidth; | 204 var offsetWidth = this._selectElement.offsetWidth / scale; |
| 205 var desiredWindowWidth = offsetWidth; |
| 206 |
| 203 var expectingScrollbar = false; | 207 var expectingScrollbar = false; |
| 204 if (desiredWindowHeight > maxHeight) { | 208 if (desiredWindowHeight > maxHeight) { |
| 205 desiredWindowHeight = maxHeight; | 209 desiredWindowHeight = maxHeight; |
| 206 // Setting overflow to auto does not increase width for the scrollbar | 210 // Setting overflow to auto does not increase width for the scrollbar |
| 207 // so we need to do it manually. | 211 // so we need to do it manually. |
| 208 desiredWindowWidth += getScrollbarWidth(); | 212 desiredWindowWidth += getScrollbarWidth() / scale; |
| 209 expectingScrollbar = true; | 213 expectingScrollbar = true; |
| 210 } | 214 } |
| 211 desiredWindowWidth = Math.max(this._config.anchorRectInScreen.width, desired
WindowWidth); | 215 desiredWindowWidth = Math.max(this._config.anchorRectInScreen.width, desired
WindowWidth); |
| 212 var windowRect = adjustWindowRect(desiredWindowWidth, desiredWindowHeight, t
his._selectElement.offsetWidth, 0); | 216 var windowRect = adjustWindowRect(desiredWindowWidth, desiredWindowHeight, o
ffsetWidth, 0); |
| 217 |
| 213 // If the available screen space is smaller than maxHeight, we will get an u
nexpected scrollbar. | 218 // If the available screen space is smaller than maxHeight, we will get an u
nexpected scrollbar. |
| 214 if (!expectingScrollbar && windowRect.height < noScrollHeight) { | 219 if (!expectingScrollbar && windowRect.height < noScrollHeight) { |
| 215 desiredWindowWidth = windowRect.width + getScrollbarWidth(); | 220 desiredWindowWidth = windowRect.width + getScrollbarWidth() / scale; |
| 216 windowRect = adjustWindowRect(desiredWindowWidth, windowRect.height, win
dowRect.width, windowRect.height); | 221 windowRect = adjustWindowRect(desiredWindowWidth, windowRect.height, win
dowRect.width, windowRect.height); |
| 217 } | 222 } |
| 218 this._selectElement.style.width = windowRect.width + "px"; | 223 |
| 219 this._selectElement.style.height = windowRect.height + "px"; | 224 this._selectElement.style.width = Math.round(windowRect.width * scale) + "px
"; |
| 220 this._element.style.height = windowRect.height + "px"; | 225 this._selectElement.style.height = Math.round(windowRect.height * scale) + "
px"; |
| 226 this._element.style.height = Math.round(windowRect.height * scale) + "px"; |
| 221 setWindowRect(windowRect); | 227 setWindowRect(windowRect); |
| 222 }; | 228 }; |
| 223 | 229 |
| 224 ListPicker.prototype._calculateScrollHeight = function() { | 230 ListPicker.prototype._calculateScrollHeight = function() { |
| 225 // Element.scrollHeight returns an integer value but this calculate the | 231 // Element.scrollHeight returns an integer value but this calculate the |
| 226 // actual fractional value. | 232 // actual fractional value. |
| 227 var top = Infinity; | 233 var top = Infinity; |
| 228 var bottom = -Infinity; | 234 var bottom = -Infinity; |
| 229 for (var i = 0; i < this._selectElement.children.length; i++) { | 235 for (var i = 0; i < this._selectElement.children.length; i++) { |
| 230 var rect = this._selectElement.children[i].getBoundingClientRect(); | 236 var rect = this._selectElement.children[i].getBoundingClientRect(); |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 } | 427 } |
| 422 this._applyItemStyle(element, config.style); | 428 this._applyItemStyle(element, config.style); |
| 423 }; | 429 }; |
| 424 | 430 |
| 425 if (window.dialogArguments) { | 431 if (window.dialogArguments) { |
| 426 initialize(dialogArguments); | 432 initialize(dialogArguments); |
| 427 } else { | 433 } else { |
| 428 window.addEventListener("message", handleMessage, false); | 434 window.addEventListener("message", handleMessage, false); |
| 429 window.setTimeout(handleArgumentsTimeout, 1000); | 435 window.setTimeout(handleArgumentsTimeout, 1000); |
| 430 } | 436 } |
| OLD | NEW |