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

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

Issue 1456753002: Compute the popup location/size correctly when use-zoom-for-dsf is enabled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update TestExpectations Created 5 years 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
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 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // be reopened. 204 // be reopened.
205 setTimeout(function () { 205 setTimeout(function () {
206 window.pagePopupController.closePopup(); 206 window.pagePopupController.closePopup();
207 }, 0); 207 }, 0);
208 event.preventDefault(); 208 event.preventDefault();
209 } 209 }
210 }; 210 };
211 211
212 ListPicker.prototype._fixWindowSize = function() { 212 ListPicker.prototype._fixWindowSize = function() {
213 this._selectElement.style.height = ""; 213 this._selectElement.style.height = "";
214 var maxHeight = this._selectElement.offsetHeight; 214 var zoom = this._config.zoomFactor;
215 var noScrollHeight = this._calculateScrollHeight() + ListPicker.ListboxSelec tBorder * 2; 215 var maxHeight = this._selectElement.offsetHeight * zoom;
216 var noScrollHeight = (this._calculateScrollHeight() + ListPicker.ListboxSele ctBorder * 2) * zoom;
217 var scrollbarWidth = getScrollbarWidth() * zoom;
218 var elementOffsetWidth = this._selectElement.offsetWidth * zoom;
216 var desiredWindowHeight = noScrollHeight; 219 var desiredWindowHeight = noScrollHeight;
217 var desiredWindowWidth = this._selectElement.offsetWidth; 220 var desiredWindowWidth = elementOffsetWidth;
218 var expectingScrollbar = false; 221 var expectingScrollbar = false;
219 if (desiredWindowHeight > maxHeight) { 222 if (desiredWindowHeight > maxHeight) {
220 desiredWindowHeight = maxHeight; 223 desiredWindowHeight = maxHeight;
221 // Setting overflow to auto does not increase width for the scrollbar 224 // Setting overflow to auto does not increase width for the scrollbar
222 // so we need to do it manually. 225 // so we need to do it manually.
223 desiredWindowWidth += getScrollbarWidth(); 226 desiredWindowWidth += scrollbarWidth;
224 expectingScrollbar = true; 227 expectingScrollbar = true;
225 } 228 }
226 var zoom = this._config.zoomFactor; 229 desiredWindowWidth = Math.max(this._config.anchorRectInScreen.width, desired WindowWidth);
227 desiredWindowWidth = Math.max(this._config.anchorRectInScreen.width / zoom, desiredWindowWidth); 230 var windowRect = adjustWindowRect(desiredWindowWidth, desiredWindowHeight, e lementOffsetWidth, 0);
228 var windowRect = adjustWindowRect(desiredWindowWidth * zoom, desiredWindowHe ight * zoom, this._selectElement.offsetWidth * zoom, 0);
229 // If the available screen space is smaller than maxHeight, we will get an u nexpected scrollbar. 231 // If the available screen space is smaller than maxHeight, we will get an u nexpected scrollbar.
230 if (!expectingScrollbar && windowRect.height < noScrollHeight * zoom) { 232 if (!expectingScrollbar && windowRect.height < noScrollHeight) {
231 desiredWindowWidth = windowRect.width + getScrollbarWidth() * zoom; 233 desiredWindowWidth = windowRect.width + scrollbarWidth;
232 windowRect = adjustWindowRect(desiredWindowWidth, windowRect.height, win dowRect.width, windowRect.height); 234 windowRect = adjustWindowRect(desiredWindowWidth, windowRect.height, win dowRect.width, windowRect.height);
233 } 235 }
234 this._selectElement.style.width = (windowRect.width / zoom) + "px"; 236 this._selectElement.style.width = (windowRect.width / zoom) + "px";
235 this._selectElement.style.height = (windowRect.height / zoom) + "px"; 237 this._selectElement.style.height = (windowRect.height / zoom) + "px";
236 this._element.style.height = (windowRect.height / zoom) + "px"; 238 this._element.style.height = (windowRect.height / zoom) + "px";
237 setWindowRect(windowRect); 239 setWindowRect(windowRect);
238 }; 240 };
239 241
240 ListPicker.prototype._calculateScrollHeight = function() { 242 ListPicker.prototype._calculateScrollHeight = function() {
241 // Element.scrollHeight returns an integer value but this calculate the 243 // Element.scrollHeight returns an integer value but this calculate the
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
437 } 439 }
438 this._applyItemStyle(element, config.style); 440 this._applyItemStyle(element, config.style);
439 }; 441 };
440 442
441 if (window.dialogArguments) { 443 if (window.dialogArguments) {
442 initialize(dialogArguments); 444 initialize(dialogArguments);
443 } else { 445 } else {
444 window.addEventListener("message", handleMessage, false); 446 window.addEventListener("message", handleMessage, false);
445 window.setTimeout(handleArgumentsTimeout, 1000); 447 window.setTimeout(handleArgumentsTimeout, 1000);
446 } 448 }
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/WebPagePopupImpl.cpp ('k') | third_party/WebKit/Source/web/resources/suggestionPicker.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698