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

Unified Diff: chrome/content/ui/ext/popup.js

Issue 5294633391226880: issue 1435 - Port popup.html from Chrome/Safari/Opera to Firefox (Closed)
Patch Set: Created Sept. 26, 2014, 12:48 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/content/ui/ext/popup.js
===================================================================
new file mode 100644
--- /dev/null
+++ b/chrome/content/ui/ext/popup.js
@@ -0,0 +1,85 @@
+/*
+ * This file is part of Adblock Plus <http://adblockplus.org/>,
+ * Copyright (C) 2006-2014 Eyeo GmbH
+ *
+ * Adblock Plus is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 3 as
+ * published by the Free Software Foundation.
+ *
+ * Adblock Plus is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+ */
+
+(function()
+{
+ var {UI} = require("ui");
+
+ var iframe = window.QueryInterface(Components.interfaces.nsIInterfaceRequestor)
+ .getInterface(Components.interfaces.nsIWebNavigation)
+ .QueryInterface(Components.interfaces.nsIDocShell)
+ .chromeEventHandler;
+ var topWindow = iframe.ownerDocument.defaultView;
+
+ // Firefox doesn't adjust the size of the popup automatically to the size
+ // of its content, like when the ad counter is expanded/collapsed. So we add
+ // event listeners 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.
+ 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.
+ var resizingScheduled = false;
+
+ function updateSize()
+ {
+ if (mayResize && !resizingScheduled)
+ {
+ setTimeout(function()
+ {
+ iframe.parentNode.sizeTo(document.body.scrollWidth, document.body.offsetHeight + 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
+ resizingScheduled = false;
+ }, 0);
+
+ resizingScheduled = true;
+ }
+ }
+
+ window.addEventListener("load", function()
+ {
+ updateSize();
+ new MutationObserver(updateSize).observe(document, {
+ childList: true, attributes: true,
+ characterData: true, subtree: true
+ });
+ });
+
+ ext = {
+ __proto__: ext,
+ closePopup: function()
+ {
+ iframe.parentNode.hidePopup();
+ },
+ openBlockable: function()
+ {
+ if (!UI.isBottombarOpen(topWindow))
+ {
+ UI.toggleBottombar(topWindow);
+ ext.closePopup();
+ }
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
+ },
+ showBlockable: function()
+ {
+ 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.
+ },
+ reportIssue: function()
+ {
+ UI.openReportDialog(topWindow);
+ },
+ showReportIssue: function()
+ {
+ var location = UI.getCurrentLocation(topWindow);
+ return location && Policy.isBlockableScheme(location) && location.scheme != "mailto";
+ }
+ };
+})();

Powered by Google App Engine
This is Rietveld