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

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

Issue 186693002: DevTools: Prevent setting huge textContent in UI. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: addressed 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 | « no previous file | Source/devtools/front_end/ObjectPropertiesSection.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 Apple Inc. All rights reserved. 2 * Copyright (C) 2007 Apple Inc. All rights reserved.
3 * Copyright (C) 2012 Google Inc. All rights reserved. 3 * Copyright (C) 2012 Google Inc. All rights reserved.
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 * 8 *
9 * 1. Redistributions of source code must retain the above copyright 9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer. 10 * notice, this list of conditions and the following disclaimer.
(...skipping 552 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 return null; 563 return null;
564 var node = this.previousSibling; 564 var node = this.previousSibling;
565 while (node && node.lastChild) 565 while (node && node.lastChild)
566 node = node.lastChild; 566 node = node.lastChild;
567 if (node) 567 if (node)
568 return node; 568 return node;
569 return this.parentNode; 569 return this.parentNode;
570 } 570 }
571 571
572 /** 572 /**
573 * @param {*} text
574 * @param {string=} placeholder
575 * @return {boolean} true if was truncated
576 */
577 Node.prototype.setTextContentTruncatedIfNeeded = function(text, placeholder)
578 {
579 // Huge texts in the UI reduce rendering performance drastically.
580 // Moreover, Blink/WebKit uses <unsigned short> internally for storing text content
581 // length, so texts longer than 65535 are inherently displayed incorrectly.
582 const maxTextContentLength = 65535;
583
584 if (typeof text === "string" && text.length > maxTextContentLength) {
585 this.textContent = typeof placeholder === "string" ? placeholder : text. trimEnd(maxTextContentLength);
586 return true;
587 }
588
589 this.textContent = text;
590 return false;
591 }
592
593 /**
573 * @return {boolean} 594 * @return {boolean}
574 */ 595 */
575 function isEnterKey(event) { 596 function isEnterKey(event) {
576 // Check if in IME. 597 // Check if in IME.
577 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; 598 return event.keyCode !== 229 && event.keyIdentifier === "Enter";
578 } 599 }
579 600
580 function consumeEvent(e) 601 function consumeEvent(e)
581 { 602 {
582 e.consume(); 603 e.consume();
583 } 604 }
OLDNEW
« no previous file with comments | « no previous file | Source/devtools/front_end/ObjectPropertiesSection.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698