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

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

Issue 2510883002: DevTools: all swatches should have a default focused element (Closed)
Patch Set: a Created 4 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2009 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * 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 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 * @param {?number=} preferredWidth 76 * @param {?number=} preferredWidth
77 * @param {?number=} preferredHeight 77 * @param {?number=} preferredHeight
78 * @param {?UI.Popover.Orientation=} arrowDirection 78 * @param {?UI.Popover.Orientation=} arrowDirection
79 */ 79 */
80 _innerShow(view, contentElement, anchor, preferredWidth, preferredHeight, arro wDirection) { 80 _innerShow(view, contentElement, anchor, preferredWidth, preferredHeight, arro wDirection) {
81 if (this._disposed) 81 if (this._disposed)
82 return; 82 return;
83 this._contentElement = contentElement; 83 this._contentElement = contentElement;
84 84
85 // This should not happen, but we hide previous popup to be on the safe side . 85 // This should not happen, but we hide previous popup to be on the safe side .
86 if (UI.Popover._popover) 86 var restoreFocus;
87 if (UI.Popover._popover) {
88 restoreFocus = UI.Popover._popover.hasFocus();
87 UI.Popover._popover.hide(); 89 UI.Popover._popover.hide();
90 }
88 UI.Popover._popover = this; 91 UI.Popover._popover = this;
89 92
90 var document = anchor instanceof Element ? anchor.ownerDocument : contentEle ment.ownerDocument; 93 var document = anchor instanceof Element ? anchor.ownerDocument : contentEle ment.ownerDocument;
91 var window = document.defaultView; 94 var window = document.defaultView;
92 95
93 // Temporarily attach in order to measure preferred dimensions. 96 // Temporarily attach in order to measure preferred dimensions.
94 var preferredSize = view ? view.measurePreferredSize() : UI.measurePreferred Size(this._contentElement); 97 var preferredSize = view ? view.measurePreferredSize() : UI.measurePreferred Size(this._contentElement);
95 this._preferredWidth = preferredWidth || preferredSize.width; 98 this._preferredWidth = preferredWidth || preferredSize.width;
96 this._preferredHeight = preferredHeight || preferredSize.height; 99 this._preferredHeight = preferredHeight || preferredSize.height;
97 100
98 window.addEventListener('resize', this._hideBound, false); 101 window.addEventListener('resize', this._hideBound, false);
99 document.body.appendChild(this._containerElement); 102 document.body.appendChild(this._containerElement);
100 super.show(this._containerElement); 103 super.show(this._containerElement);
104 if (restoreFocus && view)
105 view.focus();
dgozman 2016/11/17 01:29:50 How do you focus view before showing it in line 10
luoe 2016/11/17 21:38:08 Ahh, good point. We should restore focus after th
101 106
102 if (view) 107 if (view)
103 view.show(this._contentDiv); 108 view.show(this._contentDiv);
104 else 109 else
105 this._contentDiv.appendChild(this._contentElement); 110 this._contentDiv.appendChild(this._contentElement);
106 111
107 this.positionElement(anchor, this._preferredWidth, this._preferredHeight, ar rowDirection); 112 this.positionElement(anchor, this._preferredWidth, this._preferredHeight, ar rowDirection);
108 113
109 if (this._popoverHelper) { 114 if (this._popoverHelper) {
110 this._contentDiv.addEventListener( 115 this._contentDiv.addEventListener(
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 this._resetHoverTimer(); 409 this._resetHoverTimer();
405 } 410 }
406 } 411 }
407 }; 412 };
408 413
409 /** @enum {string} */ 414 /** @enum {string} */
410 UI.Popover.Orientation = { 415 UI.Popover.Orientation = {
411 Top: 'top', 416 Top: 'top',
412 Bottom: 'bottom' 417 Bottom: 'bottom'
413 }; 418 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698