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

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

Issue 2377193004: [DevTools] Rework some focus code. (Closed)
Patch Set: FocusRestorer Created 4 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 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 /** 5 /**
6 * @constructor 6 * @constructor
7 */ 7 */
8 WebInspector.InplaceEditor = function() 8 WebInspector.InplaceEditor = function()
9 { 9 {
10 } 10 }
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 }, 61 },
62 62
63 setUpEditor: function(editingContext) 63 setUpEditor: function(editingContext)
64 { 64 {
65 var element = editingContext.element; 65 var element = editingContext.element;
66 element.classList.add("editing"); 66 element.classList.add("editing");
67 67
68 var oldTabIndex = element.getAttribute("tabIndex"); 68 var oldTabIndex = element.getAttribute("tabIndex");
69 if (typeof oldTabIndex !== "number" || oldTabIndex < 0) 69 if (typeof oldTabIndex !== "number" || oldTabIndex < 0)
70 element.tabIndex = 0; 70 element.tabIndex = 0;
71 WebInspector.setCurrentFocusElement(element); 71 this._focusRestorer = new WebInspector.ElementFocusRestorer(element);
72 editingContext.oldTabIndex = oldTabIndex; 72 editingContext.oldTabIndex = oldTabIndex;
73 }, 73 },
74 74
75 closeEditor: function(editingContext) 75 closeEditor: function(editingContext)
76 { 76 {
77 var element = editingContext.element; 77 var element = editingContext.element;
78 element.classList.remove("editing"); 78 element.classList.remove("editing");
79 79
80 if (typeof editingContext.oldTabIndex !== "number") 80 if (typeof editingContext.oldTabIndex !== "number")
81 element.removeAttribute("tabIndex"); 81 element.removeAttribute("tabIndex");
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 142
143 function cleanUpAfterEditing() 143 function cleanUpAfterEditing()
144 { 144 {
145 WebInspector.markBeingEdited(element, false); 145 WebInspector.markBeingEdited(element, false);
146 146
147 element.removeEventListener("blur", blurEventListener, isMultiline); 147 element.removeEventListener("blur", blurEventListener, isMultiline);
148 element.removeEventListener("keydown", keyDownEventListener, true); 148 element.removeEventListener("keydown", keyDownEventListener, true);
149 if (pasteCallback) 149 if (pasteCallback)
150 element.removeEventListener("paste", pasteEventListener, true); 150 element.removeEventListener("paste", pasteEventListener, true);
151 151
152 WebInspector.restoreFocusFromElement(element); 152 if (self._focusRestorer)
153 self._focusRestorer.restore();
153 self.closeEditor(editingContext); 154 self.closeEditor(editingContext);
154 } 155 }
155 156
156 /** @this {Element} */ 157 /** @this {Element} */
157 function editingCancelled() 158 function editingCancelled()
158 { 159 {
159 self.cancelEditing(editingContext); 160 self.cancelEditing(editingContext);
160 cleanUpAfterEditing(); 161 cleanUpAfterEditing();
161 cancelledCallback(this, context); 162 cancelledCallback(this, context);
162 } 163 }
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 }, 293 },
293 294
294 /** 295 /**
295 * @param {function(!Event):string} postKeydownFinishHandler 296 * @param {function(!Event):string} postKeydownFinishHandler
296 */ 297 */
297 setPostKeydownFinishHandler: function(postKeydownFinishHandler) 298 setPostKeydownFinishHandler: function(postKeydownFinishHandler)
298 { 299 {
299 this.postKeydownFinishHandler = postKeydownFinishHandler; 300 this.postKeydownFinishHandler = postKeydownFinishHandler;
300 } 301 }
301 } 302 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698