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

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: ac 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);
101 104
102 if (view) 105 if (view) {
103 view.show(this._contentDiv); 106 view.show(this._contentDiv);
104 else 107 if (restoreFocus)
108 view.focus();
109 } else {
105 this._contentDiv.appendChild(this._contentElement); 110 this._contentDiv.appendChild(this._contentElement);
111 if (restoreFocus)
112 this._contentElement.focus();
113 }
106 114
107 this.positionElement(anchor, this._preferredWidth, this._preferredHeight, ar rowDirection); 115 this.positionElement(anchor, this._preferredWidth, this._preferredHeight, ar rowDirection);
108 116
109 if (this._popoverHelper) { 117 if (this._popoverHelper) {
110 this._contentDiv.addEventListener( 118 this._contentDiv.addEventListener(
111 'mousemove', this._popoverHelper._killHidePopoverTimer.bind(this._popo verHelper), true); 119 'mousemove', this._popoverHelper._killHidePopoverTimer.bind(this._popo verHelper), true);
112 this.element.addEventListener('mouseout', this._popoverHelper._popoverMous eOut.bind(this._popoverHelper), true); 120 this.element.addEventListener('mouseout', this._popoverHelper._popoverMous eOut.bind(this._popoverHelper), true);
113 } 121 }
114 } 122 }
115 123
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 this._resetHoverTimer(); 412 this._resetHoverTimer();
405 } 413 }
406 } 414 }
407 }; 415 };
408 416
409 /** @enum {string} */ 417 /** @enum {string} */
410 UI.Popover.Orientation = { 418 UI.Popover.Orientation = {
411 Top: 'top', 419 Top: 'top',
412 Bottom: 'bottom' 420 Bottom: 'bottom'
413 }; 421 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698