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: Another work-in-progress approach, previous changes reverted Created July 29, 2015, 11:58 a.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"];
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 let node = nodeActor.rawNode;
47 return {
48 host: node.ownerDocument.defaultView.location.hostname,
49 nodeData: getNodeData(node)
50 };
51 }
52 }
53 };
54
55 function getNodeData(node, parentNode)
56 {
57 if (!node)
58 return null;
59
60 let result = {};
61 result.tagName = {value: node.tagName, checked: false};
62
63 if (typeof parentNode != "undefined")
64 result.parentNode = parentNode;
65 else
66 result.parentNode = getNodeData(node.parentElement);
67
68 let prevSibling = node.previousElementSibling;
69 result.prevSibling = getNodeData(prevSibling, result.parentNode);
70
71 if (result.parentNode && !prevSibling)
72 result.firstChild = {checked: false};
73
74 let nextSibling = node.nextElementSibling;
75 if (result.parentNode && !nextSibling)
76 result.lastChild = {checked: false};
77
78 result.attributes = [];
79 for (let attribute of node.attributes)
80 {
81 let data = {name: attribute.name, value: attribute.value, selected: attribut e.value, checked: false};
82 if (data.name == "id" || data.name == "class")
83 result.attributes.unshift(data);
84 else
85 result.attributes.push(data);
86 }
87
88 if (result.attributes.length >= 2 && result.attributes[1].name == "id")
89 {
90 // Make sure ID attribute comes first
91 let tmp = result.attributes[1];
92 result.attributes[1] = result.attributes[0];
93 result.attributes[0] = tmp;
94 }
95
96 result.customCSS = {selected: "", checked: false};
97 return result;
98 }
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