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

Unified Diff: ext/background.js

Issue 29894584: Issue 6948 - Begun simplifying the "block element" context menu logic (Closed)
Patch Set: Created Sept. 28, 2018, 3:21 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
« no previous file with comments | « no previous file | lib/filterComposer.js » ('j') | lib/filterComposer.js » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ext/background.js
diff --git a/ext/background.js b/ext/background.js
index c8c68278ca7929ded4e985c2557d194c216364df..341fc1d2f4f729cc7b58744507d2369ef41cd8aa 100644
--- a/ext/background.js
+++ b/ext/background.js
@@ -75,7 +75,6 @@
this._url = tab.url && new URL(tab.url);
this.browserAction = new BrowserAction(tab.id);
- this.contextMenus = new ContextMenus(this);
};
Page.prototype = {
get url()
@@ -423,90 +422,6 @@
};
- /* Context menus */
-
- let contextMenuItems = new ext.PageMap();
- let contextMenuUpdating = false;
-
- let updateContextMenu = () =>
- {
- // Firefox for Android does not support context menus.
- // https://bugzilla.mozilla.org/show_bug.cgi?id=1269062
- if (!("contextMenus" in browser) || contextMenuUpdating)
- return;
-
- contextMenuUpdating = true;
-
- browser.tabs.query({active: true, lastFocusedWindow: true}, tabs =>
- {
- browser.contextMenus.removeAll(() =>
- {
- contextMenuUpdating = false;
-
- if (tabs.length == 0)
- return;
-
- let items = contextMenuItems.get({id: tabs[0].id});
-
- if (!items)
- return;
-
- items.forEach(item =>
- {
- browser.contextMenus.create({
- title: item.title,
- contexts: item.contexts,
- onclick(info, tab)
- {
- item.onclick(new Page(tab));
- }
- });
- });
- });
- });
- };
-
- let ContextMenus = function(page)
- {
- this._page = page;
- };
- ContextMenus.prototype = {
- create(item)
- {
- let items = contextMenuItems.get(this._page);
- if (!items)
- contextMenuItems.set(this._page, items = []);
-
- items.push(item);
- updateContextMenu();
- },
- remove(item)
- {
- let items = contextMenuItems.get(this._page);
- if (items)
- {
- let index = items.indexOf(item);
- if (index != -1)
- {
- items.splice(index, 1);
- updateContextMenu();
- }
- }
- }
- };
-
- browser.tabs.onActivated.addListener(updateContextMenu);
-
- if ("windows" in browser)
- {
- browser.windows.onFocusChanged.addListener(windowId =>
- {
- if (windowId != browser.windows.WINDOW_ID_NONE)
- updateContextMenu();
- });
- }
-
-
/* Web requests */
let framesOfTabs = new Map();
« no previous file with comments | « no previous file | lib/filterComposer.js » ('j') | lib/filterComposer.js » ('J')

Powered by Google App Engine
This is Rietveld