Bug 1304804 - Don't set a default cropLimit for reps;r=Honza draft
authorBrian Grinstead <bgrinstead@mozilla.com>
Mon, 26 Sep 2016 11:49:54 -0700
changeset 417735 f57959b4271106a67ee5801cb0b2ba511279e4ff
parent 417649 c55bcb7c777ea09431b4d16903ed079ae5632648
child 532155 b0c9b02c049b3002b313ecfcd1c6e11590d9f9c7
push id30473
push userbgrinstead@mozilla.com
push dateMon, 26 Sep 2016 18:51:52 +0000
reviewersHonza
bugs1304804
milestone52.0a1
Bug 1304804 - Don't set a default cropLimit for reps;r=Honza MozReview-Commit-ID: HVHqkomVrLW
devtools/client/dom/content/components/dom-tree.js
devtools/client/jsonview/components/json-panel.js
devtools/client/shared/components/reps/rep-utils.js
devtools/client/shared/components/test/mochitest/test_reps_string.html
devtools/client/webconsole/net/components/post-tab.js
devtools/client/webconsole/net/components/response-tab.js
--- a/devtools/client/dom/content/components/dom-tree.js
+++ b/devtools/client/dom/content/components/dom-tree.js
@@ -56,16 +56,17 @@ var DomTree = React.createClass({
     }];
 
     // This is the integration point with Reps. The DomTree is using
     // Reps to render all values. The code also specifies default rep
     // used for data types that don't have its own specific template.
     let renderValue = props => {
       return Rep(Object.assign({}, props, {
         defaultRep: Grip,
+        cropLimit: 50,
       }));
     };
 
     return (
       TreeView({
         object: this.props.object,
         provider: new GripProvider(this.props.grips, this.props.dispatch),
         decorator: new DomDecorator(),
--- a/devtools/client/jsonview/components/json-panel.js
+++ b/devtools/client/jsonview/components/json-panel.js
@@ -88,17 +88,19 @@ define(function (require, exports, modul
       let member = props.member;
 
       // Hide object summary when object is expanded (bug 1244912).
       if (typeof member.value == "object" && member.open) {
         return null;
       }
 
       // Render the value (summary) using Reps library.
-      return Rep(props);
+      return Rep(Object.assign({}, props, {
+        cropLimit: 50,
+      }));
     },
 
     renderTree: function () {
       // Append custom column for displaying values. This column
       // Take all available horizontal space.
       let columns = [{
         id: "value",
         width: "100%"
--- a/devtools/client/shared/components/reps/rep-utils.js
+++ b/devtools/client/shared/components/reps/rep-utils.js
@@ -43,23 +43,18 @@ define(function (require, exports, modul
   function cropString(text, limit, alternativeText) {
     if (!alternativeText) {
       alternativeText = "\u2026";
     }
 
     // Make sure it's a string.
     text = text + "";
 
-    // Use default limit if necessary.
-    if (!limit) {
-      limit = 50;
-    }
-
     // Crop the string only if a limit is actually specified.
-    if (limit <= 0) {
+    if (!limit || limit <= 0) {
       return text;
     }
 
     // Set the limit at least to the length of the alternative text
     // plus one character of the original text.
     if (limit <= alternativeText.length) {
       limit = alternativeText.length + 1;
     }
--- a/devtools/client/shared/components/test/mochitest/test_reps_string.html
+++ b/devtools/client/shared/components/test/mochitest/test_reps_string.html
@@ -31,17 +31,17 @@ window.onload = Task.async(function* () 
   } catch(e) {
     ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
   } finally {
     SimpleTest.finish();
   }
 
   function testMultiline() {
     const renderedComponent = renderComponent(StringRep.rep, { object: getGripStub("testMultiline") });
-    is(renderedComponent.textContent, "\"aaaaaaaaaaaaaaaaaaaaa\\nbbb…bbbbbb\\ncccccccccccccccc\\n\"", "String rep has expected text content for multiline string");
+    is(renderedComponent.textContent, "\"aaaaaaaaaaaaaaaaaaaaa\\nbbbbbbbbbbbbbbbbbbb\\ncccccccccccccccc\\n\"", "String rep has expected text content for multiline string");
   }
 
   function testMultilineLimit() {
     const renderedComponent = renderComponent(StringRep.rep, { object: getGripStub("testMultiline"), cropLimit: 20 });
     is(renderedComponent.textContent, "\"aaaaaaaaaa…cccccccc\\n\"", "String rep has expected text content for multiline string with specified number of characters");
   }
 
   function testMultilineOpen() {
--- a/devtools/client/webconsole/net/components/post-tab.js
+++ b/devtools/client/webconsole/net/components/post-tab.js
@@ -72,17 +72,19 @@ var PostTab = React.createClass({
     }
 
     return {
       key: "json",
       content: TreeView({
         columns: [{id: "value"}],
         object: json,
         mode: "tiny",
-        renderValue: props => Rep(props)
+        renderValue: props => Rep(Object.assign({}, props, {
+          cropLimit: 50,
+        })),
       }),
       name: Locale.$STR("jsonScopeName")
     };
   },
 
   parseXml(file) {
     let text = file.request.postData.text;
     if (isLongString(text)) {
--- a/devtools/client/webconsole/net/components/response-tab.js
+++ b/devtools/client/webconsole/net/components/response-tab.js
@@ -100,17 +100,19 @@ var ResponseTab = React.createClass({
     }
 
     return {
       key: "json",
       content: TreeView({
         columns: [{id: "value"}],
         object: json,
         mode: "tiny",
-        renderValue: props => Rep(props)
+        renderValue: props => Rep(Object.assign({}, props, {
+          cropLimit: 50,
+        })),
       }),
       name: Locale.$STR("jsonScopeName")
     };
   },
 
   renderImage(file) {
     let content = file.response.content;
     if (!this.isImage(content)) {