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

Unified Diff: Source/web/resources/listPicker.js

Issue 1075073004: New SELECT Popup: Fix window width to include scrollbar width (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Added TestExpectation entry Created 5 years, 8 months 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « LayoutTests/platform/linux/fast/forms/select/popup-menu-appearance-tall-expected.png ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/web/resources/listPicker.js
diff --git a/Source/web/resources/listPicker.js b/Source/web/resources/listPicker.js
index 97d38c792f6dec1bfb97dfdb1639964d40a46eee..606325191b0c847e2ecabe6e1a5fc2a6c981dac9 100644
--- a/Source/web/resources/listPicker.js
+++ b/Source/web/resources/listPicker.js
@@ -178,11 +178,24 @@ ListPicker.prototype._fixWindowSize = function() {
var maxHeight = this._selectElement.offsetHeight;
this._selectElement.style.height = "0";
var heightOutsideOfContent = this._selectElement.offsetHeight - this._selectElement.clientHeight;
- var desiredWindowHeight = Math.round(this._calculateScrollHeight() + heightOutsideOfContent);
- if (desiredWindowHeight > maxHeight)
+ var noScrollHeight = Math.round(this._calculateScrollHeight() + heightOutsideOfContent);
+ var desiredWindowHeight = noScrollHeight;
+ var desiredWindowWidth = this._selectElement.offsetWidth;
+ var expectingScrollbar = false;
+ if (desiredWindowHeight > maxHeight) {
desiredWindowHeight = maxHeight;
- var desiredWindowWidth = Math.max(this._config.anchorRectInScreen.width, this._selectElement.offsetWidth);
+ // Setting overflow to auto does not increase width for the scrollbar
+ // so we need to do it manually.
+ desiredWindowWidth += getScrollbarWidth();
+ expectingScrollbar = true;
+ }
+ desiredWindowWidth = Math.max(this._config.anchorRectInScreen.width, desiredWindowWidth);
var windowRect = adjustWindowRect(desiredWindowWidth, desiredWindowHeight, this._selectElement.offsetWidth, 0);
+ // If the available screen space is smaller than maxHeight, we will get an unexpected scrollbar.
+ if (!expectingScrollbar && windowRect.height < noScrollHeight) {
+ desiredWindowWidth = windowRect.width + getScrollbarWidth();
+ windowRect = adjustWindowRect(desiredWindowWidth, windowRect.height, windowRect.width, windowRect.height);
+ }
this._selectElement.style.width = windowRect.width + "px";
this._selectElement.style.height = windowRect.height + "px";
this._element.style.height = windowRect.height + "px";
« no previous file with comments | « LayoutTests/platform/linux/fast/forms/select/popup-menu-appearance-tall-expected.png ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698