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: Unified code paths Created July 29, 2015, 12:23 p.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", "getNodeInfo"]; 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;
(...skipping 22 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 return getNodeInfo(nodeActor.rawNode); 49 return getNodeInfo(nodeActor.rawNode);
47 } 50 }
48 } 51 }
49 }; 52 };
50 53
51 function getNodeInfo(node) 54 function getNodeInfo(node)
52 { 55 {
53 return { 56 return {
54 host: node.ownerDocument.defaultView.location.hostname, 57 host: node.ownerDocument.defaultView.location.hostname,
55 nodeData: getNodeData(node) 58 nodeData: getNodeData(node)
56 } 59 };
57 } 60 }
58 61
59 function getNodeData(node, parentNode) 62 function getNodeData(node, parentNode)
60 { 63 {
61 if (!node) 64 if (!node)
62 return null; 65 return null;
63 66
64 let result = {}; 67 let result = {};
65 result.tagName = {value: node.tagName, checked: false}; 68 result.tagName = {value: node.tagName, checked: false};
66 69
67 if (typeof parentNode != "undefined") 70 if (typeof parentNode != "undefined")
68 result.parentNode = parentNode; 71 result.parentNode = parentNode;
69 else 72 else
70 result.parentNode = getNodeData(node.parentElement); 73 result.parentNode = getNodeData(node.parentElement);
71 74
72 let prevSibling = node.previousElementSibling; 75 let prevSibling = node.previousElementSibling;
73 result.prevSibling = getNodeData(prevSibling, result.parentNode); 76 result.prevSibling = getNodeData(prevSibling, result.parentNode);
74 77
75 if (result.parentNode && !prevSibling) 78 if (result.parentNode && !prevSibling)
76 result.firstChild = {checked: false}; 79 result.firstChild = {checked: false};
77 80
78 let nextSibling = node.nextElementSibling; 81 let nextSibling = node.nextElementSibling;
79 if (result.parentNode && !nextSibling) 82 if (result.parentNode && !nextSibling)
80 result.lastChild = {checked: false}; 83 result.lastChild = {checked: false};
81 84
82 result.attributes = []; 85 result.attributes = [];
83 for (let attribute of node.attributes) 86 for (let attribute of node.attributes)
84 { 87 {
85 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 };
86 if (data.name == "id" || data.name == "class") 94 if (data.name == "id" || data.name == "class")
87 result.attributes.unshift(data); 95 result.attributes.unshift(data);
88 else 96 else
89 result.attributes.push(data); 97 result.attributes.push(data);
90 } 98 }
91 99
92 if (result.attributes.length >= 2 && result.attributes[1].name == "id") 100 if (result.attributes.length >= 2 && result.attributes[1].name == "id")
93 { 101 {
94 // Make sure ID attribute comes first 102 // Make sure ID attribute comes first
95 let tmp = result.attributes[1]; 103 let tmp = result.attributes[1];
96 result.attributes[1] = result.attributes[0]; 104 result.attributes[1] = result.attributes[0];
97 result.attributes[0] = tmp; 105 result.attributes[0] = tmp;
98 } 106 }
99 107
100 result.customCSS = {selected: "", checked: false}; 108 result.customCSS = {selected: "", checked: false};
101 return result; 109 return result;
102 } 110 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld