Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Delta Between Two Patch Sets: chrome/content/actor.jsm

Issue 29322778: Issue 2816 - Partial fix for EHH button in inspector tool, preview functionality still broken (Closed)
Left Patch Set: Another work-in-progress approach, previous changes reverted Created July 29, 2015, 11:58 a.m.
Right Patch Set: Preemptively fixed some nits and compatibility info Created July 29, 2015, 12:41 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « no previous file | chrome/content/composer.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 * This Source Code is subject to the terms of the Mozilla Public License 2 * This Source Code is subject to the terms of the Mozilla Public License
3 * version 2.0 (the "License"). You can obtain a copy of the License at 3 * version 2.0 (the "License"). You can obtain a copy of the License at
4 * http://mozilla.org/MPL/2.0/. 4 * http://mozilla.org/MPL/2.0/.
5 */ 5 */
6 6
7 let EXPORTED_SYMBOLS = ["shutdown"]; 7 let EXPORTED_SYMBOLS = ["shutdown", "getNodeInfo"];
8 8
9 const Ci = Components.interfaces; 9 const Ci = Components.interfaces;
10 const Cu = Components.utils; 10 const Cu = Components.utils;
11 11
12 let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {}); 12 let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
13 let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm ", {}); 13 let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm ", {});
14 let name = "elemhidehelper"; 14 let name = "elemhidehelper";
15 let actor = { 15 let actor = {
16 constructorFun: Actor, 16 constructorFun: Actor,
17 constructorName: name, 17 constructorName: name,
(...skipping 15 matching lines...) Expand all
33 33
34 function Actor(connection, tabActor) 34 function Actor(connection, tabActor)
35 { 35 {
36 } 36 }
37 37
38 Actor.prototype = { 38 Actor.prototype = {
39 requestTypes: { 39 requestTypes: {
40 nodeinfo: function(request, connection) 40 nodeinfo: function(request, connection)
41 { 41 {
42 let nodeActor = connection.getActor(request.nodeActor); 42 let nodeActor = connection.getActor(request.nodeActor);
43 if (!nodeActor || !nodeActor.rawNode || nodeActor.rawNode.nodeType != Ci.n sIDOMNode.ELEMENT_NODE) 43 if (!nodeActor || !nodeActor.rawNode ||
44 nodeActor.rawNode.nodeType != Ci.nsIDOMNode.ELEMENT_NODE)
45 {
44 return {}; 46 return {};
47 }
45 48
46 let node = nodeActor.rawNode; 49 return getNodeInfo(nodeActor.rawNode);
47 return {
48 host: node.ownerDocument.defaultView.location.hostname,
49 nodeData: getNodeData(node)
50 };
51 } 50 }
52 } 51 }
53 }; 52 };
53
54 function getNodeInfo(node)
55 {
56 return {
57 host: node.ownerDocument.defaultView.location.hostname,
58 nodeData: getNodeData(node)
59 };
60 }
54 61
55 function getNodeData(node, parentNode) 62 function getNodeData(node, parentNode)
56 { 63 {
57 if (!node) 64 if (!node)
58 return null; 65 return null;
59 66
60 let result = {}; 67 let result = {};
61 result.tagName = {value: node.tagName, checked: false}; 68 result.tagName = {value: node.tagName, checked: false};
62 69
63 if (typeof parentNode != "undefined") 70 if (typeof parentNode != "undefined")
64 result.parentNode = parentNode; 71 result.parentNode = parentNode;
65 else 72 else
66 result.parentNode = getNodeData(node.parentElement); 73 result.parentNode = getNodeData(node.parentElement);
67 74
68 let prevSibling = node.previousElementSibling; 75 let prevSibling = node.previousElementSibling;
69 result.prevSibling = getNodeData(prevSibling, result.parentNode); 76 result.prevSibling = getNodeData(prevSibling, result.parentNode);
70 77
71 if (result.parentNode && !prevSibling) 78 if (result.parentNode && !prevSibling)
72 result.firstChild = {checked: false}; 79 result.firstChild = {checked: false};
73 80
74 let nextSibling = node.nextElementSibling; 81 let nextSibling = node.nextElementSibling;
75 if (result.parentNode && !nextSibling) 82 if (result.parentNode && !nextSibling)
76 result.lastChild = {checked: false}; 83 result.lastChild = {checked: false};
77 84
78 result.attributes = []; 85 result.attributes = [];
79 for (let attribute of node.attributes) 86 for (let attribute of node.attributes)
80 { 87 {
81 let data = {name: attribute.name, value: attribute.value, selected: attribut e.value, checked: false}; 88 let data = {
89 name: attribute.name,
90 value: attribute.value,
91 selected: attribute.value,
92 checked: false
93 };
82 if (data.name == "id" || data.name == "class") 94 if (data.name == "id" || data.name == "class")
83 result.attributes.unshift(data); 95 result.attributes.unshift(data);
84 else 96 else
85 result.attributes.push(data); 97 result.attributes.push(data);
86 } 98 }
87 99
88 if (result.attributes.length >= 2 && result.attributes[1].name == "id") 100 if (result.attributes.length >= 2 && result.attributes[1].name == "id")
89 { 101 {
90 // Make sure ID attribute comes first 102 // Make sure ID attribute comes first
91 let tmp = result.attributes[1]; 103 let tmp = result.attributes[1];
92 result.attributes[1] = result.attributes[0]; 104 result.attributes[1] = result.attributes[0];
93 result.attributes[0] = tmp; 105 result.attributes[0] = tmp;
94 } 106 }
95 107
96 result.customCSS = {selected: "", checked: false}; 108 result.customCSS = {selected: "", checked: false};
97 return result; 109 return result;
98 } 110 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld