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

Side by Side Diff: chrome/content/actor.jsm

Issue 29322778: Issue 2816 - Partial fix for EHH button in inspector tool, preview functionality still broken (Closed)
Patch Set: Unified code paths Created July 29, 2015, 12:23 p.m.
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | chrome/content/composer.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 /*
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
4 * http://mozilla.org/MPL/2.0/.
5 */
6
7 let EXPORTED_SYMBOLS = ["shutdown", "getNodeInfo"];
8
9 const Ci = Components.interfaces;
10 const Cu = Components.utils;
11
12 let {console} = Cu.import("resource://gre/modules/devtools/Console.jsm", {});
13 let {DebuggerServer} = Cu.import("resource://gre/modules/devtools/dbg-server.jsm ", {});
14 let name = "elemhidehelper";
15 let actor = {
16 constructorFun: Actor,
17 constructorName: name,
18 name: name
19 };
20
21 DebuggerServer.addTabActor(actor, name);
22
23 let shutdown = (function()
24 {
25 let executed = false;
26 return function()
27 {
28 if (!executed)
29 DebuggerServer.removeTabActor(actor);
30 executed = true;
31 }
32 })();
33
34 function Actor(connection, tabActor)
35 {
36 }
37
38 Actor.prototype = {
39 requestTypes: {
40 nodeinfo: function(request, connection)
41 {
42 let nodeActor = connection.getActor(request.nodeActor);
43 if (!nodeActor || !nodeActor.rawNode || nodeActor.rawNode.nodeType != Ci.n sIDOMNode.ELEMENT_NODE)
44 return {};
45
46 return getNodeInfo(nodeActor.rawNode);
47 }
48 }
49 };
50
51 function getNodeInfo(node)
52 {
53 return {
54 host: node.ownerDocument.defaultView.location.hostname,
55 nodeData: getNodeData(node)
56 }
57 }
58
59 function getNodeData(node, parentNode)
60 {
61 if (!node)
62 return null;
63
64 let result = {};
65 result.tagName = {value: node.tagName, checked: false};
66
67 if (typeof parentNode != "undefined")
68 result.parentNode = parentNode;
69 else
70 result.parentNode = getNodeData(node.parentElement);
71
72 let prevSibling = node.previousElementSibling;
73 result.prevSibling = getNodeData(prevSibling, result.parentNode);
74
75 if (result.parentNode && !prevSibling)
76 result.firstChild = {checked: false};
77
78 let nextSibling = node.nextElementSibling;
79 if (result.parentNode && !nextSibling)
80 result.lastChild = {checked: false};
81
82 result.attributes = [];
83 for (let attribute of node.attributes)
84 {
85 let data = {name: attribute.name, value: attribute.value, selected: attribut e.value, checked: false};
86 if (data.name == "id" || data.name == "class")
87 result.attributes.unshift(data);
88 else
89 result.attributes.push(data);
90 }
91
92 if (result.attributes.length >= 2 && result.attributes[1].name == "id")
93 {
94 // Make sure ID attribute comes first
95 let tmp = result.attributes[1];
96 result.attributes[1] = result.attributes[0];
97 result.attributes[0] = tmp;
98 }
99
100 result.customCSS = {selected: "", checked: false};
101 return result;
102 }
OLDNEW
« no previous file with comments | « no previous file | chrome/content/composer.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld