Skip to content

Commit

Permalink
Backed out 2 changesets (bug 1266437, bug 1232918) for causing mochit…
Browse files Browse the repository at this point in the history
…est failures in test_autoplay_policy_key_blacklist.html CLOSED TREE

Backed out changeset 33e3c6593d4b (bug 1232918)
Backed out changeset 1b56e99dd221 (bug 1266437)
  • Loading branch information
Cristian Tuns committed Aug 4, 2023
1 parent 4286f52 commit f5572b4
Show file tree
Hide file tree
Showing 68 changed files with 721 additions and 506 deletions.
2 changes: 2 additions & 0 deletions accessible/basetypes/Accessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,8 @@ uint32_t KeyBinding::AccelModifier() {
return kControl;
case MODIFIER_META:
return kMeta;
case MODIFIER_OS:
return kOS;
default:
MOZ_CRASH("Handle the new result of WidgetInputEvent::AccelModifier()");
return 0;
Expand Down
1 change: 1 addition & 0 deletions accessible/basetypes/Accessible.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,7 @@ class KeyBinding {
static const uint32_t kControl = 2;
static const uint32_t kAlt = 4;
static const uint32_t kMeta = 8;
static const uint32_t kOS = 16;

static uint32_t AccelModifier();

Expand Down
5 changes: 4 additions & 1 deletion accessible/xul/XULMenuAccessible.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,9 +167,11 @@ KeyBinding XULMenuitemAccessible::AccessKey() const {
modifierKey = KeyBinding::kAlt;
break;
case dom::KeyboardEvent_Binding::DOM_VK_META:
case dom::KeyboardEvent_Binding::DOM_VK_WIN:
modifierKey = KeyBinding::kMeta;
break;
case dom::KeyboardEvent_Binding::DOM_VK_WIN:
modifierKey = KeyBinding::kOS;
break;
}
}
}
Expand Down Expand Up @@ -208,6 +210,7 @@ KeyBinding XULMenuitemAccessible::KeyboardShortcut() const {
if (modifiersStr.Find(u"shift") != -1) modifierMask |= KeyBinding::kShift;
if (modifiersStr.Find(u"alt") != -1) modifierMask |= KeyBinding::kAlt;
if (modifiersStr.Find(u"meta") != -1) modifierMask |= KeyBinding::kMeta;
if (modifiersStr.Find(u"os") != -1) modifierMask |= KeyBinding::kOS;
if (modifiersStr.Find(u"control") != -1) modifierMask |= KeyBinding::kControl;
if (modifiersStr.Find(u"accel") != -1) {
modifierMask |= KeyBinding::AccelModifier();
Expand Down
2 changes: 1 addition & 1 deletion browser/app/profile/firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ pref("browser.history_swipe_animation.disabled", false);
pref("mousewheel.with_alt.action", 2);
#endif

pref("mousewheel.with_meta.action", 1);
pref("mousewheel.with_win.action", 1);

pref("browser.xul.error_pages.expert_bad_cert", false);
pref("browser.xul.error_pages.show_safe_browsing_details_on_load", false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,9 +163,8 @@ const TEST_CASES_EN = [
expectedKeyEvent: SHOULD_DELIVER_KEYDOWN,
result: {
key: "Meta",
code: "MetaLeft",
code: "OSLeft",
charCode: 0,
// Don't let web apps know pressing Command key on macOS
keyCode: KeyboardEvent.DOM_VK_WIN,
location: KeyboardEvent.DOM_KEY_LOCATION_LEFT,
altKey: false,
Expand All @@ -183,9 +182,40 @@ const TEST_CASES_EN = [
expectedKeyEvent: SHOULD_DELIVER_KEYDOWN,
result: {
key: "Meta",
code: "MetaRight",
code: "OSRight",
charCode: 0,
keyCode: KeyboardEvent.DOM_VK_WIN,
location: KeyboardEvent.DOM_KEY_LOCATION_RIGHT,
altKey: false,
shiftKey: false,
ctrlKey: false,
altGraphKey: false,
},
},
{
key: "KEY_OS",
modifiers: { location: KeyboardEvent.DOM_KEY_LOCATION_LEFT, osKey: true },
expectedKeyEvent: SHOULD_DELIVER_KEYDOWN,
result: {
key: "OS",
code: "OSLeft",
charCode: 0,
keyCode: KeyboardEvent.DOM_VK_WIN,
location: KeyboardEvent.DOM_KEY_LOCATION_LEFT,
altKey: false,
shiftKey: false,
ctrlKey: false,
altGraphKey: false,
},
},
{
key: "KEY_OS",
modifiers: { location: KeyboardEvent.DOM_KEY_LOCATION_RIGHT, osKey: true },
expectedKeyEvent: SHOULD_DELIVER_KEYDOWN,
result: {
key: "OS",
code: "OSRight",
charCode: 0,
// Don't let web apps know pressing Command key on macOS
keyCode: KeyboardEvent.DOM_VK_WIN,
location: KeyboardEvent.DOM_KEY_LOCATION_RIGHT,
altKey: false,
Expand Down
2 changes: 2 additions & 0 deletions dom/base/FuzzingFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ static const ModifierKey kModifierKeys[] = {
ModifierKey(MODIFIER_CONTROL, KEY_NAME_INDEX_Control, false),
ModifierKey(MODIFIER_FN, KEY_NAME_INDEX_Fn, false),
ModifierKey(MODIFIER_META, KEY_NAME_INDEX_Meta, false),
ModifierKey(MODIFIER_OS, KEY_NAME_INDEX_OS, false),
ModifierKey(MODIFIER_SHIFT, KEY_NAME_INDEX_Shift, false),
ModifierKey(MODIFIER_SYMBOL, KEY_NAME_INDEX_Symbol, false),
ModifierKey(MODIFIER_CAPSLOCK, KEY_NAME_INDEX_CapsLock, true),
Expand Down Expand Up @@ -240,6 +241,7 @@ void FuzzingFunctions::SynthesizeKeyboardEvents(
SET_MODIFIER(ModifierFn, MODIFIER_FN)
SET_MODIFIER(ModifierFnLock, MODIFIER_FNLOCK)
SET_MODIFIER(ModifierNumLock, MODIFIER_NUMLOCK)
SET_MODIFIER(ModifierOS, MODIFIER_OS)
SET_MODIFIER(ModifierScrollLock, MODIFIER_SCROLLLOCK)
SET_MODIFIER(ModifierSymbol, MODIFIER_SYMBOL)
SET_MODIFIER(ModifierSymbolLock, MODIFIER_SYMBOLLOCK)
Expand Down
32 changes: 23 additions & 9 deletions dom/base/nsContentUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -450,7 +450,8 @@ bool nsContentUtils::sIsHandlingKeyBoardEvent = false;

nsString* nsContentUtils::sShiftText = nullptr;
nsString* nsContentUtils::sControlText = nullptr;
nsString* nsContentUtils::sCommandOrWinText = nullptr;
nsString* nsContentUtils::sMetaText = nullptr;
nsString* nsContentUtils::sOSText = nullptr;
nsString* nsContentUtils::sAltText = nullptr;
nsString* nsContentUtils::sModifierSeparator = nullptr;

Expand Down Expand Up @@ -881,11 +882,16 @@ void nsContentUtils::GetControlText(nsAString& text) {
text.Assign(*sControlText);
}

void nsContentUtils::GetCommandOrWinText(nsAString& text) {
if (!sCommandOrWinText) {
void nsContentUtils::GetMetaText(nsAString& text) {
if (!sMetaText) InitializeModifierStrings();
text.Assign(*sMetaText);
}

void nsContentUtils::GetOSText(nsAString& text) {
if (!sOSText) {
InitializeModifierStrings();
}
text.Assign(*sCommandOrWinText);
text.Assign(*sOSText);
}

void nsContentUtils::GetAltText(nsAString& text) {
Expand Down Expand Up @@ -914,22 +920,25 @@ void nsContentUtils::InitializeModifierStrings() {
NS_SUCCEEDED(rv) && bundle,
"chrome://global/locale/platformKeys.properties could not be loaded");
nsAutoString shiftModifier;
nsAutoString commandOrWinModifier;
nsAutoString metaModifier;
nsAutoString osModifier;
nsAutoString altModifier;
nsAutoString controlModifier;
nsAutoString modifierSeparator;
if (bundle) {
// macs use symbols for each modifier key, so fetch each from the bundle,
// which also covers i18n
bundle->GetStringFromName("VK_SHIFT", shiftModifier);
bundle->GetStringFromName("VK_COMMAND_OR_WIN", commandOrWinModifier);
bundle->GetStringFromName("VK_META", metaModifier);
bundle->GetStringFromName("VK_WIN", osModifier);
bundle->GetStringFromName("VK_ALT", altModifier);
bundle->GetStringFromName("VK_CONTROL", controlModifier);
bundle->GetStringFromName("MODIFIER_SEPARATOR", modifierSeparator);
}
// if any of these don't exist, we get an empty string
sShiftText = new nsString(shiftModifier);
sCommandOrWinText = new nsString(commandOrWinModifier);
sMetaText = new nsString(metaModifier);
sOSText = new nsString(osModifier);
sAltText = new nsString(altModifier);
sControlText = new nsString(controlModifier);
sModifierSeparator = new nsString(modifierSeparator);
Expand Down Expand Up @@ -1926,8 +1935,10 @@ void nsContentUtils::Shutdown() {
sShiftText = nullptr;
delete sControlText;
sControlText = nullptr;
delete sCommandOrWinText;
sCommandOrWinText = nullptr;
delete sMetaText;
sMetaText = nullptr;
delete sOSText;
sOSText = nullptr;
delete sAltText;
sAltText = nullptr;
delete sModifierSeparator;
Expand Down Expand Up @@ -8481,6 +8492,9 @@ Modifiers nsContentUtils::GetWidgetModifiers(int32_t aModifiers) {
if (aModifiers & nsIDOMWindowUtils::MODIFIER_SYMBOLLOCK) {
result |= mozilla::MODIFIER_SYMBOLLOCK;
}
if (aModifiers & nsIDOMWindowUtils::MODIFIER_OS) {
result |= mozilla::MODIFIER_OS;
}
return result;
}

Expand Down
6 changes: 4 additions & 2 deletions dom/base/nsContentUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -2474,7 +2474,8 @@ class nsContentUtils {

static void GetShiftText(nsAString& text);
static void GetControlText(nsAString& text);
static void GetCommandOrWinText(nsAString& text);
static void GetMetaText(nsAString& text);
static void GetOSText(nsAString& text);
static void GetAltText(nsAString& text);
static void GetModifierSeparatorText(nsAString& text);

Expand Down Expand Up @@ -3566,7 +3567,8 @@ class nsContentUtils {

static nsString* sShiftText;
static nsString* sControlText;
static nsString* sCommandOrWinText;
static nsString* sMetaText;
static nsString* sOSText;
static nsString* sAltText;
static nsString* sModifierSeparator;

Expand Down
15 changes: 8 additions & 7 deletions dom/base/test/chrome/window_nsITextInputProcessor.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -2814,8 +2814,8 @@ function runKeyTests()
{ code: "ControlLeft", location: KeyboardEvent.DOM_KEY_LOCATION_LEFT },
{ code: "ControlRight", location: KeyboardEvent.DOM_KEY_LOCATION_RIGHT },
{ code: "Enter", location: KeyboardEvent.DOM_KEY_LOCATION_STANDARD },
{ code: "MetaLeft", location: KeyboardEvent.DOM_KEY_LOCATION_LEFT },
{ code: "MetaRight", location: KeyboardEvent.DOM_KEY_LOCATION_RIGHT },
{ code: "OSLeft", location: KeyboardEvent.DOM_KEY_LOCATION_LEFT },
{ code: "OSRight", location: KeyboardEvent.DOM_KEY_LOCATION_RIGHT },
{ code: "ShiftLeft", location: KeyboardEvent.DOM_KEY_LOCATION_LEFT },
{ code: "ShiftRight", location: KeyboardEvent.DOM_KEY_LOCATION_RIGHT },
{ code: "Space", location: KeyboardEvent.DOM_KEY_LOCATION_STANDARD },
Expand Down Expand Up @@ -2937,6 +2937,7 @@ function runKeyTests()
{ key: "PrintScreen", keyCode: KeyboardEvent.DOM_VK_PRINTSCREEN },
{ key: "Insert", keyCode: KeyboardEvent.DOM_VK_INSERT },
{ key: "Delete", keyCode: KeyboardEvent.DOM_VK_DELETE },
{ key: "OS", keyCode: KeyboardEvent.DOM_VK_WIN, isModifier: true },
{ key: "ContextMenu", keyCode: KeyboardEvent.DOM_VK_CONTEXT_MENU },
{ key: "F1", keyCode: KeyboardEvent.DOM_VK_F1 },
{ key: "F2", keyCode: KeyboardEvent.DOM_VK_F2 },
Expand Down Expand Up @@ -2967,9 +2968,7 @@ function runKeyTests()
{ key: "AudioVolumeMute", keyCode: KeyboardEvent.DOM_VK_VOLUME_MUTE },
{ key: "AudioVolumeDown", keyCode: KeyboardEvent.DOM_VK_VOLUME_DOWN },
{ key: "AudioVolumeUp", keyCode: KeyboardEvent.DOM_VK_VOLUME_UP },
{ key: "Meta", keyCode: kIsMac
? KeyboardEvent.DOM_VK_META
: KeyboardEvent.DOM_VK_WIN, isModifier: true },
{ key: "Meta", keyCode: KeyboardEvent.DOM_VK_META, isModifier: true },
{ key: "AltGraph", keyCode: KeyboardEvent.DOM_VK_ALTGR, isModifier: true },
{ key: "Attn", keyCode: KeyboardEvent.DOM_VK_ATTN },
{ key: "CrSel", keyCode: KeyboardEvent.DOM_VK_CRSEL },
Expand Down Expand Up @@ -3049,14 +3048,16 @@ function runKeyTests()
{ key: "Control", code: "ControlRight", isLockable: false },
{ key: "Fn", code: "Fn", isLockable: false },
{ key: "FnLock", code: "", isLockable: true },
{ key: "Meta", code: "MetaLeft", isLockable: false },
{ key: "Meta", code: "MetaRight", isLockable: false },
{ key: "Meta", code: "OSLeft", isLockable: false },
{ key: "Meta", code: "OSRight", isLockable: false },
{ key: "NumLock", code: "NumLock", isLockable: true },
{ key: "ScrollLock", code: "ScrollLock", isLockable: true },
{ key: "Shift", code: "ShiftLeft", isLockable: false },
{ key: "Shift", code: "ShiftRight", isLockable: false },
{ key: "Symbol", code: "", isLockable: false },
{ key: "SymbolLock", code: "", isLockable: true },
{ key: "OS", code: "OSLeft", isLockable: false },
{ key: "OS", code: "OSRight", isLockable: false },
];

function checkModifiers(aTestDesc, aEvent, aType, aKey, aCode, aModifiers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,9 +56,13 @@
let tests = [ [ 'a', { altKey: true }, false],
[ 'a', { ctrlKey: true }, false],
[ 'a', { metaKey: true }, false],
[ 'a', { osKey: true }, false],
[ 'c', { altKey: true }, false ],
[ 'c', { osKey: true }, false ],
[ 'v', { altKey: true }, false ],
[ 'v', { osKey: true }, false ],
[ 'x', { altKey: true }, false ],
[ 'x', { osKey: true }, false ],
// Treat as user input
[ 'a', { altGraphKey: true }, true ],
[ 'a', { fnKey: true }, true ],
Expand Down
18 changes: 14 additions & 4 deletions dom/events/EventStateManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ bool EventStateManager::IsKeyboardEventUserActivity(WidgetEvent* aEvent) {
return true;
}
if (!keyEvent->CanTreatAsUserInput() || keyEvent->IsControl() ||
keyEvent->IsMeta() || keyEvent->IsAlt()) {
keyEvent->IsMeta() || keyEvent->IsOS() || keyEvent->IsAlt()) {
return false;
}
// Deal with function keys:
Expand Down Expand Up @@ -1329,7 +1329,11 @@ void EventStateManager::GetAccessKeyLabelPrefix(Element* aElement,
aPrefix.Append(modifierText + separator);
}
if (modifiers & MODIFIER_META) {
nsContentUtils::GetCommandOrWinText(modifierText);
nsContentUtils::GetMetaText(modifierText);
aPrefix.Append(modifierText + separator);
}
if (modifiers & MODIFIER_OS) {
nsContentUtils::GetOSText(modifierText);
aPrefix.Append(modifierText + separator);
}
if (modifiers & MODIFIER_ALT) {
Expand Down Expand Up @@ -6468,8 +6472,9 @@ EventStateManager::WheelPrefs::Index EventStateManager::WheelPrefs::GetIndexFor(
return INDEX_DEFAULT;
}

Modifiers modifiers = (aEvent->mModifiers & (MODIFIER_ALT | MODIFIER_CONTROL |
MODIFIER_META | MODIFIER_SHIFT));
Modifiers modifiers =
(aEvent->mModifiers & (MODIFIER_ALT | MODIFIER_CONTROL | MODIFIER_META |
MODIFIER_SHIFT | MODIFIER_OS));

switch (modifiers) {
case MODIFIER_ALT:
Expand All @@ -6480,6 +6485,8 @@ EventStateManager::WheelPrefs::Index EventStateManager::WheelPrefs::GetIndexFor(
return INDEX_META;
case MODIFIER_SHIFT:
return INDEX_SHIFT;
case MODIFIER_OS:
return INDEX_OS;
default:
// If two or more modifier keys are pressed, we should use default
// settings.
Expand All @@ -6503,6 +6510,9 @@ void EventStateManager::WheelPrefs::GetBasePrefName(
case INDEX_SHIFT:
aBasePrefName.AppendLiteral("with_shift.");
break;
case INDEX_OS:
aBasePrefName.AppendLiteral("with_win.");
break;
case INDEX_DEFAULT:
default:
aBasePrefName.AppendLiteral("default.");
Expand Down
9 changes: 5 additions & 4 deletions dom/events/EventStateManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -688,16 +688,17 @@ class EventStateManager : public nsSupportsWeakReference, public nsIObserver {
INDEX_CONTROL,
INDEX_META,
INDEX_SHIFT,
INDEX_OS,
COUNT_OF_MULTIPLIERS
};

/**
* GetIndexFor() returns the index of the members which should be used for
* the aEvent. When only one modifier key of MODIFIER_ALT,
* MODIFIER_CONTROL, MODIFIER_META or MODIFIER_SHIFT is pressed, returns the
* index for the modifier. Otherwise, this return the default index which
* is used at either no modifier key is pressed or two or modifier keys are
* pressed.
* MODIFIER_CONTROL, MODIFIER_META, MODIFIER_SHIFT or MODIFIER_OS is
* pressed, returns the index for the modifier. Otherwise, this return the
* default index which is used at either no modifier key is pressed or
* two or modifier keys are pressed.
*/
Index GetIndexFor(const WidgetWheelEvent* aEvent);

Expand Down
4 changes: 2 additions & 2 deletions dom/events/GlobalKeyListener.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -377,9 +377,9 @@ bool GlobalKeyListener::WalkHandlersAndExecute(
// shortcut keys even if the key is pressed. Therefore, if there is no
// shortcut key which exactly matches current modifier state, we should
// retry to look for a shortcut key without the Windows-Logo key press.
if (!aIgnoreModifierState.mMeta && widgetKeyboardEvent->IsMeta()) {
if (!aIgnoreModifierState.mOS && widgetKeyboardEvent->IsOS()) {
IgnoreModifierState ignoreModifierState(aIgnoreModifierState);
ignoreModifierState.mMeta = true;
ignoreModifierState.mOS = true;
return WalkHandlersAndExecute(aKeyEvent, aCharCode, ignoreModifierState,
aExecute);
}
Expand Down
Loading

0 comments on commit f5572b4

Please sign in to comment.