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

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: 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
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 * @return {boolean} true if was truncated
575 */
576 Node.prototype.setTextContentTruncatedIfNeeded = function(text)
577 {
578 // Huge texts in the UI reduce rendering performance drastically.
579 // Moreover Blink/WebKit uses <unsigned short> internally for storing text c ontent
580 // length, so texts longer than 65535 are inherently displayed incorrectly.
581 const maxTextContentLength = 65535;
582
583 if (typeof text === "string" && text.length > maxTextContentLength) {
584 this.textContent = text.trimEnd(maxTextContentLength);
585 return true;
586 }
587
588 this.textContent = text;
589 return false;
590 }
591
592 /**
573 * @return {boolean} 593 * @return {boolean}
574 */ 594 */
575 function isEnterKey(event) { 595 function isEnterKey(event) {
576 // Check if in IME. 596 // Check if in IME.
577 return event.keyCode !== 229 && event.keyIdentifier === "Enter"; 597 return event.keyCode !== 229 && event.keyIdentifier === "Enter";
578 } 598 }
579 599
580 function consumeEvent(e) 600 function consumeEvent(e)
581 { 601 {
582 e.consume(); 602 e.consume();
583 } 603 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698