From 2a6713072836a1e6895a635f478d4321844795cf Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Tue, 7 May 2013 11:38:08 -0700 Subject: [PATCH] Bug 867163 - Clear context actions when dismissing the appbar [r=sfoster] --- browser/metro/base/content/TopSites.js | 1 - browser/metro/base/content/appbar.js | 21 ++++++++++++++++++++- browser/metro/base/content/bookmarks.js | 7 ------- browser/metro/base/content/history.js | 1 - 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/browser/metro/base/content/TopSites.js b/browser/metro/base/content/TopSites.js index 70de14c17d07..7e8d8812e2a2 100644 --- a/browser/metro/base/content/TopSites.js +++ b/browser/metro/base/content/TopSites.js @@ -257,7 +257,6 @@ TopSitesView.prototype = { case "MozAppbarDismissing": // clean up when the context appbar is dismissed - we don't remember selections this._lastSelectedSites = null; - this._set.clearSelection(); } }, diff --git a/browser/metro/base/content/appbar.js b/browser/metro/base/content/appbar.js index 47b9baa2e331..ea4956488018 100644 --- a/browser/metro/base/content/appbar.js +++ b/browser/metro/base/content/appbar.js @@ -1,3 +1,8 @@ +/* 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/. */ +"use strict"; + var Appbar = { get appbar() { return document.getElementById('appbar'); }, get consoleButton() { return document.getElementById('console-button'); }, @@ -13,6 +18,7 @@ var Appbar = { init: function Appbar_init() { window.addEventListener('MozAppbarShowing', this, false); + window.addEventListener('MozAppbarDismissing', this, false); window.addEventListener('MozPrecisePointer', this, false); window.addEventListener('MozImprecisePointer', this, false); window.addEventListener('MozContextActionsChange', this, false); @@ -40,6 +46,13 @@ var Appbar = { this._updatePinButton(); this._updateStarButton(); break; + case 'MozAppbarDismissing': + if (this.activeTileset) { + this.activeTileset.clearSelection(); + } + this.clearContextualActions(); + this.activeTileset = null; + break; case 'MozPrecisePointer': case 'MozImprecisePointer': this._updateZoomButtons(); @@ -162,7 +175,8 @@ var Appbar = { } } }, - showContextualActions: function(aVerbs){ + + showContextualActions: function(aVerbs) { let doc = document; // button element id to action verb lookup let buttonsMap = new Map(); @@ -195,6 +209,11 @@ var Appbar = { } }); }, + + clearContextualActions: function() { + this.showContextualActions([]); + }, + _onTileSelectionChanged: function _onTileSelectionChanged(aEvent){ let activeTileset = aEvent.target; diff --git a/browser/metro/base/content/bookmarks.js b/browser/metro/base/content/bookmarks.js index 94baa762ed46..74a24b9013cd 100644 --- a/browser/metro/base/content/bookmarks.js +++ b/browser/metro/base/content/bookmarks.js @@ -354,14 +354,7 @@ BookmarksView.prototype = { for (let bookmarkId of this._toRemove) { this._bookmarkService.removeItem(bookmarkId); } - this._toRemove = null; - this._set.clearSelection(); - - // Clear context app bar - let event = document.createEvent("Events"); - event.initEvent("MozContextActionsChange", true, false); - this._set.dispatchEvent(event); } break; diff --git a/browser/metro/base/content/history.js b/browser/metro/base/content/history.js index a3c421b1d006..6cedee73768c 100644 --- a/browser/metro/base/content/history.js +++ b/browser/metro/base/content/history.js @@ -194,7 +194,6 @@ HistoryView.prototype = { this._set.dispatchEvent(event); this._toRemove = null; - this._set.clearSelection(); } break;