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

Unified 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, 10 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 side-by-side diff with in-line comments
Download patch
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..550ba0ad011f136bba8db38c9efb0d2570917bc8 100644
--- a/Source/devtools/front_end/DOMExtension.js
+++ b/Source/devtools/front_end/DOMExtension.js
@@ -570,6 +570,26 @@ Node.prototype.traversePreviousNode = function(stayWithin)
}
/**
+ * @param {*} text
+ * @return {boolean} true if was truncated
+ */
+Node.prototype.setTextContentTruncatedIfNeeded = function(text)
+{
+ // 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 = text.trimEnd(maxTextContentLength);
+ return true;
+ }
+
+ this.textContent = text;
+ return false;
+}
+
+/**
* @return {boolean}
*/
function isEnterKey(event) {

Powered by Google App Engine
This is Rietveld 408576698