This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch tor-browser-91.13.0esr-11.5-1 in repository tor-browser.
commit 2885a2cf84eecb9bedf8a7c2984f67a787bbd9f6 Author: Nika Layzell nika@thelayzells.com AuthorDate: Fri Oct 14 21:32:17 2022 +0000
Bug 1793676 - Dynamically generate DOM code names for some continuous runs of codes, r=mccr8, a=dmeehan
Differential Revision: https://phabricator.services.mozilla.com/D159400 --- widget/WidgetEventImpl.cpp | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+)
diff --git a/widget/WidgetEventImpl.cpp b/widget/WidgetEventImpl.cpp index ee3f8fb4104d..d6c47da1b578 100644 --- a/widget/WidgetEventImpl.cpp +++ b/widget/WidgetEventImpl.cpp @@ -1193,6 +1193,37 @@ void WidgetKeyboardEvent::GetDOMCodeName(CodeNameIndex aCodeNameIndex, MOZ_RELEASE_ASSERT( static_cast<size_t>(aCodeNameIndex) < ArrayLength(kCodeNames), "Illegal physical code enumeration value"); + + // Generate some continuous runs of codes, rather than looking them up. + if (aCodeNameIndex >= CODE_NAME_INDEX_KeyA && + aCodeNameIndex <= CODE_NAME_INDEX_KeyZ) { + uint32_t index = aCodeNameIndex - CODE_NAME_INDEX_KeyA; + aCodeName.AssignLiteral(u"Key"); + aCodeName.Append(u'A' + index); + return; + } + if (aCodeNameIndex >= CODE_NAME_INDEX_Digit0 && + aCodeNameIndex <= CODE_NAME_INDEX_Digit9) { + uint32_t index = aCodeNameIndex - CODE_NAME_INDEX_Digit0; + aCodeName.AssignLiteral(u"Digit"); + aCodeName.AppendInt(index); + return; + } + if (aCodeNameIndex >= CODE_NAME_INDEX_Numpad0 && + aCodeNameIndex <= CODE_NAME_INDEX_Numpad9) { + uint32_t index = aCodeNameIndex - CODE_NAME_INDEX_Numpad0; + aCodeName.AssignLiteral(u"Numpad"); + aCodeName.AppendInt(index); + return; + } + if (aCodeNameIndex >= CODE_NAME_INDEX_F1 && + aCodeNameIndex <= CODE_NAME_INDEX_F24) { + uint32_t index = aCodeNameIndex - CODE_NAME_INDEX_F1; + aCodeName.Assign(u'F'); + aCodeName.AppendInt(index + 1); + return; + } + aCodeName = kCodeNames[aCodeNameIndex]; }