| 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 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 80 ListPicker.prototype._handleWindowMessage = function(event) { | 80 ListPicker.prototype._handleWindowMessage = function(event) { |
| 81 eval(event.data); | 81 eval(event.data); |
| 82 if (window.updateData.type === "update") { | 82 if (window.updateData.type === "update") { |
| 83 this._config.baseStyle = window.updateData.baseStyle; | 83 this._config.baseStyle = window.updateData.baseStyle; |
| 84 this._config.children = window.updateData.children; | 84 this._config.children = window.updateData.children; |
| 85 this._update(); | 85 this._update(); |
| 86 } | 86 } |
| 87 delete window.updateData; | 87 delete window.updateData; |
| 88 }; | 88 }; |
| 89 | 89 |
| 90 // This should be matched to the border width of the internal listbox |
| 91 // SELECT. See listPicker.css and html.css. |
| 92 ListPicker.ListboxSelectBorder = 1; |
| 93 |
| 90 ListPicker.prototype._handleWindowMouseMove = function (event) { | 94 ListPicker.prototype._handleWindowMouseMove = function (event) { |
| 95 var visibleTop = ListPicker.ListboxSelectBorder; |
| 96 var visibleBottom = this._selectElement.offsetHeight - ListPicker.ListboxSel
ectBorder; |
| 97 var optionBounds = event.target.getBoundingClientRect(); |
| 98 if (optionBounds.height >= 1.0) { |
| 99 // If the height of the visible part of event.target is less than 1px, |
| 100 // ignore this event because it may be an error by sub-pixel layout. |
| 101 if (optionBounds.top < visibleTop) { |
| 102 if (optionBounds.bottom - visibleTop < 1.0) |
| 103 return; |
| 104 } else if (optionBounds.bottom > visibleBottom) { |
| 105 if (visibleBottom - optionBounds.top < 1.0) |
| 106 return; |
| 107 } |
| 108 } |
| 91 this.lastMousePositionX = event.clientX; | 109 this.lastMousePositionX = event.clientX; |
| 92 this.lastMousePositionY = event.clientY; | 110 this.lastMousePositionY = event.clientY; |
| 93 this._highlightOption(event.target); | 111 this._highlightOption(event.target); |
| 94 this._selectionSetByMouseHover = true; | 112 this._selectionSetByMouseHover = true; |
| 95 // Prevent the select element from firing change events for mouse input. | 113 // Prevent the select element from firing change events for mouse input. |
| 96 event.preventDefault(); | 114 event.preventDefault(); |
| 97 }; | 115 }; |
| 98 | 116 |
| 99 ListPicker.prototype._handleMouseUp = function(event) { | 117 ListPicker.prototype._handleMouseUp = function(event) { |
| 100 if (event.target.tagName !== "OPTION") | 118 if (event.target.tagName !== "OPTION") |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 187 setTimeout(function () { | 205 setTimeout(function () { |
| 188 window.pagePopupController.closePopup(); | 206 window.pagePopupController.closePopup(); |
| 189 }, 0); | 207 }, 0); |
| 190 event.preventDefault(); | 208 event.preventDefault(); |
| 191 } | 209 } |
| 192 }; | 210 }; |
| 193 | 211 |
| 194 ListPicker.prototype._fixWindowSize = function() { | 212 ListPicker.prototype._fixWindowSize = function() { |
| 195 this._selectElement.style.height = ""; | 213 this._selectElement.style.height = ""; |
| 196 var maxHeight = this._selectElement.offsetHeight; | 214 var maxHeight = this._selectElement.offsetHeight; |
| 197 // heightOutsideOfContent should be matched to border widths of the listbox | 215 var noScrollHeight = Math.round(this._calculateScrollHeight() + ListPicker.L
istboxSelectBorder * 2); |
| 198 // SELECT. See listPicker.css and html.css. | |
| 199 var heightOutsideOfContent = 2; | |
| 200 var noScrollHeight = Math.round(this._calculateScrollHeight() + heightOutsid
eOfContent); | |
| 201 var desiredWindowHeight = noScrollHeight; | 216 var desiredWindowHeight = noScrollHeight; |
| 202 var desiredWindowWidth = this._selectElement.offsetWidth; | 217 var desiredWindowWidth = this._selectElement.offsetWidth; |
| 203 var expectingScrollbar = false; | 218 var expectingScrollbar = false; |
| 204 if (desiredWindowHeight > maxHeight) { | 219 if (desiredWindowHeight > maxHeight) { |
| 205 desiredWindowHeight = maxHeight; | 220 desiredWindowHeight = maxHeight; |
| 206 // Setting overflow to auto does not increase width for the scrollbar | 221 // Setting overflow to auto does not increase width for the scrollbar |
| 207 // so we need to do it manually. | 222 // so we need to do it manually. |
| 208 desiredWindowWidth += getScrollbarWidth(); | 223 desiredWindowWidth += getScrollbarWidth(); |
| 209 expectingScrollbar = true; | 224 expectingScrollbar = true; |
| 210 } | 225 } |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 421 } | 436 } |
| 422 this._applyItemStyle(element, config.style); | 437 this._applyItemStyle(element, config.style); |
| 423 }; | 438 }; |
| 424 | 439 |
| 425 if (window.dialogArguments) { | 440 if (window.dialogArguments) { |
| 426 initialize(dialogArguments); | 441 initialize(dialogArguments); |
| 427 } else { | 442 } else { |
| 428 window.addEventListener("message", handleMessage, false); | 443 window.addEventListener("message", handleMessage, false); |
| 429 window.setTimeout(handleArgumentsTimeout, 1000); | 444 window.setTimeout(handleArgumentsTimeout, 1000); |
| 430 } | 445 } |
| OLD | NEW |