Bug 886033 - Port markup view text value editing to inspector actor. r=paul
authorDave Camp <dcamp@mozilla.com>
Mon, 17 Jun 2013 06:52:55 -0700
changeset 151601 89e4e5c1581957b38d50ba323562a22b33f31287
parent 151600 89fd81b99fcfa2881b850343da680b9d5a975d65
child 151602 bf73e10f5e54f9c424a0899b3032e11a6a65d10a
push id2859
push userakeybl@mozilla.com
push dateMon, 16 Sep 2013 19:14:59 +0000
treeherdermozilla-beta@87d3c51cd2bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspaul
bugs886033
milestone25.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 886033 - Port markup view text value editing to inspector actor. r=paul
browser/devtools/markupview/markup-view.js
--- a/browser/devtools/markupview/markup-view.js
+++ b/browser/devtools/markupview/markup-view.js
@@ -1003,38 +1003,42 @@ function DoctypeEditor(aContainer, aNode
  */
 function TextEditor(aContainer, aNode, aTemplate)
 {
   this.node = aNode;
   this._selected = false;
 
   aContainer.markup.template(aTemplate, this);
 
-  let rawNode = aNode.rawNode();
-  if (rawNode) {
-    editableField({
-      element: this.value,
-      stopOnReturn: true,
-      trigger: "dblclick",
-      multiline: true,
-      done: function TE_done(aVal, aCommit) {
-        if (!aCommit) {
-          return;
-        }
-        let oldValue = rawNode.nodeValue;
-        aContainer.undo.do(function() {
-          rawNode.nodeValue = aVal;
-          aContainer.markup.nodeChanged(this.node);
-        }.bind(this), function() {
-          rawNode.nodeValue = oldValue;
-          aContainer.markup.nodeChanged(this.node);
-        }.bind(this));
-      }.bind(this)
-    });
-  }
+  editableField({
+    element: this.value,
+    stopOnReturn: true,
+    trigger: "dblclick",
+    multiline: true,
+    done: (aVal, aCommit) => {
+      if (!aCommit) {
+        return;
+      }
+      this.node.getNodeValue().then(longstr => {
+        longstr.string().then(oldValue => {
+          longstr.release().then(null, console.error);
+
+          aContainer.undo.do(() => {
+            this.node.setNodeValue(aVal).then(() => {
+              aContainer.markup.nodeChanged(this.node);
+            });
+          }, () => {
+            this.node.setNodeValue(oldValue).then(() => {
+              aContainer.markup.nodeChanged(this.node);
+            })
+          });
+        });
+      });
+    }
+  });
 
   this.update();
 }
 
 TextEditor.prototype = {
   get selected() this._selected,
   set selected(aValue) {
     if (aValue === this._selected) {