From 8880224f6bef6a2d9a46ebc7b2657c1eef473095 Mon Sep 17 00:00:00 2001 From: Jared Wein Date: Tue, 8 Aug 2017 11:56:49 -0400 Subject: [PATCH] Bug 1387077 - Reimplement Pocket animation in the Page Action area. r=adw MozReview-Commit-ID: 5pJ96un8W5t --HG-- extra : rebase_source : bef396788013f8ed60d72b01bf59e34e01d36209 --- browser/base/content/browser-pageActions.js | 33 ++- browser/base/content/browser.css | 2 +- browser/base/content/browser.xul | 1 + browser/extensions/pocket/bootstrap.js | 130 ++++++++- browser/extensions/pocket/content/main.js | 3 + .../pocket/skin/shared/pocket-animation.svg | 260 ++++++++++++------ .../pocket/skin/shared/pocket-list.svg | 7 - .../extensions/pocket/skin/shared/pocket.css | 39 ++- .../extensions/pocket/skin/shared/pocket.svg | 4 +- browser/modules/PageActions.jsm | 70 +++++ 10 files changed, 429 insertions(+), 120 deletions(-) delete mode 100644 browser/extensions/pocket/skin/shared/pocket-list.svg diff --git a/browser/base/content/browser-pageActions.js b/browser/base/content/browser-pageActions.js index 606e9e793903..98646e07d51a 100644 --- a/browser/base/content/browser-pageActions.js +++ b/browser/base/content/browser-pageActions.js @@ -69,6 +69,7 @@ var BrowserPageActions = { this._appendPanelSeparator(action); return; } + action.onBeforePlacedInWindow(window); this.placeActionInPanel(action, panelInsertBeforeID); this.placeActionInUrlbar(action, urlbarInsertBeforeID); }, @@ -176,7 +177,7 @@ var BrowserPageActions = { let panelNode = document.getElementById(panelNodeID); if (panelNode) { panelNode.hidePopup(); - return; + return null; } panelNode = document.createElement("panel"); @@ -205,9 +206,18 @@ var BrowserPageActions = { let popupSet = document.getElementById("mainPopupSet"); popupSet.appendChild(panelNode); panelNode.addEventListener("popuphidden", () => { + if (iframeNode) { + action.onIframeHidden(iframeNode, panelNode); + } panelNode.remove(); }, { once: true }); + panelNode.addEventListener("popuphiding", () => { + if (iframeNode) { + action.onIframeHiding(iframeNode, panelNode); + } + }, { once: true }); + if (panelViewNode) { action.subview.onPlaced(panelViewNode); action.subview.onShowing(panelViewNode); @@ -216,13 +226,22 @@ var BrowserPageActions = { this.panelNode.hidePopup(); let urlbarNodeID = this._urlbarButtonNodeIDForActionID(action.id); - let anchorNode = - document.getElementById(urlbarNodeID) || this.mainButtonNode; + let urlbarNode = document.getElementById(urlbarNodeID); + let anchorNode; + if (urlbarNode && !urlbarNode.hidden) { + anchorNode = action.anchorIDOverride ? + document.getElementById(action.anchorIDOverride) : + urlbarNode; + } else { + anchorNode = this.mainButtonNode; + } panelNode.openPopup(anchorNode, "bottomcenter topright"); if (iframeNode) { action.onIframeShown(iframeNode, panelNode); } + + return panelNode; }, get _tempPanelID() { @@ -411,6 +430,14 @@ var BrowserPageActions = { } }, + doCommandForAction(action) { + if (action.subview || action.wantsIframe) { + this._toggleTempPanelForAction(action); + return; + } + action.onCommand(); + }, + /** * Returns the action for a node. * diff --git a/browser/base/content/browser.css b/browser/base/content/browser.css index 60d33d6b673d..8c5ab7532006 100644 --- a/browser/base/content/browser.css +++ b/browser/base/content/browser.css @@ -664,7 +664,7 @@ html|input.urlbar-input[textoverflow]:not([focused]) { } #urlbar[pageproxystate="invalid"] > #urlbar-icons > .urlbar-icon, -#urlbar[pageproxystate="invalid"] > #urlbar-icons > #star-button-box > .urlbar-icon, +#urlbar[pageproxystate="invalid"] > #urlbar-icons > .urlbar-icon-wrapper > .urlbar-icon, .urlbar-go-button[pageproxystate="valid"], .urlbar-go-button:not([parentfocused="true"]), #urlbar[pageproxystate="invalid"] > #identity-box > #blocked-permissions-container, diff --git a/browser/base/content/browser.xul b/browser/base/content/browser.xul index 39ad3423ac77..4660e5640457 100644 --- a/browser/base/content/browser.xul +++ b/browser/base/content/browser.xul @@ -899,6 +899,7 @@ onclick="BrowserPageActions.mainButtonClicked(event);"/>