| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |