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

Side by Side Diff: third_party/WebKit/Source/devtools/front_end/ui/GlassPane.js

Issue 2805543002: [DevTools] When adjusting glass pane's content width for arrow, do not comporomise the size (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | 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 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 UI.GlassPane = class { 5 UI.GlassPane = class {
6 constructor() { 6 constructor() {
7 this._widget = new UI.Widget(true); 7 this._widget = new UI.Widget(true);
8 this._widget.markAsRoot(); 8 this._widget.markAsRoot();
9 this.element = this._widget.element; 9 this.element = this._widget.element;
10 this.contentElement = this._widget.contentElement; 10 this.contentElement = this._widget.contentElement;
(...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 } else { 233 } else {
234 height = Math.min(height, spaceBottom); 234 height = Math.min(height, spaceBottom);
235 } 235 }
236 this._arrowElement.setIconType('mediumicon-arrow-top'); 236 this._arrowElement.setIconType('mediumicon-arrow-top');
237 this._arrowElement.classList.add('arrow-top'); 237 this._arrowElement.classList.add('arrow-top');
238 arrowY = anchorBox.y + anchorBox.height + gutterSize; 238 arrowY = anchorBox.y + anchorBox.height + gutterSize;
239 } 239 }
240 240
241 positionX = Math.max(gutterSize, Math.min(anchorBox.x, containerWidth - width - gutterSize)); 241 positionX = Math.max(gutterSize, Math.min(anchorBox.x, containerWidth - width - gutterSize));
242 if (!enoughHeight) 242 if (!enoughHeight)
243 positionX += arrowSize; 243 positionX = Math.min(positionX + arrowSize, containerWidth - width - g utterSize);
244 else if (showArrow && positionX - arrowSize >= gutterSize) 244 else if (showArrow && positionX - arrowSize >= gutterSize)
245 positionX -= arrowSize; 245 positionX -= arrowSize;
246 width = Math.min(width, containerWidth - positionX - gutterSize); 246 width = Math.min(width, containerWidth - positionX - gutterSize);
247 if (2 * arrowSize >= width) { 247 if (2 * arrowSize >= width) {
248 this._arrowElement.classList.add('arrow-none'); 248 this._arrowElement.classList.add('arrow-none');
249 } else { 249 } else {
250 var arrowX = anchorBox.x + Math.min(50, Math.floor(anchorBox.width / 2 )); 250 var arrowX = anchorBox.x + Math.min(50, Math.floor(anchorBox.width / 2 ));
251 arrowX = Number.constrain(arrowX, positionX + arrowSize, positionX + w idth - arrowSize); 251 arrowX = Number.constrain(arrowX, positionX + arrowSize, positionX + w idth - arrowSize);
252 this._arrowElement.positionAt(arrowX, arrowY, container); 252 this._arrowElement.positionAt(arrowX, arrowY, container);
253 } 253 }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 } else { 291 } else {
292 width = Math.min(width, spaceRight); 292 width = Math.min(width, spaceRight);
293 } 293 }
294 this._arrowElement.setIconType('mediumicon-arrow-left'); 294 this._arrowElement.setIconType('mediumicon-arrow-left');
295 this._arrowElement.classList.add('arrow-left'); 295 this._arrowElement.classList.add('arrow-left');
296 arrowX = anchorBox.x + anchorBox.width + gutterSize; 296 arrowX = anchorBox.x + anchorBox.width + gutterSize;
297 } 297 }
298 298
299 positionY = Math.max(gutterSize, Math.min(anchorBox.y, containerHeight - height - gutterSize)); 299 positionY = Math.max(gutterSize, Math.min(anchorBox.y, containerHeight - height - gutterSize));
300 if (!enoughWidth) 300 if (!enoughWidth)
301 positionY += arrowSize; 301 positionY = Math.min(positionY + arrowSize, containerHeight - height - gutterSize);
302 else if (showArrow && positionY - arrowSize >= gutterSize) 302 else if (showArrow && positionY - arrowSize >= gutterSize)
303 positionY -= arrowSize; 303 positionY -= arrowSize;
304 height = Math.min(height, containerHeight - positionY - gutterSize); 304 height = Math.min(height, containerHeight - positionY - gutterSize);
305 if (2 * arrowSize >= height) { 305 if (2 * arrowSize >= height) {
306 this._arrowElement.classList.add('arrow-none'); 306 this._arrowElement.classList.add('arrow-none');
307 } else { 307 } else {
308 var arrowY = anchorBox.y + Math.min(50, Math.floor(anchorBox.height / 2)); 308 var arrowY = anchorBox.y + Math.min(50, Math.floor(anchorBox.height / 2));
309 arrowY = Number.constrain(arrowY, positionY + arrowSize, positionY + h eight - arrowSize); 309 arrowY = Number.constrain(arrowY, positionY + arrowSize, positionY + h eight - arrowSize);
310 this._arrowElement.positionAt(arrowX, arrowY, container); 310 this._arrowElement.positionAt(arrowX, arrowY, container);
311 } 311 }
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
388 UI.GlassPane.MarginBehavior = { 388 UI.GlassPane.MarginBehavior = {
389 Arrow: Symbol('Arrow'), 389 Arrow: Symbol('Arrow'),
390 DefaultMargin: Symbol('DefaultMargin'), 390 DefaultMargin: Symbol('DefaultMargin'),
391 NoMargin: Symbol('NoMargin') 391 NoMargin: Symbol('NoMargin')
392 }; 392 };
393 393
394 /** @type {!Map<!Document, !Element>} */ 394 /** @type {!Map<!Document, !Element>} */
395 UI.GlassPane._containers = new Map(); 395 UI.GlassPane._containers = new Map();
396 /** @type {!Set<!UI.GlassPane>} */ 396 /** @type {!Set<!UI.GlassPane>} */
397 UI.GlassPane._panes = new Set(); 397 UI.GlassPane._panes = new Set();
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698