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

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

Issue 1200833006: 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 function handleKeyDownEvents(event) 669 /**
670 * @param {!Event} event
671 * @return {string}
672 */
673 function postKeyDownFinishHandler(event)
670 { 674 {
671 var isMetaOrCtrl = WebInspector.isMac() ? 675 WebInspector.handleElementValueModifications(event, attribute);
672 event.metaKey && !event.shiftKey && !event.ctrlKey && !event.alt Key : 676 return "";
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 }
684 } 677 }
685 678 config.setPostKeydownFinishHandler(postKeyDownFinishHandler);
686 config.customFinishHandler = handleKeyDownEvents;
687 679
688 this._editing = WebInspector.InplaceEditor.startEditing(attribute, confi g); 680 this._editing = WebInspector.InplaceEditor.startEditing(attribute, confi g);
689 681
690 this.listItemElement.getComponentSelection().setBaseAndExtent(elementFor Selection, 0, elementForSelection, 1); 682 this.listItemElement.getComponentSelection().setBaseAndExtent(elementFor Selection, 0, elementForSelection, 1);
691 683
692 return true; 684 return true;
693 }, 685 },
694 686
695 /** 687 /**
696 * @param {!Element} textNodeElement 688 * @param {!Element} textNodeElement
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
841 while (child) { 833 while (child) {
842 child.style.removeProperty("display"); 834 child.style.removeProperty("display");
843 child = child.nextSibling; 835 child = child.nextSibling;
844 } 836 }
845 837
846 this.treeOutline.element.removeEventListener("mousedown", consume, f alse); 838 this.treeOutline.element.removeEventListener("mousedown", consume, f alse);
847 this.updateSelection(); 839 this.updateSelection();
848 this.treeOutline.focus(); 840 this.treeOutline.focus();
849 } 841 }
850 842
843 /**
844 * @param {!Event} event
845 * @return {string}
846 */
847 function postKeyDownFinishHandler(event)
848 {
849 if (event.keyCode === WebInspector.KeyboardShortcut.Keys.F2.code)
pfeldman 2015/06/22 17:59:37 I'd move this to ElementsPanel.js
850 return "commit";
851 return "";
852 }
853
851 var config = new WebInspector.InplaceEditor.Config(commit.bind(this), di spose.bind(this)); 854 var config = new WebInspector.InplaceEditor.Config(commit.bind(this), di spose.bind(this));
852 config.setMultilineOptions(initialValue, { name: "xml", htmlMode: true } , "web-inspector-html", WebInspector.moduleSetting("domWordWrap").get(), true); 855 config.setMultilineOptions(initialValue, { name: "xml", htmlMode: true } , "web-inspector-html", WebInspector.moduleSetting("domWordWrap").get(), true);
856 config.setPostKeydownFinishHandler(postKeyDownFinishHandler);
853 WebInspector.InplaceEditor.startMultilineEditing(this._htmlEditElement, config).then(markAsBeingEdited.bind(this)); 857 WebInspector.InplaceEditor.startMultilineEditing(this._htmlEditElement, config).then(markAsBeingEdited.bind(this));
854 858
855 /** 859 /**
856 * @param {!Object} controller 860 * @param {!Object} controller
857 * @this {WebInspector.ElementsTreeElement} 861 * @this {WebInspector.ElementsTreeElement}
858 */ 862 */
859 function markAsBeingEdited(controller) 863 function markAsBeingEdited(controller)
860 { 864 {
861 this._editing = /** @type {!WebInspector.InplaceEditor.Controller} * / (controller); 865 this._editing = /** @type {!WebInspector.InplaceEditor.Controller} * / (controller);
862 this._editing.setWidth(this.treeOutline.visibleWidth()); 866 this._editing.setWidth(this.treeOutline.visibleWidth());
(...skipping 662 matching lines...) Expand 10 before | Expand all | Expand 10 after
1525 1529
1526 if (object) 1530 if (object)
1527 object.callFunction(scrollIntoView); 1531 object.callFunction(scrollIntoView);
1528 } 1532 }
1529 1533
1530 this._node.resolveToObject("", scrollIntoViewCallback); 1534 this._node.resolveToObject("", scrollIntoViewCallback);
1531 }, 1535 },
1532 1536
1533 __proto__: TreeElement.prototype 1537 __proto__: TreeElement.prototype
1534 } 1538 }
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