Bug 1314573 - Modify textNode Reps modes to match elementNodeRep; r=Honza draft
authorNicolas Chevobbe <chevobbe.nicolas@gmail.com>
Thu, 17 Nov 2016 18:04:55 +0100
changeset 440563 1e33216239ebdcde47a0f7e80e3c138a8d3335f2
parent 440562 39fcc8ff5cb3386663fb5f0821cecd78abae00b3
child 537410 32b71be12d4485ce4a6ab03f1d10c7d5258fd483
push id36265
push userchevobbe.nicolas@gmail.com
push dateThu, 17 Nov 2016 20:39:34 +0000
reviewersHonza
bugs1314573
milestone53.0a1
Bug 1314573 - Modify textNode Reps modes to match elementNodeRep; r=Honza On elementNodeRep, we have different outputs for tiny and short modes, and short and long modes are the same. Since the current long mode of textNodeRep aren't used anywhere, we can do the same, i.e. have a really small representation for tiny mode, and then the same rendering for short and long modes. Modify tests to adapt them to the new rendering. MozReview-Commit-ID: BRA7iADkn1C
devtools/client/shared/components/reps/text-node.js
devtools/client/shared/components/test/mochitest/test_reps_text-node.html
--- a/devtools/client/shared/components/reps/text-node.js
+++ b/devtools/client/shared/components/reps/text-node.js
@@ -27,22 +27,23 @@ define(function (require, exports, modul
       mode: React.PropTypes.string,
     },
 
     getTextContent: function (grip) {
       return cropString(grip.preview.textContent);
     },
 
     getTitle: function (grip) {
+      const title = "#text";
       if (this.props.objectLink) {
         return this.props.objectLink({
           object: grip
-        }, "#text ");
+        }, title);
       }
-      return "";
+      return title;
     },
 
     render: function () {
       let grip = this.props.object;
       let mode = this.props.mode || "short";
 
       let baseConfig = {className: "objectBox objectBox-textNode"};
       if (this.props.onDOMNodeMouseOver) {
@@ -52,43 +53,27 @@ define(function (require, exports, modul
       }
 
       if (this.props.onDOMNodeMouseOut) {
         Object.assign(baseConfig, {
           onMouseOut: this.props.onDOMNodeMouseOut
         });
       }
 
-      if (mode == "short" || mode == "tiny") {
-        return (
-          DOM.span(baseConfig,
-            this.getTitle(grip),
-            DOM.span({className: "nodeValue"},
-              "\"" + this.getTextContent(grip) + "\""
-            )
-          )
-        );
+      if (mode == "tiny") {
+        return DOM.span(baseConfig, this.getTitle(grip));
       }
 
-      let objectLink = this.props.objectLink || DOM.span;
       return (
         DOM.span(baseConfig,
           this.getTitle(grip),
-          objectLink({
-            object: grip
-          }, "<"),
-          DOM.span({className: "nodeTag"}, "TextNode"),
-          " textContent=\"",
           DOM.span({className: "nodeValue"},
-            this.getTextContent(grip)
-          ),
-          "\"",
-          objectLink({
-            object: grip
-          }, ">;")
+            " ",
+            `"${this.getTextContent(grip)}"`
+          )
         )
       );
     },
   });
 
   // Registration
 
   function supportsObject(grip, type) {
--- a/devtools/client/shared/components/test/mochitest/test_reps_text-node.html
+++ b/devtools/client/shared/components/test/mochitest/test_reps_text-node.html
@@ -55,62 +55,60 @@ window.onload = Task.async(function* () 
   } catch (e) {
     ok(false, "Got an error: " + DevToolsUtils.safeErrorString(e));
   } finally {
     SimpleTest.finish();
   }
 
   function testRendering() {
     const stub = gripStubs.get("testRendering");
-    const defaultShortOutput = `"hello world"`;
-    const defaultLongOutput = `<TextNode textContent="hello world">;`;
+    const defaultOutput = `#text "hello world"`;
 
     const modeTests = [
       {
         mode: undefined,
-        expectedOutput: defaultShortOutput,
+        expectedOutput: defaultOutput,
       },
       {
         mode: "tiny",
-        expectedOutput: defaultShortOutput,
+        expectedOutput: "#text",
       },
       {
         mode: "short",
-        expectedOutput: defaultShortOutput,
+        expectedOutput: defaultOutput,
       },
       {
         mode: "long",
-        expectedOutput: defaultLongOutput,
+        expectedOutput: defaultOutput,
       }
     ];
 
     testRepRenderModes(modeTests, "testRendering", TextNode, stub);
   }
 
   function testRenderingWithEOL() {
     const stub = gripStubs.get("testRenderingWithEOL");
-    const defaultShortOutput = `"hello\nworld"`;
-    const defaultLongOutput = `<TextNode textContent="hello\nworld">;`;
+    const defaultOutput = `#text "hello\nworld"`;
 
     const modeTests = [
       {
         mode: undefined,
-        expectedOutput: defaultShortOutput,
+        expectedOutput: defaultOutput,
       },
       {
         mode: "tiny",
-        expectedOutput: defaultShortOutput,
+        expectedOutput: "#text",
       },
       {
         mode: "short",
-        expectedOutput: defaultShortOutput,
+        expectedOutput: defaultOutput,
       },
       {
         mode: "long",
-        expectedOutput: defaultLongOutput,
+        expectedOutput: defaultOutput,
       }
     ];
 
     testRepRenderModes(modeTests, "testRenderingWithEOL", TextNode, stub);
   }
 
   function testOnMouseOver() {
     const stub = gripStubs.get("testRendering");