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

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

Issue 1397403003: [DevTools] Remove HelpScreen, turn SettingsScreen into dialog and web component. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screens
Patch Set: markAsRoot Created 5 years, 2 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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 197
198 /** 198 /**
199 * @constructor 199 * @constructor
200 * @param {!Document} document 200 * @param {!Document} document
201 * @param {boolean=} dimmed 201 * @param {boolean=} dimmed
202 */ 202 */
203 WebInspector.GlassPane = function(document, dimmed) 203 WebInspector.GlassPane = function(document, dimmed)
204 { 204 {
205 this.element = createElement("div"); 205 this.element = createElement("div");
206 var background = dimmed ? "rgba(255, 255, 255, 0.5)" : "transparent"; 206 var background = dimmed ? "rgba(255, 255, 255, 0.5)" : "transparent";
207 this.element.style.cssText = "position:absolute;top:0;bottom:0;left:0;right: 0;background-color:" + background + ";z-index:3000;overflow:hidden;"; 207 var zIndex = (3 + WebInspector._glassPanes.length) * 1000; // Deliberately starts with 3000 to hide other z-indexed elements below.
208 this.element.style.cssText = "position:absolute;top:0;bottom:0;left:0;right: 0;background-color:" + background + ";z-index:" + zIndex + ";overflow:hidden;";
208 document.body.appendChild(this.element); 209 document.body.appendChild(this.element);
209 WebInspector._glassPane = this; 210 WebInspector._glassPanes.push(this);
210 } 211 }
211 212
212 WebInspector.GlassPane.prototype = { 213 WebInspector.GlassPane.prototype = {
213 dispose: function() 214 dispose: function()
214 { 215 {
215 delete WebInspector._glassPane; 216 console.assert(this === WebInspector._glassPanes.peekLast());
217 WebInspector._glassPanes.pop();
216 if (WebInspector.GlassPane.DefaultFocusedViewStack.length) 218 if (WebInspector.GlassPane.DefaultFocusedViewStack.length)
217 WebInspector.GlassPane.DefaultFocusedViewStack.peekLast().focus(); 219 WebInspector.GlassPane.DefaultFocusedViewStack.peekLast().focus();
218 this.element.remove(); 220 this.element.remove();
219 } 221 }
220 } 222 }
221 223
224 /** @type {!Array<!WebInspector.GlassPane>} */
225 WebInspector._glassPanes = [];
226
222 /** 227 /**
223 * @type {!Array.<!WebInspector.Widget|!WebInspector.Dialog>} 228 * @type {!Array.<!WebInspector.Widget|!WebInspector.Dialog>}
224 */ 229 */
225 WebInspector.GlassPane.DefaultFocusedViewStack = []; 230 WebInspector.GlassPane.DefaultFocusedViewStack = [];
226 231
227 /** 232 /**
228 * @param {?Node=} node 233 * @param {?Node=} node
229 * @return {boolean} 234 * @return {boolean}
230 */ 235 */
231 WebInspector.isBeingEdited = function(node) 236 WebInspector.isBeingEdited = function(node)
(...skipping 526 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 return true; 763 return true;
759 764
760 return false; 765 return false;
761 } 766 }
762 767
763 /** 768 /**
764 * @param {?Node} x 769 * @param {?Node} x
765 */ 770 */
766 WebInspector.setCurrentFocusElement = function(x) 771 WebInspector.setCurrentFocusElement = function(x)
767 { 772 {
768 if (WebInspector._glassPane && x && !WebInspector._glassPane.element.isAnces tor(x)) 773 if (WebInspector._glassPanes.length && x && !WebInspector._glassPanes.peekLa st().element.isAncestor(x))
769 return; 774 return;
770 if (WebInspector._currentFocusElement !== x) 775 if (WebInspector._currentFocusElement !== x)
771 WebInspector._previousFocusElement = WebInspector._currentFocusElement; 776 WebInspector._previousFocusElement = WebInspector._currentFocusElement;
772 WebInspector._currentFocusElement = x; 777 WebInspector._currentFocusElement = x;
773 778
774 if (WebInspector._currentFocusElement) { 779 if (x) {
775 WebInspector._currentFocusElement.focus(); 780 x.focus();
776 781
777 // Make a caret selection inside the new element if there isn't a range selection and there isn't already a caret selection inside. 782 // Make a caret selection inside the new element if there isn't a range selection and there isn't already a caret selection inside.
778 // This is needed (at least) to remove caret from console when focus is moved to some element in the panel. 783 // This is needed (at least) to remove caret from console when focus is moved to some element in the panel.
779 // The code below should not be applied to text fields and text areas, h ence _isTextEditingElement check. 784 // The code below should not be applied to text fields and text areas, h ence _isTextEditingElement check.
780 var selection = x.getComponentSelection(); 785 var selection = x.getComponentSelection();
781 if (!WebInspector._isTextEditingElement(WebInspector._currentFocusElemen t) && selection.isCollapsed && !WebInspector._currentFocusElement.isInsertionCar etInside()) { 786 if (!WebInspector._isTextEditingElement(x) && selection.isCollapsed && ! x.isInsertionCaretInside()) {
782 var selectionRange = WebInspector._currentFocusElement.ownerDocument .createRange(); 787 var selectionRange = x.ownerDocument.createRange();
783 selectionRange.setStart(WebInspector._currentFocusElement, 0); 788 selectionRange.setStart(x, 0);
784 selectionRange.setEnd(WebInspector._currentFocusElement, 0); 789 selectionRange.setEnd(x, 0);
785 790
786 selection.removeAllRanges(); 791 selection.removeAllRanges();
787 selection.addRange(selectionRange); 792 selection.addRange(selectionRange);
788 } 793 }
789 } else if (WebInspector._previousFocusElement) 794 } else if (WebInspector._previousFocusElement)
790 WebInspector._previousFocusElement.blur(); 795 WebInspector._previousFocusElement.blur();
791 } 796 }
792 797
793 WebInspector.restoreFocusFromElement = function(element) 798 WebInspector.restoreFocusFromElement = function(element)
794 { 799 {
(...skipping 678 matching lines...) Expand 10 before | Expand all | Expand 10 after
1473 // Due to the nature of regex, |items| array has matched elements on its even indexes. 1478 // Due to the nature of regex, |items| array has matched elements on its even indexes.
1474 var items = text.replace(regex, "\0$1\0").split("\0"); 1479 var items = text.replace(regex, "\0$1\0").split("\0");
1475 for (var i = 0; i < items.length; ++i) { 1480 for (var i = 0; i < items.length; ++i) {
1476 var processedNode = i % 2 ? processor(items[i]) : this._runProcessor (processorIndex + 1, items[i]); 1481 var processedNode = i % 2 ? processor(items[i]) : this._runProcessor (processorIndex + 1, items[i]);
1477 container.appendChild(processedNode); 1482 container.appendChild(processedNode);
1478 } 1483 }
1479 1484
1480 return container; 1485 return container;
1481 } 1486 }
1482 } 1487 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698