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

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

Issue 2859623002: DevTools: Migrate from -webkit-user-modify to contenteditable (Closed)
Patch Set: Add contenteditable on attach Created 3 years, 7 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 * @unrestricted 5 * @unrestricted
6 */ 6 */
7 UI.InplaceEditor = class { 7 UI.InplaceEditor = class {
8 /** 8 /**
9 * @param {!Element} element 9 * @param {!Element} element
10 * @param {!UI.InplaceEditor.Config=} config 10 * @param {!UI.InplaceEditor.Config=} config
(...skipping 12 matching lines...) Expand all
23 var element = editingContext.element; 23 var element = editingContext.element;
24 if (element.tagName === 'INPUT' && element.type === 'text') 24 if (element.tagName === 'INPUT' && element.type === 'text')
25 return element.value; 25 return element.value;
26 26
27 return element.textContent; 27 return element.textContent;
28 } 28 }
29 29
30 setUpEditor(editingContext) { 30 setUpEditor(editingContext) {
31 var element = editingContext.element; 31 var element = editingContext.element;
32 element.classList.add('editing'); 32 element.classList.add('editing');
33 element.setAttribute('contenteditable', 'plaintext-only');
33 34
34 var oldTabIndex = element.getAttribute('tabIndex'); 35 var oldTabIndex = element.getAttribute('tabIndex');
35 if (typeof oldTabIndex !== 'number' || oldTabIndex < 0) 36 if (typeof oldTabIndex !== 'number' || oldTabIndex < 0)
36 element.tabIndex = 0; 37 element.tabIndex = 0;
37 this._focusRestorer = new UI.ElementFocusRestorer(element); 38 this._focusRestorer = new UI.ElementFocusRestorer(element);
38 editingContext.oldTabIndex = oldTabIndex; 39 editingContext.oldTabIndex = oldTabIndex;
39 } 40 }
40 41
41 closeEditor(editingContext) { 42 closeEditor(editingContext) {
42 var element = editingContext.element; 43 var element = editingContext.element;
43 element.classList.remove('editing'); 44 element.classList.remove('editing');
45 element.removeAttribute('contenteditable');
44 46
45 if (typeof editingContext.oldTabIndex !== 'number') 47 if (typeof editingContext.oldTabIndex !== 'number')
46 element.removeAttribute('tabIndex'); 48 element.removeAttribute('tabIndex');
47 else 49 else
48 element.tabIndex = editingContext.oldTabIndex; 50 element.tabIndex = editingContext.oldTabIndex;
49 element.scrollTop = 0; 51 element.scrollTop = 0;
50 element.scrollLeft = 0; 52 element.scrollLeft = 0;
51 } 53 }
52 54
53 cancelEditing(editingContext) { 55 cancelEditing(editingContext) {
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 this.pasteHandler = pasteHandler; 217 this.pasteHandler = pasteHandler;
216 } 218 }
217 219
218 /** 220 /**
219 * @param {function(!Event):string} postKeydownFinishHandler 221 * @param {function(!Event):string} postKeydownFinishHandler
220 */ 222 */
221 setPostKeydownFinishHandler(postKeydownFinishHandler) { 223 setPostKeydownFinishHandler(postKeydownFinishHandler) {
222 this.postKeydownFinishHandler = postKeydownFinishHandler; 224 this.postKeydownFinishHandler = postKeydownFinishHandler;
223 } 225 }
224 }; 226 };
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698