Bug 1304804 - Don't set a default cropLimit for reps;r=Honza
MozReview-Commit-ID: HVHqkomVrLW
--- 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)) {