Bug 1154183 part.3 Clean up some variable names in nsXBLWindowKeyHandler::WalkHandlersAndExecute() r=smaug

MozReview-Commit-ID: 17fCUBwFf92
This commit is contained in:
Masayuki Nakano 2016-03-18 11:25:08 +09:00
Родитель 7bcaf602d0
Коммит 77166dd790
1 изменённых файлов: 36 добавлений и 35 удалений

Просмотреть файл

@ -573,24 +573,23 @@ bool
nsXBLWindowKeyHandler::WalkHandlersAndExecute(
nsIDOMKeyEvent* aKeyEvent,
nsIAtom* aEventType,
nsXBLPrototypeHandler* aHandler,
nsXBLPrototypeHandler* aFirstHandler,
uint32_t aCharCode,
const IgnoreModifierState& aIgnoreModifierState,
bool aExecute,
bool* aOutReservedForChrome)
{
nsresult rv;
// Try all of the handlers until we find one that matches the event.
for (nsXBLPrototypeHandler *currHandler = aHandler; currHandler;
currHandler = currHandler->GetNextHandler()) {
for (nsXBLPrototypeHandler* handler = aFirstHandler;
handler;
handler = handler->GetNextHandler()) {
bool stopped = aKeyEvent->AsEvent()->IsDispatchStopped();
if (stopped) {
// The event is finished, don't execute any more handlers
return false;
}
if (!EventMatched(currHandler, aEventType, aKeyEvent,
if (!EventMatched(handler, aEventType, aKeyEvent,
aCharCode, aIgnoreModifierState)) {
continue; // try the next one
}
@ -598,67 +597,69 @@ nsXBLWindowKeyHandler::WalkHandlersAndExecute(
// Before executing this handler, check that it's not disabled,
// and that it has something to do (oncommand of the <key> or its
// <command> is non-empty).
nsCOMPtr<nsIContent> elt = currHandler->GetHandlerElement();
nsCOMPtr<Element> commandElt;
nsCOMPtr<nsIContent> keyContent = handler->GetHandlerElement();
nsCOMPtr<Element> commandElement;
// See if we're in a XUL doc.
nsCOMPtr<Element> el = GetElement();
if (el && elt) {
nsCOMPtr<Element> chromeHandlerElement = GetElement();
if (chromeHandlerElement && keyContent) {
// We are. Obtain our command attribute.
nsAutoString command;
elt->GetAttr(kNameSpaceID_None, nsGkAtoms::command, command);
keyContent->GetAttr(kNameSpaceID_None, nsGkAtoms::command, command);
if (!command.IsEmpty()) {
// Locate the command element in question. Note that we
// know "elt" is in a doc if we're dealing with it here.
NS_ASSERTION(elt->IsInDoc(), "elt must be in document");
nsIDocument *doc = elt->GetCurrentDoc();
if (doc)
commandElt = do_QueryInterface(doc->GetElementById(command));
// know "keyContent" is in a doc if we're dealing with it here.
NS_ASSERTION(keyContent->IsInDoc(),
"the key element must be in document");
nsIDocument* doc = keyContent->GetCurrentDoc();
if (doc) {
commandElement = do_QueryInterface(doc->GetElementById(command));
}
if (!commandElt) {
NS_ERROR("A XUL <key> is observing a command that doesn't exist. Unable to execute key binding!");
if (!commandElement) {
NS_ERROR("A XUL <key> is observing a command that doesn't exist. "
"Unable to execute key binding!");
continue;
}
}
}
if (!commandElt) {
commandElt = do_QueryInterface(elt);
if (!commandElement) {
commandElement = do_QueryInterface(keyContent);
}
if (commandElt) {
if (commandElement) {
nsAutoString value;
commandElt->GetAttribute(NS_LITERAL_STRING("disabled"), value);
commandElement->GetAttribute(NS_LITERAL_STRING("disabled"), value);
if (value.EqualsLiteral("true")) {
continue; // this handler is disabled, try the next one
}
// Check that there is an oncommand handler
commandElt->GetAttribute(NS_LITERAL_STRING("oncommand"), value);
commandElement->GetAttribute(NS_LITERAL_STRING("oncommand"), value);
if (value.IsEmpty()) {
continue; // nothing to do
}
if (aOutReservedForChrome) {
// The caller wants to know if this is a reserved command
commandElt->GetAttribute(NS_LITERAL_STRING("reserved"), value);
commandElement->GetAttribute(NS_LITERAL_STRING("reserved"), value);
*aOutReservedForChrome = value.EqualsLiteral("true");
}
}
nsCOMPtr<EventTarget> piTarget;
nsCOMPtr<Element> element = GetElement();
if (element) {
piTarget = commandElt;
} else {
piTarget = mTarget;
}
if (!aExecute) {
return true;
}
rv = currHandler->ExecuteHandler(piTarget, aKeyEvent->AsEvent());
nsCOMPtr<EventTarget> target;
if (chromeHandlerElement) {
target = commandElement;
} else {
target = mTarget;
}
nsresult rv = handler->ExecuteHandler(target, aKeyEvent->AsEvent());
if (NS_SUCCEEDED(rv)) {
return true;
}
@ -675,8 +676,8 @@ nsXBLWindowKeyHandler::WalkHandlersAndExecute(
if (keyEvent && keyEvent->IsOS()) {
IgnoreModifierState ignoreModifierState(aIgnoreModifierState);
ignoreModifierState.mOS = true;
return WalkHandlersAndExecute(aKeyEvent, aEventType, aHandler, aCharCode,
ignoreModifierState, aExecute);
return WalkHandlersAndExecute(aKeyEvent, aEventType, aFirstHandler,
aCharCode, ignoreModifierState, aExecute);
}
}
#endif