Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(198)

Side by Side Diff: third_party/WebKit/Source/web/resources/listPicker.js

Issue 1468353002: New SELECT Popup: Do not select and scroll to an option of which visible area is less than 1px heig… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/fast/forms/select/popup-menu-mouse-operations-expected.txt ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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 // |selectBorder| should be matched the border-width of the internal SELECT
96 // |element.
keishi 2015/11/24 09:52:32 nit: extra comment
tkent 2015/11/24 12:23:41 Removed.
97 var visibleTop = ListPicker.ListboxSelectBorder;
98 var visibleBottom = this._selectElement.offsetHeight - ListPicker.ListboxSel ectBorder;
99 var optionBounds = event.target.getBoundingClientRect();
100 if (optionBounds.height >= 1.0) {
101 // If the height of the visible part of event.target is less than 1px,
102 // ignore this event because it may be an error by sub-pixel layout.
103 if (optionBounds.top < visibleTop) {
104 if (optionBounds.bottom - visibleTop < 1.0)
105 return;
106 } else if (optionBounds.bottom > visibleBottom) {
107 if (visibleBottom - optionBounds.top < 1.0)
108 return;
109 }
110 }
91 this.lastMousePositionX = event.clientX; 111 this.lastMousePositionX = event.clientX;
92 this.lastMousePositionY = event.clientY; 112 this.lastMousePositionY = event.clientY;
93 this._highlightOption(event.target); 113 this._highlightOption(event.target);
94 this._selectionSetByMouseHover = true; 114 this._selectionSetByMouseHover = true;
95 // Prevent the select element from firing change events for mouse input. 115 // Prevent the select element from firing change events for mouse input.
96 event.preventDefault(); 116 event.preventDefault();
97 }; 117 };
98 118
99 ListPicker.prototype._handleMouseUp = function(event) { 119 ListPicker.prototype._handleMouseUp = function(event) {
100 if (event.target.tagName !== "OPTION") 120 if (event.target.tagName !== "OPTION")
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 setTimeout(function () { 207 setTimeout(function () {
188 window.pagePopupController.closePopup(); 208 window.pagePopupController.closePopup();
189 }, 0); 209 }, 0);
190 event.preventDefault(); 210 event.preventDefault();
191 } 211 }
192 }; 212 };
193 213
194 ListPicker.prototype._fixWindowSize = function() { 214 ListPicker.prototype._fixWindowSize = function() {
195 this._selectElement.style.height = ""; 215 this._selectElement.style.height = "";
196 var maxHeight = this._selectElement.offsetHeight; 216 var maxHeight = this._selectElement.offsetHeight;
197 // heightOutsideOfContent should be matched to border widths of the listbox 217 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; 218 var desiredWindowHeight = noScrollHeight;
202 var desiredWindowWidth = this._selectElement.offsetWidth; 219 var desiredWindowWidth = this._selectElement.offsetWidth;
203 var expectingScrollbar = false; 220 var expectingScrollbar = false;
204 if (desiredWindowHeight > maxHeight) { 221 if (desiredWindowHeight > maxHeight) {
205 desiredWindowHeight = maxHeight; 222 desiredWindowHeight = maxHeight;
206 // Setting overflow to auto does not increase width for the scrollbar 223 // Setting overflow to auto does not increase width for the scrollbar
207 // so we need to do it manually. 224 // so we need to do it manually.
208 desiredWindowWidth += getScrollbarWidth(); 225 desiredWindowWidth += getScrollbarWidth();
209 expectingScrollbar = true; 226 expectingScrollbar = true;
210 } 227 }
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 } 438 }
422 this._applyItemStyle(element, config.style); 439 this._applyItemStyle(element, config.style);
423 }; 440 };
424 441
425 if (window.dialogArguments) { 442 if (window.dialogArguments) {
426 initialize(dialogArguments); 443 initialize(dialogArguments);
427 } else { 444 } else {
428 window.addEventListener("message", handleMessage, false); 445 window.addEventListener("message", handleMessage, false);
429 window.setTimeout(handleArgumentsTimeout, 1000); 446 window.setTimeout(handleArgumentsTimeout, 1000);
430 } 447 }
OLDNEW
« no previous file with comments | « third_party/WebKit/LayoutTests/platform/win/fast/forms/select/popup-menu-mouse-operations-expected.txt ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698