Index: Source/devtools/front_end/DOMExtension.js |
diff --git a/Source/devtools/front_end/DOMExtension.js b/Source/devtools/front_end/DOMExtension.js |
index b9629db22ae888684218858aa77034103cff8a75..5573146c201824f47469862ab30b16252f060010 100644 |
--- a/Source/devtools/front_end/DOMExtension.js |
+++ b/Source/devtools/front_end/DOMExtension.js |
@@ -570,6 +570,27 @@ Node.prototype.traversePreviousNode = function(stayWithin) |
} |
/** |
+ * @param {*} text |
+ * @param {string=} placeholder |
+ * @return {boolean} true if was truncated |
+ */ |
+Node.prototype.setTextContentTruncatedIfNeeded = function(text, placeholder) |
+{ |
+ // Huge texts in the UI reduce rendering performance drastically. |
+ // Moreover, Blink/WebKit uses <unsigned short> internally for storing text content |
+ // length, so texts longer than 65535 are inherently displayed incorrectly. |
+ const maxTextContentLength = 65535; |
+ |
+ if (typeof text === "string" && text.length > maxTextContentLength) { |
+ this.textContent = typeof placeholder === "string" ? placeholder : text.trimEnd(maxTextContentLength); |
+ return true; |
+ } |
+ |
+ this.textContent = text; |
+ return false; |
+} |
+ |
+/** |
* @return {boolean} |
*/ |
function isEnterKey(event) { |