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

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

Issue 2658383002: [DevTools] Make UI.GlassPane position contentElement for different overlay controls. (Closed)
Patch Set: less layouts Created 3 years, 10 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
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved. 3 * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved.
4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com). 4 * Copyright (C) 2007 Matt Lilek (pewtermoose@gmail.com).
5 * Copyright (C) 2009 Joseph Pecoraro 5 * Copyright (C) 2009 Joseph Pecoraro
6 * 6 *
7 * Redistribution and use in source and binary forms, with or without 7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions 8 * modification, are permitted provided that the following conditions
9 * are met: 9 * are met:
10 * 10 *
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 */ 87 */
88 UI.DragHandler = class { 88 UI.DragHandler = class {
89 constructor() { 89 constructor() {
90 this._elementDragMove = this._elementDragMove.bind(this); 90 this._elementDragMove = this._elementDragMove.bind(this);
91 this._elementDragEnd = this._elementDragEnd.bind(this); 91 this._elementDragEnd = this._elementDragEnd.bind(this);
92 this._mouseOutWhileDragging = this._mouseOutWhileDragging.bind(this); 92 this._mouseOutWhileDragging = this._mouseOutWhileDragging.bind(this);
93 } 93 }
94 94
95 _createGlassPane() { 95 _createGlassPane() {
96 this._glassPaneInUse = true; 96 this._glassPaneInUse = true;
97 if (!UI.DragHandler._glassPaneUsageCount++) 97 if (!UI.DragHandler._glassPaneUsageCount++) {
98 UI.DragHandler._glassPane = new UI.GlassPane(UI.DragHandler._documentForMo useOut); 98 UI.DragHandler._glassPane =
99 new UI.GlassPane(UI.DragHandler._documentForMouseOut, false /* dimmed */, true /* blockPointerEvents */);
100 }
99 } 101 }
100 102
101 _disposeGlassPane() { 103 _disposeGlassPane() {
102 if (!this._glassPaneInUse) 104 if (!this._glassPaneInUse)
103 return; 105 return;
104 this._glassPaneInUse = false; 106 this._glassPaneInUse = false;
105 if (--UI.DragHandler._glassPaneUsageCount) 107 if (--UI.DragHandler._glassPaneUsageCount)
106 return; 108 return;
107 UI.DragHandler._glassPane.dispose(); 109 UI.DragHandler._glassPane.dispose();
108 delete UI.DragHandler._glassPane; 110 delete UI.DragHandler._glassPane;
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 elementDrag(lastX, lastY); 299 elementDrag(lastX, lastY);
298 } 300 }
299 }; 301 };
300 302
301 /** 303 /**
302 * @unrestricted 304 * @unrestricted
303 */ 305 */
304 UI.GlassPane = class { 306 UI.GlassPane = class {
305 /** 307 /**
306 * @param {!Document} document 308 * @param {!Document} document
307 * @param {boolean=} dimmed 309 * @param {boolean} dimmed
310 * @param {boolean} blockPointerEvents
308 */ 311 */
309 constructor(document, dimmed) { 312 constructor(document, dimmed, blockPointerEvents) {
310 this.element = createElement('div'); 313 this.element = createElement('div');
311 var background = dimmed ? 'rgba(255, 255, 255, 0.5)' : 'transparent'; 314 var background = dimmed ? 'rgba(255, 255, 255, 0.5)' : 'transparent';
312 this._zIndex = UI._glassPane ? UI._glassPane._zIndex + 1000 :
313 3000; // Deliberately starts with 3000 to hi de other z-indexed elements below.
314 this.element.style.cssText = 'position:absolute;top:0;bottom:0;left:0;right: 0;background-color:' + background + 315 this.element.style.cssText = 'position:absolute;top:0;bottom:0;left:0;right: 0;background-color:' + background +
315 ';z-index:' + this._zIndex + ';overflow:hidden;'; 316 ';z-index:' + UI._glassPaneZIndex + ';overflow:hidden;' + (blockPointerE vents ? '' : 'pointer-events:none;');
317 UI._glassPaneZIndex += 1000;
316 document.body.appendChild(this.element); 318 document.body.appendChild(this.element);
317 UI._glassPane = this;
318 // TODO(dgozman): disallow focus outside of glass pane? 319 // TODO(dgozman): disallow focus outside of glass pane?
319 } 320 }
320 321
321 dispose() { 322 dispose() {
322 delete UI._glassPane; 323 UI._glassPaneZIndex -= 1000;
einbinder 2017/01/30 23:59:47 Should we do a check if this.element has a parent
323 this.element.remove(); 324 this.element.remove();
324 } 325 }
325 }; 326 };
326 327
327 /** @type {!UI.GlassPane|undefined} */ 328 /** @type {number} */
328 UI._glassPane; 329 UI._glassPaneZIndex = 3000; // Deliberately starts with 3000 to hide other z-in dexed elements below.
329 330
330 /** 331 /**
331 * @param {?Node=} node 332 * @param {?Node=} node
332 * @return {boolean} 333 * @return {boolean}
333 */ 334 */
334 UI.isBeingEdited = function(node) { 335 UI.isBeingEdited = function(node) {
335 if (!node || node.nodeType !== Node.ELEMENT_NODE) 336 if (!node || node.nodeType !== Node.ELEMENT_NODE)
336 return false; 337 return false;
337 var element = /** {!Element} */ (node); 338 var element = /** {!Element} */ (node);
338 if (element.classList.contains('text-prompt') || element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA') 339 if (element.classList.contains('text-prompt') || element.nodeName === 'INPUT' || element.nodeName === 'TEXTAREA')
(...skipping 871 matching lines...) Expand 10 before | Expand all | Expand 10 after
1210 document.defaultView.addEventListener('blur', UI._windowBlurred.bind(UI, docum ent), false); 1211 document.defaultView.addEventListener('blur', UI._windowBlurred.bind(UI, docum ent), false);
1211 document.addEventListener('focus', UI._focusChanged.bind(UI), true); 1212 document.addEventListener('focus', UI._focusChanged.bind(UI), true);
1212 1213
1213 if (!UI.themeSupport) 1214 if (!UI.themeSupport)
1214 UI.themeSupport = new UI.ThemeSupport(themeSetting); 1215 UI.themeSupport = new UI.ThemeSupport(themeSetting);
1215 UI.themeSupport.applyTheme(document); 1216 UI.themeSupport.applyTheme(document);
1216 1217
1217 var body = /** @type {!Element} */ (document.body); 1218 var body = /** @type {!Element} */ (document.body);
1218 UI.appendStyle(body, 'ui/inspectorStyle.css'); 1219 UI.appendStyle(body, 'ui/inspectorStyle.css');
1219 UI.appendStyle(body, 'ui/popover.css'); 1220 UI.appendStyle(body, 'ui/popover.css');
1221 UI.ModalOverlay.setRootElement(/** @type {!Element} */ (document.body));
1220 }; 1222 };
1221 1223
1222 /** 1224 /**
1223 * @param {string} name 1225 * @param {string} name
1224 * @return {string} 1226 * @return {string}
1225 */ 1227 */
1226 UI.beautifyFunctionName = function(name) { 1228 UI.beautifyFunctionName = function(name) {
1227 return name || Common.UIString('(anonymous)'); 1229 return name || Common.UIString('(anonymous)');
1228 }; 1230 };
1229 1231
(...skipping 847 matching lines...) Expand 10 before | Expand all | Expand 10 after
2077 */ 2079 */
2078 constructor(message, okCallback, cancelCallback) { 2080 constructor(message, okCallback, cancelCallback) {
2079 super(true); 2081 super(true);
2080 this.registerRequiredCSS('ui/confirmDialog.css'); 2082 this.registerRequiredCSS('ui/confirmDialog.css');
2081 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message; 2083 this.contentElement.createChild('div', 'message').createChild('span').textCo ntent = message;
2082 var buttonsBar = this.contentElement.createChild('div', 'button'); 2084 var buttonsBar = this.contentElement.createChild('div', 'button');
2083 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback )); 2085 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Ok'), okCallback ));
2084 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback)); 2086 buttonsBar.appendChild(UI.createTextButton(Common.UIString('Cancel'), cancel Callback));
2085 } 2087 }
2086 }; 2088 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698