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

Delta Between Two Patch Sets: chrome/content/ui/ext/popup.js

Issue 5294633391226880: issue 1435 - Port popup.html from Chrome/Safari/Opera to Firefox (Closed)
Left Patch Set: Created Sept. 26, 2014, 12:48 p.m.
Right Patch Set: Created Oct. 27, 2014, 9:40 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
LEFTRIGHT
1 /* 1 /*
2 * This file is part of Adblock Plus <http://adblockplus.org/>, 2 * This file is part of Adblock Plus <http://adblockplus.org/>,
3 * Copyright (C) 2006-2014 Eyeo GmbH 3 * Copyright (C) 2006-2014 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
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details. 12 * GNU General Public License for more details.
13 * 13 *
14 * You should have received a copy of the GNU General Public License 14 * You should have received a copy of the GNU General Public License
15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. 15 * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
16 */ 16 */
17 17
18 (function() 18 (function()
19 { 19 {
20 var {UI} = require("ui"); 20 var {UI} = require("ui");
21 21
22 var iframe = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor ) 22 var iframe = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor )
23 .getInterface(Components.interfaces.nsIWebNavigation) 23 .getInterface(Components.interfaces.nsIWebNavigation)
24 .QueryInterface(Components.interfaces.nsIDocShell) 24 .QueryInterface(Components.interfaces.nsIDocShell)
25 .chromeEventHandler; 25 .chromeEventHandler;
26 var topWindow = iframe.ownerDocument.defaultView; 26 var topWindow = iframe.ownerDocument.defaultView;
27 27 var panel = iframe.parentNode;
28
28 // Firefox doesn't adjust the size of the popup automatically to the size 29 // Firefox doesn't adjust the size of the popup automatically to the size
29 // of its content, like when the ad counter is expanded/collapsed. So we add 30 // of its content, like when the ad counter is expanded/collapsed. So we use
30 // event listeners to do so. 31 // MutationObserver to do so.
Thomas Greiner 2014/10/08 10:40:43 It's true that we're not using event listeners for
saroyanm 2014/10/10 12:05:58 Done.
31 var mayResize = true;
Thomas Greiner 2014/09/29 16:19:49 Is this variable ever set to false?
saroyanm 2014/10/02 07:53:56 Good point, removed.
32 var resizingScheduled = false; 32 var resizingScheduled = false;
33 33
34 function updateSize() 34 function updateSize()
35 { 35 {
36 if (mayResize && !resizingScheduled) 36 if (!resizingScheduled)
37 { 37 {
38 setTimeout(function() 38 setTimeout(function()
39 { 39 {
40 iframe.parentNode.sizeTo(document.body.scrollWidth, document.body.offset Height + 11);
Thomas Greiner 2014/09/29 16:19:49 Why `+ 11`?
saroyanm 2014/10/02 07:53:56 I guess here I should use scrollHeight instead of
saroyanm 2014/10/07 13:02:05 Thomas, so here are the results of investigation:
Thomas Greiner 2014/10/08 10:40:43 Couldn't we check for those values on runtime? Tho
saroyanm 2014/10/10 12:05:58 Yes, looks like we can, while iframe is stretching
41 resizingScheduled = false; 40 resizingScheduled = false;
41
42 // We need to calculate the height difference because the panel's size i ncludes
43 // the height of the arrow image and the border width of the panel conte nt
44 var heightDifference = panel.clientHeight - iframe.clientHeight;
45 panel.sizeTo(document.body.scrollWidth, document.body.scrollHeight + hei ghtDifference);
42 }, 0); 46 }, 0);
43 47
44 resizingScheduled = true; 48 resizingScheduled = true;
45 } 49 }
46 } 50 }
47 51
48 window.addEventListener("load", function() 52 window.addEventListener("load", function()
49 { 53 {
50 updateSize(); 54 updateSize();
51 new MutationObserver(updateSize).observe(document, { 55 new MutationObserver(updateSize).observe(document, {
52 childList: true, attributes: true, 56 childList: true, attributes: true,
53 characterData: true, subtree: true 57 characterData: true, subtree: true
54 }); 58 });
55 }); 59 });
56 60
57 ext = { 61 ext = {
58 __proto__: ext, 62 __proto__: ext,
59 closePopup: function() 63 closePopup: function()
60 { 64 {
61 iframe.parentNode.hidePopup(); 65 panel.hidePopup();
62 }, 66 },
63 openBlockable: function() 67 openBlockable: function()
64 { 68 {
65 if (!UI.isBottombarOpen(topWindow)) 69 UI.toggleBottombar(topWindow);
66 { 70 ext.closePopup();
67 UI.toggleBottombar(topWindow);
68 ext.closePopup();
69 }
Thomas Greiner 2014/09/29 16:19:49 What about the "else" case? Please look at the cur
saroyanm 2014/10/02 07:53:56 I guess if you can clarify on the comment in conte
70 }, 71 },
71 showBlockable: function() 72 isBlockableOpen: function()
72 { 73 {
73 return !UI.isBottombarOpen(topWindow); 74 return UI.isBottombarOpen(topWindow);
Thomas Greiner 2014/09/29 16:19:49 This function should no longer be necessary if you
saroyanm 2014/10/02 07:53:56 Same as comment above.
74 }, 75 },
75 reportIssue: function() 76 reportIssue: function()
76 { 77 {
77 UI.openReportDialog(topWindow); 78 UI.openReportDialog(topWindow);
78 }, 79 },
79 showReportIssue: function() 80 showReportIssue: function()
80 { 81 {
81 var location = UI.getCurrentLocation(topWindow); 82 var location = UI.getCurrentLocation(topWindow);
82 return location && Policy.isBlockableScheme(location) && location.scheme ! = "mailto"; 83 return location && Policy.isBlockableScheme(location) && location.scheme ! = "mailto";
83 } 84 }
84 }; 85 };
85 })(); 86 })();
LEFTRIGHT

Powered by Google App Engine
This is Rietveld