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

Side by Side Diff: third_party/WebKit/Source/web/resources/suggestionPicker.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: 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 /* 2 /*
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 for (var i=0; i < contentElements.length; ++i) { 131 for (var i=0; i < contentElements.length; ++i) {
132 maxContentWidth = Math.max(maxContentWidth, contentElements[i].offsetWid th); 132 maxContentWidth = Math.max(maxContentWidth, contentElements[i].offsetWid th);
133 } 133 }
134 this._containerElement.classList.remove("measuring-width"); 134 this._containerElement.classList.remove("measuring-width");
135 return maxContentWidth; 135 return maxContentWidth;
136 }; 136 };
137 137
138 SuggestionPicker.prototype._fixWindowSize = function() { 138 SuggestionPicker.prototype._fixWindowSize = function() {
139 var ListBorder = 2; 139 var ListBorder = 2;
140 var zoom = this._config.zoomFactor; 140 var zoom = this._config.zoomFactor;
141 var desiredWindowWidth = this._measureMaxContentWidth() + ListBorder; 141 var desiredWindowWidth = (this._measureMaxContentWidth() + ListBorder) * zoo m;
142 if (typeof this._config.inputWidth === "number") 142 if (typeof this._config.inputWidth === "number")
143 desiredWindowWidth = Math.max(this._config.inputWidth / zoom, desiredWin dowWidth); 143 desiredWindowWidth = Math.max(this._config.inputWidth, desiredWindowWidt h);
144 var totalHeight = ListBorder; 144 var totalHeight = ListBorder
tkent 2015/12/09 04:35:51 Add ';' back.
oshima 2015/12/17 05:01:28 Done.
145 var maxHeight = 0; 145 var maxHeight = 0;
146 var entryCount = 0; 146 var entryCount = 0;
147 for (var i = 0; i < this._containerElement.childNodes.length; ++i) { 147 for (var i = 0; i < this._containerElement.childNodes.length; ++i) {
148 var node = this._containerElement.childNodes[i]; 148 var node = this._containerElement.childNodes[i];
149 if (node.classList.contains(SuggestionPicker.ListEntryClass)) 149 if (node.classList.contains(SuggestionPicker.ListEntryClass))
150 entryCount++; 150 entryCount++;
151 totalHeight += node.offsetHeight; 151 totalHeight += node.offsetHeight;
152 if (maxHeight === 0 && entryCount == SuggestionPicker.NumberOfVisibleEnt ries) 152 if (maxHeight === 0 && entryCount == SuggestionPicker.NumberOfVisibleEnt ries)
153 maxHeight = totalHeight; 153 maxHeight = totalHeight;
154 } 154 }
155 var desiredWindowHeight = totalHeight; 155 var desiredWindowHeight = totalHeight * zoom;
156 if (maxHeight !== 0 && totalHeight > maxHeight) { 156 if (maxHeight !== 0 && totalHeight > maxHeight * zoom) {
157 this._containerElement.style.maxHeight = (maxHeight - ListBorder) + "px" ; 157 this._containerElement.style.maxHeight = (maxHeight - ListBorder) + "px" ;
158 desiredWindowWidth += getScrollbarWidth(); 158 desiredWindowWidth += getScrollbarWidth() * zoom;
159 desiredWindowHeight = maxHeight; 159 desiredWindowHeight = maxHeight * zoom;
160 this._containerElement.style.overflowY = "scroll"; 160 this._containerElement.style.overflowY = "scroll";
161 } 161 }
162 162 var windowRect = adjustWindowRect(desiredWindowWidth, desiredWindowHeight, d esiredWindowWidth, 0);
163 var windowRect = adjustWindowRect(desiredWindowWidth * zoom, desiredWindowHe ight * zoom, desiredWindowWidth * zoom, 0);
164 this._containerElement.style.height = (windowRect.height / zoom - ListBorder ) + "px"; 163 this._containerElement.style.height = (windowRect.height / zoom - ListBorder ) + "px";
165 setWindowRect(windowRect); 164 setWindowRect(windowRect);
166 }; 165 };
167 166
168 SuggestionPicker.prototype._layout = function() { 167 SuggestionPicker.prototype._layout = function() {
169 if (this._config.isRTL) 168 if (this._config.isRTL)
170 this._element.classList.add("rtl"); 169 this._element.classList.add("rtl");
171 if (this._config.isLocaleRTL) 170 if (this._config.isLocaleRTL)
172 this._element.classList.add("locale-rtl"); 171 this._element.classList.add("locale-rtl");
173 this._containerElement = createElement("ul", "suggestion-list"); 172 this._containerElement = createElement("ul", "suggestion-list");
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
317 /** 316 /**
318 * @param {!Event} event 317 * @param {!Event} event
319 */ 318 */
320 SuggestionPicker.prototype._handleMouseOut = function(event) { 319 SuggestionPicker.prototype._handleMouseOut = function(event) {
321 if (!document.activeElement.classList.contains(SuggestionPicker.ListEntryCla ss)) 320 if (!document.activeElement.classList.contains(SuggestionPicker.ListEntryCla ss))
322 return; 321 return;
323 this._isFocusByMouse = false; 322 this._isFocusByMouse = false;
324 document.activeElement.blur(); 323 document.activeElement.blur();
325 event.preventDefault(); 324 event.preventDefault();
326 }; 325 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698