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

Side by Side Diff: Source/devtools/front_end/ObjectPropertiesSection.js

Issue 186693002: DevTools: Prevent setting huge textContent in UI. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 9 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 | « Source/devtools/front_end/DOMExtension.js ('k') | no next file » | 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) 2008 Apple Inc. All Rights Reserved. 2 * Copyright (C) 2008 Apple Inc. All Rights Reserved.
3 * Copyright (C) 2009 Joseph Pecoraro 3 * Copyright (C) 2009 Joseph Pecoraro
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions 6 * modification, are permitted provided that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 this.nameElement.classList.add("properties-accessor-property-name"); 197 this.nameElement.classList.add("properties-accessor-property-name");
198 198
199 var separatorElement = document.createElement("span"); 199 var separatorElement = document.createElement("span");
200 separatorElement.className = "separator"; 200 separatorElement.className = "separator";
201 separatorElement.textContent = ": "; 201 separatorElement.textContent = ": ";
202 202
203 if (this.property.value) { 203 if (this.property.value) {
204 this.valueElement = document.createElement("span"); 204 this.valueElement = document.createElement("span");
205 this.valueElement.className = "value"; 205 this.valueElement.className = "value";
206 var description = this.property.value.description; 206 var description = this.property.value.description;
207 // Render \n as a nice unicode cr symbol.
208 if (this.property.wasThrown) { 207 if (this.property.wasThrown) {
209 this.valueElement.textContent = "[Exception: " + description + " ]"; 208 var text = "[Exception: " + description + "]";
209 this.valueElement.setTextContentTruncatedIfNeeded(text);
pfeldman 2014/03/05 05:14:03 Do it once for all below?
aandrey 2014/03/05 10:47:35 Done.
210 } else if (this.property.value.type === "string" && typeof descripti on === "string") { 210 } else if (this.property.value.type === "string" && typeof descripti on === "string") {
211 this.valueElement.textContent = "\"" + description.replace(/\n/g , "\u21B5") + "\""; 211 // Render \n as a nice unicode cr symbol.
212 var text = "\"" + description.replace(/\n/g, "\u21B5") + "\"";
213 this.valueElement.setTextContentTruncatedIfNeeded(text);
212 this.valueElement._originalTextContent = "\"" + description + "\ ""; 214 this.valueElement._originalTextContent = "\"" + description + "\ "";
213 } else if (this.property.value.type === "function" && typeof descrip tion === "string") { 215 } else if (this.property.value.type === "function" && typeof descrip tion === "string") {
214 this.valueElement.textContent = /.*/.exec(description)[0].replac e(/ +$/g, ""); 216 var text = /.*/.exec(description)[0].replace(/ +$/g, "");
217 this.valueElement.setTextContentTruncatedIfNeeded(text);
215 this.valueElement._originalTextContent = description; 218 this.valueElement._originalTextContent = description;
pfeldman 2014/03/05 05:14:03 Accidental click will start editing the original.
aandrey 2014/03/05 10:47:35 Done.
216 } else if (this.property.value.type !== "object" || this.property.va lue.subtype !== "node") { 219 } else if (this.property.value.type !== "object" || this.property.va lue.subtype !== "node") {
217 this.valueElement.textContent = description; 220 this.valueElement.setTextContentTruncatedIfNeeded(description);
218 } 221 }
219 222
220 if (this.property.wasThrown) 223 if (this.property.wasThrown)
221 this.valueElement.classList.add("error"); 224 this.valueElement.classList.add("error");
222 if (this.property.value.subtype) 225 if (this.property.value.subtype)
223 this.valueElement.classList.add("console-formatted-" + this.prop erty.value.subtype); 226 this.valueElement.classList.add("console-formatted-" + this.prop erty.value.subtype);
224 else if (this.property.value.type) 227 else if (this.property.value.type)
225 this.valueElement.classList.add("console-formatted-" + this.prop erty.value.type); 228 this.valueElement.classList.add("console-formatted-" + this.prop erty.value.type);
226 229
227 this.valueElement.addEventListener("contextmenu", this._contextMenuF ired.bind(this, this.property.value), false); 230 this.valueElement.addEventListener("contextmenu", this._contextMenuF ired.bind(this, this.property.value), false);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
309 { 312 {
310 var elementAndValueToEdit = this.elementAndValueToEdit(event); 313 var elementAndValueToEdit = this.elementAndValueToEdit(event);
311 var elementToEdit = elementAndValueToEdit[0]; 314 var elementToEdit = elementAndValueToEdit[0];
312 var valueToEdit = elementAndValueToEdit[1]; 315 var valueToEdit = elementAndValueToEdit[1];
313 316
314 if (WebInspector.isBeingEdited(elementToEdit) || !this.treeOutline.secti on.editable || this._readOnly) 317 if (WebInspector.isBeingEdited(elementToEdit) || !this.treeOutline.secti on.editable || this._readOnly)
315 return; 318 return;
316 319
317 // Edit original source. 320 // Edit original source.
318 if (typeof valueToEdit !== "undefined") 321 if (typeof valueToEdit !== "undefined")
319 elementToEdit.textContent = valueToEdit; 322 elementToEdit.setTextContentTruncatedIfNeeded(valueToEdit);
320 323
321 var context = { expanded: this.expanded, elementToEdit: elementToEdit, p reviousContent: elementToEdit.textContent }; 324 var context = { expanded: this.expanded, elementToEdit: elementToEdit, p reviousContent: elementToEdit.textContent };
322 325
323 // Lie about our children to prevent expanding on double click and to co llapse subproperties. 326 // Lie about our children to prevent expanding on double click and to co llapse subproperties.
324 this.hasChildren = false; 327 this.hasChildren = false;
325 328
326 this.listItemElement.classList.add("editing-sub-part"); 329 this.listItemElement.classList.add("editing-sub-part");
327 330
328 this._prompt = new WebInspector.ObjectPropertyPrompt(this.editingCommitt ed.bind(this, null, elementToEdit.textContent, context.previousContent, context) , this.editingCancelled.bind(this, null, context), this.renderPromptAsBlock()); 331 this._prompt = new WebInspector.ObjectPropertyPrompt(this.editingCommitt ed.bind(this, null, elementToEdit.textContent, context.previousContent, context) , this.editingCancelled.bind(this, null, context), this.renderPromptAsBlock());
329 332
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 { 982 {
980 WebInspector.TextPrompt.call(this, WebInspector.runtimeModel.completionsForT extPrompt.bind(WebInspector.runtimeModel)); 983 WebInspector.TextPrompt.call(this, WebInspector.runtimeModel.completionsForT extPrompt.bind(WebInspector.runtimeModel));
981 this.setSuggestBoxEnabled("generic-suggest"); 984 this.setSuggestBoxEnabled("generic-suggest");
982 if (renderAsBlock) 985 if (renderAsBlock)
983 this.renderAsBlock(); 986 this.renderAsBlock();
984 } 987 }
985 988
986 WebInspector.ObjectPropertyPrompt.prototype = { 989 WebInspector.ObjectPropertyPrompt.prototype = {
987 __proto__: WebInspector.TextPrompt.prototype 990 __proto__: WebInspector.TextPrompt.prototype
988 } 991 }
OLDNEW
« no previous file with comments | « Source/devtools/front_end/DOMExtension.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698