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

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: addressed 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
« no previous file with comments | « no previous file | Source/devtools/front_end/ObjectPropertiesSection.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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) {
« 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