Bug 599328 - Clicking a label shouldn't draw a focus ring if clicking the control wouldn't have. r=enndeakin

This commit is contained in:
Markus Stange
2015-06-23 08:20:04 -07:00
parent e4cfd6fe7b
commit b4489711cf
2 changed files with 42 additions and 24 deletions

View File

@@ -169,8 +169,14 @@ HTMLLabelElement::PostHandleEvent(EventChainPostVisitor& aVisitor)
// be selected only when focused via a key or when the navigation
// flag is used and we want to select the text on label clicks as
// well.
// If the label has been clicked by the user, we also want to
// pass FLAG_BYMOUSE so that we get correct focus ring behavior,
// but we don't want to pass FLAG_BYMOUSE if this click event was
// caused by the user pressing an accesskey.
nsCOMPtr<nsIDOMElement> elem = do_QueryInterface(content);
fm->SetFocus(elem, nsIFocusManager::FLAG_BYMOVEFOCUS);
bool byMouse = (mouseEvent->inputSource != nsIDOMMouseEvent::MOZ_SOURCE_KEYBOARD);
fm->SetFocus(elem, nsIFocusManager::FLAG_BYMOVEFOCUS |
(byMouse ? nsIFocusManager::FLAG_BYMOUSE : 0));
}
}
// Dispatch a new click event to |content|