Skip to content
Snippets Groups Projects
Commit 383b8e7e authored by Arthur Edelstein's avatar Arthur Edelstein Committed by Georg Koppen
Browse files

Bug 17009: Pref to suppress some modifier key events

parent a65b5269
No related merge requests found
......@@ -1813,6 +1813,9 @@ protected:
// to true, so we can avoid any paint calls for widget related to this
// presshell.
bool mIsNeverPainting;
// If true, don't report Alt, Shift, and AltGr KeyboardEvents to content.
static bool sSuppressModifierKeyEvents;
};
NS_DEFINE_STATIC_IID_ACCESSOR(nsIPresShell, NS_IPRESSHELL_IID)
......
......@@ -209,6 +209,7 @@ CapturingContentInfo nsIPresShell::gCaptureInfo =
nsIContent* nsIPresShell::gKeyDownTarget;
nsClassHashtable<nsUint32HashKey, nsIPresShell::PointerCaptureInfo>* nsIPresShell::gPointerCaptureList;
nsClassHashtable<nsUint32HashKey, nsIPresShell::PointerInfo>* nsIPresShell::gActivePointersIds;
bool nsIPresShell::sSuppressModifierKeyEvents = false;
// RangePaintInfo is used to paint ranges to offscreen buffers
struct RangePaintInfo {
......@@ -6881,6 +6882,16 @@ PresShell::HandleKeyboardEvent(nsINode* aTarget,
nsEventStatus* aStatus,
EventDispatchingCallback* aEventCB)
{
if (nsContentUtils::ResistFingerprinting() && sSuppressModifierKeyEvents) {
nsString keyName;
aEvent.GetDOMKeyName(keyName);
if (keyName.Equals(NS_LITERAL_STRING("Shift")) ||
keyName.Equals(NS_LITERAL_STRING("Alt")) ||
keyName.Equals(NS_LITERAL_STRING("AltGraph"))) {
aEvent.mFlags.mOnlyChromeDispatch = true;
}
}
if (aEvent.mMessage == eKeyPress ||
!BeforeAfterKeyboardEventEnabled()) {
EventDispatcher::Dispatch(aTarget, mPresContext,
......@@ -10545,6 +10556,8 @@ void nsIPresShell::InitializeStatics()
NS_ASSERTION(!gPointerCaptureList, "InitializeStatics called multiple times!");
gPointerCaptureList = new nsClassHashtable<nsUint32HashKey, PointerCaptureInfo>;
gActivePointersIds = new nsClassHashtable<nsUint32HashKey, PointerInfo>;
Preferences::AddBoolVarCache(&sSuppressModifierKeyEvents,
"privacy.suppressModifierKeyEvents", false);
}
void nsIPresShell::ReleaseStatics()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment