зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1595082 - Ensure every Touch Bar input is updated at least once. r=mikedeboer,spohl
Differential Revision: https://phabricator.services.mozilla.com/D53176 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
8d974e5d12
Коммит
bde6fc32f1
|
@ -296,6 +296,13 @@ class TouchBarHelper {
|
|||
layoutItems.appendElement(input);
|
||||
}
|
||||
|
||||
// Every input must be updated at least once so that all assets (titles,
|
||||
// icons) are loaded. We keep track of which inputs haven't updated and
|
||||
// run an update on them after the first location change.
|
||||
this._inputsNotUpdated = new Set(Object.keys(kBuiltInInputs));
|
||||
// This is a temporary workaround until bug 1596723 is resolved.
|
||||
this._inputsNotUpdated.delete("SearchPopover");
|
||||
|
||||
return layoutItems;
|
||||
}
|
||||
|
||||
|
@ -356,6 +363,7 @@ class TouchBarHelper {
|
|||
kBuiltInInputs[inputName].localTitle = result; // Cache result.
|
||||
// Checking TouchBarHelper.window since this callback can fire after all windows are closed.
|
||||
if (TouchBarHelper.window) {
|
||||
this._inputsNotUpdated.delete(inputName);
|
||||
gTouchBarUpdater.updateTouchBarInputs(TouchBarHelper.baseWindow, [
|
||||
item,
|
||||
]);
|
||||
|
@ -367,22 +375,21 @@ class TouchBarHelper {
|
|||
|
||||
/**
|
||||
* Fetches a specific Touch Bar Input by name and updates it on the Touch Bar.
|
||||
* @param {string} inputName
|
||||
* A key to a value in the kBuiltInInputs object in this file.
|
||||
* @param {...*} [otherInputs] (optional)
|
||||
* Additional keys to values in the kBuiltInInputs object in this file.
|
||||
* @param {...*} inputNames
|
||||
* A key/keys to a value/values in the kBuiltInInputs object in this file.
|
||||
*/
|
||||
_updateTouchBarInputs(...inputNames) {
|
||||
if (!TouchBarHelper.window) {
|
||||
if (!TouchBarHelper.window || !inputNames.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
let inputs = [];
|
||||
for (let inputName of inputNames) {
|
||||
for (let inputName of new Set(inputNames)) {
|
||||
let input = this.getTouchBarInput(inputName);
|
||||
if (!input) {
|
||||
continue;
|
||||
}
|
||||
this._inputsNotUpdated.delete(inputName);
|
||||
inputs.push(input);
|
||||
}
|
||||
|
||||
|
@ -419,7 +426,7 @@ class TouchBarHelper {
|
|||
.canGoBack;
|
||||
kBuiltInInputs.Forward.disabled = !TouchBarHelper.window.gBrowser
|
||||
.canGoForward;
|
||||
this._updateTouchBarInputs("ReaderView", "Back", "Forward");
|
||||
this._updateTouchBarInputs("ReaderView", "Back", "Forward", ...this._inputsNotUpdated);
|
||||
break;
|
||||
case "bookmark-icon-updated":
|
||||
data == "starred"
|
||||
|
|
|
@ -44,6 +44,14 @@ nsTouchBarUpdater::UpdateTouchBarInputs(nsIBaseWindow* aWindow,
|
|||
continue;
|
||||
}
|
||||
|
||||
NSTouchBarItemIdentifier newIdentifier = [TouchBarInput nativeIdentifierWithXPCOM:input];
|
||||
// We don't support updating the Share scrubber since it's a special
|
||||
// Apple-made component that behaves differently from the other inputs.
|
||||
if ([newIdentifier isEqualToString:[TouchBarInput nativeIdentifierWithType:@"scrubber"
|
||||
withKey:@"share"]]) {
|
||||
continue;
|
||||
}
|
||||
|
||||
TouchBarInput* convertedInput = [[TouchBarInput alloc] initWithXPCOM:input];
|
||||
[(nsTouchBar*)cocoaWin.touchBar updateItem:convertedInput];
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче