Skip to content
This repository has been archived by the owner on Dec 3, 2020. It is now read-only.

Commit

Permalink
Detect overflow for explicit (un)pinning of toolbar button to overflo…
Browse files Browse the repository at this point in the history
…w menu

Detect toolbar button in fixed overflow menu:
- Add a call to `getPlacementOfWidget`
- This check covers the case when the toolbar button is explicitly pinned/unpinned to the Overflow menu by the user.

Context:
- The original patch only detected the toolbar button in the non-fixed overflow menu, which only covered the case when the toolbar button was moved into and out of the overflow menu by a window resize.
- Per jaws, the fixed versus non-fixed Overflow menus live in two different areas of the browser chrome, where "the non-fixed overflow panel is the area that is basically an extension of the navigation-toolbar."
- With both checks together, we cover both of the cases in which the toolbar button can be moved into and out of the Overflow menu.
  • Loading branch information
biancadanforth committed Nov 21, 2018
1 parent a719bba commit b6c508a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 7 deletions.
14 changes: 9 additions & 5 deletions src/experiment_apis/customizableUI/api.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
/* global ChromeUtils ExtensionAPI ExtensionCommon */
/* global ChromeUtils ExtensionAPI */

this.customizableUI = class extends ExtensionAPI {
getAPI(context) {
const {Services} = ChromeUtils.import('resource://gre/modules/Services.jsm');
ChromeUtils.import('resource://gre/modules/ExtensionCommon.jsm');
const {CustomizableUI} = ChromeUtils.import('resource:///modules/CustomizableUI.jsm');
const {ExtensionCommon} = ChromeUtils.import('resource://gre/modules/ExtensionCommon.jsm');
const {EventManager} = ExtensionCommon;
const {CustomizableUI} = ChromeUtils.import('resource:///modules/CustomizableUI.jsm', {});
const {Services} = ChromeUtils.import('resource://gre/modules/Services.jsm');
return {
customizableUI: {
onWidgetRemoved: new EventManager(
Expand All @@ -27,8 +27,12 @@ this.customizableUI = class extends ExtensionAPI {
},
).api(),
async isWidgetInOverflow(widgetId) {
const {area} = CustomizableUI.getPlacementOfWidget(widgetId);
const browserWindow = Services.wm.getMostRecentWindow('navigator:browser');
return CustomizableUI.getWidget(widgetId).forWindow(browserWindow).overflowed;
// First check is for the non-fixed overflow menu (e.g. widget moved by resizing window)
// Second is for fixed overflow menu (e.g. widget moved by (un)pinning button to overflow)
return (CustomizableUI.getWidget(widgetId).forWindow(browserWindow).overflowed
|| area === 'widget-overflow-fixed-list');
},
},
};
Expand Down
4 changes: 2 additions & 2 deletions src/experiment_apis/customizableUI/schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{
"name": "onWidgetRemoved",
"type": "function",
"description": "Fired when a widget is removed from the browser chrome",
"description": "Fired when a widget is removed from the browser chrome.",
"parameters": [
{
"name": "widgetId",
Expand All @@ -19,7 +19,7 @@
{
"name": "isWidgetInOverflow",
"type": "function",
"description": "Returns a boolean for whether or not the provided widget in the provided window is in the overflow menu or not.",
"description": "Determine whether or not a widget is in the overflow menu.",
"async": true,
"parameters": [
{
Expand Down

0 comments on commit b6c508a

Please sign in to comment.