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

Side by Side Diff: lib/child/contextMenu.js

Issue 29331700: Issue 3223 - Implement context menu fallback for SeaMonkey Mail and Thunderbird (Closed)
Patch Set: Changed notification name Created Dec. 2, 2015, 11:20 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 | lib/ui.js » ('j') | lib/ui.js » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * This file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2015 Eyeo GmbH 3 * Copyright (C) 2006-2015 Eyeo GmbH
4 * 4 *
5 * Adblock Plus is free software: you can redistribute it and/or modify 5 * Adblock Plus is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License version 3 as 6 * it under the terms of the GNU General Public License version 3 as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
8 * 8 *
9 * Adblock Plus is distributed in the hope that it will be useful, 9 * Adblock Plus is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
(...skipping 15 matching lines...) Expand all
26 26
27 /** 27 /**
28 * Determines the context menu entries to be shown for a contextmenu event. 28 * Determines the context menu entries to be shown for a contextmenu event.
29 * @param {Event} event 29 * @param {Event} event
30 * @return {Array} 30 * @return {Array}
31 */ 31 */
32 function getContextInfo(event) 32 function getContextInfo(event)
33 { 33 {
34 let items = []; 34 let items = [];
35 let target = event.target; 35 let target = event.target;
36 if (target.localName == "menupopup" && target.triggerNode) 36 if (target.localName == "menupopup" && target.triggerNode)
tschuster 2015/12/02 12:14:17 Is this still needed now?
Wladimir Palant 2015/12/02 12:20:54 Yes, it is. That's SeaMonkey sending the content-c
37 { 37 {
38 // SeaMonkey gives us the context menu's popupshowing event 38 // SeaMonkey gives us the context menu's popupshowing event
39 target = target.triggerNode; 39 target = target.triggerNode;
40 } 40 }
41 if (target instanceof Ci.nsIDOMHTMLMapElement || target instanceof Ci.nsIDOMHT MLAreaElement) 41 if (target instanceof Ci.nsIDOMHTMLMapElement || target instanceof Ci.nsIDOMHT MLAreaElement)
42 { 42 {
43 // HTML image maps will usually receive events when the mouse pointer is 43 // HTML image maps will usually receive events when the mouse pointer is
44 // over a different element, get the real event target. 44 // over a different element, get the real event target.
45 let rect = target.getClientRects()[0]; 45 let rect = target.getClientRects()[0];
46 target = target.ownerDocument.elementFromPoint(Math.max(rect.left, 0), Math. max(rect.top, 0)); 46 target = target.ownerDocument.elementFromPoint(Math.max(rect.left, 0), Math. max(rect.top, 0));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 } 113 }
114 } 114 }
115 115
116 return items; 116 return items;
117 }; 117 };
118 118
119 let ContextMenuObserver = 119 let ContextMenuObserver =
120 { 120 {
121 observe: function(subject, topic, data) 121 observe: function(subject, topic, data)
122 { 122 {
123 if (topic == "content-contextmenu") 123 if (subject.wrappedJSObject)
124 { 124 subject = subject.wrappedJSObject;
125 if (subject.wrappedJSObject)
126 subject = subject.wrappedJSObject;
127 125
128 if (subject.addonInfo) 126 if (subject.addonInfo)
129 subject.addonInfo.adblockplus = getContextInfo(subject.event); 127 subject.addonInfo.adblockplus = getContextInfo(subject.event);
130 }
131 }, 128 },
132 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver]) 129 QueryInterface: XPCOMUtils.generateQI([Ci.nsISupportsWeakReference, Ci.nsIObse rver])
133 }; 130 };
134 131
135 let addObserver = Utils.getPropertyWithoutCompatShims(Services.obs, "addObserver "); 132 let addObserver = Utils.getPropertyWithoutCompatShims(Services.obs, "addObserver ");
136 addObserver.call(Services.obs, ContextMenuObserver, "content-contextmenu", true) ; 133 addObserver.call(Services.obs, ContextMenuObserver, "content-contextmenu", true) ;
134 addObserver.call(Services.obs, ContextMenuObserver, "AdblockPlus:content-context menu", true);
137 onShutdown.add(() => { 135 onShutdown.add(() => {
138 let removeObserver = Utils.getPropertyWithoutCompatShims(Services.obs, "remove Observer"); 136 let removeObserver = Utils.getPropertyWithoutCompatShims(Services.obs, "remove Observer");
139 removeObserver.call(Services.obs, ContextMenuObserver, "content-contextmenu"); 137 removeObserver.call(Services.obs, ContextMenuObserver, "content-contextmenu");
138 removeObserver.call(Services.obs, ContextMenuObserver, "AdblockPlus:content-co ntextmenu");
140 }); 139 });
OLDNEW
« no previous file with comments | « no previous file | lib/ui.js » ('j') | lib/ui.js » ('J')

Powered by Google App Engine
This is Rietveld