/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* vim: set ts=8 sts=2 et sw=2 tw=80: */ /* 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/. */
if (commandObservers) { // XXX Should we worry about observers removing themselves from Observe()?
int32_t i, numItems = commandObservers->Length(); for (i = 0; i < numItems; ++i) {
nsCOMPtr<nsIObserver> observer = commandObservers->ElementAt(i); // should we get the command state to pass here? This might be expensive.
observer->Observe(NS_ISUPPORTS_CAST(nsICommandManager*, this),
aCommandName, u"command_status_changed");
}
}
}
// XXX todo: handle special cases of aCommandToObserve being null, or empty
// for each command in the table, we make a list of observers for that command auto* const commandObservers =
mObserversTable.GetOrInsertNew(aCommandToObserve);
// need to check that this command observer hasn't already been registered
int32_t existingIndex = commandObservers->IndexOf(aCommandObserver); if (existingIndex == -1) {
commandObservers->AppendElement(aCommandObserver);
} else {
NS_WARNING("Registering command observer twice on the same command");
}
// check if we're in content or chrome // if we're not chrome we must have a target window or we bail if (!nsContentUtils::LegacyIsCallerChromeOrNativeCode()) { if (!aTargetWindow) { return rv;
}
// if a target window is specified, it must be the window we expect if (aTargetWindow != mWindow) { return NS_ERROR_FAILURE;
}
}
if (auto* targetWindow = nsPIDOMWindowOuter::From(aTargetWindow)) { // get the controller for this particular window
nsCOMPtr<nsIControllers> controllers;
rv = targetWindow->GetControllers(getter_AddRefs(controllers)); if (NS_FAILED(rv)) { return rv;
} if (!controllers) { return NS_ERROR_FAILURE;
}
// dispatch the command return controllers->GetControllerForCommand(aCommand, aResult);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung ist noch experimentell.