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

Delta Between Two Patch Sets: lib/child/subscribeLinks.js

Issue 29338861: Issue 3851 - Implement subscribe link handling via process scripts (Closed)
Left Patch Set: Created March 21, 2016, 7:25 p.m.
Right Patch Set: Added guard and removed dead code Created April 18, 2016, 3:36 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 | « lib/child/main.js ('k') | lib/ui.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 file is part of Adblock Plus <https://adblockplus.org/>, 2 * This file is part of Adblock Plus <https://adblockplus.org/>,
3 * Copyright (C) 2006-2016 Eyeo GmbH 3 * Copyright (C) 2006-2016 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 11 matching lines...) Expand all
22 Services.obs.addObserver(onContentWindow, "content-document-global-created", 22 Services.obs.addObserver(onContentWindow, "content-document-global-created",
23 false); 23 false);
24 onShutdown.add(() => 24 onShutdown.add(() =>
25 { 25 {
26 Services.obs.removeObserver(onContentWindow, 26 Services.obs.removeObserver(onContentWindow,
27 "content-document-global-created"); 27 "content-document-global-created");
28 }); 28 });
29 29
30 function onContentWindow(subject, topic, data) 30 function onContentWindow(subject, topic, data)
31 { 31 {
32 if (subject instanceof Ci.nsIDOMWindow && subject.top == subject) 32 if (subject instanceof Ci.nsIDOMWindow && subject.top == subject)
Thomas Greiner 2016/04/18 15:16:25 So we're not listening to clicks in subdocuments?
Wladimir Palant 2016/04/18 15:38:40 We do, clicks will bubble up from frames. I verifi
Thomas Greiner 2016/04/18 17:49:43 Thanks for verifying!
33 { 33 {
34 let eventTarget = subject.QueryInterface(Ci.nsIInterfaceRequestor) 34 let eventTarget = subject.QueryInterface(Ci.nsIInterfaceRequestor)
35 .getInterface(Ci.nsIWebNavigation) 35 .getInterface(Ci.nsIWebNavigation)
36 .QueryInterface(Ci.nsIDocShell) 36 .QueryInterface(Ci.nsIDocShell)
37 .chromeEventHandler; 37 .chromeEventHandler;
38 eventTarget.addEventListener("click", onClick, true); 38 if (eventTarget)
Wladimir Palant 2016/04/18 15:38:40 Not sure when this happens but there are apparentl
39 eventTarget.addEventListener("click", onClick, true);
39 } 40 }
40 } 41 }
41 42
42 function onClick(event) 43 function onClick(event)
Wladimir Palant 2016/03/21 19:27:20 It's mostly an indentation change for this functio
Wladimir Palant 2016/03/21 19:29:20 Heh, forgot the sendAsyncMessage call at the botto
43 { 44 {
44 if (onShutdown.done) 45 if (onShutdown.done)
45 return; 46 return;
Erik 2016/04/06 03:11:41 This will stop the function from running after shu
Wladimir Palant 2016/04/18 15:38:40 Yes, the function itself is leaked - getting the e
46 47
47 // Ignore right-clicks 48 // Ignore right-clicks
48 if (event.button == 2) 49 if (event.button == 2)
49 return; 50 return;
50 51
51 // Search the link associated with the click 52 // Search the link associated with the click
52 let link = event.target; 53 let link = event.target;
53 while (!(link instanceof Ci.nsIDOMHTMLAnchorElement)) 54 while (!(link instanceof Ci.nsIDOMHTMLAnchorElement))
54 { 55 {
55 link = link.parentNode; 56 link = link.parentNode;
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 } 109 }
109 } 110 }
110 111
111 port.emit("subscribeLinkClick", { 112 port.emit("subscribeLinkClick", {
112 title: title, 113 title: title,
113 url: url, 114 url: url,
114 mainSubscriptionTitle: mainSubscriptionTitle, 115 mainSubscriptionTitle: mainSubscriptionTitle,
115 mainSubscriptionURL: mainSubscriptionURL 116 mainSubscriptionURL: mainSubscriptionURL
116 }); 117 });
117 } 118 }
LEFTRIGHT

Powered by Google App Engine
This is Rietveld