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

Side by Side Diff: Source/devtools/front_end/elements/ElementsTreeElement.js

Issue 1196343002: Revert of DevTools: [Elements] F2 should commit changes in edit-as-html (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/devtools/front_end/ui/InplaceEditor.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved.
3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com> 3 * Copyright (C) 2008 Matt Lilek <webkit@mattlilek.com>
4 * Copyright (C) 2009 Joseph Pecoraro 4 * Copyright (C) 2009 Joseph Pecoraro
5 * 5 *
6 * Redistribution and use in source and binary forms, with or without 6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions 7 * modification, are permitted provided that the following conditions
8 * are met: 8 * are met:
9 * 9 *
10 * 1. Redistributions of source code must retain the above copyright 10 * 1. Redistributions of source code must retain the above copyright
(...skipping 648 matching lines...) Expand 10 before | Expand all | Expand 10 after
659 659
660 var attributeValue = attributeName && attributeValueElement ? this._node .getAttribute(attributeName) : undefined; 660 var attributeValue = attributeName && attributeValueElement ? this._node .getAttribute(attributeName) : undefined;
661 if (attributeValue !== undefined) 661 if (attributeValue !== undefined)
662 attributeValueElement.setTextContentTruncatedIfNeeded(attributeValue , WebInspector.UIString("<value is too large to edit>")); 662 attributeValueElement.setTextContentTruncatedIfNeeded(attributeValue , WebInspector.UIString("<value is too large to edit>"));
663 663
664 // Remove zero-width spaces that were added by nodeTitleInfo. 664 // Remove zero-width spaces that were added by nodeTitleInfo.
665 removeZeroWidthSpaceRecursive(attribute); 665 removeZeroWidthSpaceRecursive(attribute);
666 666
667 var config = new WebInspector.InplaceEditor.Config(this._attributeEditin gCommitted.bind(this), this._editingCancelled.bind(this), attributeName); 667 var config = new WebInspector.InplaceEditor.Config(this._attributeEditin gCommitted.bind(this), this._editingCancelled.bind(this), attributeName);
668 668
669 /** 669 function handleKeyDownEvents(event)
670 * @param {!Event} event
671 * @return {string}
672 */
673 function postKeyDownFinishHandler(event)
674 { 670 {
675 WebInspector.handleElementValueModifications(event, attribute); 671 var isMetaOrCtrl = WebInspector.isMac() ?
676 return ""; 672 event.metaKey && !event.shiftKey && !event.ctrlKey && !event.alt Key :
673 event.ctrlKey && !event.shiftKey && !event.metaKey && !event.alt Key;
674 if (isEnterKey(event) && (event.isMetaOrCtrlForTest || !config.multi line || isMetaOrCtrl))
675 return "commit";
676 else if (event.keyCode === WebInspector.KeyboardShortcut.Keys.Esc.co de || event.keyIdentifier === "U+001B")
677 return "cancel";
678 else if (event.keyIdentifier === "U+0009") // Tab key
679 return "move-" + (event.shiftKey ? "backward" : "forward");
680 else {
681 WebInspector.handleElementValueModifications(event, attribute);
682 return "";
683 }
677 } 684 }
678 config.setPostKeydownFinishHandler(postKeyDownFinishHandler); 685
686 config.customFinishHandler = handleKeyDownEvents;
679 687
680 this._editing = WebInspector.InplaceEditor.startEditing(attribute, confi g); 688 this._editing = WebInspector.InplaceEditor.startEditing(attribute, confi g);
681 689
682 this.listItemElement.getComponentSelection().setBaseAndExtent(elementFor Selection, 0, elementForSelection, 1); 690 this.listItemElement.getComponentSelection().setBaseAndExtent(elementFor Selection, 0, elementForSelection, 1);
683 691
684 return true; 692 return true;
685 }, 693 },
686 694
687 /** 695 /**
688 * @param {!Element} textNodeElement 696 * @param {!Element} textNodeElement
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
833 while (child) { 841 while (child) {
834 child.style.removeProperty("display"); 842 child.style.removeProperty("display");
835 child = child.nextSibling; 843 child = child.nextSibling;
836 } 844 }
837 845
838 this.treeOutline.element.removeEventListener("mousedown", consume, f alse); 846 this.treeOutline.element.removeEventListener("mousedown", consume, f alse);
839 this.updateSelection(); 847 this.updateSelection();
840 this.treeOutline.focus(); 848 this.treeOutline.focus();
841 } 849 }
842 850
843 /**
844 * @param {!Event} event
845 * @return {string}
846 */
847 function postKeyDownFinishHandler(event)
848 {
849 if (event.keyCode === WebInspector.KeyboardShortcut.Keys.F2.code)
850 return "commit";
851 return "";
852 }
853
854 var config = new WebInspector.InplaceEditor.Config(commit.bind(this), di spose.bind(this)); 851 var config = new WebInspector.InplaceEditor.Config(commit.bind(this), di spose.bind(this));
855 config.setMultilineOptions(initialValue, { name: "xml", htmlMode: true } , "web-inspector-html", WebInspector.moduleSetting("domWordWrap").get(), true); 852 config.setMultilineOptions(initialValue, { name: "xml", htmlMode: true } , "web-inspector-html", WebInspector.moduleSetting("domWordWrap").get(), true);
856 config.setPostKeydownFinishHandler(postKeyDownFinishHandler);
857 WebInspector.InplaceEditor.startMultilineEditing(this._htmlEditElement, config).then(markAsBeingEdited.bind(this)); 853 WebInspector.InplaceEditor.startMultilineEditing(this._htmlEditElement, config).then(markAsBeingEdited.bind(this));
858 854
859 /** 855 /**
860 * @param {!Object} controller 856 * @param {!Object} controller
861 * @this {WebInspector.ElementsTreeElement} 857 * @this {WebInspector.ElementsTreeElement}
862 */ 858 */
863 function markAsBeingEdited(controller) 859 function markAsBeingEdited(controller)
864 { 860 {
865 this._editing = /** @type {!WebInspector.InplaceEditor.Controller} * / (controller); 861 this._editing = /** @type {!WebInspector.InplaceEditor.Controller} * / (controller);
866 this._editing.setWidth(this.treeOutline.visibleWidth()); 862 this._editing.setWidth(this.treeOutline.visibleWidth());
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1529 1525
1530 if (object) 1526 if (object)
1531 object.callFunction(scrollIntoView); 1527 object.callFunction(scrollIntoView);
1532 } 1528 }
1533 1529
1534 this._node.resolveToObject("", scrollIntoViewCallback); 1530 this._node.resolveToObject("", scrollIntoViewCallback);
1535 }, 1531 },
1536 1532
1537 __proto__: TreeElement.prototype 1533 __proto__: TreeElement.prototype
1538 } 1534 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/ui/InplaceEditor.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698