Bug 1735076 - Use ProgrammaticFocusFlags from nsXULCommandDispatcher. r=smaug
Relevant calls are here: https://searchfox.org/mozilla-central/rev/21a9b72545da06681db97c4b3a2a6be761f4aae5/toolkit/content/widgets/button.js#42-68 This makes sure to set the FLAG_BYKEY properly if needed, instead of passing down raw flags to nsFocusManager. Clean up a bit while at it. Let me know if you want a test for this, but we have tests for programmatic focus and :focus-visible already, so my gut feeling is that testing this particular XUL-specific change is not super-worth-it... Differential Revision: https://phabricator.services.mozilla.com/D133690
This commit is contained in:
@@ -3755,11 +3755,18 @@ nsresult HTMLInputElement::PostHandleEvent(EventChainPostVisitor& aVisitor) {
|
||||
!aVisitor.mEvent->AsFocusEvent()->mFromRaise &&
|
||||
SelectTextFieldOnFocus()) {
|
||||
if (Document* document = GetComposedDoc()) {
|
||||
uint32_t lastFocusMethod;
|
||||
fm->GetLastFocusMethod(document->GetWindow(), &lastFocusMethod);
|
||||
if (lastFocusMethod & (nsIFocusManager::FLAG_BYKEY |
|
||||
nsIFocusManager::FLAG_BYMOVEFOCUS) &&
|
||||
!(lastFocusMethod & nsIFocusManager::FLAG_BYJS)) {
|
||||
uint32_t lastFocusMethod =
|
||||
fm->GetLastFocusMethod(document->GetWindow());
|
||||
const bool shouldSelectAllOnFocus = [&] {
|
||||
if (lastFocusMethod & nsIFocusManager::FLAG_BYMOVEFOCUS) {
|
||||
return true;
|
||||
}
|
||||
if (lastFocusMethod & nsIFocusManager::FLAG_BYJS) {
|
||||
return false;
|
||||
}
|
||||
return bool(lastFocusMethod & nsIFocusManager::FLAG_BYKEY);
|
||||
}();
|
||||
if (shouldSelectAllOnFocus) {
|
||||
RefPtr<nsPresContext> presContext =
|
||||
GetPresContext(eForComposedDoc);
|
||||
DispatchSelectEvent(presContext);
|
||||
|
||||
Reference in New Issue
Block a user